Add sh2e support:
[official-gcc.git] / gcc / toplev.c
blob33997052b1b893eb2d65354229f19e0386534086
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"
77 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
78 #include "dwarf2out.h"
79 #endif
81 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
82 #include "dbxout.h"
83 #endif
85 #ifdef SDB_DEBUGGING_INFO
86 #include "sdbout.h"
87 #endif
89 #ifdef XCOFF_DEBUGGING_INFO
90 #include "xcoffout.h" /* Needed for external data
91 declarations for e.g. AIX 4.x. */
92 #endif
94 /* Carry information from ASM_DECLARE_OBJECT_NAME
95 to ASM_FINISH_DECLARE_OBJECT. */
97 extern int size_directive_output;
98 extern tree last_assemble_variable_decl;
100 extern void reg_alloc PARAMS ((void));
102 static void general_init PARAMS ((char *));
103 static void parse_options_and_default_flags PARAMS ((int, char **));
104 static void do_compile PARAMS ((void));
105 static void process_options PARAMS ((void));
106 static void backend_init PARAMS ((void));
107 static int lang_dependent_init PARAMS ((const char *));
108 static void init_asm_output PARAMS ((const char *));
109 static void finalize PARAMS ((void));
111 static void set_target_switch PARAMS ((const char *));
113 static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
114 static void compile_file PARAMS ((void));
115 static void display_help PARAMS ((void));
116 static void display_target_options PARAMS ((void));
118 static void decode_d_option PARAMS ((const char *));
119 static int decode_f_option PARAMS ((const char *));
120 static int decode_W_option PARAMS ((const char *));
121 static int decode_g_option PARAMS ((const char *));
122 static unsigned int independent_decode_option PARAMS ((int, char **));
124 static void print_version PARAMS ((FILE *, const char *));
125 static int print_single_switch PARAMS ((FILE *, int, int, const char *,
126 const char *, const char *,
127 const char *, const char *));
128 static void print_switch_values PARAMS ((FILE *, int, int, const char *,
129 const char *, const char *));
131 /* Nonzero to dump debug info whilst parsing (-dy option). */
132 static int set_yydebug;
134 /* Length of line when printing switch values. */
135 #define MAX_LINE 75
137 /* Name of program invoked, sans directories. */
139 const char *progname;
141 /* Copy of arguments to toplev_main. */
142 int save_argc;
143 char **save_argv;
145 /* Name of current original source file (what was input to cpp).
146 This comes from each #-command in the actual input. */
148 const char *input_filename;
150 /* Name of top-level original source file (what was input to cpp).
151 This comes from the #-command at the beginning of the actual input.
152 If there isn't any there, then this is the cc1 input file name. */
154 const char *main_input_filename;
156 /* Current line number in real source file. */
158 int lineno;
160 /* Nonzero if it is unsafe to create any new pseudo registers. */
161 int no_new_pseudos;
163 /* Stack of currently pending input files. */
165 struct file_stack *input_file_stack;
167 /* Incremented on each change to input_file_stack. */
168 int input_file_stack_tick;
170 /* Name to use as base of names for dump output files. */
172 const char *dump_base_name;
174 /* Name to use as a base for auxiliary output files. */
176 const char *aux_base_name;
178 /* Format to use to print dumpfile index value */
179 #ifndef DUMPFILE_FORMAT
180 #define DUMPFILE_FORMAT ".%02d."
181 #endif
183 /* Bit flags that specify the machine subtype we are compiling for.
184 Bits are tested using macros TARGET_... defined in the tm.h file
185 and set by `-m...' switches. Must be defined in rtlanal.c. */
187 extern int target_flags;
189 /* A mask of target_flags that includes bit X if X was set or cleared
190 on the command line. */
192 int target_flags_explicit;
194 /* Debug hooks - dependent upon command line options. */
196 const struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks;
198 /* Describes a dump file. */
200 struct dump_file_info
202 /* The unique extension to apply, e.g. ".jump". */
203 const char *const extension;
205 /* The -d<c> character that enables this dump file. */
206 char const debug_switch;
208 /* True if there is a corresponding graph dump file. */
209 char const graph_dump_p;
211 /* True if the user selected this dump. */
212 char enabled;
214 /* True if the files have been initialized (ie truncated). */
215 char initialized;
218 /* Enumerate the extant dump files. */
220 enum dump_file_index
222 DFI_rtl,
223 DFI_sibling,
224 DFI_eh,
225 DFI_jump,
226 DFI_ssa,
227 DFI_ssa_ccp,
228 DFI_ssa_dce,
229 DFI_ussa,
230 DFI_null,
231 DFI_cse,
232 DFI_addressof,
233 DFI_gcse,
234 DFI_loop,
235 DFI_bypass,
236 DFI_cfg,
237 DFI_bp,
238 DFI_ce1,
239 DFI_tracer,
240 DFI_cse2,
241 DFI_life,
242 DFI_combine,
243 DFI_ce2,
244 DFI_regmove,
245 DFI_sched,
246 DFI_lreg,
247 DFI_greg,
248 DFI_postreload,
249 DFI_flow2,
250 DFI_peephole2,
251 DFI_rnreg,
252 DFI_ce3,
253 DFI_sched2,
254 DFI_stack,
255 DFI_bbro,
256 DFI_mach,
257 DFI_dbr,
258 DFI_MAX
261 /* Describes all the dump files. Should be kept in order of the
262 pass and in sync with dump_file_index above.
264 Remaining -d letters:
266 " o q "
267 " H JK OPQ TUV YZ"
270 static struct dump_file_info dump_file[DFI_MAX] =
272 { "rtl", 'r', 0, 0, 0 },
273 { "sibling", 'i', 0, 0, 0 },
274 { "eh", 'h', 0, 0, 0 },
275 { "jump", 'j', 0, 0, 0 },
276 { "ssa", 'e', 1, 0, 0 },
277 { "ssaccp", 'W', 1, 0, 0 },
278 { "ssadce", 'X', 1, 0, 0 },
279 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
280 { "null", 'u', 0, 0, 0 },
281 { "cse", 's', 0, 0, 0 },
282 { "addressof", 'F', 0, 0, 0 },
283 { "gcse", 'G', 1, 0, 0 },
284 { "loop", 'L', 1, 0, 0 },
285 { "bypass", 'G', 1, 0, 0 }, /* Yes, duplicate enable switch. */
286 { "cfg", 'f', 1, 0, 0 },
287 { "bp", 'b', 1, 0, 0 },
288 { "ce1", 'C', 1, 0, 0 },
289 { "tracer", 'T', 1, 0, 0 },
290 { "cse2", 't', 1, 0, 0 },
291 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
292 { "combine", 'c', 1, 0, 0 },
293 { "ce2", 'C', 1, 0, 0 },
294 { "regmove", 'N', 1, 0, 0 },
295 { "sched", 'S', 1, 0, 0 },
296 { "lreg", 'l', 1, 0, 0 },
297 { "greg", 'g', 1, 0, 0 },
298 { "postreload", 'o', 1, 0, 0 },
299 { "flow2", 'w', 1, 0, 0 },
300 { "peephole2", 'z', 1, 0, 0 },
301 { "rnreg", 'n', 1, 0, 0 },
302 { "ce3", 'E', 1, 0, 0 },
303 { "sched2", 'R', 1, 0, 0 },
304 { "stack", 'k', 1, 0, 0 },
305 { "bbro", 'B', 1, 0, 0 },
306 { "mach", 'M', 1, 0, 0 },
307 { "dbr", 'd', 0, 0, 0 },
310 static int open_dump_file PARAMS ((enum dump_file_index, tree));
311 static void close_dump_file PARAMS ((enum dump_file_index,
312 void (*) (FILE *, rtx), rtx));
314 /* Other flags saying which kinds of debugging dump have been requested. */
316 int rtl_dump_and_exit;
317 int flag_print_asm_name;
318 static int version_flag;
319 static char *filename;
320 enum graph_dump_types graph_dump_format;
322 /* Name for output file of assembly code, specified with -o. */
324 char *asm_file_name;
326 /* Value of the -G xx switch, and whether it was passed or not. */
327 int g_switch_value;
328 int g_switch_set;
330 /* Type(s) of debugging information we are producing (if any).
331 See flags.h for the definitions of the different possible
332 types of debugging information. */
333 enum debug_info_type write_symbols = NO_DEBUG;
335 /* Level of debugging information we are producing. See flags.h
336 for the definitions of the different possible levels. */
337 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
339 /* Nonzero means use GNU-only extensions in the generated symbolic
340 debugging information. */
341 /* Currently, this only has an effect when write_symbols is set to
342 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
343 int use_gnu_debug_info_extensions = 0;
345 /* Nonzero means do optimizations. -O.
346 Particular numeric values stand for particular amounts of optimization;
347 thus, -O2 stores 2 here. However, the optimizations beyond the basic
348 ones are not controlled directly by this variable. Instead, they are
349 controlled by individual `flag_...' variables that are defaulted
350 based on this variable. */
352 int optimize = 0;
354 /* Nonzero means optimize for size. -Os.
355 The only valid values are zero and nonzero. When optimize_size is
356 nonzero, optimize defaults to 2, but certain individual code
357 bloating optimizations are disabled. */
359 int optimize_size = 0;
361 /* Nonzero if we should exit after parsing options. */
362 static int exit_after_options = 0;
364 /* The FUNCTION_DECL for the function currently being compiled,
365 or 0 if between functions. */
366 tree current_function_decl;
368 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
369 if none. */
370 tree current_function_func_begin_label;
372 /* Nonzero if doing dwarf2 duplicate elimination. */
374 int flag_eliminate_dwarf2_dups = 0;
376 /* Nonzero if generating code to do profiling. */
378 int profile_flag = 0;
380 /* Nonzero if generating code to profile program flow graph arcs. */
382 int profile_arc_flag = 0;
384 /* Nonzero if generating info for gcov to calculate line test coverage. */
386 int flag_test_coverage = 0;
388 /* Nonzero indicates that branch taken probabilities should be calculated. */
390 int flag_branch_probabilities = 0;
392 /* Nonzero if basic blocks should be reordered. */
394 int flag_reorder_blocks = 0;
396 /* Nonzero if functions should be reordered. */
398 int flag_reorder_functions = 0;
400 /* Nonzero if registers should be renamed. */
402 int flag_rename_registers = 0;
403 int flag_cprop_registers = 0;
405 /* Nonzero for -pedantic switch: warn about anything
406 that standard spec forbids. */
408 int pedantic = 0;
410 /* Temporarily suppress certain warnings.
411 This is set while reading code from a system header file. */
413 int in_system_header = 0;
415 /* Don't print functions as they are compiled. -quiet. */
417 int quiet_flag = 0;
419 /* Print times taken by the various passes. -ftime-report. */
421 int time_report = 0;
423 /* Print memory still in use at end of compilation (which may have little
424 to do with peak memory consumption). -fmem-report. */
426 int mem_report = 0;
428 /* Nonzero means to collect statistics which might be expensive
429 and to print them when we are done. */
430 int flag_detailed_statistics = 0;
433 /* -f flags. */
435 /* Nonzero means `char' should be signed. */
437 int flag_signed_char;
439 /* Nonzero means give an enum type only as many bytes as it needs. */
441 int flag_short_enums;
443 /* Nonzero for -fcaller-saves: allocate values in regs that need to
444 be saved across function calls, if that produces overall better code.
445 Optional now, so people can test it. */
447 #ifdef DEFAULT_CALLER_SAVES
448 int flag_caller_saves = 1;
449 #else
450 int flag_caller_saves = 0;
451 #endif
453 /* Nonzero if structures and unions should be returned in memory.
455 This should only be defined if compatibility with another compiler or
456 with an ABI is needed, because it results in slower code. */
458 #ifndef DEFAULT_PCC_STRUCT_RETURN
459 #define DEFAULT_PCC_STRUCT_RETURN 1
460 #endif
462 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
464 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
466 /* Nonzero for -fforce-mem: load memory value into a register
467 before arithmetic on it. This makes better cse but slower compilation. */
469 int flag_force_mem = 0;
471 /* Nonzero for -fforce-addr: load memory address into a register before
472 reference to memory. This makes better cse but slower compilation. */
474 int flag_force_addr = 0;
476 /* Nonzero for -fdefer-pop: don't pop args after each function call;
477 instead save them up to pop many calls' args with one insns. */
479 int flag_defer_pop = 0;
481 /* Nonzero for -ffloat-store: don't allocate floats and doubles
482 in extended-precision registers. */
484 int flag_float_store = 0;
486 /* Nonzero for -fcse-follow-jumps:
487 have cse follow jumps to do a more extensive job. */
489 int flag_cse_follow_jumps;
491 /* Nonzero for -fcse-skip-blocks:
492 have cse follow a branch around a block. */
493 int flag_cse_skip_blocks;
495 /* Nonzero for -fexpensive-optimizations:
496 perform miscellaneous relatively-expensive optimizations. */
497 int flag_expensive_optimizations;
499 /* Nonzero for -fthread-jumps:
500 have jump optimize output of loop. */
502 int flag_thread_jumps;
504 /* Nonzero enables strength-reduction in loop.c. */
506 int flag_strength_reduce = 0;
508 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
509 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
510 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
511 unrolled. */
513 int flag_unroll_loops;
515 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
516 This is generally not a win. */
518 int flag_unroll_all_loops;
520 /* Nonzero enables prefetch optimizations for arrays in loops. */
522 int flag_prefetch_loop_arrays;
524 /* Nonzero forces all invariant computations in loops to be moved
525 outside the loop. */
527 int flag_move_all_movables = 0;
529 /* Nonzero forces all general induction variables in loops to be
530 strength reduced. */
532 int flag_reduce_all_givs = 0;
534 /* Nonzero to perform full register move optimization passes. This is the
535 default for -O2. */
537 int flag_regmove = 0;
539 /* Nonzero for -fwritable-strings:
540 store string constants in data segment and don't uniquize them. */
542 int flag_writable_strings = 0;
544 /* Nonzero means don't put addresses of constant functions in registers.
545 Used for compiling the Unix kernel, where strange substitutions are
546 done on the assembly output. */
548 int flag_no_function_cse = 0;
550 /* Nonzero for -fomit-frame-pointer:
551 don't make a frame pointer in simple functions that don't require one. */
553 int flag_omit_frame_pointer = 0;
555 /* Nonzero means place each function into its own section on those platforms
556 which support arbitrary section names and unlimited numbers of sections. */
558 int flag_function_sections = 0;
560 /* ... and similar for data. */
562 int flag_data_sections = 0;
564 /* Nonzero to inhibit use of define_optimization peephole opts. */
566 int flag_no_peephole = 0;
568 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
570 int flag_optimize_sibling_calls = 0;
572 /* Nonzero means the front end generally wants `errno' maintained by math
573 operations, like built-in SQRT. */
575 int flag_errno_math = 1;
577 /* Nonzero means that unsafe floating-point math optimizations are allowed
578 for the sake of speed. IEEE compliance is not guaranteed, and operations
579 are allowed to assume that their arguments and results are "normal"
580 (e.g., nonnegative for SQRT). */
582 int flag_unsafe_math_optimizations = 0;
584 /* Nonzero means that no NaNs or +-Infs are expected. */
586 int flag_finite_math_only = 0;
588 /* Zero means that floating-point math operations cannot generate a
589 (user-visible) trap. This is the case, for example, in nonstop
590 IEEE 754 arithmetic. Trapping conditions include division by zero,
591 overflow, underflow, invalid and inexact, but does not include
592 operations on signaling NaNs (see below). */
594 int flag_trapping_math = 1;
596 /* Nonzero means disable transformations observable by signaling NaNs.
597 This option implies that any operation on a IEEE signaling NaN can
598 generate a (user-visible) trap. */
600 int flag_signaling_nans = 0;
602 /* 0 means straightforward implementation of complex divide acceptable.
603 1 means wide ranges of inputs must work for complex divide.
604 2 means C99-like requirements for complex divide (not yet implemented). */
606 int flag_complex_divide_method = 0;
608 /* Nonzero means all references through pointers are volatile. */
610 int flag_volatile;
612 /* Nonzero means treat all global and extern variables as volatile. */
614 int flag_volatile_global;
616 /* Nonzero means treat all static variables as volatile. */
618 int flag_volatile_static;
620 /* Nonzero means just do syntax checking; don't output anything. */
622 int flag_syntax_only = 0;
624 /* Nonzero means perform loop optimizer. */
626 static int flag_loop_optimize;
628 /* Nonzero means perform crossjumping. */
630 static int flag_crossjumping;
632 /* Nonzero means perform if conversion. */
634 static int flag_if_conversion;
636 /* Nonzero means perform if conversion after reload. */
638 static int flag_if_conversion2;
640 /* Nonzero means to use global dataflow analysis to eliminate
641 useless null pointer tests. */
643 static int flag_delete_null_pointer_checks;
645 /* Nonzero means perform global CSE. */
647 int flag_gcse = 0;
649 /* Nonzero means to do the enhanced load motion during gcse, which trys
650 to hoist loads by not killing them when a store to the same location
651 is seen. */
653 int flag_gcse_lm = 1;
655 /* Nonzero means to perform store motion after gcse, which will try to
656 move stores closer to the exit block. Its not very effective without
657 flag_gcse_lm. */
659 int flag_gcse_sm = 1;
661 /* Nonzero means to rerun cse after loop optimization. This increases
662 compilation time about 20% and picks up a few more common expressions. */
664 static int flag_rerun_cse_after_loop;
666 /* Nonzero means to run loop optimizations twice. */
668 int flag_rerun_loop_opt;
670 /* Nonzero for -finline-functions: ok to inline functions that look like
671 good inline candidates. */
673 int flag_inline_functions;
675 /* Nonzero for -fkeep-inline-functions: even if we make a function
676 go inline everywhere, keep its definition around for debugging
677 purposes. */
679 int flag_keep_inline_functions;
681 /* Nonzero means that functions will not be inlined. */
683 int flag_no_inline = 2;
685 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
686 not just because the tree inliner turned us off. */
688 int flag_really_no_inline = 2;
690 /* Nonzero means that we should emit static const variables
691 regardless of whether or not optimization is turned on. */
693 int flag_keep_static_consts = 1;
695 /* Nonzero means we should be saving declaration info into a .X file. */
697 int flag_gen_aux_info = 0;
699 /* Specified name of aux-info file. */
701 static char *aux_info_file_name;
703 /* Nonzero means make the text shared if supported. */
705 int flag_shared_data;
707 /* Nonzero means schedule into delayed branch slots if supported. */
709 int flag_delayed_branch;
711 /* Nonzero if we are compiling pure (sharable) code.
712 Value is 1 if we are doing "small" pic; value is 2 if we're doing
713 "large" pic. */
715 int flag_pic;
717 /* Set to the default thread-local storage (tls) model to use. */
719 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
721 /* Nonzero means generate extra code for exception handling and enable
722 exception handling. */
724 int flag_exceptions;
726 /* Nonzero means generate frame unwind info table when supported. */
728 int flag_unwind_tables = 0;
730 /* Nonzero means generate frame unwind info table exact at each insn boundary */
732 int flag_asynchronous_unwind_tables = 0;
734 /* Nonzero means don't place uninitialized global data in common storage
735 by default. */
737 int flag_no_common;
739 /* Nonzero means change certain warnings into errors.
740 Usually these are warnings about failure to conform to some standard. */
742 int flag_pedantic_errors = 0;
744 /* flag_schedule_insns means schedule insns within basic blocks (before
745 local_alloc).
746 flag_schedule_insns_after_reload means schedule insns after
747 global_alloc. */
749 int flag_schedule_insns = 0;
750 int flag_schedule_insns_after_reload = 0;
752 /* The following flags have effect only for scheduling before register
753 allocation:
755 flag_schedule_interblock means schedule insns across basic blocks.
756 flag_schedule_speculative means allow speculative motion of non-load insns.
757 flag_schedule_speculative_load means allow speculative motion of some
758 load insns.
759 flag_schedule_speculative_load_dangerous allows speculative motion of more
760 load insns. */
762 int flag_schedule_interblock = 1;
763 int flag_schedule_speculative = 1;
764 int flag_schedule_speculative_load = 0;
765 int flag_schedule_speculative_load_dangerous = 0;
767 int flag_single_precision_constant;
769 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
770 by a cheaper branch on a count register. */
771 int flag_branch_on_count_reg = 1;
773 /* -finhibit-size-directive inhibits output of .size for ELF.
774 This is used only for compiling crtstuff.c,
775 and it may be extended to other effects
776 needed for crtstuff.c on other systems. */
777 int flag_inhibit_size_directive = 0;
779 /* -fverbose-asm causes extra commentary information to be produced in
780 the generated assembly code (to make it more readable). This option
781 is generally only of use to those who actually need to read the
782 generated assembly code (perhaps while debugging the compiler itself).
783 -fno-verbose-asm, the default, causes the extra information
784 to be omitted and is useful when comparing two assembler files. */
786 int flag_verbose_asm = 0;
788 /* -dA causes debug commentary information to be produced in
789 the generated assembly code (to make it more readable). This option
790 is generally only of use to those who actually need to read the
791 generated assembly code (perhaps while debugging the compiler itself).
792 Currently, this switch is only used by dwarfout.c; however, it is intended
793 to be a catchall for printing debug information in the assembler file. */
795 int flag_debug_asm = 0;
797 /* -dP causes the rtl to be emitted as a comment in assembly. */
799 int flag_dump_rtl_in_asm = 0;
801 /* -fgnu-linker specifies use of the GNU linker for initializations.
802 (Or, more generally, a linker that handles initializations.)
803 -fno-gnu-linker says that collect2 will be used. */
804 #ifdef USE_COLLECT2
805 int flag_gnu_linker = 0;
806 #else
807 int flag_gnu_linker = 1;
808 #endif
810 /* Nonzero means put zero initialized data in the bss section. */
811 int flag_zero_initialized_in_bss = 1;
813 /* Enable SSA. */
814 int flag_ssa = 0;
816 /* Enable ssa conditional constant propagation. */
817 int flag_ssa_ccp = 0;
819 /* Enable ssa aggressive dead code elimination. */
820 int flag_ssa_dce = 0;
822 /* Tag all structures with __attribute__(packed). */
823 int flag_pack_struct = 0;
825 /* Emit code to check for stack overflow; also may cause large objects
826 to be allocated dynamically. */
827 int flag_stack_check;
829 /* When non-NULL, indicates that whenever space is allocated on the
830 stack, the resulting stack pointer must not pass this
831 address---that is, for stacks that grow downward, the stack pointer
832 must always be greater than or equal to this address; for stacks
833 that grow upward, the stack pointer must be less than this address.
834 At present, the rtx may be either a REG or a SYMBOL_REF, although
835 the support provided depends on the backend. */
836 rtx stack_limit_rtx;
838 /* 0 if pointer arguments may alias each other. True in C.
839 1 if pointer arguments may not alias each other but may alias
840 global variables.
841 2 if pointer arguments may not alias each other and may not
842 alias global variables. True in Fortran.
843 This defaults to 0 for C. */
844 int flag_argument_noalias = 0;
846 /* Nonzero if we should do (language-dependent) alias analysis.
847 Typically, this analysis will assume that expressions of certain
848 types do not alias expressions of certain other types. Only used
849 if alias analysis (in general) is enabled. */
850 int flag_strict_aliasing = 0;
852 /* Instrument functions with calls at entry and exit, for profiling. */
853 int flag_instrument_function_entry_exit = 0;
855 /* Nonzero means ignore `#ident' directives. 0 means handle them.
856 On SVR4 targets, it also controls whether or not to emit a
857 string identifying the compiler. */
859 int flag_no_ident = 0;
861 /* This will perform a peephole pass before sched2. */
862 int flag_peephole2 = 0;
864 /* This will try to guess branch probabilities. */
865 int flag_guess_branch_prob = 0;
867 /* -fcheck-bounds causes gcc to generate array bounds checks.
868 For C, C++, ObjC: defaults to off.
869 For Java: defaults to on.
870 For Fortran: defaults to off. */
871 int flag_bounds_check = 0;
873 /* This will attempt to merge constant section constants, if 1 only
874 string constants and constants from constant pool, if 2 also constant
875 variables. */
876 int flag_merge_constants = 1;
878 /* If one, renumber instruction UIDs to reduce the number of
879 unused UIDs if there are a lot of instructions. If greater than
880 one, unconditionally renumber instruction UIDs. */
881 int flag_renumber_insns = 1;
883 /* If nonzero, use the graph coloring register allocator. */
884 int flag_new_regalloc = 0;
886 /* Nonzero if we perform superblock formation. */
888 int flag_tracer = 0;
890 /* Values of the -falign-* flags: how much to align labels in code.
891 0 means `use default', 1 means `don't align'.
892 For each variable, there is an _log variant which is the power
893 of two not less than the variable, for .align output. */
895 int align_loops;
896 int align_loops_log;
897 int align_loops_max_skip;
898 int align_jumps;
899 int align_jumps_log;
900 int align_jumps_max_skip;
901 int align_labels;
902 int align_labels_log;
903 int align_labels_max_skip;
904 int align_functions;
905 int align_functions_log;
907 /* Like align_functions_log above, but used by front-ends to force the
908 minimum function alignment. Zero means no alignment is forced. */
909 int force_align_functions_log;
911 /* Table of supported debugging formats. */
912 static const struct
914 const char *const arg;
915 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
916 constant expression, we use NO_DEBUG in its place. */
917 const enum debug_info_type debug_type;
918 const int use_extensions_p;
919 const char *const description;
920 } *da,
921 debug_args[] =
923 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
924 N_("Generate debugging info in default format") },
925 { "gdb", NO_DEBUG, 1, N_("Generate debugging info in default extended format") },
926 #ifdef DBX_DEBUGGING_INFO
927 { "stabs", DBX_DEBUG, 0, N_("Generate STABS format debug info") },
928 { "stabs+", DBX_DEBUG, 1, N_("Generate extended STABS format debug info") },
929 #endif
930 #ifdef DWARF_DEBUGGING_INFO
931 { "dwarf", DWARF_DEBUG, 0, N_("Generate DWARF-1 format debug info") },
932 { "dwarf+", DWARF_DEBUG, 1,
933 N_("Generate extended DWARF-1 format debug info") },
934 #endif
935 #ifdef DWARF2_DEBUGGING_INFO
936 { "dwarf-2", DWARF2_DEBUG, 0, N_("Generate DWARF-2 debug info") },
937 #endif
938 #ifdef XCOFF_DEBUGGING_INFO
939 { "xcoff", XCOFF_DEBUG, 0, N_("Generate XCOFF format debug info") },
940 { "xcoff+", XCOFF_DEBUG, 1, N_("Generate extended XCOFF format debug info") },
941 #endif
942 #ifdef SDB_DEBUGGING_INFO
943 { "coff", SDB_DEBUG, 0, N_("Generate COFF format debug info") },
944 #endif
945 #ifdef VMS_DEBUGGING_INFO
946 { "vms", VMS_DEBUG, 0, N_("Generate VMS format debug info") },
947 #endif
948 { 0, 0, 0, 0 }
951 typedef struct
953 const char *const string;
954 int *const variable;
955 const int on_value;
956 const char *const description;
958 lang_independent_options;
960 int flag_trapv = 0;
962 /* Add or remove a leading underscore from user symbols. */
963 int flag_leading_underscore = -1;
965 /* The user symbol prefix after having resolved same. */
966 const char *user_label_prefix;
968 static const param_info lang_independent_params[] = {
969 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
970 { OPTION, DEFAULT, HELP },
971 #include "params.def"
972 #undef DEFPARAM
973 { NULL, 0, NULL }
976 /* Table of language-independent -f options.
977 STRING is the option name. VARIABLE is the address of the variable.
978 ON_VALUE is the value to store in VARIABLE
979 if `-fSTRING' is seen as an option.
980 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
982 static const lang_independent_options f_options[] =
984 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
985 N_("Perform DWARF2 duplicate elimination") },
986 {"float-store", &flag_float_store, 1,
987 N_("Do not store floats in registers") },
988 {"volatile", &flag_volatile, 1,
989 N_("Consider all mem refs through pointers as volatile") },
990 {"volatile-global", &flag_volatile_global, 1,
991 N_("Consider all mem refs to global data to be volatile") },
992 {"volatile-static", &flag_volatile_static, 1,
993 N_("Consider all mem refs to static data to be volatile") },
994 {"defer-pop", &flag_defer_pop, 1,
995 N_("Defer popping functions args from stack until later") },
996 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
997 N_("When possible do not generate stack frames") },
998 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
999 N_("Optimize sibling and tail recursive calls") },
1000 {"tracer", &flag_tracer, 1,
1001 N_("Perform superblock formation via tail duplication") },
1002 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
1003 N_("When running CSE, follow jumps to their targets") },
1004 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
1005 N_("When running CSE, follow conditional jumps") },
1006 {"expensive-optimizations", &flag_expensive_optimizations, 1,
1007 N_("Perform a number of minor, expensive optimizations") },
1008 {"thread-jumps", &flag_thread_jumps, 1,
1009 N_("Perform jump threading optimizations") },
1010 {"strength-reduce", &flag_strength_reduce, 1,
1011 N_("Perform strength reduction optimizations") },
1012 {"unroll-loops", &flag_unroll_loops, 1,
1013 N_("Perform loop unrolling when iteration count is known") },
1014 {"unroll-all-loops", &flag_unroll_all_loops, 1,
1015 N_("Perform loop unrolling for all loops") },
1016 {"prefetch-loop-arrays", &flag_prefetch_loop_arrays, 1,
1017 N_("Generate prefetch instructions, if available, for arrays in loops") },
1018 {"move-all-movables", &flag_move_all_movables, 1,
1019 N_("Force all loop invariant computations out of loops") },
1020 {"reduce-all-givs", &flag_reduce_all_givs, 1,
1021 N_("Strength reduce all loop general induction variables") },
1022 {"writable-strings", &flag_writable_strings, 1,
1023 N_("Store strings in writable data section") },
1024 {"peephole", &flag_no_peephole, 0,
1025 N_("Enable machine specific peephole optimizations") },
1026 {"force-mem", &flag_force_mem, 1,
1027 N_("Copy memory operands into registers before using") },
1028 {"force-addr", &flag_force_addr, 1,
1029 N_("Copy memory address constants into regs before using") },
1030 {"function-cse", &flag_no_function_cse, 0,
1031 N_("Allow function addresses to be held in registers") },
1032 {"inline-functions", &flag_inline_functions, 1,
1033 N_("Integrate simple functions into their callers") },
1034 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1035 N_("Generate code for funcs even if they are fully inlined") },
1036 {"inline", &flag_no_inline, 0,
1037 N_("Pay attention to the 'inline' keyword") },
1038 {"keep-static-consts", &flag_keep_static_consts, 1,
1039 N_("Emit static const variables even if they are not used") },
1040 {"syntax-only", &flag_syntax_only, 1,
1041 N_("Check for syntax errors, then stop") },
1042 {"shared-data", &flag_shared_data, 1,
1043 N_("Mark data as shared rather than private") },
1044 {"caller-saves", &flag_caller_saves, 1,
1045 N_("Enable saving registers around function calls") },
1046 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1047 N_("Return 'short' aggregates in memory, not registers") },
1048 {"reg-struct-return", &flag_pcc_struct_return, 0,
1049 N_("Return 'short' aggregates in registers") },
1050 {"delayed-branch", &flag_delayed_branch, 1,
1051 N_("Attempt to fill delay slots of branch instructions") },
1052 {"gcse", &flag_gcse, 1,
1053 N_("Perform the global common subexpression elimination") },
1054 {"gcse-lm", &flag_gcse_lm, 1,
1055 N_("Perform enhanced load motion during global subexpression elimination") },
1056 {"gcse-sm", &flag_gcse_sm, 1,
1057 N_("Perform store motion after global subexpression elimination") },
1058 {"loop-optimize", &flag_loop_optimize, 1,
1059 N_("Perform the loop optimizations") },
1060 {"crossjumping", &flag_crossjumping, 1,
1061 N_("Perform cross-jumping optimization") },
1062 {"if-conversion", &flag_if_conversion, 1,
1063 N_("Perform conversion of conditional jumps to branchless equivalents") },
1064 {"if-conversion2", &flag_if_conversion2, 1,
1065 N_("Perform conversion of conditional jumps to conditional execution") },
1066 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1067 N_("Run CSE pass after loop optimizations") },
1068 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1069 N_("Run the loop optimizer twice") },
1070 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1071 N_("Delete useless null pointer checks") },
1072 {"schedule-insns", &flag_schedule_insns, 1,
1073 N_("Reschedule instructions before register allocation") },
1074 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1075 N_("Reschedule instructions after register allocation") },
1076 {"sched-interblock",&flag_schedule_interblock, 1,
1077 N_("Enable scheduling across basic blocks") },
1078 {"sched-spec",&flag_schedule_speculative, 1,
1079 N_("Allow speculative motion of non-loads") },
1080 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1081 N_("Allow speculative motion of some loads") },
1082 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1083 N_("Allow speculative motion of more loads") },
1084 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1085 N_("Replace add,compare,branch with branch on count reg") },
1086 {"pic", &flag_pic, 1,
1087 N_("Generate position independent code, if possible") },
1088 {"PIC", &flag_pic, 2, ""},
1089 {"exceptions", &flag_exceptions, 1,
1090 N_("Enable exception handling") },
1091 {"unwind-tables", &flag_unwind_tables, 1,
1092 N_("Just generate unwind tables for exception handling") },
1093 {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1,
1094 N_("Generate unwind tables exact at each instruction boundary") },
1095 {"non-call-exceptions", &flag_non_call_exceptions, 1,
1096 N_("Support synchronous non-call exceptions") },
1097 {"profile-arcs", &profile_arc_flag, 1,
1098 N_("Insert arc based program profiling code") },
1099 {"test-coverage", &flag_test_coverage, 1,
1100 N_("Create data files needed by gcov") },
1101 {"branch-probabilities", &flag_branch_probabilities, 1,
1102 N_("Use profiling information for branch probabilities") },
1103 {"profile", &profile_flag, 1,
1104 N_("Enable basic program profiling code") },
1105 {"reorder-blocks", &flag_reorder_blocks, 1,
1106 N_("Reorder basic blocks to improve code placement") },
1107 {"reorder-functions", &flag_reorder_functions, 1,
1108 N_("Reorder functions to improve code placement") },
1109 {"rename-registers", &flag_rename_registers, 1,
1110 N_("Do the register renaming optimization pass") },
1111 {"cprop-registers", &flag_cprop_registers, 1,
1112 N_("Do the register copy-propagation optimization pass") },
1113 {"common", &flag_no_common, 0,
1114 N_("Do not put uninitialized globals in the common section") },
1115 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1116 N_("Do not generate .size directives") },
1117 {"function-sections", &flag_function_sections, 1,
1118 N_("place each function into its own section") },
1119 {"data-sections", &flag_data_sections, 1,
1120 N_("place data items into their own section") },
1121 {"verbose-asm", &flag_verbose_asm, 1,
1122 N_("Add extra commentry to assembler output") },
1123 {"gnu-linker", &flag_gnu_linker, 1,
1124 N_("Output GNU ld formatted global initializers") },
1125 {"regmove", &flag_regmove, 1,
1126 N_("Enables a register move optimization") },
1127 {"optimize-register-move", &flag_regmove, 1,
1128 N_("Do the full regmove optimization pass") },
1129 {"pack-struct", &flag_pack_struct, 1,
1130 N_("Pack structure members together without holes") },
1131 {"stack-check", &flag_stack_check, 1,
1132 N_("Insert stack checking code into the program") },
1133 {"argument-alias", &flag_argument_noalias, 0,
1134 N_("Specify that arguments may alias each other & globals") },
1135 {"argument-noalias", &flag_argument_noalias, 1,
1136 N_("Assume arguments may alias globals but not each other") },
1137 {"argument-noalias-global", &flag_argument_noalias, 2,
1138 N_("Assume arguments do not alias each other or globals") },
1139 {"strict-aliasing", &flag_strict_aliasing, 1,
1140 N_("Assume strict aliasing rules apply") },
1141 {"align-loops", &align_loops, 0,
1142 N_("Align the start of loops") },
1143 {"align-jumps", &align_jumps, 0,
1144 N_("Align labels which are only reached by jumping") },
1145 {"align-labels", &align_labels, 0,
1146 N_("Align all labels") },
1147 {"align-functions", &align_functions, 0,
1148 N_("Align the start of functions") },
1149 {"merge-constants", &flag_merge_constants, 1,
1150 N_("Attempt to merge identical constants accross compilation units") },
1151 {"merge-all-constants", &flag_merge_constants, 2,
1152 N_("Attempt to merge identical constants and constant variables") },
1153 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1154 N_("Suppress output of instruction numbers and line number notes in debugging dumps") },
1155 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1156 N_("Instrument function entry/exit with profiling calls") },
1157 {"zero-initialized-in-bss", &flag_zero_initialized_in_bss, 1,
1158 N_("Put zero initialized data in the bss section") },
1159 {"ssa", &flag_ssa, 1,
1160 N_("Enable SSA optimizations") },
1161 {"ssa-ccp", &flag_ssa_ccp, 1,
1162 N_("Enable SSA conditional constant propagation") },
1163 {"ssa-dce", &flag_ssa_dce, 1,
1164 N_("Enable aggressive SSA dead code elimination") },
1165 {"leading-underscore", &flag_leading_underscore, 1,
1166 N_("External symbols have a leading underscore") },
1167 {"ident", &flag_no_ident, 0,
1168 N_("Process #ident directives") },
1169 { "peephole2", &flag_peephole2, 1,
1170 N_("Enables an rtl peephole pass run before sched2") },
1171 {"finite-math-only", &flag_finite_math_only, 1,
1172 N_("Assume no NaNs or +-Infs are generated") },
1173 { "guess-branch-probability", &flag_guess_branch_prob, 1,
1174 N_("Enables guessing of branch probabilities") },
1175 {"math-errno", &flag_errno_math, 1,
1176 N_("Set errno after built-in math functions") },
1177 {"trapping-math", &flag_trapping_math, 1,
1178 N_("Floating-point operations can trap") },
1179 {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1,
1180 N_("Allow math optimizations that may violate IEEE or ANSI standards") },
1181 {"signaling-nans", &flag_signaling_nans, 1,
1182 N_("Disable optimizations observable by IEEE signaling NaNs") },
1183 {"bounds-check", &flag_bounds_check, 1,
1184 N_("Generate code to check bounds before indexing arrays") },
1185 {"single-precision-constant", &flag_single_precision_constant, 1,
1186 N_("Convert floating point constant to single precision constant") },
1187 {"time-report", &time_report, 1,
1188 N_("Report time taken by each compiler pass at end of run") },
1189 {"mem-report", &mem_report, 1,
1190 N_("Report on permanent memory allocation at end of run") },
1191 { "trapv", &flag_trapv, 1,
1192 N_("Trap for signed overflow in addition / subtraction / multiplication") },
1193 { "new-ra", &flag_new_regalloc, 1,
1194 N_("Use graph coloring register allocation.") },
1197 /* Table of language-specific options. */
1199 static const struct lang_opt
1201 const char *const option;
1202 const char *const description;
1204 documented_lang_options[] =
1206 /* In order not to overload the --help output, the convention
1207 used here is to only describe those options which are not
1208 enabled by default. */
1210 { "-ansi",
1211 N_("Compile just for ISO C90") },
1212 { "-std= ",
1213 N_("Determine language standard") },
1215 { "-fsigned-bitfields", "" },
1216 { "-funsigned-bitfields",
1217 N_("Make bit-fields by unsigned by default") },
1218 { "-fno-signed-bitfields", "" },
1219 { "-fno-unsigned-bitfields","" },
1220 { "-fsigned-char",
1221 N_("Make 'char' be signed by default") },
1222 { "-funsigned-char",
1223 N_("Make 'char' be unsigned by default") },
1224 { "-fno-signed-char", "" },
1225 { "-fno-unsigned-char", "" },
1227 { "-fasm", "" },
1228 { "-fno-asm",
1229 N_("Do not recognize the 'asm' keyword") },
1230 { "-fbuiltin", "" },
1231 { "-fno-builtin",
1232 N_("Do not recognize any built in functions") },
1233 { "-fhosted",
1234 N_("Assume normal C execution environment") },
1235 { "-fno-hosted", "" },
1236 { "-ffreestanding",
1237 N_("Assume that standard libraries & main might not exist") },
1238 { "-fno-freestanding", "" },
1239 { "-fcond-mismatch",
1240 N_("Allow different types as args of ? operator") },
1241 { "-fno-cond-mismatch", "" },
1242 { "-fdollars-in-identifiers",
1243 N_("Allow the use of $ inside identifiers") },
1244 { "-fno-dollars-in-identifiers", "" },
1245 { "-fpreprocessed", "" },
1246 { "-fno-preprocessed", "" },
1247 { "-fshort-double",
1248 N_("Use the same size for double as for float") },
1249 { "-fno-short-double", "" },
1250 { "-fshort-enums",
1251 N_("Use the smallest fitting integer to hold enums") },
1252 { "-fno-short-enums", "" },
1253 { "-fshort-wchar",
1254 N_("Override the underlying type for wchar_t to `unsigned short'") },
1255 { "-fno-short-wchar", "" },
1257 { "-Wall",
1258 N_("Enable most warning messages") },
1259 { "-Wbad-function-cast",
1260 N_("Warn about casting functions to incompatible types") },
1261 { "-Wno-bad-function-cast", "" },
1262 { "-Wmissing-format-attribute",
1263 N_("Warn about functions which might be candidates for format attributes") },
1264 { "-Wno-missing-format-attribute", "" },
1265 { "-Wcast-qual",
1266 N_("Warn about casts which discard qualifiers") },
1267 { "-Wno-cast-qual", "" },
1268 { "-Wchar-subscripts",
1269 N_("Warn about subscripts whose type is 'char'") },
1270 { "-Wno-char-subscripts", "" },
1271 { "-Wcomment",
1272 N_("Warn if nested comments are detected") },
1273 { "-Wno-comment", "" },
1274 { "-Wcomments",
1275 N_("Warn if nested comments are detected") },
1276 { "-Wno-comments", "" },
1277 { "-Wconversion",
1278 N_("Warn about possibly confusing type conversions") },
1279 { "-Wno-conversion", "" },
1280 { "-Wdiv-by-zero", "" },
1281 { "-Wno-div-by-zero",
1282 N_("Do not warn about compile-time integer division by zero") },
1283 { "-Wfloat-equal",
1284 N_("Warn about testing equality of floating point numbers") },
1285 { "-Wno-float-equal", "" },
1286 { "-Wformat",
1287 N_("Warn about printf/scanf/strftime/strfmon format anomalies") },
1288 { "-Wno-format", "" },
1289 { "-Wformat-extra-args", "" },
1290 { "-Wno-format-extra-args",
1291 N_("Don't warn about too many arguments to format functions") },
1292 { "-Wformat-nonliteral",
1293 N_("Warn about non-string-literal format strings") },
1294 { "-Wno-format-nonliteral", "" },
1295 { "-Wformat-security",
1296 N_("Warn about possible security problems with format functions") },
1297 { "-Wno-format-security", "" },
1298 { "-Wformat-y2k", "" },
1299 { "-Wno-format-y2k",
1300 N_("Don't warn about strftime formats yielding 2 digit years") },
1301 { "-Wimplicit-function-declaration",
1302 N_("Warn about implicit function declarations") },
1303 { "-Wno-implicit-function-declaration", "" },
1304 { "-Werror-implicit-function-declaration", "" },
1305 { "-Wimplicit-int",
1306 N_("Warn when a declaration does not specify a type") },
1307 { "-Wno-implicit-int", "" },
1308 { "-Wimplicit", "" },
1309 { "-Wno-implicit", "" },
1310 { "-Wimport",
1311 N_("Warn about the use of the #import directive") },
1312 { "-Wno-import", "" },
1313 { "-Winvalid-pch",
1314 N_("Warn about PCH files that are found but not used") },
1315 { "-Wlong-long","" },
1316 { "-Wno-long-long",
1317 N_("Do not warn about using 'long long' when -pedantic") },
1318 { "-Wmain",
1319 N_("Warn about suspicious declarations of main") },
1320 { "-Wno-main", "" },
1321 { "-Wmissing-braces",
1322 N_("Warn about possibly missing braces around initializers") },
1323 { "-Wno-missing-braces", "" },
1324 { "-Wmissing-declarations",
1325 N_("Warn about global funcs without previous declarations") },
1326 { "-Wno-missing-declarations", "" },
1327 { "-Wmissing-prototypes",
1328 N_("Warn about global funcs without prototypes") },
1329 { "-Wno-missing-prototypes", "" },
1330 { "-Wmultichar",
1331 N_("Warn about use of multicharacter literals") },
1332 { "-Wno-multichar", "" },
1333 { "-Wnested-externs",
1334 N_("Warn about externs not at file scope level") },
1335 { "-Wno-nested-externs", "" },
1336 { "-Wparentheses",
1337 N_("Warn about possible missing parentheses") },
1338 { "-Wno-parentheses", "" },
1339 { "-Wpointer-arith",
1340 N_("Warn about function pointer arithmetic") },
1341 { "-Wno-pointer-arith", "" },
1342 { "-Wredundant-decls",
1343 N_("Warn about multiple declarations of the same object") },
1344 { "-Wno-redundant-decls", "" },
1345 { "-Wreturn-type",
1346 N_("Warn whenever a function's return-type defaults to int") },
1347 { "-Wno-return-type", "" },
1348 { "-Wsequence-point",
1349 N_("Warn about possible violations of sequence point rules") },
1350 { "-Wno-sequence-point", "" },
1351 { "-Wsign-compare",
1352 N_("Warn about signed/unsigned comparisons") },
1353 { "-Wno-sign-compare", "" },
1354 { "-Wstrict-prototypes",
1355 N_("Warn about non-prototyped function decls") },
1356 { "-Wno-strict-prototypes", "" },
1357 { "-Wtraditional",
1358 N_("Warn about constructs whose meanings change in ISO C") },
1359 { "-Wno-traditional", "" },
1360 { "-Wtrigraphs",
1361 N_("Warn when trigraphs are encountered") },
1362 { "-Wno-trigraphs", "" },
1363 { "-Wundef", "" },
1364 { "-Wno-undef", "" },
1365 { "-Wunknown-pragmas",
1366 N_("Warn about unrecognized pragmas") },
1367 { "-Wno-unknown-pragmas", "" },
1368 { "-Wwrite-strings",
1369 N_("Mark strings as 'const char *'") },
1370 { "-Wno-write-strings", "" },
1372 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1374 #include "options.h"
1378 /* Here is a table, controlled by the tm.h file, listing each -m switch
1379 and which bits in `target_switches' it should set or clear.
1380 If VALUE is positive, it is bits to set.
1381 If VALUE is negative, -VALUE is bits to clear.
1382 (The sign bit is not used so there is no confusion.) */
1384 static const struct
1386 const char *const name;
1387 const int value;
1388 const char *const description;
1390 target_switches[] = TARGET_SWITCHES;
1392 /* This table is similar, but allows the switch to have a value. */
1394 #ifdef TARGET_OPTIONS
1395 static const struct
1397 const char *const prefix;
1398 const char **const variable;
1399 const char *const description;
1401 target_options[] = TARGET_OPTIONS;
1402 #endif
1404 /* Options controlling warnings. */
1406 /* Don't print warning messages. -w. */
1408 int inhibit_warnings = 0;
1410 /* Don't suppress warnings from system headers. -Wsystem-headers. */
1412 int warn_system_headers = 0;
1414 /* Print various extra warnings. -W/-Wextra. */
1416 int extra_warnings = 0;
1418 /* Treat warnings as errors. -Werror. */
1420 int warnings_are_errors = 0;
1422 /* Nonzero to warn about unused variables, functions et.al. */
1424 int warn_unused_function;
1425 int warn_unused_label;
1426 int warn_unused_parameter;
1427 int warn_unused_variable;
1428 int warn_unused_value;
1430 /* Nonzero to warn about code which is never reached. */
1432 int warn_notreached;
1434 /* Nonzero to warn about variables used before they are initialized. */
1436 int warn_uninitialized;
1438 /* Nonzero means warn about all declarations which shadow others. */
1440 int warn_shadow;
1442 /* Warn if a switch on an enum, that does not have a default case,
1443 fails to have a case for every enum value. */
1445 int warn_switch;
1447 /* Warn if a switch does not have a default case. */
1449 int warn_switch_default;
1451 /* Warn if a switch on an enum fails to have a case for every enum
1452 value (regardless of the presence or otherwise of a default case). */
1454 int warn_switch_enum;
1456 /* Nonzero means warn about function definitions that default the return type
1457 or that use a null return and have a return-type other than void. */
1459 int warn_return_type;
1461 /* Nonzero means warn about pointer casts that increase the required
1462 alignment of the target type (and might therefore lead to a crash
1463 due to a misaligned access). */
1465 int warn_cast_align;
1467 /* Nonzero means warn about any objects definitions whose size is larger
1468 than N bytes. Also want about function definitions whose returned
1469 values are larger than N bytes. The value N is in `larger_than_size'. */
1471 int warn_larger_than;
1472 HOST_WIDE_INT larger_than_size;
1474 /* Nonzero means warn if inline function is too large. */
1476 int warn_inline;
1478 /* Warn if a function returns an aggregate,
1479 since there are often incompatible calling conventions for doing this. */
1481 int warn_aggregate_return;
1483 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1485 int warn_packed;
1487 /* Warn when gcc pads a structure to an alignment boundary. */
1489 int warn_padded;
1491 /* Warn when an optimization pass is disabled. */
1493 int warn_disabled_optimization;
1495 /* Warn about functions which might be candidates for attribute noreturn. */
1497 int warn_missing_noreturn;
1499 /* Nonzero means warn about uses of __attribute__((deprecated))
1500 declarations. */
1502 int warn_deprecated_decl = 1;
1504 /* Nonzero means warn about constructs which might not be
1505 strict-aliasing safe. */
1507 int warn_strict_aliasing;
1509 /* Like f_options, but for -W. */
1511 static const lang_independent_options W_options[] =
1513 {"unused-function", &warn_unused_function, 1,
1514 N_("Warn when a function is unused") },
1515 {"unused-label", &warn_unused_label, 1,
1516 N_("Warn when a label is unused") },
1517 {"unused-parameter", &warn_unused_parameter, 1,
1518 N_("Warn when a function parameter is unused") },
1519 {"unused-variable", &warn_unused_variable, 1,
1520 N_("Warn when a variable is unused") },
1521 {"unused-value", &warn_unused_value, 1,
1522 N_("Warn when an expression value is unused") },
1523 {"system-headers", &warn_system_headers, 1,
1524 N_("Do not suppress warnings from system headers") },
1525 {"error", &warnings_are_errors, 1,
1526 N_("Treat all warnings as errors") },
1527 {"shadow", &warn_shadow, 1,
1528 N_("Warn when one local variable shadows another") },
1529 {"switch", &warn_switch, 1,
1530 N_("Warn about enumerated switches, with no default, missing a case") },
1531 {"switch-default", &warn_switch_default, 1,
1532 N_("Warn about enumerated switches missing a default case") },
1533 {"switch-enum", &warn_switch_enum, 1,
1534 N_("Warn about all enumerated switches missing a specific case") },
1535 {"aggregate-return", &warn_aggregate_return, 1,
1536 N_("Warn about returning structures, unions or arrays") },
1537 {"cast-align", &warn_cast_align, 1,
1538 N_("Warn about pointer casts which increase alignment") },
1539 {"unreachable-code", &warn_notreached, 1,
1540 N_("Warn about code that will never be executed") },
1541 {"uninitialized", &warn_uninitialized, 1,
1542 N_("Warn about uninitialized automatic variables") },
1543 {"inline", &warn_inline, 1,
1544 N_("Warn when an inlined function cannot be inlined") },
1545 {"packed", &warn_packed, 1,
1546 N_("Warn when the packed attribute has no effect on struct layout") },
1547 {"padded", &warn_padded, 1,
1548 N_("Warn when padding is required to align struct members") },
1549 {"disabled-optimization", &warn_disabled_optimization, 1,
1550 N_("Warn when an optimization pass is disabled") },
1551 {"deprecated-declarations", &warn_deprecated_decl, 1,
1552 N_("Warn about uses of __attribute__((deprecated)) declarations") },
1553 {"extra", &extra_warnings, 1,
1554 N_("Print extra (possibly unwanted) warnings") },
1555 {"missing-noreturn", &warn_missing_noreturn, 1,
1556 N_("Warn about functions which might be candidates for attribute noreturn") },
1557 {"strict-aliasing", &warn_strict_aliasing, 1,
1558 N_ ("Warn about code which might break the strict aliasing rules") }
1561 void
1562 set_Wunused (setting)
1563 int setting;
1565 warn_unused_function = setting;
1566 warn_unused_label = setting;
1567 /* Unused function parameter warnings are reported when either ``-W
1568 -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
1569 -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
1570 if (!setting)
1571 warn_unused_parameter = 0;
1572 else if (!warn_unused_parameter)
1573 warn_unused_parameter = -1;
1574 warn_unused_variable = setting;
1575 warn_unused_value = setting;
1578 /* The following routines are useful in setting all the flags that
1579 -ffast-math and -fno-fast-math imply. */
1581 void
1582 set_fast_math_flags (set)
1583 int set;
1585 flag_trapping_math = !set;
1586 flag_unsafe_math_optimizations = set;
1587 flag_finite_math_only = set;
1588 flag_errno_math = !set;
1589 if (set)
1590 flag_signaling_nans = 0;
1593 /* Return true iff flags are set as if -ffast-math. */
1594 bool
1595 fast_math_flags_set_p ()
1597 return (!flag_trapping_math
1598 && flag_unsafe_math_optimizations
1599 && flag_finite_math_only
1600 && !flag_errno_math);
1604 /* Output files for assembler code (real compiler output)
1605 and debugging dumps. */
1607 FILE *asm_out_file;
1608 FILE *aux_info_file;
1609 FILE *rtl_dump_file = NULL;
1611 /* Decode the string P as an integral parameter.
1612 If the string is indeed an integer return its numeric value else
1613 issue an Invalid Option error for the option PNAME and return DEFVAL.
1614 If PNAME is zero just return DEFVAL, do not call error. */
1617 read_integral_parameter (p, pname, defval)
1618 const char *p;
1619 const char *pname;
1620 const int defval;
1622 const char *endp = p;
1624 while (*endp)
1626 if (ISDIGIT (*endp))
1627 endp++;
1628 else
1629 break;
1632 if (*endp != 0)
1634 if (pname != 0)
1635 error ("invalid option `%s'", pname);
1636 return defval;
1639 return atoi (p);
1642 /* This calls abort and is used to avoid problems when abort is a macro.
1643 It is used when we need to pass the address of abort. */
1645 void
1646 do_abort ()
1648 abort ();
1651 /* When `malloc.c' is compiled with `rcheck' defined,
1652 it calls this function to report clobberage. */
1654 void
1655 botch (s)
1656 const char *s ATTRIBUTE_UNUSED;
1658 abort ();
1661 /* Return the logarithm of X, base 2, considering X unsigned,
1662 if X is a power of 2. Otherwise, returns -1.
1664 This should be used via the `exact_log2' macro. */
1667 exact_log2_wide (x)
1668 unsigned HOST_WIDE_INT x;
1670 int log = 0;
1671 /* Test for 0 or a power of 2. */
1672 if (x == 0 || x != (x & -x))
1673 return -1;
1674 while ((x >>= 1) != 0)
1675 log++;
1676 return log;
1679 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1680 If X is 0, return -1.
1682 This should be used via the floor_log2 macro. */
1685 floor_log2_wide (x)
1686 unsigned HOST_WIDE_INT x;
1688 int log = -1;
1689 while (x != 0)
1690 log++,
1691 x >>= 1;
1692 return log;
1695 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1696 into ICE messages, which is much more user friendly. */
1698 static void
1699 crash_signal (signo)
1700 int signo;
1702 internal_error ("%s", strsignal (signo));
1705 /* Strip off a legitimate source ending from the input string NAME of
1706 length LEN. Rather than having to know the names used by all of
1707 our front ends, we strip off an ending of a period followed by
1708 up to five characters. (Java uses ".class".) */
1710 void
1711 strip_off_ending (name, len)
1712 char *name;
1713 int len;
1715 int i;
1716 for (i = 2; i < 6 && len > i; i++)
1718 if (name[len - i] == '.')
1720 name[len - i] = '\0';
1721 break;
1726 /* Output a quoted string. */
1728 void
1729 output_quoted_string (asm_file, string)
1730 FILE *asm_file;
1731 const char *string;
1733 #ifdef OUTPUT_QUOTED_STRING
1734 OUTPUT_QUOTED_STRING (asm_file, string);
1735 #else
1736 char c;
1738 putc ('\"', asm_file);
1739 while ((c = *string++) != 0)
1741 if (ISPRINT (c))
1743 if (c == '\"' || c == '\\')
1744 putc ('\\', asm_file);
1745 putc (c, asm_file);
1747 else
1748 fprintf (asm_file, "\\%03o", (unsigned char) c);
1750 putc ('\"', asm_file);
1751 #endif
1754 /* Output NAME into FILE after having turned it into something
1755 usable as an identifier in a target's assembly file. */
1756 void
1757 output_clean_symbol_name (file, name)
1758 FILE *file;
1759 const char *name;
1761 /* Make a copy of NAME. */
1762 char *id = xstrdup (name);
1764 /* Make it look like a valid identifier for an assembler. */
1765 clean_symbol_name (id);
1767 fputs (id, file);
1768 free (id);
1772 /* Output a file name in the form wanted by System V. */
1774 void
1775 output_file_directive (asm_file, input_name)
1776 FILE *asm_file;
1777 const char *input_name;
1779 int len = strlen (input_name);
1780 const char *na = input_name + len;
1782 /* NA gets INPUT_NAME sans directory names. */
1783 while (na > input_name)
1785 if (IS_DIR_SEPARATOR (na[-1]))
1786 break;
1787 na--;
1790 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1791 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1792 #else
1793 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1794 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1795 #else
1796 fprintf (asm_file, "\t.file\t");
1797 output_quoted_string (asm_file, na);
1798 fputc ('\n', asm_file);
1799 #endif
1800 #endif
1803 /* Routine to open a dump file. Return true if the dump file is enabled. */
1805 static int
1806 open_dump_file (index, decl)
1807 enum dump_file_index index;
1808 tree decl;
1810 char *dump_name;
1811 const char *open_arg;
1812 char seq[16];
1814 if (! dump_file[index].enabled)
1815 return 0;
1817 timevar_push (TV_DUMP);
1818 if (rtl_dump_file != NULL)
1819 fclose (rtl_dump_file);
1821 sprintf (seq, DUMPFILE_FORMAT, index);
1823 if (! dump_file[index].initialized)
1825 /* If we've not initialized the files, do so now. */
1826 if (graph_dump_format != no_graph
1827 && dump_file[index].graph_dump_p)
1829 dump_name = concat (seq, dump_file[index].extension, NULL);
1830 clean_graph_dump_file (dump_base_name, dump_name);
1831 free (dump_name);
1833 dump_file[index].initialized = 1;
1834 open_arg = "w";
1836 else
1837 open_arg = "a";
1839 dump_name = concat (dump_base_name, seq,
1840 dump_file[index].extension, NULL);
1842 rtl_dump_file = fopen (dump_name, open_arg);
1843 if (rtl_dump_file == NULL)
1844 fatal_io_error ("can't open %s", dump_name);
1846 free (dump_name);
1848 if (decl)
1849 fprintf (rtl_dump_file, "\n;; Function %s%s\n\n",
1850 (*lang_hooks.decl_printable_name) (decl, 2),
1851 cfun->function_frequency == FUNCTION_FREQUENCY_HOT
1852 ? " (hot)"
1853 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
1854 ? " (unlikely executed)"
1855 : "");
1857 timevar_pop (TV_DUMP);
1858 return 1;
1861 /* Routine to close a dump file. */
1863 static void
1864 close_dump_file (index, func, insns)
1865 enum dump_file_index index;
1866 void (*func) PARAMS ((FILE *, rtx));
1867 rtx insns;
1869 if (! rtl_dump_file)
1870 return;
1872 timevar_push (TV_DUMP);
1873 if (insns
1874 && graph_dump_format != no_graph
1875 && dump_file[index].graph_dump_p)
1877 char seq[16];
1878 char *suffix;
1880 sprintf (seq, DUMPFILE_FORMAT, index);
1881 suffix = concat (seq, dump_file[index].extension, NULL);
1882 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1883 free (suffix);
1886 if (func && insns)
1887 func (rtl_dump_file, insns);
1889 fflush (rtl_dump_file);
1890 fclose (rtl_dump_file);
1892 rtl_dump_file = NULL;
1893 timevar_pop (TV_DUMP);
1896 /* Do any final processing required for the declarations in VEC, of
1897 which there are LEN. We write out inline functions and variables
1898 that have been deferred until this point, but which are required.
1899 Returns nonzero if anything was put out. */
1902 wrapup_global_declarations (vec, len)
1903 tree *vec;
1904 int len;
1906 tree decl;
1907 int i;
1908 int reconsider;
1909 int output_something = 0;
1911 for (i = 0; i < len; i++)
1913 decl = vec[i];
1915 /* We're not deferring this any longer. */
1916 DECL_DEFER_OUTPUT (decl) = 0;
1918 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1919 (*lang_hooks.finish_incomplete_decl) (decl);
1922 /* Now emit any global variables or functions that we have been
1923 putting off. We need to loop in case one of the things emitted
1924 here references another one which comes earlier in the list. */
1927 reconsider = 0;
1928 for (i = 0; i < len; i++)
1930 decl = vec[i];
1932 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1933 continue;
1935 /* Don't write out static consts, unless we still need them.
1937 We also keep static consts if not optimizing (for debugging),
1938 unless the user specified -fno-keep-static-consts.
1939 ??? They might be better written into the debug information.
1940 This is possible when using DWARF.
1942 A language processor that wants static constants to be always
1943 written out (even if it is not used) is responsible for
1944 calling rest_of_decl_compilation itself. E.g. the C front-end
1945 calls rest_of_decl_compilation from finish_decl.
1946 One motivation for this is that is conventional in some
1947 environments to write things like:
1948 static const char rcsid[] = "... version string ...";
1949 intending to force the string to be in the executable.
1951 A language processor that would prefer to have unneeded
1952 static constants "optimized away" would just defer writing
1953 them out until here. E.g. C++ does this, because static
1954 constants are often defined in header files.
1956 ??? A tempting alternative (for both C and C++) would be
1957 to force a constant to be written if and only if it is
1958 defined in a main file, as opposed to an include file. */
1960 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1962 bool needed = 1;
1964 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1965 /* needed */;
1966 else if (DECL_COMDAT (decl))
1967 needed = 0;
1968 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1969 && (optimize || !flag_keep_static_consts
1970 || DECL_ARTIFICIAL (decl)))
1971 needed = 0;
1973 if (needed)
1975 reconsider = 1;
1976 rest_of_decl_compilation (decl, NULL, 1, 1);
1980 if (TREE_CODE (decl) == FUNCTION_DECL
1981 && DECL_INITIAL (decl) != 0
1982 && DECL_SAVED_INSNS (decl) != 0
1983 && (flag_keep_inline_functions
1984 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1985 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1987 reconsider = 1;
1988 output_inline_function (decl);
1992 if (reconsider)
1993 output_something = 1;
1995 while (reconsider);
1997 return output_something;
2000 /* Issue appropriate warnings for the global declarations in VEC (of
2001 which there are LEN). Output debugging information for them. */
2003 void
2004 check_global_declarations (vec, len)
2005 tree *vec;
2006 int len;
2008 tree decl;
2009 int i;
2011 for (i = 0; i < len; i++)
2013 decl = vec[i];
2015 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2016 && ! TREE_ASM_WRITTEN (decl))
2017 /* Cancel the RTL for this decl so that, if debugging info
2018 output for global variables is still to come,
2019 this one will be omitted. */
2020 SET_DECL_RTL (decl, NULL_RTX);
2022 /* Warn about any function
2023 declared static but not defined.
2024 We don't warn about variables,
2025 because many programs have static variables
2026 that exist only to get some text into the object file. */
2027 if (TREE_CODE (decl) == FUNCTION_DECL
2028 && (warn_unused_function
2029 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2030 && DECL_INITIAL (decl) == 0
2031 && DECL_EXTERNAL (decl)
2032 && ! DECL_ARTIFICIAL (decl)
2033 && ! TREE_PUBLIC (decl))
2035 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2036 pedwarn_with_decl (decl,
2037 "`%s' used but never defined");
2038 else
2039 warning_with_decl (decl,
2040 "`%s' declared `static' but never defined");
2041 /* This symbol is effectively an "extern" declaration now. */
2042 TREE_PUBLIC (decl) = 1;
2043 assemble_external (decl);
2046 /* Warn about static fns or vars defined but not used. */
2047 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
2048 || (warn_unused_variable && TREE_CODE (decl) == VAR_DECL))
2049 && ! TREE_USED (decl)
2050 /* The TREE_USED bit for file-scope decls is kept in the identifier,
2051 to handle multiple external decls in different scopes. */
2052 && ! TREE_USED (DECL_NAME (decl))
2053 && ! DECL_EXTERNAL (decl)
2054 && ! TREE_PUBLIC (decl)
2055 /* Global register variables must be declared to reserve them. */
2056 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
2057 /* Otherwise, ask the language. */
2058 && (*lang_hooks.decls.warn_unused_global) (decl))
2059 warning_with_decl (decl, "`%s' defined but not used");
2061 /* Avoid confusing the debug information machinery when there are
2062 errors. */
2063 if (errorcount == 0 && sorrycount == 0)
2065 timevar_push (TV_SYMOUT);
2066 (*debug_hooks->global_decl) (decl);
2067 timevar_pop (TV_SYMOUT);
2072 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2073 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2074 INPUT_FILENAME and LINENO accordingly. */
2076 void
2077 push_srcloc (file, line)
2078 const char *file;
2079 int line;
2081 struct file_stack *fs;
2083 if (input_file_stack)
2085 input_file_stack->name = input_filename;
2086 input_file_stack->line = lineno;
2089 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2090 fs->name = input_filename = file;
2091 fs->line = lineno = line;
2092 fs->next = input_file_stack;
2093 input_file_stack = fs;
2094 input_file_stack_tick++;
2097 /* Pop the top entry off the stack of presently open source files.
2098 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2099 the stack. */
2101 void
2102 pop_srcloc ()
2104 struct file_stack *fs;
2106 fs = input_file_stack;
2107 input_file_stack = fs->next;
2108 free (fs);
2109 input_file_stack_tick++;
2110 /* The initial source file is never popped. */
2111 if (!input_file_stack)
2112 abort ();
2113 input_filename = input_file_stack->name;
2114 lineno = input_file_stack->line;
2117 /* Compile an entire translation unit. Write a file of assembly
2118 output and various debugging dumps. */
2120 static void
2121 compile_file ()
2123 tree globals;
2125 /* Initialize yet another pass. */
2127 init_final (main_input_filename);
2128 init_branch_prob (aux_base_name);
2130 timevar_push (TV_PARSE);
2132 /* Call the parser, which parses the entire file (calling
2133 rest_of_compilation for each function). */
2134 (*lang_hooks.parse_file) (set_yydebug);
2136 /* In case there were missing block closers,
2137 get us back to the global binding level. */
2138 (*lang_hooks.clear_binding_stack) ();
2140 /* Compilation is now finished except for writing
2141 what's left of the symbol table output. */
2142 timevar_pop (TV_PARSE);
2144 if (flag_syntax_only)
2145 return;
2147 globals = (*lang_hooks.decls.getdecls) ();
2149 /* Really define vars that have had only a tentative definition.
2150 Really output inline functions that must actually be callable
2151 and have not been output so far. */
2154 int len = list_length (globals);
2155 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2156 int i;
2157 tree decl;
2159 /* Process the decls in reverse order--earliest first.
2160 Put them into VEC from back to front, then take out from front. */
2162 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2163 vec[len - i - 1] = decl;
2165 wrapup_global_declarations (vec, len);
2167 if (profile_arc_flag)
2168 /* This must occur after the loop to output deferred functions.
2169 Else the profiler initializer would not be emitted if all the
2170 functions in this compilation unit were deferred. */
2171 create_profiler ();
2173 check_global_declarations (vec, len);
2175 /* Clean up. */
2176 free (vec);
2179 /* Write out any pending weak symbol declarations. */
2181 weak_finish ();
2183 /* Do dbx symbols. */
2184 timevar_push (TV_SYMOUT);
2186 #ifdef DWARF2_UNWIND_INFO
2187 if (dwarf2out_do_frame ())
2188 dwarf2out_frame_finish ();
2189 #endif
2191 (*debug_hooks->finish) (main_input_filename);
2192 timevar_pop (TV_SYMOUT);
2194 /* Output some stuff at end of file if nec. */
2196 dw2_output_indirect_constants ();
2198 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2200 timevar_push (TV_DUMP);
2201 open_dump_file (DFI_bp, NULL);
2203 end_branch_prob ();
2205 close_dump_file (DFI_bp, NULL, NULL_RTX);
2206 timevar_pop (TV_DUMP);
2209 #ifdef ASM_FILE_END
2210 ASM_FILE_END (asm_out_file);
2211 #endif
2213 /* Attach a special .ident directive to the end of the file to identify
2214 the version of GCC which compiled this code. The format of the .ident
2215 string is patterned after the ones produced by native SVR4 compilers. */
2216 #ifdef IDENT_ASM_OP
2217 if (!flag_no_ident)
2218 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2219 IDENT_ASM_OP, version_string);
2220 #endif
2222 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2224 timevar_push (TV_DUMP);
2225 dump_combine_total_stats (rtl_dump_file);
2226 close_dump_file (DFI_combine, NULL, NULL_RTX);
2227 timevar_pop (TV_DUMP);
2231 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2232 and TYPE_DECL nodes.
2234 This does nothing for local (non-static) variables, unless the
2235 variable is a register variable with an ASMSPEC. In that case, or
2236 if the variable is not an automatic, it sets up the RTL and
2237 outputs any assembler code (label definition, storage allocation
2238 and initialization).
2240 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2241 the assembler symbol name to be used. TOP_LEVEL is nonzero
2242 if this declaration is not within a function. */
2244 void
2245 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2246 tree decl;
2247 const char *asmspec;
2248 int top_level;
2249 int at_end;
2251 /* Declarations of variables, and of functions defined elsewhere. */
2253 /* The most obvious approach, to put an #ifndef around where
2254 this macro is used, doesn't work since it's inside a macro call. */
2255 #ifndef ASM_FINISH_DECLARE_OBJECT
2256 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2257 #endif
2259 /* We deferred calling assemble_alias so that we could collect
2260 other attributes such as visibility. Emit the alias now. */
2262 tree alias;
2263 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
2264 if (alias)
2266 alias = TREE_VALUE (TREE_VALUE (alias));
2267 alias = get_identifier (TREE_STRING_POINTER (alias));
2268 assemble_alias (decl, alias);
2272 /* Forward declarations for nested functions are not "external",
2273 but we need to treat them as if they were. */
2274 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2275 || TREE_CODE (decl) == FUNCTION_DECL)
2277 timevar_push (TV_VARCONST);
2279 if (asmspec)
2280 make_decl_rtl (decl, asmspec);
2282 /* Don't output anything when a tentative file-scope definition
2283 is seen. But at end of compilation, do output code for them. */
2284 if (at_end || !DECL_DEFER_OUTPUT (decl))
2285 assemble_variable (decl, top_level, at_end, 0);
2286 if (decl == last_assemble_variable_decl)
2288 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2289 top_level, at_end);
2292 timevar_pop (TV_VARCONST);
2294 else if (DECL_REGISTER (decl) && asmspec != 0)
2296 if (decode_reg_name (asmspec) >= 0)
2298 SET_DECL_RTL (decl, NULL_RTX);
2299 make_decl_rtl (decl, asmspec);
2301 else
2303 error ("invalid register name `%s' for register variable", asmspec);
2304 DECL_REGISTER (decl) = 0;
2305 if (!top_level)
2306 expand_decl (decl);
2309 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2310 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2311 && TREE_CODE (decl) == TYPE_DECL)
2313 timevar_push (TV_SYMOUT);
2314 dbxout_symbol (decl, 0);
2315 timevar_pop (TV_SYMOUT);
2317 #endif
2318 #ifdef SDB_DEBUGGING_INFO
2319 else if (write_symbols == SDB_DEBUG && top_level
2320 && TREE_CODE (decl) == TYPE_DECL)
2322 timevar_push (TV_SYMOUT);
2323 sdbout_symbol (decl, 0);
2324 timevar_pop (TV_SYMOUT);
2326 #endif
2327 #ifdef DWARF2_DEBUGGING_INFO
2328 else if ((write_symbols == DWARF2_DEBUG
2329 || write_symbols == VMS_AND_DWARF2_DEBUG)
2330 && top_level
2331 && TREE_CODE (decl) == TYPE_DECL)
2333 timevar_push (TV_SYMOUT);
2334 dwarf2out_decl (decl);
2335 timevar_pop (TV_SYMOUT);
2337 #endif
2340 /* Called after finishing a record, union or enumeral type. */
2342 void
2343 rest_of_type_compilation (type, toplev)
2344 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2345 tree type;
2346 int toplev;
2347 #else
2348 tree type ATTRIBUTE_UNUSED;
2349 int toplev ATTRIBUTE_UNUSED;
2350 #endif
2352 /* Avoid confusing the debug information machinery when there are
2353 errors. */
2354 if (errorcount != 0 || sorrycount != 0)
2355 return;
2357 timevar_push (TV_SYMOUT);
2358 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2359 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2360 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2361 #endif
2362 #ifdef SDB_DEBUGGING_INFO
2363 if (write_symbols == SDB_DEBUG)
2364 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2365 #endif
2366 #ifdef DWARF2_DEBUGGING_INFO
2367 if ((write_symbols == DWARF2_DEBUG
2368 || write_symbols == VMS_AND_DWARF2_DEBUG)
2369 && toplev)
2370 dwarf2out_decl (TYPE_STUB_DECL (type));
2371 #endif
2372 timevar_pop (TV_SYMOUT);
2375 /* This is called from finish_function (within langhooks.parse_file)
2376 after each top-level definition is parsed.
2377 It is supposed to compile that function or variable
2378 and output the assembler code for it.
2379 After we return, the tree storage is freed. */
2381 void
2382 rest_of_compilation (decl)
2383 tree decl;
2385 rtx insns;
2386 int tem;
2387 int failure = 0;
2388 int rebuild_label_notes_after_reload;
2389 int register_life_up_to_date;
2391 timevar_push (TV_REST_OF_COMPILATION);
2393 /* Now that we're out of the frontend, we shouldn't have any more
2394 CONCATs anywhere. */
2395 generating_concat_p = 0;
2397 /* When processing delayed functions, prepare_function_start() won't
2398 have been run to re-initialize it. */
2399 cse_not_expected = ! optimize;
2401 /* First, make sure that NOTE_BLOCK is set correctly for each
2402 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2403 if (!cfun->x_whole_function_mode_p)
2404 identify_blocks ();
2406 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2407 tree in sensible shape. So, we just recalculate it here. */
2408 if (cfun->x_whole_function_mode_p)
2409 reorder_blocks ();
2411 init_flow ();
2413 /* If we are reconsidering an inline function
2414 at the end of compilation, skip the stuff for making it inline. */
2416 if (DECL_SAVED_INSNS (decl) == 0)
2418 int inlinable = 0;
2419 tree parent;
2420 const char *lose;
2422 /* If this is nested inside an inlined external function, pretend
2423 it was only declared. Since we cannot inline such functions,
2424 generating code for this one is not only not necessary but will
2425 confuse some debugging output writers. */
2426 for (parent = DECL_CONTEXT (current_function_decl);
2427 parent != NULL_TREE;
2428 parent = get_containing_scope (parent))
2429 if (TREE_CODE (parent) == FUNCTION_DECL
2430 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2432 DECL_INITIAL (decl) = 0;
2433 goto exit_rest_of_compilation;
2435 else if (TYPE_P (parent))
2436 /* A function in a local class should be treated normally. */
2437 break;
2439 /* If requested, consider whether to make this function inline. */
2440 if ((DECL_INLINE (decl) && !flag_no_inline)
2441 || flag_inline_functions)
2443 timevar_push (TV_INTEGRATION);
2444 lose = function_cannot_inline_p (decl);
2445 timevar_pop (TV_INTEGRATION);
2446 if (lose || ! optimize)
2448 if (warn_inline && DECL_INLINE (decl))
2449 warning_with_decl (decl, lose);
2450 DECL_ABSTRACT_ORIGIN (decl) = 0;
2451 /* Don't really compile an extern inline function.
2452 If we can't make it inline, pretend
2453 it was only declared. */
2454 if (DECL_EXTERNAL (decl))
2456 DECL_INITIAL (decl) = 0;
2457 goto exit_rest_of_compilation;
2460 else
2461 /* ??? Note that this has the effect of making it look
2462 like "inline" was specified for a function if we choose
2463 to inline it. This isn't quite right, but it's
2464 probably not worth the trouble to fix. */
2465 inlinable = DECL_INLINE (decl) = 1;
2468 insns = get_insns ();
2470 /* Dump the rtl code if we are dumping rtl. */
2472 if (open_dump_file (DFI_rtl, decl))
2474 if (DECL_SAVED_INSNS (decl))
2475 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2476 close_dump_file (DFI_rtl, print_rtl, insns);
2479 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2480 sorts of eh initialization. Delay this until after the
2481 initial rtl dump so that we can see the original nesting. */
2482 convert_from_eh_region_ranges ();
2484 /* If function is inline, and we don't yet know whether to
2485 compile it by itself, defer decision till end of compilation.
2486 wrapup_global_declarations will (indirectly) call
2487 rest_of_compilation again for those functions that need to
2488 be output. Also defer those functions that we are supposed
2489 to defer. */
2491 if (inlinable
2492 || (DECL_INLINE (decl)
2493 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2494 && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
2495 && ! flag_keep_inline_functions)
2496 || DECL_EXTERNAL (decl))))
2497 DECL_DEFER_OUTPUT (decl) = 1;
2499 if (DECL_INLINE (decl))
2500 /* DWARF wants separate debugging info for abstract and
2501 concrete instances of all inline functions, including those
2502 declared inline but not inlined, and those inlined even
2503 though they weren't declared inline. Conveniently, that's
2504 what DECL_INLINE means at this point. */
2505 (*debug_hooks->deferred_inline_function) (decl);
2507 if (DECL_DEFER_OUTPUT (decl))
2509 /* If -Wreturn-type, we have to do a bit of compilation. We just
2510 want to call cleanup the cfg to figure out whether or not we can
2511 fall off the end of the function; we do the minimum amount of
2512 work necessary to make that safe. */
2513 if (warn_return_type)
2515 int saved_optimize = optimize;
2517 optimize = 0;
2518 rebuild_jump_labels (insns);
2519 find_exception_handler_labels ();
2520 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2521 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2522 optimize = saved_optimize;
2524 /* CFG is no longer maintained up-to-date. */
2525 free_bb_for_insn ();
2528 set_nothrow_function_flags ();
2529 if (current_function_nothrow)
2530 /* Now we know that this can't throw; set the flag for the benefit
2531 of other functions later in this translation unit. */
2532 TREE_NOTHROW (current_function_decl) = 1;
2534 timevar_push (TV_INTEGRATION);
2535 save_for_inline (decl);
2536 timevar_pop (TV_INTEGRATION);
2537 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2538 goto exit_rest_of_compilation;
2541 /* If specified extern inline but we aren't inlining it, we are
2542 done. This goes for anything that gets here with DECL_EXTERNAL
2543 set, not just things with DECL_INLINE. */
2544 if (DECL_EXTERNAL (decl))
2545 goto exit_rest_of_compilation;
2548 /* If we're emitting a nested function, make sure its parent gets
2549 emitted as well. Doing otherwise confuses debug info. */
2551 tree parent;
2552 for (parent = DECL_CONTEXT (current_function_decl);
2553 parent != NULL_TREE;
2554 parent = get_containing_scope (parent))
2555 if (TREE_CODE (parent) == FUNCTION_DECL)
2556 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
2559 /* We are now committed to emitting code for this function. Do any
2560 preparation, such as emitting abstract debug info for the inline
2561 before it gets mangled by optimization. */
2562 if (DECL_INLINE (decl))
2563 (*debug_hooks->outlining_inline_function) (decl);
2565 /* Remove any notes we don't need. That will make iterating
2566 over the instruction sequence faster, and allow the garbage
2567 collector to reclaim the memory used by the notes. */
2568 remove_unnecessary_notes ();
2569 reorder_blocks ();
2571 ggc_collect ();
2573 /* Initialize some variables used by the optimizers. */
2574 init_function_for_compilation ();
2576 if (! DECL_DEFER_OUTPUT (decl))
2577 TREE_ASM_WRITTEN (decl) = 1;
2579 /* Now that integrate will no longer see our rtl, we need not
2580 distinguish between the return value of this function and the
2581 return value of called functions. Also, we can remove all SETs
2582 of subregs of hard registers; they are only here because of
2583 integrate. Also, we can now initialize pseudos intended to
2584 carry magic hard reg data throughout the function. */
2585 rtx_equal_function_value_matters = 0;
2586 purge_hard_subreg_sets (get_insns ());
2588 /* Early return if there were errors. We can run afoul of our
2589 consistency checks, and there's not really much point in fixing them.
2590 Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
2591 if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2592 || errorcount || sorrycount)
2593 goto exit_rest_of_compilation;
2595 timevar_push (TV_JUMP);
2596 open_dump_file (DFI_sibling, decl);
2597 insns = get_insns ();
2598 rebuild_jump_labels (insns);
2599 find_exception_handler_labels ();
2600 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2602 delete_unreachable_blocks ();
2604 /* Turn NOTE_INSN_PREDICTIONs into branch predictions. */
2605 timevar_push (TV_BRANCH_PROB);
2606 note_prediction_to_br_prob ();
2607 timevar_pop (TV_BRANCH_PROB);
2609 /* We may have potential sibling or tail recursion sites. Select one
2610 (of possibly multiple) methods of performing the call. */
2611 if (flag_optimize_sibling_calls)
2613 rtx insn;
2614 optimize_sibling_and_tail_recursive_calls ();
2616 /* Recompute the CFG as sibling optimization clobbers it randomly. */
2617 free_bb_for_insn ();
2618 find_exception_handler_labels ();
2619 rebuild_jump_labels (insns);
2620 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2622 /* There is pass ordering problem - we must lower NOTE_INSN_PREDICTION
2623 notes before simplifying cfg and we must do lowering after sibcall
2624 that unhides parts of RTL chain and cleans up the CFG.
2626 Until sibcall is replaced by tree-level optimizer, lets just
2627 sweep away the NOTE_INSN_PREDICTION notes that leaked out. */
2628 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2629 if (GET_CODE (insn) == NOTE
2630 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PREDICTION)
2631 delete_insn (insn);
2633 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2634 timevar_pop (TV_JUMP);
2636 scope_to_insns_initialize ();
2637 /* Complete generation of exception handling code. */
2638 if (doing_eh (0))
2640 timevar_push (TV_JUMP);
2641 open_dump_file (DFI_eh, decl);
2643 finish_eh_generation ();
2645 close_dump_file (DFI_eh, print_rtl, get_insns ());
2646 timevar_pop (TV_JUMP);
2649 /* Delay emitting hard_reg_initial_value sets until after EH landing pad
2650 generation, which might create new sets. */
2651 emit_initial_value_sets ();
2653 #ifdef FINALIZE_PIC
2654 /* If we are doing position-independent code generation, now
2655 is the time to output special prologues and epilogues.
2656 We do not want to do this earlier, because it just clutters
2657 up inline functions with meaningless insns. */
2658 if (flag_pic)
2659 FINALIZE_PIC;
2660 #endif
2662 insns = get_insns ();
2664 /* Copy any shared structure that should not be shared. */
2665 unshare_all_rtl (current_function_decl, insns);
2667 #ifdef SETJMP_VIA_SAVE_AREA
2668 /* This must be performed before virtual register instantiation.
2669 Please be aware the everything in the compiler that can look
2670 at the RTL up to this point must understand that REG_SAVE_AREA
2671 is just like a use of the REG contained inside. */
2672 if (current_function_calls_alloca)
2673 optimize_save_area_alloca (insns);
2674 #endif
2676 /* Instantiate all virtual registers. */
2677 instantiate_virtual_regs (current_function_decl, insns);
2679 open_dump_file (DFI_jump, decl);
2681 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2682 are initialized and to compute whether control can drop off the end
2683 of the function. */
2685 timevar_push (TV_JUMP);
2686 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2687 before jump optimization switches branch directions. */
2688 expected_value_to_br_prob ();
2690 reg_scan (insns, max_reg_num (), 0);
2691 rebuild_jump_labels (insns);
2692 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2693 if (rtl_dump_file)
2694 dump_flow_info (rtl_dump_file);
2695 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
2696 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2698 /* CFG is no longer maintained up-to-date. */
2699 free_bb_for_insn ();
2700 copy_loop_headers (insns);
2701 purge_line_number_notes (insns);
2702 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2704 timevar_pop (TV_JUMP);
2705 close_dump_file (DFI_jump, print_rtl, insns);
2707 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2708 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2710 goto exit_rest_of_compilation;
2713 /* Long term, this should probably move before the jump optimizer too,
2714 but I didn't want to disturb the rtl_dump_and_exit and related
2715 stuff at this time. */
2716 if (optimize > 0 && flag_ssa)
2718 /* Convert to SSA form. */
2720 timevar_push (TV_TO_SSA);
2721 open_dump_file (DFI_ssa, decl);
2723 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2724 convert_to_ssa ();
2726 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2727 timevar_pop (TV_TO_SSA);
2729 /* Perform sparse conditional constant propagation, if requested. */
2730 if (flag_ssa_ccp)
2732 timevar_push (TV_SSA_CCP);
2733 open_dump_file (DFI_ssa_ccp, decl);
2735 ssa_const_prop ();
2737 close_dump_file (DFI_ssa_ccp, print_rtl_with_bb, get_insns ());
2738 timevar_pop (TV_SSA_CCP);
2741 /* It would be useful to cleanup the CFG at this point, but block
2742 merging and possibly other transformations might leave a PHI
2743 node in the middle of a basic block, which is a strict no-no. */
2745 /* The SSA implementation uses basic block numbers in its phi
2746 nodes. Thus, changing the control-flow graph or the basic
2747 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
2748 may cause problems. */
2750 if (flag_ssa_dce)
2752 /* Remove dead code. */
2754 timevar_push (TV_SSA_DCE);
2755 open_dump_file (DFI_ssa_dce, decl);
2757 insns = get_insns ();
2758 ssa_eliminate_dead_code ();
2760 close_dump_file (DFI_ssa_dce, print_rtl_with_bb, insns);
2761 timevar_pop (TV_SSA_DCE);
2764 /* Convert from SSA form. */
2766 timevar_push (TV_FROM_SSA);
2767 open_dump_file (DFI_ussa, decl);
2769 convert_from_ssa ();
2770 /* New registers have been created. Rescan their usage. */
2771 reg_scan (insns, max_reg_num (), 1);
2773 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
2774 timevar_pop (TV_FROM_SSA);
2776 ggc_collect ();
2779 timevar_push (TV_JUMP);
2780 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP: 0);
2782 /* Try to identify useless null pointer tests and delete them. */
2783 if (flag_delete_null_pointer_checks)
2785 open_dump_file (DFI_null, decl);
2786 if (rtl_dump_file)
2787 dump_flow_info (rtl_dump_file);
2789 if (delete_null_pointer_checks (insns))
2790 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2792 close_dump_file (DFI_null, print_rtl_with_bb, insns);
2795 /* Jump optimization, and the removal of NULL pointer checks, may
2796 have reduced the number of instructions substantially. CSE, and
2797 future passes, allocate arrays whose dimensions involve the
2798 maximum instruction UID, so if we can reduce the maximum UID
2799 we'll save big on memory. */
2800 renumber_insns (rtl_dump_file);
2801 timevar_pop (TV_JUMP);
2803 close_dump_file (DFI_jump, print_rtl_with_bb, insns);
2805 ggc_collect ();
2807 /* Perform common subexpression elimination.
2808 Nonzero value from `cse_main' means that jumps were simplified
2809 and some code may now be unreachable, so do
2810 jump optimization again. */
2812 if (optimize > 0)
2814 open_dump_file (DFI_cse, decl);
2815 if (rtl_dump_file)
2816 dump_flow_info (rtl_dump_file);
2817 timevar_push (TV_CSE);
2819 reg_scan (insns, max_reg_num (), 1);
2821 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2822 if (tem)
2823 rebuild_jump_labels (insns);
2824 purge_all_dead_edges (0);
2826 delete_trivially_dead_insns (insns, max_reg_num ());
2828 /* If we are not running more CSE passes, then we are no longer
2829 expecting CSE to be run. But always rerun it in a cheap mode. */
2830 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
2832 if (tem || optimize > 1)
2833 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2834 /* Try to identify useless null pointer tests and delete them. */
2835 if (flag_delete_null_pointer_checks)
2837 timevar_push (TV_JUMP);
2839 if (delete_null_pointer_checks (insns))
2840 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2841 timevar_pop (TV_JUMP);
2844 /* The second pass of jump optimization is likely to have
2845 removed a bunch more instructions. */
2846 renumber_insns (rtl_dump_file);
2848 timevar_pop (TV_CSE);
2849 close_dump_file (DFI_cse, print_rtl_with_bb, insns);
2852 open_dump_file (DFI_addressof, decl);
2854 purge_addressof (insns);
2855 if (optimize)
2856 purge_all_dead_edges (0);
2857 reg_scan (insns, max_reg_num (), 1);
2859 close_dump_file (DFI_addressof, print_rtl, insns);
2861 ggc_collect ();
2863 /* Perform global cse. */
2865 if (optimize > 0 && flag_gcse)
2867 int save_csb, save_cfj;
2868 int tem2 = 0;
2870 timevar_push (TV_GCSE);
2871 open_dump_file (DFI_gcse, decl);
2873 tem = gcse_main (insns, rtl_dump_file);
2874 rebuild_jump_labels (insns);
2875 delete_trivially_dead_insns (insns, max_reg_num ());
2877 save_csb = flag_cse_skip_blocks;
2878 save_cfj = flag_cse_follow_jumps;
2879 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
2881 /* If -fexpensive-optimizations, re-run CSE to clean up things done
2882 by gcse. */
2883 if (flag_expensive_optimizations)
2885 timevar_push (TV_CSE);
2886 reg_scan (insns, max_reg_num (), 1);
2887 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2888 purge_all_dead_edges (0);
2889 delete_trivially_dead_insns (insns, max_reg_num ());
2890 timevar_pop (TV_CSE);
2891 cse_not_expected = !flag_rerun_cse_after_loop;
2894 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
2895 things up. Then possibly re-run CSE again. */
2896 while (tem || tem2)
2898 tem = tem2 = 0;
2899 timevar_push (TV_JUMP);
2900 rebuild_jump_labels (insns);
2901 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2902 timevar_pop (TV_JUMP);
2904 if (flag_expensive_optimizations)
2906 timevar_push (TV_CSE);
2907 reg_scan (insns, max_reg_num (), 1);
2908 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2909 purge_all_dead_edges (0);
2910 delete_trivially_dead_insns (insns, max_reg_num ());
2911 timevar_pop (TV_CSE);
2915 close_dump_file (DFI_gcse, print_rtl_with_bb, insns);
2916 timevar_pop (TV_GCSE);
2918 ggc_collect ();
2919 flag_cse_skip_blocks = save_csb;
2920 flag_cse_follow_jumps = save_cfj;
2921 #ifdef ENABLE_CHECKING
2922 verify_flow_info ();
2923 #endif
2926 /* Instantiate any remaining CONSTANT_P_RTX nodes. */
2927 purge_builtin_constant_p ();
2929 /* Move constant computations out of loops. */
2931 if (optimize > 0 && flag_loop_optimize)
2933 int do_unroll, do_prefetch;
2935 timevar_push (TV_LOOP);
2936 delete_dead_jumptables ();
2937 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2938 open_dump_file (DFI_loop, decl);
2939 /* CFG is no longer maintained up-to-date. */
2940 free_bb_for_insn ();
2942 do_unroll = flag_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
2943 do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
2944 if (flag_rerun_loop_opt)
2946 cleanup_barriers ();
2948 /* We only want to perform unrolling once. */
2949 loop_optimize (insns, rtl_dump_file, do_unroll);
2950 do_unroll = 0;
2952 /* The first call to loop_optimize makes some instructions
2953 trivially dead. We delete those instructions now in the
2954 hope that doing so will make the heuristics in loop work
2955 better and possibly speed up compilation. */
2956 delete_trivially_dead_insns (insns, max_reg_num ());
2958 /* The regscan pass is currently necessary as the alias
2959 analysis code depends on this information. */
2960 reg_scan (insns, max_reg_num (), 1);
2962 cleanup_barriers ();
2963 loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch);
2965 /* Loop can create trivially dead instructions. */
2966 delete_trivially_dead_insns (insns, max_reg_num ());
2967 close_dump_file (DFI_loop, print_rtl, insns);
2968 timevar_pop (TV_LOOP);
2969 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2971 ggc_collect ();
2974 /* Perform jump bypassing and control flow optimizations. */
2975 if (optimize > 0 && flag_gcse)
2977 timevar_push (TV_BYPASS);
2978 open_dump_file (DFI_bypass, decl);
2980 cleanup_cfg (CLEANUP_EXPENSIVE);
2981 tem = bypass_jumps (rtl_dump_file);
2983 if (tem)
2985 rebuild_jump_labels (insns);
2986 cleanup_cfg (CLEANUP_EXPENSIVE);
2987 delete_trivially_dead_insns (insns, max_reg_num ());
2990 close_dump_file (DFI_bypass, print_rtl_with_bb, insns);
2991 timevar_pop (TV_BYPASS);
2993 ggc_collect ();
2995 #ifdef ENABLE_CHECKING
2996 verify_flow_info ();
2997 #endif
3000 /* Do control and data flow analysis; wrote some of the results to
3001 the dump file. */
3003 timevar_push (TV_FLOW);
3004 open_dump_file (DFI_cfg, decl);
3005 if (rtl_dump_file)
3006 dump_flow_info (rtl_dump_file);
3007 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0)
3008 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3010 /* It may make more sense to mark constant functions after dead code is
3011 eliminated by life_analysis, but we need to do it early, as -fprofile-arcs
3012 may insert code making function non-constant, but we still must consider
3013 it as constant, otherwise -fbranch-probabilities will not read data back.
3015 life_analysis rarely eliminates modification of external memory.
3017 if (optimize)
3018 mark_constant_function ();
3020 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
3022 /* Do branch profiling and static profile estimation passes. */
3023 if (optimize > 0 || cfun->arc_profile || flag_branch_probabilities)
3025 struct loops loops;
3027 timevar_push (TV_BRANCH_PROB);
3028 open_dump_file (DFI_bp, decl);
3029 if (cfun->arc_profile || flag_branch_probabilities)
3030 branch_prob ();
3032 /* Discover and record the loop depth at the head of each basic
3033 block. The loop infrastructure does the real job for us. */
3034 flow_loops_find (&loops, LOOP_TREE);
3036 if (rtl_dump_file)
3037 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
3039 /* Estimate using heuristics if no profiling info is available. */
3040 if (flag_guess_branch_prob)
3041 estimate_probability (&loops);
3043 flow_loops_free (&loops);
3044 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
3045 timevar_pop (TV_BRANCH_PROB);
3047 if (optimize >= 0)
3049 open_dump_file (DFI_ce1, decl);
3050 if (flag_if_conversion)
3052 timevar_push (TV_IFCVT);
3053 if (rtl_dump_file)
3054 dump_flow_info (rtl_dump_file);
3055 cleanup_cfg (CLEANUP_EXPENSIVE);
3056 reg_scan (insns, max_reg_num (), 0);
3057 if_convert (0);
3058 timevar_pop (TV_IFCVT);
3060 timevar_push (TV_JUMP);
3061 cleanup_cfg (CLEANUP_EXPENSIVE);
3062 reg_scan (insns, max_reg_num (), 0);
3063 timevar_pop (TV_JUMP);
3064 close_dump_file (DFI_ce1, print_rtl_with_bb, get_insns ());
3066 if (flag_tracer)
3068 timevar_push (TV_TRACER);
3069 open_dump_file (DFI_tracer, decl);
3070 if (rtl_dump_file)
3071 dump_flow_info (rtl_dump_file);
3072 tracer ();
3073 cleanup_cfg (CLEANUP_EXPENSIVE);
3074 reg_scan (insns, max_reg_num (), 0);
3075 close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
3076 timevar_pop (TV_TRACER);
3079 if (flag_rerun_cse_after_loop)
3081 timevar_push (TV_CSE2);
3082 open_dump_file (DFI_cse2, decl);
3083 if (rtl_dump_file)
3084 dump_flow_info (rtl_dump_file);
3085 /* CFG is no longer maintained up-to-date. */
3086 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3087 purge_all_dead_edges (0);
3088 delete_trivially_dead_insns (insns, max_reg_num ());
3090 if (tem)
3092 timevar_push (TV_JUMP);
3093 rebuild_jump_labels (insns);
3094 cleanup_cfg (CLEANUP_EXPENSIVE);
3095 timevar_pop (TV_JUMP);
3097 reg_scan (insns, max_reg_num (), 0);
3098 close_dump_file (DFI_cse2, print_rtl_with_bb, insns);
3099 ggc_collect ();
3100 timevar_pop (TV_CSE2);
3103 cse_not_expected = 1;
3105 open_dump_file (DFI_life, decl);
3106 regclass_init ();
3108 check_function_return_warnings ();
3110 #ifdef ENABLE_CHECKING
3111 verify_flow_info ();
3112 #endif
3113 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3114 if (optimize)
3115 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_UPDATE_LIFE
3116 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3117 timevar_pop (TV_FLOW);
3119 no_new_pseudos = 1;
3121 if (warn_uninitialized || extra_warnings)
3123 uninitialized_vars_warning (DECL_INITIAL (decl));
3124 if (extra_warnings)
3125 setjmp_args_warning ();
3128 if (optimize)
3130 clear_bb_flags ();
3131 if (!flag_new_regalloc && initialize_uninitialized_subregs ())
3133 /* Insns were inserted, so things might look a bit different. */
3134 insns = get_insns ();
3135 update_life_info_in_dirty_blocks (UPDATE_LIFE_GLOBAL_RM_NOTES,
3136 PROP_LOG_LINKS | PROP_REG_INFO
3137 | PROP_DEATH_NOTES);
3141 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3143 ggc_collect ();
3145 /* If -opt, try combining insns through substitution. */
3147 if (optimize > 0)
3149 int rebuild_jump_labels_after_combine = 0;
3151 timevar_push (TV_COMBINE);
3152 open_dump_file (DFI_combine, decl);
3154 rebuild_jump_labels_after_combine
3155 = combine_instructions (insns, max_reg_num ());
3157 /* Combining insns may have turned an indirect jump into a
3158 direct jump. Rebuild the JUMP_LABEL fields of jumping
3159 instructions. */
3160 if (rebuild_jump_labels_after_combine)
3162 timevar_push (TV_JUMP);
3163 rebuild_jump_labels (insns);
3164 timevar_pop (TV_JUMP);
3166 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3169 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3170 timevar_pop (TV_COMBINE);
3172 ggc_collect ();
3175 /* Rerun if-conversion, as combine may have simplified things enough to
3176 now meet sequence length restrictions. */
3177 if (flag_if_conversion)
3179 timevar_push (TV_IFCVT);
3180 open_dump_file (DFI_ce2, decl);
3182 no_new_pseudos = 0;
3183 if_convert (1);
3184 no_new_pseudos = 1;
3186 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3187 timevar_pop (TV_IFCVT);
3190 /* Register allocation pre-pass, to reduce number of moves
3191 necessary for two-address machines. */
3192 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3194 timevar_push (TV_REGMOVE);
3195 open_dump_file (DFI_regmove, decl);
3197 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3199 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3200 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3201 timevar_pop (TV_REGMOVE);
3203 ggc_collect ();
3206 /* Do unconditional splitting before register allocation to allow machine
3207 description to add extra information not needed previously. */
3208 split_all_insns (1);
3210 /* Any of the several passes since flow1 will have munged register
3211 lifetime data a bit. */
3212 register_life_up_to_date = 0;
3214 #ifdef OPTIMIZE_MODE_SWITCHING
3215 timevar_push (TV_MODE_SWITCH);
3217 no_new_pseudos = 0;
3218 optimize_mode_switching (NULL);
3219 no_new_pseudos = 1;
3221 timevar_pop (TV_MODE_SWITCH);
3222 #endif
3224 timevar_push (TV_SCHED);
3226 #ifdef INSN_SCHEDULING
3228 /* Print function header into sched dump now
3229 because doing the sched analysis makes some of the dump. */
3230 if (optimize > 0 && flag_schedule_insns)
3232 open_dump_file (DFI_sched, decl);
3234 /* Do control and data sched analysis,
3235 and write some of the results to dump file. */
3237 schedule_insns (rtl_dump_file);
3239 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3241 /* Register lifetime information was updated as part of verifying
3242 the schedule. */
3243 register_life_up_to_date = 1;
3245 #endif
3246 timevar_pop (TV_SCHED);
3248 ggc_collect ();
3250 /* Determine if the current function is a leaf before running reload
3251 since this can impact optimizations done by the prologue and
3252 epilogue thus changing register elimination offsets. */
3253 current_function_is_leaf = leaf_function_p ();
3255 timevar_push (TV_LOCAL_ALLOC);
3256 open_dump_file (DFI_lreg, decl);
3258 /* Allocate pseudo-regs that are used only within 1 basic block.
3260 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3261 jump optimizer after register allocation and reloading are finished. */
3263 if (! register_life_up_to_date)
3264 recompute_reg_usage (insns, ! optimize_size);
3266 if (flag_new_regalloc)
3268 delete_trivially_dead_insns (insns, max_reg_num ());
3269 reg_alloc ();
3271 timevar_pop (TV_LOCAL_ALLOC);
3272 if (dump_file[DFI_lreg].enabled)
3274 timevar_push (TV_DUMP);
3276 close_dump_file (DFI_lreg, NULL, NULL);
3277 timevar_pop (TV_DUMP);
3280 /* XXX clean up the whole mess to bring live info in shape again. */
3281 timevar_push (TV_GLOBAL_ALLOC);
3282 open_dump_file (DFI_greg, decl);
3284 build_insn_chain (insns);
3285 failure = reload (insns, 0);
3287 timevar_pop (TV_GLOBAL_ALLOC);
3289 if (dump_file[DFI_greg].enabled)
3291 timevar_push (TV_DUMP);
3293 dump_global_regs (rtl_dump_file);
3295 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3296 timevar_pop (TV_DUMP);
3299 if (failure)
3300 goto exit_rest_of_compilation;
3301 reload_completed = 1;
3302 rebuild_label_notes_after_reload = 0;
3304 else
3306 /* Allocate the reg_renumber array. */
3307 allocate_reg_info (max_regno, FALSE, TRUE);
3309 /* And the reg_equiv_memory_loc array. */
3310 reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
3312 allocate_initial_values (reg_equiv_memory_loc);
3314 regclass (insns, max_reg_num (), rtl_dump_file);
3315 rebuild_label_notes_after_reload = local_alloc ();
3317 timevar_pop (TV_LOCAL_ALLOC);
3319 if (dump_file[DFI_lreg].enabled)
3321 timevar_push (TV_DUMP);
3323 dump_flow_info (rtl_dump_file);
3324 dump_local_alloc (rtl_dump_file);
3326 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3327 timevar_pop (TV_DUMP);
3330 ggc_collect ();
3332 timevar_push (TV_GLOBAL_ALLOC);
3333 open_dump_file (DFI_greg, decl);
3335 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3336 pass fixing up any insns that are invalid. */
3338 if (optimize)
3339 failure = global_alloc (rtl_dump_file);
3340 else
3342 build_insn_chain (insns);
3343 failure = reload (insns, 0);
3346 timevar_pop (TV_GLOBAL_ALLOC);
3348 if (dump_file[DFI_greg].enabled)
3350 timevar_push (TV_DUMP);
3352 dump_global_regs (rtl_dump_file);
3354 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3355 timevar_pop (TV_DUMP);
3358 if (failure)
3359 goto exit_rest_of_compilation;
3362 ggc_collect ();
3364 open_dump_file (DFI_postreload, decl);
3366 /* Do a very simple CSE pass over just the hard registers. */
3367 if (optimize > 0)
3369 timevar_push (TV_RELOAD_CSE_REGS);
3370 reload_cse_regs (insns);
3371 timevar_pop (TV_RELOAD_CSE_REGS);
3374 /* Register allocation and reloading may have turned an indirect jump into
3375 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3376 jumping instructions. */
3377 if (rebuild_label_notes_after_reload)
3379 timevar_push (TV_JUMP);
3381 rebuild_jump_labels (insns);
3382 purge_all_dead_edges (0);
3384 timevar_pop (TV_JUMP);
3387 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3389 /* Re-create the death notes which were deleted during reload. */
3390 timevar_push (TV_FLOW2);
3391 open_dump_file (DFI_flow2, decl);
3393 #ifdef ENABLE_CHECKING
3394 verify_flow_info ();
3395 #endif
3397 /* If optimizing, then go ahead and split insns now. */
3398 if (optimize > 0)
3399 split_all_insns (0);
3401 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
3403 /* On some machines, the prologue and epilogue code, or parts thereof,
3404 can be represented as RTL. Doing so lets us schedule insns between
3405 it and the rest of the code and also allows delayed branch
3406 scheduling to operate in the epilogue. */
3407 thread_prologue_and_epilogue_insns (insns);
3409 if (optimize)
3411 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3412 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
3413 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3415 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3416 even for machines with possibly nonzero RETURN_POPS_ARGS
3417 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3418 push instructions will have popping returns. */
3419 #ifndef PUSH_ROUNDING
3420 if (!ACCUMULATE_OUTGOING_ARGS)
3421 #endif
3422 combine_stack_adjustments ();
3424 ggc_collect ();
3427 flow2_completed = 1;
3429 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3430 timevar_pop (TV_FLOW2);
3432 #ifdef HAVE_peephole2
3433 if (optimize > 0 && flag_peephole2)
3435 timevar_push (TV_PEEPHOLE2);
3436 open_dump_file (DFI_peephole2, decl);
3438 peephole2_optimize (rtl_dump_file);
3440 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3441 timevar_pop (TV_PEEPHOLE2);
3443 #endif
3445 if (optimize > 0 && (flag_rename_registers || flag_cprop_registers))
3447 timevar_push (TV_RENAME_REGISTERS);
3448 open_dump_file (DFI_rnreg, decl);
3450 if (flag_rename_registers)
3451 regrename_optimize ();
3452 if (flag_cprop_registers)
3453 copyprop_hardreg_forward ();
3455 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3456 timevar_pop (TV_RENAME_REGISTERS);
3459 if (flag_if_conversion2)
3461 timevar_push (TV_IFCVT2);
3462 open_dump_file (DFI_ce3, decl);
3464 if_convert (1);
3466 close_dump_file (DFI_ce3, print_rtl_with_bb, insns);
3467 timevar_pop (TV_IFCVT2);
3469 #ifdef STACK_REGS
3470 if (optimize)
3471 split_all_insns (1);
3472 #endif
3474 #ifdef INSN_SCHEDULING
3475 if (optimize > 0 && flag_schedule_insns_after_reload)
3477 timevar_push (TV_SCHED2);
3478 open_dump_file (DFI_sched2, decl);
3480 /* Do control and data sched analysis again,
3481 and write some more of the results to dump file. */
3483 split_all_insns (1);
3485 schedule_insns (rtl_dump_file);
3487 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3488 timevar_pop (TV_SCHED2);
3490 ggc_collect ();
3492 #endif
3494 #ifdef LEAF_REGISTERS
3495 current_function_uses_only_leaf_regs
3496 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3497 #endif
3499 #ifdef STACK_REGS
3500 timevar_push (TV_REG_STACK);
3501 open_dump_file (DFI_stack, decl);
3503 reg_to_stack (insns, rtl_dump_file);
3505 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3506 timevar_pop (TV_REG_STACK);
3508 ggc_collect ();
3509 #endif
3510 if (optimize > 0)
3512 timevar_push (TV_REORDER_BLOCKS);
3513 open_dump_file (DFI_bbro, decl);
3515 /* Last attempt to optimize CFG, as scheduling, peepholing and insn
3516 splitting possibly introduced more crossjumping opportunities.
3517 Except that we can't actually run crossjumping without running
3518 another DCE pass, which we can't do after reg-stack. */
3519 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
3520 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3521 if (flag_reorder_blocks)
3523 reorder_basic_blocks ();
3524 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
3527 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3528 timevar_pop (TV_REORDER_BLOCKS);
3530 compute_alignments ();
3532 /* CFG is no longer maintained up-to-date. */
3533 free_bb_for_insn ();
3535 /* If a machine dependent reorganization is needed, call it. */
3536 #ifdef MACHINE_DEPENDENT_REORG
3537 timevar_push (TV_MACH_DEP);
3538 open_dump_file (DFI_mach, decl);
3540 MACHINE_DEPENDENT_REORG (insns);
3542 close_dump_file (DFI_mach, print_rtl, insns);
3543 timevar_pop (TV_MACH_DEP);
3545 ggc_collect ();
3546 #endif
3548 purge_line_number_notes (insns);
3549 cleanup_barriers ();
3551 /* If a scheduling pass for delayed branches is to be done,
3552 call the scheduling code. */
3554 #ifdef DELAY_SLOTS
3555 if (optimize > 0 && flag_delayed_branch)
3557 timevar_push (TV_DBR_SCHED);
3558 open_dump_file (DFI_dbr, decl);
3560 dbr_schedule (insns, rtl_dump_file);
3562 close_dump_file (DFI_dbr, print_rtl, insns);
3563 timevar_pop (TV_DBR_SCHED);
3565 ggc_collect ();
3567 #endif
3569 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3570 timevar_push (TV_SHORTEN_BRANCH);
3571 split_all_insns_noflow ();
3572 timevar_pop (TV_SHORTEN_BRANCH);
3573 #endif
3575 convert_to_eh_region_ranges ();
3577 /* Shorten branches. */
3578 timevar_push (TV_SHORTEN_BRANCH);
3579 shorten_branches (get_insns ());
3580 timevar_pop (TV_SHORTEN_BRANCH);
3582 set_nothrow_function_flags ();
3583 if (current_function_nothrow)
3584 /* Now we know that this can't throw; set the flag for the benefit
3585 of other functions later in this translation unit. */
3586 TREE_NOTHROW (current_function_decl) = 1;
3588 /* Now turn the rtl into assembler code. */
3590 timevar_push (TV_FINAL);
3592 rtx x;
3593 const char *fnname;
3595 /* Get the function's name, as described by its RTL. This may be
3596 different from the DECL_NAME name used in the source file. */
3598 x = DECL_RTL (decl);
3599 if (GET_CODE (x) != MEM)
3600 abort ();
3601 x = XEXP (x, 0);
3602 if (GET_CODE (x) != SYMBOL_REF)
3603 abort ();
3604 fnname = XSTR (x, 0);
3606 assemble_start_function (decl, fnname);
3607 final_start_function (insns, asm_out_file, optimize);
3608 final (insns, asm_out_file, optimize, 0);
3609 final_end_function ();
3611 #ifdef IA64_UNWIND_INFO
3612 /* ??? The IA-64 ".handlerdata" directive must be issued before
3613 the ".endp" directive that closes the procedure descriptor. */
3614 output_function_exception_table ();
3615 #endif
3617 assemble_end_function (decl, fnname);
3619 #ifndef IA64_UNWIND_INFO
3620 /* Otherwise, it feels unclean to switch sections in the middle. */
3621 output_function_exception_table ();
3622 #endif
3624 if (! quiet_flag)
3625 fflush (asm_out_file);
3627 /* Release all memory allocated by flow. */
3628 free_basic_block_vars (0);
3630 /* Release all memory held by regsets now. */
3631 regset_release_memory ();
3633 timevar_pop (TV_FINAL);
3635 ggc_collect ();
3637 /* Write DBX symbols if requested. */
3639 /* Note that for those inline functions where we don't initially
3640 know for certain that we will be generating an out-of-line copy,
3641 the first invocation of this routine (rest_of_compilation) will
3642 skip over this code by doing a `goto exit_rest_of_compilation;'.
3643 Later on, wrapup_global_declarations will (indirectly) call
3644 rest_of_compilation again for those inline functions that need
3645 to have out-of-line copies generated. During that call, we
3646 *will* be routed past here. */
3648 timevar_push (TV_SYMOUT);
3649 (*debug_hooks->function_decl) (decl);
3650 timevar_pop (TV_SYMOUT);
3652 exit_rest_of_compilation:
3654 /* In case the function was not output,
3655 don't leave any temporary anonymous types
3656 queued up for sdb output. */
3657 #ifdef SDB_DEBUGGING_INFO
3658 if (write_symbols == SDB_DEBUG)
3659 sdbout_types (NULL_TREE);
3660 #endif
3662 reload_completed = 0;
3663 flow2_completed = 0;
3664 no_new_pseudos = 0;
3666 timevar_push (TV_FINAL);
3668 /* Clear out the insn_length contents now that they are no
3669 longer valid. */
3670 init_insn_lengths ();
3672 /* Show no temporary slots allocated. */
3673 init_temp_slots ();
3675 free_basic_block_vars (0);
3676 free_bb_for_insn ();
3678 timevar_pop (TV_FINAL);
3680 /* Make sure volatile mem refs aren't considered valid operands for
3681 arithmetic insns. We must call this here if this is a nested inline
3682 function, since the above code leaves us in the init_recog state
3683 (from final.c), and the function context push/pop code does not
3684 save/restore volatile_ok.
3686 ??? Maybe it isn't necessary for expand_start_function to call this
3687 anymore if we do it here? */
3689 init_recog_no_volatile ();
3691 /* We're done with this function. Free up memory if we can. */
3692 free_after_parsing (cfun);
3693 if (! DECL_DEFER_OUTPUT (decl))
3695 free_after_compilation (cfun);
3697 /* Clear integrate.c's pointer to the cfun structure we just
3698 destroyed. */
3699 DECL_SAVED_INSNS (decl) = 0;
3701 cfun = 0;
3703 ggc_collect ();
3705 timevar_pop (TV_REST_OF_COMPILATION);
3708 static void
3709 display_help ()
3711 int undoc;
3712 unsigned long i;
3713 const char *lang;
3715 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3716 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3717 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3718 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3719 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3720 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"));
3721 printf (_(" -ftls-model=[global-dynamic | local-dynamic | initial-exec | local-exec] Indicates the default thread-local storage code generation model\n"));
3723 for (i = ARRAY_SIZE (f_options); i--;)
3725 const char *description = f_options[i].description;
3727 if (description != NULL && *description != 0)
3728 printf (" -f%-21s %s\n",
3729 f_options[i].string, _(description));
3732 printf (_(" -O[number] Set optimization level to [number]\n"));
3733 printf (_(" -Os Optimize for space rather than speed\n"));
3734 for (i = LAST_PARAM; i--;)
3736 const char *description = compiler_params[i].help;
3737 const int length = 21 - strlen (compiler_params[i].option);
3739 if (description != NULL && *description != 0)
3740 printf (" --param %s=<value>%.*s%s\n",
3741 compiler_params[i].option,
3742 length > 0 ? length : 1, " ",
3743 _(description));
3745 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3746 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3747 printf (_(" -w Suppress warnings\n"));
3749 for (i = ARRAY_SIZE (W_options); i--;)
3751 const char *description = W_options[i].description;
3753 if (description != NULL && *description != 0)
3754 printf (" -W%-21s %s\n",
3755 W_options[i].string, _(description));
3758 printf (_(" -Wunused Enable unused warnings\n"));
3759 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3760 printf (_(" -p Enable function profiling\n"));
3761 printf (_(" -o <file> Place output into <file> \n"));
3762 printf (_("\
3763 -G <number> Put global and static data smaller than <number>\n\
3764 bytes into a special section (on some targets)\n"));
3766 for (i = ARRAY_SIZE (debug_args); i--;)
3768 if (debug_args[i].description != NULL)
3769 printf (" -g%-21s %s\n",
3770 debug_args[i].arg, _(debug_args[i].description));
3773 printf (_(" -aux-info <file> Emit declaration info into <file>\n"));
3774 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3775 printf (_(" -version Display the compiler's version\n"));
3776 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3777 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3778 #if defined INSN_SCHEDULING
3779 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3780 #endif
3781 printf (_(" --help Display this information\n"));
3783 undoc = 0;
3784 lang = "language";
3786 /* Display descriptions of language specific options.
3787 If there is no description, note that there is an undocumented option.
3788 If the description is empty, do not display anything. (This allows
3789 options to be deliberately undocumented, for whatever reason).
3790 If the option string is missing, then this is a marker, indicating
3791 that the description string is in fact the name of a language, whose
3792 language specific options are to follow. */
3794 if (ARRAY_SIZE (documented_lang_options) > 1)
3796 printf (_("\nLanguage specific options:\n"));
3798 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3800 const char *description = documented_lang_options[i].description;
3801 const char *option = documented_lang_options[i].option;
3803 if (description == NULL)
3805 undoc = 1;
3807 if (extra_warnings)
3808 printf (_(" %-23.23s [undocumented]\n"), option);
3810 else if (*description == 0)
3811 continue;
3812 else if (option == NULL)
3814 if (undoc)
3815 printf
3816 (_("\nThere are undocumented %s specific options as well.\n"),
3817 lang);
3818 undoc = 0;
3820 printf (_("\n Options for %s:\n"), description);
3822 lang = description;
3824 else
3825 printf (" %-23.23s %s\n", option, _(description));
3829 if (undoc)
3830 printf (_("\nThere are undocumented %s specific options as well.\n"),
3831 lang);
3833 display_target_options ();
3836 static void
3837 display_target_options ()
3839 int undoc, i;
3840 static bool displayed = false;
3842 /* Avoid double printing for --help --target-help. */
3843 if (displayed)
3844 return;
3845 displayed = true;
3847 if (ARRAY_SIZE (target_switches) > 1
3848 #ifdef TARGET_OPTIONS
3849 || ARRAY_SIZE (target_options) > 1
3850 #endif
3853 int doc = 0;
3855 undoc = 0;
3857 printf (_("\nTarget specific options:\n"));
3859 for (i = ARRAY_SIZE (target_switches); i--;)
3861 const char *option = target_switches[i].name;
3862 const char *description = target_switches[i].description;
3864 if (option == NULL || *option == 0)
3865 continue;
3866 else if (description == NULL)
3868 undoc = 1;
3870 if (extra_warnings)
3871 printf (_(" -m%-23.23s [undocumented]\n"), option);
3873 else if (*description != 0)
3874 doc += printf (" -m%-23.23s %s\n", option, _(description));
3877 #ifdef TARGET_OPTIONS
3878 for (i = ARRAY_SIZE (target_options); i--;)
3880 const char *option = target_options[i].prefix;
3881 const char *description = target_options[i].description;
3883 if (option == NULL || *option == 0)
3884 continue;
3885 else if (description == NULL)
3887 undoc = 1;
3889 if (extra_warnings)
3890 printf (_(" -m%-23.23s [undocumented]\n"), option);
3892 else if (*description != 0)
3893 doc += printf (" -m%-23.23s %s\n", option, _(description));
3895 #endif
3896 if (undoc)
3898 if (doc)
3899 printf (_("\nThere are undocumented target specific options as well.\n"));
3900 else
3901 printf (_(" They exist, but they are not documented.\n"));
3906 /* Parse a -d... command line switch. */
3908 static void
3909 decode_d_option (arg)
3910 const char *arg;
3912 int i, c, matched;
3914 while (*arg)
3915 switch (c = *arg++)
3917 case 'a':
3918 for (i = 0; i < (int) DFI_MAX; ++i)
3919 dump_file[i].enabled = 1;
3920 break;
3921 case 'A':
3922 flag_debug_asm = 1;
3923 break;
3924 case 'p':
3925 flag_print_asm_name = 1;
3926 break;
3927 case 'P':
3928 flag_dump_rtl_in_asm = 1;
3929 flag_print_asm_name = 1;
3930 break;
3931 case 'v':
3932 graph_dump_format = vcg;
3933 break;
3934 case 'x':
3935 rtl_dump_and_exit = 1;
3936 break;
3937 case 'y':
3938 set_yydebug = 1;
3939 break;
3940 case 'D': /* These are handled by the preprocessor. */
3941 case 'I':
3942 break;
3944 default:
3945 matched = 0;
3946 for (i = 0; i < (int) DFI_MAX; ++i)
3947 if (c == dump_file[i].debug_switch)
3949 dump_file[i].enabled = 1;
3950 matched = 1;
3953 if (! matched)
3954 warning ("unrecognized gcc debugging option: %c", c);
3955 break;
3959 /* Parse a -f... command line switch. ARG is the value after the -f.
3960 It is safe to access 'ARG - 2' to generate the full switch name.
3961 Return the number of strings consumed. */
3963 static int
3964 decode_f_option (arg)
3965 const char *arg;
3967 int j;
3968 const char *option_value = NULL;
3970 /* Search for the option in the table of binary f options. */
3971 for (j = ARRAY_SIZE (f_options); j--;)
3973 if (!strcmp (arg, f_options[j].string))
3975 *f_options[j].variable = f_options[j].on_value;
3976 return 1;
3979 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3980 && ! strcmp (arg + 3, f_options[j].string))
3982 *f_options[j].variable = ! f_options[j].on_value;
3983 return 1;
3987 if (!strcmp (arg, "fast-math"))
3988 set_fast_math_flags (1);
3989 else if (!strcmp (arg, "no-fast-math"))
3990 set_fast_math_flags (0);
3991 else if ((option_value = skip_leading_substring (arg, "inline-limit-"))
3992 || (option_value = skip_leading_substring (arg, "inline-limit=")))
3994 int val =
3995 read_integral_parameter (option_value, arg - 2,
3996 MAX_INLINE_INSNS);
3997 set_param_value ("max-inline-insns", val);
3999 else if ((option_value = skip_leading_substring (arg, "tls-model=")))
4001 if (strcmp (option_value, "global-dynamic") == 0)
4002 flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
4003 else if (strcmp (option_value, "local-dynamic") == 0)
4004 flag_tls_default = TLS_MODEL_LOCAL_DYNAMIC;
4005 else if (strcmp (option_value, "initial-exec") == 0)
4006 flag_tls_default = TLS_MODEL_INITIAL_EXEC;
4007 else if (strcmp (option_value, "local-exec") == 0)
4008 flag_tls_default = TLS_MODEL_LOCAL_EXEC;
4009 else
4010 warning ("`%s': unknown tls-model option", arg - 2);
4012 #ifdef INSN_SCHEDULING
4013 else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
4014 fix_sched_param ("verbose", option_value);
4015 #endif
4016 else if ((option_value = skip_leading_substring (arg, "fixed-")))
4017 fix_register (option_value, 1, 1);
4018 else if ((option_value = skip_leading_substring (arg, "call-used-")))
4019 fix_register (option_value, 0, 1);
4020 else if ((option_value = skip_leading_substring (arg, "call-saved-")))
4021 fix_register (option_value, 0, 0);
4022 else if ((option_value = skip_leading_substring (arg, "align-loops=")))
4023 align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
4024 else if ((option_value = skip_leading_substring (arg, "align-functions=")))
4025 align_functions
4026 = read_integral_parameter (option_value, arg - 2, align_functions);
4027 else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
4028 align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
4029 else if ((option_value = skip_leading_substring (arg, "align-labels=")))
4030 align_labels
4031 = read_integral_parameter (option_value, arg - 2, align_labels);
4032 else if ((option_value
4033 = skip_leading_substring (arg, "stack-limit-register=")))
4035 int reg = decode_reg_name (option_value);
4036 if (reg < 0)
4037 error ("unrecognized register name `%s'", option_value);
4038 else
4039 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
4041 else if ((option_value
4042 = skip_leading_substring (arg, "stack-limit-symbol=")))
4044 const char *nm;
4045 nm = ggc_strdup (option_value);
4046 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
4048 else if ((option_value
4049 = skip_leading_substring (arg, "message-length=")))
4050 output_set_maximum_length
4051 (&global_dc->buffer, read_integral_parameter
4052 (option_value, arg - 2, diagnostic_line_cutoff (global_dc)));
4053 else if ((option_value
4054 = skip_leading_substring (arg, "diagnostics-show-location=")))
4056 if (!strcmp (option_value, "once"))
4057 diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
4058 else if (!strcmp (option_value, "every-line"))
4059 diagnostic_prefixing_rule (global_dc)
4060 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
4061 else
4062 error ("unrecognized option `%s'", arg - 2);
4064 else if (!strcmp (arg, "no-stack-limit"))
4065 stack_limit_rtx = NULL_RTX;
4066 else if (!strcmp (arg, "preprocessed"))
4067 /* Recognize this switch but do nothing. This prevents warnings
4068 about an unrecognized switch if cpplib has not been linked in. */
4070 else
4071 return 0;
4073 return 1;
4076 /* Parse a -W... command line switch. ARG is the value after the -W.
4077 It is safe to access 'ARG - 2' to generate the full switch name.
4078 Return the number of strings consumed. */
4080 static int
4081 decode_W_option (arg)
4082 const char *arg;
4084 const char *option_value = NULL;
4085 int j;
4087 /* Search for the option in the table of binary W options. */
4089 for (j = ARRAY_SIZE (W_options); j--;)
4091 if (!strcmp (arg, W_options[j].string))
4093 *W_options[j].variable = W_options[j].on_value;
4094 return 1;
4097 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4098 && ! strcmp (arg + 3, W_options[j].string))
4100 *W_options[j].variable = ! W_options[j].on_value;
4101 return 1;
4105 if ((option_value = skip_leading_substring (arg, "id-clash-")))
4106 warning ("-Wid-clash-LEN is no longer supported");
4107 else if ((option_value = skip_leading_substring (arg, "larger-than-")))
4109 larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
4111 warn_larger_than = larger_than_size != -1;
4113 else if (!strcmp (arg, "unused"))
4115 set_Wunused (1);
4117 else if (!strcmp (arg, "no-unused"))
4119 set_Wunused (0);
4121 else if (!strcmp (arg, "extra"))
4123 /* We save the value of warn_uninitialized, since if they put
4124 -Wuninitialized on the command line, we need to generate a
4125 warning about not using it without also specifying -O. */
4126 if (warn_uninitialized != 1)
4127 warn_uninitialized = 2;
4129 else
4130 return 0;
4132 return 1;
4135 /* Parse a -g... command line switch. ARG is the value after the -g.
4136 It is safe to access 'ARG - 2' to generate the full switch name.
4137 Return the number of strings consumed. */
4139 static int
4140 decode_g_option (arg)
4141 const char *arg;
4143 static unsigned level = 0;
4144 /* A lot of code assumes write_symbols == NO_DEBUG if the
4145 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4146 of what debugging type has been selected). This records the
4147 selected type. It is an error to specify more than one
4148 debugging type. */
4149 static enum debug_info_type selected_debug_type = NO_DEBUG;
4150 /* Nonzero if debugging format has been explicitly set.
4151 -g and -ggdb don't explicitly set the debugging format so
4152 -gdwarf -g3 is equivalent to -gdwarf3. */
4153 static int type_explicitly_set_p = 0;
4154 /* Indexed by enum debug_info_type. */
4155 static const char *const debug_type_names[] =
4157 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
4160 /* The maximum admissible debug level value. */
4161 static const unsigned max_debug_level = 3;
4163 /* Look up ARG in the table. */
4164 for (da = debug_args; da->arg; da++)
4166 const int da_len = strlen (da->arg);
4168 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4170 enum debug_info_type type = da->debug_type;
4171 const char *p = arg + da_len;
4173 if (*p && ! ISDIGIT (*p))
4174 continue;
4176 /* A debug flag without a level defaults to level 2.
4177 Note we do not want to call read_integral_parameter
4178 for that case since it will call atoi which
4179 will return zero.
4181 ??? We may want to generalize the interface to
4182 read_integral_parameter to better handle this case
4183 if this case shows up often. */
4184 if (*p)
4185 level = read_integral_parameter (p, 0, max_debug_level + 1);
4186 else
4187 level = (level == 0) ? 2 : level;
4189 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4191 error ("use -gdwarf -g%d for DWARF v1, level %d",
4192 level, level);
4193 if (level == 2)
4194 error ("use -gdwarf-2 for DWARF v2");
4197 if (level > max_debug_level)
4199 warning ("\
4200 ignoring option `%s' due to invalid debug level specification",
4201 arg - 2);
4202 level = debug_info_level;
4205 if (type == NO_DEBUG)
4207 type = PREFERRED_DEBUGGING_TYPE;
4209 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4211 #ifdef DWARF2_DEBUGGING_INFO
4212 type = DWARF2_DEBUG;
4213 #else
4214 #ifdef DBX_DEBUGGING_INFO
4215 type = DBX_DEBUG;
4216 #endif
4217 #endif
4221 if (type == NO_DEBUG)
4222 warning ("`%s': unknown or unsupported -g option", arg - 2);
4224 /* Does it conflict with an already selected type? */
4225 if (type_explicitly_set_p
4226 /* -g/-ggdb don't conflict with anything. */
4227 && da->debug_type != NO_DEBUG
4228 && type != selected_debug_type)
4229 warning ("`%s' ignored, conflicts with `-g%s'",
4230 arg - 2, debug_type_names[(int) selected_debug_type]);
4231 else
4233 /* If the format has already been set, -g/-ggdb
4234 only change the debug level. */
4235 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4236 /* Don't change debugging type. */
4238 else
4240 selected_debug_type = type;
4241 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4244 write_symbols = (level == 0
4245 ? NO_DEBUG
4246 : selected_debug_type);
4247 use_gnu_debug_info_extensions = da->use_extensions_p;
4248 debug_info_level = (enum debug_info_level) level;
4251 break;
4255 if (! da->arg)
4256 return 0;
4258 return 1;
4261 /* Decode the first argument in the argv as a language-independent option.
4262 Return the number of strings consumed. */
4264 static unsigned int
4265 independent_decode_option (argc, argv)
4266 int argc;
4267 char **argv;
4269 char *arg = argv[0];
4271 if (arg[0] != '-' || arg[1] == 0)
4273 if (arg[0] == '+')
4274 return 0;
4276 filename = arg;
4278 return 1;
4281 arg++;
4283 if (!strcmp (arg, "-help"))
4285 display_help ();
4286 exit_after_options = 1;
4289 if (!strcmp (arg, "-target-help"))
4291 display_target_options ();
4292 exit_after_options = 1;
4295 if (!strcmp (arg, "-version"))
4297 print_version (stderr, "");
4298 exit_after_options = 1;
4301 /* Handle '--param <name>=<value>'. */
4302 if (strcmp (arg, "-param") == 0)
4304 char *equal;
4306 if (argc == 1)
4308 error ("-param option missing argument");
4309 return 1;
4312 /* Get the '<name>=<value>' parameter. */
4313 arg = argv[1];
4314 /* Look for the `='. */
4315 equal = strchr (arg, '=');
4316 if (!equal)
4317 error ("invalid --param option: %s", arg);
4318 else
4320 int val;
4322 /* Zero out the `=' sign so that we get two separate strings. */
4323 *equal = '\0';
4324 /* Figure out what value is specified. */
4325 val = read_integral_parameter (equal + 1, NULL, INVALID_PARAM_VAL);
4326 if (val != INVALID_PARAM_VAL)
4327 set_param_value (arg, val);
4328 else
4329 error ("invalid parameter value `%s'", equal + 1);
4332 return 2;
4335 if (*arg == 'Y')
4336 arg++;
4338 switch (*arg)
4340 default:
4341 return 0;
4343 case 'O':
4344 /* Already been treated in main (). Do nothing. */
4345 break;
4347 case 'm':
4348 set_target_switch (arg + 1);
4349 break;
4351 case 'f':
4352 return decode_f_option (arg + 1);
4354 case 'g':
4355 return decode_g_option (arg + 1);
4357 case 'd':
4358 if (!strcmp (arg, "dumpbase"))
4360 if (argc == 1)
4361 return 0;
4363 if (argv[1][0])
4364 dump_base_name = argv[1];
4366 return 2;
4368 else
4369 decode_d_option (arg + 1);
4370 break;
4372 case 'p':
4373 if (!strcmp (arg, "pedantic"))
4374 pedantic = 1;
4375 else if (!strcmp (arg, "pedantic-errors"))
4376 flag_pedantic_errors = pedantic = 1;
4377 else if (arg[1] == 0)
4378 profile_flag = 1;
4379 else
4380 return 0;
4381 break;
4383 case 'q':
4384 if (!strcmp (arg, "quiet"))
4385 quiet_flag = 1;
4386 else
4387 return 0;
4388 break;
4390 case 'v':
4391 if (!strcmp (arg, "version"))
4392 version_flag = 1;
4393 else
4394 return 0;
4395 break;
4397 case 'w':
4398 if (arg[1] == 0)
4399 inhibit_warnings = 1;
4400 else
4401 return 0;
4402 break;
4404 case 'W':
4405 if (arg[1] == 0)
4407 extra_warnings = 1;
4408 /* We save the value of warn_uninitialized, since if they put
4409 -Wuninitialized on the command line, we need to generate a
4410 warning about not using it without also specifying -O. */
4411 if (warn_uninitialized != 1)
4412 warn_uninitialized = 2;
4414 else
4415 return decode_W_option (arg + 1);
4416 break;
4418 case 'a':
4419 if (!strncmp (arg, "aux-info", 8))
4421 if (arg[8] == '\0')
4423 if (argc == 1)
4424 return 0;
4426 aux_info_file_name = argv[1];
4427 flag_gen_aux_info = 1;
4428 return 2;
4430 else if (arg[8] == '=')
4432 aux_info_file_name = arg + 9;
4433 flag_gen_aux_info = 1;
4435 else
4436 return 0;
4438 else if (!strcmp (arg, "auxbase"))
4440 if (argc == 1)
4441 return 0;
4443 if (argv[1][0])
4444 aux_base_name = argv[1];
4446 return 2;
4448 else if (!strcmp (arg, "auxbase-strip"))
4450 if (argc == 1)
4451 return 0;
4453 if (argv[1][0])
4455 strip_off_ending (argv[1], strlen (argv[1]));
4456 if (argv[1][0])
4457 aux_base_name = argv[1];
4460 return 2;
4462 else
4463 return 0;
4464 break;
4466 case 'o':
4467 if (arg[1] == 0)
4469 if (argc == 1)
4470 return 0;
4472 asm_file_name = argv[1];
4473 return 2;
4475 return 0;
4477 case 'G':
4479 int g_switch_val;
4480 int return_val;
4482 if (arg[1] == 0)
4484 if (argc == 1)
4485 return 0;
4487 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4488 return_val = 2;
4490 else
4492 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4493 return_val = 1;
4496 if (g_switch_val == -1)
4497 return_val = 0;
4498 else
4500 g_switch_set = TRUE;
4501 g_switch_value = g_switch_val;
4504 return return_val;
4508 return 1;
4511 /* Decode -m switches. */
4512 /* Decode the switch -mNAME. */
4514 static void
4515 set_target_switch (name)
4516 const char *name;
4518 size_t j;
4519 int valid_target_option = 0;
4521 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4522 if (!strcmp (target_switches[j].name, name))
4524 if (target_switches[j].value < 0)
4525 target_flags &= ~-target_switches[j].value;
4526 else
4527 target_flags |= target_switches[j].value;
4528 if (name[0] != 0)
4530 if (target_switches[j].value < 0)
4531 target_flags_explicit |= -target_switches[j].value;
4532 else
4533 target_flags_explicit |= target_switches[j].value;
4535 valid_target_option = 1;
4538 #ifdef TARGET_OPTIONS
4539 if (!valid_target_option)
4540 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4542 int len = strlen (target_options[j].prefix);
4543 if (!strncmp (target_options[j].prefix, name, len))
4545 *target_options[j].variable = name + len;
4546 valid_target_option = 1;
4549 #endif
4551 if (!valid_target_option)
4552 error ("invalid option `%s'", name);
4555 /* Print version information to FILE.
4556 Each line begins with INDENT (for the case where FILE is the
4557 assembler output file). */
4559 static void
4560 print_version (file, indent)
4561 FILE *file;
4562 const char *indent;
4564 #ifndef __VERSION__
4565 #define __VERSION__ "[?]"
4566 #endif
4567 fnotice (file,
4568 #ifdef __GNUC__
4569 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
4570 #else
4571 "%s%s%s version %s (%s) compiled by CC.\n"
4572 #endif
4573 , indent, *indent != 0 ? " " : "",
4574 lang_hooks.name, version_string, TARGET_NAME,
4575 indent, __VERSION__);
4578 /* Print an option value and return the adjusted position in the line.
4579 ??? We don't handle error returns from fprintf (disk full); presumably
4580 other code will catch a disk full though. */
4582 static int
4583 print_single_switch (file, pos, max, indent, sep, term, type, name)
4584 FILE *file;
4585 int pos, max;
4586 const char *indent, *sep, *term, *type, *name;
4588 /* The ultrix fprintf returns 0 on success, so compute the result we want
4589 here since we need it for the following test. */
4590 int len = strlen (sep) + strlen (type) + strlen (name);
4592 if (pos != 0
4593 && pos + len > max)
4595 fprintf (file, "%s", term);
4596 pos = 0;
4598 if (pos == 0)
4600 fprintf (file, "%s", indent);
4601 pos = strlen (indent);
4603 fprintf (file, "%s%s%s", sep, type, name);
4604 pos += len;
4605 return pos;
4608 /* Print active target switches to FILE.
4609 POS is the current cursor position and MAX is the size of a "line".
4610 Each line begins with INDENT and ends with TERM.
4611 Each switch is separated from the next by SEP. */
4613 static void
4614 print_switch_values (file, pos, max, indent, sep, term)
4615 FILE *file;
4616 int pos, max;
4617 const char *indent, *sep, *term;
4619 size_t j;
4620 char **p;
4622 /* Print the options as passed. */
4624 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4625 _("options passed: "), "");
4627 for (p = &save_argv[1]; *p != NULL; p++)
4628 if (**p == '-')
4630 /* Ignore these. */
4631 if (strcmp (*p, "-o") == 0)
4633 if (p[1] != NULL)
4634 p++;
4635 continue;
4637 if (strcmp (*p, "-quiet") == 0)
4638 continue;
4639 if (strcmp (*p, "-version") == 0)
4640 continue;
4641 if ((*p)[1] == 'd')
4642 continue;
4644 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4646 if (pos > 0)
4647 fprintf (file, "%s", term);
4649 /* Print the -f and -m options that have been enabled.
4650 We don't handle language specific options but printing argv
4651 should suffice. */
4653 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4654 _("options enabled: "), "");
4656 for (j = 0; j < ARRAY_SIZE (f_options); j++)
4657 if (*f_options[j].variable == f_options[j].on_value)
4658 pos = print_single_switch (file, pos, max, indent, sep, term,
4659 "-f", f_options[j].string);
4661 /* Print target specific options. */
4663 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4664 if (target_switches[j].name[0] != '\0'
4665 && target_switches[j].value > 0
4666 && ((target_switches[j].value & target_flags)
4667 == target_switches[j].value))
4669 pos = print_single_switch (file, pos, max, indent, sep, term,
4670 "-m", target_switches[j].name);
4673 #ifdef TARGET_OPTIONS
4674 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4675 if (*target_options[j].variable != NULL)
4677 char prefix[256];
4678 sprintf (prefix, "-m%s", target_options[j].prefix);
4679 pos = print_single_switch (file, pos, max, indent, sep, term,
4680 prefix, *target_options[j].variable);
4682 #endif
4684 fprintf (file, "%s", term);
4687 /* Open assembly code output file. Do this even if -fsyntax-only is
4688 on, because then the driver will have provided the name of a
4689 temporary file or bit bucket for us. NAME is the file specified on
4690 the command line, possibly NULL. */
4691 static void
4692 init_asm_output (name)
4693 const char *name;
4695 if (name == NULL && asm_file_name == 0)
4696 asm_out_file = stdout;
4697 else
4699 if (asm_file_name == 0)
4701 int len = strlen (dump_base_name);
4702 char *dumpname = (char *) xmalloc (len + 6);
4703 memcpy (dumpname, dump_base_name, len + 1);
4704 strip_off_ending (dumpname, len);
4705 strcat (dumpname, ".s");
4706 asm_file_name = dumpname;
4708 if (!strcmp (asm_file_name, "-"))
4709 asm_out_file = stdout;
4710 else
4711 asm_out_file = fopen (asm_file_name, "w+");
4712 if (asm_out_file == 0)
4713 fatal_io_error ("can't open %s for writing", asm_file_name);
4716 #ifdef IO_BUFFER_SIZE
4717 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
4718 _IOFBF, IO_BUFFER_SIZE);
4719 #endif
4721 if (!flag_syntax_only)
4723 #ifdef ASM_FILE_START
4724 ASM_FILE_START (asm_out_file);
4725 #endif
4727 #ifdef ASM_COMMENT_START
4728 if (flag_verbose_asm)
4730 /* Print the list of options in effect. */
4731 print_version (asm_out_file, ASM_COMMENT_START);
4732 print_switch_values (asm_out_file, 0, MAX_LINE,
4733 ASM_COMMENT_START, " ", "\n");
4734 /* Add a blank line here so it appears in assembler output but not
4735 screen output. */
4736 fprintf (asm_out_file, "\n");
4738 #endif
4742 /* Initialization of the front end environment, before command line
4743 options are parsed. Signal handlers, internationalization etc.
4744 ARGV0 is main's argv[0]. */
4745 static void
4746 general_init (argv0)
4747 char *argv0;
4749 char *p;
4751 p = argv0 + strlen (argv0);
4752 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4753 --p;
4754 progname = p;
4756 xmalloc_set_program_name (progname);
4758 hex_init ();
4760 gcc_init_libintl ();
4762 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4763 #ifdef SIGSEGV
4764 signal (SIGSEGV, crash_signal);
4765 #endif
4766 #ifdef SIGILL
4767 signal (SIGILL, crash_signal);
4768 #endif
4769 #ifdef SIGBUS
4770 signal (SIGBUS, crash_signal);
4771 #endif
4772 #ifdef SIGABRT
4773 signal (SIGABRT, crash_signal);
4774 #endif
4775 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4776 signal (SIGIOT, crash_signal);
4777 #endif
4778 #ifdef SIGFPE
4779 signal (SIGFPE, crash_signal);
4780 #endif
4782 /* Initialize the diagnostics reporting machinery, so option parsing
4783 can give warnings and errors. */
4784 diagnostic_initialize (global_dc);
4786 /* Initialize the garbage-collector, string pools and tree type hash
4787 table. */
4788 init_ggc ();
4789 init_stringpool ();
4790 init_ttree ();
4793 /* Parse command line options and set default flag values, called
4794 after language-independent option-independent initialization. Do
4795 minimal options processing. Outputting diagnostics is OK, but GC
4796 and identifier hashtables etc. are not initialized yet.
4798 Return nonzero to suppress compiler back end initialization. */
4799 static void
4800 parse_options_and_default_flags (argc, argv)
4801 int argc;
4802 char **argv;
4804 int i;
4806 /* Save in case md file wants to emit args as a comment. */
4807 save_argc = argc;
4808 save_argv = argv;
4810 /* Initialize register usage now so switches may override. */
4811 init_reg_sets ();
4813 /* Register the language-independent parameters. */
4814 add_params (lang_independent_params, LAST_PARAM);
4816 /* Perform language-specific options initialization. */
4817 (*lang_hooks.init_options) ();
4819 /* Scan to see what optimization level has been specified. That will
4820 determine the default value of many flags. */
4821 for (i = 1; i < argc; i++)
4823 if (!strcmp (argv[i], "-O"))
4825 optimize = 1;
4826 optimize_size = 0;
4828 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4830 /* Handle -Os, -O2, -O3, -O69, ... */
4831 char *p = &argv[i][2];
4833 if ((p[0] == 's') && (p[1] == 0))
4835 optimize_size = 1;
4837 /* Optimizing for size forces optimize to be 2. */
4838 optimize = 2;
4840 else
4842 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4843 if (optimize_val != -1)
4845 optimize = optimize_val;
4846 optimize_size = 0;
4852 if (!optimize)
4854 flag_merge_constants = 0;
4857 if (optimize >= 1)
4859 flag_defer_pop = 1;
4860 flag_thread_jumps = 1;
4861 #ifdef DELAY_SLOTS
4862 flag_delayed_branch = 1;
4863 #endif
4864 #ifdef CAN_DEBUG_WITHOUT_FP
4865 flag_omit_frame_pointer = 1;
4866 #endif
4867 flag_guess_branch_prob = 1;
4868 flag_cprop_registers = 1;
4869 flag_loop_optimize = 1;
4870 flag_crossjumping = 1;
4871 flag_if_conversion = 1;
4872 flag_if_conversion2 = 1;
4875 if (optimize >= 2)
4877 flag_optimize_sibling_calls = 1;
4878 flag_cse_follow_jumps = 1;
4879 flag_cse_skip_blocks = 1;
4880 flag_gcse = 1;
4881 flag_expensive_optimizations = 1;
4882 flag_strength_reduce = 1;
4883 flag_rerun_cse_after_loop = 1;
4884 flag_rerun_loop_opt = 1;
4885 flag_caller_saves = 1;
4886 flag_force_mem = 1;
4887 flag_peephole2 = 1;
4888 #ifdef INSN_SCHEDULING
4889 flag_schedule_insns = 1;
4890 flag_schedule_insns_after_reload = 1;
4891 #endif
4892 flag_regmove = 1;
4893 flag_strict_aliasing = 1;
4894 flag_delete_null_pointer_checks = 1;
4895 flag_reorder_blocks = 1;
4896 flag_reorder_functions = 1;
4899 if (optimize >= 3)
4901 flag_inline_functions = 1;
4902 flag_rename_registers = 1;
4905 if (optimize < 2 || optimize_size)
4907 align_loops = 1;
4908 align_jumps = 1;
4909 align_labels = 1;
4910 align_functions = 1;
4912 /* Don't reorder blocks when optimizing for size because extra
4913 jump insns may be created; also barrier may create extra padding.
4915 More correctly we should have a block reordering mode that tried
4916 to minimize the combined size of all the jumps. This would more
4917 or less automatically remove extra jumps, but would also try to
4918 use more short jumps instead of long jumps. */
4919 flag_reorder_blocks = 0;
4922 /* Initialize whether `char' is signed. */
4923 flag_signed_char = DEFAULT_SIGNED_CHAR;
4924 #ifdef DEFAULT_SHORT_ENUMS
4925 /* Initialize how much space enums occupy, by default. */
4926 flag_short_enums = DEFAULT_SHORT_ENUMS;
4927 #endif
4929 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4930 modify it. */
4931 target_flags = 0;
4932 set_target_switch ("");
4934 /* Unwind tables are always present in an ABI-conformant IA-64
4935 object file, so the default should be ON. */
4936 #ifdef IA64_UNWIND_INFO
4937 flag_unwind_tables = IA64_UNWIND_INFO;
4938 #endif
4940 #ifdef OPTIMIZATION_OPTIONS
4941 /* Allow default optimizations to be specified on a per-machine basis. */
4942 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4943 #endif
4945 /* Perform normal command line switch decoding. */
4946 for (i = 1; i < argc;)
4948 int lang_processed;
4949 int indep_processed;
4951 /* Give the language a chance to decode the option for itself. */
4952 lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
4954 if (lang_processed >= 0)
4955 /* Now see if the option also has a language independent meaning.
4956 Some options are both language specific and language independent,
4957 eg --help. */
4958 indep_processed = independent_decode_option (argc - i, argv + i);
4959 else
4961 lang_processed = -lang_processed;
4962 indep_processed = 0;
4965 if (lang_processed || indep_processed)
4966 i += MAX (lang_processed, indep_processed);
4967 else
4969 const char *option = NULL;
4970 const char *lang = NULL;
4971 unsigned int j;
4973 /* It is possible that the command line switch is not valid for the
4974 current language, but it is valid for another language. In order
4975 to be compatible with previous versions of the compiler (which
4976 did not issue an error message in this case) we check for this
4977 possibility here. If we do find a match, then if extra_warnings
4978 is set we generate a warning message, otherwise we will just
4979 ignore the option. */
4980 for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4982 option = documented_lang_options[j].option;
4984 if (option == NULL)
4985 lang = documented_lang_options[j].description;
4986 else if (! strncmp (argv[i], option, strlen (option)))
4987 break;
4990 if (j != ARRAY_SIZE (documented_lang_options))
4992 if (extra_warnings)
4994 warning ("ignoring command line option '%s'", argv[i]);
4995 if (lang)
4996 warning
4997 ("(it is valid for %s but not the selected language)",
4998 lang);
5001 else if (argv[i][0] == '-' && argv[i][1] == 'g')
5002 warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
5003 else
5004 error ("unrecognized option `%s'", argv[i]);
5006 i++;
5010 if (flag_no_inline == 2)
5011 flag_no_inline = 0;
5012 else
5013 flag_really_no_inline = flag_no_inline;
5015 /* Set flag_no_inline before the post_options () hook. The C front
5016 ends use it to determine tree inlining defaults. FIXME: such
5017 code should be lang-independent when all front ends use tree
5018 inlining, in which case it, and this condition, should be moved
5019 to the top of process_options() instead. */
5020 if (optimize == 0)
5022 /* Inlining does not work if not optimizing,
5023 so force it not to be done. */
5024 flag_no_inline = 1;
5025 warn_inline = 0;
5027 /* The c_decode_option function and decode_option hook set
5028 this to `2' if -Wall is used, so we can avoid giving out
5029 lots of errors for people who don't realize what -Wall does. */
5030 if (warn_uninitialized == 1)
5031 warning ("-Wuninitialized is not supported without -O");
5034 if (flag_really_no_inline == 2)
5035 flag_really_no_inline = flag_no_inline;
5038 /* Process the options that have been parsed. */
5039 static void
5040 process_options ()
5042 #ifdef OVERRIDE_OPTIONS
5043 /* Some machines may reject certain combinations of options. */
5044 OVERRIDE_OPTIONS;
5045 #endif
5047 /* Set up the align_*_log variables, defaulting them to 1 if they
5048 were still unset. */
5049 if (align_loops <= 0) align_loops = 1;
5050 if (align_loops_max_skip > align_loops || !align_loops)
5051 align_loops_max_skip = align_loops - 1;
5052 align_loops_log = floor_log2 (align_loops * 2 - 1);
5053 if (align_jumps <= 0) align_jumps = 1;
5054 if (align_jumps_max_skip > align_jumps || !align_jumps)
5055 align_jumps_max_skip = align_jumps - 1;
5056 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
5057 if (align_labels <= 0) align_labels = 1;
5058 align_labels_log = floor_log2 (align_labels * 2 - 1);
5059 if (align_labels_max_skip > align_labels || !align_labels)
5060 align_labels_max_skip = align_labels - 1;
5061 if (align_functions <= 0) align_functions = 1;
5062 align_functions_log = floor_log2 (align_functions * 2 - 1);
5064 /* Unrolling all loops implies that standard loop unrolling must also
5065 be done. */
5066 if (flag_unroll_all_loops)
5067 flag_unroll_loops = 1;
5068 /* Loop unrolling requires that strength_reduction be on also. Silently
5069 turn on strength reduction here if it isn't already on. Also, the loop
5070 unrolling code assumes that cse will be run after loop, so that must
5071 be turned on also. */
5072 if (flag_unroll_loops)
5074 flag_strength_reduce = 1;
5075 flag_rerun_cse_after_loop = 1;
5078 if (flag_non_call_exceptions)
5079 flag_asynchronous_unwind_tables = 1;
5080 if (flag_asynchronous_unwind_tables)
5081 flag_unwind_tables = 1;
5083 /* Warn about options that are not supported on this machine. */
5084 #ifndef INSN_SCHEDULING
5085 if (flag_schedule_insns || flag_schedule_insns_after_reload)
5086 warning ("instruction scheduling not supported on this target machine");
5087 #endif
5088 #ifndef DELAY_SLOTS
5089 if (flag_delayed_branch)
5090 warning ("this target machine does not have delayed branches");
5091 #endif
5093 user_label_prefix = USER_LABEL_PREFIX;
5094 if (flag_leading_underscore != -1)
5096 /* If the default prefix is more complicated than "" or "_",
5097 issue a warning and ignore this option. */
5098 if (user_label_prefix[0] == 0 ||
5099 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5101 user_label_prefix = flag_leading_underscore ? "_" : "";
5103 else
5104 warning ("-f%sleading-underscore not supported on this target machine",
5105 flag_leading_underscore ? "" : "no-");
5108 /* If we are in verbose mode, write out the version and maybe all the
5109 option flags in use. */
5110 if (version_flag)
5112 print_version (stderr, "");
5113 if (! quiet_flag)
5114 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5117 if (! quiet_flag)
5118 time_report = 1;
5120 if (flag_syntax_only)
5122 write_symbols = NO_DEBUG;
5123 profile_flag = 0;
5126 /* Now we know write_symbols, set up the debug hooks based on it.
5127 By default we do nothing for debug output. */
5128 #if defined(DBX_DEBUGGING_INFO)
5129 if (write_symbols == DBX_DEBUG)
5130 debug_hooks = &dbx_debug_hooks;
5131 #endif
5132 #if defined(XCOFF_DEBUGGING_INFO)
5133 if (write_symbols == XCOFF_DEBUG)
5134 debug_hooks = &xcoff_debug_hooks;
5135 #endif
5136 #ifdef SDB_DEBUGGING_INFO
5137 if (write_symbols == SDB_DEBUG)
5138 debug_hooks = &sdb_debug_hooks;
5139 #endif
5140 #ifdef DWARF_DEBUGGING_INFO
5141 if (write_symbols == DWARF_DEBUG)
5142 debug_hooks = &dwarf_debug_hooks;
5143 #endif
5144 #ifdef DWARF2_DEBUGGING_INFO
5145 if (write_symbols == DWARF2_DEBUG)
5146 debug_hooks = &dwarf2_debug_hooks;
5147 #endif
5148 #ifdef VMS_DEBUGGING_INFO
5149 if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
5150 debug_hooks = &vmsdbg_debug_hooks;
5151 #endif
5153 /* If auxiliary info generation is desired, open the output file.
5154 This goes in the same directory as the source file--unlike
5155 all the other output files. */
5156 if (flag_gen_aux_info)
5158 aux_info_file = fopen (aux_info_file_name, "w");
5159 if (aux_info_file == 0)
5160 fatal_io_error ("can't open %s", aux_info_file_name);
5163 if (! targetm.have_named_sections)
5165 if (flag_function_sections)
5167 warning ("-ffunction-sections not supported for this target");
5168 flag_function_sections = 0;
5170 if (flag_data_sections)
5172 warning ("-fdata-sections not supported for this target");
5173 flag_data_sections = 0;
5177 if (flag_function_sections && profile_flag)
5179 warning ("-ffunction-sections disabled; it makes profiling impossible");
5180 flag_function_sections = 0;
5183 #ifndef HAVE_prefetch
5184 if (flag_prefetch_loop_arrays)
5186 warning ("-fprefetch-loop-arrays not supported for this target");
5187 flag_prefetch_loop_arrays = 0;
5189 #else
5190 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
5192 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
5193 flag_prefetch_loop_arrays = 0;
5195 #endif
5197 /* This combination of options isn't handled for i386 targets and doesn't
5198 make much sense anyway, so don't allow it. */
5199 if (flag_prefetch_loop_arrays && optimize_size)
5201 warning ("-fprefetch-loop-arrays is not supported with -Os");
5202 flag_prefetch_loop_arrays = 0;
5205 #ifndef OBJECT_FORMAT_ELF
5206 if (flag_function_sections && write_symbols != NO_DEBUG)
5207 warning ("-ffunction-sections may affect debugging on some targets");
5208 #endif
5210 /* The presence of IEEE signaling NaNs, implies all math can trap. */
5211 if (flag_signaling_nans)
5212 flag_trapping_math = 1;
5215 /* Initialize the compiler back end. */
5216 static void
5217 backend_init ()
5219 /* init_emit_once uses reg_raw_mode and therefore must be called
5220 after init_regs which initialized reg_raw_mode. */
5221 init_regs ();
5222 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
5223 || debug_info_level == DINFO_LEVEL_VERBOSE
5224 #ifdef VMS_DEBUGGING_INFO
5225 /* Enable line number info for traceback */
5226 || debug_info_level > DINFO_LEVEL_NONE
5227 #endif
5228 || flag_test_coverage
5229 || warn_notreached);
5230 init_fake_stack_mems ();
5231 init_alias_once ();
5232 init_loop ();
5233 init_reload ();
5234 init_function_once ();
5235 init_varasm_once ();
5237 /* The following initialization functions need to generate rtl, so
5238 provide a dummy function context for them. */
5239 init_dummy_function_start ();
5240 init_expmed ();
5241 if (flag_caller_saves)
5242 init_caller_save ();
5243 expand_dummy_function_end ();
5246 /* Language-dependent initialization. Returns nonzero on success. */
5247 static int
5248 lang_dependent_init (name)
5249 const char *name;
5251 if (dump_base_name == 0)
5252 dump_base_name = name ? name : "gccdump";
5254 /* Front-end initialization. This hook can assume that GC,
5255 identifier hashes etc. are set up, but debug initialization is
5256 not done yet. This routine must return the original filename
5257 (e.g. foo.i -> foo.c) so can correctly initialize debug output. */
5258 name = (*lang_hooks.init) (name);
5259 if (name == NULL)
5260 return 0;
5262 /* Is this duplication necessary? */
5263 name = ggc_strdup (name);
5264 main_input_filename = input_filename = name;
5265 init_asm_output (name);
5267 /* These create various _DECL nodes, so need to be called after the
5268 front end is initialized. */
5269 init_eh ();
5270 init_optabs ();
5272 /* The following initialization functions need to generate rtl, so
5273 provide a dummy function context for them. */
5274 init_dummy_function_start ();
5275 init_expr_once ();
5276 expand_dummy_function_end ();
5278 /* Put an entry on the input file stack for the main input file. */
5279 push_srcloc (input_filename, 0);
5281 /* If dbx symbol table desired, initialize writing it and output the
5282 predefined types. */
5283 timevar_push (TV_SYMOUT);
5285 #ifdef DWARF2_UNWIND_INFO
5286 if (dwarf2out_do_frame ())
5287 dwarf2out_frame_init ();
5288 #endif
5290 /* Now we have the correct original filename, we can initialize
5291 debug output. */
5292 (*debug_hooks->init) (name);
5294 timevar_pop (TV_SYMOUT);
5296 return 1;
5299 /* Clean up: close opened files, etc. */
5301 static void
5302 finalize ()
5304 /* Close the dump files. */
5305 if (flag_gen_aux_info)
5307 fclose (aux_info_file);
5308 if (errorcount)
5309 unlink (aux_info_file_name);
5312 /* Close non-debugging input and output files. Take special care to note
5313 whether fclose returns an error, since the pages might still be on the
5314 buffer chain while the file is open. */
5316 if (asm_out_file)
5318 if (ferror (asm_out_file) != 0)
5319 fatal_io_error ("error writing to %s", asm_file_name);
5320 if (fclose (asm_out_file) != 0)
5321 fatal_io_error ("error closing %s", asm_file_name);
5324 /* Do whatever is necessary to finish printing the graphs. */
5325 if (graph_dump_format != no_graph)
5327 int i;
5329 for (i = 0; i < (int) DFI_MAX; ++i)
5330 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
5332 char seq[16];
5333 char *suffix;
5335 sprintf (seq, DUMPFILE_FORMAT, i);
5336 suffix = concat (seq, dump_file[i].extension, NULL);
5337 finish_graph_dump_file (dump_base_name, suffix);
5338 free (suffix);
5342 if (mem_report)
5344 ggc_print_statistics ();
5345 stringpool_statistics ();
5346 dump_tree_statistics ();
5349 /* Free up memory for the benefit of leak detectors. */
5350 free_reg_info ();
5352 /* Language-specific end of compilation actions. */
5353 (*lang_hooks.finish) ();
5356 /* Initialize the compiler, and compile the input file. */
5357 static void
5358 do_compile ()
5360 /* All command line options have been parsed; allow the front end to
5361 perform consistency checks, etc. */
5362 bool no_backend = (*lang_hooks.post_options) ();
5364 /* The bulk of command line switch processing. */
5365 process_options ();
5367 /* If an error has already occurred, give up. */
5368 if (errorcount)
5369 return;
5371 if (aux_base_name)
5372 /*NOP*/;
5373 else if (filename)
5375 char *name = xstrdup (lbasename (filename));
5377 aux_base_name = name;
5378 strip_off_ending (name, strlen (name));
5380 else
5381 aux_base_name = "gccaux";
5383 /* We cannot start timing until after options are processed since that
5384 says if we run timers or not. */
5385 init_timevar ();
5386 timevar_start (TV_TOTAL);
5388 /* Set up the back-end if requested. */
5389 if (!no_backend)
5390 backend_init ();
5392 /* Language-dependent initialization. Returns true on success. */
5393 if (lang_dependent_init (filename))
5394 compile_file ();
5396 finalize ();
5398 /* Stop timing and print the times. */
5399 timevar_stop (TV_TOTAL);
5400 timevar_print (stderr);
5403 /* Entry point of cc1, cc1plus, jc1, f771, etc.
5404 Decode command args, then call compile_file.
5405 Exit code is FATAL_EXIT_CODE if can't open files or if there were
5406 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
5408 It is not safe to call this function more than once. */
5411 toplev_main (argc, argv)
5412 int argc;
5413 char **argv;
5415 /* Initialization of GCC's environment, and diagnostics. */
5416 general_init (argv[0]);
5418 /* Parse the options and do minimal processing; basically just
5419 enough to default flags appropriately. */
5420 parse_options_and_default_flags (argc, argv);
5422 /* Exit early if we can (e.g. -help). */
5423 if (!exit_after_options)
5424 do_compile ();
5426 if (errorcount || sorrycount)
5427 return (FATAL_EXIT_CODE);
5429 return (SUCCESS_EXIT_CODE);