* ChangeLog: Follow spelling conventions.
[official-gcc.git] / gcc / toplev.c
blob0f7e6a5644b219060396272b12fd54d4a4fb078b
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
22 /* This is the top level of cc1/c++.
23 It parses command args, opens files, invokes the various passes
24 in the proper order, and counts the time used by each.
25 Error messages and low-level interface to malloc also handled here. */
27 #include "config.h"
28 #undef FLOAT /* This is for hpux. They should change hpux. */
29 #undef FFS /* Some systems define this in param.h. */
30 #include "system.h"
31 #include <signal.h>
33 #ifdef HAVE_SYS_RESOURCE_H
34 # include <sys/resource.h>
35 #endif
37 #ifdef HAVE_SYS_TIMES_H
38 # include <sys/times.h>
39 #endif
41 #include "input.h"
42 #include "tree.h"
43 #include "rtl.h"
44 #include "tm_p.h"
45 #include "flags.h"
46 #include "insn-attr.h"
47 #include "insn-config.h"
48 #include "insn-flags.h"
49 #include "hard-reg-set.h"
50 #include "recog.h"
51 #include "output.h"
52 #include "except.h"
53 #include "function.h"
54 #include "toplev.h"
55 #include "expr.h"
56 #include "basic-block.h"
57 #include "intl.h"
58 #include "ggc.h"
59 #include "graph.h"
60 #include "loop.h"
61 #include "regs.h"
62 #include "timevar.h"
63 #include "diagnostic.h"
64 #include "ssa.h"
65 #include "params.h"
66 #include "reload.h"
67 #include "dwarf2asm.h"
68 #include "integrate.h"
69 #include "debug.h"
70 #include "target.h"
71 #include "langhooks.h"
72 #include "cfglayout.h"
74 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
75 #include "dwarf2out.h"
76 #endif
78 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
79 #include "dbxout.h"
80 #endif
82 #ifdef SDB_DEBUGGING_INFO
83 #include "sdbout.h"
84 #endif
86 #ifdef XCOFF_DEBUGGING_INFO
87 #include "xcoffout.h" /* Needed for external data
88 declarations for e.g. AIX 4.x. */
89 #endif
91 /* Carry information from ASM_DECLARE_OBJECT_NAME
92 to ASM_FINISH_DECLARE_OBJECT. */
94 extern int size_directive_output;
95 extern tree last_assemble_variable_decl;
97 extern void reg_alloc PARAMS ((void));
99 static void general_init PARAMS ((char *));
100 static void parse_options_and_default_flags PARAMS ((int, char **));
101 static void do_compile PARAMS ((void));
102 static void process_options PARAMS ((void));
103 static void backend_init PARAMS ((void));
104 static int lang_dependent_init PARAMS ((const char *));
105 static void init_asm_output PARAMS ((const char *));
106 static void finalize PARAMS ((void));
108 static void set_target_switch PARAMS ((const char *));
110 static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
111 static void compile_file PARAMS ((void));
112 static void display_help PARAMS ((void));
113 static void display_target_options PARAMS ((void));
115 static void decode_d_option PARAMS ((const char *));
116 static int decode_f_option PARAMS ((const char *));
117 static int decode_W_option PARAMS ((const char *));
118 static int decode_g_option PARAMS ((const char *));
119 static unsigned int independent_decode_option PARAMS ((int, char **));
121 static void print_version PARAMS ((FILE *, const char *));
122 static int print_single_switch PARAMS ((FILE *, int, int, const char *,
123 const char *, const char *,
124 const char *, const char *));
125 static void print_switch_values PARAMS ((FILE *, int, int, const char *,
126 const char *, const char *));
128 /* Nonzero to dump debug info whilst parsing (-dy option). */
129 static int set_yydebug;
131 /* Length of line when printing switch values. */
132 #define MAX_LINE 75
134 /* Name of program invoked, sans directories. */
136 const char *progname;
138 /* Copy of arguments to toplev_main. */
139 int save_argc;
140 char **save_argv;
142 /* Name of current original source file (what was input to cpp).
143 This comes from each #-command in the actual input. */
145 const char *input_filename;
147 /* Name of top-level original source file (what was input to cpp).
148 This comes from the #-command at the beginning of the actual input.
149 If there isn't any there, then this is the cc1 input file name. */
151 const char *main_input_filename;
153 /* Current line number in real source file. */
155 int lineno;
157 /* Nonzero if it is unsafe to create any new pseudo registers. */
158 int no_new_pseudos;
160 /* Stack of currently pending input files. */
162 struct file_stack *input_file_stack;
164 /* Incremented on each change to input_file_stack. */
165 int input_file_stack_tick;
167 /* Name to use as base of names for dump output files. */
169 const char *dump_base_name;
171 /* Name to use as a base for auxiliary output files. */
173 const char *aux_base_name;
175 /* Format to use to print dumpfile index value */
176 #ifndef DUMPFILE_FORMAT
177 #define DUMPFILE_FORMAT ".%02d."
178 #endif
180 /* Bit flags that specify the machine subtype we are compiling for.
181 Bits are tested using macros TARGET_... defined in the tm.h file
182 and set by `-m...' switches. Must be defined in rtlanal.c. */
184 extern int target_flags;
186 /* A mask of target_flags that includes bit X if X was set or cleared
187 on the command line. */
189 int target_flags_explicit;
191 /* Debug hooks - dependent upon command line options. */
193 const struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks;
195 /* Describes a dump file. */
197 struct dump_file_info
199 /* The unique extension to apply, e.g. ".jump". */
200 const char *const extension;
202 /* The -d<c> character that enables this dump file. */
203 char const debug_switch;
205 /* True if there is a corresponding graph dump file. */
206 char const graph_dump_p;
208 /* True if the user selected this dump. */
209 char enabled;
211 /* True if the files have been initialized (ie truncated). */
212 char initialized;
215 /* Enumerate the extant dump files. */
217 enum dump_file_index
219 DFI_rtl,
220 DFI_sibling,
221 DFI_eh,
222 DFI_jump,
223 DFI_ssa,
224 DFI_ssa_ccp,
225 DFI_ssa_dce,
226 DFI_ussa,
227 DFI_null,
228 DFI_cse,
229 DFI_addressof,
230 DFI_gcse,
231 DFI_loop,
232 DFI_cfg,
233 DFI_bp,
234 DFI_tracer,
235 DFI_cse2,
236 DFI_life,
237 DFI_combine,
238 DFI_ce,
239 DFI_regmove,
240 DFI_sched,
241 DFI_lreg,
242 DFI_greg,
243 DFI_postreload,
244 DFI_flow2,
245 DFI_peephole2,
246 DFI_rnreg,
247 DFI_ce2,
248 DFI_sched2,
249 DFI_stack,
250 DFI_bbro,
251 DFI_mach,
252 DFI_dbr,
253 DFI_MAX
256 /* Describes all the dump files. Should be kept in order of the
257 pass and in sync with dump_file_index above.
259 Remaining -d letters:
261 " o q "
262 " H JK OPQ TUV YZ"
265 static struct dump_file_info dump_file[DFI_MAX] =
267 { "rtl", 'r', 0, 0, 0 },
268 { "sibling", 'i', 0, 0, 0 },
269 { "eh", 'h', 0, 0, 0 },
270 { "jump", 'j', 0, 0, 0 },
271 { "ssa", 'e', 1, 0, 0 },
272 { "ssaccp", 'W', 1, 0, 0 },
273 { "ssadce", 'X', 1, 0, 0 },
274 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
275 { "null", 'u', 0, 0, 0 },
276 { "cse", 's', 0, 0, 0 },
277 { "addressof", 'F', 0, 0, 0 },
278 { "gcse", 'G', 1, 0, 0 },
279 { "loop", 'L', 1, 0, 0 },
280 { "cfg", 'f', 1, 0, 0 },
281 { "bp", 'b', 1, 0, 0 },
282 { "tracer", 'T', 1, 0, 0 },
283 { "cse2", 't', 1, 0, 0 },
284 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
285 { "combine", 'c', 1, 0, 0 },
286 { "ce", 'C', 1, 0, 0 },
287 { "regmove", 'N', 1, 0, 0 },
288 { "sched", 'S', 1, 0, 0 },
289 { "lreg", 'l', 1, 0, 0 },
290 { "greg", 'g', 1, 0, 0 },
291 { "postreload", 'o', 1, 0, 0 },
292 { "flow2", 'w', 1, 0, 0 },
293 { "peephole2", 'z', 1, 0, 0 },
294 { "rnreg", 'n', 1, 0, 0 },
295 { "ce2", 'E', 1, 0, 0 },
296 { "sched2", 'R', 1, 0, 0 },
297 { "stack", 'k', 1, 0, 0 },
298 { "bbro", 'B', 1, 0, 0 },
299 { "mach", 'M', 1, 0, 0 },
300 { "dbr", 'd', 0, 0, 0 },
303 static int open_dump_file PARAMS ((enum dump_file_index, tree));
304 static void close_dump_file PARAMS ((enum dump_file_index,
305 void (*) (FILE *, rtx), rtx));
307 /* Other flags saying which kinds of debugging dump have been requested. */
309 int rtl_dump_and_exit;
310 int flag_print_asm_name;
311 static int version_flag;
312 static char *filename;
313 enum graph_dump_types graph_dump_format;
315 /* Name for output file of assembly code, specified with -o. */
317 char *asm_file_name;
319 /* Value of the -G xx switch, and whether it was passed or not. */
320 int g_switch_value;
321 int g_switch_set;
323 /* Type(s) of debugging information we are producing (if any).
324 See flags.h for the definitions of the different possible
325 types of debugging information. */
326 enum debug_info_type write_symbols = NO_DEBUG;
328 /* Level of debugging information we are producing. See flags.h
329 for the definitions of the different possible levels. */
330 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
332 /* Nonzero means use GNU-only extensions in the generated symbolic
333 debugging information. */
334 /* Currently, this only has an effect when write_symbols is set to
335 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
336 int use_gnu_debug_info_extensions = 0;
338 /* Nonzero means do optimizations. -O.
339 Particular numeric values stand for particular amounts of optimization;
340 thus, -O2 stores 2 here. However, the optimizations beyond the basic
341 ones are not controlled directly by this variable. Instead, they are
342 controlled by individual `flag_...' variables that are defaulted
343 based on this variable. */
345 int optimize = 0;
347 /* Nonzero means optimize for size. -Os.
348 The only valid values are zero and non-zero. When optimize_size is
349 non-zero, optimize defaults to 2, but certain individual code
350 bloating optimizations are disabled. */
352 int optimize_size = 0;
354 /* Nonzero if we should exit after parsing options. */
355 static int exit_after_options = 0;
357 /* The FUNCTION_DECL for the function currently being compiled,
358 or 0 if between functions. */
359 tree current_function_decl;
361 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
362 if none. */
363 tree current_function_func_begin_label;
365 /* Nonzero if doing dwarf2 duplicate elimination. */
367 int flag_eliminate_dwarf2_dups = 0;
369 /* Nonzero if generating code to do profiling. */
371 int profile_flag = 0;
373 /* Nonzero if generating code to profile program flow graph arcs. */
375 int profile_arc_flag = 0;
377 /* Nonzero if we should not attempt to generate thread-safe
378 code to profile program flow graph arcs. */
380 int flag_unsafe_profile_arcs = 0;
382 /* Nonzero if generating info for gcov to calculate line test coverage. */
384 int flag_test_coverage = 0;
386 /* Nonzero indicates that branch taken probabilities should be calculated. */
388 int flag_branch_probabilities = 0;
390 /* Nonzero if basic blocks should be reordered. */
392 int flag_reorder_blocks = 0;
394 /* Nonzero if functions should be reordered. */
396 int flag_reorder_functions = 0;
398 /* Nonzero if registers should be renamed. */
400 int flag_rename_registers = 0;
401 int flag_cprop_registers = 0;
403 /* Nonzero for -pedantic switch: warn about anything
404 that standard spec forbids. */
406 int pedantic = 0;
408 /* Temporarily suppress certain warnings.
409 This is set while reading code from a system header file. */
411 int in_system_header = 0;
413 /* Don't print functions as they are compiled. -quiet. */
415 int quiet_flag = 0;
417 /* Print times taken by the various passes. -ftime-report. */
419 int time_report = 0;
421 /* Print memory still in use at end of compilation (which may have little
422 to do with peak memory consumption). -fmem-report. */
424 int mem_report = 0;
426 /* Non-zero means to collect statistics which might be expensive
427 and to print them when we are done. */
428 int flag_detailed_statistics = 0;
431 /* -f flags. */
433 /* Nonzero means `char' should be signed. */
435 int flag_signed_char;
437 /* Nonzero means give an enum type only as many bytes as it needs. */
439 int flag_short_enums;
441 /* Nonzero for -fcaller-saves: allocate values in regs that need to
442 be saved across function calls, if that produces overall better code.
443 Optional now, so people can test it. */
445 #ifdef DEFAULT_CALLER_SAVES
446 int flag_caller_saves = 1;
447 #else
448 int flag_caller_saves = 0;
449 #endif
451 /* Nonzero if structures and unions should be returned in memory.
453 This should only be defined if compatibility with another compiler or
454 with an ABI is needed, because it results in slower code. */
456 #ifndef DEFAULT_PCC_STRUCT_RETURN
457 #define DEFAULT_PCC_STRUCT_RETURN 1
458 #endif
460 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
462 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
464 /* Nonzero for -fforce-mem: load memory value into a register
465 before arithmetic on it. This makes better cse but slower compilation. */
467 int flag_force_mem = 0;
469 /* Nonzero for -fforce-addr: load memory address into a register before
470 reference to memory. This makes better cse but slower compilation. */
472 int flag_force_addr = 0;
474 /* Nonzero for -fdefer-pop: don't pop args after each function call;
475 instead save them up to pop many calls' args with one insns. */
477 int flag_defer_pop = 0;
479 /* Nonzero for -ffloat-store: don't allocate floats and doubles
480 in extended-precision registers. */
482 int flag_float_store = 0;
484 /* Nonzero for -fcse-follow-jumps:
485 have cse follow jumps to do a more extensive job. */
487 int flag_cse_follow_jumps;
489 /* Nonzero for -fcse-skip-blocks:
490 have cse follow a branch around a block. */
491 int flag_cse_skip_blocks;
493 /* Nonzero for -fexpensive-optimizations:
494 perform miscellaneous relatively-expensive optimizations. */
495 int flag_expensive_optimizations;
497 /* Nonzero for -fthread-jumps:
498 have jump optimize output of loop. */
500 int flag_thread_jumps;
502 /* Nonzero enables strength-reduction in loop.c. */
504 int flag_strength_reduce = 0;
506 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
507 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
508 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
509 unrolled. */
511 int flag_unroll_loops;
513 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
514 This is generally not a win. */
516 int flag_unroll_all_loops;
518 /* Nonzero enables prefetch optimizations for arrays in loops. */
520 int flag_prefetch_loop_arrays;
522 /* Nonzero forces all invariant computations in loops to be moved
523 outside the loop. */
525 int flag_move_all_movables = 0;
527 /* Nonzero forces all general induction variables in loops to be
528 strength reduced. */
530 int flag_reduce_all_givs = 0;
532 /* Nonzero to perform full register move optimization passes. This is the
533 default for -O2. */
535 int flag_regmove = 0;
537 /* Nonzero for -fwritable-strings:
538 store string constants in data segment and don't uniquize them. */
540 int flag_writable_strings = 0;
542 /* Nonzero means don't put addresses of constant functions in registers.
543 Used for compiling the Unix kernel, where strange substitutions are
544 done on the assembly output. */
546 int flag_no_function_cse = 0;
548 /* Nonzero for -fomit-frame-pointer:
549 don't make a frame pointer in simple functions that don't require one. */
551 int flag_omit_frame_pointer = 0;
553 /* Nonzero means place each function into its own section on those platforms
554 which support arbitrary section names and unlimited numbers of sections. */
556 int flag_function_sections = 0;
558 /* ... and similar for data. */
560 int flag_data_sections = 0;
562 /* Nonzero to inhibit use of define_optimization peephole opts. */
564 int flag_no_peephole = 0;
566 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
568 int flag_optimize_sibling_calls = 0;
570 /* Nonzero means the front end generally wants `errno' maintained by math
571 operations, like built-in SQRT. */
573 int flag_errno_math = 1;
575 /* Nonzero means that unsafe floating-point math optimizations are allowed
576 for the sake of speed. IEEE compliance is not guaranteed, and operations
577 are allowed to assume that their arguments and results are "normal"
578 (e.g., nonnegative for SQRT). */
580 int flag_unsafe_math_optimizations = 0;
582 /* Nonzero means that no NaNs or +-Infs are expected. */
584 int flag_finite_math_only = 0;
586 /* Zero means that floating-point math operations cannot generate a
587 (user-visible) trap. This is the case, for example, in nonstop
588 IEEE 754 arithmetic. Trapping conditions include division by zero,
589 overflow, underflow, invalid and inexact, but does not include
590 operations on signaling NaNs (see below). */
592 int flag_trapping_math = 1;
594 /* Nonzero means disable transformations observable by signaling NaNs.
595 This option implies that any operation on a IEEE signaling NaN can
596 generate a (user-visible) trap. */
598 int flag_signaling_nans = 0;
600 /* 0 means straightforward implementation of complex divide acceptable.
601 1 means wide ranges of inputs must work for complex divide.
602 2 means C99-like requirements for complex divide (not yet implemented). */
604 int flag_complex_divide_method = 0;
606 /* Nonzero means all references through pointers are volatile. */
608 int flag_volatile;
610 /* Nonzero means treat all global and extern variables as volatile. */
612 int flag_volatile_global;
614 /* Nonzero means treat all static variables as volatile. */
616 int flag_volatile_static;
618 /* Nonzero means just do syntax checking; don't output anything. */
620 int flag_syntax_only = 0;
622 /* Nonzero means perform global cse. */
624 static int flag_gcse;
626 /* Nonzero means perform loop optimizer. */
628 static int flag_loop_optimize;
630 /* Nonzero means perform crossjumping. */
632 static int flag_crossjumping;
634 /* Nonzero means perform if conversion. */
636 static int flag_if_conversion;
638 /* Nonzero means perform if conversion after reload. */
640 static int flag_if_conversion2;
642 /* Nonzero means to use global dataflow analysis to eliminate
643 useless null pointer tests. */
645 static int flag_delete_null_pointer_checks;
647 /* Nonzero means to do the enhanced load motion during gcse, which trys
648 to hoist loads by not killing them when a store to the same location
649 is seen. */
651 int flag_gcse_lm = 1;
653 /* Nonzero means to perform store motion after gcse, which will try to
654 move stores closer to the exit block. Its not very effective without
655 flag_gcse_lm. */
657 int flag_gcse_sm = 1;
659 /* Nonzero means to rerun cse after loop optimization. This increases
660 compilation time about 20% and picks up a few more common expressions. */
662 static int flag_rerun_cse_after_loop;
664 /* Nonzero means to run loop optimizations twice. */
666 int flag_rerun_loop_opt;
668 /* Nonzero for -finline-functions: ok to inline functions that look like
669 good inline candidates. */
671 int flag_inline_functions;
673 /* Nonzero for -fkeep-inline-functions: even if we make a function
674 go inline everywhere, keep its definition around for debugging
675 purposes. */
677 int flag_keep_inline_functions;
679 /* Nonzero means that functions will not be inlined. */
681 int flag_no_inline = 2;
683 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
684 not just because the tree inliner turned us off. */
686 int flag_really_no_inline = 2;
688 /* Nonzero means that we should emit static const variables
689 regardless of whether or not optimization is turned on. */
691 int flag_keep_static_consts = 1;
693 /* Nonzero means we should be saving declaration info into a .X file. */
695 int flag_gen_aux_info = 0;
697 /* Specified name of aux-info file. */
699 static char *aux_info_file_name;
701 /* Nonzero means make the text shared if supported. */
703 int flag_shared_data;
705 /* Nonzero means schedule into delayed branch slots if supported. */
707 int flag_delayed_branch;
709 /* Nonzero if we are compiling pure (sharable) code.
710 Value is 1 if we are doing "small" pic; value is 2 if we're doing
711 "large" pic. */
713 int flag_pic;
715 /* Set to the default thread-local storage (tls) model to use. */
717 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
719 /* Nonzero means generate extra code for exception handling and enable
720 exception handling. */
722 int flag_exceptions;
724 /* Nonzero means generate frame unwind info table when supported. */
726 int flag_unwind_tables = 0;
728 /* Nonzero means generate frame unwind info table exact at each insn boundary */
730 int flag_asynchronous_unwind_tables = 0;
732 /* Nonzero means don't place uninitialized global data in common storage
733 by default. */
735 int flag_no_common;
737 /* Nonzero means change certain warnings into errors.
738 Usually these are warnings about failure to conform to some standard. */
740 int flag_pedantic_errors = 0;
742 /* flag_schedule_insns means schedule insns within basic blocks (before
743 local_alloc).
744 flag_schedule_insns_after_reload means schedule insns after
745 global_alloc. */
747 int flag_schedule_insns = 0;
748 int flag_schedule_insns_after_reload = 0;
750 /* The following flags have effect only for scheduling before register
751 allocation:
753 flag_schedule_interblock means schedule insns accross basic blocks.
754 flag_schedule_speculative means allow speculative motion of non-load insns.
755 flag_schedule_speculative_load means allow speculative motion of some
756 load insns.
757 flag_schedule_speculative_load_dangerous allows speculative motion of more
758 load insns. */
760 int flag_schedule_interblock = 1;
761 int flag_schedule_speculative = 1;
762 int flag_schedule_speculative_load = 0;
763 int flag_schedule_speculative_load_dangerous = 0;
765 int flag_single_precision_constant;
767 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
768 by a cheaper branch on a count register. */
769 int flag_branch_on_count_reg = 1;
771 /* -finhibit-size-directive inhibits output of .size for ELF.
772 This is used only for compiling crtstuff.c,
773 and it may be extended to other effects
774 needed for crtstuff.c on other systems. */
775 int flag_inhibit_size_directive = 0;
777 /* -fverbose-asm causes extra commentary information to be produced in
778 the generated assembly code (to make it more readable). This option
779 is generally only of use to those who actually need to read the
780 generated assembly code (perhaps while debugging the compiler itself).
781 -fno-verbose-asm, the default, causes the extra information
782 to be omitted and is useful when comparing two assembler files. */
784 int flag_verbose_asm = 0;
786 /* -dA causes debug commentary information to be produced in
787 the generated assembly code (to make it more readable). This option
788 is generally only of use to those who actually need to read the
789 generated assembly code (perhaps while debugging the compiler itself).
790 Currently, this switch is only used by dwarfout.c; however, it is intended
791 to be a catchall for printing debug information in the assembler file. */
793 int flag_debug_asm = 0;
795 /* -dP causes the rtl to be emitted as a comment in assembly. */
797 int flag_dump_rtl_in_asm = 0;
799 /* -fgnu-linker specifies use of the GNU linker for initializations.
800 (Or, more generally, a linker that handles initializations.)
801 -fno-gnu-linker says that collect2 will be used. */
802 #ifdef USE_COLLECT2
803 int flag_gnu_linker = 0;
804 #else
805 int flag_gnu_linker = 1;
806 #endif
808 /* Nonzero means put zero initialized data in the bss section. */
809 int flag_zero_initialized_in_bss = 1;
811 /* Enable SSA. */
812 int flag_ssa = 0;
814 /* Enable ssa conditional constant propagation. */
815 int flag_ssa_ccp = 0;
817 /* Enable ssa aggressive dead code elimination. */
818 int flag_ssa_dce = 0;
820 /* Tag all structures with __attribute__(packed). */
821 int flag_pack_struct = 0;
823 /* Emit code to check for stack overflow; also may cause large objects
824 to be allocated dynamically. */
825 int flag_stack_check;
827 /* When non-NULL, indicates that whenever space is allocated on the
828 stack, the resulting stack pointer must not pass this
829 address---that is, for stacks that grow downward, the stack pointer
830 must always be greater than or equal to this address; for stacks
831 that grow upward, the stack pointer must be less than this address.
832 At present, the rtx may be either a REG or a SYMBOL_REF, although
833 the support provided depends on the backend. */
834 rtx stack_limit_rtx;
836 /* 0 if pointer arguments may alias each other. True in C.
837 1 if pointer arguments may not alias each other but may alias
838 global variables.
839 2 if pointer arguments may not alias each other and may not
840 alias global variables. True in Fortran.
841 This defaults to 0 for C. */
842 int flag_argument_noalias = 0;
844 /* Nonzero if we should do (language-dependent) alias analysis.
845 Typically, this analysis will assume that expressions of certain
846 types do not alias expressions of certain other types. Only used
847 if alias analysis (in general) is enabled. */
848 int flag_strict_aliasing = 0;
850 /* Instrument functions with calls at entry and exit, for profiling. */
851 int flag_instrument_function_entry_exit = 0;
853 /* Nonzero means ignore `#ident' directives. 0 means handle them.
854 On SVR4 targets, it also controls whether or not to emit a
855 string identifying the compiler. */
857 int flag_no_ident = 0;
859 /* This will perform a peephole pass before sched2. */
860 int flag_peephole2 = 0;
862 /* This will try to guess branch probabilities. */
863 int flag_guess_branch_prob = 0;
865 /* -fbounded-pointers causes gcc to compile pointers as composite
866 objects occupying three words: the pointer value, the base address
867 of the referent object, and the address immediately beyond the end
868 of the referent object. The base and extent allow us to perform
869 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
870 int flag_bounded_pointers = 0;
872 /* -fcheck-bounds causes gcc to generate array bounds checks.
873 For C, C++: defaults to value of flag_bounded_pointers.
874 For ObjC: defaults to off.
875 For Java: defaults to on.
876 For Fortran: defaults to off.
877 For CHILL: defaults to off. */
878 int flag_bounds_check = 0;
880 /* This will attempt to merge constant section constants, if 1 only
881 string constants and constants from constant pool, if 2 also constant
882 variables. */
883 int flag_merge_constants = 1;
885 /* If one, renumber instruction UIDs to reduce the number of
886 unused UIDs if there are a lot of instructions. If greater than
887 one, unconditionally renumber instruction UIDs. */
888 int flag_renumber_insns = 1;
890 /* If nonzero, use the graph coloring register allocator. */
891 int flag_new_regalloc = 0;
893 /* Nonzero if we perform superblock formation. */
895 int flag_tracer = 0;
897 /* Values of the -falign-* flags: how much to align labels in code.
898 0 means `use default', 1 means `don't align'.
899 For each variable, there is an _log variant which is the power
900 of two not less than the variable, for .align output. */
902 int align_loops;
903 int align_loops_log;
904 int align_loops_max_skip;
905 int align_jumps;
906 int align_jumps_log;
907 int align_jumps_max_skip;
908 int align_labels;
909 int align_labels_log;
910 int align_labels_max_skip;
911 int align_functions;
912 int align_functions_log;
914 /* Table of supported debugging formats. */
915 static const struct
917 const char *const arg;
918 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
919 constant expression, we use NO_DEBUG in its place. */
920 const enum debug_info_type debug_type;
921 const int use_extensions_p;
922 const char *const description;
923 } *da,
924 debug_args[] =
926 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
927 N_("Generate debugging info in default format") },
928 { "gdb", NO_DEBUG, 1, N_("Generate debugging info in default extended format") },
929 #ifdef DBX_DEBUGGING_INFO
930 { "stabs", DBX_DEBUG, 0, N_("Generate STABS format debug info") },
931 { "stabs+", DBX_DEBUG, 1, N_("Generate extended STABS format debug info") },
932 #endif
933 #ifdef DWARF_DEBUGGING_INFO
934 { "dwarf", DWARF_DEBUG, 0, N_("Generate DWARF-1 format debug info") },
935 { "dwarf+", DWARF_DEBUG, 1,
936 N_("Generate extended DWARF-1 format debug info") },
937 #endif
938 #ifdef DWARF2_DEBUGGING_INFO
939 { "dwarf-2", DWARF2_DEBUG, 0, N_("Generate DWARF-2 debug info") },
940 #endif
941 #ifdef XCOFF_DEBUGGING_INFO
942 { "xcoff", XCOFF_DEBUG, 0, N_("Generate XCOFF format debug info") },
943 { "xcoff+", XCOFF_DEBUG, 1, N_("Generate extended XCOFF format debug info") },
944 #endif
945 #ifdef SDB_DEBUGGING_INFO
946 { "coff", SDB_DEBUG, 0, N_("Generate COFF format debug info") },
947 #endif
948 #ifdef VMS_DEBUGGING_INFO
949 { "vms", VMS_DEBUG, 0, N_("Generate VMS format debug info") },
950 #endif
951 { 0, 0, 0, 0 }
954 typedef struct
956 const char *const string;
957 int *const variable;
958 const int on_value;
959 const char *const description;
961 lang_independent_options;
963 int flag_trapv = 0;
965 /* Add or remove a leading underscore from user symbols. */
966 int flag_leading_underscore = -1;
968 /* The user symbol prefix after having resolved same. */
969 const char *user_label_prefix;
971 static const param_info lang_independent_params[] = {
972 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
973 { OPTION, DEFAULT, HELP },
974 #include "params.def"
975 #undef DEFPARAM
976 { NULL, 0, NULL }
979 /* Table of language-independent -f options.
980 STRING is the option name. VARIABLE is the address of the variable.
981 ON_VALUE is the value to store in VARIABLE
982 if `-fSTRING' is seen as an option.
983 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
985 static const lang_independent_options f_options[] =
987 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
988 N_("Perform DWARF2 duplicate elimination") },
989 {"float-store", &flag_float_store, 1,
990 N_("Do not store floats in registers") },
991 {"volatile", &flag_volatile, 1,
992 N_("Consider all mem refs through pointers as volatile") },
993 {"volatile-global", &flag_volatile_global, 1,
994 N_("Consider all mem refs to global data to be volatile") },
995 {"volatile-static", &flag_volatile_static, 1,
996 N_("Consider all mem refs to static data to be volatile") },
997 {"defer-pop", &flag_defer_pop, 1,
998 N_("Defer popping functions args from stack until later") },
999 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
1000 N_("When possible do not generate stack frames") },
1001 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
1002 N_("Optimize sibling and tail recursive calls") },
1003 {"tracer", &flag_tracer, 1,
1004 N_("Perform superblock formation via tail duplication") },
1005 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
1006 N_("When running CSE, follow jumps to their targets") },
1007 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
1008 N_("When running CSE, follow conditional jumps") },
1009 {"expensive-optimizations", &flag_expensive_optimizations, 1,
1010 N_("Perform a number of minor, expensive optimizations") },
1011 {"thread-jumps", &flag_thread_jumps, 1,
1012 N_("Perform jump threading optimizations") },
1013 {"strength-reduce", &flag_strength_reduce, 1,
1014 N_("Perform strength reduction optimizations") },
1015 {"unroll-loops", &flag_unroll_loops, 1,
1016 N_("Perform loop unrolling when iteration count is known") },
1017 {"unroll-all-loops", &flag_unroll_all_loops, 1,
1018 N_("Perform loop unrolling for all loops") },
1019 {"prefetch-loop-arrays", &flag_prefetch_loop_arrays, 1,
1020 N_("Generate prefetch instructions, if available, for arrays in loops") },
1021 {"move-all-movables", &flag_move_all_movables, 1,
1022 N_("Force all loop invariant computations out of loops") },
1023 {"reduce-all-givs", &flag_reduce_all_givs, 1,
1024 N_("Strength reduce all loop general induction variables") },
1025 {"writable-strings", &flag_writable_strings, 1,
1026 N_("Store strings in writable data section") },
1027 {"peephole", &flag_no_peephole, 0,
1028 N_("Enable machine specific peephole optimizations") },
1029 {"force-mem", &flag_force_mem, 1,
1030 N_("Copy memory operands into registers before using") },
1031 {"force-addr", &flag_force_addr, 1,
1032 N_("Copy memory address constants into regs before using") },
1033 {"function-cse", &flag_no_function_cse, 0,
1034 N_("Allow function addresses to be held in registers") },
1035 {"inline-functions", &flag_inline_functions, 1,
1036 N_("Integrate simple functions into their callers") },
1037 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1038 N_("Generate code for funcs even if they are fully inlined") },
1039 {"inline", &flag_no_inline, 0,
1040 N_("Pay attention to the 'inline' keyword") },
1041 {"keep-static-consts", &flag_keep_static_consts, 1,
1042 N_("Emit static const variables even if they are not used") },
1043 {"syntax-only", &flag_syntax_only, 1,
1044 N_("Check for syntax errors, then stop") },
1045 {"shared-data", &flag_shared_data, 1,
1046 N_("Mark data as shared rather than private") },
1047 {"caller-saves", &flag_caller_saves, 1,
1048 N_("Enable saving registers around function calls") },
1049 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1050 N_("Return 'short' aggregates in memory, not registers") },
1051 {"reg-struct-return", &flag_pcc_struct_return, 0,
1052 N_("Return 'short' aggregates in registers") },
1053 {"delayed-branch", &flag_delayed_branch, 1,
1054 N_("Attempt to fill delay slots of branch instructions") },
1055 {"gcse", &flag_gcse, 1,
1056 N_("Perform the global common subexpression elimination") },
1057 {"gcse-lm", &flag_gcse_lm, 1,
1058 N_("Perform enhanced load motion during global subexpression elimination") },
1059 {"gcse-sm", &flag_gcse_sm, 1,
1060 N_("Perform store motion after global subexpression elimination") },
1061 {"loop-optimize", &flag_loop_optimize, 1,
1062 N_("Perform the loop optimizations") },
1063 {"crossjumping", &flag_crossjumping, 1,
1064 N_("Perform cross-jumping optimization") },
1065 {"if-conversion", &flag_if_conversion, 1,
1066 N_("Perform conversion of conditional jumps to branchless equivalents") },
1067 {"if-conversion2", &flag_if_conversion2, 1,
1068 N_("Perform conversion of conditional jumps to conditional execution") },
1069 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1070 N_("Run CSE pass after loop optimizations") },
1071 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1072 N_("Run the loop optimizer twice") },
1073 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1074 N_("Delete useless null pointer checks") },
1075 {"schedule-insns", &flag_schedule_insns, 1,
1076 N_("Reschedule instructions before register allocation") },
1077 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1078 N_("Reschedule instructions after register allocation") },
1079 {"sched-interblock",&flag_schedule_interblock, 1,
1080 N_("Enable scheduling across basic blocks") },
1081 {"sched-spec",&flag_schedule_speculative, 1,
1082 N_("Allow speculative motion of non-loads") },
1083 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1084 N_("Allow speculative motion of some loads") },
1085 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1086 N_("Allow speculative motion of more loads") },
1087 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1088 N_("Replace add,compare,branch with branch on count reg") },
1089 {"pic", &flag_pic, 1,
1090 N_("Generate position independent code, if possible") },
1091 {"PIC", &flag_pic, 2, ""},
1092 {"exceptions", &flag_exceptions, 1,
1093 N_("Enable exception handling") },
1094 {"unwind-tables", &flag_unwind_tables, 1,
1095 N_("Just generate unwind tables for exception handling") },
1096 {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1,
1097 N_("Generate unwind tables exact at each instruction boundary") },
1098 {"non-call-exceptions", &flag_non_call_exceptions, 1,
1099 N_("Support synchronous non-call exceptions") },
1100 {"profile-arcs", &profile_arc_flag, 1,
1101 N_("Insert arc based program profiling code") },
1102 {"unsafe-profile-arcs", &flag_unsafe_profile_arcs, 1,
1103 N_("Avoid thread safety profiling overhead") },
1104 {"test-coverage", &flag_test_coverage, 1,
1105 N_("Create data files needed by gcov") },
1106 {"branch-probabilities", &flag_branch_probabilities, 1,
1107 N_("Use profiling information for branch probabilities") },
1108 {"profile", &profile_flag, 1,
1109 N_("Enable basic program profiling code") },
1110 {"reorder-blocks", &flag_reorder_blocks, 1,
1111 N_("Reorder basic blocks to improve code placement") },
1112 {"reorder-functions", &flag_reorder_functions, 1,
1113 N_("Reorder functions to improve code placement") },
1114 {"rename-registers", &flag_rename_registers, 1,
1115 N_("Do the register renaming optimization pass") },
1116 {"cprop-registers", &flag_cprop_registers, 1,
1117 N_("Do the register copy-propagation optimization pass") },
1118 {"common", &flag_no_common, 0,
1119 N_("Do not put uninitialized globals in the common section") },
1120 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1121 N_("Do not generate .size directives") },
1122 {"function-sections", &flag_function_sections, 1,
1123 N_("place each function into its own section") },
1124 {"data-sections", &flag_data_sections, 1,
1125 N_("place data items into their own section") },
1126 {"verbose-asm", &flag_verbose_asm, 1,
1127 N_("Add extra commentry to assembler output") },
1128 {"gnu-linker", &flag_gnu_linker, 1,
1129 N_("Output GNU ld formatted global initializers") },
1130 {"regmove", &flag_regmove, 1,
1131 N_("Enables a register move optimization") },
1132 {"optimize-register-move", &flag_regmove, 1,
1133 N_("Do the full regmove optimization pass") },
1134 {"pack-struct", &flag_pack_struct, 1,
1135 N_("Pack structure members together without holes") },
1136 {"stack-check", &flag_stack_check, 1,
1137 N_("Insert stack checking code into the program") },
1138 {"argument-alias", &flag_argument_noalias, 0,
1139 N_("Specify that arguments may alias each other & globals") },
1140 {"argument-noalias", &flag_argument_noalias, 1,
1141 N_("Assume arguments may alias globals but not each other") },
1142 {"argument-noalias-global", &flag_argument_noalias, 2,
1143 N_("Assume arguments do not alias each other or globals") },
1144 {"strict-aliasing", &flag_strict_aliasing, 1,
1145 N_("Assume strict aliasing rules apply") },
1146 {"align-loops", &align_loops, 0,
1147 N_("Align the start of loops") },
1148 {"align-jumps", &align_jumps, 0,
1149 N_("Align labels which are only reached by jumping") },
1150 {"align-labels", &align_labels, 0,
1151 N_("Align all labels") },
1152 {"align-functions", &align_functions, 0,
1153 N_("Align the start of functions") },
1154 {"merge-constants", &flag_merge_constants, 1,
1155 N_("Attempt to merge identical constants accross compilation units") },
1156 {"merge-all-constants", &flag_merge_constants, 2,
1157 N_("Attempt to merge identical constants and constant variables") },
1158 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1159 N_("Suppress output of instruction numbers and line number notes in debugging dumps") },
1160 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1161 N_("Instrument function entry/exit with profiling calls") },
1162 {"zero-initialized-in-bss", &flag_zero_initialized_in_bss, 1,
1163 N_("Put zero initialized data in the bss section") },
1164 {"ssa", &flag_ssa, 1,
1165 N_("Enable SSA optimizations") },
1166 {"ssa-ccp", &flag_ssa_ccp, 1,
1167 N_("Enable SSA conditional constant propagation") },
1168 {"ssa-dce", &flag_ssa_dce, 1,
1169 N_("Enable aggressive SSA dead code elimination") },
1170 {"leading-underscore", &flag_leading_underscore, 1,
1171 N_("External symbols have a leading underscore") },
1172 {"ident", &flag_no_ident, 0,
1173 N_("Process #ident directives") },
1174 { "peephole2", &flag_peephole2, 1,
1175 N_("Enables an rtl peephole pass run before sched2") },
1176 {"finite-math-only", &flag_finite_math_only, 1,
1177 N_("Assume no NaNs or +-Infs are generated") },
1178 { "guess-branch-probability", &flag_guess_branch_prob, 1,
1179 N_("Enables guessing of branch probabilities") },
1180 {"math-errno", &flag_errno_math, 1,
1181 N_("Set errno after built-in math functions") },
1182 {"trapping-math", &flag_trapping_math, 1,
1183 N_("Floating-point operations can trap") },
1184 {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1,
1185 N_("Allow math optimizations that may violate IEEE or ANSI standards") },
1186 {"signaling-nans", &flag_signaling_nans, 1,
1187 N_("Disable optimizations observable by IEEE signaling NaNs") },
1188 {"bounded-pointers", &flag_bounded_pointers, 1,
1189 N_("Compile pointers as triples: value, base & end") },
1190 {"bounds-check", &flag_bounds_check, 1,
1191 N_("Generate code to check bounds before dereferencing pointers and arrays") },
1192 {"single-precision-constant", &flag_single_precision_constant, 1,
1193 N_("Convert floating point constant to single precision constant") },
1194 {"time-report", &time_report, 1,
1195 N_("Report time taken by each compiler pass at end of run") },
1196 {"mem-report", &mem_report, 1,
1197 N_("Report on permanent memory allocation at end of run") },
1198 { "trapv", &flag_trapv, 1,
1199 N_("Trap for signed overflow in addition / subtraction / multiplication") },
1200 { "new-ra", &flag_new_regalloc, 1,
1201 N_("Use graph coloring register allocation.") },
1204 /* Table of language-specific options. */
1206 static const struct lang_opt
1208 const char *const option;
1209 const char *const description;
1211 documented_lang_options[] =
1213 /* In order not to overload the --help output, the convention
1214 used here is to only describe those options which are not
1215 enabled by default. */
1217 { "-ansi",
1218 N_("Compile just for ISO C90") },
1219 { "-std= ",
1220 N_("Determine language standard") },
1222 { "-fsigned-bitfields", "" },
1223 { "-funsigned-bitfields",
1224 N_("Make bit-fields by unsigned by default") },
1225 { "-fno-signed-bitfields", "" },
1226 { "-fno-unsigned-bitfields","" },
1227 { "-fsigned-char",
1228 N_("Make 'char' be signed by default") },
1229 { "-funsigned-char",
1230 N_("Make 'char' be unsigned by default") },
1231 { "-fno-signed-char", "" },
1232 { "-fno-unsigned-char", "" },
1234 { "-fasm", "" },
1235 { "-fno-asm",
1236 N_("Do not recognize the 'asm' keyword") },
1237 { "-fbuiltin", "" },
1238 { "-fno-builtin",
1239 N_("Do not recognize any built in functions") },
1240 { "-fhosted",
1241 N_("Assume normal C execution environment") },
1242 { "-fno-hosted", "" },
1243 { "-ffreestanding",
1244 N_("Assume that standard libraries & main might not exist") },
1245 { "-fno-freestanding", "" },
1246 { "-fcond-mismatch",
1247 N_("Allow different types as args of ? operator") },
1248 { "-fno-cond-mismatch", "" },
1249 { "-fdollars-in-identifiers",
1250 N_("Allow the use of $ inside identifiers") },
1251 { "-fno-dollars-in-identifiers", "" },
1252 { "-fpreprocessed", "" },
1253 { "-fno-preprocessed", "" },
1254 { "-fshort-double",
1255 N_("Use the same size for double as for float") },
1256 { "-fno-short-double", "" },
1257 { "-fshort-enums",
1258 N_("Use the smallest fitting integer to hold enums") },
1259 { "-fno-short-enums", "" },
1260 { "-fshort-wchar",
1261 N_("Override the underlying type for wchar_t to `unsigned short'") },
1262 { "-fno-short-wchar", "" },
1264 { "-Wall",
1265 N_("Enable most warning messages") },
1266 { "-Wbad-function-cast",
1267 N_("Warn about casting functions to incompatible types") },
1268 { "-Wno-bad-function-cast", "" },
1269 { "-Wmissing-format-attribute",
1270 N_("Warn about functions which might be candidates for format attributes") },
1271 { "-Wno-missing-format-attribute", "" },
1272 { "-Wcast-qual",
1273 N_("Warn about casts which discard qualifiers") },
1274 { "-Wno-cast-qual", "" },
1275 { "-Wchar-subscripts",
1276 N_("Warn about subscripts whose type is 'char'") },
1277 { "-Wno-char-subscripts", "" },
1278 { "-Wcomment",
1279 N_("Warn if nested comments are detected") },
1280 { "-Wno-comment", "" },
1281 { "-Wcomments",
1282 N_("Warn if nested comments are detected") },
1283 { "-Wno-comments", "" },
1284 { "-Wconversion",
1285 N_("Warn about possibly confusing type conversions") },
1286 { "-Wno-conversion", "" },
1287 { "-Wdiv-by-zero", "" },
1288 { "-Wno-div-by-zero",
1289 N_("Do not warn about compile-time integer division by zero") },
1290 { "-Wfloat-equal",
1291 N_("Warn about testing equality of floating point numbers") },
1292 { "-Wno-float-equal", "" },
1293 { "-Wformat",
1294 N_("Warn about printf/scanf/strftime/strfmon format anomalies") },
1295 { "-Wno-format", "" },
1296 { "-Wformat-extra-args", "" },
1297 { "-Wno-format-extra-args",
1298 N_("Don't warn about too many arguments to format functions") },
1299 { "-Wformat-nonliteral",
1300 N_("Warn about non-string-literal format strings") },
1301 { "-Wno-format-nonliteral", "" },
1302 { "-Wformat-security",
1303 N_("Warn about possible security problems with format functions") },
1304 { "-Wno-format-security", "" },
1305 { "-Wformat-y2k", "" },
1306 { "-Wno-format-y2k",
1307 N_("Don't warn about strftime formats yielding 2 digit years") },
1308 { "-Wimplicit-function-declaration",
1309 N_("Warn about implicit function declarations") },
1310 { "-Wno-implicit-function-declaration", "" },
1311 { "-Werror-implicit-function-declaration", "" },
1312 { "-Wimplicit-int",
1313 N_("Warn when a declaration does not specify a type") },
1314 { "-Wno-implicit-int", "" },
1315 { "-Wimplicit", "" },
1316 { "-Wno-implicit", "" },
1317 { "-Wimport",
1318 N_("Warn about the use of the #import directive") },
1319 { "-Wno-import", "" },
1320 { "-Wlong-long","" },
1321 { "-Wno-long-long",
1322 N_("Do not warn about using 'long long' when -pedantic") },
1323 { "-Wmain",
1324 N_("Warn about suspicious declarations of main") },
1325 { "-Wno-main", "" },
1326 { "-Wmissing-braces",
1327 N_("Warn about possibly missing braces around initializers") },
1328 { "-Wno-missing-braces", "" },
1329 { "-Wmissing-declarations",
1330 N_("Warn about global funcs without previous declarations") },
1331 { "-Wno-missing-declarations", "" },
1332 { "-Wmissing-prototypes",
1333 N_("Warn about global funcs without prototypes") },
1334 { "-Wno-missing-prototypes", "" },
1335 { "-Wmultichar",
1336 N_("Warn about use of multicharacter literals") },
1337 { "-Wno-multichar", "" },
1338 { "-Wnested-externs",
1339 N_("Warn about externs not at file scope level") },
1340 { "-Wno-nested-externs", "" },
1341 { "-Wparentheses",
1342 N_("Warn about possible missing parentheses") },
1343 { "-Wno-parentheses", "" },
1344 { "-Wpointer-arith",
1345 N_("Warn about function pointer arithmetic") },
1346 { "-Wno-pointer-arith", "" },
1347 { "-Wredundant-decls",
1348 N_("Warn about multiple declarations of the same object") },
1349 { "-Wno-redundant-decls", "" },
1350 { "-Wreturn-type",
1351 N_("Warn whenever a function's return-type defaults to int") },
1352 { "-Wno-return-type", "" },
1353 { "-Wsequence-point",
1354 N_("Warn about possible violations of sequence point rules") },
1355 { "-Wno-sequence-point", "" },
1356 { "-Wsign-compare",
1357 N_("Warn about signed/unsigned comparisons") },
1358 { "-Wno-sign-compare", "" },
1359 { "-Wstrict-prototypes",
1360 N_("Warn about non-prototyped function decls") },
1361 { "-Wno-strict-prototypes", "" },
1362 { "-Wtraditional",
1363 N_("Warn about constructs whose meanings change in ISO C") },
1364 { "-Wno-traditional", "" },
1365 { "-Wtrigraphs",
1366 N_("Warn when trigraphs are encountered") },
1367 { "-Wno-trigraphs", "" },
1368 { "-Wundef", "" },
1369 { "-Wno-undef", "" },
1370 { "-Wunknown-pragmas",
1371 N_("Warn about unrecognized pragmas") },
1372 { "-Wno-unknown-pragmas", "" },
1373 { "-Wwrite-strings",
1374 N_("Mark strings as 'const char *'") },
1375 { "-Wno-write-strings", "" },
1377 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1379 #include "options.h"
1383 /* Here is a table, controlled by the tm.h file, listing each -m switch
1384 and which bits in `target_switches' it should set or clear.
1385 If VALUE is positive, it is bits to set.
1386 If VALUE is negative, -VALUE is bits to clear.
1387 (The sign bit is not used so there is no confusion.) */
1389 static const struct
1391 const char *const name;
1392 const int value;
1393 const char *const description;
1395 target_switches[] = TARGET_SWITCHES;
1397 /* This table is similar, but allows the switch to have a value. */
1399 #ifdef TARGET_OPTIONS
1400 static const struct
1402 const char *const prefix;
1403 const char **const variable;
1404 const char *const description;
1406 target_options[] = TARGET_OPTIONS;
1407 #endif
1409 /* Options controlling warnings. */
1411 /* Don't print warning messages. -w. */
1413 int inhibit_warnings = 0;
1415 /* Don't suppress warnings from system headers. -Wsystem-headers. */
1417 int warn_system_headers = 0;
1419 /* Print various extra warnings. -W. */
1421 int extra_warnings = 0;
1423 /* Treat warnings as errors. -Werror. */
1425 int warnings_are_errors = 0;
1427 /* Nonzero to warn about unused variables, functions et.al. */
1429 int warn_unused_function;
1430 int warn_unused_label;
1431 int warn_unused_parameter;
1432 int warn_unused_variable;
1433 int warn_unused_value;
1435 /* Nonzero to warn about code which is never reached. */
1437 int warn_notreached;
1439 /* Nonzero to warn about variables used before they are initialized. */
1441 int warn_uninitialized;
1443 /* Nonzero means warn about all declarations which shadow others. */
1445 int warn_shadow;
1447 /* Warn if a switch on an enum, that does not have a default case,
1448 fails to have a case for every enum value. */
1450 int warn_switch;
1452 /* Warn if a switch does not have a default case. */
1454 int warn_switch_default;
1456 /* Warn if a switch on an enum fails to have a case for every enum
1457 value (regardless of the presence or otherwise of a default case). */
1459 int warn_switch_enum;
1461 /* Nonzero means warn about function definitions that default the return type
1462 or that use a null return and have a return-type other than void. */
1464 int warn_return_type;
1466 /* Nonzero means warn about pointer casts that increase the required
1467 alignment of the target type (and might therefore lead to a crash
1468 due to a misaligned access). */
1470 int warn_cast_align;
1472 /* Nonzero means warn about any objects definitions whose size is larger
1473 than N bytes. Also want about function definitions whose returned
1474 values are larger than N bytes. The value N is in `larger_than_size'. */
1476 int warn_larger_than;
1477 HOST_WIDE_INT larger_than_size;
1479 /* Nonzero means warn if inline function is too large. */
1481 int warn_inline;
1483 /* Warn if a function returns an aggregate,
1484 since there are often incompatible calling conventions for doing this. */
1486 int warn_aggregate_return;
1488 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1490 int warn_packed;
1492 /* Warn when gcc pads a structure to an alignment boundary. */
1494 int warn_padded;
1496 /* Warn when an optimization pass is disabled. */
1498 int warn_disabled_optimization;
1500 /* Warn about functions which might be candidates for attribute noreturn. */
1502 int warn_missing_noreturn;
1504 /* Nonzero means warn about uses of __attribute__((deprecated))
1505 declarations. */
1507 int warn_deprecated_decl = 1;
1509 /* Likewise 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 {"missing-noreturn", &warn_missing_noreturn, 1,
1554 N_("Warn about functions which might be candidates for attribute noreturn") }
1557 void
1558 set_Wunused (setting)
1559 int setting;
1561 warn_unused_function = setting;
1562 warn_unused_label = setting;
1563 /* Unused function parameter warnings are reported when either ``-W
1564 -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
1565 -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
1566 if (!setting)
1567 warn_unused_parameter = 0;
1568 else if (!warn_unused_parameter)
1569 warn_unused_parameter = -1;
1570 warn_unused_variable = setting;
1571 warn_unused_value = setting;
1574 /* The following routines are useful in setting all the flags that
1575 -ffast-math and -fno-fast-math imply. */
1577 void
1578 set_fast_math_flags (set)
1579 int set;
1581 flag_trapping_math = !set;
1582 flag_unsafe_math_optimizations = set;
1583 flag_finite_math_only = set;
1584 flag_errno_math = !set;
1585 if (set)
1586 flag_signaling_nans = 0;
1589 /* Return true iff flags are set as if -ffast-math. */
1590 bool
1591 fast_math_flags_set_p ()
1593 return (!flag_trapping_math
1594 && flag_unsafe_math_optimizations
1595 && flag_finite_math_only
1596 && !flag_errno_math);
1600 /* Output files for assembler code (real compiler output)
1601 and debugging dumps. */
1603 FILE *asm_out_file;
1604 FILE *aux_info_file;
1605 FILE *rtl_dump_file = NULL;
1607 /* Decode the string P as an integral parameter.
1608 If the string is indeed an integer return its numeric value else
1609 issue an Invalid Option error for the option PNAME and return DEFVAL.
1610 If PNAME is zero just return DEFVAL, do not call error. */
1613 read_integral_parameter (p, pname, defval)
1614 const char *p;
1615 const char *pname;
1616 const int defval;
1618 const char *endp = p;
1620 while (*endp)
1622 if (ISDIGIT (*endp))
1623 endp++;
1624 else
1625 break;
1628 if (*endp != 0)
1630 if (pname != 0)
1631 error ("invalid option `%s'", pname);
1632 return defval;
1635 return atoi (p);
1638 /* This calls abort and is used to avoid problems when abort is a macro.
1639 It is used when we need to pass the address of abort. */
1641 void
1642 do_abort ()
1644 abort ();
1647 /* When `malloc.c' is compiled with `rcheck' defined,
1648 it calls this function to report clobberage. */
1650 void
1651 botch (s)
1652 const char *s ATTRIBUTE_UNUSED;
1654 abort ();
1657 /* Return the logarithm of X, base 2, considering X unsigned,
1658 if X is a power of 2. Otherwise, returns -1.
1660 This should be used via the `exact_log2' macro. */
1663 exact_log2_wide (x)
1664 unsigned HOST_WIDE_INT x;
1666 int log = 0;
1667 /* Test for 0 or a power of 2. */
1668 if (x == 0 || x != (x & -x))
1669 return -1;
1670 while ((x >>= 1) != 0)
1671 log++;
1672 return log;
1675 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1676 If X is 0, return -1.
1678 This should be used via the floor_log2 macro. */
1681 floor_log2_wide (x)
1682 unsigned HOST_WIDE_INT x;
1684 int log = -1;
1685 while (x != 0)
1686 log++,
1687 x >>= 1;
1688 return log;
1691 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1692 into ICE messages, which is much more user friendly. */
1694 static void
1695 crash_signal (signo)
1696 int signo;
1698 internal_error ("%s", strsignal (signo));
1701 /* Strip off a legitimate source ending from the input string NAME of
1702 length LEN. Rather than having to know the names used by all of
1703 our front ends, we strip off an ending of a period followed by
1704 up to five characters. (Java uses ".class".) */
1706 void
1707 strip_off_ending (name, len)
1708 char *name;
1709 int len;
1711 int i;
1712 for (i = 2; i < 6 && len > i; i++)
1714 if (name[len - i] == '.')
1716 name[len - i] = '\0';
1717 break;
1722 /* Output a quoted string. */
1724 void
1725 output_quoted_string (asm_file, string)
1726 FILE *asm_file;
1727 const char *string;
1729 #ifdef OUTPUT_QUOTED_STRING
1730 OUTPUT_QUOTED_STRING (asm_file, string);
1731 #else
1732 char c;
1734 putc ('\"', asm_file);
1735 while ((c = *string++) != 0)
1737 if (ISPRINT (c))
1739 if (c == '\"' || c == '\\')
1740 putc ('\\', asm_file);
1741 putc (c, asm_file);
1743 else
1744 fprintf (asm_file, "\\%03o", (unsigned char) c);
1746 putc ('\"', asm_file);
1747 #endif
1750 /* Output NAME into FILE after having turned it into something
1751 usable as an identifier in a target's assembly file. */
1752 void
1753 output_clean_symbol_name (file, name)
1754 FILE *file;
1755 const char *name;
1757 /* Make a copy of NAME. */
1758 char *id = xstrdup (name);
1760 /* Make it look like a valid identifier for an assembler. */
1761 clean_symbol_name (id);
1763 fputs (id, file);
1764 free (id);
1768 /* Output a file name in the form wanted by System V. */
1770 void
1771 output_file_directive (asm_file, input_name)
1772 FILE *asm_file;
1773 const char *input_name;
1775 int len = strlen (input_name);
1776 const char *na = input_name + len;
1778 /* NA gets INPUT_NAME sans directory names. */
1779 while (na > input_name)
1781 if (IS_DIR_SEPARATOR (na[-1]))
1782 break;
1783 na--;
1786 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1787 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1788 #else
1789 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1790 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1791 #else
1792 fprintf (asm_file, "\t.file\t");
1793 output_quoted_string (asm_file, na);
1794 fputc ('\n', asm_file);
1795 #endif
1796 #endif
1799 /* Routine to open a dump file. Return true if the dump file is enabled. */
1801 static int
1802 open_dump_file (index, decl)
1803 enum dump_file_index index;
1804 tree decl;
1806 char *dump_name;
1807 const char *open_arg;
1808 char seq[16];
1810 if (! dump_file[index].enabled)
1811 return 0;
1813 timevar_push (TV_DUMP);
1814 if (rtl_dump_file != NULL)
1815 fclose (rtl_dump_file);
1817 sprintf (seq, DUMPFILE_FORMAT, index);
1819 if (! dump_file[index].initialized)
1821 /* If we've not initialized the files, do so now. */
1822 if (graph_dump_format != no_graph
1823 && dump_file[index].graph_dump_p)
1825 dump_name = concat (seq, dump_file[index].extension, NULL);
1826 clean_graph_dump_file (dump_base_name, dump_name);
1827 free (dump_name);
1829 dump_file[index].initialized = 1;
1830 open_arg = "w";
1832 else
1833 open_arg = "a";
1835 dump_name = concat (dump_base_name, seq,
1836 dump_file[index].extension, NULL);
1838 rtl_dump_file = fopen (dump_name, open_arg);
1839 if (rtl_dump_file == NULL)
1840 fatal_io_error ("can't open %s", dump_name);
1842 free (dump_name);
1844 if (decl)
1845 fprintf (rtl_dump_file, "\n;; Function %s%s\n\n",
1846 (*lang_hooks.decl_printable_name) (decl, 2),
1847 cfun->function_frequency == FUNCTION_FREQUENCY_HOT
1848 ? " (hot)"
1849 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
1850 ? " (unlikely executed)"
1851 : "");
1853 timevar_pop (TV_DUMP);
1854 return 1;
1857 /* Routine to close a dump file. */
1859 static void
1860 close_dump_file (index, func, insns)
1861 enum dump_file_index index;
1862 void (*func) PARAMS ((FILE *, rtx));
1863 rtx insns;
1865 if (! rtl_dump_file)
1866 return;
1868 timevar_push (TV_DUMP);
1869 if (insns
1870 && graph_dump_format != no_graph
1871 && dump_file[index].graph_dump_p)
1873 char seq[16];
1874 char *suffix;
1876 sprintf (seq, DUMPFILE_FORMAT, index);
1877 suffix = concat (seq, dump_file[index].extension, NULL);
1878 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1879 free (suffix);
1882 if (func && insns)
1883 func (rtl_dump_file, insns);
1885 fflush (rtl_dump_file);
1886 fclose (rtl_dump_file);
1888 rtl_dump_file = NULL;
1889 timevar_pop (TV_DUMP);
1892 /* Do any final processing required for the declarations in VEC, of
1893 which there are LEN. We write out inline functions and variables
1894 that have been deferred until this point, but which are required.
1895 Returns non-zero if anything was put out. */
1898 wrapup_global_declarations (vec, len)
1899 tree *vec;
1900 int len;
1902 tree decl;
1903 int i;
1904 int reconsider;
1905 int output_something = 0;
1907 for (i = 0; i < len; i++)
1909 decl = vec[i];
1911 /* We're not deferring this any longer. */
1912 DECL_DEFER_OUTPUT (decl) = 0;
1914 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1915 (*lang_hooks.finish_incomplete_decl) (decl);
1918 /* Now emit any global variables or functions that we have been
1919 putting off. We need to loop in case one of the things emitted
1920 here references another one which comes earlier in the list. */
1923 reconsider = 0;
1924 for (i = 0; i < len; i++)
1926 decl = vec[i];
1928 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1929 continue;
1931 /* Don't write out static consts, unless we still need them.
1933 We also keep static consts if not optimizing (for debugging),
1934 unless the user specified -fno-keep-static-consts.
1935 ??? They might be better written into the debug information.
1936 This is possible when using DWARF.
1938 A language processor that wants static constants to be always
1939 written out (even if it is not used) is responsible for
1940 calling rest_of_decl_compilation itself. E.g. the C front-end
1941 calls rest_of_decl_compilation from finish_decl.
1942 One motivation for this is that is conventional in some
1943 environments to write things like:
1944 static const char rcsid[] = "... version string ...";
1945 intending to force the string to be in the executable.
1947 A language processor that would prefer to have unneeded
1948 static constants "optimized away" would just defer writing
1949 them out until here. E.g. C++ does this, because static
1950 constants are often defined in header files.
1952 ??? A tempting alternative (for both C and C++) would be
1953 to force a constant to be written if and only if it is
1954 defined in a main file, as opposed to an include file. */
1956 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1958 bool needed = 1;
1960 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1961 /* needed */;
1962 else if (DECL_COMDAT (decl))
1963 needed = 0;
1964 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1965 && (optimize || !flag_keep_static_consts
1966 || DECL_ARTIFICIAL (decl)))
1967 needed = 0;
1969 if (needed)
1971 reconsider = 1;
1972 rest_of_decl_compilation (decl, NULL, 1, 1);
1976 if (TREE_CODE (decl) == FUNCTION_DECL
1977 && DECL_INITIAL (decl) != 0
1978 && DECL_SAVED_INSNS (decl) != 0
1979 && (flag_keep_inline_functions
1980 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1981 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1983 reconsider = 1;
1984 output_inline_function (decl);
1988 if (reconsider)
1989 output_something = 1;
1991 while (reconsider);
1993 return output_something;
1996 /* Issue appropriate warnings for the global declarations in VEC (of
1997 which there are LEN). Output debugging information for them. */
1999 void
2000 check_global_declarations (vec, len)
2001 tree *vec;
2002 int len;
2004 tree decl;
2005 int i;
2007 for (i = 0; i < len; i++)
2009 decl = vec[i];
2011 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2012 && ! TREE_ASM_WRITTEN (decl))
2013 /* Cancel the RTL for this decl so that, if debugging info
2014 output for global variables is still to come,
2015 this one will be omitted. */
2016 SET_DECL_RTL (decl, NULL_RTX);
2018 /* Warn about any function
2019 declared static but not defined.
2020 We don't warn about variables,
2021 because many programs have static variables
2022 that exist only to get some text into the object file. */
2023 if (TREE_CODE (decl) == FUNCTION_DECL
2024 && (warn_unused_function
2025 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2026 && DECL_INITIAL (decl) == 0
2027 && DECL_EXTERNAL (decl)
2028 && ! DECL_ARTIFICIAL (decl)
2029 && ! TREE_PUBLIC (decl))
2031 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2032 pedwarn_with_decl (decl,
2033 "`%s' used but never defined");
2034 else
2035 warning_with_decl (decl,
2036 "`%s' declared `static' but never defined");
2037 /* This symbol is effectively an "extern" declaration now. */
2038 TREE_PUBLIC (decl) = 1;
2039 assemble_external (decl);
2042 /* Warn about static fns or vars defined but not used. */
2043 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
2044 || (warn_unused_variable && TREE_CODE (decl) == VAR_DECL))
2045 && ! TREE_USED (decl)
2046 /* The TREE_USED bit for file-scope decls is kept in the identifier,
2047 to handle multiple external decls in different scopes. */
2048 && ! TREE_USED (DECL_NAME (decl))
2049 && ! DECL_EXTERNAL (decl)
2050 && ! TREE_PUBLIC (decl)
2051 /* Global register variables must be declared to reserve them. */
2052 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
2053 /* Otherwise, ask the language. */
2054 && (*lang_hooks.decls.warn_unused_global) (decl))
2055 warning_with_decl (decl, "`%s' defined but not used");
2057 timevar_push (TV_SYMOUT);
2058 (*debug_hooks->global_decl) (decl);
2059 timevar_pop (TV_SYMOUT);
2063 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2064 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2065 INPUT_FILENAME and LINENO accordingly. */
2067 void
2068 push_srcloc (file, line)
2069 const char *file;
2070 int line;
2072 struct file_stack *fs;
2074 if (input_file_stack)
2076 input_file_stack->name = input_filename;
2077 input_file_stack->line = lineno;
2080 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2081 fs->name = input_filename = file;
2082 fs->line = lineno = line;
2083 fs->next = input_file_stack;
2084 input_file_stack = fs;
2085 input_file_stack_tick++;
2088 /* Pop the top entry off the stack of presently open source files.
2089 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2090 the stack. */
2092 void
2093 pop_srcloc ()
2095 struct file_stack *fs;
2097 fs = input_file_stack;
2098 input_file_stack = fs->next;
2099 free (fs);
2100 input_file_stack_tick++;
2101 /* The initial source file is never popped. */
2102 if (!input_file_stack)
2103 abort ();
2104 input_filename = input_file_stack->name;
2105 lineno = input_file_stack->line;
2108 /* Compile an entire translation unit. Write a file of assembly
2109 output and various debugging dumps. */
2111 static void
2112 compile_file ()
2114 tree globals;
2116 /* Initialize yet another pass. */
2118 init_final (main_input_filename);
2119 init_branch_prob (aux_base_name);
2121 timevar_push (TV_PARSE);
2123 /* Call the parser, which parses the entire file (calling
2124 rest_of_compilation for each function). */
2125 (*lang_hooks.parse_file) (set_yydebug);
2127 /* In case there were missing block closers,
2128 get us back to the global binding level. */
2129 (*lang_hooks.clear_binding_stack) ();
2131 /* Compilation is now finished except for writing
2132 what's left of the symbol table output. */
2133 timevar_pop (TV_PARSE);
2135 if (flag_syntax_only)
2136 return;
2138 globals = (*lang_hooks.decls.getdecls) ();
2140 /* Really define vars that have had only a tentative definition.
2141 Really output inline functions that must actually be callable
2142 and have not been output so far. */
2145 int len = list_length (globals);
2146 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2147 int i;
2148 tree decl;
2150 /* Process the decls in reverse order--earliest first.
2151 Put them into VEC from back to front, then take out from front. */
2153 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2154 vec[len - i - 1] = decl;
2156 wrapup_global_declarations (vec, len);
2158 /* This must occur after the loop to output deferred functions. Else
2159 the profiler initializer would not be emitted if all the functions
2160 in this compilation unit were deferred.
2162 output_func_start_profiler can not cause any additional functions or
2163 data to need to be output, so it need not be in the deferred function
2164 loop above. */
2165 output_func_start_profiler ();
2167 check_global_declarations (vec, len);
2169 /* Clean up. */
2170 free (vec);
2173 /* Write out any pending weak symbol declarations. */
2175 weak_finish ();
2177 /* Do dbx symbols. */
2178 timevar_push (TV_SYMOUT);
2180 #ifdef DWARF2_UNWIND_INFO
2181 if (dwarf2out_do_frame ())
2182 dwarf2out_frame_finish ();
2183 #endif
2185 (*debug_hooks->finish) (main_input_filename);
2186 timevar_pop (TV_SYMOUT);
2188 /* Output some stuff at end of file if nec. */
2190 dw2_output_indirect_constants ();
2192 end_final (aux_base_name);
2194 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2196 timevar_push (TV_DUMP);
2197 open_dump_file (DFI_bp, NULL);
2199 end_branch_prob ();
2201 close_dump_file (DFI_bp, NULL, NULL_RTX);
2202 timevar_pop (TV_DUMP);
2205 #ifdef ASM_FILE_END
2206 ASM_FILE_END (asm_out_file);
2207 #endif
2209 /* Attach a special .ident directive to the end of the file to identify
2210 the version of GCC which compiled this code. The format of the .ident
2211 string is patterned after the ones produced by native SVR4 compilers. */
2212 #ifdef IDENT_ASM_OP
2213 if (!flag_no_ident)
2214 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2215 IDENT_ASM_OP, version_string);
2216 #endif
2218 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2220 timevar_push (TV_DUMP);
2221 dump_combine_total_stats (rtl_dump_file);
2222 close_dump_file (DFI_combine, NULL, NULL_RTX);
2223 timevar_pop (TV_DUMP);
2227 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2228 and TYPE_DECL nodes.
2230 This does nothing for local (non-static) variables, unless the
2231 variable is a register variable with an ASMSPEC. In that case, or
2232 if the variable is not an automatic, it sets up the RTL and
2233 outputs any assembler code (label definition, storage allocation
2234 and initialization).
2236 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2237 the assembler symbol name to be used. TOP_LEVEL is nonzero
2238 if this declaration is not within a function. */
2240 void
2241 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2242 tree decl;
2243 const char *asmspec;
2244 int top_level;
2245 int at_end;
2247 /* Declarations of variables, and of functions defined elsewhere. */
2249 /* The most obvious approach, to put an #ifndef around where
2250 this macro is used, doesn't work since it's inside a macro call. */
2251 #ifndef ASM_FINISH_DECLARE_OBJECT
2252 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2253 #endif
2255 /* We deferred calling assemble_alias so that we could collect
2256 other attributes such as visibility. Emit the alias now. */
2258 tree alias;
2259 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
2260 if (alias)
2262 alias = TREE_VALUE (TREE_VALUE (alias));
2263 alias = get_identifier (TREE_STRING_POINTER (alias));
2264 assemble_alias (decl, alias);
2268 /* Forward declarations for nested functions are not "external",
2269 but we need to treat them as if they were. */
2270 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2271 || TREE_CODE (decl) == FUNCTION_DECL)
2273 timevar_push (TV_VARCONST);
2275 if (asmspec)
2276 make_decl_rtl (decl, asmspec);
2278 /* Don't output anything when a tentative file-scope definition
2279 is seen. But at end of compilation, do output code for them. */
2280 if (at_end || !DECL_DEFER_OUTPUT (decl))
2281 assemble_variable (decl, top_level, at_end, 0);
2282 if (decl == last_assemble_variable_decl)
2284 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2285 top_level, at_end);
2288 timevar_pop (TV_VARCONST);
2290 else if (DECL_REGISTER (decl) && asmspec != 0)
2292 if (decode_reg_name (asmspec) >= 0)
2294 SET_DECL_RTL (decl, NULL_RTX);
2295 make_decl_rtl (decl, asmspec);
2297 else
2299 error ("invalid register name `%s' for register variable", asmspec);
2300 DECL_REGISTER (decl) = 0;
2301 if (!top_level)
2302 expand_decl (decl);
2305 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2306 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2307 && TREE_CODE (decl) == TYPE_DECL)
2309 timevar_push (TV_SYMOUT);
2310 dbxout_symbol (decl, 0);
2311 timevar_pop (TV_SYMOUT);
2313 #endif
2314 #ifdef SDB_DEBUGGING_INFO
2315 else if (write_symbols == SDB_DEBUG && top_level
2316 && TREE_CODE (decl) == TYPE_DECL)
2318 timevar_push (TV_SYMOUT);
2319 sdbout_symbol (decl, 0);
2320 timevar_pop (TV_SYMOUT);
2322 #endif
2325 /* Called after finishing a record, union or enumeral type. */
2327 void
2328 rest_of_type_compilation (type, toplev)
2329 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2330 tree type;
2331 int toplev;
2332 #else
2333 tree type ATTRIBUTE_UNUSED;
2334 int toplev ATTRIBUTE_UNUSED;
2335 #endif
2337 timevar_push (TV_SYMOUT);
2338 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2339 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2340 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2341 #endif
2342 #ifdef SDB_DEBUGGING_INFO
2343 if (write_symbols == SDB_DEBUG)
2344 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2345 #endif
2346 #ifdef DWARF2_DEBUGGING_INFO
2347 if ((write_symbols == DWARF2_DEBUG
2348 || write_symbols == VMS_AND_DWARF2_DEBUG)
2349 && toplev)
2350 dwarf2out_decl (TYPE_STUB_DECL (type));
2351 #endif
2352 timevar_pop (TV_SYMOUT);
2355 /* This is called from finish_function (within langhooks.parse_file)
2356 after each top-level definition is parsed.
2357 It is supposed to compile that function or variable
2358 and output the assembler code for it.
2359 After we return, the tree storage is freed. */
2361 void
2362 rest_of_compilation (decl)
2363 tree decl;
2365 rtx insns;
2366 int tem;
2367 int failure = 0;
2368 int rebuild_label_notes_after_reload;
2369 int register_life_up_to_date;
2371 timevar_push (TV_REST_OF_COMPILATION);
2373 /* Now that we're out of the frontend, we shouldn't have any more
2374 CONCATs anywhere. */
2375 generating_concat_p = 0;
2377 /* When processing delayed functions, prepare_function_start() won't
2378 have been run to re-initialize it. */
2379 cse_not_expected = ! optimize;
2381 /* First, make sure that NOTE_BLOCK is set correctly for each
2382 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2383 if (!cfun->x_whole_function_mode_p)
2384 identify_blocks ();
2386 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2387 tree in sensible shape. So, we just recalculate it here. */
2388 if (cfun->x_whole_function_mode_p)
2389 reorder_blocks ();
2391 init_flow ();
2393 /* If we are reconsidering an inline function
2394 at the end of compilation, skip the stuff for making it inline. */
2396 if (DECL_SAVED_INSNS (decl) == 0)
2398 int inlinable = 0;
2399 tree parent;
2400 const char *lose;
2402 /* If this is nested inside an inlined external function, pretend
2403 it was only declared. Since we cannot inline such functions,
2404 generating code for this one is not only not necessary but will
2405 confuse some debugging output writers. */
2406 for (parent = DECL_CONTEXT (current_function_decl);
2407 parent != NULL_TREE;
2408 parent = get_containing_scope (parent))
2409 if (TREE_CODE (parent) == FUNCTION_DECL
2410 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2412 DECL_INITIAL (decl) = 0;
2413 goto exit_rest_of_compilation;
2416 /* If requested, consider whether to make this function inline. */
2417 if ((DECL_INLINE (decl) && !flag_no_inline)
2418 || flag_inline_functions)
2420 timevar_push (TV_INTEGRATION);
2421 lose = function_cannot_inline_p (decl);
2422 timevar_pop (TV_INTEGRATION);
2423 if (lose || ! optimize)
2425 if (warn_inline && DECL_INLINE (decl))
2426 warning_with_decl (decl, lose);
2427 DECL_ABSTRACT_ORIGIN (decl) = 0;
2428 /* Don't really compile an extern inline function.
2429 If we can't make it inline, pretend
2430 it was only declared. */
2431 if (DECL_EXTERNAL (decl))
2433 DECL_INITIAL (decl) = 0;
2434 goto exit_rest_of_compilation;
2437 else
2438 /* ??? Note that this has the effect of making it look
2439 like "inline" was specified for a function if we choose
2440 to inline it. This isn't quite right, but it's
2441 probably not worth the trouble to fix. */
2442 inlinable = DECL_INLINE (decl) = 1;
2445 insns = get_insns ();
2447 /* Dump the rtl code if we are dumping rtl. */
2449 if (open_dump_file (DFI_rtl, decl))
2451 if (DECL_SAVED_INSNS (decl))
2452 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2453 close_dump_file (DFI_rtl, print_rtl, insns);
2456 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2457 sorts of eh initialization. Delay this until after the
2458 initial rtl dump so that we can see the original nesting. */
2459 convert_from_eh_region_ranges ();
2461 /* If function is inline, and we don't yet know whether to
2462 compile it by itself, defer decision till end of compilation.
2463 finish_compilation will call rest_of_compilation again
2464 for those functions that need to be output. Also defer those
2465 functions that we are supposed to defer. */
2467 if (inlinable
2468 || (DECL_INLINE (decl)
2469 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2470 && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
2471 && ! flag_keep_inline_functions)
2472 || DECL_EXTERNAL (decl))))
2473 DECL_DEFER_OUTPUT (decl) = 1;
2475 if (DECL_INLINE (decl))
2476 /* DWARF wants separate debugging info for abstract and
2477 concrete instances of all inline functions, including those
2478 declared inline but not inlined, and those inlined even
2479 though they weren't declared inline. Conveniently, that's
2480 what DECL_INLINE means at this point. */
2481 (*debug_hooks->deferred_inline_function) (decl);
2483 if (DECL_DEFER_OUTPUT (decl))
2485 /* If -Wreturn-type, we have to do a bit of compilation. We just
2486 want to call cleanup the cfg to figure out whether or not we can
2487 fall off the end of the function; we do the minimum amount of
2488 work necessary to make that safe. */
2489 if (warn_return_type)
2491 int saved_optimize = optimize;
2493 optimize = 0;
2494 rebuild_jump_labels (insns);
2495 find_exception_handler_labels ();
2496 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2497 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2498 optimize = saved_optimize;
2500 /* CFG is no longer maintained up-to-date. */
2501 free_bb_for_insn ();
2504 set_nothrow_function_flags ();
2505 if (current_function_nothrow)
2506 /* Now we know that this can't throw; set the flag for the benefit
2507 of other functions later in this translation unit. */
2508 TREE_NOTHROW (current_function_decl) = 1;
2510 timevar_push (TV_INTEGRATION);
2511 save_for_inline (decl);
2512 timevar_pop (TV_INTEGRATION);
2513 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2514 goto exit_rest_of_compilation;
2517 /* If specified extern inline but we aren't inlining it, we are
2518 done. This goes for anything that gets here with DECL_EXTERNAL
2519 set, not just things with DECL_INLINE. */
2520 if (DECL_EXTERNAL (decl))
2521 goto exit_rest_of_compilation;
2524 /* If we're emitting a nested function, make sure its parent gets
2525 emitted as well. Doing otherwise confuses debug info. */
2527 tree parent;
2528 for (parent = DECL_CONTEXT (current_function_decl);
2529 parent != NULL_TREE;
2530 parent = get_containing_scope (parent))
2531 if (TREE_CODE (parent) == FUNCTION_DECL)
2532 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
2535 /* We are now committed to emitting code for this function. Do any
2536 preparation, such as emitting abstract debug info for the inline
2537 before it gets mangled by optimization. */
2538 if (DECL_INLINE (decl))
2539 (*debug_hooks->outlining_inline_function) (decl);
2541 /* Remove any notes we don't need. That will make iterating
2542 over the instruction sequence faster, and allow the garbage
2543 collector to reclaim the memory used by the notes. */
2544 remove_unnecessary_notes ();
2545 reorder_blocks ();
2547 ggc_collect ();
2549 /* Initialize some variables used by the optimizers. */
2550 init_function_for_compilation ();
2552 if (! DECL_DEFER_OUTPUT (decl))
2553 TREE_ASM_WRITTEN (decl) = 1;
2555 /* Now that integrate will no longer see our rtl, we need not
2556 distinguish between the return value of this function and the
2557 return value of called functions. Also, we can remove all SETs
2558 of subregs of hard registers; they are only here because of
2559 integrate. Also, we can now initialize pseudos intended to
2560 carry magic hard reg data throughout the function. */
2561 rtx_equal_function_value_matters = 0;
2562 purge_hard_subreg_sets (get_insns ());
2564 /* Early return if there were errors. We can run afoul of our
2565 consistency checks, and there's not really much point in fixing them.
2566 Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
2567 if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2568 || errorcount || sorrycount)
2569 goto exit_rest_of_compilation;
2571 timevar_push (TV_JUMP);
2572 open_dump_file (DFI_sibling, decl);
2573 insns = get_insns ();
2574 rebuild_jump_labels (insns);
2575 find_exception_handler_labels ();
2576 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2578 delete_unreachable_blocks ();
2580 /* Turn NOTE_INSN_PREDICTIONs into branch predictions. */
2581 note_prediction_to_br_prob ();
2583 /* We may have potential sibling or tail recursion sites. Select one
2584 (of possibly multiple) methods of performing the call. */
2585 if (flag_optimize_sibling_calls)
2587 rtx insn;
2588 optimize_sibling_and_tail_recursive_calls ();
2590 /* Recompute the CFG as sibling optimization clobbers it randomly. */
2591 free_bb_for_insn ();
2592 find_exception_handler_labels ();
2593 rebuild_jump_labels (insns);
2594 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2596 /* There is pass ordering problem - we must lower NOTE_INSN_PREDICTION
2597 notes before simplifying cfg and we must do lowering after sibcall
2598 that unhides parts of RTL chain and cleans up the CFG.
2600 Until sibcall is replaced by tree-level optimizer, lets just
2601 sweep away the NOTE_INSN_PREDICTION notes that leaked out. */
2602 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2603 if (GET_CODE (insn) == NOTE
2604 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PREDICTION)
2605 delete_insn (insn);
2607 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2608 timevar_pop (TV_JUMP);
2610 scope_to_insns_initialize ();
2611 /* Complete generation of exception handling code. */
2612 if (doing_eh (0))
2614 timevar_push (TV_JUMP);
2615 open_dump_file (DFI_eh, decl);
2617 finish_eh_generation ();
2619 close_dump_file (DFI_eh, print_rtl, get_insns ());
2620 timevar_pop (TV_JUMP);
2623 /* Delay emitting hard_reg_initial_value sets until after EH landing pad
2624 generation, which might create new sets. */
2625 emit_initial_value_sets ();
2627 #ifdef FINALIZE_PIC
2628 /* If we are doing position-independent code generation, now
2629 is the time to output special prologues and epilogues.
2630 We do not want to do this earlier, because it just clutters
2631 up inline functions with meaningless insns. */
2632 if (flag_pic)
2633 FINALIZE_PIC;
2634 #endif
2636 insns = get_insns ();
2638 /* Copy any shared structure that should not be shared. */
2639 unshare_all_rtl (current_function_decl, insns);
2641 #ifdef SETJMP_VIA_SAVE_AREA
2642 /* This must be performed before virtual register instantiation.
2643 Please be aware the everything in the compiler that can look
2644 at the RTL up to this point must understand that REG_SAVE_AREA
2645 is just like a use of the REG contained inside. */
2646 if (current_function_calls_alloca)
2647 optimize_save_area_alloca (insns);
2648 #endif
2650 /* Instantiate all virtual registers. */
2651 instantiate_virtual_regs (current_function_decl, insns);
2653 open_dump_file (DFI_jump, decl);
2655 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2656 are initialized and to compute whether control can drop off the end
2657 of the function. */
2659 timevar_push (TV_JUMP);
2660 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2661 before jump optimization switches branch directions. */
2662 expected_value_to_br_prob ();
2664 reg_scan (insns, max_reg_num (), 0);
2665 rebuild_jump_labels (insns);
2666 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2667 if (rtl_dump_file)
2668 dump_flow_info (rtl_dump_file);
2669 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
2670 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2672 /* CFG is no longer maintained up-to-date. */
2673 free_bb_for_insn ();
2674 copy_loop_headers (insns);
2675 purge_line_number_notes (insns);
2676 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2678 timevar_pop (TV_JUMP);
2679 close_dump_file (DFI_jump, print_rtl, insns);
2681 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2682 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2684 goto exit_rest_of_compilation;
2687 /* Long term, this should probably move before the jump optimizer too,
2688 but I didn't want to disturb the rtl_dump_and_exit and related
2689 stuff at this time. */
2690 if (optimize > 0 && flag_ssa)
2692 /* Convert to SSA form. */
2694 timevar_push (TV_TO_SSA);
2695 open_dump_file (DFI_ssa, decl);
2697 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2698 convert_to_ssa ();
2700 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2701 timevar_pop (TV_TO_SSA);
2703 /* Perform sparse conditional constant propagation, if requested. */
2704 if (flag_ssa_ccp)
2706 timevar_push (TV_SSA_CCP);
2707 open_dump_file (DFI_ssa_ccp, decl);
2709 ssa_const_prop ();
2711 close_dump_file (DFI_ssa_ccp, print_rtl_with_bb, get_insns ());
2712 timevar_pop (TV_SSA_CCP);
2715 /* It would be useful to cleanup the CFG at this point, but block
2716 merging and possibly other transformations might leave a PHI
2717 node in the middle of a basic block, which is a strict no-no. */
2719 /* The SSA implementation uses basic block numbers in its phi
2720 nodes. Thus, changing the control-flow graph or the basic
2721 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
2722 may cause problems. */
2724 if (flag_ssa_dce)
2726 /* Remove dead code. */
2728 timevar_push (TV_SSA_DCE);
2729 open_dump_file (DFI_ssa_dce, decl);
2731 insns = get_insns ();
2732 ssa_eliminate_dead_code ();
2734 close_dump_file (DFI_ssa_dce, print_rtl_with_bb, insns);
2735 timevar_pop (TV_SSA_DCE);
2738 /* Convert from SSA form. */
2740 timevar_push (TV_FROM_SSA);
2741 open_dump_file (DFI_ussa, decl);
2743 convert_from_ssa ();
2744 /* New registers have been created. Rescan their usage. */
2745 reg_scan (insns, max_reg_num (), 1);
2747 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
2748 timevar_pop (TV_FROM_SSA);
2750 ggc_collect ();
2753 timevar_push (TV_JUMP);
2754 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP: 0);
2756 /* Try to identify useless null pointer tests and delete them. */
2757 if (flag_delete_null_pointer_checks)
2759 open_dump_file (DFI_null, decl);
2760 if (rtl_dump_file)
2761 dump_flow_info (rtl_dump_file);
2763 if (delete_null_pointer_checks (insns))
2764 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2766 close_dump_file (DFI_null, print_rtl_with_bb, insns);
2769 /* Jump optimization, and the removal of NULL pointer checks, may
2770 have reduced the number of instructions substantially. CSE, and
2771 future passes, allocate arrays whose dimensions involve the
2772 maximum instruction UID, so if we can reduce the maximum UID
2773 we'll save big on memory. */
2774 renumber_insns (rtl_dump_file);
2775 timevar_pop (TV_JUMP);
2777 close_dump_file (DFI_jump, print_rtl_with_bb, insns);
2779 ggc_collect ();
2781 /* Perform common subexpression elimination.
2782 Nonzero value from `cse_main' means that jumps were simplified
2783 and some code may now be unreachable, so do
2784 jump optimization again. */
2786 if (optimize > 0)
2788 open_dump_file (DFI_cse, decl);
2789 if (rtl_dump_file)
2790 dump_flow_info (rtl_dump_file);
2791 timevar_push (TV_CSE);
2793 reg_scan (insns, max_reg_num (), 1);
2795 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2796 if (tem)
2797 rebuild_jump_labels (insns);
2798 purge_all_dead_edges (0);
2800 delete_trivially_dead_insns (insns, max_reg_num ());
2802 /* If we are not running more CSE passes, then we are no longer
2803 expecting CSE to be run. But always rerun it in a cheap mode. */
2804 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
2806 if (tem || optimize > 1)
2807 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2808 /* Try to identify useless null pointer tests and delete them. */
2809 if (flag_delete_null_pointer_checks)
2811 timevar_push (TV_JUMP);
2813 if (delete_null_pointer_checks (insns))
2814 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2815 timevar_pop (TV_JUMP);
2818 /* The second pass of jump optimization is likely to have
2819 removed a bunch more instructions. */
2820 renumber_insns (rtl_dump_file);
2822 timevar_pop (TV_CSE);
2823 close_dump_file (DFI_cse, print_rtl_with_bb, insns);
2826 open_dump_file (DFI_addressof, decl);
2828 purge_addressof (insns);
2829 if (optimize)
2830 purge_all_dead_edges (0);
2831 reg_scan (insns, max_reg_num (), 1);
2833 close_dump_file (DFI_addressof, print_rtl, insns);
2835 ggc_collect ();
2837 /* Perform global cse. */
2839 if (optimize > 0 && flag_gcse)
2841 int save_csb, save_cfj;
2842 int tem2 = 0;
2844 timevar_push (TV_GCSE);
2845 open_dump_file (DFI_gcse, decl);
2847 tem = gcse_main (insns, rtl_dump_file);
2848 rebuild_jump_labels (insns);
2849 delete_trivially_dead_insns (insns, max_reg_num ());
2851 save_csb = flag_cse_skip_blocks;
2852 save_cfj = flag_cse_follow_jumps;
2853 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
2855 /* If -fexpensive-optimizations, re-run CSE to clean up things done
2856 by gcse. */
2857 if (flag_expensive_optimizations)
2859 timevar_push (TV_CSE);
2860 reg_scan (insns, max_reg_num (), 1);
2861 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2862 purge_all_dead_edges (0);
2863 delete_trivially_dead_insns (insns, max_reg_num ());
2864 timevar_pop (TV_CSE);
2865 cse_not_expected = !flag_rerun_cse_after_loop;
2868 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
2869 things up. Then possibly re-run CSE again. */
2870 while (tem || tem2)
2872 tem = tem2 = 0;
2873 timevar_push (TV_JUMP);
2874 rebuild_jump_labels (insns);
2875 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2876 timevar_pop (TV_JUMP);
2878 if (flag_expensive_optimizations)
2880 timevar_push (TV_CSE);
2881 reg_scan (insns, max_reg_num (), 1);
2882 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2883 purge_all_dead_edges (0);
2884 delete_trivially_dead_insns (insns, max_reg_num ());
2885 timevar_pop (TV_CSE);
2889 close_dump_file (DFI_gcse, print_rtl_with_bb, insns);
2890 timevar_pop (TV_GCSE);
2892 ggc_collect ();
2893 flag_cse_skip_blocks = save_csb;
2894 flag_cse_follow_jumps = save_cfj;
2895 #ifdef ENABLE_CHECKING
2896 verify_flow_info ();
2897 #endif
2900 /* Move constant computations out of loops. */
2902 if (optimize > 0 && flag_loop_optimize)
2904 int do_unroll, do_prefetch;
2906 timevar_push (TV_LOOP);
2907 delete_dead_jumptables ();
2908 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2909 open_dump_file (DFI_loop, decl);
2910 /* CFG is no longer maintained up-to-date. */
2911 free_bb_for_insn ();
2913 do_unroll = flag_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
2914 do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
2915 if (flag_rerun_loop_opt)
2917 cleanup_barriers ();
2919 /* We only want to perform unrolling once. */
2920 loop_optimize (insns, rtl_dump_file, do_unroll);
2921 do_unroll = 0;
2923 /* The first call to loop_optimize makes some instructions
2924 trivially dead. We delete those instructions now in the
2925 hope that doing so will make the heuristics in loop work
2926 better and possibly speed up compilation. */
2927 delete_trivially_dead_insns (insns, max_reg_num ());
2929 /* The regscan pass is currently necessary as the alias
2930 analysis code depends on this information. */
2931 reg_scan (insns, max_reg_num (), 1);
2933 cleanup_barriers ();
2934 loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch);
2936 /* Loop can create trivially dead instructions. */
2937 delete_trivially_dead_insns (insns, max_reg_num ());
2938 close_dump_file (DFI_loop, print_rtl, insns);
2939 timevar_pop (TV_LOOP);
2940 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2942 ggc_collect ();
2945 /* Do control and data flow analysis; wrote some of the results to
2946 the dump file. */
2948 timevar_push (TV_FLOW);
2949 open_dump_file (DFI_cfg, decl);
2950 if (rtl_dump_file)
2951 dump_flow_info (rtl_dump_file);
2952 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0)
2953 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2955 /* It may make more sense to mark constant functions after dead code is
2956 eliminated by life_analyzis, but we need to do it early, as -fprofile-arcs
2957 may insert code making function non-constant, but we still must consider
2958 it as constant, otherwise -fbranch-probabilities will not read data back.
2960 life_analyzis rarely eliminates modification of external memory.
2962 if (optimize)
2963 mark_constant_function ();
2965 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
2967 /* Do branch profiling and static profile estimation passes. */
2968 if (optimize > 0 || cfun->arc_profile || flag_branch_probabilities)
2970 struct loops loops;
2972 timevar_push (TV_BRANCH_PROB);
2973 open_dump_file (DFI_bp, decl);
2974 if (cfun->arc_profile || flag_branch_probabilities)
2975 branch_prob ();
2977 /* Discover and record the loop depth at the head of each basic
2978 block. The loop infrastructure does the real job for us. */
2979 flow_loops_find (&loops, LOOP_TREE);
2981 if (rtl_dump_file)
2982 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
2984 /* Estimate using heuristics if no profiling info is available. */
2985 if (flag_guess_branch_prob)
2986 estimate_probability (&loops);
2988 flow_loops_free (&loops);
2989 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
2990 timevar_pop (TV_BRANCH_PROB);
2992 if (flag_tracer)
2994 timevar_push (TV_TRACER);
2995 open_dump_file (DFI_tracer, decl);
2996 if (rtl_dump_file)
2997 dump_flow_info (rtl_dump_file);
2998 cleanup_cfg (CLEANUP_EXPENSIVE);
2999 tracer ();
3000 cleanup_cfg (CLEANUP_EXPENSIVE);
3001 close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
3002 timevar_pop (TV_TRACER);
3003 reg_scan (get_insns (), max_reg_num (), 0);
3006 if (optimize > 0)
3008 timevar_push (TV_CSE2);
3009 open_dump_file (DFI_cse2, decl);
3010 if (rtl_dump_file)
3011 dump_flow_info (rtl_dump_file);
3013 if (flag_rerun_cse_after_loop)
3015 timevar_push (TV_JUMP);
3017 reg_scan (insns, max_reg_num (), 0);
3019 timevar_push (TV_IFCVT);
3020 cleanup_cfg (CLEANUP_EXPENSIVE);
3021 if (flag_if_conversion)
3022 if_convert (0);
3023 timevar_pop (TV_IFCVT);
3025 timevar_pop (TV_JUMP);
3026 /* CFG is no longer maintained up-to-date. */
3027 reg_scan (insns, max_reg_num (), 0);
3028 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3029 purge_all_dead_edges (0);
3030 delete_trivially_dead_insns (insns, max_reg_num ());
3032 if (tem)
3034 timevar_push (TV_JUMP);
3035 rebuild_jump_labels (insns);
3036 cleanup_cfg (CLEANUP_EXPENSIVE);
3037 timevar_pop (TV_JUMP);
3041 close_dump_file (DFI_cse2, print_rtl_with_bb, insns);
3042 timevar_pop (TV_CSE2);
3044 ggc_collect ();
3047 cse_not_expected = 1;
3049 open_dump_file (DFI_life, decl);
3050 regclass_init ();
3052 check_function_return_warnings ();
3054 #ifdef ENABLE_CHECKING
3055 verify_flow_info ();
3056 #endif
3057 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3058 if (optimize)
3059 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_UPDATE_LIFE
3060 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3061 timevar_pop (TV_FLOW);
3063 no_new_pseudos = 1;
3065 if (warn_uninitialized || extra_warnings)
3067 uninitialized_vars_warning (DECL_INITIAL (decl));
3068 if (extra_warnings)
3069 setjmp_args_warning ();
3072 if (optimize)
3074 clear_bb_flags ();
3075 if (!flag_new_regalloc && initialize_uninitialized_subregs ())
3077 /* Insns were inserted, so things might look a bit different. */
3078 insns = get_insns ();
3079 update_life_info_in_dirty_blocks (UPDATE_LIFE_GLOBAL_RM_NOTES,
3080 PROP_LOG_LINKS | PROP_REG_INFO
3081 | PROP_DEATH_NOTES);
3085 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3087 ggc_collect ();
3089 /* If -opt, try combining insns through substitution. */
3091 if (optimize > 0)
3093 int rebuild_jump_labels_after_combine = 0;
3095 timevar_push (TV_COMBINE);
3096 open_dump_file (DFI_combine, decl);
3098 rebuild_jump_labels_after_combine
3099 = combine_instructions (insns, max_reg_num ());
3101 /* Combining insns may have turned an indirect jump into a
3102 direct jump. Rebuid the JUMP_LABEL fields of jumping
3103 instructions. */
3104 if (rebuild_jump_labels_after_combine)
3106 timevar_push (TV_JUMP);
3107 rebuild_jump_labels (insns);
3108 timevar_pop (TV_JUMP);
3110 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3113 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3114 timevar_pop (TV_COMBINE);
3116 ggc_collect ();
3119 /* Rerun if-conversion, as combine may have simplified things enough to
3120 now meet sequence length restrictions. */
3121 if (flag_if_conversion)
3123 timevar_push (TV_IFCVT);
3124 open_dump_file (DFI_ce, decl);
3126 no_new_pseudos = 0;
3127 if_convert (1);
3128 no_new_pseudos = 1;
3130 close_dump_file (DFI_ce, print_rtl_with_bb, insns);
3131 timevar_pop (TV_IFCVT);
3134 /* Register allocation pre-pass, to reduce number of moves
3135 necessary for two-address machines. */
3136 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3138 timevar_push (TV_REGMOVE);
3139 open_dump_file (DFI_regmove, decl);
3141 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3143 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3144 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3145 timevar_pop (TV_REGMOVE);
3147 ggc_collect ();
3150 /* Do unconditional splitting before register allocation to allow machine
3151 description to add extra information not needed previously. */
3152 split_all_insns (1);
3154 /* Any of the several passes since flow1 will have munged register
3155 lifetime data a bit. */
3156 register_life_up_to_date = 0;
3158 #ifdef OPTIMIZE_MODE_SWITCHING
3159 timevar_push (TV_MODE_SWITCH);
3161 no_new_pseudos = 0;
3162 optimize_mode_switching (NULL);
3163 no_new_pseudos = 1;
3165 timevar_pop (TV_MODE_SWITCH);
3166 #endif
3168 timevar_push (TV_SCHED);
3170 #ifdef INSN_SCHEDULING
3172 /* Print function header into sched dump now
3173 because doing the sched analysis makes some of the dump. */
3174 if (optimize > 0 && flag_schedule_insns)
3176 open_dump_file (DFI_sched, decl);
3178 /* Do control and data sched analysis,
3179 and write some of the results to dump file. */
3181 schedule_insns (rtl_dump_file);
3183 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3185 /* Register lifetime information was updated as part of verifying
3186 the schedule. */
3187 register_life_up_to_date = 1;
3189 #endif
3190 timevar_pop (TV_SCHED);
3192 ggc_collect ();
3194 /* Determine if the current function is a leaf before running reload
3195 since this can impact optimizations done by the prologue and
3196 epilogue thus changing register elimination offsets. */
3197 current_function_is_leaf = leaf_function_p ();
3199 timevar_push (TV_LOCAL_ALLOC);
3200 open_dump_file (DFI_lreg, decl);
3202 /* Allocate pseudo-regs that are used only within 1 basic block.
3204 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3205 jump optimizer after register allocation and reloading are finished. */
3207 if (! register_life_up_to_date)
3208 recompute_reg_usage (insns, ! optimize_size);
3210 if (flag_new_regalloc)
3212 delete_trivially_dead_insns (insns, max_reg_num ());
3213 reg_alloc ();
3215 timevar_pop (TV_LOCAL_ALLOC);
3216 if (dump_file[DFI_lreg].enabled)
3218 timevar_push (TV_DUMP);
3220 close_dump_file (DFI_lreg, NULL, NULL);
3221 timevar_pop (TV_DUMP);
3224 /* XXX clean up the whole mess to bring live info in shape again. */
3225 timevar_push (TV_GLOBAL_ALLOC);
3226 open_dump_file (DFI_greg, decl);
3228 build_insn_chain (insns);
3229 failure = reload (insns, 0);
3231 timevar_pop (TV_GLOBAL_ALLOC);
3233 if (dump_file[DFI_greg].enabled)
3235 timevar_push (TV_DUMP);
3237 dump_global_regs (rtl_dump_file);
3239 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3240 timevar_pop (TV_DUMP);
3243 if (failure)
3244 goto exit_rest_of_compilation;
3245 reload_completed = 1;
3246 rebuild_label_notes_after_reload = 0;
3248 else
3250 /* Allocate the reg_renumber array. */
3251 allocate_reg_info (max_regno, FALSE, TRUE);
3253 /* And the reg_equiv_memory_loc array. */
3254 reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
3256 allocate_initial_values (reg_equiv_memory_loc);
3258 regclass (insns, max_reg_num (), rtl_dump_file);
3259 rebuild_label_notes_after_reload = local_alloc ();
3261 timevar_pop (TV_LOCAL_ALLOC);
3263 if (dump_file[DFI_lreg].enabled)
3265 timevar_push (TV_DUMP);
3267 dump_flow_info (rtl_dump_file);
3268 dump_local_alloc (rtl_dump_file);
3270 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3271 timevar_pop (TV_DUMP);
3274 ggc_collect ();
3276 timevar_push (TV_GLOBAL_ALLOC);
3277 open_dump_file (DFI_greg, decl);
3279 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3280 pass fixing up any insns that are invalid. */
3282 if (optimize)
3283 failure = global_alloc (rtl_dump_file);
3284 else
3286 build_insn_chain (insns);
3287 failure = reload (insns, 0);
3290 timevar_pop (TV_GLOBAL_ALLOC);
3292 if (dump_file[DFI_greg].enabled)
3294 timevar_push (TV_DUMP);
3296 dump_global_regs (rtl_dump_file);
3298 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3299 timevar_pop (TV_DUMP);
3302 if (failure)
3303 goto exit_rest_of_compilation;
3306 ggc_collect ();
3308 open_dump_file (DFI_postreload, decl);
3310 /* Do a very simple CSE pass over just the hard registers. */
3311 if (optimize > 0)
3313 timevar_push (TV_RELOAD_CSE_REGS);
3314 reload_cse_regs (insns);
3315 timevar_pop (TV_RELOAD_CSE_REGS);
3318 /* Register allocation and reloading may have turned an indirect jump into
3319 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3320 jumping instructions. */
3321 if (rebuild_label_notes_after_reload)
3323 timevar_push (TV_JUMP);
3325 rebuild_jump_labels (insns);
3326 purge_all_dead_edges (0);
3328 timevar_pop (TV_JUMP);
3331 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3333 /* Re-create the death notes which were deleted during reload. */
3334 timevar_push (TV_FLOW2);
3335 open_dump_file (DFI_flow2, decl);
3337 #ifdef ENABLE_CHECKING
3338 verify_flow_info ();
3339 #endif
3341 /* If optimizing, then go ahead and split insns now. */
3342 if (optimize > 0)
3343 split_all_insns (0);
3345 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
3347 /* On some machines, the prologue and epilogue code, or parts thereof,
3348 can be represented as RTL. Doing so lets us schedule insns between
3349 it and the rest of the code and also allows delayed branch
3350 scheduling to operate in the epilogue. */
3351 thread_prologue_and_epilogue_insns (insns);
3353 if (optimize)
3355 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3356 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
3357 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3359 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3360 even for machines with possibly nonzero RETURN_POPS_ARGS
3361 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3362 push instructions will have popping returns. */
3363 #ifndef PUSH_ROUNDING
3364 if (!ACCUMULATE_OUTGOING_ARGS)
3365 #endif
3366 combine_stack_adjustments ();
3368 ggc_collect ();
3371 flow2_completed = 1;
3373 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3374 timevar_pop (TV_FLOW2);
3376 #ifdef HAVE_peephole2
3377 if (optimize > 0 && flag_peephole2)
3379 timevar_push (TV_PEEPHOLE2);
3380 open_dump_file (DFI_peephole2, decl);
3382 peephole2_optimize (rtl_dump_file);
3384 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3385 timevar_pop (TV_PEEPHOLE2);
3387 #endif
3389 if (optimize > 0 && (flag_rename_registers || flag_cprop_registers))
3391 timevar_push (TV_RENAME_REGISTERS);
3392 open_dump_file (DFI_rnreg, decl);
3394 if (flag_rename_registers)
3395 regrename_optimize ();
3396 if (flag_cprop_registers)
3397 copyprop_hardreg_forward ();
3399 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3400 timevar_pop (TV_RENAME_REGISTERS);
3403 if (flag_if_conversion2)
3405 timevar_push (TV_IFCVT2);
3406 open_dump_file (DFI_ce2, decl);
3408 if_convert (1);
3410 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3411 timevar_pop (TV_IFCVT2);
3413 #ifdef STACK_REGS
3414 if (optimize)
3415 split_all_insns (1);
3416 #endif
3418 #ifdef INSN_SCHEDULING
3419 if (optimize > 0 && flag_schedule_insns_after_reload)
3421 timevar_push (TV_SCHED2);
3422 open_dump_file (DFI_sched2, decl);
3424 /* Do control and data sched analysis again,
3425 and write some more of the results to dump file. */
3427 split_all_insns (1);
3429 schedule_insns (rtl_dump_file);
3431 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3432 timevar_pop (TV_SCHED2);
3434 ggc_collect ();
3436 #endif
3438 #ifdef LEAF_REGISTERS
3439 current_function_uses_only_leaf_regs
3440 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3441 #endif
3443 #ifdef STACK_REGS
3444 timevar_push (TV_REG_STACK);
3445 open_dump_file (DFI_stack, decl);
3447 reg_to_stack (insns, rtl_dump_file);
3449 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3450 timevar_pop (TV_REG_STACK);
3452 ggc_collect ();
3453 #endif
3454 if (optimize > 0)
3456 timevar_push (TV_REORDER_BLOCKS);
3457 open_dump_file (DFI_bbro, decl);
3459 /* Last attempt to optimize CFG, as scheduling, peepholing and insn
3460 splitting possibly introduced more crossjumping oppurtuntities.
3461 Except that we can't actually run crossjumping without running
3462 another DCE pass, which we can't do after reg-stack. */
3463 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
3464 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3465 if (flag_reorder_blocks)
3467 reorder_basic_blocks ();
3468 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
3471 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3472 timevar_pop (TV_REORDER_BLOCKS);
3474 compute_alignments ();
3476 /* CFG is no longer maintained up-to-date. */
3477 free_bb_for_insn ();
3479 /* If a machine dependent reorganization is needed, call it. */
3480 #ifdef MACHINE_DEPENDENT_REORG
3481 timevar_push (TV_MACH_DEP);
3482 open_dump_file (DFI_mach, decl);
3484 MACHINE_DEPENDENT_REORG (insns);
3486 close_dump_file (DFI_mach, print_rtl, insns);
3487 timevar_pop (TV_MACH_DEP);
3489 ggc_collect ();
3490 #endif
3492 purge_line_number_notes (insns);
3493 cleanup_barriers ();
3495 /* If a scheduling pass for delayed branches is to be done,
3496 call the scheduling code. */
3498 #ifdef DELAY_SLOTS
3499 if (optimize > 0 && flag_delayed_branch)
3501 timevar_push (TV_DBR_SCHED);
3502 open_dump_file (DFI_dbr, decl);
3504 dbr_schedule (insns, rtl_dump_file);
3506 close_dump_file (DFI_dbr, print_rtl, insns);
3507 timevar_pop (TV_DBR_SCHED);
3509 ggc_collect ();
3511 #endif
3513 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3514 timevar_push (TV_SHORTEN_BRANCH);
3515 split_all_insns_noflow ();
3516 timevar_pop (TV_SHORTEN_BRANCH);
3517 #endif
3519 convert_to_eh_region_ranges ();
3521 /* Shorten branches. */
3522 timevar_push (TV_SHORTEN_BRANCH);
3523 shorten_branches (get_insns ());
3524 timevar_pop (TV_SHORTEN_BRANCH);
3526 set_nothrow_function_flags ();
3527 if (current_function_nothrow)
3528 /* Now we know that this can't throw; set the flag for the benefit
3529 of other functions later in this translation unit. */
3530 TREE_NOTHROW (current_function_decl) = 1;
3532 /* Now turn the rtl into assembler code. */
3534 timevar_push (TV_FINAL);
3536 rtx x;
3537 const char *fnname;
3539 /* Get the function's name, as described by its RTL. This may be
3540 different from the DECL_NAME name used in the source file. */
3542 x = DECL_RTL (decl);
3543 if (GET_CODE (x) != MEM)
3544 abort ();
3545 x = XEXP (x, 0);
3546 if (GET_CODE (x) != SYMBOL_REF)
3547 abort ();
3548 fnname = XSTR (x, 0);
3550 assemble_start_function (decl, fnname);
3551 final_start_function (insns, asm_out_file, optimize);
3552 final (insns, asm_out_file, optimize, 0);
3553 final_end_function ();
3555 #ifdef IA64_UNWIND_INFO
3556 /* ??? The IA-64 ".handlerdata" directive must be issued before
3557 the ".endp" directive that closes the procedure descriptor. */
3558 output_function_exception_table ();
3559 #endif
3561 assemble_end_function (decl, fnname);
3563 #ifndef IA64_UNWIND_INFO
3564 /* Otherwise, it feels unclean to switch sections in the middle. */
3565 output_function_exception_table ();
3566 #endif
3568 if (! quiet_flag)
3569 fflush (asm_out_file);
3571 /* Release all memory allocated by flow. */
3572 free_basic_block_vars (0);
3574 /* Release all memory held by regsets now. */
3575 regset_release_memory ();
3577 timevar_pop (TV_FINAL);
3579 ggc_collect ();
3581 /* Write DBX symbols if requested. */
3583 /* Note that for those inline functions where we don't initially
3584 know for certain that we will be generating an out-of-line copy,
3585 the first invocation of this routine (rest_of_compilation) will
3586 skip over this code by doing a `goto exit_rest_of_compilation;'.
3587 Later on, finish_compilation will call rest_of_compilation again
3588 for those inline functions that need to have out-of-line copies
3589 generated. During that call, we *will* be routed past here. */
3591 timevar_push (TV_SYMOUT);
3592 (*debug_hooks->function_decl) (decl);
3593 timevar_pop (TV_SYMOUT);
3595 exit_rest_of_compilation:
3597 /* In case the function was not output,
3598 don't leave any temporary anonymous types
3599 queued up for sdb output. */
3600 #ifdef SDB_DEBUGGING_INFO
3601 if (write_symbols == SDB_DEBUG)
3602 sdbout_types (NULL_TREE);
3603 #endif
3605 reload_completed = 0;
3606 flow2_completed = 0;
3607 no_new_pseudos = 0;
3609 timevar_push (TV_FINAL);
3611 /* Clear out the insn_length contents now that they are no
3612 longer valid. */
3613 init_insn_lengths ();
3615 /* Show no temporary slots allocated. */
3616 init_temp_slots ();
3618 free_basic_block_vars (0);
3619 free_bb_for_insn ();
3621 timevar_pop (TV_FINAL);
3623 /* Make sure volatile mem refs aren't considered valid operands for
3624 arithmetic insns. We must call this here if this is a nested inline
3625 function, since the above code leaves us in the init_recog state
3626 (from final.c), and the function context push/pop code does not
3627 save/restore volatile_ok.
3629 ??? Maybe it isn't necessary for expand_start_function to call this
3630 anymore if we do it here? */
3632 init_recog_no_volatile ();
3634 /* We're done with this function. Free up memory if we can. */
3635 free_after_parsing (cfun);
3636 if (! DECL_DEFER_OUTPUT (decl))
3638 free_after_compilation (cfun);
3640 /* Clear integrate.c's pointer to the cfun structure we just
3641 destroyed. */
3642 DECL_SAVED_INSNS (decl) = 0;
3644 cfun = 0;
3646 ggc_collect ();
3648 timevar_pop (TV_REST_OF_COMPILATION);
3651 static void
3652 display_help ()
3654 int undoc;
3655 unsigned long i;
3656 const char *lang;
3658 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3659 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3660 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3661 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3662 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3663 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"));
3664 printf (_(" -ftls-model=[global-dynamic | local-dynamic | initial-exec | local-exec] Indicates the default thread-local storage code generation model\n"));
3666 for (i = ARRAY_SIZE (f_options); i--;)
3668 const char *description = f_options[i].description;
3670 if (description != NULL && *description != 0)
3671 printf (" -f%-21s %s\n",
3672 f_options[i].string, _(description));
3675 printf (_(" -O[number] Set optimization level to [number]\n"));
3676 printf (_(" -Os Optimize for space rather than speed\n"));
3677 for (i = LAST_PARAM; i--;)
3679 const char *description = compiler_params[i].help;
3680 const int length = 21 - strlen (compiler_params[i].option);
3682 if (description != NULL && *description != 0)
3683 printf (" --param %s=<value>%.*s%s\n",
3684 compiler_params[i].option,
3685 length > 0 ? length : 1, " ",
3686 _(description));
3688 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3689 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3690 printf (_(" -w Suppress warnings\n"));
3691 printf (_(" -W Enable extra warnings\n"));
3693 for (i = ARRAY_SIZE (W_options); i--;)
3695 const char *description = W_options[i].description;
3697 if (description != NULL && *description != 0)
3698 printf (" -W%-21s %s\n",
3699 W_options[i].string, _(description));
3702 printf (_(" -Wunused Enable unused warnings\n"));
3703 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3704 printf (_(" -p Enable function profiling\n"));
3705 printf (_(" -o <file> Place output into <file> \n"));
3706 printf (_("\
3707 -G <number> Put global and static data smaller than <number>\n\
3708 bytes into a special section (on some targets)\n"));
3710 for (i = ARRAY_SIZE (debug_args); i--;)
3712 if (debug_args[i].description != NULL)
3713 printf (" -g%-21s %s\n",
3714 debug_args[i].arg, _(debug_args[i].description));
3717 printf (_(" -aux-info <file> Emit declaration info into <file>\n"));
3718 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3719 printf (_(" -version Display the compiler's version\n"));
3720 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3721 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3722 #if defined INSN_SCHEDULING
3723 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3724 #endif
3725 printf (_(" --help Display this information\n"));
3727 undoc = 0;
3728 lang = "language";
3730 /* Display descriptions of language specific options.
3731 If there is no description, note that there is an undocumented option.
3732 If the description is empty, do not display anything. (This allows
3733 options to be deliberately undocumented, for whatever reason).
3734 If the option string is missing, then this is a marker, indicating
3735 that the description string is in fact the name of a language, whose
3736 language specific options are to follow. */
3738 if (ARRAY_SIZE (documented_lang_options) > 1)
3740 printf (_("\nLanguage specific options:\n"));
3742 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3744 const char *description = documented_lang_options[i].description;
3745 const char *option = documented_lang_options[i].option;
3747 if (description == NULL)
3749 undoc = 1;
3751 if (extra_warnings)
3752 printf (_(" %-23.23s [undocumented]\n"), option);
3754 else if (*description == 0)
3755 continue;
3756 else if (option == NULL)
3758 if (undoc)
3759 printf
3760 (_("\nThere are undocumented %s specific options as well.\n"),
3761 lang);
3762 undoc = 0;
3764 printf (_("\n Options for %s:\n"), description);
3766 lang = description;
3768 else
3769 printf (" %-23.23s %s\n", option, _(description));
3773 if (undoc)
3774 printf (_("\nThere are undocumented %s specific options as well.\n"),
3775 lang);
3777 display_target_options ();
3780 static void
3781 display_target_options ()
3783 int undoc, i;
3784 static bool displayed = false;
3786 /* Avoid double printing for --help --target-help. */
3787 if (displayed)
3788 return;
3789 displayed = true;
3791 if (ARRAY_SIZE (target_switches) > 1
3792 #ifdef TARGET_OPTIONS
3793 || ARRAY_SIZE (target_options) > 1
3794 #endif
3797 int doc = 0;
3799 undoc = 0;
3801 printf (_("\nTarget specific options:\n"));
3803 for (i = ARRAY_SIZE (target_switches); i--;)
3805 const char *option = target_switches[i].name;
3806 const char *description = target_switches[i].description;
3808 if (option == NULL || *option == 0)
3809 continue;
3810 else if (description == NULL)
3812 undoc = 1;
3814 if (extra_warnings)
3815 printf (_(" -m%-23.23s [undocumented]\n"), option);
3817 else if (*description != 0)
3818 doc += printf (" -m%-23.23s %s\n", option, _(description));
3821 #ifdef TARGET_OPTIONS
3822 for (i = ARRAY_SIZE (target_options); i--;)
3824 const char *option = target_options[i].prefix;
3825 const char *description = target_options[i].description;
3827 if (option == NULL || *option == 0)
3828 continue;
3829 else if (description == NULL)
3831 undoc = 1;
3833 if (extra_warnings)
3834 printf (_(" -m%-23.23s [undocumented]\n"), option);
3836 else if (*description != 0)
3837 doc += printf (" -m%-23.23s %s\n", option, _(description));
3839 #endif
3840 if (undoc)
3842 if (doc)
3843 printf (_("\nThere are undocumented target specific options as well.\n"));
3844 else
3845 printf (_(" They exist, but they are not documented.\n"));
3850 /* Parse a -d... command line switch. */
3852 static void
3853 decode_d_option (arg)
3854 const char *arg;
3856 int i, c, matched;
3858 while (*arg)
3859 switch (c = *arg++)
3861 case 'a':
3862 for (i = 0; i < (int) DFI_MAX; ++i)
3863 dump_file[i].enabled = 1;
3864 break;
3865 case 'A':
3866 flag_debug_asm = 1;
3867 break;
3868 case 'p':
3869 flag_print_asm_name = 1;
3870 break;
3871 case 'P':
3872 flag_dump_rtl_in_asm = 1;
3873 flag_print_asm_name = 1;
3874 break;
3875 case 'v':
3876 graph_dump_format = vcg;
3877 break;
3878 case 'x':
3879 rtl_dump_and_exit = 1;
3880 break;
3881 case 'y':
3882 set_yydebug = 1;
3883 break;
3884 case 'D': /* These are handled by the preprocessor. */
3885 case 'I':
3886 break;
3888 default:
3889 matched = 0;
3890 for (i = 0; i < (int) DFI_MAX; ++i)
3891 if (c == dump_file[i].debug_switch)
3893 dump_file[i].enabled = 1;
3894 matched = 1;
3897 if (! matched)
3898 warning ("unrecognized gcc debugging option: %c", c);
3899 break;
3903 /* Parse a -f... command line switch. ARG is the value after the -f.
3904 It is safe to access 'ARG - 2' to generate the full switch name.
3905 Return the number of strings consumed. */
3907 static int
3908 decode_f_option (arg)
3909 const char *arg;
3911 int j;
3912 const char *option_value = NULL;
3914 /* Search for the option in the table of binary f options. */
3915 for (j = ARRAY_SIZE (f_options); j--;)
3917 if (!strcmp (arg, f_options[j].string))
3919 *f_options[j].variable = f_options[j].on_value;
3920 return 1;
3923 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3924 && ! strcmp (arg + 3, f_options[j].string))
3926 *f_options[j].variable = ! f_options[j].on_value;
3927 return 1;
3931 if (!strcmp (arg, "fast-math"))
3932 set_fast_math_flags (1);
3933 else if (!strcmp (arg, "no-fast-math"))
3934 set_fast_math_flags (0);
3935 else if ((option_value = skip_leading_substring (arg, "inline-limit-"))
3936 || (option_value = skip_leading_substring (arg, "inline-limit=")))
3938 int val =
3939 read_integral_parameter (option_value, arg - 2,
3940 MAX_INLINE_INSNS);
3941 set_param_value ("max-inline-insns", val);
3943 else if ((option_value = skip_leading_substring (arg, "tls-model=")))
3945 if (strcmp (option_value, "global-dynamic") == 0)
3946 flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
3947 else if (strcmp (option_value, "local-dynamic") == 0)
3948 flag_tls_default = TLS_MODEL_LOCAL_DYNAMIC;
3949 else if (strcmp (option_value, "initial-exec") == 0)
3950 flag_tls_default = TLS_MODEL_INITIAL_EXEC;
3951 else if (strcmp (option_value, "local-exec") == 0)
3952 flag_tls_default = TLS_MODEL_LOCAL_EXEC;
3953 else
3954 warning ("`%s': unknown tls-model option", arg - 2);
3956 #ifdef INSN_SCHEDULING
3957 else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
3958 fix_sched_param ("verbose", option_value);
3959 #endif
3960 else if ((option_value = skip_leading_substring (arg, "fixed-")))
3961 fix_register (option_value, 1, 1);
3962 else if ((option_value = skip_leading_substring (arg, "call-used-")))
3963 fix_register (option_value, 0, 1);
3964 else if ((option_value = skip_leading_substring (arg, "call-saved-")))
3965 fix_register (option_value, 0, 0);
3966 else if ((option_value = skip_leading_substring (arg, "align-loops=")))
3967 align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
3968 else if ((option_value = skip_leading_substring (arg, "align-functions=")))
3969 align_functions
3970 = read_integral_parameter (option_value, arg - 2, align_functions);
3971 else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
3972 align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
3973 else if ((option_value = skip_leading_substring (arg, "align-labels=")))
3974 align_labels
3975 = read_integral_parameter (option_value, arg - 2, align_labels);
3976 else if ((option_value
3977 = skip_leading_substring (arg, "stack-limit-register=")))
3979 int reg = decode_reg_name (option_value);
3980 if (reg < 0)
3981 error ("unrecognized register name `%s'", option_value);
3982 else
3983 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
3985 else if ((option_value
3986 = skip_leading_substring (arg, "stack-limit-symbol=")))
3988 const char *nm;
3989 nm = ggc_strdup (option_value);
3990 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
3992 else if ((option_value
3993 = skip_leading_substring (arg, "message-length=")))
3994 output_set_maximum_length
3995 (&global_dc->buffer, read_integral_parameter
3996 (option_value, arg - 2, diagnostic_line_cutoff (global_dc)));
3997 else if ((option_value
3998 = skip_leading_substring (arg, "diagnostics-show-location=")))
4000 if (!strcmp (option_value, "once"))
4001 diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
4002 else if (!strcmp (option_value, "every-line"))
4003 diagnostic_prefixing_rule (global_dc)
4004 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
4005 else
4006 error ("unrecognized option `%s'", arg - 2);
4008 else if (!strcmp (arg, "no-stack-limit"))
4009 stack_limit_rtx = NULL_RTX;
4010 else if (!strcmp (arg, "preprocessed"))
4011 /* Recognize this switch but do nothing. This prevents warnings
4012 about an unrecognized switch if cpplib has not been linked in. */
4014 else
4015 return 0;
4017 return 1;
4020 /* Parse a -W... command line switch. ARG is the value after the -W.
4021 It is safe to access 'ARG - 2' to generate the full switch name.
4022 Return the number of strings consumed. */
4024 static int
4025 decode_W_option (arg)
4026 const char *arg;
4028 const char *option_value = NULL;
4029 int j;
4031 /* Search for the option in the table of binary W options. */
4033 for (j = ARRAY_SIZE (W_options); j--;)
4035 if (!strcmp (arg, W_options[j].string))
4037 *W_options[j].variable = W_options[j].on_value;
4038 return 1;
4041 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4042 && ! strcmp (arg + 3, W_options[j].string))
4044 *W_options[j].variable = ! W_options[j].on_value;
4045 return 1;
4049 if ((option_value = skip_leading_substring (arg, "id-clash-")))
4050 warning ("-Wid-clash-LEN is no longer supported");
4051 else if ((option_value = skip_leading_substring (arg, "larger-than-")))
4053 larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
4055 warn_larger_than = larger_than_size != -1;
4057 else if (!strcmp (arg, "unused"))
4059 set_Wunused (1);
4061 else if (!strcmp (arg, "no-unused"))
4063 set_Wunused (0);
4065 else
4066 return 0;
4068 return 1;
4071 /* Parse a -g... command line switch. ARG is the value after the -g.
4072 It is safe to access 'ARG - 2' to generate the full switch name.
4073 Return the number of strings consumed. */
4075 static int
4076 decode_g_option (arg)
4077 const char *arg;
4079 static unsigned level = 0;
4080 /* A lot of code assumes write_symbols == NO_DEBUG if the
4081 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4082 of what debugging type has been selected). This records the
4083 selected type. It is an error to specify more than one
4084 debugging type. */
4085 static enum debug_info_type selected_debug_type = NO_DEBUG;
4086 /* Non-zero if debugging format has been explicitly set.
4087 -g and -ggdb don't explicitly set the debugging format so
4088 -gdwarf -g3 is equivalent to -gdwarf3. */
4089 static int type_explicitly_set_p = 0;
4090 /* Indexed by enum debug_info_type. */
4091 static const char *const debug_type_names[] =
4093 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
4096 /* The maximum admissible debug level value. */
4097 static const unsigned max_debug_level = 3;
4099 /* Look up ARG in the table. */
4100 for (da = debug_args; da->arg; da++)
4102 const int da_len = strlen (da->arg);
4104 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4106 enum debug_info_type type = da->debug_type;
4107 const char *p = arg + da_len;
4109 if (*p && ! ISDIGIT (*p))
4110 continue;
4112 /* A debug flag without a level defaults to level 2.
4113 Note we do not want to call read_integral_parameter
4114 for that case since it will call atoi which
4115 will return zero.
4117 ??? We may want to generalize the interface to
4118 read_integral_parameter to better handle this case
4119 if this case shows up often. */
4120 if (*p)
4121 level = read_integral_parameter (p, 0, max_debug_level + 1);
4122 else
4123 level = (level == 0) ? 2 : level;
4125 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4127 error ("use -gdwarf -g%d for DWARF v1, level %d",
4128 level, level);
4129 if (level == 2)
4130 error ("use -gdwarf-2 for DWARF v2");
4133 if (level > max_debug_level)
4135 warning ("\
4136 ignoring option `%s' due to invalid debug level specification",
4137 arg - 2);
4138 level = debug_info_level;
4141 if (type == NO_DEBUG)
4143 type = PREFERRED_DEBUGGING_TYPE;
4145 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4147 #ifdef DWARF2_DEBUGGING_INFO
4148 type = DWARF2_DEBUG;
4149 #else
4150 #ifdef DBX_DEBUGGING_INFO
4151 type = DBX_DEBUG;
4152 #endif
4153 #endif
4157 if (type == NO_DEBUG)
4158 warning ("`%s': unknown or unsupported -g option", arg - 2);
4160 /* Does it conflict with an already selected type? */
4161 if (type_explicitly_set_p
4162 /* -g/-ggdb don't conflict with anything. */
4163 && da->debug_type != NO_DEBUG
4164 && type != selected_debug_type)
4165 warning ("`%s' ignored, conflicts with `-g%s'",
4166 arg - 2, debug_type_names[(int) selected_debug_type]);
4167 else
4169 /* If the format has already been set, -g/-ggdb
4170 only change the debug level. */
4171 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4172 /* Don't change debugging type. */
4174 else
4176 selected_debug_type = type;
4177 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4180 write_symbols = (level == 0
4181 ? NO_DEBUG
4182 : selected_debug_type);
4183 use_gnu_debug_info_extensions = da->use_extensions_p;
4184 debug_info_level = (enum debug_info_level) level;
4187 break;
4191 if (! da->arg)
4192 return 0;
4194 return 1;
4197 /* Decode the first argument in the argv as a language-independent option.
4198 Return the number of strings consumed. */
4200 static unsigned int
4201 independent_decode_option (argc, argv)
4202 int argc;
4203 char **argv;
4205 char *arg = argv[0];
4207 if (arg[0] != '-' || arg[1] == 0)
4209 if (arg[0] == '+')
4210 return 0;
4212 filename = arg;
4214 return 1;
4217 arg++;
4219 if (!strcmp (arg, "-help"))
4221 display_help ();
4222 exit_after_options = 1;
4225 if (!strcmp (arg, "-target-help"))
4227 display_target_options ();
4228 exit_after_options = 1;
4231 if (!strcmp (arg, "-version"))
4233 print_version (stderr, "");
4234 exit_after_options = 1;
4237 /* Handle '--param <name>=<value>'. */
4238 if (strcmp (arg, "-param") == 0)
4240 char *equal;
4242 if (argc == 1)
4244 error ("-param option missing argument");
4245 return 1;
4248 /* Get the '<name>=<value>' parameter. */
4249 arg = argv[1];
4250 /* Look for the `='. */
4251 equal = strchr (arg, '=');
4252 if (!equal)
4253 error ("invalid --param option: %s", arg);
4254 else
4256 int val;
4258 /* Zero out the `=' sign so that we get two separate strings. */
4259 *equal = '\0';
4260 /* Figure out what value is specified. */
4261 val = read_integral_parameter (equal + 1, NULL, INVALID_PARAM_VAL);
4262 if (val != INVALID_PARAM_VAL)
4263 set_param_value (arg, val);
4264 else
4265 error ("invalid parameter value `%s'", equal + 1);
4268 return 2;
4271 if (*arg == 'Y')
4272 arg++;
4274 switch (*arg)
4276 default:
4277 return 0;
4279 case 'O':
4280 /* Already been treated in main (). Do nothing. */
4281 break;
4283 case 'm':
4284 set_target_switch (arg + 1);
4285 break;
4287 case 'f':
4288 return decode_f_option (arg + 1);
4290 case 'g':
4291 return decode_g_option (arg + 1);
4293 case 'd':
4294 if (!strcmp (arg, "dumpbase"))
4296 if (argc == 1)
4297 return 0;
4299 if (argv[1][0])
4300 dump_base_name = argv[1];
4302 return 2;
4304 else
4305 decode_d_option (arg + 1);
4306 break;
4308 case 'p':
4309 if (!strcmp (arg, "pedantic"))
4310 pedantic = 1;
4311 else if (!strcmp (arg, "pedantic-errors"))
4312 flag_pedantic_errors = pedantic = 1;
4313 else if (arg[1] == 0)
4314 profile_flag = 1;
4315 else
4316 return 0;
4317 break;
4319 case 'q':
4320 if (!strcmp (arg, "quiet"))
4321 quiet_flag = 1;
4322 else
4323 return 0;
4324 break;
4326 case 'v':
4327 if (!strcmp (arg, "version"))
4328 version_flag = 1;
4329 else
4330 return 0;
4331 break;
4333 case 'w':
4334 if (arg[1] == 0)
4335 inhibit_warnings = 1;
4336 else
4337 return 0;
4338 break;
4340 case 'W':
4341 if (arg[1] == 0)
4343 extra_warnings = 1;
4344 /* We save the value of warn_uninitialized, since if they put
4345 -Wuninitialized on the command line, we need to generate a
4346 warning about not using it without also specifying -O. */
4347 if (warn_uninitialized != 1)
4348 warn_uninitialized = 2;
4350 else
4351 return decode_W_option (arg + 1);
4352 break;
4354 case 'a':
4355 if (!strncmp (arg, "aux-info", 8))
4357 if (arg[8] == '\0')
4359 if (argc == 1)
4360 return 0;
4362 aux_info_file_name = argv[1];
4363 flag_gen_aux_info = 1;
4364 return 2;
4366 else if (arg[8] == '=')
4368 aux_info_file_name = arg + 9;
4369 flag_gen_aux_info = 1;
4371 else
4372 return 0;
4374 else if (!strcmp (arg, "auxbase"))
4376 if (argc == 1)
4377 return 0;
4379 if (argv[1][0])
4380 aux_base_name = argv[1];
4382 return 2;
4384 else if (!strcmp (arg, "auxbase-strip"))
4386 if (argc == 1)
4387 return 0;
4389 if (argv[1][0])
4391 strip_off_ending (argv[1], strlen (argv[1]));
4392 if (argv[1][0])
4393 aux_base_name = argv[1];
4396 return 2;
4398 else
4399 return 0;
4400 break;
4402 case 'o':
4403 if (arg[1] == 0)
4405 if (argc == 1)
4406 return 0;
4408 asm_file_name = argv[1];
4409 return 2;
4411 return 0;
4413 case 'G':
4415 int g_switch_val;
4416 int return_val;
4418 if (arg[1] == 0)
4420 if (argc == 1)
4421 return 0;
4423 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4424 return_val = 2;
4426 else
4428 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4429 return_val = 1;
4432 if (g_switch_val == -1)
4433 return_val = 0;
4434 else
4436 g_switch_set = TRUE;
4437 g_switch_value = g_switch_val;
4440 return return_val;
4444 return 1;
4447 /* Decode -m switches. */
4448 /* Decode the switch -mNAME. */
4450 static void
4451 set_target_switch (name)
4452 const char *name;
4454 size_t j;
4455 int valid_target_option = 0;
4457 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4458 if (!strcmp (target_switches[j].name, name))
4460 if (target_switches[j].value < 0)
4461 target_flags &= ~-target_switches[j].value;
4462 else
4463 target_flags |= target_switches[j].value;
4464 if (name[0] != 0)
4466 if (target_switches[j].value < 0)
4467 target_flags_explicit |= -target_switches[j].value;
4468 else
4469 target_flags_explicit |= target_switches[j].value;
4471 valid_target_option = 1;
4474 #ifdef TARGET_OPTIONS
4475 if (!valid_target_option)
4476 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4478 int len = strlen (target_options[j].prefix);
4479 if (!strncmp (target_options[j].prefix, name, len))
4481 *target_options[j].variable = name + len;
4482 valid_target_option = 1;
4485 #endif
4487 if (!valid_target_option)
4488 error ("invalid option `%s'", name);
4491 /* Print version information to FILE.
4492 Each line begins with INDENT (for the case where FILE is the
4493 assembler output file). */
4495 static void
4496 print_version (file, indent)
4497 FILE *file;
4498 const char *indent;
4500 #ifndef __VERSION__
4501 #define __VERSION__ "[?]"
4502 #endif
4503 fnotice (file,
4504 #ifdef __GNUC__
4505 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
4506 #else
4507 "%s%s%s version %s (%s) compiled by CC.\n"
4508 #endif
4509 , indent, *indent != 0 ? " " : "",
4510 lang_hooks.name, version_string, TARGET_NAME,
4511 indent, __VERSION__);
4514 /* Print an option value and return the adjusted position in the line.
4515 ??? We don't handle error returns from fprintf (disk full); presumably
4516 other code will catch a disk full though. */
4518 static int
4519 print_single_switch (file, pos, max, indent, sep, term, type, name)
4520 FILE *file;
4521 int pos, max;
4522 const char *indent, *sep, *term, *type, *name;
4524 /* The ultrix fprintf returns 0 on success, so compute the result we want
4525 here since we need it for the following test. */
4526 int len = strlen (sep) + strlen (type) + strlen (name);
4528 if (pos != 0
4529 && pos + len > max)
4531 fprintf (file, "%s", term);
4532 pos = 0;
4534 if (pos == 0)
4536 fprintf (file, "%s", indent);
4537 pos = strlen (indent);
4539 fprintf (file, "%s%s%s", sep, type, name);
4540 pos += len;
4541 return pos;
4544 /* Print active target switches to FILE.
4545 POS is the current cursor position and MAX is the size of a "line".
4546 Each line begins with INDENT and ends with TERM.
4547 Each switch is separated from the next by SEP. */
4549 static void
4550 print_switch_values (file, pos, max, indent, sep, term)
4551 FILE *file;
4552 int pos, max;
4553 const char *indent, *sep, *term;
4555 size_t j;
4556 char **p;
4558 /* Print the options as passed. */
4560 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4561 _("options passed: "), "");
4563 for (p = &save_argv[1]; *p != NULL; p++)
4564 if (**p == '-')
4566 /* Ignore these. */
4567 if (strcmp (*p, "-o") == 0)
4569 if (p[1] != NULL)
4570 p++;
4571 continue;
4573 if (strcmp (*p, "-quiet") == 0)
4574 continue;
4575 if (strcmp (*p, "-version") == 0)
4576 continue;
4577 if ((*p)[1] == 'd')
4578 continue;
4580 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4582 if (pos > 0)
4583 fprintf (file, "%s", term);
4585 /* Print the -f and -m options that have been enabled.
4586 We don't handle language specific options but printing argv
4587 should suffice. */
4589 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4590 _("options enabled: "), "");
4592 for (j = 0; j < ARRAY_SIZE (f_options); j++)
4593 if (*f_options[j].variable == f_options[j].on_value)
4594 pos = print_single_switch (file, pos, max, indent, sep, term,
4595 "-f", f_options[j].string);
4597 /* Print target specific options. */
4599 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4600 if (target_switches[j].name[0] != '\0'
4601 && target_switches[j].value > 0
4602 && ((target_switches[j].value & target_flags)
4603 == target_switches[j].value))
4605 pos = print_single_switch (file, pos, max, indent, sep, term,
4606 "-m", target_switches[j].name);
4609 #ifdef TARGET_OPTIONS
4610 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4611 if (*target_options[j].variable != NULL)
4613 char prefix[256];
4614 sprintf (prefix, "-m%s", target_options[j].prefix);
4615 pos = print_single_switch (file, pos, max, indent, sep, term,
4616 prefix, *target_options[j].variable);
4618 #endif
4620 fprintf (file, "%s", term);
4623 /* Open assembly code output file. Do this even if -fsyntax-only is
4624 on, because then the driver will have provided the name of a
4625 temporary file or bit bucket for us. NAME is the file specified on
4626 the command line, possibly NULL. */
4627 static void
4628 init_asm_output (name)
4629 const char *name;
4631 if (name == NULL && asm_file_name == 0)
4632 asm_out_file = stdout;
4633 else
4635 if (asm_file_name == 0)
4637 int len = strlen (dump_base_name);
4638 char *dumpname = (char *) xmalloc (len + 6);
4639 memcpy (dumpname, dump_base_name, len + 1);
4640 strip_off_ending (dumpname, len);
4641 strcat (dumpname, ".s");
4642 asm_file_name = dumpname;
4644 if (!strcmp (asm_file_name, "-"))
4645 asm_out_file = stdout;
4646 else
4647 asm_out_file = fopen (asm_file_name, "w");
4648 if (asm_out_file == 0)
4649 fatal_io_error ("can't open %s for writing", asm_file_name);
4652 #ifdef IO_BUFFER_SIZE
4653 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
4654 _IOFBF, IO_BUFFER_SIZE);
4655 #endif
4657 if (!flag_syntax_only)
4659 #ifdef ASM_FILE_START
4660 ASM_FILE_START (asm_out_file);
4661 #endif
4663 #ifdef ASM_COMMENT_START
4664 if (flag_verbose_asm)
4666 /* Print the list of options in effect. */
4667 print_version (asm_out_file, ASM_COMMENT_START);
4668 print_switch_values (asm_out_file, 0, MAX_LINE,
4669 ASM_COMMENT_START, " ", "\n");
4670 /* Add a blank line here so it appears in assembler output but not
4671 screen output. */
4672 fprintf (asm_out_file, "\n");
4674 #endif
4678 /* Initialization of the front end environment, before command line
4679 options are parsed. Signal handlers, internationalization etc.
4680 ARGV0 is main's argv[0]. */
4681 static void
4682 general_init (argv0)
4683 char *argv0;
4685 char *p;
4687 p = argv0 + strlen (argv0);
4688 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4689 --p;
4690 progname = p;
4692 xmalloc_set_program_name (progname);
4694 hex_init ();
4696 gcc_init_libintl ();
4698 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4699 #ifdef SIGSEGV
4700 signal (SIGSEGV, crash_signal);
4701 #endif
4702 #ifdef SIGILL
4703 signal (SIGILL, crash_signal);
4704 #endif
4705 #ifdef SIGBUS
4706 signal (SIGBUS, crash_signal);
4707 #endif
4708 #ifdef SIGABRT
4709 signal (SIGABRT, crash_signal);
4710 #endif
4711 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4712 signal (SIGIOT, crash_signal);
4713 #endif
4714 #ifdef SIGFPE
4715 signal (SIGFPE, crash_signal);
4716 #endif
4718 /* Initialize the diagnostics reporting machinery, so option parsing
4719 can give warnings and errors. */
4720 diagnostic_initialize (global_dc);
4722 /* Initialize the garbage-collector, string pools and tree type hash
4723 table. */
4724 init_ggc ();
4725 init_stringpool ();
4726 init_ttree ();
4729 /* Parse command line options and set default flag values, called
4730 after language-independent option-independent initialization. Do
4731 minimal options processing. Outputting diagnostics is OK, but GC
4732 and identifier hashtables etc. are not initialized yet.
4734 Return non-zero to suppress compiler back end initialization. */
4735 static void
4736 parse_options_and_default_flags (argc, argv)
4737 int argc;
4738 char **argv;
4740 int i;
4742 /* Save in case md file wants to emit args as a comment. */
4743 save_argc = argc;
4744 save_argv = argv;
4746 /* Initialize register usage now so switches may override. */
4747 init_reg_sets ();
4749 /* Register the language-independent parameters. */
4750 add_params (lang_independent_params, LAST_PARAM);
4752 /* Perform language-specific options initialization. */
4753 (*lang_hooks.init_options) ();
4755 /* Scan to see what optimization level has been specified. That will
4756 determine the default value of many flags. */
4757 for (i = 1; i < argc; i++)
4759 if (!strcmp (argv[i], "-O"))
4761 optimize = 1;
4762 optimize_size = 0;
4764 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4766 /* Handle -Os, -O2, -O3, -O69, ... */
4767 char *p = &argv[i][2];
4769 if ((p[0] == 's') && (p[1] == 0))
4771 optimize_size = 1;
4773 /* Optimizing for size forces optimize to be 2. */
4774 optimize = 2;
4776 else
4778 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4779 if (optimize_val != -1)
4781 optimize = optimize_val;
4782 optimize_size = 0;
4788 if (!optimize)
4790 flag_merge_constants = 0;
4793 if (optimize >= 1)
4795 flag_defer_pop = 1;
4796 flag_thread_jumps = 1;
4797 #ifdef DELAY_SLOTS
4798 flag_delayed_branch = 1;
4799 #endif
4800 #ifdef CAN_DEBUG_WITHOUT_FP
4801 flag_omit_frame_pointer = 1;
4802 #endif
4803 flag_guess_branch_prob = 1;
4804 flag_cprop_registers = 1;
4805 flag_loop_optimize = 1;
4806 flag_crossjumping = 1;
4807 flag_if_conversion = 1;
4808 flag_if_conversion2 = 1;
4811 if (optimize >= 2)
4813 flag_optimize_sibling_calls = 1;
4814 flag_cse_follow_jumps = 1;
4815 flag_cse_skip_blocks = 1;
4816 flag_gcse = 1;
4817 flag_expensive_optimizations = 1;
4818 flag_strength_reduce = 1;
4819 flag_rerun_cse_after_loop = 1;
4820 flag_rerun_loop_opt = 1;
4821 flag_caller_saves = 1;
4822 flag_force_mem = 1;
4823 flag_peephole2 = 1;
4824 #ifdef INSN_SCHEDULING
4825 flag_schedule_insns = 1;
4826 flag_schedule_insns_after_reload = 1;
4827 #endif
4828 flag_regmove = 1;
4829 flag_strict_aliasing = 1;
4830 flag_delete_null_pointer_checks = 1;
4831 flag_reorder_blocks = 1;
4832 flag_reorder_functions = 1;
4835 if (optimize >= 3)
4837 flag_inline_functions = 1;
4838 flag_rename_registers = 1;
4841 if (optimize < 2 || optimize_size)
4843 align_loops = 1;
4844 align_jumps = 1;
4845 align_labels = 1;
4846 align_functions = 1;
4848 /* Don't reorder blocks when optimizing for size because extra
4849 jump insns may be created; also barrier may create extra padding.
4851 More correctly we should have a block reordering mode that tried
4852 to minimize the combined size of all the jumps. This would more
4853 or less automatically remove extra jumps, but would also try to
4854 use more short jumps instead of long jumps. */
4855 flag_reorder_blocks = 0;
4858 /* Initialize whether `char' is signed. */
4859 flag_signed_char = DEFAULT_SIGNED_CHAR;
4860 #ifdef DEFAULT_SHORT_ENUMS
4861 /* Initialize how much space enums occupy, by default. */
4862 flag_short_enums = DEFAULT_SHORT_ENUMS;
4863 #endif
4865 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4866 modify it. */
4867 target_flags = 0;
4868 set_target_switch ("");
4870 /* Unwind tables are always present in an ABI-conformant IA-64
4871 object file, so the default should be ON. */
4872 #ifdef IA64_UNWIND_INFO
4873 flag_unwind_tables = IA64_UNWIND_INFO;
4874 #endif
4876 #ifdef OPTIMIZATION_OPTIONS
4877 /* Allow default optimizations to be specified on a per-machine basis. */
4878 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4879 #endif
4881 /* Perform normal command line switch decoding. */
4882 for (i = 1; i < argc;)
4884 int lang_processed;
4885 int indep_processed;
4887 /* Give the language a chance to decode the option for itself. */
4888 lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
4890 if (lang_processed >= 0)
4891 /* Now see if the option also has a language independent meaning.
4892 Some options are both language specific and language independent,
4893 eg --help. */
4894 indep_processed = independent_decode_option (argc - i, argv + i);
4895 else
4897 lang_processed = -lang_processed;
4898 indep_processed = 0;
4901 if (lang_processed || indep_processed)
4902 i += MAX (lang_processed, indep_processed);
4903 else
4905 const char *option = NULL;
4906 const char *lang = NULL;
4907 unsigned int j;
4909 /* It is possible that the command line switch is not valid for the
4910 current language, but it is valid for another language. In order
4911 to be compatible with previous versions of the compiler (which
4912 did not issue an error message in this case) we check for this
4913 possibility here. If we do find a match, then if extra_warnings
4914 is set we generate a warning message, otherwise we will just
4915 ignore the option. */
4916 for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4918 option = documented_lang_options[j].option;
4920 if (option == NULL)
4921 lang = documented_lang_options[j].description;
4922 else if (! strncmp (argv[i], option, strlen (option)))
4923 break;
4926 if (j != ARRAY_SIZE (documented_lang_options))
4928 if (extra_warnings)
4930 warning ("ignoring command line option '%s'", argv[i]);
4931 if (lang)
4932 warning
4933 ("(it is valid for %s but not the selected language)",
4934 lang);
4937 else if (argv[i][0] == '-' && argv[i][1] == 'g')
4938 warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
4939 else
4940 error ("unrecognized option `%s'", argv[i]);
4942 i++;
4946 if (flag_no_inline == 2)
4947 flag_no_inline = 0;
4948 else
4949 flag_really_no_inline = flag_no_inline;
4951 /* Set flag_no_inline before the post_options () hook. The C front
4952 ends use it to determine tree inlining defaults. FIXME: such
4953 code should be lang-independent when all front ends use tree
4954 inlining, in which case it, and this condition, should be moved
4955 to the top of process_options() instead. */
4956 if (optimize == 0)
4958 /* Inlining does not work if not optimizing,
4959 so force it not to be done. */
4960 flag_no_inline = 1;
4961 warn_inline = 0;
4963 /* The c_decode_option function and decode_option hook set
4964 this to `2' if -Wall is used, so we can avoid giving out
4965 lots of errors for people who don't realize what -Wall does. */
4966 if (warn_uninitialized == 1)
4967 warning ("-Wuninitialized is not supported without -O");
4970 if (flag_really_no_inline == 2)
4971 flag_really_no_inline = flag_no_inline;
4974 /* Process the options that have been parsed. */
4975 static void
4976 process_options ()
4978 #ifdef OVERRIDE_OPTIONS
4979 /* Some machines may reject certain combinations of options. */
4980 OVERRIDE_OPTIONS;
4981 #endif
4983 /* Set up the align_*_log variables, defaulting them to 1 if they
4984 were still unset. */
4985 if (align_loops <= 0) align_loops = 1;
4986 if (align_loops_max_skip > align_loops || !align_loops)
4987 align_loops_max_skip = align_loops - 1;
4988 align_loops_log = floor_log2 (align_loops * 2 - 1);
4989 if (align_jumps <= 0) align_jumps = 1;
4990 if (align_jumps_max_skip > align_jumps || !align_jumps)
4991 align_jumps_max_skip = align_jumps - 1;
4992 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4993 if (align_labels <= 0) align_labels = 1;
4994 align_labels_log = floor_log2 (align_labels * 2 - 1);
4995 if (align_labels_max_skip > align_labels || !align_labels)
4996 align_labels_max_skip = align_labels - 1;
4997 if (align_functions <= 0) align_functions = 1;
4998 align_functions_log = floor_log2 (align_functions * 2 - 1);
5000 /* Unrolling all loops implies that standard loop unrolling must also
5001 be done. */
5002 if (flag_unroll_all_loops)
5003 flag_unroll_loops = 1;
5004 /* Loop unrolling requires that strength_reduction be on also. Silently
5005 turn on strength reduction here if it isn't already on. Also, the loop
5006 unrolling code assumes that cse will be run after loop, so that must
5007 be turned on also. */
5008 if (flag_unroll_loops)
5010 flag_strength_reduce = 1;
5011 flag_rerun_cse_after_loop = 1;
5014 if (flag_non_call_exceptions)
5015 flag_asynchronous_unwind_tables = 1;
5016 if (flag_asynchronous_unwind_tables)
5017 flag_unwind_tables = 1;
5019 /* Warn about options that are not supported on this machine. */
5020 #ifndef INSN_SCHEDULING
5021 if (flag_schedule_insns || flag_schedule_insns_after_reload)
5022 warning ("instruction scheduling not supported on this target machine");
5023 #endif
5024 #ifndef DELAY_SLOTS
5025 if (flag_delayed_branch)
5026 warning ("this target machine does not have delayed branches");
5027 #endif
5029 user_label_prefix = USER_LABEL_PREFIX;
5030 if (flag_leading_underscore != -1)
5032 /* If the default prefix is more complicated than "" or "_",
5033 issue a warning and ignore this option. */
5034 if (user_label_prefix[0] == 0 ||
5035 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5037 user_label_prefix = flag_leading_underscore ? "_" : "";
5039 else
5040 warning ("-f%sleading-underscore not supported on this target machine",
5041 flag_leading_underscore ? "" : "no-");
5044 /* If we are in verbose mode, write out the version and maybe all the
5045 option flags in use. */
5046 if (version_flag)
5048 print_version (stderr, "");
5049 if (! quiet_flag)
5050 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5053 if (! quiet_flag)
5054 time_report = 1;
5056 if (flag_syntax_only)
5058 write_symbols = NO_DEBUG;
5059 profile_flag = 0;
5062 /* Now we know write_symbols, set up the debug hooks based on it.
5063 By default we do nothing for debug output. */
5064 #if defined(DBX_DEBUGGING_INFO)
5065 if (write_symbols == DBX_DEBUG)
5066 debug_hooks = &dbx_debug_hooks;
5067 #endif
5068 #if defined(XCOFF_DEBUGGING_INFO)
5069 if (write_symbols == XCOFF_DEBUG)
5070 debug_hooks = &xcoff_debug_hooks;
5071 #endif
5072 #ifdef SDB_DEBUGGING_INFO
5073 if (write_symbols == SDB_DEBUG)
5074 debug_hooks = &sdb_debug_hooks;
5075 #endif
5076 #ifdef DWARF_DEBUGGING_INFO
5077 if (write_symbols == DWARF_DEBUG)
5078 debug_hooks = &dwarf_debug_hooks;
5079 #endif
5080 #ifdef DWARF2_DEBUGGING_INFO
5081 if (write_symbols == DWARF2_DEBUG)
5082 debug_hooks = &dwarf2_debug_hooks;
5083 #endif
5084 #ifdef VMS_DEBUGGING_INFO
5085 if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
5086 debug_hooks = &vmsdbg_debug_hooks;
5087 #endif
5089 /* If auxiliary info generation is desired, open the output file.
5090 This goes in the same directory as the source file--unlike
5091 all the other output files. */
5092 if (flag_gen_aux_info)
5094 aux_info_file = fopen (aux_info_file_name, "w");
5095 if (aux_info_file == 0)
5096 fatal_io_error ("can't open %s", aux_info_file_name);
5099 if (! targetm.have_named_sections)
5101 if (flag_function_sections)
5103 warning ("-ffunction-sections not supported for this target");
5104 flag_function_sections = 0;
5106 if (flag_data_sections)
5108 warning ("-fdata-sections not supported for this target");
5109 flag_data_sections = 0;
5113 if (flag_function_sections && profile_flag)
5115 warning ("-ffunction-sections disabled; it makes profiling impossible");
5116 flag_function_sections = 0;
5119 #ifndef HAVE_prefetch
5120 if (flag_prefetch_loop_arrays)
5122 warning ("-fprefetch-loop-arrays not supported for this target");
5123 flag_prefetch_loop_arrays = 0;
5125 #else
5126 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
5128 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
5129 flag_prefetch_loop_arrays = 0;
5131 #endif
5133 /* This combination of options isn't handled for i386 targets and doesn't
5134 make much sense anyway, so don't allow it. */
5135 if (flag_prefetch_loop_arrays && optimize_size)
5137 warning ("-fprefetch-loop-arrays is not supported with -Os");
5138 flag_prefetch_loop_arrays = 0;
5141 #ifndef OBJECT_FORMAT_ELF
5142 if (flag_function_sections && write_symbols != NO_DEBUG)
5143 warning ("-ffunction-sections may affect debugging on some targets");
5144 #endif
5146 /* The presence of IEEE signaling NaNs, implies all math can trap. */
5147 if (flag_signaling_nans)
5148 flag_trapping_math = 1;
5151 /* Initialize the compiler back end. */
5152 static void
5153 backend_init ()
5155 /* init_emit_once uses reg_raw_mode and therefore must be called
5156 after init_regs which initialized reg_raw_mode. */
5157 init_regs ();
5158 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
5159 || debug_info_level == DINFO_LEVEL_VERBOSE
5160 #ifdef VMS_DEBUGGING_INFO
5161 /* Enable line number info for traceback */
5162 || debug_info_level > DINFO_LEVEL_NONE
5163 #endif
5164 || flag_test_coverage
5165 || warn_notreached);
5166 init_fake_stack_mems ();
5167 init_alias_once ();
5168 init_loop ();
5169 init_reload ();
5170 init_function_once ();
5171 init_varasm_once ();
5173 /* The following initialization functions need to generate rtl, so
5174 provide a dummy function context for them. */
5175 init_dummy_function_start ();
5176 init_expmed ();
5177 if (flag_caller_saves)
5178 init_caller_save ();
5179 expand_dummy_function_end ();
5182 /* Language-dependent initialization. Returns non-zero on success. */
5183 static int
5184 lang_dependent_init (name)
5185 const char *name;
5187 if (dump_base_name == 0)
5188 dump_base_name = name ? name : "gccdump";
5190 /* Front-end initialization. This hook can assume that GC,
5191 identifier hashes etc. are set up, but debug initialization is
5192 not done yet. This routine must return the original filename
5193 (e.g. foo.i -> foo.c) so can correctly initialize debug output. */
5194 name = (*lang_hooks.init) (name);
5195 if (name == NULL)
5196 return 0;
5198 /* Is this duplication necessary? */
5199 name = ggc_strdup (name);
5200 main_input_filename = input_filename = name;
5201 init_asm_output (name);
5203 /* These create various _DECL nodes, so need to be called after the
5204 front end is initialized. */
5205 init_eh ();
5206 init_optabs ();
5208 /* The following initialization functions need to generate rtl, so
5209 provide a dummy function context for them. */
5210 init_dummy_function_start ();
5211 init_expr_once ();
5212 expand_dummy_function_end ();
5214 /* Put an entry on the input file stack for the main input file. */
5215 push_srcloc (input_filename, 0);
5217 /* If dbx symbol table desired, initialize writing it and output the
5218 predefined types. */
5219 timevar_push (TV_SYMOUT);
5221 #ifdef DWARF2_UNWIND_INFO
5222 if (dwarf2out_do_frame ())
5223 dwarf2out_frame_init ();
5224 #endif
5226 /* Now we have the correct original filename, we can initialize
5227 debug output. */
5228 (*debug_hooks->init) (name);
5230 timevar_pop (TV_SYMOUT);
5232 return 1;
5235 /* Clean up: close opened files, etc. */
5237 static void
5238 finalize ()
5240 /* Close the dump files. */
5241 if (flag_gen_aux_info)
5243 fclose (aux_info_file);
5244 if (errorcount)
5245 unlink (aux_info_file_name);
5248 /* Close non-debugging input and output files. Take special care to note
5249 whether fclose returns an error, since the pages might still be on the
5250 buffer chain while the file is open. */
5252 if (asm_out_file)
5254 if (ferror (asm_out_file) != 0)
5255 fatal_io_error ("error writing to %s", asm_file_name);
5256 if (fclose (asm_out_file) != 0)
5257 fatal_io_error ("error closing %s", asm_file_name);
5260 /* Do whatever is necessary to finish printing the graphs. */
5261 if (graph_dump_format != no_graph)
5263 int i;
5265 for (i = 0; i < (int) DFI_MAX; ++i)
5266 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
5268 char seq[16];
5269 char *suffix;
5271 sprintf (seq, DUMPFILE_FORMAT, i);
5272 suffix = concat (seq, dump_file[i].extension, NULL);
5273 finish_graph_dump_file (dump_base_name, suffix);
5274 free (suffix);
5278 if (mem_report)
5280 ggc_print_statistics ();
5281 stringpool_statistics ();
5282 dump_tree_statistics ();
5285 /* Free up memory for the benefit of leak detectors. */
5286 free_reg_info ();
5288 /* Language-specific end of compilation actions. */
5289 (*lang_hooks.finish) ();
5292 /* Initialize the compiler, and compile the input file. */
5293 static void
5294 do_compile ()
5296 /* All command line options have been parsed; allow the front end to
5297 perform consistency checks, etc. */
5298 bool no_backend = (*lang_hooks.post_options) ();
5300 /* The bulk of command line switch processing. */
5301 process_options ();
5303 /* If an error has already occurred, give up. */
5304 if (errorcount)
5305 return;
5307 if (aux_base_name)
5308 /*NOP*/;
5309 else if (filename)
5311 char *name = xstrdup (lbasename (filename));
5313 aux_base_name = name;
5314 strip_off_ending (name, strlen (name));
5316 else
5317 aux_base_name = "gccaux";
5319 /* We cannot start timing until after options are processed since that
5320 says if we run timers or not. */
5321 init_timevar ();
5322 timevar_start (TV_TOTAL);
5324 /* Set up the back-end if requested. */
5325 if (!no_backend)
5326 backend_init ();
5328 /* Language-dependent initialization. Returns true on success. */
5329 if (lang_dependent_init (filename))
5330 compile_file ();
5332 finalize ();
5334 /* Stop timing and print the times. */
5335 timevar_stop (TV_TOTAL);
5336 timevar_print (stderr);
5339 /* Entry point of cc1, cc1plus, jc1, f771, etc.
5340 Decode command args, then call compile_file.
5341 Exit code is FATAL_EXIT_CODE if can't open files or if there were
5342 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
5344 It is not safe to call this function more than once. */
5347 toplev_main (argc, argv)
5348 int argc;
5349 char **argv;
5351 /* Initialization of GCC's environment, and diagnostics. */
5352 general_init (argv[0]);
5354 /* Parse the options and do minimal processing; basically just
5355 enough to default flags appropriately. */
5356 parse_options_and_default_flags (argc, argv);
5358 /* Exit early if we can (e.g. -help). */
5359 if (!exit_after_options)
5360 do_compile ();
5362 if (errorcount || sorrycount)
5363 return (FATAL_EXIT_CODE);
5365 return (SUCCESS_EXIT_CODE);