PR c++/3637
[official-gcc.git] / gcc / toplev.c
blob0876467825540fd93024d9a9e9f717bcff6dcd8d
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
22 /* This is the top level of cc1/c++.
23 It parses command args, opens files, invokes the various passes
24 in the proper order, and counts the time used by each.
25 Error messages and low-level interface to malloc also handled here. */
27 #include "config.h"
28 #undef FLOAT /* This is for hpux. They should change hpux. */
29 #undef FFS /* Some systems define this in param.h. */
30 #include "system.h"
31 #include <signal.h>
32 #include <setjmp.h>
34 #ifdef HAVE_SYS_RESOURCE_H
35 # include <sys/resource.h>
36 #endif
38 #ifdef HAVE_SYS_TIMES_H
39 # include <sys/times.h>
40 #endif
42 #include "input.h"
43 #include "tree.h"
44 #include "rtl.h"
45 #include "tm_p.h"
46 #include "flags.h"
47 #include "insn-attr.h"
48 #include "insn-config.h"
49 #include "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"
73 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
74 #include "dwarf2out.h"
75 #endif
77 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
78 #include "dbxout.h"
79 #endif
81 #ifdef SDB_DEBUGGING_INFO
82 #include "sdbout.h"
83 #endif
85 #ifdef XCOFF_DEBUGGING_INFO
86 #include "xcoffout.h" /* Needed for external data
87 declarations for e.g. AIX 4.x. */
88 #endif
90 #ifdef HALF_PIC_DEBUG
91 #include "halfpic.h"
92 #endif
94 #ifdef VMS
95 /* The extra parameters substantially improve the I/O performance. */
97 static FILE *
98 vms_fopen (fname, type)
99 char *fname;
100 char *type;
102 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
103 fixed arguments, which matches ANSI's specification but not VAXCRTL's
104 pre-ANSI implementation. This hack circumvents the mismatch problem. */
105 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
107 if (*type == 'w')
108 return (*vmslib_fopen) (fname, type, "mbc=32",
109 "deq=64", "fop=tef", "shr=nil");
110 else
111 return (*vmslib_fopen) (fname, type, "mbc=32");
114 #define fopen vms_fopen
115 #endif /* VMS */
117 #ifndef DEFAULT_GDB_EXTENSIONS
118 #define DEFAULT_GDB_EXTENSIONS 1
119 #endif
121 /* If more than one debugging type is supported, you must define
122 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
124 This is one long line cause VAXC can't handle a \-newline. */
125 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
126 #ifndef PREFERRED_DEBUGGING_TYPE
127 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
128 #endif /* no PREFERRED_DEBUGGING_TYPE */
129 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
130 so the following code needn't care. */
131 #ifdef DBX_DEBUGGING_INFO
132 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
133 #endif
134 #ifdef SDB_DEBUGGING_INFO
135 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
136 #endif
137 #ifdef DWARF_DEBUGGING_INFO
138 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
139 #endif
140 #ifdef DWARF2_DEBUGGING_INFO
141 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
142 #endif
143 #ifdef XCOFF_DEBUGGING_INFO
144 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
145 #endif
146 #endif /* More than one debugger format enabled. */
148 /* If still not defined, must have been because no debugging formats
149 are supported. */
150 #ifndef PREFERRED_DEBUGGING_TYPE
151 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
152 #endif
154 #if defined (HAVE_DECL_ENVIRON) && !HAVE_DECL_ENVIRON
155 extern char **environ;
156 #endif
158 /* Carry information from ASM_DECLARE_OBJECT_NAME
159 to ASM_FINISH_DECLARE_OBJECT. */
161 extern int size_directive_output;
162 extern tree last_assemble_variable_decl;
164 static void general_init PARAMS ((char *));
165 static void parse_options_and_default_flags PARAMS ((int, char **));
166 static void process_options PARAMS ((void));
167 static void lang_independent_init PARAMS ((void));
168 static int lang_dependent_init PARAMS ((const char *));
169 static void init_asm_output PARAMS ((const char *));
170 static void finalize PARAMS ((void));
172 static void set_target_switch PARAMS ((const char *));
173 static const char *decl_name PARAMS ((tree, int));
175 static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
176 static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
177 static void set_float_handler PARAMS ((jmp_buf));
178 static void compile_file PARAMS ((void));
179 static void display_help PARAMS ((void));
180 static void display_target_options PARAMS ((void));
182 static void decode_d_option PARAMS ((const char *));
183 static int decode_f_option PARAMS ((const char *));
184 static int decode_W_option PARAMS ((const char *));
185 static int decode_g_option PARAMS ((const char *));
186 static unsigned int independent_decode_option PARAMS ((int, char **));
188 static void print_version PARAMS ((FILE *, const char *));
189 static int print_single_switch PARAMS ((FILE *, int, int, const char *,
190 const char *, const char *,
191 const char *, const char *));
192 static void print_switch_values PARAMS ((FILE *, int, int, const char *,
193 const char *, const char *));
195 /* Length of line when printing switch values. */
196 #define MAX_LINE 75
198 /* Name of program invoked, sans directories. */
200 const char *progname;
202 /* Copy of arguments to toplev_main. */
203 int save_argc;
204 char **save_argv;
206 /* Name of current original source file (what was input to cpp).
207 This comes from each #-command in the actual input. */
209 const char *input_filename;
211 /* Name of top-level original source file (what was input to cpp).
212 This comes from the #-command at the beginning of the actual input.
213 If there isn't any there, then this is the cc1 input file name. */
215 const char *main_input_filename;
217 /* Current line number in real source file. */
219 int lineno;
221 /* Nonzero if it is unsafe to create any new pseudo registers. */
222 int no_new_pseudos;
224 /* Stack of currently pending input files. */
226 struct file_stack *input_file_stack;
228 /* Incremented on each change to input_file_stack. */
229 int input_file_stack_tick;
231 /* Name to use as base of names for dump output files. */
233 const char *dump_base_name;
235 /* Format to use to print dumpfile index value */
236 #ifndef DUMPFILE_FORMAT
237 #define DUMPFILE_FORMAT ".%02d."
238 #endif
240 /* Bit flags that specify the machine subtype we are compiling for.
241 Bits are tested using macros TARGET_... defined in the tm.h file
242 and set by `-m...' switches. Must be defined in rtlanal.c. */
244 extern int target_flags;
246 /* Debug hooks - dependent upon command line options. */
248 struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks;
250 /* Describes a dump file. */
252 struct dump_file_info
254 /* The unique extension to apply, e.g. ".jump". */
255 const char *const extension;
257 /* The -d<c> character that enables this dump file. */
258 char const debug_switch;
260 /* True if there is a corresponding graph dump file. */
261 char const graph_dump_p;
263 /* True if the user selected this dump. */
264 char enabled;
266 /* True if the files have been initialized (ie truncated). */
267 char initialized;
270 /* Enumerate the extant dump files. */
272 enum dump_file_index
274 DFI_rtl,
275 DFI_sibling,
276 DFI_eh,
277 DFI_jump,
278 DFI_ssa,
279 DFI_ssa_ccp,
280 DFI_ssa_dce,
281 DFI_ussa,
282 DFI_cse,
283 DFI_addressof,
284 DFI_gcse,
285 DFI_loop,
286 DFI_cse2,
287 DFI_cfg,
288 DFI_bp,
289 DFI_life,
290 DFI_combine,
291 DFI_ce,
292 DFI_regmove,
293 DFI_sched,
294 DFI_lreg,
295 DFI_greg,
296 DFI_postreload,
297 DFI_flow2,
298 DFI_peephole2,
299 DFI_rnreg,
300 DFI_ce2,
301 DFI_sched2,
302 DFI_stack,
303 DFI_bbro,
304 DFI_mach,
305 DFI_dbr,
306 DFI_MAX
309 /* Describes all the dump files. Should be kept in order of the
310 pass and in sync with dump_file_index above.
312 Remaining -d letters:
314 " o q u "
315 " H JK OPQ TUV YZ"
318 struct dump_file_info dump_file[DFI_MAX] =
320 { "rtl", 'r', 0, 0, 0 },
321 { "sibling", 'i', 0, 0, 0 },
322 { "eh", 'h', 0, 0, 0 },
323 { "jump", 'j', 0, 0, 0 },
324 { "ssa", 'e', 1, 0, 0 },
325 { "ssaccp", 'W', 1, 0, 0 },
326 { "ssadce", 'X', 1, 0, 0 },
327 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
328 { "cse", 's', 0, 0, 0 },
329 { "addressof", 'F', 0, 0, 0 },
330 { "gcse", 'G', 1, 0, 0 },
331 { "loop", 'L', 1, 0, 0 },
332 { "cse2", 't', 1, 0, 0 },
333 { "cfg", 'f', 1, 0, 0 },
334 { "bp", 'b', 1, 0, 0 },
335 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
336 { "combine", 'c', 1, 0, 0 },
337 { "ce", 'C', 1, 0, 0 },
338 { "regmove", 'N', 1, 0, 0 },
339 { "sched", 'S', 1, 0, 0 },
340 { "lreg", 'l', 1, 0, 0 },
341 { "greg", 'g', 1, 0, 0 },
342 { "postreload", 'o', 1, 0, 0 },
343 { "flow2", 'w', 1, 0, 0 },
344 { "peephole2", 'z', 1, 0, 0 },
345 { "rnreg", 'n', 1, 0, 0 },
346 { "ce2", 'E', 1, 0, 0 },
347 { "sched2", 'R', 1, 0, 0 },
348 { "stack", 'k', 1, 0, 0 },
349 { "bbro", 'B', 1, 0, 0 },
350 { "mach", 'M', 1, 0, 0 },
351 { "dbr", 'd', 0, 0, 0 },
354 static int open_dump_file PARAMS ((enum dump_file_index, tree));
355 static void close_dump_file PARAMS ((enum dump_file_index,
356 void (*) (FILE *, rtx), rtx));
358 /* Other flags saying which kinds of debugging dump have been requested. */
360 int rtl_dump_and_exit;
361 int flag_print_asm_name;
362 static int version_flag;
363 static char *filename;
364 enum graph_dump_types graph_dump_format;
366 /* Name for output file of assembly code, specified with -o. */
368 char *asm_file_name;
370 /* Value of the -G xx switch, and whether it was passed or not. */
371 int g_switch_value;
372 int g_switch_set;
374 /* Type(s) of debugging information we are producing (if any).
375 See flags.h for the definitions of the different possible
376 types of debugging information. */
377 enum debug_info_type write_symbols = NO_DEBUG;
379 /* Level of debugging information we are producing. See flags.h
380 for the definitions of the different possible levels. */
381 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
383 /* Nonzero means use GNU-only extensions in the generated symbolic
384 debugging information. */
385 /* Currently, this only has an effect when write_symbols is set to
386 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
387 int use_gnu_debug_info_extensions = 0;
389 /* Nonzero means do optimizations. -O.
390 Particular numeric values stand for particular amounts of optimization;
391 thus, -O2 stores 2 here. However, the optimizations beyond the basic
392 ones are not controlled directly by this variable. Instead, they are
393 controlled by individual `flag_...' variables that are defaulted
394 based on this variable. */
396 int optimize = 0;
398 /* Nonzero means optimize for size. -Os.
399 The only valid values are zero and non-zero. When optimize_size is
400 non-zero, optimize defaults to 2, but certain individual code
401 bloating optimizations are disabled. */
403 int optimize_size = 0;
405 /* Nonzero if we should exit after parsing options. */
406 static int exit_after_options = 0;
408 /* The FUNCTION_DECL for the function currently being compiled,
409 or 0 if between functions. */
410 tree current_function_decl;
412 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
413 if none. */
414 tree current_function_func_begin_label;
416 /* Pointer to function to compute the name to use to print a declaration.
417 DECL is the declaration in question.
418 VERBOSITY determines what information will be printed:
419 0: DECL_NAME, demangled as necessary.
420 1: and scope information.
421 2: and any other information that might be interesting, such as function
422 parameter types in C++. */
424 const char *(*decl_printable_name) PARAMS ((tree, int));
426 /* Pointer to function to compute rtl for a language-specific tree code. */
428 typedef rtx (*lang_expand_expr_t)
429 PARAMS ((union tree_node *, rtx, enum machine_mode,
430 enum expand_modifier modifier));
432 lang_expand_expr_t lang_expand_expr = 0;
434 tree (*lang_expand_constant) PARAMS ((tree)) = 0;
436 /* Pointer to function to finish handling an incomplete decl at the
437 end of compilation. */
439 void (*incomplete_decl_finalize_hook) PARAMS ((tree)) = 0;
441 /* Nonzero if doing dwarf2 duplicate elimination. */
443 int flag_eliminate_dwarf2_dups = 0;
445 /* Nonzero if generating code to do profiling. */
447 int profile_flag = 0;
449 /* Nonzero if generating code to do profiling on a line-by-line basis. */
451 int profile_block_flag;
453 /* Nonzero if generating code to profile program flow graph arcs. */
455 int profile_arc_flag = 0;
457 /* Nonzero if generating info for gcov to calculate line test coverage. */
459 int flag_test_coverage = 0;
461 /* Nonzero indicates that branch taken probabilities should be calculated. */
463 int flag_branch_probabilities = 0;
465 /* Nonzero if basic blocks should be reordered. */
467 int flag_reorder_blocks = 0;
469 /* Nonzero if registers should be renamed. */
471 int flag_rename_registers = 0;
473 /* Nonzero for -pedantic switch: warn about anything
474 that standard spec forbids. */
476 int pedantic = 0;
478 /* Temporarily suppress certain warnings.
479 This is set while reading code from a system header file. */
481 int in_system_header = 0;
483 /* Don't print functions as they are compiled. -quiet. */
485 int quiet_flag = 0;
487 /* Print times taken by the various passes. -ftime-report. */
489 int time_report = 0;
491 /* Print memory still in use at end of compilation (which may have little
492 to do with peak memory consumption). -fmem-report. */
494 int mem_report = 0;
496 /* Non-zero means to collect statistics which might be expensive
497 and to print them when we are done. */
498 int flag_detailed_statistics = 0;
501 /* -f flags. */
503 /* Nonzero means `char' should be signed. */
505 int flag_signed_char;
507 /* Nonzero means give an enum type only as many bytes as it needs. */
509 int flag_short_enums;
511 /* Nonzero for -fcaller-saves: allocate values in regs that need to
512 be saved across function calls, if that produces overall better code.
513 Optional now, so people can test it. */
515 #ifdef DEFAULT_CALLER_SAVES
516 int flag_caller_saves = 1;
517 #else
518 int flag_caller_saves = 0;
519 #endif
521 /* Nonzero if structures and unions should be returned in memory.
523 This should only be defined if compatibility with another compiler or
524 with an ABI is needed, because it results in slower code. */
526 #ifndef DEFAULT_PCC_STRUCT_RETURN
527 #define DEFAULT_PCC_STRUCT_RETURN 1
528 #endif
530 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
532 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
534 /* Nonzero for -fforce-mem: load memory value into a register
535 before arithmetic on it. This makes better cse but slower compilation. */
537 int flag_force_mem = 0;
539 /* Nonzero for -fforce-addr: load memory address into a register before
540 reference to memory. This makes better cse but slower compilation. */
542 int flag_force_addr = 0;
544 /* Nonzero for -fdefer-pop: don't pop args after each function call;
545 instead save them up to pop many calls' args with one insns. */
547 int flag_defer_pop = 0;
549 /* Nonzero for -ffloat-store: don't allocate floats and doubles
550 in extended-precision registers. */
552 int flag_float_store = 0;
554 /* Nonzero for -fcse-follow-jumps:
555 have cse follow jumps to do a more extensive job. */
557 int flag_cse_follow_jumps;
559 /* Nonzero for -fcse-skip-blocks:
560 have cse follow a branch around a block. */
561 int flag_cse_skip_blocks;
563 /* Nonzero for -fexpensive-optimizations:
564 perform miscellaneous relatively-expensive optimizations. */
565 int flag_expensive_optimizations;
567 /* Nonzero for -fthread-jumps:
568 have jump optimize output of loop. */
570 int flag_thread_jumps;
572 /* Nonzero enables strength-reduction in loop.c. */
574 int flag_strength_reduce = 0;
576 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
577 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
578 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
579 unrolled. */
581 int flag_unroll_loops;
583 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
584 This is generally not a win. */
586 int flag_unroll_all_loops;
588 /* Nonzero forces all invariant computations in loops to be moved
589 outside the loop. */
591 int flag_move_all_movables = 0;
593 /* Nonzero forces all general induction variables in loops to be
594 strength reduced. */
596 int flag_reduce_all_givs = 0;
598 /* Nonzero to perform full register move optimization passes. This is the
599 default for -O2. */
601 int flag_regmove = 0;
603 /* Nonzero for -fwritable-strings:
604 store string constants in data segment and don't uniquize them. */
606 int flag_writable_strings = 0;
608 /* Nonzero means don't put addresses of constant functions in registers.
609 Used for compiling the Unix kernel, where strange substitutions are
610 done on the assembly output. */
612 int flag_no_function_cse = 0;
614 /* Nonzero for -fomit-frame-pointer:
615 don't make a frame pointer in simple functions that don't require one. */
617 int flag_omit_frame_pointer = 0;
619 /* Nonzero means place each function into its own section on those platforms
620 which support arbitrary section names and unlimited numbers of sections. */
622 int flag_function_sections = 0;
624 /* ... and similar for data. */
626 int flag_data_sections = 0;
628 /* Nonzero to inhibit use of define_optimization peephole opts. */
630 int flag_no_peephole = 0;
632 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
634 int flag_optimize_sibling_calls = 0;
636 /* Nonzero means the front end generally wants `errno' maintained by math
637 operations, like built-in SQRT. */
639 int flag_errno_math = 1;
641 /* Nonzero means that unsafe floating-point math optimizations are allowed
642 for the sake of speed. IEEE compliance is not guaranteed, and operations
643 are allowed to assume that their arguments and results are "normal"
644 (e.g., nonnegative for SQRT). */
646 int flag_unsafe_math_optimizations = 0;
648 /* Zero means that floating-point math operations cannot generate a
649 (user-visible) trap. This is the case, for example, in nonstop
650 IEEE 754 arithmetic. */
652 int flag_trapping_math = 1;
654 /* 0 means straightforward implementation of complex divide acceptable.
655 1 means wide ranges of inputs must work for complex divide.
656 2 means C99-like requirements for complex divide (not yet implemented). */
658 int flag_complex_divide_method = 0;
660 /* Nonzero means all references through pointers are volatile. */
662 int flag_volatile;
664 /* Nonzero means treat all global and extern variables as volatile. */
666 int flag_volatile_global;
668 /* Nonzero means treat all static variables as volatile. */
670 int flag_volatile_static;
672 /* Nonzero means just do syntax checking; don't output anything. */
674 int flag_syntax_only = 0;
676 /* Nonzero means perform global cse. */
678 static int flag_gcse;
680 /* Nonzero means to use global dataflow analysis to eliminate
681 useless null pointer tests. */
683 static int flag_delete_null_pointer_checks;
685 /* Nonzero means to do the enhanced load motion during gcse, which trys
686 to hoist loads by not killing them when a store to the same location
687 is seen. */
689 int flag_gcse_lm = 1;
691 /* Nonzero means to perform store motion after gcse, which will try to
692 move stores closer to the exit block. Its not very effective without
693 flag_gcse_lm. */
695 int flag_gcse_sm = 1;
697 /* Nonzero means to rerun cse after loop optimization. This increases
698 compilation time about 20% and picks up a few more common expressions. */
700 static int flag_rerun_cse_after_loop;
702 /* Nonzero means to run loop optimizations twice. */
704 int flag_rerun_loop_opt;
706 /* Nonzero for -finline-functions: ok to inline functions that look like
707 good inline candidates. */
709 int flag_inline_functions;
711 /* Nonzero for -fkeep-inline-functions: even if we make a function
712 go inline everywhere, keep its definition around for debugging
713 purposes. */
715 int flag_keep_inline_functions;
717 /* Nonzero means that functions will not be inlined. */
719 int flag_no_inline;
721 /* Nonzero means that we should emit static const variables
722 regardless of whether or not optimization is turned on. */
724 int flag_keep_static_consts = 1;
726 /* Nonzero means we should be saving declaration info into a .X file. */
728 int flag_gen_aux_info = 0;
730 /* Specified name of aux-info file. */
732 static char *aux_info_file_name;
734 /* Nonzero means make the text shared if supported. */
736 int flag_shared_data;
738 /* Nonzero means schedule into delayed branch slots if supported. */
740 int flag_delayed_branch;
742 /* Nonzero if we are compiling pure (sharable) code.
743 Value is 1 if we are doing reasonable (i.e. simple
744 offset into offset table) pic. Value is 2 if we can
745 only perform register offsets. */
747 int flag_pic;
749 /* Nonzero means generate extra code for exception handling and enable
750 exception handling. */
752 int flag_exceptions;
754 /* Nonzero means generate frame unwind info table when supported. */
756 int flag_unwind_tables = 0;
758 /* Nonzero means generate frame unwind info table exact at each insn boundary */
760 int flag_asynchronous_unwind_tables = 0;
762 /* Nonzero means don't place uninitialized global data in common storage
763 by default. */
765 int flag_no_common;
767 /* Nonzero means pretend it is OK to examine bits of target floats,
768 even if that isn't true. The resulting code will have incorrect constants,
769 but the same series of instructions that the native compiler would make. */
771 int flag_pretend_float;
773 /* Nonzero means change certain warnings into errors.
774 Usually these are warnings about failure to conform to some standard. */
776 int flag_pedantic_errors = 0;
778 /* flag_schedule_insns means schedule insns within basic blocks (before
779 local_alloc).
780 flag_schedule_insns_after_reload means schedule insns after
781 global_alloc. */
783 int flag_schedule_insns = 0;
784 int flag_schedule_insns_after_reload = 0;
786 /* The following flags have effect only for scheduling before register
787 allocation:
789 flag_schedule_interblock means schedule insns accross basic blocks.
790 flag_schedule_speculative means allow speculative motion of non-load insns.
791 flag_schedule_speculative_load means allow speculative motion of some
792 load insns.
793 flag_schedule_speculative_load_dangerous allows speculative motion of more
794 load insns. */
796 int flag_schedule_interblock = 1;
797 int flag_schedule_speculative = 1;
798 int flag_schedule_speculative_load = 0;
799 int flag_schedule_speculative_load_dangerous = 0;
801 int flag_single_precision_constant;
803 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
804 by a cheaper branch on a count register. */
805 int flag_branch_on_count_reg = 1;
807 /* -finhibit-size-directive inhibits output of .size for ELF.
808 This is used only for compiling crtstuff.c,
809 and it may be extended to other effects
810 needed for crtstuff.c on other systems. */
811 int flag_inhibit_size_directive = 0;
813 /* -fverbose-asm causes extra commentary information to be produced in
814 the generated assembly code (to make it more readable). This option
815 is generally only of use to those who actually need to read the
816 generated assembly code (perhaps while debugging the compiler itself).
817 -fno-verbose-asm, the default, causes the extra information
818 to be omitted and is useful when comparing two assembler files. */
820 int flag_verbose_asm = 0;
822 /* -dA causes debug commentary information to be produced in
823 the generated assembly code (to make it more readable). This option
824 is generally only of use to those who actually need to read the
825 generated assembly code (perhaps while debugging the compiler itself).
826 Currently, this switch is only used by dwarfout.c; however, it is intended
827 to be a catchall for printing debug information in the assembler file. */
829 int flag_debug_asm = 0;
831 /* -dP causes the rtl to be emitted as a comment in assembly. */
833 int flag_dump_rtl_in_asm = 0;
835 /* -fgnu-linker specifies use of the GNU linker for initializations.
836 (Or, more generally, a linker that handles initializations.)
837 -fno-gnu-linker says that collect2 will be used. */
838 #ifdef USE_COLLECT2
839 int flag_gnu_linker = 0;
840 #else
841 int flag_gnu_linker = 1;
842 #endif
844 /* Enable SSA. */
845 int flag_ssa = 0;
847 /* Enable ssa conditional constant propagation. */
848 int flag_ssa_ccp = 0;
850 /* Enable ssa aggressive dead code elimination. */
851 int flag_ssa_dce = 0;
853 /* Tag all structures with __attribute__(packed). */
854 int flag_pack_struct = 0;
856 /* Emit code to check for stack overflow; also may cause large objects
857 to be allocated dynamically. */
858 int flag_stack_check;
860 /* When non-NULL, indicates that whenever space is allocated on the
861 stack, the resulting stack pointer must not pass this
862 address---that is, for stacks that grow downward, the stack pointer
863 must always be greater than or equal to this address; for stacks
864 that grow upward, the stack pointer must be less than this address.
865 At present, the rtx may be either a REG or a SYMBOL_REF, although
866 the support provided depends on the backend. */
867 rtx stack_limit_rtx;
869 /* -fcheck-memory-usage causes extra code to be generated in order to check
870 memory accesses. This is used by a detector of bad memory accesses such
871 as Checker. */
872 int flag_check_memory_usage = 0;
874 /* -fprefix-function-name causes function name to be prefixed. This
875 can be used with -fcheck-memory-usage to isolate code compiled with
876 -fcheck-memory-usage. */
877 int flag_prefix_function_name = 0;
879 /* 0 if pointer arguments may alias each other. True in C.
880 1 if pointer arguments may not alias each other but may alias
881 global variables.
882 2 if pointer arguments may not alias each other and may not
883 alias global variables. True in Fortran.
884 This defaults to 0 for C. */
885 int flag_argument_noalias = 0;
887 /* Nonzero if we should do (language-dependent) alias analysis.
888 Typically, this analysis will assume that expressions of certain
889 types do not alias expressions of certain other types. Only used
890 if alias analysis (in general) is enabled. */
891 int flag_strict_aliasing = 0;
893 /* Instrument functions with calls at entry and exit, for profiling. */
894 int flag_instrument_function_entry_exit = 0;
896 /* Nonzero means ignore `#ident' directives. 0 means handle them.
897 On SVR4 targets, it also controls whether or not to emit a
898 string identifying the compiler. */
900 int flag_no_ident = 0;
902 /* This will perform a peephole pass before sched2. */
903 int flag_peephole2 = 0;
905 /* This will try to guess branch probabilities. */
906 int flag_guess_branch_prob = 0;
908 /* -fbounded-pointers causes gcc to compile pointers as composite
909 objects occupying three words: the pointer value, the base address
910 of the referent object, and the address immediately beyond the end
911 of the referent object. The base and extent allow us to perform
912 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
913 int flag_bounded_pointers = 0;
915 /* -fcheck-bounds causes gcc to generate array bounds checks.
916 For C, C++: defaults to value of flag_bounded_pointers.
917 For ObjC: defaults to off.
918 For Java: defaults to on.
919 For Fortran: defaults to off.
920 For CHILL: defaults to off. */
921 int flag_bounds_check = 0;
923 /* This will attempt to merge constant section constants, if 1 only
924 string constants and constants from constant pool, if 2 also constant
925 variables. */
926 int flag_merge_constants = 1;
928 /* If one, renumber instruction UIDs to reduce the number of
929 unused UIDs if there are a lot of instructions. If greater than
930 one, unconditionally renumber instruction UIDs. */
931 int flag_renumber_insns = 1;
933 /* Values of the -falign-* flags: how much to align labels in code.
934 0 means `use default', 1 means `don't align'.
935 For each variable, there is an _log variant which is the power
936 of two not less than the variable, for .align output. */
938 int align_loops;
939 int align_loops_log;
940 int align_loops_max_skip;
941 int align_jumps;
942 int align_jumps_log;
943 int align_jumps_max_skip;
944 int align_labels;
945 int align_labels_log;
946 int align_labels_max_skip;
947 int align_functions;
948 int align_functions_log;
950 /* Table of supported debugging formats. */
951 static const struct
953 const char *const arg;
954 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
955 constant expression, we use NO_DEBUG in its place. */
956 const enum debug_info_type debug_type;
957 const int use_extensions_p;
958 const char *const description;
959 } *da,
960 debug_args[] =
962 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
963 N_("Generate debugging info in default format") },
964 { "gdb", NO_DEBUG, 1, N_("Generate debugging info in default extended format") },
965 #ifdef DBX_DEBUGGING_INFO
966 { "stabs", DBX_DEBUG, 0, N_("Generate STABS format debug info") },
967 { "stabs+", DBX_DEBUG, 1, N_("Generate extended STABS format debug info") },
968 #endif
969 #ifdef DWARF_DEBUGGING_INFO
970 { "dwarf", DWARF_DEBUG, 0, N_("Generate DWARF-1 format debug info") },
971 { "dwarf+", DWARF_DEBUG, 1,
972 N_("Generate extended DWARF-1 format debug info") },
973 #endif
974 #ifdef DWARF2_DEBUGGING_INFO
975 { "dwarf-2", DWARF2_DEBUG, 0, N_("Generate DWARF-2 debug info") },
976 #endif
977 #ifdef XCOFF_DEBUGGING_INFO
978 { "xcoff", XCOFF_DEBUG, 0, N_("Generate XCOFF format debug info") },
979 { "xcoff+", XCOFF_DEBUG, 1, N_("Generate extended XCOFF format debug info") },
980 #endif
981 #ifdef SDB_DEBUGGING_INFO
982 { "coff", SDB_DEBUG, 0, N_("Generate COFF format debug info") },
983 #endif
984 { 0, 0, 0, 0 }
987 typedef struct
989 const char *string;
990 int *variable;
991 int on_value;
992 const char *description;
994 lang_independent_options;
996 int flag_trapv = 0;
998 /* Add or remove a leading underscore from user symbols. */
999 int flag_leading_underscore = -1;
1001 /* The user symbol prefix after having resolved same. */
1002 const char *user_label_prefix;
1004 static const param_info lang_independent_params[] = {
1005 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
1006 { OPTION, DEFAULT, HELP },
1007 #include "params.def"
1008 #undef DEFPARAM
1009 { NULL, 0, NULL }
1012 /* A default for same. */
1013 #ifndef USER_LABEL_PREFIX
1014 #define USER_LABEL_PREFIX ""
1015 #endif
1017 /* Table of language-independent -f options.
1018 STRING is the option name. VARIABLE is the address of the variable.
1019 ON_VALUE is the value to store in VARIABLE
1020 if `-fSTRING' is seen as an option.
1021 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
1023 lang_independent_options f_options[] =
1025 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
1026 N_("Perform DWARF2 duplicate elimination") },
1027 {"float-store", &flag_float_store, 1,
1028 N_("Do not store floats in registers") },
1029 {"volatile", &flag_volatile, 1,
1030 N_("Consider all mem refs through pointers as volatile") },
1031 {"volatile-global", &flag_volatile_global, 1,
1032 N_("Consider all mem refs to global data to be volatile") },
1033 {"volatile-static", &flag_volatile_static, 1,
1034 N_("Consider all mem refs to static data to be volatile") },
1035 {"defer-pop", &flag_defer_pop, 1,
1036 N_("Defer popping functions args from stack until later") },
1037 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
1038 N_("When possible do not generate stack frames") },
1039 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
1040 N_("Optimize sibling and tail recursive calls") },
1041 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
1042 N_("When running CSE, follow jumps to their targets") },
1043 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
1044 N_("When running CSE, follow conditional jumps") },
1045 {"expensive-optimizations", &flag_expensive_optimizations, 1,
1046 N_("Perform a number of minor, expensive optimisations") },
1047 {"thread-jumps", &flag_thread_jumps, 1,
1048 N_("Perform jump threading optimisations") },
1049 {"strength-reduce", &flag_strength_reduce, 1,
1050 N_("Perform strength reduction optimisations") },
1051 {"unroll-loops", &flag_unroll_loops, 1,
1052 N_("Perform loop unrolling when iteration count is known") },
1053 {"unroll-all-loops", &flag_unroll_all_loops, 1,
1054 N_("Perform loop unrolling for all loops") },
1055 {"move-all-movables", &flag_move_all_movables, 1,
1056 N_("Force all loop invariant computations out of loops") },
1057 {"reduce-all-givs", &flag_reduce_all_givs, 1,
1058 N_("Strength reduce all loop general induction variables") },
1059 {"writable-strings", &flag_writable_strings, 1,
1060 N_("Store strings in writable data section") },
1061 {"peephole", &flag_no_peephole, 0,
1062 N_("Enable machine specific peephole optimisations") },
1063 {"force-mem", &flag_force_mem, 1,
1064 N_("Copy memory operands into registers before using") },
1065 {"force-addr", &flag_force_addr, 1,
1066 N_("Copy memory address constants into regs before using") },
1067 {"function-cse", &flag_no_function_cse, 0,
1068 N_("Allow function addresses to be held in registers") },
1069 {"inline-functions", &flag_inline_functions, 1,
1070 N_("Integrate simple functions into their callers") },
1071 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1072 N_("Generate code for funcs even if they are fully inlined") },
1073 {"inline", &flag_no_inline, 0,
1074 N_("Pay attention to the 'inline' keyword") },
1075 {"keep-static-consts", &flag_keep_static_consts, 1,
1076 N_("Emit static const variables even if they are not used") },
1077 {"syntax-only", &flag_syntax_only, 1,
1078 N_("Check for syntax errors, then stop") },
1079 {"shared-data", &flag_shared_data, 1,
1080 N_("Mark data as shared rather than private") },
1081 {"caller-saves", &flag_caller_saves, 1,
1082 N_("Enable saving registers around function calls") },
1083 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1084 N_("Return 'short' aggregates in memory, not registers") },
1085 {"reg-struct-return", &flag_pcc_struct_return, 0,
1086 N_("Return 'short' aggregates in registers") },
1087 {"delayed-branch", &flag_delayed_branch, 1,
1088 N_("Attempt to fill delay slots of branch instructions") },
1089 {"gcse", &flag_gcse, 1,
1090 N_("Perform the global common subexpression elimination") },
1091 {"gcse-lm", &flag_gcse_lm, 1,
1092 N_("Perform enhanced load motion during global subexpression elimination") },
1093 {"gcse-sm", &flag_gcse_sm, 1,
1094 N_("Perform store motion after global subexpression elimination") },
1095 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1096 N_("Run CSE pass after loop optimisations") },
1097 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1098 N_("Run the loop optimiser twice") },
1099 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1100 N_("Delete useless null pointer checks") },
1101 {"pretend-float", &flag_pretend_float, 1,
1102 N_("Pretend that host and target use the same FP format") },
1103 {"schedule-insns", &flag_schedule_insns, 1,
1104 N_("Reschedule instructions before register allocation") },
1105 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1106 N_("Reschedule instructions after register allocation") },
1107 {"sched-interblock",&flag_schedule_interblock, 1,
1108 N_("Enable scheduling across basic blocks") },
1109 {"sched-spec",&flag_schedule_speculative, 1,
1110 N_("Allow speculative motion of non-loads") },
1111 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1112 N_("Allow speculative motion of some loads") },
1113 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1114 N_("Allow speculative motion of more loads") },
1115 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1116 N_("Replace add,compare,branch with branch on count reg") },
1117 {"pic", &flag_pic, 1,
1118 N_("Generate position independent code, if possible") },
1119 {"PIC", &flag_pic, 2, ""},
1120 {"exceptions", &flag_exceptions, 1,
1121 N_("Enable exception handling") },
1122 {"unwind-tables", &flag_unwind_tables, 1,
1123 N_("Just generate unwind tables for exception handling") },
1124 {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1,
1125 N_("Generate unwind tables exact at each instruction boundary") },
1126 {"non-call-exceptions", &flag_non_call_exceptions, 1,
1127 N_("Support synchronous non-call exceptions") },
1128 {"profile-arcs", &profile_arc_flag, 1,
1129 N_("Insert arc based program profiling code") },
1130 {"test-coverage", &flag_test_coverage, 1,
1131 N_("Create data files needed by gcov") },
1132 {"branch-probabilities", &flag_branch_probabilities, 1,
1133 N_("Use profiling information for branch probabilities") },
1134 {"reorder-blocks", &flag_reorder_blocks, 1,
1135 N_("Reorder basic blocks to improve code placement") },
1136 {"rename-registers", &flag_rename_registers, 1,
1137 N_("Do the register renaming optimization pass") },
1138 {"common", &flag_no_common, 0,
1139 N_("Do not put uninitialized globals in the common section") },
1140 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1141 N_("Do not generate .size directives") },
1142 {"function-sections", &flag_function_sections, 1,
1143 N_("place each function into its own section") },
1144 {"data-sections", &flag_data_sections, 1,
1145 N_("place data items into their own section") },
1146 {"verbose-asm", &flag_verbose_asm, 1,
1147 N_("Add extra commentry to assembler output") },
1148 {"gnu-linker", &flag_gnu_linker, 1,
1149 N_("Output GNU ld formatted global initialisers") },
1150 {"regmove", &flag_regmove, 1,
1151 N_("Enables a register move optimisation") },
1152 {"optimize-register-move", &flag_regmove, 1,
1153 N_("Do the full regmove optimization pass") },
1154 {"pack-struct", &flag_pack_struct, 1,
1155 N_("Pack structure members together without holes") },
1156 {"stack-check", &flag_stack_check, 1,
1157 N_("Insert stack checking code into the program") },
1158 {"argument-alias", &flag_argument_noalias, 0,
1159 N_("Specify that arguments may alias each other & globals") },
1160 {"argument-noalias", &flag_argument_noalias, 1,
1161 N_("Assume arguments may alias globals but not each other") },
1162 {"argument-noalias-global", &flag_argument_noalias, 2,
1163 N_("Assume arguments do not alias each other or globals") },
1164 {"strict-aliasing", &flag_strict_aliasing, 1,
1165 N_("Assume strict aliasing rules apply") },
1166 {"align-loops", &align_loops, 0,
1167 N_("Align the start of loops") },
1168 {"align-jumps", &align_jumps, 0,
1169 N_("Align labels which are only reached by jumping") },
1170 {"align-labels", &align_labels, 0,
1171 N_("Align all labels") },
1172 {"align-functions", &align_functions, 0,
1173 N_("Align the start of functions") },
1174 {"merge-constants", &flag_merge_constants, 1,
1175 N_("Attempt to merge identical constants accross compilation units") },
1176 {"merge-all-constants", &flag_merge_constants, 2,
1177 N_("Attempt to merge identical constants and constant variables") },
1178 {"check-memory-usage", &flag_check_memory_usage, 1,
1179 N_("Generate code to check every memory access") },
1180 {"prefix-function-name", &flag_prefix_function_name, 1,
1181 N_("Add a prefix to all function names") },
1182 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1183 N_("Suppress output of instruction numbers and line number notes in debugging dumps") },
1184 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1185 N_("Instrument function entry/exit with profiling calls") },
1186 {"ssa", &flag_ssa, 1,
1187 N_("Enable SSA optimizations") },
1188 {"ssa-ccp", &flag_ssa_ccp, 1,
1189 N_("Enable SSA conditional constant propagation") },
1190 {"ssa-dce", &flag_ssa_dce, 1,
1191 N_("Enable aggressive SSA dead code elimination") },
1192 {"leading-underscore", &flag_leading_underscore, 1,
1193 N_("External symbols have a leading underscore") },
1194 {"ident", &flag_no_ident, 0,
1195 N_("Process #ident directives") },
1196 { "peephole2", &flag_peephole2, 1,
1197 N_("Enables an rtl peephole pass run before sched2") },
1198 { "guess-branch-probability", &flag_guess_branch_prob, 1,
1199 N_("Enables guessing of branch probabilities") },
1200 {"math-errno", &flag_errno_math, 1,
1201 N_("Set errno after built-in math functions") },
1202 {"trapping-math", &flag_trapping_math, 1,
1203 N_("Floating-point operations can trap") },
1204 {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1,
1205 N_("Allow math optimizations that may violate IEEE or ANSI standards") },
1206 {"bounded-pointers", &flag_bounded_pointers, 1,
1207 N_("Compile pointers as triples: value, base & end") },
1208 {"bounds-check", &flag_bounds_check, 1,
1209 N_("Generate code to check bounds before dereferencing pointers and arrays") },
1210 {"single-precision-constant", &flag_single_precision_constant, 1,
1211 N_("Convert floating point constant to single precision constant") },
1212 {"time-report", &time_report, 1,
1213 N_("Report time taken by each compiler pass at end of run") },
1214 {"mem-report", &mem_report, 1,
1215 N_("Report on permanent memory allocation at end of run") },
1216 { "trapv", &flag_trapv, 1,
1217 N_("Trap for signed overflow in addition / subtraction / multiplication.") },
1220 /* Table of language-specific options. */
1222 static const struct lang_opt
1224 const char *const option;
1225 const char *const description;
1227 documented_lang_options[] =
1229 /* In order not to overload the --help output, the convention
1230 used here is to only describe those options which are not
1231 enabled by default. */
1233 { "-ansi",
1234 N_("Compile just for ISO C89") },
1235 { "-fallow-single-precision",
1236 N_("Do not promote floats to double if using -traditional") },
1237 { "-std= ",
1238 N_("Determine language standard") },
1240 { "-fsigned-bitfields", "" },
1241 { "-funsigned-bitfields",
1242 N_("Make bitfields by unsigned by default") },
1243 { "-fno-signed-bitfields", "" },
1244 { "-fno-unsigned-bitfields","" },
1245 { "-fsigned-char",
1246 N_("Make 'char' be signed by default") },
1247 { "-funsigned-char",
1248 N_("Make 'char' be unsigned by default") },
1249 { "-fno-signed-char", "" },
1250 { "-fno-unsigned-char", "" },
1252 { "-ftraditional", "" },
1253 { "-traditional",
1254 N_("Attempt to support traditional K&R style C") },
1255 { "-fnotraditional", "" },
1256 { "-fno-traditional", "" },
1258 { "-fasm", "" },
1259 { "-fno-asm",
1260 N_("Do not recognise the 'asm' keyword") },
1261 { "-fbuiltin", "" },
1262 { "-fno-builtin",
1263 N_("Do not recognise any built in functions") },
1264 { "-fhosted",
1265 N_("Assume normal C execution environment") },
1266 { "-fno-hosted", "" },
1267 { "-ffreestanding",
1268 N_("Assume that standard libraries & main might not exist") },
1269 { "-fno-freestanding", "" },
1270 { "-fcond-mismatch",
1271 N_("Allow different types as args of ? operator") },
1272 { "-fno-cond-mismatch", "" },
1273 { "-fdollars-in-identifiers",
1274 N_("Allow the use of $ inside identifiers") },
1275 { "-fno-dollars-in-identifiers", "" },
1276 { "-fpreprocessed", "" },
1277 { "-fno-preprocessed", "" },
1278 { "-fshort-double",
1279 N_("Use the same size for double as for float") },
1280 { "-fno-short-double", "" },
1281 { "-fshort-enums",
1282 N_("Use the smallest fitting integer to hold enums") },
1283 { "-fno-short-enums", "" },
1284 { "-fshort-wchar",
1285 N_("Override the underlying type for wchar_t to `unsigned short'") },
1286 { "-fno-short-wchar", "" },
1288 { "-Wall",
1289 N_("Enable most warning messages") },
1290 { "-Wbad-function-cast",
1291 N_("Warn about casting functions to incompatible types") },
1292 { "-Wno-bad-function-cast", "" },
1293 { "-Wno-missing-noreturn", "" },
1294 { "-Wmissing-format-attribute",
1295 N_("Warn about functions which might be candidates for format attributes") },
1296 { "-Wno-missing-format-attribute", "" },
1297 { "-Wcast-qual",
1298 N_("Warn about casts which discard qualifiers") },
1299 { "-Wno-cast-qual", "" },
1300 { "-Wchar-subscripts",
1301 N_("Warn about subscripts whose type is 'char'") },
1302 { "-Wno-char-subscripts", "" },
1303 { "-Wcomment",
1304 N_("Warn if nested comments are detected") },
1305 { "-Wno-comment", "" },
1306 { "-Wcomments",
1307 N_("Warn if nested comments are detected") },
1308 { "-Wno-comments", "" },
1309 { "-Wconversion",
1310 N_("Warn about possibly confusing type conversions") },
1311 { "-Wno-conversion", "" },
1312 { "-Wformat",
1313 N_("Warn about printf/scanf/strftime/strfmon format anomalies") },
1314 { "-Wno-format", "" },
1315 { "-Wformat-y2k", "" },
1316 { "-Wno-format-y2k",
1317 N_("Don't warn about strftime formats yielding 2 digit years") },
1318 { "-Wformat-extra-args", "" },
1319 { "-Wno-format-extra-args",
1320 N_("Don't warn about too many arguments to format functions") },
1321 { "-Wformat-nonliteral",
1322 N_("Warn about non-string-literal format strings") },
1323 { "-Wno-format-nonliteral", "" },
1324 { "-Wformat-security",
1325 N_("Warn about possible security problems with format functions") },
1326 { "-Wno-format-security", "" },
1327 { "-Wimplicit-function-declaration",
1328 N_("Warn about implicit function declarations") },
1329 { "-Wno-implicit-function-declaration", "" },
1330 { "-Werror-implicit-function-declaration", "" },
1331 { "-Wimplicit-int",
1332 N_("Warn when a declaration does not specify a type") },
1333 { "-Wno-implicit-int", "" },
1334 { "-Wimplicit", "" },
1335 { "-Wno-implicit", "" },
1336 { "-Wimport",
1337 N_("Warn about the use of the #import directive") },
1338 { "-Wno-import", "" },
1339 { "-Wlong-long","" },
1340 { "-Wno-long-long",
1341 N_("Do not warn about using 'long long' when -pedantic") },
1342 { "-Wmain",
1343 N_("Warn about suspicious declarations of main") },
1344 { "-Wno-main", "" },
1345 { "-Wmissing-braces",
1346 N_("Warn about possibly missing braces around initialisers") },
1347 { "-Wno-missing-braces", "" },
1348 { "-Wmissing-declarations",
1349 N_("Warn about global funcs without previous declarations") },
1350 { "-Wno-missing-declarations", "" },
1351 { "-Wmissing-prototypes",
1352 N_("Warn about global funcs without prototypes") },
1353 { "-Wno-missing-prototypes", "" },
1354 { "-Wmultichar",
1355 N_("Warn about use of multicharacter literals") },
1356 { "-Wno-multichar", "" },
1357 { "-Wnested-externs",
1358 N_("Warn about externs not at file scope level") },
1359 { "-Wno-nested-externs", "" },
1360 { "-Wparentheses",
1361 N_("Warn about possible missing parentheses") },
1362 { "-Wno-parentheses", "" },
1363 { "-Wsequence-point",
1364 N_("Warn about possible violations of sequence point rules") },
1365 { "-Wno-sequence-point", "" },
1366 { "-Wpointer-arith",
1367 N_("Warn about function pointer arithmetic") },
1368 { "-Wno-pointer-arith", "" },
1369 { "-Wredundant-decls",
1370 N_("Warn about multiple declarations of the same object") },
1371 { "-Wno-redundant-decls", "" },
1372 { "-Wsign-compare",
1373 N_("Warn about signed/unsigned comparisons") },
1374 { "-Wno-sign-compare", "" },
1375 { "-Wfloat-equal",
1376 N_("Warn about testing equality of floating point numbers") },
1377 { "-Wno-float-equal", "" },
1378 { "-Wunknown-pragmas",
1379 N_("Warn about unrecognized pragmas") },
1380 { "-Wno-unknown-pragmas", "" },
1381 { "-Wstrict-prototypes",
1382 N_("Warn about non-prototyped function decls") },
1383 { "-Wno-strict-prototypes", "" },
1384 { "-Wtraditional",
1385 N_("Warn about constructs whose meaning change in ISO C") },
1386 { "-Wno-traditional", "" },
1387 { "-Wtrigraphs",
1388 N_("Warn when trigraphs are encountered") },
1389 { "-Wno-trigraphs", "" },
1390 { "-Wundef", "" },
1391 { "-Wno-undef", "" },
1392 { "-Wwrite-strings",
1393 N_("Mark strings as 'const char *'") },
1394 { "-Wno-write-strings", "" },
1396 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1398 #include "options.h"
1402 /* Here is a table, controlled by the tm.h file, listing each -m switch
1403 and which bits in `target_switches' it should set or clear.
1404 If VALUE is positive, it is bits to set.
1405 If VALUE is negative, -VALUE is bits to clear.
1406 (The sign bit is not used so there is no confusion.) */
1408 static const struct
1410 const char *const name;
1411 const int value;
1412 const char *const description;
1414 target_switches [] = TARGET_SWITCHES;
1416 /* This table is similar, but allows the switch to have a value. */
1418 #ifdef TARGET_OPTIONS
1419 static const struct
1421 const char *const prefix;
1422 const char **const variable;
1423 const char *const description;
1425 target_options [] = TARGET_OPTIONS;
1426 #endif
1428 /* Options controlling warnings. */
1430 /* Don't print warning messages. -w. */
1432 int inhibit_warnings = 0;
1434 /* Don't suppress warnings from system headers. -Wsystem-headers. */
1436 int warn_system_headers = 0;
1438 /* Print various extra warnings. -W. */
1440 int extra_warnings = 0;
1442 /* Treat warnings as errors. -Werror. */
1444 int warnings_are_errors = 0;
1446 /* Nonzero to warn about unused variables, functions et.al. */
1448 int warn_unused_function;
1449 int warn_unused_label;
1450 int warn_unused_parameter;
1451 int warn_unused_variable;
1452 int warn_unused_value;
1454 /* Nonzero to warn about code which is never reached. */
1456 int warn_notreached;
1458 /* Nonzero to warn about variables used before they are initialized. */
1460 int warn_uninitialized;
1462 /* Nonzero means warn about all declarations which shadow others. */
1464 int warn_shadow;
1466 /* Warn if a switch on an enum fails to have a case for every enum value. */
1468 int warn_switch;
1470 /* Nonzero means warn about function definitions that default the return type
1471 or that use a null return and have a return-type other than void. */
1473 int warn_return_type;
1475 /* Nonzero means warn about pointer casts that increase the required
1476 alignment of the target type (and might therefore lead to a crash
1477 due to a misaligned access). */
1479 int warn_cast_align;
1481 /* Nonzero means warn about any objects definitions whose size is larger
1482 than N bytes. Also want about function definitions whose returned
1483 values are larger than N bytes. The value N is in `larger_than_size'. */
1485 int warn_larger_than;
1486 HOST_WIDE_INT larger_than_size;
1488 /* Nonzero means warn if inline function is too large. */
1490 int warn_inline;
1492 /* Warn if a function returns an aggregate,
1493 since there are often incompatible calling conventions for doing this. */
1495 int warn_aggregate_return;
1497 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1499 int warn_packed;
1501 /* Warn when gcc pads a structure to an alignment boundary. */
1503 int warn_padded;
1505 /* Warn when an optimization pass is disabled. */
1507 int warn_disabled_optimization;
1509 /* Warn about functions which might be candidates for attribute noreturn. */
1511 int warn_missing_noreturn;
1513 /* Likewise for -W. */
1515 lang_independent_options W_options[] =
1517 {"unused-function", &warn_unused_function, 1,
1518 N_("Warn when a function is unused") },
1519 {"unused-label", &warn_unused_label, 1,
1520 N_("Warn when a label is unused") },
1521 {"unused-parameter", &warn_unused_parameter, 1,
1522 N_("Warn when a function parameter is unused") },
1523 {"unused-variable", &warn_unused_variable, 1,
1524 N_("Warn when a variable is unused") },
1525 {"unused-value", &warn_unused_value, 1,
1526 N_("Warn when an expression value is unused") },
1527 {"system-headers", &warn_system_headers, 1,
1528 N_("Do not suppress warnings from system headers") },
1529 {"error", &warnings_are_errors, 1,
1530 N_("Treat all warnings as errors") },
1531 {"shadow", &warn_shadow, 1,
1532 N_("Warn when one local variable shadows another") },
1533 {"switch", &warn_switch, 1,
1534 N_("Warn about 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 {"missing-noreturn", &warn_missing_noreturn, 1,
1552 N_("Warn about functions which might be candidates for attribute noreturn") }
1555 void
1556 set_Wunused (setting)
1557 int setting;
1559 warn_unused_function = setting;
1560 warn_unused_label = setting;
1561 /* Unused function parameter warnings are reported when either ``-W
1562 -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
1563 -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
1564 if (!setting)
1565 warn_unused_parameter = 0;
1566 else if (!warn_unused_parameter)
1567 warn_unused_parameter = -1;
1568 warn_unused_variable = setting;
1569 warn_unused_value = setting;
1572 /* The following routines are useful in setting all the flags that
1573 -ffast-math and -fno-fast-math imply. */
1575 void
1576 set_fast_math_flags ()
1578 flag_trapping_math = 0;
1579 flag_unsafe_math_optimizations = 1;
1580 flag_errno_math = 0;
1583 void
1584 set_no_fast_math_flags ()
1586 flag_trapping_math = 1;
1587 flag_unsafe_math_optimizations = 0;
1588 flag_errno_math = 1;
1592 /* Output files for assembler code (real compiler output)
1593 and debugging dumps. */
1595 FILE *asm_out_file;
1596 FILE *aux_info_file;
1597 FILE *rtl_dump_file = NULL;
1599 /* Decode the string P as an integral parameter.
1600 If the string is indeed an integer return its numeric value else
1601 issue an Invalid Option error for the option PNAME and return DEFVAL.
1602 If PNAME is zero just return DEFVAL, do not call error. */
1605 read_integral_parameter (p, pname, defval)
1606 const char *p;
1607 const char *pname;
1608 const int defval;
1610 const char *endp = p;
1612 while (*endp)
1614 if (ISDIGIT (*endp))
1615 endp++;
1616 else
1617 break;
1620 if (*endp != 0)
1622 if (pname != 0)
1623 error ("Invalid option `%s'", pname);
1624 return defval;
1627 return atoi (p);
1631 /* This is the default decl_printable_name function. */
1633 static const char *
1634 decl_name (decl, verbosity)
1635 tree decl;
1636 int verbosity ATTRIBUTE_UNUSED;
1638 return IDENTIFIER_POINTER (DECL_NAME (decl));
1642 /* This calls abort and is used to avoid problems when abort if a macro.
1643 It is used when we need to pass the address of abort. */
1645 void
1646 do_abort ()
1648 abort ();
1651 /* When `malloc.c' is compiled with `rcheck' defined,
1652 it calls this function to report clobberage. */
1654 void
1655 botch (s)
1656 const char *s ATTRIBUTE_UNUSED;
1658 abort ();
1661 /* Return the logarithm of X, base 2, considering X unsigned,
1662 if X is a power of 2. Otherwise, returns -1.
1664 This should be used via the `exact_log2' macro. */
1667 exact_log2_wide (x)
1668 unsigned HOST_WIDE_INT x;
1670 int log = 0;
1671 /* Test for 0 or a power of 2. */
1672 if (x == 0 || x != (x & -x))
1673 return -1;
1674 while ((x >>= 1) != 0)
1675 log++;
1676 return log;
1679 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1680 If X is 0, return -1.
1682 This should be used via the floor_log2 macro. */
1685 floor_log2_wide (x)
1686 unsigned HOST_WIDE_INT x;
1688 int log = -1;
1689 while (x != 0)
1690 log++,
1691 x >>= 1;
1692 return log;
1695 static int float_handler_set;
1696 int float_handled;
1697 jmp_buf float_handler;
1699 /* Signals actually come here. */
1701 static void
1702 float_signal (signo)
1703 /* If this is missing, some compilers complain. */
1704 int signo ATTRIBUTE_UNUSED;
1706 if (float_handled == 0)
1707 crash_signal (signo);
1708 float_handled = 0;
1710 /* On System-V derived systems, we must reinstall the signal handler.
1711 This is harmless on BSD-derived systems. */
1712 signal (SIGFPE, float_signal);
1713 longjmp (float_handler, 1);
1716 /* Specify where to longjmp to when a floating arithmetic error happens.
1717 If HANDLER is 0, it means don't handle the errors any more. */
1719 static void
1720 set_float_handler (handler)
1721 jmp_buf handler;
1723 float_handled = (handler != 0);
1724 if (handler)
1725 memcpy (float_handler, handler, sizeof (float_handler));
1727 if (float_handled && ! float_handler_set)
1729 signal (SIGFPE, float_signal);
1730 float_handler_set = 1;
1734 /* This is a wrapper function for code which might elicit an
1735 arithmetic exception. That code should be passed in as a function
1736 pointer FN, and one argument DATA. DATA is usually a struct which
1737 contains the real input and output for function FN. This function
1738 returns 0 (failure) if longjmp was called (i.e. an exception
1739 occurred.) It returns 1 (success) otherwise. */
1742 do_float_handler (fn, data)
1743 void (*fn) PARAMS ((PTR));
1744 PTR data;
1746 jmp_buf buf;
1748 if (setjmp (buf))
1750 /* We got here via longjmp () caused by an exception in function
1751 fn (). */
1752 set_float_handler (NULL);
1753 return 0;
1756 set_float_handler (buf);
1757 (*fn)(data);
1758 set_float_handler (NULL);
1759 return 1;
1762 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1763 into ICE messages, which is much more user friendly. */
1765 static void
1766 crash_signal (signo)
1767 int signo;
1769 internal_error ("Internal error: %s", strsignal (signo));
1772 /* Strip off a legitimate source ending from the input string NAME of
1773 length LEN. Rather than having to know the names used by all of
1774 our front ends, we strip off an ending of a period followed by
1775 up to five characters. (Java uses ".class".) */
1777 void
1778 strip_off_ending (name, len)
1779 char *name;
1780 int len;
1782 int i;
1783 for (i = 2; i < 6 && len > i; i++)
1785 if (name[len - i] == '.')
1787 name[len - i] = '\0';
1788 break;
1793 /* Output a quoted string. */
1795 void
1796 output_quoted_string (asm_file, string)
1797 FILE *asm_file;
1798 const char *string;
1800 #ifdef OUTPUT_QUOTED_STRING
1801 OUTPUT_QUOTED_STRING (asm_file, string);
1802 #else
1803 char c;
1805 putc ('\"', asm_file);
1806 while ((c = *string++) != 0)
1808 if (c == '\"' || c == '\\')
1809 putc ('\\', asm_file);
1810 putc (c, asm_file);
1812 putc ('\"', asm_file);
1813 #endif
1816 /* Output a file name in the form wanted by System V. */
1818 void
1819 output_file_directive (asm_file, input_name)
1820 FILE *asm_file;
1821 const char *input_name;
1823 int len = strlen (input_name);
1824 const char *na = input_name + len;
1826 /* NA gets INPUT_NAME sans directory names. */
1827 while (na > input_name)
1829 if (IS_DIR_SEPARATOR (na[-1]))
1830 break;
1831 na--;
1834 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1835 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1836 #else
1837 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1838 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1839 #else
1840 fprintf (asm_file, "\t.file\t");
1841 output_quoted_string (asm_file, na);
1842 fputc ('\n', asm_file);
1843 #endif
1844 #endif
1847 /* Routine to open a dump file. Return true if the dump file is enabled. */
1849 static int
1850 open_dump_file (index, decl)
1851 enum dump_file_index index;
1852 tree decl;
1854 char *dump_name;
1855 const char *open_arg;
1856 char seq[16];
1858 if (! dump_file[index].enabled)
1859 return 0;
1861 timevar_push (TV_DUMP);
1862 if (rtl_dump_file != NULL)
1863 fclose (rtl_dump_file);
1865 sprintf (seq, DUMPFILE_FORMAT, index);
1867 if (! dump_file[index].initialized)
1869 /* If we've not initialized the files, do so now. */
1870 if (graph_dump_format != no_graph
1871 && dump_file[index].graph_dump_p)
1873 dump_name = concat (seq, dump_file[index].extension, NULL);
1874 clean_graph_dump_file (dump_base_name, dump_name);
1875 free (dump_name);
1877 dump_file[index].initialized = 1;
1878 open_arg = "w";
1880 else
1881 open_arg = "a";
1883 dump_name = concat (dump_base_name, seq,
1884 dump_file[index].extension, NULL);
1886 rtl_dump_file = fopen (dump_name, open_arg);
1887 if (rtl_dump_file == NULL)
1888 fatal_io_error ("can't open %s", dump_name);
1890 free (dump_name);
1892 if (decl)
1893 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1894 decl_printable_name (decl, 2));
1896 timevar_pop (TV_DUMP);
1897 return 1;
1900 /* Routine to close a dump file. */
1902 static void
1903 close_dump_file (index, func, insns)
1904 enum dump_file_index index;
1905 void (*func) PARAMS ((FILE *, rtx));
1906 rtx insns;
1908 if (! rtl_dump_file)
1909 return;
1911 timevar_push (TV_DUMP);
1912 if (insns
1913 && graph_dump_format != no_graph
1914 && dump_file[index].graph_dump_p)
1916 char seq[16];
1917 char *suffix;
1919 sprintf (seq, DUMPFILE_FORMAT, index);
1920 suffix = concat (seq, dump_file[index].extension, NULL);
1921 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1922 free (suffix);
1925 if (func && insns)
1926 func (rtl_dump_file, insns);
1928 fflush (rtl_dump_file);
1929 fclose (rtl_dump_file);
1931 rtl_dump_file = NULL;
1932 timevar_pop (TV_DUMP);
1935 /* Do any final processing required for the declarations in VEC, of
1936 which there are LEN. We write out inline functions and variables
1937 that have been deferred until this point, but which are required.
1938 Returns non-zero if anything was put out. */
1941 wrapup_global_declarations (vec, len)
1942 tree *vec;
1943 int len;
1945 tree decl;
1946 int i;
1947 int reconsider;
1948 int output_something = 0;
1950 for (i = 0; i < len; i++)
1952 decl = vec[i];
1954 /* We're not deferring this any longer. */
1955 DECL_DEFER_OUTPUT (decl) = 0;
1957 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
1958 && incomplete_decl_finalize_hook != 0)
1959 (*incomplete_decl_finalize_hook) (decl);
1962 /* Now emit any global variables or functions that we have been
1963 putting off. We need to loop in case one of the things emitted
1964 here references another one which comes earlier in the list. */
1967 reconsider = 0;
1968 for (i = 0; i < len; i++)
1970 decl = vec[i];
1972 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1973 continue;
1975 /* Don't write out static consts, unless we still need them.
1977 We also keep static consts if not optimizing (for debugging),
1978 unless the user specified -fno-keep-static-consts.
1979 ??? They might be better written into the debug information.
1980 This is possible when using DWARF.
1982 A language processor that wants static constants to be always
1983 written out (even if it is not used) is responsible for
1984 calling rest_of_decl_compilation itself. E.g. the C front-end
1985 calls rest_of_decl_compilation from finish_decl.
1986 One motivation for this is that is conventional in some
1987 environments to write things like:
1988 static const char rcsid[] = "... version string ...";
1989 intending to force the string to be in the executable.
1991 A language processor that would prefer to have unneeded
1992 static constants "optimized away" would just defer writing
1993 them out until here. E.g. C++ does this, because static
1994 constants are often defined in header files.
1996 ??? A tempting alternative (for both C and C++) would be
1997 to force a constant to be written if and only if it is
1998 defined in a main file, as opposed to an include file. */
2000 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2001 && (((! TREE_READONLY (decl) || TREE_PUBLIC (decl))
2002 && !DECL_COMDAT (decl))
2003 || (!optimize
2004 && flag_keep_static_consts
2005 && !DECL_ARTIFICIAL (decl))
2006 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2008 reconsider = 1;
2009 rest_of_decl_compilation (decl, NULL, 1, 1);
2012 if (TREE_CODE (decl) == FUNCTION_DECL
2013 && DECL_INITIAL (decl) != 0
2014 && DECL_SAVED_INSNS (decl) != 0
2015 && (flag_keep_inline_functions
2016 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2017 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2019 reconsider = 1;
2020 output_inline_function (decl);
2024 if (reconsider)
2025 output_something = 1;
2027 while (reconsider);
2029 return output_something;
2032 /* Issue appropriate warnings for the global declarations in VEC (of
2033 which there are LEN). Output debugging information for them. */
2035 void
2036 check_global_declarations (vec, len)
2037 tree *vec;
2038 int len;
2040 tree decl;
2041 int i;
2043 for (i = 0; i < len; i++)
2045 decl = vec[i];
2047 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2048 && ! TREE_ASM_WRITTEN (decl))
2049 /* Cancel the RTL for this decl so that, if debugging info
2050 output for global variables is still to come,
2051 this one will be omitted. */
2052 SET_DECL_RTL (decl, NULL_RTX);
2054 /* Warn about any function
2055 declared static but not defined.
2056 We don't warn about variables,
2057 because many programs have static variables
2058 that exist only to get some text into the object file. */
2059 if (TREE_CODE (decl) == FUNCTION_DECL
2060 && (warn_unused_function
2061 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2062 && DECL_INITIAL (decl) == 0
2063 && DECL_EXTERNAL (decl)
2064 && ! DECL_ARTIFICIAL (decl)
2065 && ! TREE_PUBLIC (decl))
2067 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2068 pedwarn_with_decl (decl,
2069 "`%s' used but never defined");
2070 else
2071 warning_with_decl (decl,
2072 "`%s' declared `static' but never defined");
2073 /* This symbol is effectively an "extern" declaration now. */
2074 TREE_PUBLIC (decl) = 1;
2075 assemble_external (decl);
2078 /* Warn about static fns or vars defined but not used,
2079 but not about inline functions or static consts
2080 since defining those in header files is normal practice. */
2081 if (((warn_unused_function
2082 && TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2083 || (warn_unused_variable
2084 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2085 && ! DECL_IN_SYSTEM_HEADER (decl)
2086 && ! DECL_EXTERNAL (decl)
2087 && ! TREE_PUBLIC (decl)
2088 && ! TREE_USED (decl)
2089 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2090 /* The TREE_USED bit for file-scope decls
2091 is kept in the identifier, to handle multiple
2092 external decls in different scopes. */
2093 && ! TREE_USED (DECL_NAME (decl)))
2094 warning_with_decl (decl, "`%s' defined but not used");
2096 timevar_push (TV_SYMOUT);
2097 (*debug_hooks->global_decl) (decl);
2098 timevar_pop (TV_SYMOUT);
2102 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2103 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2104 INPUT_FILENAME and LINENO accordingly. */
2106 void
2107 push_srcloc (file, line)
2108 const char *file;
2109 int line;
2111 struct file_stack *fs;
2113 if (input_file_stack)
2115 input_file_stack->name = input_filename;
2116 input_file_stack->line = lineno;
2119 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2120 fs->name = input_filename = file;
2121 fs->line = lineno = line;
2122 fs->indent_level = 0;
2123 fs->next = input_file_stack;
2124 input_file_stack = fs;
2125 input_file_stack_tick++;
2128 /* Pop the top entry off the stack of presently open source files.
2129 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2130 the stack. */
2132 void
2133 pop_srcloc ()
2135 struct file_stack *fs;
2137 fs = input_file_stack;
2138 input_file_stack = fs->next;
2139 free (fs);
2140 input_file_stack_tick++;
2141 /* The initial source file is never popped. */
2142 if (!input_file_stack)
2143 abort ();
2144 input_filename = input_file_stack->name;
2145 lineno = input_file_stack->line;
2148 /* Compile an entire translation unit. Write a file of assembly
2149 output and various debugging dumps. */
2151 static void
2152 compile_file ()
2154 tree globals;
2156 /* Initialize yet another pass. */
2158 init_final (main_input_filename);
2159 init_branch_prob (dump_base_name);
2161 timevar_push (TV_PARSE);
2163 /* Call the parser, which parses the entire file
2164 (calling rest_of_compilation for each function). */
2165 yyparse ();
2167 /* In case there were missing block closers,
2168 get us back to the global binding level. */
2169 (*lang_hooks.clear_binding_stack) ();
2171 /* Compilation is now finished except for writing
2172 what's left of the symbol table output. */
2174 timevar_pop (TV_PARSE);
2176 if (flag_syntax_only)
2177 return;
2179 globals = getdecls ();
2181 /* Really define vars that have had only a tentative definition.
2182 Really output inline functions that must actually be callable
2183 and have not been output so far. */
2186 int len = list_length (globals);
2187 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2188 int i;
2189 tree decl;
2191 /* Process the decls in reverse order--earliest first.
2192 Put them into VEC from back to front, then take out from front. */
2194 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2195 vec[len - i - 1] = decl;
2197 wrapup_global_declarations (vec, len);
2199 /* This must occur after the loop to output deferred functions. Else
2200 the profiler initializer would not be emitted if all the functions
2201 in this compilation unit were deferred.
2203 output_func_start_profiler can not cause any additional functions or
2204 data to need to be output, so it need not be in the deferred function
2205 loop above. */
2206 output_func_start_profiler ();
2208 check_global_declarations (vec, len);
2210 /* Clean up. */
2211 free (vec);
2214 /* Write out any pending weak symbol declarations. */
2216 weak_finish ();
2218 /* Do dbx symbols. */
2219 timevar_push (TV_SYMOUT);
2221 #ifdef DWARF2_UNWIND_INFO
2222 if (dwarf2out_do_frame ())
2223 dwarf2out_frame_finish ();
2224 #endif
2226 (*debug_hooks->finish) (main_input_filename);
2227 timevar_pop (TV_SYMOUT);
2229 /* Output some stuff at end of file if nec. */
2231 dw2_output_indirect_constants ();
2233 end_final (dump_base_name);
2235 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2237 timevar_push (TV_DUMP);
2238 open_dump_file (DFI_bp, NULL);
2240 end_branch_prob ();
2242 close_dump_file (DFI_bp, NULL, NULL_RTX);
2243 timevar_pop (TV_DUMP);
2246 #ifdef ASM_FILE_END
2247 ASM_FILE_END (asm_out_file);
2248 #endif
2250 /* Attach a special .ident directive to the end of the file to identify
2251 the version of GCC which compiled this code. The format of the .ident
2252 string is patterned after the ones produced by native SVR4 compilers. */
2253 #ifdef IDENT_ASM_OP
2254 if (!flag_no_ident)
2255 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2256 IDENT_ASM_OP, version_string);
2257 #endif
2259 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2261 timevar_push (TV_DUMP);
2262 dump_combine_total_stats (rtl_dump_file);
2263 close_dump_file (DFI_combine, NULL, NULL_RTX);
2264 timevar_pop (TV_DUMP);
2268 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2269 and TYPE_DECL nodes.
2271 This does nothing for local (non-static) variables, unless the
2272 variable is a register variable with an ASMSPEC. In that case, or
2273 if the variable is not an automatic, it sets up the RTL and
2274 outputs any assembler code (label definition, storage allocation
2275 and initialization).
2277 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2278 the assembler symbol name to be used. TOP_LEVEL is nonzero
2279 if this declaration is not within a function. */
2281 void
2282 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2283 tree decl;
2284 const char *asmspec;
2285 int top_level;
2286 int at_end;
2288 /* Declarations of variables, and of functions defined elsewhere. */
2290 /* The most obvious approach, to put an #ifndef around where
2291 this macro is used, doesn't work since it's inside a macro call. */
2292 #ifndef ASM_FINISH_DECLARE_OBJECT
2293 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2294 #endif
2296 /* Forward declarations for nested functions are not "external",
2297 but we need to treat them as if they were. */
2298 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2299 || TREE_CODE (decl) == FUNCTION_DECL)
2301 timevar_push (TV_VARCONST);
2302 if (asmspec)
2303 make_decl_rtl (decl, asmspec);
2304 /* Don't output anything
2305 when a tentative file-scope definition is seen.
2306 But at end of compilation, do output code for them. */
2307 if (at_end || !DECL_DEFER_OUTPUT (decl))
2308 assemble_variable (decl, top_level, at_end, 0);
2309 if (decl == last_assemble_variable_decl)
2311 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2312 top_level, at_end);
2314 timevar_pop (TV_VARCONST);
2316 else if (DECL_REGISTER (decl) && asmspec != 0)
2318 if (decode_reg_name (asmspec) >= 0)
2320 SET_DECL_RTL (decl, NULL_RTX);
2321 make_decl_rtl (decl, asmspec);
2323 else
2325 error ("invalid register name `%s' for register variable", asmspec);
2326 DECL_REGISTER (decl) = 0;
2327 if (!top_level)
2328 expand_decl (decl);
2331 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2332 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2333 && TREE_CODE (decl) == TYPE_DECL)
2335 timevar_push (TV_SYMOUT);
2336 dbxout_symbol (decl, 0);
2337 timevar_pop (TV_SYMOUT);
2339 #endif
2340 #ifdef SDB_DEBUGGING_INFO
2341 else if (write_symbols == SDB_DEBUG && top_level
2342 && TREE_CODE (decl) == TYPE_DECL)
2344 timevar_push (TV_SYMOUT);
2345 sdbout_symbol (decl, 0);
2346 timevar_pop (TV_SYMOUT);
2348 #endif
2351 /* Called after finishing a record, union or enumeral type. */
2353 void
2354 rest_of_type_compilation (type, toplev)
2355 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2356 tree type;
2357 int toplev;
2358 #else
2359 tree type ATTRIBUTE_UNUSED;
2360 int toplev ATTRIBUTE_UNUSED;
2361 #endif
2363 timevar_push (TV_SYMOUT);
2364 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2365 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2366 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2367 #endif
2368 #ifdef SDB_DEBUGGING_INFO
2369 if (write_symbols == SDB_DEBUG)
2370 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2371 #endif
2372 #ifdef DWARF2_DEBUGGING_INFO
2373 if (write_symbols == DWARF2_DEBUG && toplev)
2374 dwarf2out_decl (TYPE_STUB_DECL (type));
2375 #endif
2376 timevar_pop (TV_SYMOUT);
2379 /* This is called from finish_function (within yyparse)
2380 after each top-level definition is parsed.
2381 It is supposed to compile that function or variable
2382 and output the assembler code for it.
2383 After we return, the tree storage is freed. */
2385 void
2386 rest_of_compilation (decl)
2387 tree decl;
2389 rtx insns;
2390 int tem;
2391 int failure = 0;
2392 int rebuild_label_notes_after_reload;
2393 int register_life_up_to_date;
2395 timevar_push (TV_REST_OF_COMPILATION);
2397 /* Now that we're out of the frontend, we shouldn't have any more
2398 CONCATs anywhere. */
2399 generating_concat_p = 0;
2401 /* When processing delayed functions, prepare_function_start() won't
2402 have been run to re-initialize it. */
2403 cse_not_expected = ! optimize;
2405 /* First, make sure that NOTE_BLOCK is set correctly for each
2406 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2407 if (!cfun->x_whole_function_mode_p)
2408 identify_blocks ();
2410 /* Then remove any notes we don't need. That will make iterating
2411 over the instruction sequence faster, and allow the garbage
2412 collector to reclaim the memory used by the notes. */
2413 remove_unnecessary_notes ();
2415 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2416 tree in sensible shape. So, we just recalculate it here. */
2417 if (cfun->x_whole_function_mode_p)
2418 reorder_blocks ();
2420 init_flow ();
2422 /* If we are reconsidering an inline function
2423 at the end of compilation, skip the stuff for making it inline. */
2425 if (DECL_SAVED_INSNS (decl) == 0)
2427 int inlinable = 0;
2428 tree parent;
2429 const char *lose;
2431 /* If this is nested inside an inlined external function, pretend
2432 it was only declared. Since we cannot inline such functions,
2433 generating code for this one is not only not necessary but will
2434 confuse some debugging output writers. */
2435 for (parent = DECL_CONTEXT (current_function_decl);
2436 parent != NULL_TREE;
2437 parent = get_containing_scope (parent))
2438 if (TREE_CODE (parent) == FUNCTION_DECL
2439 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2441 DECL_INITIAL (decl) = 0;
2442 goto exit_rest_of_compilation;
2445 /* If requested, consider whether to make this function inline. */
2446 if ((DECL_INLINE (decl) && !flag_no_inline)
2447 || flag_inline_functions)
2449 timevar_push (TV_INTEGRATION);
2450 lose = function_cannot_inline_p (decl);
2451 timevar_pop (TV_INTEGRATION);
2452 if (lose || ! optimize)
2454 if (warn_inline && DECL_INLINE (decl))
2455 warning_with_decl (decl, lose);
2456 DECL_ABSTRACT_ORIGIN (decl) = 0;
2457 /* Don't really compile an extern inline function.
2458 If we can't make it inline, pretend
2459 it was only declared. */
2460 if (DECL_EXTERNAL (decl))
2462 DECL_INITIAL (decl) = 0;
2463 goto exit_rest_of_compilation;
2466 else
2467 /* ??? Note that this has the effect of making it look
2468 like "inline" was specified for a function if we choose
2469 to inline it. This isn't quite right, but it's
2470 probably not worth the trouble to fix. */
2471 inlinable = DECL_INLINE (decl) = 1;
2474 insns = get_insns ();
2476 /* Dump the rtl code if we are dumping rtl. */
2478 if (open_dump_file (DFI_rtl, decl))
2480 if (DECL_SAVED_INSNS (decl))
2481 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2482 close_dump_file (DFI_rtl, print_rtl, insns);
2485 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2486 sorts of eh initialization. Delay this until after the
2487 initial rtl dump so that we can see the original nesting. */
2488 convert_from_eh_region_ranges ();
2490 /* If function is inline, and we don't yet know whether to
2491 compile it by itself, defer decision till end of compilation.
2492 finish_compilation will call rest_of_compilation again
2493 for those functions that need to be output. Also defer those
2494 functions that we are supposed to defer. */
2496 if (inlinable
2497 || (DECL_INLINE (decl)
2498 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2499 && ! flag_keep_inline_functions)
2500 || DECL_EXTERNAL (decl))))
2501 DECL_DEFER_OUTPUT (decl) = 1;
2503 if (DECL_INLINE (decl))
2504 /* DWARF wants separate debugging info for abstract and
2505 concrete instances of all inline functions, including those
2506 declared inline but not inlined, and those inlined even
2507 though they weren't declared inline. Conveniently, that's
2508 what DECL_INLINE means at this point. */
2509 (*debug_hooks->deferred_inline_function) (decl);
2511 if (DECL_DEFER_OUTPUT (decl))
2513 /* If -Wreturn-type, we have to do a bit of compilation. We just
2514 want to call cleanup the cfg to figure out whether or not we can
2515 fall off the end of the function; we do the minimum amount of
2516 work necessary to make that safe. */
2517 if (warn_return_type)
2519 int saved_optimize = optimize;
2521 optimize = 0;
2522 rebuild_jump_labels (insns);
2523 find_exception_handler_labels ();
2524 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2525 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2526 optimize = saved_optimize;
2528 /* CFG is no longer maintained up-to-date. */
2529 free_bb_for_insn ();
2532 current_function_nothrow = nothrow_function_p ();
2533 if (current_function_nothrow)
2534 /* Now we know that this can't throw; set the flag for the benefit
2535 of other functions later in this translation unit. */
2536 TREE_NOTHROW (current_function_decl) = 1;
2538 timevar_push (TV_INTEGRATION);
2539 save_for_inline (decl);
2540 timevar_pop (TV_INTEGRATION);
2541 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2542 goto exit_rest_of_compilation;
2545 /* If specified extern inline but we aren't inlining it, we are
2546 done. This goes for anything that gets here with DECL_EXTERNAL
2547 set, not just things with DECL_INLINE. */
2548 if (DECL_EXTERNAL (decl))
2549 goto exit_rest_of_compilation;
2552 ggc_collect ();
2554 /* Initialize some variables used by the optimizers. */
2555 init_function_for_compilation ();
2557 if (! DECL_DEFER_OUTPUT (decl))
2558 TREE_ASM_WRITTEN (decl) = 1;
2560 /* Now that integrate will no longer see our rtl, we need not
2561 distinguish between the return value of this function and the
2562 return value of called functions. Also, we can remove all SETs
2563 of subregs of hard registers; they are only here because of
2564 integrate. Also, we can now initialize pseudos intended to
2565 carry magic hard reg data throughout the function. */
2566 rtx_equal_function_value_matters = 0;
2567 purge_hard_subreg_sets (get_insns ());
2568 emit_initial_value_sets ();
2570 /* Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
2571 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2572 goto exit_rest_of_compilation;
2574 /* We may have potential sibling or tail recursion sites. Select one
2575 (of possibly multiple) methods of performing the call. */
2576 if (flag_optimize_sibling_calls)
2578 timevar_push (TV_JUMP);
2579 open_dump_file (DFI_sibling, decl);
2581 optimize_sibling_and_tail_recursive_calls ();
2583 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2584 timevar_pop (TV_JUMP);
2587 /* Complete generation of exception handling code. */
2588 find_exception_handler_labels ();
2589 if (doing_eh (0))
2591 timevar_push (TV_JUMP);
2592 open_dump_file (DFI_eh, decl);
2594 finish_eh_generation ();
2596 close_dump_file (DFI_eh, print_rtl, get_insns ());
2597 timevar_pop (TV_JUMP);
2600 #ifdef FINALIZE_PIC
2601 /* If we are doing position-independent code generation, now
2602 is the time to output special prologues and epilogues.
2603 We do not want to do this earlier, because it just clutters
2604 up inline functions with meaningless insns. */
2605 if (flag_pic)
2606 FINALIZE_PIC;
2607 #endif
2609 insns = get_insns ();
2611 /* Copy any shared structure that should not be shared. */
2612 unshare_all_rtl (current_function_decl, insns);
2614 #ifdef SETJMP_VIA_SAVE_AREA
2615 /* This must be performed before virtual register instantiation. */
2616 if (current_function_calls_alloca)
2617 optimize_save_area_alloca (insns);
2618 #endif
2620 /* Instantiate all virtual registers. */
2621 instantiate_virtual_regs (current_function_decl, insns);
2623 open_dump_file (DFI_jump, decl);
2625 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2626 are initialized and to compute whether control can drop off the end
2627 of the function. */
2629 timevar_push (TV_JUMP);
2630 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2631 before jump optimization switches branch directions. */
2632 expected_value_to_br_prob ();
2634 reg_scan (insns, max_reg_num (), 0);
2635 rebuild_jump_labels (insns);
2636 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2637 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP);
2639 /* CFG is no longer maintained up-to-date. */
2640 free_bb_for_insn ();
2641 copy_loop_headers (insns);
2642 purge_line_number_notes (insns);
2644 timevar_pop (TV_JUMP);
2646 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2647 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2649 close_dump_file (DFI_jump, print_rtl, insns);
2650 goto exit_rest_of_compilation;
2653 /* Long term, this should probably move before the jump optimizer too,
2654 but I didn't want to disturb the rtl_dump_and_exit and related
2655 stuff at this time. */
2656 if (optimize > 0 && flag_ssa)
2658 /* Convert to SSA form. */
2660 timevar_push (TV_TO_SSA);
2661 open_dump_file (DFI_ssa, decl);
2663 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2664 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2665 convert_to_ssa ();
2667 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2668 timevar_pop (TV_TO_SSA);
2670 /* Perform sparse conditional constant propagation, if requested. */
2671 if (flag_ssa_ccp)
2673 timevar_push (TV_SSA_CCP);
2674 open_dump_file (DFI_ssa_ccp, decl);
2676 ssa_const_prop ();
2678 close_dump_file (DFI_ssa_ccp, print_rtl_with_bb, get_insns ());
2679 timevar_pop (TV_SSA_CCP);
2682 /* It would be useful to cleanup the CFG at this point, but block
2683 merging and possibly other transformations might leave a PHI
2684 node in the middle of a basic block, which is a strict no-no. */
2686 /* The SSA implementation uses basic block numbers in its phi
2687 nodes. Thus, changing the control-flow graph or the basic
2688 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
2689 may cause problems. */
2691 if (flag_ssa_dce)
2693 /* Remove dead code. */
2695 timevar_push (TV_SSA_DCE);
2696 open_dump_file (DFI_ssa_dce, decl);
2698 insns = get_insns ();
2699 ssa_eliminate_dead_code();
2701 close_dump_file (DFI_ssa_dce, print_rtl_with_bb, insns);
2702 timevar_pop (TV_SSA_DCE);
2705 /* Convert from SSA form. */
2707 timevar_push (TV_FROM_SSA);
2708 open_dump_file (DFI_ussa, decl);
2710 convert_from_ssa ();
2711 /* New registers have been created. Rescan their usage. */
2712 reg_scan (insns, max_reg_num (), 1);
2714 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
2715 timevar_pop (TV_FROM_SSA);
2717 ggc_collect ();
2718 /* CFG is no longer maintained up-to-date. */
2719 free_bb_for_insn ();
2722 timevar_push (TV_JUMP);
2724 if (optimize > 0)
2726 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2727 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2729 /* ??? Run if-conversion before delete_null_pointer_checks,
2730 since the later does not preserve the CFG. This should
2731 be changed -- no since converting if's that are going to
2732 be deleted. */
2733 timevar_push (TV_IFCVT);
2734 if_convert (0);
2735 timevar_pop (TV_IFCVT);
2737 /* CFG is no longer maintained up-to-date. */
2738 free_bb_for_insn ();
2739 /* Try to identify useless null pointer tests and delete them. */
2740 if (flag_delete_null_pointer_checks)
2741 delete_null_pointer_checks (insns);
2744 /* Jump optimization, and the removal of NULL pointer checks, may
2745 have reduced the number of instructions substantially. CSE, and
2746 future passes, allocate arrays whose dimensions involve the
2747 maximum instruction UID, so if we can reduce the maximum UID
2748 we'll save big on memory. */
2749 renumber_insns (rtl_dump_file);
2750 timevar_pop (TV_JUMP);
2752 close_dump_file (DFI_jump, print_rtl, insns);
2754 ggc_collect ();
2756 /* Perform common subexpression elimination.
2757 Nonzero value from `cse_main' means that jumps were simplified
2758 and some code may now be unreachable, so do
2759 jump optimization again. */
2761 if (optimize > 0)
2763 open_dump_file (DFI_cse, decl);
2764 timevar_push (TV_CSE);
2766 reg_scan (insns, max_reg_num (), 1);
2768 if (flag_thread_jumps)
2770 timevar_push (TV_JUMP);
2771 thread_jumps (insns, max_reg_num (), 1);
2772 timevar_pop (TV_JUMP);
2775 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2777 /* If we are not running more CSE passes, then we are no longer
2778 expecting CSE to be run. But always rerun it in a cheap mode. */
2779 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
2781 if (tem || optimize > 1)
2783 timevar_push (TV_JUMP);
2784 rebuild_jump_labels (insns);
2785 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2786 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2787 timevar_pop (TV_JUMP);
2788 /* CFG is no longer maintained up-to-date. */
2789 free_bb_for_insn ();
2792 /* Run this after jump optmizations remove all the unreachable code
2793 so that unreachable code will not keep values live. */
2794 delete_trivially_dead_insns (insns, max_reg_num (), 0);
2796 /* Try to identify useless null pointer tests and delete them. */
2797 if (flag_delete_null_pointer_checks)
2799 timevar_push (TV_JUMP);
2800 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2802 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2804 delete_null_pointer_checks (insns);
2805 /* CFG is no longer maintained up-to-date. */
2806 free_bb_for_insn ();
2807 timevar_pop (TV_JUMP);
2810 /* The second pass of jump optimization is likely to have
2811 removed a bunch more instructions. */
2812 renumber_insns (rtl_dump_file);
2814 timevar_pop (TV_CSE);
2815 close_dump_file (DFI_cse, print_rtl, insns);
2818 open_dump_file (DFI_addressof, decl);
2820 purge_addressof (insns);
2821 reg_scan (insns, max_reg_num (), 1);
2823 close_dump_file (DFI_addressof, print_rtl, insns);
2825 ggc_collect ();
2827 /* Perform global cse. */
2829 if (optimize > 0 && flag_gcse)
2831 int save_csb, save_cfj;
2832 int tem2 = 0;
2834 timevar_push (TV_GCSE);
2835 open_dump_file (DFI_gcse, decl);
2837 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2838 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2839 tem = gcse_main (insns, rtl_dump_file);
2841 save_csb = flag_cse_skip_blocks;
2842 save_cfj = flag_cse_follow_jumps;
2843 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
2845 /* CFG is no longer maintained up-to-date. */
2846 free_bb_for_insn ();
2847 /* If -fexpensive-optimizations, re-run CSE to clean up things done
2848 by gcse. */
2849 if (flag_expensive_optimizations)
2851 timevar_push (TV_CSE);
2852 reg_scan (insns, max_reg_num (), 1);
2853 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2854 timevar_pop (TV_CSE);
2855 cse_not_expected = !flag_rerun_cse_after_loop;
2858 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
2859 things up. Then possibly re-run CSE again. */
2860 while (tem || tem2)
2862 tem = tem2 = 0;
2863 timevar_push (TV_JUMP);
2864 rebuild_jump_labels (insns);
2865 delete_trivially_dead_insns (insns, max_reg_num (), 0);
2866 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2867 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2868 /* CFG is no longer maintained up-to-date. */
2869 free_bb_for_insn ();
2870 timevar_pop (TV_JUMP);
2872 if (flag_expensive_optimizations)
2874 timevar_push (TV_CSE);
2875 reg_scan (insns, max_reg_num (), 1);
2876 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2877 timevar_pop (TV_CSE);
2881 close_dump_file (DFI_gcse, print_rtl, insns);
2882 timevar_pop (TV_GCSE);
2884 ggc_collect ();
2885 flag_cse_skip_blocks = save_csb;
2886 flag_cse_follow_jumps = save_cfj;
2889 /* Move constant computations out of loops. */
2891 if (optimize > 0)
2893 timevar_push (TV_LOOP);
2894 open_dump_file (DFI_loop, decl);
2895 free_bb_for_insn ();
2897 if (flag_rerun_loop_opt)
2899 cleanup_barriers ();
2901 /* We only want to perform unrolling once. */
2903 loop_optimize (insns, rtl_dump_file, 0);
2905 /* The first call to loop_optimize makes some instructions
2906 trivially dead. We delete those instructions now in the
2907 hope that doing so will make the heuristics in loop work
2908 better and possibly speed up compilation. */
2909 delete_trivially_dead_insns (insns, max_reg_num (), 0);
2911 /* The regscan pass is currently necessary as the alias
2912 analysis code depends on this information. */
2913 reg_scan (insns, max_reg_num (), 1);
2915 cleanup_barriers ();
2916 loop_optimize (insns, rtl_dump_file,
2917 (flag_unroll_loops ? LOOP_UNROLL : 0) | LOOP_BCT);
2919 close_dump_file (DFI_loop, print_rtl, insns);
2920 timevar_pop (TV_LOOP);
2922 ggc_collect ();
2925 if (optimize > 0)
2927 timevar_push (TV_CSE2);
2928 open_dump_file (DFI_cse2, decl);
2930 if (flag_rerun_cse_after_loop)
2932 /* Running another jump optimization pass before the second
2933 cse pass sometimes simplifies the RTL enough to allow
2934 the second CSE pass to do a better job. Jump_optimize can change
2935 max_reg_num so we must rerun reg_scan afterwards.
2936 ??? Rework to not call reg_scan so often. */
2937 timevar_push (TV_JUMP);
2939 /* The previous call to loop_optimize makes some instructions
2940 trivially dead. We delete those instructions now in the
2941 hope that doing so will make the heuristics in jump work
2942 better and possibly speed up compilation. */
2943 delete_trivially_dead_insns (insns, max_reg_num (), 0);
2945 reg_scan (insns, max_reg_num (), 0);
2947 timevar_push (TV_IFCVT);
2949 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2950 cleanup_cfg (CLEANUP_EXPENSIVE);
2951 if_convert (0);
2953 timevar_pop(TV_IFCVT);
2955 timevar_pop (TV_JUMP);
2957 /* CFG is no longer maintained up-to-date. */
2958 free_bb_for_insn ();
2959 reg_scan (insns, max_reg_num (), 0);
2960 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
2962 if (tem)
2964 timevar_push (TV_JUMP);
2965 rebuild_jump_labels (insns);
2966 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2967 cleanup_cfg (CLEANUP_EXPENSIVE);
2968 /* CFG is no longer maintained up-to-date. */
2969 free_bb_for_insn ();
2970 timevar_pop (TV_JUMP);
2974 if (flag_thread_jumps)
2976 /* This pass of jump threading straightens out code
2977 that was kinked by loop optimization. */
2978 timevar_push (TV_JUMP);
2979 reg_scan (insns, max_reg_num (), 0);
2980 thread_jumps (insns, max_reg_num (), 0);
2981 timevar_pop (TV_JUMP);
2984 close_dump_file (DFI_cse2, print_rtl, insns);
2985 timevar_pop (TV_CSE2);
2987 ggc_collect ();
2990 cse_not_expected = 1;
2992 regclass_init ();
2994 /* Do control and data flow analysis; wrote some of the results to
2995 the dump file. */
2997 timevar_push (TV_FLOW);
2998 open_dump_file (DFI_cfg, decl);
3000 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3001 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
3002 check_function_return_warnings ();
3004 /* It may make more sense to mark constant functions after dead code is
3005 eliminated by life_analyzis, but we need to do it early, as -fprofile-arcs
3006 may insert code making function non-constant, but we still must consider
3007 it as constant, otherwise -fbranch-probabilities will not read data back.
3009 life_analyzis rarely eliminates modification of external memory.
3011 mark_constant_function ();
3013 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
3015 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3017 timevar_push (TV_BRANCH_PROB);
3018 open_dump_file (DFI_bp, decl);
3020 branch_prob ();
3022 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
3023 timevar_pop (TV_BRANCH_PROB);
3026 open_dump_file (DFI_life, decl);
3027 if (optimize)
3029 struct loops loops;
3031 /* Discover and record the loop depth at the head of each basic
3032 block. The loop infrastructure does the real job for us. */
3033 flow_loops_find (&loops, LOOP_TREE);
3035 /* Estimate using heuristics if no profiling info is available. */
3036 if (flag_guess_branch_prob)
3037 estimate_probability (&loops);
3039 if (rtl_dump_file)
3040 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
3042 flow_loops_free (&loops);
3044 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3045 timevar_pop (TV_FLOW);
3047 no_new_pseudos = 1;
3049 if (warn_uninitialized || extra_warnings)
3051 uninitialized_vars_warning (DECL_INITIAL (decl));
3052 if (extra_warnings)
3053 setjmp_args_warning ();
3056 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3058 ggc_collect ();
3060 /* If -opt, try combining insns through substitution. */
3062 if (optimize > 0)
3064 int rebuild_jump_labels_after_combine = 0;
3066 timevar_push (TV_COMBINE);
3067 open_dump_file (DFI_combine, decl);
3069 rebuild_jump_labels_after_combine
3070 = combine_instructions (insns, max_reg_num ());
3072 /* Always purge dead edges, as we may eliminate an insn throwing
3073 exception. */
3074 rebuild_jump_labels_after_combine |= purge_all_dead_edges (true);
3076 /* Combining insns may have turned an indirect jump into a
3077 direct jump. Rebuid the JUMP_LABEL fields of jumping
3078 instructions. */
3079 if (rebuild_jump_labels_after_combine)
3081 timevar_push (TV_JUMP);
3082 rebuild_jump_labels (insns);
3083 timevar_pop (TV_JUMP);
3085 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3088 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3089 timevar_pop (TV_COMBINE);
3091 ggc_collect ();
3094 /* Rerun if-conversion, as combine may have simplified things enough to
3095 now meet sequence length restrictions. */
3096 if (optimize > 0)
3098 timevar_push (TV_IFCVT);
3099 open_dump_file (DFI_ce, decl);
3101 no_new_pseudos = 0;
3102 if_convert (1);
3103 no_new_pseudos = 1;
3105 close_dump_file (DFI_ce, print_rtl_with_bb, insns);
3106 timevar_pop (TV_IFCVT);
3109 /* Register allocation pre-pass, to reduce number of moves
3110 necessary for two-address machines. */
3111 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3113 timevar_push (TV_REGMOVE);
3114 open_dump_file (DFI_regmove, decl);
3116 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3118 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3119 timevar_pop (TV_REGMOVE);
3121 ggc_collect ();
3124 /* Do unconditional splitting before register allocation to allow machine
3125 description to add extra information not needed previously. */
3126 split_all_insns (1);
3128 /* Any of the several passes since flow1 will have munged register
3129 lifetime data a bit. */
3130 register_life_up_to_date = 0;
3132 #ifdef OPTIMIZE_MODE_SWITCHING
3133 timevar_push (TV_MODE_SWITCH);
3135 no_new_pseudos = 0;
3136 if (optimize_mode_switching (NULL))
3138 /* We did work, and so had to regenerate global life information.
3139 Take advantage of this and don't re-recompute register life
3140 information below. */
3141 register_life_up_to_date = 1;
3143 no_new_pseudos = 1;
3145 timevar_pop (TV_MODE_SWITCH);
3146 #endif
3148 timevar_push (TV_SCHED);
3150 #ifdef INSN_SCHEDULING
3152 /* Print function header into sched dump now
3153 because doing the sched analysis makes some of the dump. */
3154 if (optimize > 0 && flag_schedule_insns)
3156 open_dump_file (DFI_sched, decl);
3158 /* Do control and data sched analysis,
3159 and write some of the results to dump file. */
3161 schedule_insns (rtl_dump_file);
3163 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3165 /* Register lifetime information was updated as part of verifying
3166 the schedule. */
3167 register_life_up_to_date = 1;
3169 #endif
3170 timevar_pop (TV_SCHED);
3172 ggc_collect ();
3174 /* Determine if the current function is a leaf before running reload
3175 since this can impact optimizations done by the prologue and
3176 epilogue thus changing register elimination offsets. */
3177 current_function_is_leaf = leaf_function_p ();
3179 timevar_push (TV_LOCAL_ALLOC);
3180 open_dump_file (DFI_lreg, decl);
3182 /* Allocate pseudo-regs that are used only within 1 basic block.
3184 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3185 jump optimizer after register allocation and reloading are finished. */
3187 if (! register_life_up_to_date)
3188 recompute_reg_usage (insns, ! optimize_size);
3190 /* Allocate the reg_renumber array. */
3191 allocate_reg_info (max_regno, FALSE, TRUE);
3193 /* And the reg_equiv_memory_loc array. */
3194 reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
3196 allocate_initial_values (reg_equiv_memory_loc);
3198 regclass (insns, max_reg_num (), rtl_dump_file);
3199 rebuild_label_notes_after_reload = local_alloc ();
3201 timevar_pop (TV_LOCAL_ALLOC);
3203 if (dump_file[DFI_lreg].enabled)
3205 timevar_push (TV_DUMP);
3207 dump_flow_info (rtl_dump_file);
3208 dump_local_alloc (rtl_dump_file);
3210 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3211 timevar_pop (TV_DUMP);
3214 ggc_collect ();
3216 timevar_push (TV_GLOBAL_ALLOC);
3217 open_dump_file (DFI_greg, decl);
3219 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3220 pass fixing up any insns that are invalid. */
3222 if (optimize)
3223 failure = global_alloc (rtl_dump_file);
3224 else
3226 build_insn_chain (insns);
3227 failure = reload (insns, 0);
3230 timevar_pop (TV_GLOBAL_ALLOC);
3232 if (dump_file[DFI_greg].enabled)
3234 timevar_push (TV_DUMP);
3236 dump_global_regs (rtl_dump_file);
3238 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3239 timevar_pop (TV_DUMP);
3242 if (failure)
3243 goto exit_rest_of_compilation;
3245 ggc_collect ();
3247 open_dump_file (DFI_postreload, decl);
3249 /* Do a very simple CSE pass over just the hard registers. */
3250 if (optimize > 0)
3252 timevar_push (TV_RELOAD_CSE_REGS);
3253 reload_cse_regs (insns);
3254 timevar_pop (TV_RELOAD_CSE_REGS);
3257 /* Register allocation and reloading may have turned an indirect jump into
3258 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3259 jumping instructions. */
3260 if (rebuild_label_notes_after_reload)
3262 timevar_push (TV_JUMP);
3264 rebuild_jump_labels (insns);
3266 timevar_pop (TV_JUMP);
3269 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3271 /* Re-create the death notes which were deleted during reload. */
3272 timevar_push (TV_FLOW2);
3273 open_dump_file (DFI_flow2, decl);
3275 #ifdef ENABLE_CHECKING
3276 verify_flow_info ();
3277 #endif
3279 /* If optimizing, then go ahead and split insns now. */
3280 if (optimize > 0)
3281 split_all_insns (0);
3283 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
3285 /* On some machines, the prologue and epilogue code, or parts thereof,
3286 can be represented as RTL. Doing so lets us schedule insns between
3287 it and the rest of the code and also allows delayed branch
3288 scheduling to operate in the epilogue. */
3289 thread_prologue_and_epilogue_insns (insns);
3291 if (optimize)
3293 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_CROSSJUMP);
3294 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3296 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3297 even for machines with possibly nonzero RETURN_POPS_ARGS
3298 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3299 push instructions will have popping returns. */
3300 #ifndef PUSH_ROUNDING
3301 if (!ACCUMULATE_OUTGOING_ARGS)
3302 #endif
3303 combine_stack_adjustments ();
3305 ggc_collect ();
3308 flow2_completed = 1;
3310 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3311 timevar_pop (TV_FLOW2);
3313 #ifdef HAVE_peephole2
3314 if (optimize > 0 && flag_peephole2)
3316 timevar_push (TV_PEEPHOLE2);
3317 open_dump_file (DFI_peephole2, decl);
3319 peephole2_optimize (rtl_dump_file);
3321 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3322 timevar_pop (TV_PEEPHOLE2);
3324 #endif
3326 if (optimize > 0 && flag_rename_registers)
3328 timevar_push (TV_RENAME_REGISTERS);
3329 open_dump_file (DFI_rnreg, decl);
3331 regrename_optimize ();
3333 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3334 timevar_pop (TV_RENAME_REGISTERS);
3337 if (optimize > 0)
3339 timevar_push (TV_IFCVT2);
3340 open_dump_file (DFI_ce2, decl);
3342 if_convert (1);
3344 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3345 timevar_pop (TV_IFCVT2);
3347 #ifdef STACK_REGS
3348 if (optimize)
3349 split_all_insns (1);
3350 #endif
3352 #ifdef INSN_SCHEDULING
3353 if (optimize > 0 && flag_schedule_insns_after_reload)
3355 timevar_push (TV_SCHED2);
3356 open_dump_file (DFI_sched2, decl);
3358 /* Do control and data sched analysis again,
3359 and write some more of the results to dump file. */
3361 split_all_insns (1);
3363 schedule_insns (rtl_dump_file);
3365 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3366 timevar_pop (TV_SCHED2);
3368 ggc_collect ();
3370 #endif
3372 #ifdef LEAF_REGISTERS
3373 current_function_uses_only_leaf_regs
3374 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3375 #endif
3377 #ifdef STACK_REGS
3378 timevar_push (TV_REG_STACK);
3379 open_dump_file (DFI_stack, decl);
3381 reg_to_stack (insns, rtl_dump_file);
3383 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3384 timevar_pop (TV_REG_STACK);
3386 ggc_collect ();
3387 #endif
3388 if (optimize > 0)
3390 timevar_push (TV_REORDER_BLOCKS);
3391 open_dump_file (DFI_bbro, decl);
3393 /* Last attempt to optimize CFG, as life analyzis possibly removed
3394 some instructions. */
3395 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
3396 | CLEANUP_CROSSJUMP);
3397 if (flag_reorder_blocks)
3399 reorder_basic_blocks ();
3400 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
3403 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3404 timevar_pop (TV_REORDER_BLOCKS);
3406 compute_alignments ();
3408 /* CFG is no longer maintained up-to-date. */
3409 free_bb_for_insn ();
3411 /* If a machine dependent reorganization is needed, call it. */
3412 #ifdef MACHINE_DEPENDENT_REORG
3413 timevar_push (TV_MACH_DEP);
3414 open_dump_file (DFI_mach, decl);
3416 MACHINE_DEPENDENT_REORG (insns);
3418 close_dump_file (DFI_mach, print_rtl, insns);
3419 timevar_pop (TV_MACH_DEP);
3421 ggc_collect ();
3422 #endif
3424 purge_line_number_notes (insns);
3425 cleanup_barriers ();
3427 /* If a scheduling pass for delayed branches is to be done,
3428 call the scheduling code. */
3430 #ifdef DELAY_SLOTS
3431 if (optimize > 0 && flag_delayed_branch)
3433 timevar_push (TV_DBR_SCHED);
3434 open_dump_file (DFI_dbr, decl);
3436 dbr_schedule (insns, rtl_dump_file);
3438 close_dump_file (DFI_dbr, print_rtl, insns);
3439 timevar_pop (TV_DBR_SCHED);
3441 ggc_collect ();
3443 #endif
3445 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3446 timevar_push (TV_SHORTEN_BRANCH);
3447 split_all_insns_noflow ();
3448 timevar_pop (TV_SHORTEN_BRANCH);
3449 #endif
3451 convert_to_eh_region_ranges ();
3453 /* Shorten branches. */
3454 timevar_push (TV_SHORTEN_BRANCH);
3455 shorten_branches (get_insns ());
3456 timevar_pop (TV_SHORTEN_BRANCH);
3458 current_function_nothrow = nothrow_function_p ();
3459 if (current_function_nothrow)
3460 /* Now we know that this can't throw; set the flag for the benefit
3461 of other functions later in this translation unit. */
3462 TREE_NOTHROW (current_function_decl) = 1;
3464 /* Now turn the rtl into assembler code. */
3466 timevar_push (TV_FINAL);
3468 rtx x;
3469 const char *fnname;
3471 /* Get the function's name, as described by its RTL. This may be
3472 different from the DECL_NAME name used in the source file. */
3474 x = DECL_RTL (decl);
3475 if (GET_CODE (x) != MEM)
3476 abort ();
3477 x = XEXP (x, 0);
3478 if (GET_CODE (x) != SYMBOL_REF)
3479 abort ();
3480 fnname = XSTR (x, 0);
3482 assemble_start_function (decl, fnname);
3483 final_start_function (insns, asm_out_file, optimize);
3484 final (insns, asm_out_file, optimize, 0);
3485 final_end_function ();
3487 #ifdef IA64_UNWIND_INFO
3488 /* ??? The IA-64 ".handlerdata" directive must be issued before
3489 the ".endp" directive that closes the procedure descriptor. */
3490 output_function_exception_table ();
3491 #endif
3493 assemble_end_function (decl, fnname);
3495 #ifndef IA64_UNWIND_INFO
3496 /* Otherwise, it feels unclean to switch sections in the middle. */
3497 output_function_exception_table ();
3498 #endif
3500 if (! quiet_flag)
3501 fflush (asm_out_file);
3503 /* Release all memory allocated by flow. */
3504 free_basic_block_vars (0);
3506 /* Release all memory held by regsets now. */
3507 regset_release_memory ();
3509 timevar_pop (TV_FINAL);
3511 ggc_collect ();
3513 /* Write DBX symbols if requested. */
3515 /* Note that for those inline functions where we don't initially
3516 know for certain that we will be generating an out-of-line copy,
3517 the first invocation of this routine (rest_of_compilation) will
3518 skip over this code by doing a `goto exit_rest_of_compilation;'.
3519 Later on, finish_compilation will call rest_of_compilation again
3520 for those inline functions that need to have out-of-line copies
3521 generated. During that call, we *will* be routed past here. */
3523 timevar_push (TV_SYMOUT);
3524 (*debug_hooks->function_decl) (decl);
3525 timevar_pop (TV_SYMOUT);
3527 exit_rest_of_compilation:
3529 /* In case the function was not output,
3530 don't leave any temporary anonymous types
3531 queued up for sdb output. */
3532 #ifdef SDB_DEBUGGING_INFO
3533 if (write_symbols == SDB_DEBUG)
3534 sdbout_types (NULL_TREE);
3535 #endif
3537 reload_completed = 0;
3538 flow2_completed = 0;
3539 no_new_pseudos = 0;
3541 timevar_push (TV_FINAL);
3543 /* Clear out the insn_length contents now that they are no
3544 longer valid. */
3545 init_insn_lengths ();
3547 /* Clear out the real_constant_chain before some of the rtx's
3548 it runs through become garbage. */
3549 clear_const_double_mem ();
3551 /* Show no temporary slots allocated. */
3552 init_temp_slots ();
3554 free_basic_block_vars (0);
3556 timevar_pop (TV_FINAL);
3558 /* Make sure volatile mem refs aren't considered valid operands for
3559 arithmetic insns. We must call this here if this is a nested inline
3560 function, since the above code leaves us in the init_recog state
3561 (from final.c), and the function context push/pop code does not
3562 save/restore volatile_ok.
3564 ??? Maybe it isn't necessary for expand_start_function to call this
3565 anymore if we do it here? */
3567 init_recog_no_volatile ();
3569 /* We're done with this function. Free up memory if we can. */
3570 free_after_parsing (cfun);
3571 if (! DECL_DEFER_OUTPUT (decl))
3573 free_after_compilation (cfun);
3575 /* Clear integrate.c's pointer to the cfun structure we just
3576 destroyed. */
3577 DECL_SAVED_INSNS (decl) = 0;
3579 cfun = 0;
3581 ggc_collect ();
3583 timevar_pop (TV_REST_OF_COMPILATION);
3586 static void
3587 display_help ()
3589 int undoc;
3590 unsigned long i;
3591 const char *lang;
3593 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3594 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3595 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3596 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3597 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3598 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"));
3600 for (i = ARRAY_SIZE (f_options); i--;)
3602 const char *description = f_options[i].description;
3604 if (description != NULL && * description != 0)
3605 printf (" -f%-21s %s\n",
3606 f_options[i].string, _(description));
3609 printf (_(" -O[number] Set optimisation level to [number]\n"));
3610 printf (_(" -Os Optimise for space rather than speed\n"));
3611 for (i = LAST_PARAM; i--;)
3613 const char *description = compiler_params[i].help;
3614 const int length = 21-strlen(compiler_params[i].option);
3616 if (description != NULL && * description != 0)
3617 printf (" --param %s=<value>%.*s%s\n",
3618 compiler_params[i].option,
3619 length > 0 ? length : 1, " ",
3620 _(description));
3622 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3623 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3624 printf (_(" -w Suppress warnings\n"));
3625 printf (_(" -W Enable extra warnings\n"));
3627 for (i = ARRAY_SIZE (W_options); i--;)
3629 const char *description = W_options[i].description;
3631 if (description != NULL && * description != 0)
3632 printf (" -W%-21s %s\n",
3633 W_options[i].string, _(description));
3636 printf (_(" -Wunused Enable unused warnings\n"));
3637 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3638 printf (_(" -p Enable function profiling\n"));
3639 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3640 printf (_(" -a Enable block profiling \n"));
3641 #endif
3642 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3643 printf (_(" -ax Enable jump profiling \n"));
3644 #endif
3645 printf (_(" -o <file> Place output into <file> \n"));
3646 printf (_("\
3647 -G <number> Put global and static data smaller than <number>\n\
3648 bytes into a special section (on some targets)\n"));
3650 for (i = ARRAY_SIZE (debug_args); i--;)
3652 if (debug_args[i].description != NULL)
3653 printf (" -g%-21s %s\n",
3654 debug_args[i].arg, _(debug_args[i].description));
3657 printf (_(" -aux-info <file> Emit declaration info into <file>\n"));
3658 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3659 printf (_(" -version Display the compiler's version\n"));
3660 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3661 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3662 #if defined INSN_SCHEDULING
3663 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3664 #endif
3665 printf (_(" --help Display this information\n"));
3667 undoc = 0;
3668 lang = "language";
3670 /* Display descriptions of language specific options.
3671 If there is no description, note that there is an undocumented option.
3672 If the description is empty, do not display anything. (This allows
3673 options to be deliberately undocumented, for whatever reason).
3674 If the option string is missing, then this is a marker, indicating
3675 that the description string is in fact the name of a language, whose
3676 language specific options are to follow. */
3678 if (ARRAY_SIZE (documented_lang_options) > 1)
3680 printf (_("\nLanguage specific options:\n"));
3682 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3684 const char *description = documented_lang_options[i].description;
3685 const char *option = documented_lang_options[i].option;
3687 if (description == NULL)
3689 undoc = 1;
3691 if (extra_warnings)
3692 printf (_(" %-23.23s [undocumented]\n"), option);
3694 else if (*description == 0)
3695 continue;
3696 else if (option == NULL)
3698 if (undoc)
3699 printf
3700 (_("\nThere are undocumented %s specific options as well.\n"),
3701 lang);
3702 undoc = 0;
3704 printf (_("\n Options for %s:\n"), description);
3706 lang = description;
3708 else
3709 printf (" %-23.23s %s\n", option, _(description));
3713 if (undoc)
3714 printf (_("\nThere are undocumented %s specific options as well.\n"),
3715 lang);
3717 display_target_options ();
3720 static void
3721 display_target_options ()
3723 int undoc,i;
3725 if (ARRAY_SIZE (target_switches) > 1
3726 #ifdef TARGET_OPTIONS
3727 || ARRAY_SIZE (target_options) > 1
3728 #endif
3731 int doc = 0;
3733 undoc = 0;
3735 printf (_("\nTarget specific options:\n"));
3737 for (i = ARRAY_SIZE (target_switches); i--;)
3739 const char *option = target_switches[i].name;
3740 const char *description = target_switches[i].description;
3742 if (option == NULL || *option == 0)
3743 continue;
3744 else if (description == NULL)
3746 undoc = 1;
3748 if (extra_warnings)
3749 printf (_(" -m%-23.23s [undocumented]\n"), option);
3751 else if (* description != 0)
3752 doc += printf (" -m%-23.23s %s\n", option, _(description));
3755 #ifdef TARGET_OPTIONS
3756 for (i = ARRAY_SIZE (target_options); i--;)
3758 const char *option = target_options[i].prefix;
3759 const char *description = target_options[i].description;
3761 if (option == NULL || *option == 0)
3762 continue;
3763 else if (description == NULL)
3765 undoc = 1;
3767 if (extra_warnings)
3768 printf (_(" -m%-23.23s [undocumented]\n"), option);
3770 else if (* description != 0)
3771 doc += printf (" -m%-23.23s %s\n", option, _(description));
3773 #endif
3774 if (undoc)
3776 if (doc)
3777 printf (_("\nThere are undocumented target specific options as well.\n"));
3778 else
3779 printf (_(" They exist, but they are not documented.\n"));
3784 /* Parse a -d... command line switch. */
3786 static void
3787 decode_d_option (arg)
3788 const char *arg;
3790 int i, c, matched;
3792 while (*arg)
3793 switch (c = *arg++)
3795 case 'a':
3796 for (i = 0; i < (int) DFI_MAX; ++i)
3797 dump_file[i].enabled = 1;
3798 break;
3799 case 'A':
3800 flag_debug_asm = 1;
3801 break;
3802 case 'p':
3803 flag_print_asm_name = 1;
3804 break;
3805 case 'P':
3806 flag_dump_rtl_in_asm = 1;
3807 flag_print_asm_name = 1;
3808 break;
3809 case 'v':
3810 graph_dump_format = vcg;
3811 break;
3812 case 'x':
3813 rtl_dump_and_exit = 1;
3814 break;
3815 case 'y':
3816 (*lang_hooks.set_yydebug) (1);
3817 break;
3818 case 'D': /* These are handled by the preprocessor. */
3819 case 'I':
3820 break;
3822 default:
3823 matched = 0;
3824 for (i = 0; i < (int) DFI_MAX; ++i)
3825 if (c == dump_file[i].debug_switch)
3827 dump_file[i].enabled = 1;
3828 matched = 1;
3831 if (! matched)
3832 warning ("unrecognized gcc debugging option: %c", c);
3833 break;
3837 /* Parse a -f... command line switch. ARG is the value after the -f.
3838 It is safe to access 'ARG - 2' to generate the full switch name.
3839 Return the number of strings consumed. */
3841 static int
3842 decode_f_option (arg)
3843 const char *arg;
3845 int j;
3846 const char *option_value = NULL;
3848 /* Search for the option in the table of binary f options. */
3849 for (j = ARRAY_SIZE (f_options); j--;)
3851 if (!strcmp (arg, f_options[j].string))
3853 *f_options[j].variable = f_options[j].on_value;
3854 return 1;
3857 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3858 && ! strcmp (arg + 3, f_options[j].string))
3860 *f_options[j].variable = ! f_options[j].on_value;
3861 return 1;
3865 if (!strcmp (arg, "fast-math"))
3866 set_fast_math_flags();
3867 else if (!strcmp (arg, "no-fast-math"))
3868 set_no_fast_math_flags();
3869 else if ((option_value = skip_leading_substring (arg, "inline-limit-"))
3870 || (option_value = skip_leading_substring (arg, "inline-limit=")))
3872 int val =
3873 read_integral_parameter (option_value, arg - 2,
3874 MAX_INLINE_INSNS);
3875 set_param_value ("max-inline-insns", val);
3877 #ifdef INSN_SCHEDULING
3878 else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
3879 fix_sched_param ("verbose", option_value);
3880 #endif
3881 else if ((option_value = skip_leading_substring (arg, "fixed-")))
3882 fix_register (option_value, 1, 1);
3883 else if ((option_value = skip_leading_substring (arg, "call-used-")))
3884 fix_register (option_value, 0, 1);
3885 else if ((option_value = skip_leading_substring (arg, "call-saved-")))
3886 fix_register (option_value, 0, 0);
3887 else if ((option_value = skip_leading_substring (arg, "align-loops=")))
3888 align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
3889 else if ((option_value = skip_leading_substring (arg, "align-functions=")))
3890 align_functions
3891 = read_integral_parameter (option_value, arg - 2, align_functions);
3892 else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
3893 align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
3894 else if ((option_value = skip_leading_substring (arg, "align-labels=")))
3895 align_labels
3896 = read_integral_parameter (option_value, arg - 2, align_labels);
3897 else if ((option_value
3898 = skip_leading_substring (arg, "stack-limit-register=")))
3900 int reg = decode_reg_name (option_value);
3901 if (reg < 0)
3902 error ("unrecognized register name `%s'", option_value);
3903 else
3904 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
3906 else if ((option_value
3907 = skip_leading_substring (arg, "stack-limit-symbol=")))
3909 const char *nm;
3910 nm = ggc_strdup (option_value);
3911 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
3913 else if ((option_value
3914 = skip_leading_substring (arg, "message-length=")))
3915 output_set_maximum_length
3916 (&global_dc->buffer, read_integral_parameter
3917 (option_value, arg - 2, diagnostic_line_cutoff (global_dc)));
3918 else if ((option_value
3919 = skip_leading_substring (arg, "diagnostics-show-location=")))
3921 if (!strcmp (option_value, "once"))
3922 diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
3923 else if (!strcmp (option_value, "every-line"))
3924 diagnostic_prefixing_rule (global_dc)
3925 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
3926 else
3927 error ("Unrecognized option `%s'", arg - 2);
3929 else if (!strcmp (arg, "no-stack-limit"))
3930 stack_limit_rtx = NULL_RTX;
3931 else if (!strcmp (arg, "preprocessed"))
3932 /* Recognise this switch but do nothing. This prevents warnings
3933 about an unrecognized switch if cpplib has not been linked in. */
3935 else
3936 return 0;
3938 return 1;
3941 /* Parse a -W... command line switch. ARG is the value after the -W.
3942 It is safe to access 'ARG - 2' to generate the full switch name.
3943 Return the number of strings consumed. */
3945 static int
3946 decode_W_option (arg)
3947 const char *arg;
3949 const char *option_value = NULL;
3950 int j;
3952 /* Search for the option in the table of binary W options. */
3954 for (j = ARRAY_SIZE (W_options); j--;)
3956 if (!strcmp (arg, W_options[j].string))
3958 *W_options[j].variable = W_options[j].on_value;
3959 return 1;
3962 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3963 && ! strcmp (arg + 3, W_options[j].string))
3965 *W_options[j].variable = ! W_options[j].on_value;
3966 return 1;
3970 if ((option_value = skip_leading_substring (arg, "id-clash-")))
3971 warning ("-Wid-clash-LEN is no longer supported");
3972 else if ((option_value = skip_leading_substring (arg, "larger-than-")))
3974 larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
3976 warn_larger_than = larger_than_size != -1;
3978 else if (!strcmp (arg, "unused"))
3980 set_Wunused (1);
3982 else if (!strcmp (arg, "no-unused"))
3984 set_Wunused (0);
3986 else
3987 return 0;
3989 return 1;
3992 /* Parse a -g... command line switch. ARG is the value after the -g.
3993 It is safe to access 'ARG - 2' to generate the full switch name.
3994 Return the number of strings consumed. */
3996 static int
3997 decode_g_option (arg)
3998 const char *arg;
4000 static unsigned level=0;
4001 /* A lot of code assumes write_symbols == NO_DEBUG if the
4002 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4003 of what debugging type has been selected). This records the
4004 selected type. It is an error to specify more than one
4005 debugging type. */
4006 static enum debug_info_type selected_debug_type = NO_DEBUG;
4007 /* Non-zero if debugging format has been explicitly set.
4008 -g and -ggdb don't explicitly set the debugging format so
4009 -gdwarf -g3 is equivalent to -gdwarf3. */
4010 static int type_explicitly_set_p = 0;
4011 /* Indexed by enum debug_info_type. */
4012 static const char *const debug_type_names[] =
4014 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4017 /* The maximum admissible debug level value. */
4018 static const unsigned max_debug_level = 3;
4020 /* Look up ARG in the table. */
4021 for (da = debug_args; da->arg; da++)
4023 const int da_len = strlen (da->arg);
4025 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4027 enum debug_info_type type = da->debug_type;
4028 const char *p = arg + da_len;
4030 if (*p && ! ISDIGIT (*p))
4031 continue;
4033 /* A debug flag without a level defaults to level 2.
4034 Note we do not want to call read_integral_parameter
4035 for that case since it will call atoi which
4036 will return zero.
4038 ??? We may want to generalize the interface to
4039 read_integral_parameter to better handle this case
4040 if this case shows up often. */
4041 if (*p)
4042 level = read_integral_parameter (p, 0, max_debug_level + 1);
4043 else
4044 level = (level == 0) ? 2 : level;
4046 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4048 error ("use -gdwarf -g%d for DWARF v1, level %d",
4049 level, level);
4050 if (level == 2)
4051 error ("use -gdwarf-2 for DWARF v2");
4054 if (level > max_debug_level)
4056 warning ("\
4057 ignoring option `%s' due to invalid debug level specification",
4058 arg - 2);
4059 level = debug_info_level;
4062 if (type == NO_DEBUG)
4064 type = PREFERRED_DEBUGGING_TYPE;
4066 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4068 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4069 type = DWARF2_DEBUG;
4070 #else
4071 #ifdef DBX_DEBUGGING_INFO
4072 type = DBX_DEBUG;
4073 #endif
4074 #endif
4078 if (type == NO_DEBUG)
4079 warning ("`%s': unknown or unsupported -g option", arg - 2);
4081 /* Does it conflict with an already selected type? */
4082 if (type_explicitly_set_p
4083 /* -g/-ggdb don't conflict with anything. */
4084 && da->debug_type != NO_DEBUG
4085 && type != selected_debug_type)
4086 warning ("`%s' ignored, conflicts with `-g%s'",
4087 arg - 2, debug_type_names[(int) selected_debug_type]);
4088 else
4090 /* If the format has already been set, -g/-ggdb
4091 only change the debug level. */
4092 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4093 /* Don't change debugging type. */
4095 else
4097 selected_debug_type = type;
4098 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4101 write_symbols = (level == 0
4102 ? NO_DEBUG
4103 : selected_debug_type);
4104 use_gnu_debug_info_extensions = da->use_extensions_p;
4105 debug_info_level = (enum debug_info_level) level;
4108 break;
4112 if (! da->arg)
4113 return 0;
4115 return 1;
4118 /* Decode the first argument in the argv as a language-independent option.
4119 Return the number of strings consumed. */
4121 static unsigned int
4122 independent_decode_option (argc, argv)
4123 int argc;
4124 char **argv;
4126 char *arg = argv[0];
4128 if (arg[0] != '-' || arg[1] == 0)
4130 if (arg[0] == '+')
4131 return 0;
4133 filename = arg;
4135 return 1;
4138 arg++;
4140 if (!strcmp (arg, "-help"))
4142 display_help ();
4143 exit_after_options = 1;
4146 if (!strcmp (arg, "-target-help"))
4148 display_target_options ();
4149 exit_after_options = 1;
4152 if (!strcmp (arg, "-version"))
4154 print_version (stderr, "");
4155 exit_after_options = 1;
4158 /* Handle '--param <name>=<value>'. */
4159 if (strcmp (arg, "-param") == 0)
4161 char *equal;
4163 if (argc == 1)
4165 error ("-param option missing argument");
4166 return 1;
4169 /* Get the '<name>=<value>' parameter. */
4170 arg = argv[1];
4171 /* Look for the `='. */
4172 equal = strchr (arg, '=');
4173 if (!equal)
4174 error ("invalid --param option: %s", arg);
4175 else
4177 int val;
4179 /* Zero out the `=' sign so that we get two separate strings. */
4180 *equal = '\0';
4181 /* Figure out what value is specified. */
4182 val = read_integral_parameter (equal + 1, NULL, INVALID_PARAM_VAL);
4183 if (val != INVALID_PARAM_VAL)
4184 set_param_value (arg, val);
4185 else
4186 error ("invalid parameter value `%s'", equal + 1);
4189 return 2;
4192 if (*arg == 'Y')
4193 arg++;
4195 switch (*arg)
4197 default:
4198 return 0;
4200 case 'O':
4201 /* Already been treated in main (). Do nothing. */
4202 break;
4204 case 'm':
4205 set_target_switch (arg + 1);
4206 break;
4208 case 'f':
4209 return decode_f_option (arg + 1);
4211 case 'g':
4212 return decode_g_option (arg + 1);
4214 case 'd':
4215 if (!strcmp (arg, "dumpbase"))
4217 if (argc == 1)
4218 return 0;
4220 dump_base_name = argv[1];
4221 return 2;
4223 else
4224 decode_d_option (arg + 1);
4225 break;
4227 case 'p':
4228 if (!strcmp (arg, "pedantic"))
4229 pedantic = 1;
4230 else if (!strcmp (arg, "pedantic-errors"))
4231 flag_pedantic_errors = pedantic = 1;
4232 else if (arg[1] == 0)
4233 profile_flag = 1;
4234 else
4235 return 0;
4236 break;
4238 case 'q':
4239 if (!strcmp (arg, "quiet"))
4240 quiet_flag = 1;
4241 else
4242 return 0;
4243 break;
4245 case 'v':
4246 if (!strcmp (arg, "version"))
4247 version_flag = 1;
4248 else
4249 return 0;
4250 break;
4252 case 'w':
4253 if (arg[1] == 0)
4254 inhibit_warnings = 1;
4255 else
4256 return 0;
4257 break;
4259 case 'W':
4260 if (arg[1] == 0)
4262 extra_warnings = 1;
4263 /* We save the value of warn_uninitialized, since if they put
4264 -Wuninitialized on the command line, we need to generate a
4265 warning about not using it without also specifying -O. */
4266 if (warn_uninitialized != 1)
4267 warn_uninitialized = 2;
4269 else
4270 return decode_W_option (arg + 1);
4271 break;
4273 case 'a':
4274 if (arg[1] == 0)
4276 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4277 warning ("`-a' option (basic block profile) not supported");
4278 #else
4279 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4280 #endif
4282 else if (!strcmp (arg, "ax"))
4284 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4285 warning ("`-ax' option (jump profiling) not supported");
4286 #else
4287 profile_block_flag = (!profile_block_flag
4288 || profile_block_flag == 2) ? 2 : 3;
4289 #endif
4291 else if (!strncmp (arg, "aux-info", 8))
4293 if (arg[8] == '\0')
4295 if (argc == 1)
4296 return 0;
4298 aux_info_file_name = argv[1];
4299 flag_gen_aux_info = 1;
4300 return 2;
4302 else if (arg[8] == '=')
4304 aux_info_file_name = arg + 9;
4305 flag_gen_aux_info = 1;
4307 else
4308 return 0;
4310 else
4311 return 0;
4312 break;
4314 case 'o':
4315 if (arg[1] == 0)
4317 if (argc == 1)
4318 return 0;
4320 asm_file_name = argv[1];
4321 return 2;
4323 return 0;
4325 case 'G':
4327 int g_switch_val;
4328 int return_val;
4330 if (arg[1] == 0)
4332 if (argc == 1)
4333 return 0;
4335 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4336 return_val = 2;
4338 else
4340 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4341 return_val = 1;
4344 if (g_switch_val == -1)
4345 return_val = 0;
4346 else
4348 g_switch_set = TRUE;
4349 g_switch_value = g_switch_val;
4352 return return_val;
4356 return 1;
4359 /* Decode -m switches. */
4360 /* Decode the switch -mNAME. */
4362 static void
4363 set_target_switch (name)
4364 const char *name;
4366 size_t j;
4367 int valid_target_option = 0;
4369 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4370 if (!strcmp (target_switches[j].name, name))
4372 if (target_switches[j].value < 0)
4373 target_flags &= ~-target_switches[j].value;
4374 else
4375 target_flags |= target_switches[j].value;
4376 valid_target_option = 1;
4379 #ifdef TARGET_OPTIONS
4380 if (!valid_target_option)
4381 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4383 int len = strlen (target_options[j].prefix);
4384 if (!strncmp (target_options[j].prefix, name, len))
4386 *target_options[j].variable = name + len;
4387 valid_target_option = 1;
4390 #endif
4392 if (!valid_target_option)
4393 error ("Invalid option `%s'", name);
4396 /* Print version information to FILE.
4397 Each line begins with INDENT (for the case where FILE is the
4398 assembler output file). */
4400 static void
4401 print_version (file, indent)
4402 FILE *file;
4403 const char *indent;
4405 #ifndef __VERSION__
4406 #define __VERSION__ "[?]"
4407 #endif
4408 fnotice (file,
4409 #ifdef __GNUC__
4410 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
4411 #else
4412 "%s%s%s version %s (%s) compiled by CC.\n"
4413 #endif
4414 , indent, *indent != 0 ? " " : "",
4415 lang_hooks.name, version_string, TARGET_NAME,
4416 indent, __VERSION__);
4419 /* Print an option value and return the adjusted position in the line.
4420 ??? We don't handle error returns from fprintf (disk full); presumably
4421 other code will catch a disk full though. */
4423 static int
4424 print_single_switch (file, pos, max, indent, sep, term, type, name)
4425 FILE *file;
4426 int pos, max;
4427 const char *indent, *sep, *term, *type, *name;
4429 /* The ultrix fprintf returns 0 on success, so compute the result we want
4430 here since we need it for the following test. */
4431 int len = strlen (sep) + strlen (type) + strlen (name);
4433 if (pos != 0
4434 && pos + len > max)
4436 fprintf (file, "%s", term);
4437 pos = 0;
4439 if (pos == 0)
4441 fprintf (file, "%s", indent);
4442 pos = strlen (indent);
4444 fprintf (file, "%s%s%s", sep, type, name);
4445 pos += len;
4446 return pos;
4449 /* Print active target switches to FILE.
4450 POS is the current cursor position and MAX is the size of a "line".
4451 Each line begins with INDENT and ends with TERM.
4452 Each switch is separated from the next by SEP. */
4454 static void
4455 print_switch_values (file, pos, max, indent, sep, term)
4456 FILE *file;
4457 int pos, max;
4458 const char *indent, *sep, *term;
4460 size_t j;
4461 char **p;
4463 /* Print the options as passed. */
4465 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4466 _("options passed: "), "");
4468 for (p = &save_argv[1]; *p != NULL; p++)
4469 if (**p == '-')
4471 /* Ignore these. */
4472 if (strcmp (*p, "-o") == 0)
4474 if (p[1] != NULL)
4475 p++;
4476 continue;
4478 if (strcmp (*p, "-quiet") == 0)
4479 continue;
4480 if (strcmp (*p, "-version") == 0)
4481 continue;
4482 if ((*p)[1] == 'd')
4483 continue;
4485 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4487 if (pos > 0)
4488 fprintf (file, "%s", term);
4490 /* Print the -f and -m options that have been enabled.
4491 We don't handle language specific options but printing argv
4492 should suffice. */
4494 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4495 _("options enabled: "), "");
4497 for (j = 0; j < ARRAY_SIZE (f_options); j++)
4498 if (*f_options[j].variable == f_options[j].on_value)
4499 pos = print_single_switch (file, pos, max, indent, sep, term,
4500 "-f", f_options[j].string);
4502 /* Print target specific options. */
4504 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4505 if (target_switches[j].name[0] != '\0'
4506 && target_switches[j].value > 0
4507 && ((target_switches[j].value & target_flags)
4508 == target_switches[j].value))
4510 pos = print_single_switch (file, pos, max, indent, sep, term,
4511 "-m", target_switches[j].name);
4514 #ifdef TARGET_OPTIONS
4515 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4516 if (*target_options[j].variable != NULL)
4518 char prefix[256];
4519 sprintf (prefix, "-m%s", target_options[j].prefix);
4520 pos = print_single_switch (file, pos, max, indent, sep, term,
4521 prefix, *target_options[j].variable);
4523 #endif
4525 fprintf (file, "%s", term);
4528 /* Open assembly code output file. Do this even if -fsyntax-only is
4529 on, because then the driver will have provided the name of a
4530 temporary file or bit bucket for us. NAME is the file specified on
4531 the command line, possibly NULL. */
4532 static void
4533 init_asm_output (name)
4534 const char *name;
4536 if (name == NULL && asm_file_name == 0)
4537 asm_out_file = stdout;
4538 else
4540 if (asm_file_name == 0)
4542 int len = strlen (dump_base_name);
4543 char *dumpname = (char *) xmalloc (len + 6);
4544 memcpy (dumpname, dump_base_name, len + 1);
4545 strip_off_ending (dumpname, len);
4546 strcat (dumpname, ".s");
4547 asm_file_name = dumpname;
4549 if (!strcmp (asm_file_name, "-"))
4550 asm_out_file = stdout;
4551 else
4552 asm_out_file = fopen (asm_file_name, "w");
4553 if (asm_out_file == 0)
4554 fatal_io_error ("can't open %s for writing", asm_file_name);
4557 #ifdef IO_BUFFER_SIZE
4558 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
4559 _IOFBF, IO_BUFFER_SIZE);
4560 #endif
4562 if (!flag_syntax_only)
4564 #ifdef ASM_FILE_START
4565 ASM_FILE_START (asm_out_file);
4566 #endif
4568 #ifdef ASM_COMMENT_START
4569 if (flag_verbose_asm)
4571 /* Print the list of options in effect. */
4572 print_version (asm_out_file, ASM_COMMENT_START);
4573 print_switch_values (asm_out_file, 0, MAX_LINE,
4574 ASM_COMMENT_START, " ", "\n");
4575 /* Add a blank line here so it appears in assembler output but not
4576 screen output. */
4577 fprintf (asm_out_file, "\n");
4579 #endif
4583 /* Initialization of the front end environment, before command line
4584 options are parsed. Signal handlers, internationalization etc.
4585 ARGV0 is main's argv[0]. */
4586 static void
4587 general_init (argv0)
4588 char *argv0;
4590 char *p;
4592 p = argv0 + strlen (argv0);
4593 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4594 --p;
4595 progname = p;
4597 xmalloc_set_program_name (progname);
4599 gcc_init_libintl ();
4601 /* Install handler for SIGFPE, which may be received while we do
4602 compile-time floating point arithmetic. */
4603 signal (SIGFPE, float_signal);
4605 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4606 #ifdef SIGSEGV
4607 signal (SIGSEGV, crash_signal);
4608 #endif
4609 #ifdef SIGILL
4610 signal (SIGILL, crash_signal);
4611 #endif
4612 #ifdef SIGBUS
4613 signal (SIGBUS, crash_signal);
4614 #endif
4615 #ifdef SIGABRT
4616 signal (SIGABRT, crash_signal);
4617 #endif
4618 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4619 signal (SIGIOT, crash_signal);
4620 #endif
4622 /* Initialize the diagnostics reporting machinery, so option parsing
4623 can give warnings and errors. */
4624 diagnostic_initialize (global_dc);
4627 /* Parse command line options and set default flag values, called
4628 after language-independent option-independent intialization. Do
4629 minimal options processing. Outputting diagnostics is OK, but GC
4630 and identifier hashtables etc. are not initialized yet. */
4631 static void
4632 parse_options_and_default_flags (argc, argv)
4633 int argc;
4634 char **argv;
4636 int i;
4638 /* Save in case md file wants to emit args as a comment. */
4639 save_argc = argc;
4640 save_argv = argv;
4642 /* Initialize register usage now so switches may override. */
4643 init_reg_sets ();
4645 /* Register the language-independent parameters. */
4646 add_params (lang_independent_params, LAST_PARAM);
4648 /* Perform language-specific options initialization. */
4649 (*lang_hooks.init_options) ();
4651 /* Scan to see what optimization level has been specified. That will
4652 determine the default value of many flags. */
4653 for (i = 1; i < argc; i++)
4655 if (!strcmp (argv[i], "-O"))
4657 optimize = 1;
4658 optimize_size = 0;
4660 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4662 /* Handle -Os, -O2, -O3, -O69, ... */
4663 char *p = &argv[i][2];
4665 if ((p[0] == 's') && (p[1] == 0))
4667 optimize_size = 1;
4669 /* Optimizing for size forces optimize to be 2. */
4670 optimize = 2;
4672 else
4674 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4675 if (optimize_val != -1)
4677 optimize = optimize_val;
4678 optimize_size = 0;
4684 if (!optimize)
4686 flag_merge_constants = 0;
4689 if (optimize >= 1)
4691 flag_defer_pop = 1;
4692 flag_thread_jumps = 1;
4693 #ifdef DELAY_SLOTS
4694 flag_delayed_branch = 1;
4695 #endif
4696 #ifdef CAN_DEBUG_WITHOUT_FP
4697 flag_omit_frame_pointer = 1;
4698 #endif
4699 flag_guess_branch_prob = 1;
4702 if (optimize >= 2)
4704 flag_optimize_sibling_calls = 1;
4705 flag_cse_follow_jumps = 1;
4706 flag_cse_skip_blocks = 1;
4707 flag_gcse = 1;
4708 flag_expensive_optimizations = 1;
4709 flag_strength_reduce = 1;
4710 flag_rerun_cse_after_loop = 1;
4711 flag_rerun_loop_opt = 1;
4712 flag_caller_saves = 1;
4713 flag_force_mem = 1;
4714 flag_peephole2 = 1;
4715 #ifdef INSN_SCHEDULING
4716 flag_schedule_insns = 1;
4717 flag_schedule_insns_after_reload = 1;
4718 #endif
4719 flag_regmove = 1;
4720 flag_strict_aliasing = 1;
4721 flag_delete_null_pointer_checks = 1;
4722 flag_reorder_blocks = 1;
4725 if (optimize >= 3)
4727 flag_inline_functions = 1;
4728 flag_rename_registers = 1;
4731 if (optimize < 2 || optimize_size)
4733 align_loops = 1;
4734 align_jumps = 1;
4735 align_labels = 1;
4736 align_functions = 1;
4739 /* Initialize whether `char' is signed. */
4740 flag_signed_char = DEFAULT_SIGNED_CHAR;
4741 #ifdef DEFAULT_SHORT_ENUMS
4742 /* Initialize how much space enums occupy, by default. */
4743 flag_short_enums = DEFAULT_SHORT_ENUMS;
4744 #endif
4746 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4747 modify it. */
4748 target_flags = 0;
4749 set_target_switch ("");
4751 /* Unwind tables are always present in an ABI-conformant IA-64
4752 object file, so the default should be ON. */
4753 #ifdef IA64_UNWIND_INFO
4754 flag_unwind_tables = IA64_UNWIND_INFO;
4755 #endif
4757 #ifdef OPTIMIZATION_OPTIONS
4758 /* Allow default optimizations to be specified on a per-machine basis. */
4759 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4760 #endif
4762 /* Perform normal command line switch decoding. */
4763 for (i = 1; i < argc;)
4765 int lang_processed;
4766 int indep_processed;
4768 /* Give the language a chance to decode the option for itself. */
4769 lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
4771 if (lang_processed >= 0)
4772 /* Now see if the option also has a language independent meaning.
4773 Some options are both language specific and language independent,
4774 eg --help. */
4775 indep_processed = independent_decode_option (argc - i, argv + i);
4776 else
4778 lang_processed = -lang_processed;
4779 indep_processed = 0;
4782 if (lang_processed || indep_processed)
4783 i += MAX (lang_processed, indep_processed);
4784 else
4786 const char *option = NULL;
4787 const char *lang = NULL;
4788 unsigned int j;
4790 /* It is possible that the command line switch is not valid for the
4791 current language, but it is valid for another language. In order
4792 to be compatible with previous versions of the compiler (which
4793 did not issue an error message in this case) we check for this
4794 possibility here. If we do find a match, then if extra_warnings
4795 is set we generate a warning message, otherwise we will just
4796 ignore the option. */
4797 for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4799 option = documented_lang_options[j].option;
4801 if (option == NULL)
4802 lang = documented_lang_options[j].description;
4803 else if (! strncmp (argv[i], option, strlen (option)))
4804 break;
4807 if (j != ARRAY_SIZE (documented_lang_options))
4809 if (extra_warnings)
4811 warning ("Ignoring command line option '%s'", argv[i]);
4812 if (lang)
4813 warning
4814 ("(It is valid for %s but not the selected language)",
4815 lang);
4818 else if (argv[i][0] == '-' && argv[i][1] == 'g')
4819 warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
4820 else
4821 error ("Unrecognized option `%s'", argv[i]);
4823 i++;
4827 /* All command line options have been processed. */
4828 (*lang_hooks.post_options) ();
4831 /* Process the options that have been parsed. */
4832 static void
4833 process_options ()
4835 /* Checker uses the frame pointer. */
4836 if (flag_check_memory_usage)
4837 flag_omit_frame_pointer = 0;
4839 if (optimize == 0)
4841 /* Inlining does not work if not optimizing,
4842 so force it not to be done. */
4843 flag_no_inline = 1;
4844 warn_inline = 0;
4846 /* The c_decode_option function and decode_option hook set
4847 this to `2' if -Wall is used, so we can avoid giving out
4848 lots of errors for people who don't realize what -Wall does. */
4849 if (warn_uninitialized == 1)
4850 warning ("-Wuninitialized is not supported without -O");
4853 /* We do not currently support sibling-call optimization in the
4854 presence of exceptions. See PR2975 for a test-case that will
4855 fail if we try to combine both of these features. */
4856 if (flag_exceptions)
4857 flag_optimize_sibling_calls = 0;
4859 #ifdef OVERRIDE_OPTIONS
4860 /* Some machines may reject certain combinations of options. */
4861 OVERRIDE_OPTIONS;
4862 #endif
4864 /* Set up the align_*_log variables, defaulting them to 1 if they
4865 were still unset. */
4866 if (align_loops <= 0) align_loops = 1;
4867 if (align_loops_max_skip > align_loops || !align_loops)
4868 align_loops_max_skip = align_loops - 1;
4869 align_loops_log = floor_log2 (align_loops * 2 - 1);
4870 if (align_jumps <= 0) align_jumps = 1;
4871 if (align_jumps_max_skip > align_jumps || !align_jumps)
4872 align_jumps_max_skip = align_jumps - 1;
4873 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4874 if (align_labels <= 0) align_labels = 1;
4875 align_labels_log = floor_log2 (align_labels * 2 - 1);
4876 if (align_labels_max_skip > align_labels || !align_labels)
4877 align_labels_max_skip = align_labels - 1;
4878 if (align_functions <= 0) align_functions = 1;
4879 align_functions_log = floor_log2 (align_functions * 2 - 1);
4881 if (profile_block_flag == 3)
4883 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4884 profile_block_flag = 2;
4887 /* Unrolling all loops implies that standard loop unrolling must also
4888 be done. */
4889 if (flag_unroll_all_loops)
4890 flag_unroll_loops = 1;
4891 /* Loop unrolling requires that strength_reduction be on also. Silently
4892 turn on strength reduction here if it isn't already on. Also, the loop
4893 unrolling code assumes that cse will be run after loop, so that must
4894 be turned on also. */
4895 if (flag_unroll_loops)
4897 flag_strength_reduce = 1;
4898 flag_rerun_cse_after_loop = 1;
4901 if (flag_non_call_exceptions)
4902 flag_asynchronous_unwind_tables = 1;
4903 if (flag_asynchronous_unwind_tables)
4904 flag_unwind_tables = 1;
4906 /* Warn about options that are not supported on this machine. */
4907 #ifndef INSN_SCHEDULING
4908 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4909 warning ("instruction scheduling not supported on this target machine");
4910 #endif
4911 #ifndef DELAY_SLOTS
4912 if (flag_delayed_branch)
4913 warning ("this target machine does not have delayed branches");
4914 #endif
4916 /* Some operating systems do not allow profiling without a frame
4917 pointer. */
4918 if (!TARGET_ALLOWS_PROFILING_WITHOUT_FRAME_POINTER
4919 && profile_flag
4920 && flag_omit_frame_pointer)
4922 error ("profiling does not work without a frame pointer");
4923 flag_omit_frame_pointer = 0;
4926 user_label_prefix = USER_LABEL_PREFIX;
4927 if (flag_leading_underscore != -1)
4929 /* If the default prefix is more complicated than "" or "_",
4930 issue a warning and ignore this option. */
4931 if (user_label_prefix[0] == 0 ||
4932 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4934 user_label_prefix = flag_leading_underscore ? "_" : "";
4936 else
4937 warning ("-f%sleading-underscore not supported on this target machine",
4938 flag_leading_underscore ? "" : "no-");
4941 /* If we are in verbose mode, write out the version and maybe all the
4942 option flags in use. */
4943 if (version_flag)
4945 print_version (stderr, "");
4946 if (! quiet_flag)
4947 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4950 if (! quiet_flag)
4951 time_report = 1;
4953 if (flag_syntax_only)
4955 write_symbols = NO_DEBUG;
4956 profile_flag = 0;
4957 profile_block_flag = 0;
4960 /* Now we know write_symbols, set up the debug hooks based on it.
4961 By default we do nothing for debug output. */
4962 #if defined(DBX_DEBUGGING_INFO)
4963 if (write_symbols == DBX_DEBUG)
4964 debug_hooks = &dbx_debug_hooks;
4965 #endif
4966 #if defined(XCOFF_DEBUGGING_INFO)
4967 if (write_symbols == XCOFF_DEBUG)
4968 debug_hooks = &xcoff_debug_hooks;
4969 #endif
4970 #ifdef SDB_DEBUGGING_INFO
4971 if (write_symbols == SDB_DEBUG)
4972 debug_hooks = &sdb_debug_hooks;
4973 #endif
4974 #ifdef DWARF_DEBUGGING_INFO
4975 if (write_symbols == DWARF_DEBUG)
4976 debug_hooks = &dwarf_debug_hooks;
4977 #endif
4978 #ifdef DWARF2_DEBUGGING_INFO
4979 if (write_symbols == DWARF2_DEBUG)
4980 debug_hooks = &dwarf2_debug_hooks;
4981 #endif
4983 /* If auxiliary info generation is desired, open the output file.
4984 This goes in the same directory as the source file--unlike
4985 all the other output files. */
4986 if (flag_gen_aux_info)
4988 aux_info_file = fopen (aux_info_file_name, "w");
4989 if (aux_info_file == 0)
4990 fatal_io_error ("can't open %s", aux_info_file_name);
4993 if (! targetm.have_named_sections)
4995 if (flag_function_sections)
4997 warning ("-ffunction-sections not supported for this target.");
4998 flag_function_sections = 0;
5000 if (flag_data_sections)
5002 warning ("-fdata-sections not supported for this target.");
5003 flag_data_sections = 0;
5007 if (flag_function_sections
5008 && (profile_flag || profile_block_flag))
5010 warning ("-ffunction-sections disabled; it makes profiling impossible.");
5011 flag_function_sections = 0;
5014 #ifndef OBJECT_FORMAT_ELF
5015 if (flag_function_sections && write_symbols != NO_DEBUG)
5016 warning ("-ffunction-sections may affect debugging on some targets.");
5017 #endif
5020 /* Language-independent initialization, before language-dependent
5021 initialization. */
5022 static void
5023 lang_independent_init ()
5025 decl_printable_name = decl_name;
5026 lang_expand_expr = (lang_expand_expr_t) do_abort;
5028 /* Set the language-dependent identifer size. */
5029 tree_code_length[(int) IDENTIFIER_NODE]
5030 = ((lang_hooks.identifier_size - sizeof (struct tree_common))
5031 / sizeof (tree));
5033 /* Initialize the garbage-collector, and string pools. FIXME: We
5034 should do this later, in independent_init () when we know we
5035 actually want to compile something, but cpplib currently wants to
5036 use the hash table immediately in cpp_create_reader. */
5037 init_ggc ();
5038 ggc_add_rtx_root (&stack_limit_rtx, 1);
5039 ggc_add_tree_root (&current_function_decl, 1);
5040 ggc_add_tree_root (&current_function_func_begin_label, 1);
5042 init_stringpool ();
5043 init_obstacks ();
5045 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
5046 || debug_info_level == DINFO_LEVEL_VERBOSE
5047 || flag_test_coverage
5048 || warn_notreached);
5049 init_regs ();
5050 init_alias_once ();
5051 init_stmt ();
5052 init_loop ();
5053 init_reload ();
5054 init_function_once ();
5055 init_stor_layout_once ();
5056 init_varasm_once ();
5057 init_EXPR_INSN_LIST_cache ();
5059 /* The following initialization functions need to generate rtl, so
5060 provide a dummy function context for them. */
5061 init_dummy_function_start ();
5062 init_expmed ();
5063 init_expr_once ();
5064 if (flag_caller_saves)
5065 init_caller_save ();
5066 expand_dummy_function_end ();
5069 /* Language-dependent initialization. Returns non-zero on success. */
5070 static int
5071 lang_dependent_init (name)
5072 const char *name;
5074 if (dump_base_name == 0)
5075 dump_base_name = name ? name : "gccdump";
5077 /* Front-end initialization. This hook can assume that GC,
5078 identifier hashes etc. are set up, but debug initialization is
5079 not done yet. This routine must return the original filename
5080 (e.g. foo.i -> foo.c) so can correctly initialize debug output. */
5081 name = (*lang_hooks.init) (name);
5082 if (name == NULL)
5083 return 0;
5085 /* Is this duplication necessary? */
5086 name = ggc_strdup (name);
5087 main_input_filename = input_filename = name;
5088 init_asm_output (name);
5090 /* These create various _DECL nodes, so need to be called after the
5091 front end is initialized. */
5092 init_eh ();
5093 init_optabs ();
5095 /* Put an entry on the input file stack for the main input file. */
5096 push_srcloc (input_filename, 0);
5098 /* If dbx symbol table desired, initialize writing it and output the
5099 predefined types. */
5100 timevar_push (TV_SYMOUT);
5102 #ifdef DWARF2_UNWIND_INFO
5103 if (dwarf2out_do_frame ())
5104 dwarf2out_frame_init ();
5105 #endif
5107 /* Now we have the correct original filename, we can initialize
5108 debug output. */
5109 (*debug_hooks->init) (name);
5111 timevar_pop (TV_SYMOUT);
5113 return 1;
5116 /* Clean up: close opened files, etc. */
5118 static void
5119 finalize ()
5121 /* Close the dump files. */
5122 if (flag_gen_aux_info)
5124 fclose (aux_info_file);
5125 if (errorcount)
5126 unlink (aux_info_file_name);
5129 /* Close non-debugging input and output files. Take special care to note
5130 whether fclose returns an error, since the pages might still be on the
5131 buffer chain while the file is open. */
5133 if (asm_out_file)
5135 if (ferror (asm_out_file) != 0)
5136 fatal_io_error ("error writing to %s", asm_file_name);
5137 if (fclose (asm_out_file) != 0)
5138 fatal_io_error ("error closing %s", asm_file_name);
5141 /* Do whatever is necessary to finish printing the graphs. */
5142 if (graph_dump_format != no_graph)
5144 int i;
5146 for (i = 0; i < (int) DFI_MAX; ++i)
5147 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
5149 char seq[16];
5150 char *suffix;
5152 sprintf (seq, DUMPFILE_FORMAT, i);
5153 suffix = concat (seq, dump_file[i].extension, NULL);
5154 finish_graph_dump_file (dump_base_name, suffix);
5155 free (suffix);
5159 if (mem_report)
5161 ggc_print_statistics ();
5162 stringpool_statistics ();
5163 dump_tree_statistics ();
5166 /* Free up memory for the benefit of leak detectors. */
5167 free_reg_info ();
5169 /* Language-specific end of compilation actions. */
5170 (*lang_hooks.finish) ();
5173 /* Entry point of cc1, cc1plus, jc1, f771, etc.
5174 Decode command args, then call compile_file.
5175 Exit code is FATAL_EXIT_CODE if can't open files or if there were
5176 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
5178 It is not safe to call this function more than once. */
5181 toplev_main (argc, argv)
5182 int argc;
5183 char **argv;
5185 /* Initialization of GCC's environment, and diagnostics. */
5186 general_init (argv [0]);
5188 /* Parse the options and do minimal processing; basically just
5189 enough to default flags appropriately. */
5190 parse_options_and_default_flags (argc, argv);
5192 /* Exit early if we can (e.g. -help). */
5193 if (exit_after_options)
5194 return (SUCCESS_EXIT_CODE);
5196 /* The bulk of command line switch processing. */
5197 process_options ();
5199 /* We cannot start timing until after options are processed since that
5200 says if we run timers or not. */
5201 init_timevar ();
5202 timevar_start (TV_TOTAL);
5204 /* Language-independent initialization. Also sets up GC, identifier
5205 hashes etc. */
5206 lang_independent_init ();
5208 /* Language-dependent initialization. Returns true on success. */
5209 if (lang_dependent_init (filename))
5210 compile_file ();
5212 finalize ();
5214 /* Stop timing and print the times. */
5215 timevar_stop (TV_TOTAL);
5216 timevar_print (stderr);
5218 if (errorcount || sorrycount)
5219 return (FATAL_EXIT_CODE);
5221 return (SUCCESS_EXIT_CODE);