OSDN Git Service

* toplev.c (print_version): Add indentation for GGC heuristics and
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
1 /* Top level of GNU C compiler
2    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3    1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
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.
11
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.
16
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.  */
21
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.  */
26
27 #include "config.h"
28 #undef FLOAT /* This is for hpux. They should change hpux.  */
29 #undef FFS  /* Some systems define this in param.h.  */
30 #include "system.h"
31 #include "coretypes.h"
32 #include "tm.h"
33 #include <signal.h>
34
35 #ifdef HAVE_SYS_RESOURCE_H
36 # include <sys/resource.h>
37 #endif
38
39 #ifdef HAVE_SYS_TIMES_H
40 # include <sys/times.h>
41 #endif
42
43 #include "input.h"
44 #include "tree.h"
45 #include "rtl.h"
46 #include "tm_p.h"
47 #include "flags.h"
48 #include "insn-attr.h"
49 #include "insn-config.h"
50 #include "insn-flags.h"
51 #include "hard-reg-set.h"
52 #include "recog.h"
53 #include "output.h"
54 #include "except.h"
55 #include "function.h"
56 #include "toplev.h"
57 #include "expr.h"
58 #include "basic-block.h"
59 #include "intl.h"
60 #include "ggc.h"
61 #include "graph.h"
62 #include "loop.h"
63 #include "regs.h"
64 #include "timevar.h"
65 #include "diagnostic.h"
66 #include "ssa.h"
67 #include "params.h"
68 #include "reload.h"
69 #include "dwarf2asm.h"
70 #include "integrate.h"
71 #include "real.h"
72 #include "debug.h"
73 #include "target.h"
74 #include "langhooks.h"
75 #include "cfglayout.h"
76 #include "cfgloop.h"
77 #include "hosthooks.h"
78
79 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
80 #include "dwarf2out.h"
81 #endif
82
83 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
84 #include "dbxout.h"
85 #endif
86
87 #ifdef SDB_DEBUGGING_INFO
88 #include "sdbout.h"
89 #endif
90
91 #ifdef XCOFF_DEBUGGING_INFO
92 #include "xcoffout.h"           /* Needed for external data
93                                    declarations for e.g. AIX 4.x.  */
94 #endif
95 \f
96 /* Carry information from ASM_DECLARE_OBJECT_NAME
97    to ASM_FINISH_DECLARE_OBJECT.  */
98
99 extern int size_directive_output;
100 extern tree last_assemble_variable_decl;
101
102 extern void reg_alloc PARAMS ((void));
103
104 static void general_init PARAMS ((char *));
105 static void parse_options_and_default_flags PARAMS ((int, char **));
106 static void do_compile PARAMS ((void));
107 static void process_options PARAMS ((void));
108 static void backend_init PARAMS ((void));
109 static int lang_dependent_init PARAMS ((const char *));
110 static void init_asm_output PARAMS ((const char *));
111 static void finalize PARAMS ((void));
112
113 static void set_target_switch PARAMS ((const char *));
114
115 static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
116 static void setup_core_dumping PARAMS ((void));
117 static void compile_file PARAMS ((void));
118 static void display_help PARAMS ((void));
119 static void display_target_options PARAMS ((void));
120
121 static void decode_d_option PARAMS ((const char *));
122 static int decode_f_option PARAMS ((const char *));
123 static int decode_W_option PARAMS ((const char *));
124 static int decode_g_option PARAMS ((const char *));
125 static unsigned int independent_decode_option PARAMS ((int, char **));
126
127 static void print_version PARAMS ((FILE *, const char *));
128 static int print_single_switch PARAMS ((FILE *, int, int, const char *,
129                                       const char *, const char *,
130                                       const char *, const char *));
131 static void print_switch_values PARAMS ((FILE *, int, int, const char *,
132                                        const char *, const char *));
133
134 /* Nonzero to dump debug info whilst parsing (-dy option).  */
135 static int set_yydebug;
136
137 /* Length of line when printing switch values.  */
138 #define MAX_LINE 75
139
140 /* Name of program invoked, sans directories.  */
141
142 const char *progname;
143
144 /* Copy of arguments to toplev_main.  */
145 int save_argc;
146 char **save_argv;
147 \f
148 /* Name of current original source file (what was input to cpp).
149    This comes from each #-command in the actual input.  */
150
151 const char *input_filename;
152
153 /* Name of top-level original source file (what was input to cpp).
154    This comes from the #-command at the beginning of the actual input.
155    If there isn't any there, then this is the cc1 input file name.  */
156
157 const char *main_input_filename;
158
159 /* Current line number in real source file.  */
160
161 int lineno;
162
163 /* Nonzero if it is unsafe to create any new pseudo registers.  */
164 int no_new_pseudos;
165
166 /* Stack of currently pending input files.  */
167
168 struct file_stack *input_file_stack;
169
170 /* Incremented on each change to input_file_stack.  */
171 int input_file_stack_tick;
172
173 /* Name to use as base of names for dump output files.  */
174
175 const char *dump_base_name;
176
177 /* Name to use as a base for auxiliary output files.  */
178
179 const char *aux_base_name;
180
181 /* Format to use to print dumpfile index value */
182 #ifndef DUMPFILE_FORMAT
183 #define DUMPFILE_FORMAT ".%02d."
184 #endif
185
186 /* Bit flags that specify the machine subtype we are compiling for.
187    Bits are tested using macros TARGET_... defined in the tm.h file
188    and set by `-m...' switches.  Must be defined in rtlanal.c.  */
189
190 extern int target_flags;
191
192 /* A mask of target_flags that includes bit X if X was set or cleared
193    on the command line.  */
194
195 int target_flags_explicit;
196
197 /* Debug hooks - dependent upon command line options.  */
198
199 const struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks;
200
201 /* Describes a dump file.  */
202
203 struct dump_file_info
204 {
205   /* The unique extension to apply, e.g. ".jump".  */
206   const char *const extension;
207
208   /* The -d<c> character that enables this dump file.  */
209   char const debug_switch;
210
211   /* True if there is a corresponding graph dump file.  */
212   char const graph_dump_p;
213
214   /* True if the user selected this dump.  */
215   char enabled;
216
217   /* True if the files have been initialized (ie truncated).  */
218   char initialized;
219 };
220
221 /* Enumerate the extant dump files.  */
222
223 enum dump_file_index
224 {
225   DFI_rtl,
226   DFI_sibling,
227   DFI_eh,
228   DFI_jump,
229   DFI_ssa,
230   DFI_ssa_ccp,
231   DFI_ssa_dce,
232   DFI_ussa,
233   DFI_null,
234   DFI_cse,
235   DFI_addressof,
236   DFI_gcse,
237   DFI_loop,
238   DFI_bypass,
239   DFI_cfg,
240   DFI_bp,
241   DFI_ce1,
242   DFI_tracer,
243   DFI_loop2,
244   DFI_cse2,
245   DFI_life,
246   DFI_combine,
247   DFI_ce2,
248   DFI_regmove,
249   DFI_sched,
250   DFI_lreg,
251   DFI_greg,
252   DFI_postreload,
253   DFI_flow2,
254   DFI_peephole2,
255   DFI_rnreg,
256   DFI_ce3,
257   DFI_bbro,
258   DFI_sched2,
259   DFI_stack,
260   DFI_mach,
261   DFI_dbr,
262   DFI_MAX
263 };
264
265 /* Describes all the dump files.  Should be kept in order of the
266    pass and in sync with dump_file_index above.
267
268    Remaining -d letters:
269
270         "              o q         "
271         "       H JK   OPQ  TUV  YZ"
272 */
273
274 static struct dump_file_info dump_file[DFI_MAX] =
275 {
276   { "rtl",      'r', 0, 0, 0 },
277   { "sibling",  'i', 0, 0, 0 },
278   { "eh",       'h', 0, 0, 0 },
279   { "jump",     'j', 0, 0, 0 },
280   { "ssa",      'e', 1, 0, 0 },
281   { "ssaccp",   'W', 1, 0, 0 },
282   { "ssadce",   'X', 1, 0, 0 },
283   { "ussa",     'e', 1, 0, 0 }, /* Yes, duplicate enable switch.  */
284   { "null",     'u', 0, 0, 0 },
285   { "cse",      's', 0, 0, 0 },
286   { "addressof", 'F', 0, 0, 0 },
287   { "gcse",     'G', 1, 0, 0 },
288   { "loop",     'L', 1, 0, 0 },
289   { "bypass",   'G', 1, 0, 0 }, /* Yes, duplicate enable switch.  */
290   { "cfg",      'f', 1, 0, 0 },
291   { "bp",       'b', 1, 0, 0 },
292   { "ce1",      'C', 1, 0, 0 },
293   { "tracer",   'T', 1, 0, 0 },
294   { "loop2",    'L', 1, 0, 0 },
295   { "cse2",     't', 1, 0, 0 },
296   { "life",     'f', 1, 0, 0 }, /* Yes, duplicate enable switch.  */
297   { "combine",  'c', 1, 0, 0 },
298   { "ce2",      'C', 1, 0, 0 },
299   { "regmove",  'N', 1, 0, 0 },
300   { "sched",    'S', 1, 0, 0 },
301   { "lreg",     'l', 1, 0, 0 },
302   { "greg",     'g', 1, 0, 0 },
303   { "postreload", 'o', 1, 0, 0 },
304   { "flow2",    'w', 1, 0, 0 },
305   { "peephole2", 'z', 1, 0, 0 },
306   { "rnreg",    'n', 1, 0, 0 },
307   { "ce3",      'E', 1, 0, 0 },
308   { "bbro",     'B', 1, 0, 0 },
309   { "sched2",   'R', 1, 0, 0 },
310   { "stack",    'k', 1, 0, 0 },
311   { "mach",     'M', 1, 0, 0 },
312   { "dbr",      'd', 0, 0, 0 },
313 };
314
315 static int open_dump_file PARAMS ((enum dump_file_index, tree));
316 static void close_dump_file PARAMS ((enum dump_file_index,
317                                      void (*) (FILE *, rtx), rtx));
318
319 /* Other flags saying which kinds of debugging dump have been requested.  */
320
321 int rtl_dump_and_exit;
322 int flag_print_asm_name;
323 static int version_flag;
324 static char *filename;
325 enum graph_dump_types graph_dump_format;
326
327 /* Name for output file of assembly code, specified with -o.  */
328
329 char *asm_file_name;
330
331 /* Value of the -G xx switch, and whether it was passed or not.  */
332 int g_switch_value;
333 int g_switch_set;
334
335 /* Type(s) of debugging information we are producing (if any).
336    See flags.h for the definitions of the different possible
337    types of debugging information.  */
338 enum debug_info_type write_symbols = NO_DEBUG;
339
340 /* Level of debugging information we are producing.  See flags.h
341    for the definitions of the different possible levels.  */
342 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
343
344 /* Nonzero means use GNU-only extensions in the generated symbolic
345    debugging information.  */
346 /* Currently, this only has an effect when write_symbols is set to
347    DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG.  */
348 int use_gnu_debug_info_extensions = 0;
349
350 /* Nonzero means do optimizations.  -O.
351    Particular numeric values stand for particular amounts of optimization;
352    thus, -O2 stores 2 here.  However, the optimizations beyond the basic
353    ones are not controlled directly by this variable.  Instead, they are
354    controlled by individual `flag_...' variables that are defaulted
355    based on this variable.  */
356
357 int optimize = 0;
358
359 /* Nonzero means optimize for size.  -Os.
360    The only valid values are zero and nonzero. When optimize_size is
361    nonzero, optimize defaults to 2, but certain individual code
362    bloating optimizations are disabled.  */
363
364 int optimize_size = 0;
365
366 /* Nonzero if we should exit after parsing options.  */
367 static int exit_after_options = 0;
368
369 /* The FUNCTION_DECL for the function currently being compiled,
370    or 0 if between functions.  */
371 tree current_function_decl;
372
373 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
374    if none.  */
375 tree current_function_func_begin_label;
376
377 /* Nonzero if doing dwarf2 duplicate elimination.  */
378
379 int flag_eliminate_dwarf2_dups = 0;
380
381 /* Nonzero if generating code to do profiling.  */
382
383 int profile_flag = 0;
384
385 /* Nonzero if generating code to profile program flow graph arcs.  */
386
387 int profile_arc_flag = 0;
388
389 /* Nonzero if generating info for gcov to calculate line test coverage.  */
390
391 int flag_test_coverage = 0;
392
393 /* Nonzero indicates that branch taken probabilities should be calculated.  */
394
395 int flag_branch_probabilities = 0;
396
397 /* Nonzero if basic blocks should be reordered.  */
398
399 int flag_reorder_blocks = 0;
400
401 /* Nonzero if functions should be reordered.  */
402
403 int flag_reorder_functions = 0;
404
405 /* Nonzero if registers should be renamed.  */
406
407 int flag_rename_registers = 0;
408 int flag_cprop_registers = 0;
409
410 /* Nonzero for -pedantic switch: warn about anything
411    that standard spec forbids.  */
412
413 int pedantic = 0;
414
415 /* Temporarily suppress certain warnings.
416    This is set while reading code from a system header file.  */
417
418 int in_system_header = 0;
419
420 /* Don't print functions as they are compiled.  -quiet.  */
421
422 int quiet_flag = 0;
423
424 /* Print times taken by the various passes.  -ftime-report.  */
425
426 int time_report = 0;
427
428 /* Print memory still in use at end of compilation (which may have little
429    to do with peak memory consumption).  -fmem-report.  */
430
431 int mem_report = 0;
432
433 /* Nonzero means to collect statistics which might be expensive
434    and to print them when we are done.  */
435 int flag_detailed_statistics = 0;
436
437 \f
438 /* -f flags.  */
439
440 /* Nonzero means `char' should be signed.  */
441
442 int flag_signed_char;
443
444 /* Nonzero means give an enum type only as many bytes as it needs.  */
445
446 int flag_short_enums;
447
448 /* Nonzero for -fcaller-saves: allocate values in regs that need to
449    be saved across function calls, if that produces overall better code.
450    Optional now, so people can test it.  */
451
452 #ifdef DEFAULT_CALLER_SAVES
453 int flag_caller_saves = 1;
454 #else
455 int flag_caller_saves = 0;
456 #endif
457
458 /* Nonzero if structures and unions should be returned in memory.
459
460    This should only be defined if compatibility with another compiler or
461    with an ABI is needed, because it results in slower code.  */
462
463 #ifndef DEFAULT_PCC_STRUCT_RETURN
464 #define DEFAULT_PCC_STRUCT_RETURN 1
465 #endif
466
467 /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
468
469 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
470
471 /* Nonzero for -fforce-mem: load memory value into a register
472    before arithmetic on it.  This makes better cse but slower compilation.  */
473
474 int flag_force_mem = 0;
475
476 /* Nonzero for -fforce-addr: load memory address into a register before
477    reference to memory.  This makes better cse but slower compilation.  */
478
479 int flag_force_addr = 0;
480
481 /* Nonzero for -fdefer-pop: don't pop args after each function call;
482    instead save them up to pop many calls' args with one insns.  */
483
484 int flag_defer_pop = 0;
485
486 /* Nonzero for -ffloat-store: don't allocate floats and doubles
487    in extended-precision registers.  */
488
489 int flag_float_store = 0;
490
491 /* Nonzero for -fcse-follow-jumps:
492    have cse follow jumps to do a more extensive job.  */
493
494 int flag_cse_follow_jumps;
495
496 /* Nonzero for -fcse-skip-blocks:
497    have cse follow a branch around a block.  */
498 int flag_cse_skip_blocks;
499
500 /* Nonzero for -fexpensive-optimizations:
501    perform miscellaneous relatively-expensive optimizations.  */
502 int flag_expensive_optimizations;
503
504 /* Nonzero for -fthread-jumps:
505    have jump optimize output of loop.  */
506
507 int flag_thread_jumps;
508
509 /* Nonzero enables strength-reduction in loop.c.  */
510
511 int flag_strength_reduce = 0;
512
513 /* Nonzero enables loop unrolling in unroll.c.  Only loops for which the
514    number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
515    UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
516    unrolled.  */
517
518 int flag_old_unroll_loops;
519
520 /* Nonzero enables loop unrolling in unroll.c.  All loops are unrolled.
521    This is generally not a win.  */
522
523 int flag_old_unroll_all_loops;
524
525 /* Enables unrolling of simple loops in loop-unroll.c.  */
526 int flag_unroll_loops;
527
528 /* Enables unrolling of all loops in loop-unroll.c.  */
529 int flag_unroll_all_loops;
530
531 /* Nonzero enables loop peeling.  */
532 int flag_peel_loops;
533
534 /* Nonzero enables loop unswitching.  */
535 int flag_unswitch_loops;
536
537 /* Nonzero enables prefetch optimizations for arrays in loops.  */
538
539 int flag_prefetch_loop_arrays;
540
541 /* Nonzero forces all invariant computations in loops to be moved
542    outside the loop.  */
543
544 int flag_move_all_movables = 0;
545
546 /* Nonzero forces all general induction variables in loops to be
547    strength reduced.  */
548
549 int flag_reduce_all_givs = 0;
550
551 /* Nonzero to perform full register move optimization passes.  This is the
552    default for -O2.  */
553
554 int flag_regmove = 0;
555
556 /* Nonzero for -fwritable-strings:
557    store string constants in data segment and don't uniquize them.  */
558
559 int flag_writable_strings = 0;
560
561 /* Nonzero means don't put addresses of constant functions in registers.
562    Used for compiling the Unix kernel, where strange substitutions are
563    done on the assembly output.  */
564
565 int flag_no_function_cse = 0;
566
567 /* Nonzero for -fomit-frame-pointer:
568    don't make a frame pointer in simple functions that don't require one.  */
569
570 int flag_omit_frame_pointer = 0;
571
572 /* Nonzero means place each function into its own section on those platforms
573    which support arbitrary section names and unlimited numbers of sections.  */
574
575 int flag_function_sections = 0;
576
577 /* ... and similar for data.  */
578
579 int flag_data_sections = 0;
580
581 /* Nonzero to inhibit use of define_optimization peephole opts.  */
582
583 int flag_no_peephole = 0;
584
585 /* Nonzero allows GCC to optimize sibling and tail recursive calls.  */
586
587 int flag_optimize_sibling_calls = 0;
588
589 /* Nonzero means the front end generally wants `errno' maintained by math
590    operations, like built-in SQRT.  */
591
592 int flag_errno_math = 1;
593
594 /* Nonzero means that unsafe floating-point math optimizations are allowed
595    for the sake of speed.  IEEE compliance is not guaranteed, and operations
596    are allowed to assume that their arguments and results are "normal"
597    (e.g., nonnegative for SQRT).  */
598
599 int flag_unsafe_math_optimizations = 0;
600
601 /* Nonzero means that no NaNs or +-Infs are expected.  */
602
603 int flag_finite_math_only = 0;
604
605 /* Zero means that floating-point math operations cannot generate a
606    (user-visible) trap.  This is the case, for example, in nonstop
607    IEEE 754 arithmetic.  Trapping conditions include division by zero,
608    overflow, underflow, invalid and inexact, but does not include
609    operations on signaling NaNs (see below).  */
610
611 int flag_trapping_math = 1;
612
613 /* Nonzero means disable transformations observable by signaling NaNs.
614    This option implies that any operation on a IEEE signaling NaN can
615    generate a (user-visible) trap.  */
616
617 int flag_signaling_nans = 0;
618
619 /* 0 means straightforward implementation of complex divide acceptable.
620    1 means wide ranges of inputs must work for complex divide.
621    2 means C99-like requirements for complex divide (not yet implemented).  */
622
623 int flag_complex_divide_method = 0;
624
625 /* Nonzero means just do syntax checking; don't output anything.  */
626
627 int flag_syntax_only = 0;
628
629 /* Nonzero means perform loop optimizer.  */
630
631 static int flag_loop_optimize;
632
633 /* Nonzero means perform crossjumping.  */
634
635 static int flag_crossjumping;
636
637 /* Nonzero means perform if conversion.  */
638
639 static int flag_if_conversion;
640
641 /* Nonzero means perform if conversion after reload.  */
642
643 static int flag_if_conversion2;
644
645 /* Nonzero means to use global dataflow analysis to eliminate
646    useless null pointer tests.  */
647
648 static int flag_delete_null_pointer_checks;
649
650 /* Nonzero means perform global CSE.  */
651
652 int flag_gcse = 0;
653
654 /* Nonzero means to do the enhanced load motion during gcse, which trys
655    to hoist loads by not killing them when a store to the same location
656    is seen.  */
657
658 int flag_gcse_lm = 1;
659
660 /* Nonzero means to perform store motion after gcse, which will try to
661    move stores closer to the exit block.  Its not very effective without
662    flag_gcse_lm.  */
663
664 int flag_gcse_sm = 1;
665
666 /* Nonzero means to rerun cse after loop optimization.  This increases
667    compilation time about 20% and picks up a few more common expressions.  */
668
669 static int flag_rerun_cse_after_loop;
670
671 /* Nonzero means to run loop optimizations twice.  */
672
673 int flag_rerun_loop_opt;
674
675 /* Nonzero for -finline-functions: ok to inline functions that look like
676    good inline candidates.  */
677
678 int flag_inline_functions;
679
680 /* Nonzero for -fkeep-inline-functions: even if we make a function
681    go inline everywhere, keep its definition around for debugging
682    purposes.  */
683
684 int flag_keep_inline_functions;
685
686 /* Nonzero means that functions will not be inlined.  */
687
688 int flag_no_inline = 2;
689
690 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
691    not just because the tree inliner turned us off.  */
692
693 int flag_really_no_inline = 2;
694
695 /* Nonzero means that we should emit static const variables
696    regardless of whether or not optimization is turned on.  */
697
698 int flag_keep_static_consts = 1;
699
700 /* Nonzero means we should be saving declaration info into a .X file.  */
701
702 int flag_gen_aux_info = 0;
703
704 /* Specified name of aux-info file.  */
705
706 static char *aux_info_file_name;
707
708 /* Nonzero means make the text shared if supported.  */
709
710 int flag_shared_data;
711
712 /* Nonzero means schedule into delayed branch slots if supported.  */
713
714 int flag_delayed_branch;
715
716 /* Nonzero if we are compiling pure (sharable) code.
717    Value is 1 if we are doing "small" pic; value is 2 if we're doing
718    "large" pic.  */
719
720 int flag_pic;
721
722 /* Set to the default thread-local storage (tls) model to use.  */
723
724 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
725
726 /* Nonzero means generate extra code for exception handling and enable
727    exception handling.  */
728
729 int flag_exceptions;
730
731 /* Nonzero means generate frame unwind info table when supported.  */
732
733 int flag_unwind_tables = 0;
734
735 /* Nonzero means generate frame unwind info table exact at each insn boundary */
736
737 int flag_asynchronous_unwind_tables = 0;
738
739 /* Nonzero means don't place uninitialized global data in common storage
740    by default.  */
741
742 int flag_no_common;
743
744 /* Nonzero means change certain warnings into errors.
745    Usually these are warnings about failure to conform to some standard.  */
746
747 int flag_pedantic_errors = 0;
748
749 /* flag_schedule_insns means schedule insns within basic blocks (before
750    local_alloc).
751    flag_schedule_insns_after_reload means schedule insns after
752    global_alloc.  */
753
754 int flag_schedule_insns = 0;
755 int flag_schedule_insns_after_reload = 0;
756
757 /* When flag_schedule_insns_after_reload is set, use EBB scheduler.  */
758 int flag_sched2_use_superblocks = 0;
759
760 /* When flag_schedule_insns_after_reload is set, construct traces and EBB
761    scheduler.  */
762 int flag_sched2_use_traces = 0;
763
764 /* The following flags have effect only for scheduling before register
765    allocation:
766
767    flag_schedule_interblock means schedule insns across basic blocks.
768    flag_schedule_speculative means allow speculative motion of non-load insns.
769    flag_schedule_speculative_load means allow speculative motion of some
770    load insns.
771    flag_schedule_speculative_load_dangerous allows speculative motion of more
772    load insns.  */
773
774 int flag_schedule_interblock = 1;
775 int flag_schedule_speculative = 1;
776 int flag_schedule_speculative_load = 0;
777 int flag_schedule_speculative_load_dangerous = 0;
778
779 int flag_single_precision_constant;
780
781 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
782    by a cheaper branch on a count register.  */
783 int flag_branch_on_count_reg = 1;
784
785 /* -finhibit-size-directive inhibits output of .size for ELF.
786    This is used only for compiling crtstuff.c,
787    and it may be extended to other effects
788    needed for crtstuff.c on other systems.  */
789 int flag_inhibit_size_directive = 0;
790
791 /* -fverbose-asm causes extra commentary information to be produced in
792    the generated assembly code (to make it more readable).  This option
793    is generally only of use to those who actually need to read the
794    generated assembly code (perhaps while debugging the compiler itself).
795    -fno-verbose-asm, the default, causes the extra information
796    to be omitted and is useful when comparing two assembler files.  */
797
798 int flag_verbose_asm = 0;
799
800 /* -dA causes debug commentary information to be produced in
801    the generated assembly code (to make it more readable).  This option
802    is generally only of use to those who actually need to read the
803    generated assembly code (perhaps while debugging the compiler itself).
804    Currently, this switch is only used by dwarfout.c; however, it is intended
805    to be a catchall for printing debug information in the assembler file.  */
806
807 int flag_debug_asm = 0;
808
809 /* -dP causes the rtl to be emitted as a comment in assembly.  */
810
811 int flag_dump_rtl_in_asm = 0;
812
813 /* -fgnu-linker specifies use of the GNU linker for initializations.
814    (Or, more generally, a linker that handles initializations.)
815    -fno-gnu-linker says that collect2 will be used.  */
816 #ifdef USE_COLLECT2
817 int flag_gnu_linker = 0;
818 #else
819 int flag_gnu_linker = 1;
820 #endif
821
822 /* Nonzero means put zero initialized data in the bss section.  */
823 int flag_zero_initialized_in_bss = 1;
824
825 /* Enable SSA.  */
826 int flag_ssa = 0;
827
828 /* Enable ssa conditional constant propagation.  */
829 int flag_ssa_ccp = 0;
830
831 /* Enable ssa aggressive dead code elimination.  */
832 int flag_ssa_dce = 0;
833
834 /* Tag all structures with __attribute__(packed).  */
835 int flag_pack_struct = 0;
836
837 /* Emit code to check for stack overflow; also may cause large objects
838    to be allocated dynamically.  */
839 int flag_stack_check;
840
841 /* When non-NULL, indicates that whenever space is allocated on the
842    stack, the resulting stack pointer must not pass this
843    address---that is, for stacks that grow downward, the stack pointer
844    must always be greater than or equal to this address; for stacks
845    that grow upward, the stack pointer must be less than this address.
846    At present, the rtx may be either a REG or a SYMBOL_REF, although
847    the support provided depends on the backend.  */
848 rtx stack_limit_rtx;
849
850 /* 0 if pointer arguments may alias each other.  True in C.
851    1 if pointer arguments may not alias each other but may alias
852    global variables.
853    2 if pointer arguments may not alias each other and may not
854    alias global variables.  True in Fortran.
855    This defaults to 0 for C.  */
856 int flag_argument_noalias = 0;
857
858 /* Nonzero if we should do (language-dependent) alias analysis.
859    Typically, this analysis will assume that expressions of certain
860    types do not alias expressions of certain other types.  Only used
861    if alias analysis (in general) is enabled.  */
862 int flag_strict_aliasing = 0;
863
864 /* Instrument functions with calls at entry and exit, for profiling.  */
865 int flag_instrument_function_entry_exit = 0;
866
867 /* Nonzero means ignore `#ident' directives.  0 means handle them.
868    On SVR4 targets, it also controls whether or not to emit a
869    string identifying the compiler.  */
870
871 int flag_no_ident = 0;
872
873 /* This will perform a peephole pass before sched2.  */
874 int flag_peephole2 = 0;
875
876 /* This will try to guess branch probabilities.  */
877 int flag_guess_branch_prob = 0;
878
879 /* -fcheck-bounds causes gcc to generate array bounds checks.
880    For C, C++, ObjC: defaults to off.
881    For Java: defaults to on.
882    For Fortran: defaults to off.  */
883 int flag_bounds_check = 0;
884
885 /* This will attempt to merge constant section constants, if 1 only
886    string constants and constants from constant pool, if 2 also constant
887    variables.  */
888 int flag_merge_constants = 1;
889
890 /* If one, renumber instruction UIDs to reduce the number of
891    unused UIDs if there are a lot of instructions.  If greater than
892    one, unconditionally renumber instruction UIDs.  */
893 int flag_renumber_insns = 1;
894
895 /* If nonzero, use the graph coloring register allocator.  */
896 int flag_new_regalloc = 0;
897
898 /* Nonzero if we perform superblock formation.  */
899
900 int flag_tracer = 0;
901
902 /* Nonzero if we perform whole unit at a time compilation.  */
903
904 int flag_unit_at_a_time = 0;
905
906 /* Values of the -falign-* flags: how much to align labels in code.
907    0 means `use default', 1 means `don't align'.
908    For each variable, there is an _log variant which is the power
909    of two not less than the variable, for .align output.  */
910
911 int align_loops;
912 int align_loops_log;
913 int align_loops_max_skip;
914 int align_jumps;
915 int align_jumps_log;
916 int align_jumps_max_skip;
917 int align_labels;
918 int align_labels_log;
919 int align_labels_max_skip;
920 int align_functions;
921 int align_functions_log;
922
923 /* Like align_functions_log above, but used by front-ends to force the
924    minimum function alignment.  Zero means no alignment is forced.  */
925 int force_align_functions_log;
926
927 /* Table of supported debugging formats.  */
928 static const struct
929 {
930   const char *const arg;
931   /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
932      constant expression, we use NO_DEBUG in its place.  */
933   const enum debug_info_type debug_type;
934   const int use_extensions_p;
935   const char *const description;
936 } *da,
937 debug_args[] =
938 {
939   { "",       NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
940     N_("Generate debugging info in default format") },
941   { "gdb",    NO_DEBUG, 1, N_("Generate debugging info in default extended format") },
942 #ifdef DBX_DEBUGGING_INFO
943   { "stabs",  DBX_DEBUG, 0, N_("Generate STABS format debug info") },
944   { "stabs+", DBX_DEBUG, 1, N_("Generate extended STABS format debug info") },
945 #endif
946 #ifdef DWARF_DEBUGGING_INFO
947   { "dwarf",  DWARF_DEBUG, 0, N_("Generate DWARF-1 format debug info") },
948   { "dwarf+", DWARF_DEBUG, 1,
949     N_("Generate extended DWARF-1 format debug info") },
950 #endif
951 #ifdef DWARF2_DEBUGGING_INFO
952   { "dwarf-2", DWARF2_DEBUG, 0, N_("Generate DWARF-2 debug info") },
953 #endif
954 #ifdef XCOFF_DEBUGGING_INFO
955   { "xcoff",  XCOFF_DEBUG, 0, N_("Generate XCOFF format debug info") },
956   { "xcoff+", XCOFF_DEBUG, 1, N_("Generate extended XCOFF format debug info") },
957 #endif
958 #ifdef SDB_DEBUGGING_INFO
959   { "coff", SDB_DEBUG, 0, N_("Generate COFF format debug info") },
960 #endif
961 #ifdef VMS_DEBUGGING_INFO
962   { "vms", VMS_DEBUG, 0, N_("Generate VMS format debug info") },
963 #endif
964   { 0, 0, 0, 0 }
965 };
966
967 typedef struct
968 {
969   const char *const string;
970   int *const variable;
971   const int on_value;
972   const char *const description;
973 }
974 lang_independent_options;
975
976 int flag_trapv = 0;
977
978 /* Add or remove a leading underscore from user symbols.  */
979 int flag_leading_underscore = -1;
980
981 /* The user symbol prefix after having resolved same.  */
982 const char *user_label_prefix;
983
984 static const param_info lang_independent_params[] = {
985 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
986   { OPTION, DEFAULT, HELP },
987 #include "params.def"
988 #undef DEFPARAM
989   { NULL, 0, NULL }
990 };
991
992 /* Table of language-independent -f options.
993    STRING is the option name.  VARIABLE is the address of the variable.
994    ON_VALUE is the value to store in VARIABLE
995     if `-fSTRING' is seen as an option.
996    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
997
998 static const lang_independent_options f_options[] =
999 {
1000   {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
1001    N_("Perform DWARF2 duplicate elimination") },
1002   {"float-store", &flag_float_store, 1,
1003    N_("Do not store floats in registers") },
1004   {"defer-pop", &flag_defer_pop, 1,
1005    N_("Defer popping functions args from stack until later") },
1006   {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
1007    N_("When possible do not generate stack frames") },
1008   {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
1009    N_("Optimize sibling and tail recursive calls") },
1010   {"tracer", &flag_tracer, 1,
1011    N_("Perform superblock formation via tail duplication") },
1012   {"unit-at-a-time", &flag_unit_at_a_time, 1,
1013    N_("Compile whole compilation unit at a time") },
1014   {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
1015    N_("When running CSE, follow jumps to their targets") },
1016   {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
1017    N_("When running CSE, follow conditional jumps") },
1018   {"expensive-optimizations", &flag_expensive_optimizations, 1,
1019    N_("Perform a number of minor, expensive optimizations") },
1020   {"thread-jumps", &flag_thread_jumps, 1,
1021    N_("Perform jump threading optimizations") },
1022   {"strength-reduce", &flag_strength_reduce, 1,
1023    N_("Perform strength reduction optimizations") },
1024   {"unroll-loops", &flag_unroll_loops, 1,
1025    N_("Perform loop unrolling when iteration count is known") },
1026   {"unroll-all-loops", &flag_unroll_all_loops, 1,
1027    N_("Perform loop unrolling for all loops") },
1028   {"old-unroll-loops", &flag_old_unroll_loops, 1,
1029    N_("Perform loop unrolling when iteration count is known") },
1030   {"old-unroll-all-loops", &flag_old_unroll_all_loops, 1,
1031    N_("Perform loop unrolling for all loops") },
1032   {"peel-loops", &flag_peel_loops, 1,
1033    N_("Perform loop peeling") },
1034   {"unswitch-loops", &flag_unswitch_loops, 1,
1035    N_("Perform loop unswitching") },
1036   {"prefetch-loop-arrays", &flag_prefetch_loop_arrays, 1,
1037    N_("Generate prefetch instructions, if available, for arrays in loops") },
1038   {"move-all-movables", &flag_move_all_movables, 1,
1039    N_("Force all loop invariant computations out of loops") },
1040   {"reduce-all-givs", &flag_reduce_all_givs, 1,
1041    N_("Strength reduce all loop general induction variables") },
1042   {"writable-strings", &flag_writable_strings, 1,
1043    N_("Store strings in writable data section") },
1044   {"peephole", &flag_no_peephole, 0,
1045    N_("Enable machine specific peephole optimizations") },
1046   {"force-mem", &flag_force_mem, 1,
1047    N_("Copy memory operands into registers before using") },
1048   {"force-addr", &flag_force_addr, 1,
1049    N_("Copy memory address constants into regs before using") },
1050   {"function-cse", &flag_no_function_cse, 0,
1051    N_("Allow function addresses to be held in registers") },
1052   {"inline-functions", &flag_inline_functions, 1,
1053    N_("Integrate simple functions into their callers") },
1054   {"keep-inline-functions", &flag_keep_inline_functions, 1,
1055    N_("Generate code for funcs even if they are fully inlined") },
1056   {"inline", &flag_no_inline, 0,
1057    N_("Pay attention to the 'inline' keyword") },
1058   {"keep-static-consts", &flag_keep_static_consts, 1,
1059    N_("Emit static const variables even if they are not used") },
1060   {"syntax-only", &flag_syntax_only, 1,
1061    N_("Check for syntax errors, then stop") },
1062   {"shared-data", &flag_shared_data, 1,
1063    N_("Mark data as shared rather than private") },
1064   {"caller-saves", &flag_caller_saves, 1,
1065    N_("Enable saving registers around function calls") },
1066   {"pcc-struct-return", &flag_pcc_struct_return, 1,
1067    N_("Return 'short' aggregates in memory, not registers") },
1068   {"reg-struct-return", &flag_pcc_struct_return, 0,
1069    N_("Return 'short' aggregates in registers") },
1070   {"delayed-branch", &flag_delayed_branch, 1,
1071    N_("Attempt to fill delay slots of branch instructions") },
1072   {"gcse", &flag_gcse, 1,
1073    N_("Perform the global common subexpression elimination") },
1074   {"gcse-lm", &flag_gcse_lm, 1,
1075    N_("Perform enhanced load motion during global subexpression elimination") },
1076   {"gcse-sm", &flag_gcse_sm, 1,
1077    N_("Perform store motion after global subexpression elimination") },
1078   {"loop-optimize", &flag_loop_optimize, 1,
1079    N_("Perform the loop optimizations") },
1080   {"crossjumping", &flag_crossjumping, 1,
1081    N_("Perform cross-jumping optimization") },
1082   {"if-conversion", &flag_if_conversion, 1,
1083    N_("Perform conversion of conditional jumps to branchless equivalents") },
1084   {"if-conversion2", &flag_if_conversion2, 1,
1085    N_("Perform conversion of conditional jumps to conditional execution") },
1086   {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1087    N_("Run CSE pass after loop optimizations") },
1088   {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1089    N_("Run the loop optimizer twice") },
1090   {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1091    N_("Delete useless null pointer checks") },
1092   {"schedule-insns", &flag_schedule_insns, 1,
1093    N_("Reschedule instructions before register allocation") },
1094   {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1095    N_("Reschedule instructions after register allocation") },
1096   {"sched-interblock",&flag_schedule_interblock, 1,
1097    N_("Enable scheduling across basic blocks") },
1098   {"sched-spec",&flag_schedule_speculative, 1,
1099    N_("Allow speculative motion of non-loads") },
1100   {"sched-spec-load",&flag_schedule_speculative_load, 1,
1101    N_("Allow speculative motion of some loads") },
1102   {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1103    N_("Allow speculative motion of more loads") },
1104   {"sched2-use-superblocks", &flag_sched2_use_superblocks, 1,
1105    N_("If scheduling post reload, do superblock sheduling") },
1106   {"sched2-use-traces", &flag_sched2_use_traces, 1,
1107    N_("If scheduling post reload, do trace sheduling") },
1108   {"branch-count-reg",&flag_branch_on_count_reg, 1,
1109    N_("Replace add,compare,branch with branch on count reg") },
1110   {"pic", &flag_pic, 1,
1111    N_("Generate position independent code, if possible") },
1112   {"PIC", &flag_pic, 2, ""},
1113   {"exceptions", &flag_exceptions, 1,
1114    N_("Enable exception handling") },
1115   {"unwind-tables", &flag_unwind_tables, 1,
1116    N_("Just generate unwind tables for exception handling") },
1117   {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1,
1118    N_("Generate unwind tables exact at each instruction boundary") },
1119   {"non-call-exceptions", &flag_non_call_exceptions, 1,
1120    N_("Support synchronous non-call exceptions") },
1121   {"profile-arcs", &profile_arc_flag, 1,
1122    N_("Insert arc based program profiling code") },
1123   {"test-coverage", &flag_test_coverage, 1,
1124    N_("Create data files needed by gcov") },
1125   {"branch-probabilities", &flag_branch_probabilities, 1,
1126    N_("Use profiling information for branch probabilities") },
1127   {"profile", &profile_flag, 1,
1128    N_("Enable basic program profiling code") },
1129   {"reorder-blocks", &flag_reorder_blocks, 1,
1130    N_("Reorder basic blocks to improve code placement") },
1131   {"reorder-functions", &flag_reorder_functions, 1,
1132    N_("Reorder functions to improve code placement") },
1133   {"rename-registers", &flag_rename_registers, 1,
1134    N_("Do the register renaming optimization pass") },
1135   {"cprop-registers", &flag_cprop_registers, 1,
1136    N_("Do the register copy-propagation optimization pass") },
1137   {"common", &flag_no_common, 0,
1138    N_("Do not put uninitialized globals in the common section") },
1139   {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1140    N_("Do not generate .size directives") },
1141   {"function-sections", &flag_function_sections, 1,
1142    N_("place each function into its own section") },
1143   {"data-sections", &flag_data_sections, 1,
1144    N_("place data items into their own section") },
1145   {"verbose-asm", &flag_verbose_asm, 1,
1146    N_("Add extra commentry to assembler output") },
1147   {"gnu-linker", &flag_gnu_linker, 1,
1148    N_("Output GNU ld formatted global initializers") },
1149   {"regmove", &flag_regmove, 1,
1150    N_("Enables a register move optimization") },
1151   {"optimize-register-move", &flag_regmove, 1,
1152    N_("Do the full regmove optimization pass") },
1153   {"pack-struct", &flag_pack_struct, 1,
1154    N_("Pack structure members together without holes") },
1155   {"stack-check", &flag_stack_check, 1,
1156    N_("Insert stack checking code into the program") },
1157   {"argument-alias", &flag_argument_noalias, 0,
1158    N_("Specify that arguments may alias each other & globals") },
1159   {"argument-noalias", &flag_argument_noalias, 1,
1160    N_("Assume arguments may alias globals but not each other") },
1161   {"argument-noalias-global", &flag_argument_noalias, 2,
1162    N_("Assume arguments do not alias each other or globals") },
1163   {"strict-aliasing", &flag_strict_aliasing, 1,
1164    N_("Assume strict aliasing rules apply") },
1165   {"align-loops", &align_loops, 0,
1166    N_("Align the start of loops") },
1167   {"align-jumps", &align_jumps, 0,
1168    N_("Align labels which are only reached by jumping") },
1169   {"align-labels", &align_labels, 0,
1170    N_("Align all labels") },
1171   {"align-functions", &align_functions, 0,
1172    N_("Align the start of functions") },
1173   {"merge-constants", &flag_merge_constants, 1,
1174    N_("Attempt to merge identical constants accross compilation units") },
1175   {"merge-all-constants", &flag_merge_constants, 2,
1176    N_("Attempt to merge identical constants and constant variables") },
1177   {"dump-unnumbered", &flag_dump_unnumbered, 1,
1178    N_("Suppress output of instruction numbers and line number notes in debugging dumps") },
1179   {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1180    N_("Instrument function entry/exit with profiling calls") },
1181   {"zero-initialized-in-bss", &flag_zero_initialized_in_bss, 1,
1182    N_("Put zero initialized data in the bss section") },
1183   {"ssa", &flag_ssa, 1,
1184    N_("Enable SSA optimizations") },
1185   {"ssa-ccp", &flag_ssa_ccp, 1,
1186    N_("Enable SSA conditional constant propagation") },
1187   {"ssa-dce", &flag_ssa_dce, 1,
1188    N_("Enable aggressive SSA dead code elimination") },
1189   {"leading-underscore", &flag_leading_underscore, 1,
1190    N_("External symbols have a leading underscore") },
1191   {"ident", &flag_no_ident, 0,
1192    N_("Process #ident directives") },
1193   { "peephole2", &flag_peephole2, 1,
1194    N_("Enables an rtl peephole pass run before sched2") },
1195   {"finite-math-only", &flag_finite_math_only, 1,
1196    N_("Assume no NaNs or +-Infs are generated") },
1197   { "guess-branch-probability", &flag_guess_branch_prob, 1,
1198    N_("Enables guessing of branch probabilities") },
1199   {"math-errno", &flag_errno_math, 1,
1200    N_("Set errno after built-in math functions") },
1201   {"trapping-math", &flag_trapping_math, 1,
1202    N_("Floating-point operations can trap") },
1203   {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1,
1204    N_("Allow math optimizations that may violate IEEE or ANSI standards") },
1205   {"signaling-nans", &flag_signaling_nans, 1,
1206    N_("Disable optimizations observable by IEEE signaling NaNs") },
1207   {"bounds-check", &flag_bounds_check, 1,
1208    N_("Generate code to check bounds before indexing arrays") },
1209   {"single-precision-constant", &flag_single_precision_constant, 1,
1210    N_("Convert floating point constant to single precision constant") },
1211   {"time-report", &time_report, 1,
1212    N_("Report time taken by each compiler pass at end of run") },
1213   {"mem-report", &mem_report, 1,
1214    N_("Report on permanent memory allocation at end of run") },
1215   { "trapv", &flag_trapv, 1,
1216    N_("Trap for signed overflow in addition / subtraction / multiplication") },
1217   { "new-ra", &flag_new_regalloc, 1,
1218    N_("Use graph coloring register allocation.") },
1219 };
1220
1221 /* Table of language-specific options.  */
1222
1223 static const struct lang_opt
1224 {
1225   const char *const option;
1226   const char *const description;
1227 }
1228 documented_lang_options[] =
1229 {
1230   /* In order not to overload the --help output, the convention
1231      used here is to only describe those options which are not
1232      enabled by default.  */
1233
1234   { "-ansi",
1235     N_("Compile just for ISO C90") },
1236   { "-std= ",
1237     N_("Determine language standard") },
1238
1239   { "-fsigned-bitfields", "" },
1240   { "-funsigned-bitfields",
1241     N_("Make bit-fields by unsigned by default") },
1242   { "-fno-signed-bitfields", "" },
1243   { "-fno-unsigned-bitfields","" },
1244   { "-fsigned-char",
1245     N_("Make 'char' be signed by default") },
1246   { "-funsigned-char",
1247     N_("Make 'char' be unsigned by default") },
1248   { "-fno-signed-char", "" },
1249   { "-fno-unsigned-char", "" },
1250
1251   { "-fasm", "" },
1252   { "-fno-asm",
1253     N_("Do not recognize the 'asm' keyword") },
1254   { "-fbuiltin", "" },
1255   { "-fno-builtin",
1256     N_("Do not recognize any built in functions") },
1257   { "-fhosted",
1258     N_("Assume normal C execution environment") },
1259   { "-fno-hosted", "" },
1260   { "-ffreestanding",
1261     N_("Assume that standard libraries & main might not exist") },
1262   { "-fno-freestanding", "" },
1263   { "-fcond-mismatch",
1264     N_("Allow different types as args of ? operator") },
1265   { "-fno-cond-mismatch", "" },
1266   { "-fdollars-in-identifiers",
1267     N_("Allow the use of $ inside identifiers") },
1268   { "-fno-dollars-in-identifiers", "" },
1269   { "-fpreprocessed", "" },
1270   { "-fno-preprocessed", "" },
1271   { "-fshort-double",
1272     N_("Use the same size for double as for float") },
1273   { "-fno-short-double", "" },
1274   { "-fshort-enums",
1275     N_("Use the smallest fitting integer to hold enums") },
1276   { "-fno-short-enums", "" },
1277   { "-fshort-wchar",
1278     N_("Override the underlying type for wchar_t to `unsigned short'") },
1279   { "-fno-short-wchar", "" },
1280
1281   { "-Wall",
1282     N_("Enable most warning messages") },
1283   { "-Wbad-function-cast",
1284     N_("Warn about casting functions to incompatible types") },
1285   { "-Wno-bad-function-cast", "" },
1286   { "-Wmissing-format-attribute",
1287     N_("Warn about functions which might be candidates for format attributes") },
1288   { "-Wno-missing-format-attribute", "" },
1289   { "-Wcast-qual",
1290     N_("Warn about casts which discard qualifiers") },
1291   { "-Wno-cast-qual", "" },
1292   { "-Wchar-subscripts",
1293     N_("Warn about subscripts whose type is 'char'") },
1294   { "-Wno-char-subscripts", "" },
1295   { "-Wcomment",
1296     N_("Warn if nested comments are detected") },
1297   { "-Wno-comment", "" },
1298   { "-Wcomments",
1299     N_("Warn if nested comments are detected") },
1300   { "-Wno-comments", "" },
1301   { "-Wconversion",
1302     N_("Warn about possibly confusing type conversions") },
1303   { "-Wno-conversion", "" },
1304   { "-Wdiv-by-zero", "" },
1305   { "-Wno-div-by-zero",
1306     N_("Do not warn about compile-time integer division by zero") },
1307   { "-Wfloat-equal",
1308     N_("Warn about testing equality of floating point numbers") },
1309   { "-Wno-float-equal", "" },
1310   { "-Wformat",
1311     N_("Warn about printf/scanf/strftime/strfmon format anomalies") },
1312   { "-Wno-format", "" },
1313   { "-Wformat-extra-args", "" },
1314   { "-Wno-format-extra-args",
1315     N_("Don't warn about too many arguments to format functions") },
1316   { "-Wformat-nonliteral",
1317     N_("Warn about non-string-literal format strings") },
1318   { "-Wno-format-nonliteral", "" },
1319   { "-Wformat-security",
1320     N_("Warn about possible security problems with format functions") },
1321   { "-Wno-format-security", "" },
1322   { "-Wformat-y2k", "" },
1323   { "-Wno-format-y2k",
1324     N_("Don't warn about strftime formats yielding 2 digit years") },
1325   { "-Wimplicit-function-declaration",
1326     N_("Warn about implicit function declarations") },
1327   { "-Wno-implicit-function-declaration", "" },
1328   { "-Werror-implicit-function-declaration", "" },
1329   { "-Wimplicit-int",
1330     N_("Warn when a declaration does not specify a type") },
1331   { "-Wno-implicit-int", "" },
1332   { "-Wimplicit", "" },
1333   { "-Wno-implicit", "" },
1334   { "-Wimport",
1335     N_("Warn about the use of the #import directive") },
1336   { "-Wno-import", "" },
1337   { "-Winvalid-pch",
1338     N_("Warn about PCH files that are found but not used") },
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 initializers") },
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   { "-Wpointer-arith",
1364     N_("Warn about function pointer arithmetic") },
1365   { "-Wno-pointer-arith", "" },
1366   { "-Wredundant-decls",
1367     N_("Warn about multiple declarations of the same object") },
1368   { "-Wno-redundant-decls", "" },
1369   { "-Wreturn-type",
1370     N_("Warn whenever a function's return-type defaults to int") },
1371   { "-Wno-return-type", "" },
1372   { "-Wsequence-point",
1373     N_("Warn about possible violations of sequence point rules") },
1374   { "-Wno-sequence-point", "" },
1375   { "-Wsign-compare",
1376     N_("Warn about signed/unsigned comparisons") },
1377   { "-Wno-sign-compare", "" },
1378   { "-Wstrict-prototypes",
1379     N_("Warn about non-prototyped function decls") },
1380   { "-Wno-strict-prototypes", "" },
1381   { "-Wtraditional",
1382     N_("Warn about constructs whose meanings change in ISO C") },
1383   { "-Wno-traditional", "" },
1384   { "-Wtrigraphs",
1385     N_("Warn when trigraphs are encountered") },
1386   { "-Wno-trigraphs", "" },
1387   { "-Wundef", "" },
1388   { "-Wno-undef", "" },
1389   { "-Wunknown-pragmas",
1390     N_("Warn about unrecognized pragmas") },
1391   { "-Wno-unknown-pragmas", "" },
1392   { "-Wwrite-strings",
1393     N_("Mark strings as 'const char *'") },
1394   { "-Wno-write-strings", "" },
1395
1396 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1397
1398 #include "options.h"
1399
1400 };
1401
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.)  */
1407
1408 static const struct
1409 {
1410   const char *const name;
1411   const int value;
1412   const char *const description;
1413 }
1414 target_switches[] = TARGET_SWITCHES;
1415
1416 /* This table is similar, but allows the switch to have a value.  */
1417
1418 #ifdef TARGET_OPTIONS
1419 static const struct
1420 {
1421   const char *const prefix;
1422   const char **const variable;
1423   const char *const description;
1424 }
1425 target_options[] = TARGET_OPTIONS;
1426 #endif
1427 \f
1428 /* Options controlling warnings.  */
1429
1430 /* Don't print warning messages.  -w.  */
1431
1432 int inhibit_warnings = 0;
1433
1434 /* Don't suppress warnings from system headers.  -Wsystem-headers.  */
1435
1436 int warn_system_headers = 0;
1437
1438 /* Print various extra warnings.  -W/-Wextra.  */
1439
1440 int extra_warnings = 0;
1441
1442 /* Treat warnings as errors.  -Werror.  */
1443
1444 int warnings_are_errors = 0;
1445
1446 /* Nonzero to warn about unused variables, functions et.al.  */
1447
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;
1453
1454 /* Nonzero to warn about code which is never reached.  */
1455
1456 int warn_notreached;
1457
1458 /* Nonzero to warn about variables used before they are initialized.  */
1459
1460 int warn_uninitialized;
1461
1462 /* Nonzero means warn about all declarations which shadow others.  */
1463
1464 int warn_shadow;
1465
1466 /* Warn if a switch on an enum, that does not have a default case,
1467    fails to have a case for every enum value.  */
1468
1469 int warn_switch;
1470
1471 /* Warn if a switch does not have a default case.  */
1472
1473 int warn_switch_default;
1474
1475 /* Warn if a switch on an enum fails to have a case for every enum
1476    value (regardless of the presence or otherwise of a default case).  */
1477
1478 int warn_switch_enum;
1479
1480 /* Nonzero means warn about function definitions that default the return type
1481    or that use a null return and have a return-type other than void.  */
1482
1483 int warn_return_type;
1484
1485 /* Nonzero means warn about pointer casts that increase the required
1486    alignment of the target type (and might therefore lead to a crash
1487    due to a misaligned access).  */
1488
1489 int warn_cast_align;
1490
1491 /* Nonzero means warn about any objects definitions whose size is larger
1492    than N bytes.  Also want about function definitions whose returned
1493    values are larger than N bytes. The value N is in `larger_than_size'.  */
1494
1495 int warn_larger_than;
1496 HOST_WIDE_INT larger_than_size;
1497
1498 /* Nonzero means warn if inline function is too large.  */
1499
1500 int warn_inline;
1501
1502 /* Warn if a function returns an aggregate,
1503    since there are often incompatible calling conventions for doing this.  */
1504
1505 int warn_aggregate_return;
1506
1507 /* Warn if packed attribute on struct is unnecessary and inefficient.  */
1508
1509 int warn_packed;
1510
1511 /* Warn when gcc pads a structure to an alignment boundary.  */
1512
1513 int warn_padded;
1514
1515 /* Warn when an optimization pass is disabled.  */
1516
1517 int warn_disabled_optimization;
1518
1519 /* Warn about functions which might be candidates for attribute noreturn.  */
1520
1521 int warn_missing_noreturn;
1522
1523 /* Nonzero means warn about uses of __attribute__((deprecated))
1524    declarations.  */
1525
1526 int warn_deprecated_decl = 1;
1527
1528 /* Nonzero means warn about constructs which might not be
1529    strict-aliasing safe.  */
1530
1531 int warn_strict_aliasing;
1532
1533 /* Like f_options, but for -W.  */
1534
1535 static const lang_independent_options W_options[] =
1536 {
1537   {"unused-function", &warn_unused_function, 1,
1538    N_("Warn when a function is unused") },
1539   {"unused-label", &warn_unused_label, 1,
1540    N_("Warn when a label is unused") },
1541   {"unused-parameter", &warn_unused_parameter, 1,
1542    N_("Warn when a function parameter is unused") },
1543   {"unused-variable", &warn_unused_variable, 1,
1544    N_("Warn when a variable is unused") },
1545   {"unused-value", &warn_unused_value, 1,
1546    N_("Warn when an expression value is unused") },
1547   {"system-headers", &warn_system_headers, 1,
1548    N_("Do not suppress warnings from system headers") },
1549   {"error", &warnings_are_errors, 1,
1550    N_("Treat all warnings as errors") },
1551   {"shadow", &warn_shadow, 1,
1552    N_("Warn when one local variable shadows another") },
1553   {"switch", &warn_switch, 1,
1554    N_("Warn about enumerated switches, with no default, missing a case") },
1555   {"switch-default", &warn_switch_default, 1,
1556    N_("Warn about enumerated switches missing a default case") },
1557   {"switch-enum", &warn_switch_enum, 1,
1558    N_("Warn about all enumerated switches missing a specific case") },
1559   {"aggregate-return", &warn_aggregate_return, 1,
1560    N_("Warn about returning structures, unions or arrays") },
1561   {"cast-align", &warn_cast_align, 1,
1562    N_("Warn about pointer casts which increase alignment") },
1563   {"unreachable-code", &warn_notreached, 1,
1564    N_("Warn about code that will never be executed") },
1565   {"uninitialized", &warn_uninitialized, 1,
1566    N_("Warn about uninitialized automatic variables") },
1567   {"inline", &warn_inline, 1,
1568    N_("Warn when an inlined function cannot be inlined") },
1569   {"packed", &warn_packed, 1,
1570    N_("Warn when the packed attribute has no effect on struct layout") },
1571   {"padded", &warn_padded, 1,
1572    N_("Warn when padding is required to align struct members") },
1573   {"disabled-optimization", &warn_disabled_optimization, 1,
1574    N_("Warn when an optimization pass is disabled") },
1575   {"deprecated-declarations", &warn_deprecated_decl, 1,
1576    N_("Warn about uses of __attribute__((deprecated)) declarations") },
1577   {"extra", &extra_warnings, 1,
1578    N_("Print extra (possibly unwanted) warnings") },
1579   {"missing-noreturn", &warn_missing_noreturn, 1,
1580    N_("Warn about functions which might be candidates for attribute noreturn") },
1581   {"strict-aliasing", &warn_strict_aliasing, 1,
1582    N_ ("Warn about code which might break the strict aliasing rules") }
1583 };
1584
1585 void
1586 set_Wunused (setting)
1587      int setting;
1588 {
1589   warn_unused_function = setting;
1590   warn_unused_label = setting;
1591   /* Unused function parameter warnings are reported when either ``-W
1592      -Wunused'' or ``-Wunused-parameter'' is specified.  Differentiate
1593      -Wunused by setting WARN_UNUSED_PARAMETER to -1.  */
1594   if (!setting)
1595     warn_unused_parameter = 0;
1596   else if (!warn_unused_parameter)
1597     warn_unused_parameter = -1;
1598   warn_unused_variable = setting;
1599   warn_unused_value = setting;
1600 }
1601
1602 /* The following routines are useful in setting all the flags that
1603    -ffast-math and -fno-fast-math imply.  */
1604
1605 void
1606 set_fast_math_flags (set)
1607      int set;
1608 {
1609   flag_trapping_math = !set;
1610   flag_unsafe_math_optimizations = set;
1611   flag_finite_math_only = set;
1612   flag_errno_math = !set;
1613   if (set)
1614     flag_signaling_nans = 0;
1615 }
1616
1617 /* Return true iff flags are set as if -ffast-math.  */
1618 bool
1619 fast_math_flags_set_p ()
1620 {
1621   return (!flag_trapping_math
1622           && flag_unsafe_math_optimizations
1623           && flag_finite_math_only
1624           && !flag_errno_math);
1625 }
1626
1627 \f
1628 /* Output files for assembler code (real compiler output)
1629    and debugging dumps.  */
1630
1631 FILE *asm_out_file;
1632 FILE *aux_info_file;
1633 FILE *rtl_dump_file = NULL;
1634
1635 /* Decode the string P as an integral parameter.
1636    If the string is indeed an integer return its numeric value else
1637    issue an Invalid Option error for the option PNAME and return DEFVAL.
1638    If PNAME is zero just return DEFVAL, do not call error.  */
1639
1640 int
1641 read_integral_parameter (p, pname, defval)
1642      const char *p;
1643      const char *pname;
1644      const int  defval;
1645 {
1646   const char *endp = p;
1647
1648   while (*endp)
1649     {
1650       if (ISDIGIT (*endp))
1651         endp++;
1652       else
1653         break;
1654     }
1655
1656   if (*endp != 0)
1657     {
1658       if (pname != 0)
1659         error ("invalid option `%s'", pname);
1660       return defval;
1661     }
1662
1663   return atoi (p);
1664 }
1665 \f
1666 /* This calls abort and is used to avoid problems when abort is a macro.
1667    It is used when we need to pass the address of abort.  */
1668
1669 void
1670 do_abort ()
1671 {
1672   abort ();
1673 }
1674
1675 /* When `malloc.c' is compiled with `rcheck' defined,
1676    it calls this function to report clobberage.  */
1677
1678 void
1679 botch (s)
1680      const char *s ATTRIBUTE_UNUSED;
1681 {
1682   abort ();
1683 }
1684 \f
1685 /* Return the logarithm of X, base 2, considering X unsigned,
1686    if X is a power of 2.  Otherwise, returns -1.
1687
1688    This should be used via the `exact_log2' macro.  */
1689
1690 int
1691 exact_log2_wide (x)
1692      unsigned HOST_WIDE_INT x;
1693 {
1694   int log = 0;
1695   /* Test for 0 or a power of 2.  */
1696   if (x == 0 || x != (x & -x))
1697     return -1;
1698   while ((x >>= 1) != 0)
1699     log++;
1700   return log;
1701 }
1702
1703 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1704    If X is 0, return -1.
1705
1706    This should be used via the floor_log2 macro.  */
1707
1708 int
1709 floor_log2_wide (x)
1710      unsigned HOST_WIDE_INT x;
1711 {
1712   int log = -1;
1713   while (x != 0)
1714     log++,
1715     x >>= 1;
1716   return log;
1717 }
1718
1719 /* Handler for fatal signals, such as SIGSEGV.  These are transformed
1720    into ICE messages, which is much more user friendly.  */
1721
1722 static void
1723 crash_signal (signo)
1724      int signo;
1725 {
1726   internal_error ("%s", strsignal (signo));
1727 }
1728
1729 /* Arrange to dump core on error.  (The regular error message is still
1730    printed first, except in the case of abort().)  */
1731
1732 static void
1733 setup_core_dumping ()
1734 {
1735 #ifdef SIGABRT
1736   signal (SIGABRT, SIG_DFL);
1737 #endif
1738 #if defined(HAVE_SETRLIMIT)
1739   {
1740     struct rlimit rlim;
1741     if (getrlimit (RLIMIT_CORE, &rlim) != 0)
1742       fatal_io_error ("getting core file size maximum limit");
1743     rlim.rlim_cur = rlim.rlim_max;
1744     if (setrlimit (RLIMIT_CORE, &rlim) != 0)
1745       fatal_io_error ("setting core file size limit to maximum");
1746   }
1747 #endif
1748   diagnostic_abort_on_error (global_dc);
1749 }
1750
1751
1752 /* Strip off a legitimate source ending from the input string NAME of
1753    length LEN.  Rather than having to know the names used by all of
1754    our front ends, we strip off an ending of a period followed by
1755    up to five characters.  (Java uses ".class".)  */
1756
1757 void
1758 strip_off_ending (name, len)
1759      char *name;
1760      int len;
1761 {
1762   int i;
1763   for (i = 2; i < 6 && len > i; i++)
1764     {
1765       if (name[len - i] == '.')
1766         {
1767           name[len - i] = '\0';
1768           break;
1769         }
1770     }
1771 }
1772
1773 /* Output a quoted string.  */
1774
1775 void
1776 output_quoted_string (asm_file, string)
1777      FILE *asm_file;
1778      const char *string;
1779 {
1780 #ifdef OUTPUT_QUOTED_STRING
1781   OUTPUT_QUOTED_STRING (asm_file, string);
1782 #else
1783   char c;
1784
1785   putc ('\"', asm_file);
1786   while ((c = *string++) != 0)
1787     {
1788       if (ISPRINT (c))
1789         {
1790           if (c == '\"' || c == '\\')
1791             putc ('\\', asm_file);
1792           putc (c, asm_file);
1793         }
1794       else
1795         fprintf (asm_file, "\\%03o", (unsigned char) c);
1796     }
1797   putc ('\"', asm_file);
1798 #endif
1799 }
1800
1801 /* Output NAME into FILE after having turned it into something
1802    usable as an identifier in a target's assembly file.  */
1803 void
1804 output_clean_symbol_name (file, name)
1805      FILE *file;
1806      const char *name;
1807 {
1808   /* Make a copy of NAME.  */
1809   char *id = xstrdup (name);
1810
1811   /* Make it look like a valid identifier for an assembler.  */
1812   clean_symbol_name (id);
1813
1814   fputs (id, file);
1815   free (id);
1816 }
1817
1818
1819 /* Output a file name in the form wanted by System V.  */
1820
1821 void
1822 output_file_directive (asm_file, input_name)
1823      FILE *asm_file;
1824      const char *input_name;
1825 {
1826   int len = strlen (input_name);
1827   const char *na = input_name + len;
1828
1829   /* NA gets INPUT_NAME sans directory names.  */
1830   while (na > input_name)
1831     {
1832       if (IS_DIR_SEPARATOR (na[-1]))
1833         break;
1834       na--;
1835     }
1836
1837 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1838   ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1839 #else
1840 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1841   ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1842 #else
1843   fprintf (asm_file, "\t.file\t");
1844   output_quoted_string (asm_file, na);
1845   fputc ('\n', asm_file);
1846 #endif
1847 #endif
1848 }
1849 \f
1850 /* Routine to open a dump file.  Return true if the dump file is enabled.  */
1851
1852 static int
1853 open_dump_file (index, decl)
1854      enum dump_file_index index;
1855      tree decl;
1856 {
1857   char *dump_name;
1858   const char *open_arg;
1859   char seq[16];
1860
1861   if (! dump_file[index].enabled)
1862     return 0;
1863
1864   timevar_push (TV_DUMP);
1865   if (rtl_dump_file != NULL)
1866     fclose (rtl_dump_file);
1867
1868   sprintf (seq, DUMPFILE_FORMAT, index);
1869
1870   if (! dump_file[index].initialized)
1871     {
1872       /* If we've not initialized the files, do so now.  */
1873       if (graph_dump_format != no_graph
1874           && dump_file[index].graph_dump_p)
1875         {
1876           dump_name = concat (seq, dump_file[index].extension, NULL);
1877           clean_graph_dump_file (dump_base_name, dump_name);
1878           free (dump_name);
1879         }
1880       dump_file[index].initialized = 1;
1881       open_arg = "w";
1882     }
1883   else
1884     open_arg = "a";
1885
1886   dump_name = concat (dump_base_name, seq,
1887                       dump_file[index].extension, NULL);
1888
1889   rtl_dump_file = fopen (dump_name, open_arg);
1890   if (rtl_dump_file == NULL)
1891     fatal_io_error ("can't open %s", dump_name);
1892
1893   free (dump_name);
1894
1895   if (decl)
1896     fprintf (rtl_dump_file, "\n;; Function %s%s\n\n",
1897              (*lang_hooks.decl_printable_name) (decl, 2),
1898              cfun->function_frequency == FUNCTION_FREQUENCY_HOT
1899              ? " (hot)"
1900              : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
1901              ? " (unlikely executed)"
1902              : "");
1903
1904   timevar_pop (TV_DUMP);
1905   return 1;
1906 }
1907
1908 /* Routine to close a dump file.  */
1909
1910 static void
1911 close_dump_file (index, func, insns)
1912      enum dump_file_index index;
1913      void (*func) PARAMS ((FILE *, rtx));
1914      rtx insns;
1915 {
1916   if (! rtl_dump_file)
1917     return;
1918
1919   timevar_push (TV_DUMP);
1920   if (insns
1921       && graph_dump_format != no_graph
1922       && dump_file[index].graph_dump_p)
1923     {
1924       char seq[16];
1925       char *suffix;
1926
1927       sprintf (seq, DUMPFILE_FORMAT, index);
1928       suffix = concat (seq, dump_file[index].extension, NULL);
1929       print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1930       free (suffix);
1931     }
1932
1933   if (func && insns)
1934     func (rtl_dump_file, insns);
1935
1936   fflush (rtl_dump_file);
1937   fclose (rtl_dump_file);
1938
1939   rtl_dump_file = NULL;
1940   timevar_pop (TV_DUMP);
1941 }
1942
1943 /* Do any final processing required for the declarations in VEC, of
1944    which there are LEN.  We write out inline functions and variables
1945    that have been deferred until this point, but which are required.
1946    Returns nonzero if anything was put out.  */
1947
1948 int
1949 wrapup_global_declarations (vec, len)
1950      tree *vec;
1951      int len;
1952 {
1953   tree decl;
1954   int i;
1955   int reconsider;
1956   int output_something = 0;
1957
1958   for (i = 0; i < len; i++)
1959     {
1960       decl = vec[i];
1961
1962       /* We're not deferring this any longer.  Assignment is
1963          conditional to avoid needlessly dirtying PCH pages. */
1964       if (DECL_DEFER_OUTPUT (decl) != 0)
1965         DECL_DEFER_OUTPUT (decl) = 0;
1966
1967       if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1968         (*lang_hooks.finish_incomplete_decl) (decl);
1969     }
1970
1971   /* Now emit any global variables or functions that we have been
1972      putting off.  We need to loop in case one of the things emitted
1973      here references another one which comes earlier in the list.  */
1974   do
1975     {
1976       reconsider = 0;
1977       for (i = 0; i < len; i++)
1978         {
1979           decl = vec[i];
1980
1981           if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1982             continue;
1983
1984           /* Don't write out static consts, unless we still need them.
1985
1986              We also keep static consts if not optimizing (for debugging),
1987              unless the user specified -fno-keep-static-consts.
1988              ??? They might be better written into the debug information.
1989              This is possible when using DWARF.
1990
1991              A language processor that wants static constants to be always
1992              written out (even if it is not used) is responsible for
1993              calling rest_of_decl_compilation itself.  E.g. the C front-end
1994              calls rest_of_decl_compilation from finish_decl.
1995              One motivation for this is that is conventional in some
1996              environments to write things like:
1997              static const char rcsid[] = "... version string ...";
1998              intending to force the string to be in the executable.
1999
2000              A language processor that would prefer to have unneeded
2001              static constants "optimized away" would just defer writing
2002              them out until here.  E.g. C++ does this, because static
2003              constants are often defined in header files.
2004
2005              ??? A tempting alternative (for both C and C++) would be
2006              to force a constant to be written if and only if it is
2007              defined in a main file, as opposed to an include file.  */
2008
2009           if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
2010             {
2011               bool needed = 1;
2012
2013               if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2014                 /* needed */;
2015               else if (DECL_COMDAT (decl))
2016                 needed = 0;
2017               else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
2018                        && (optimize || !flag_keep_static_consts
2019                            || DECL_ARTIFICIAL (decl)))
2020                 needed = 0;
2021
2022               if (needed)
2023                 {
2024                   reconsider = 1;
2025                   rest_of_decl_compilation (decl, NULL, 1, 1);
2026                 }
2027             }
2028
2029           if (TREE_CODE (decl) == FUNCTION_DECL
2030               && DECL_INITIAL (decl) != 0
2031               && DECL_SAVED_INSNS (decl) != 0
2032               && (flag_keep_inline_functions
2033                   || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2034                   || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2035             {
2036               reconsider = 1;
2037               output_inline_function (decl);
2038             }
2039         }
2040
2041       if (reconsider)
2042         output_something = 1;
2043     }
2044   while (reconsider);
2045
2046   return output_something;
2047 }
2048
2049 /* Issue appropriate warnings for the global declarations in VEC (of
2050    which there are LEN).  Output debugging information for them.  */
2051
2052 void
2053 check_global_declarations (vec, len)
2054      tree *vec;
2055      int len;
2056 {
2057   tree decl;
2058   int i;
2059
2060   for (i = 0; i < len; i++)
2061     {
2062       decl = vec[i];
2063
2064       if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2065           && ! TREE_ASM_WRITTEN (decl))
2066         /* Cancel the RTL for this decl so that, if debugging info
2067            output for global variables is still to come,
2068            this one will be omitted.  */
2069         SET_DECL_RTL (decl, NULL_RTX);
2070
2071       /* Warn about any function
2072          declared static but not defined.
2073          We don't warn about variables,
2074          because many programs have static variables
2075          that exist only to get some text into the object file.  */
2076       if (TREE_CODE (decl) == FUNCTION_DECL
2077           && (warn_unused_function
2078               || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2079           && DECL_INITIAL (decl) == 0
2080           && DECL_EXTERNAL (decl)
2081           && ! DECL_ARTIFICIAL (decl)
2082           && ! TREE_PUBLIC (decl))
2083         {
2084           if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2085             pedwarn_with_decl (decl,
2086                                "`%s' used but never defined");
2087           else
2088             warning_with_decl (decl,
2089                                "`%s' declared `static' but never defined");
2090           /* This symbol is effectively an "extern" declaration now.  */
2091           TREE_PUBLIC (decl) = 1;
2092           assemble_external (decl);
2093         }
2094
2095       /* Warn about static fns or vars defined but not used.  */
2096       if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
2097            || (warn_unused_variable && TREE_CODE (decl) == VAR_DECL))
2098           && ! TREE_USED (decl)
2099           /* The TREE_USED bit for file-scope decls is kept in the identifier,
2100              to handle multiple external decls in different scopes.  */
2101           && ! TREE_USED (DECL_NAME (decl))
2102           && ! DECL_EXTERNAL (decl)
2103           && ! TREE_PUBLIC (decl)
2104           /* Global register variables must be declared to reserve them.  */
2105           && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
2106           /* Otherwise, ask the language.  */
2107           && (*lang_hooks.decls.warn_unused_global) (decl))
2108         warning_with_decl (decl, "`%s' defined but not used");
2109
2110       /* Avoid confusing the debug information machinery when there are
2111          errors.  */
2112       if (errorcount == 0 && sorrycount == 0)
2113         {
2114           timevar_push (TV_SYMOUT);
2115           (*debug_hooks->global_decl) (decl);
2116           timevar_pop (TV_SYMOUT);
2117         }
2118     }
2119 }
2120
2121 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2122    INPUT_FILE_STACK.  Push a new entry for FILE and LINE, and set the
2123    INPUT_FILENAME and LINENO accordingly.  */
2124
2125 void
2126 push_srcloc (file, line)
2127      const char *file;
2128      int line;
2129 {
2130   struct file_stack *fs;
2131
2132   if (input_file_stack)
2133     {
2134       input_file_stack->name = input_filename;
2135       input_file_stack->line = lineno;
2136     }
2137
2138   fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2139   fs->name = input_filename = file;
2140   fs->line = lineno = line;
2141   fs->next = input_file_stack;
2142   input_file_stack = fs;
2143   input_file_stack_tick++;
2144 }
2145
2146 /* Pop the top entry off the stack of presently open source files.
2147    Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2148    the stack.  */
2149
2150 void
2151 pop_srcloc ()
2152 {
2153   struct file_stack *fs;
2154
2155   fs = input_file_stack;
2156   input_file_stack = fs->next;
2157   free (fs);
2158   input_file_stack_tick++;
2159   /* The initial source file is never popped.  */
2160   if (!input_file_stack)
2161     abort ();
2162   input_filename = input_file_stack->name;
2163   lineno = input_file_stack->line;
2164 }
2165
2166 /* Compile an entire translation unit.  Write a file of assembly
2167    output and various debugging dumps.  */
2168
2169 static void
2170 compile_file ()
2171 {
2172   /* Initialize yet another pass.  */
2173
2174   init_final (main_input_filename);
2175   init_branch_prob (aux_base_name);
2176
2177   timevar_push (TV_PARSE);
2178
2179   /* Call the parser, which parses the entire file (calling
2180      rest_of_compilation for each function).  */
2181   (*lang_hooks.parse_file) (set_yydebug);
2182
2183   /* In case there were missing block closers,
2184      get us back to the global binding level.  */
2185   (*lang_hooks.clear_binding_stack) ();
2186
2187   /* Compilation is now finished except for writing
2188      what's left of the symbol table output.  */
2189   timevar_pop (TV_PARSE);
2190
2191   if (flag_syntax_only)
2192     return;
2193
2194   (*lang_hooks.decls.final_write_globals)();
2195
2196     if (profile_arc_flag)
2197       /* This must occur after the loop to output deferred functions.
2198          Else the profiler initializer would not be emitted if all the
2199          functions in this compilation unit were deferred.  */
2200       create_profiler ();
2201
2202   /* Write out any pending weak symbol declarations.  */
2203
2204   weak_finish ();
2205
2206   /* Do dbx symbols.  */
2207   timevar_push (TV_SYMOUT);
2208
2209 #ifdef DWARF2_UNWIND_INFO
2210   if (dwarf2out_do_frame ())
2211     dwarf2out_frame_finish ();
2212 #endif
2213
2214   (*debug_hooks->finish) (main_input_filename);
2215   timevar_pop (TV_SYMOUT);
2216
2217   /* Output some stuff at end of file if nec.  */
2218
2219   dw2_output_indirect_constants ();
2220
2221   if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2222     {
2223       timevar_push (TV_DUMP);
2224       open_dump_file (DFI_bp, NULL);
2225
2226       end_branch_prob ();
2227
2228       close_dump_file (DFI_bp, NULL, NULL_RTX);
2229       timevar_pop (TV_DUMP);
2230     }
2231
2232 #ifdef ASM_FILE_END
2233   ASM_FILE_END (asm_out_file);
2234 #endif
2235
2236   /* Attach a special .ident directive to the end of the file to identify
2237      the version of GCC which compiled this code.  The format of the .ident
2238      string is patterned after the ones produced by native SVR4 compilers.  */
2239 #ifdef IDENT_ASM_OP
2240   if (!flag_no_ident)
2241     fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2242              IDENT_ASM_OP, version_string);
2243 #endif
2244
2245   if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2246     {
2247       timevar_push (TV_DUMP);
2248       dump_combine_total_stats (rtl_dump_file);
2249       close_dump_file (DFI_combine, NULL, NULL_RTX);
2250       timevar_pop (TV_DUMP);
2251     }
2252 }
2253 \f
2254 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2255    and TYPE_DECL nodes.
2256
2257    This does nothing for local (non-static) variables, unless the
2258    variable is a register variable with an ASMSPEC.  In that case, or
2259    if the variable is not an automatic, it sets up the RTL and
2260    outputs any assembler code (label definition, storage allocation
2261    and initialization).
2262
2263    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
2264    the assembler symbol name to be used.  TOP_LEVEL is nonzero
2265    if this declaration is not within a function.  */
2266
2267 void
2268 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2269      tree decl;
2270      const char *asmspec;
2271      int top_level;
2272      int at_end;
2273 {
2274   /* We deferred calling assemble_alias so that we could collect
2275      other attributes such as visibility.  Emit the alias now.  */
2276   {
2277     tree alias;
2278     alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
2279     if (alias)
2280       {
2281         alias = TREE_VALUE (TREE_VALUE (alias));
2282         alias = get_identifier (TREE_STRING_POINTER (alias));
2283         assemble_alias (decl, alias);
2284       }
2285   }
2286
2287   /* Forward declarations for nested functions are not "external",
2288      but we need to treat them as if they were.  */
2289   if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2290       || TREE_CODE (decl) == FUNCTION_DECL)
2291     {
2292       timevar_push (TV_VARCONST);
2293
2294       if (asmspec)
2295         make_decl_rtl (decl, asmspec);
2296
2297       /* Don't output anything when a tentative file-scope definition
2298          is seen.  But at end of compilation, do output code for them.  */
2299       if (at_end || !DECL_DEFER_OUTPUT (decl))
2300         assemble_variable (decl, top_level, at_end, 0);
2301
2302 #ifdef ASM_FINISH_DECLARE_OBJECT
2303       if (decl == last_assemble_variable_decl)
2304         {
2305           ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2306                                      top_level, at_end);
2307         }
2308 #endif
2309
2310       timevar_pop (TV_VARCONST);
2311     }
2312   else if (DECL_REGISTER (decl) && asmspec != 0)
2313     {
2314       if (decode_reg_name (asmspec) >= 0)
2315         {
2316           SET_DECL_RTL (decl, NULL_RTX);
2317           make_decl_rtl (decl, asmspec);
2318         }
2319       else
2320         {
2321           error ("invalid register name `%s' for register variable", asmspec);
2322           DECL_REGISTER (decl) = 0;
2323           if (!top_level)
2324             expand_decl (decl);
2325         }
2326     }
2327 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2328   else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2329            && TREE_CODE (decl) == TYPE_DECL)
2330     {
2331       timevar_push (TV_SYMOUT);
2332       dbxout_symbol (decl, 0);
2333       timevar_pop (TV_SYMOUT);
2334     }
2335 #endif
2336 #ifdef SDB_DEBUGGING_INFO
2337   else if (write_symbols == SDB_DEBUG && top_level
2338            && TREE_CODE (decl) == TYPE_DECL)
2339     {
2340       timevar_push (TV_SYMOUT);
2341       sdbout_symbol (decl, 0);
2342       timevar_pop (TV_SYMOUT);
2343     }
2344 #endif
2345 #ifdef DWARF2_DEBUGGING_INFO
2346   else if ((write_symbols == DWARF2_DEBUG
2347            || write_symbols == VMS_AND_DWARF2_DEBUG)
2348            && top_level
2349            && TREE_CODE (decl) == TYPE_DECL)
2350     {
2351       timevar_push (TV_SYMOUT);
2352       dwarf2out_decl (decl);
2353       timevar_pop (TV_SYMOUT);
2354     }
2355 #endif
2356 }
2357
2358 /* Called after finishing a record, union or enumeral type.  */
2359
2360 void
2361 rest_of_type_compilation (type, toplev)
2362 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)      \
2363     || defined (SDB_DEBUGGING_INFO) || defined (DWARF2_DEBUGGING_INFO)
2364      tree type;
2365      int toplev;
2366 #else
2367      tree type ATTRIBUTE_UNUSED;
2368      int toplev ATTRIBUTE_UNUSED;
2369 #endif
2370 {
2371   /* Avoid confusing the debug information machinery when there are
2372      errors.  */
2373   if (errorcount != 0 || sorrycount != 0)
2374     return;
2375
2376   timevar_push (TV_SYMOUT);
2377 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2378   if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2379     dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2380 #endif
2381 #ifdef SDB_DEBUGGING_INFO
2382   if (write_symbols == SDB_DEBUG)
2383     sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2384 #endif
2385 #ifdef DWARF2_DEBUGGING_INFO
2386   if ((write_symbols == DWARF2_DEBUG
2387        || write_symbols == VMS_AND_DWARF2_DEBUG)
2388       && toplev)
2389     dwarf2out_decl (TYPE_STUB_DECL (type));
2390 #endif
2391   timevar_pop (TV_SYMOUT);
2392 }
2393
2394 /* This is called from finish_function (within langhooks.parse_file)
2395    after each top-level definition is parsed.
2396    It is supposed to compile that function or variable
2397    and output the assembler code for it.
2398    After we return, the tree storage is freed.  */
2399
2400 void
2401 rest_of_compilation (decl)
2402      tree decl;
2403 {
2404   rtx insns;
2405   int tem;
2406   int failure = 0;
2407   int rebuild_label_notes_after_reload;
2408
2409   timevar_push (TV_REST_OF_COMPILATION);
2410
2411   /* Now that we're out of the frontend, we shouldn't have any more
2412      CONCATs anywhere.  */
2413   generating_concat_p = 0;
2414
2415   /* When processing delayed functions, prepare_function_start() won't
2416      have been run to re-initialize it.  */
2417   cse_not_expected = ! optimize;
2418
2419   /* First, make sure that NOTE_BLOCK is set correctly for each
2420      NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note.  */
2421   if (!cfun->x_whole_function_mode_p)
2422     identify_blocks ();
2423
2424   /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2425      tree in sensible shape.  So, we just recalculate it here.  */
2426   if (cfun->x_whole_function_mode_p)
2427     reorder_blocks ();
2428
2429   init_flow ();
2430
2431   /* If we are reconsidering an inline function
2432      at the end of compilation, skip the stuff for making it inline.  */
2433
2434   if (DECL_SAVED_INSNS (decl) == 0)
2435     {
2436       int inlinable = 0;
2437       tree parent;
2438       const char *lose;
2439
2440       /* If this is nested inside an inlined external function, pretend
2441          it was only declared.  Since we cannot inline such functions,
2442          generating code for this one is not only not necessary but will
2443          confuse some debugging output writers.  */
2444       for (parent = DECL_CONTEXT (current_function_decl);
2445            parent != NULL_TREE;
2446            parent = get_containing_scope (parent))
2447         if (TREE_CODE (parent) == FUNCTION_DECL
2448             && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2449           {
2450             DECL_INITIAL (decl) = 0;
2451             goto exit_rest_of_compilation;
2452           }
2453         else if (TYPE_P (parent))
2454           /* A function in a local class should be treated normally.  */
2455           break;
2456
2457       /* If requested, consider whether to make this function inline.  */
2458       if ((DECL_INLINE (decl) && !flag_no_inline)
2459           || flag_inline_functions)
2460         {
2461           timevar_push (TV_INTEGRATION);
2462           lose = function_cannot_inline_p (decl);
2463           timevar_pop (TV_INTEGRATION);
2464           if (lose || ! optimize)
2465             {
2466               if (warn_inline && DECL_INLINE (decl))
2467                 warning_with_decl (decl, lose);
2468               DECL_ABSTRACT_ORIGIN (decl) = 0;
2469               /* Don't really compile an extern inline function.
2470                  If we can't make it inline, pretend
2471                  it was only declared.  */
2472               if (DECL_EXTERNAL (decl))
2473                 {
2474                   DECL_INITIAL (decl) = 0;
2475                   goto exit_rest_of_compilation;
2476                 }
2477             }
2478           else
2479             /* ??? Note that this has the effect of making it look
2480                  like "inline" was specified for a function if we choose
2481                  to inline it.  This isn't quite right, but it's
2482                  probably not worth the trouble to fix.  */
2483             inlinable = DECL_INLINE (decl) = 1;
2484         }
2485
2486       insns = get_insns ();
2487
2488       /* Dump the rtl code if we are dumping rtl.  */
2489
2490       if (open_dump_file (DFI_rtl, decl))
2491         {
2492           if (DECL_SAVED_INSNS (decl))
2493             fprintf (rtl_dump_file, ";; (integrable)\n\n");
2494           close_dump_file (DFI_rtl, print_rtl, insns);
2495         }
2496
2497       /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2498          sorts of eh initialization.  Delay this until after the
2499          initial rtl dump so that we can see the original nesting.  */
2500       convert_from_eh_region_ranges ();
2501
2502       /* If function is inline, and we don't yet know whether to
2503          compile it by itself, defer decision till end of compilation.
2504          wrapup_global_declarations will (indirectly) call
2505          rest_of_compilation again for those functions that need to
2506          be output.  Also defer those functions that we are supposed
2507          to defer.  */
2508
2509       if (inlinable
2510           || (DECL_INLINE (decl)
2511               && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2512                    && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
2513                    && ! flag_keep_inline_functions)
2514                   || DECL_EXTERNAL (decl))))
2515         DECL_DEFER_OUTPUT (decl) = 1;
2516
2517       if (DECL_INLINE (decl))
2518         /* DWARF wants separate debugging info for abstract and
2519            concrete instances of all inline functions, including those
2520            declared inline but not inlined, and those inlined even
2521            though they weren't declared inline.  Conveniently, that's
2522            what DECL_INLINE means at this point.  */
2523         (*debug_hooks->deferred_inline_function) (decl);
2524
2525       if (DECL_DEFER_OUTPUT (decl))
2526         {
2527           /* If -Wreturn-type, we have to do a bit of compilation.  We just
2528              want to call cleanup the cfg to figure out whether or not we can
2529              fall off the end of the function; we do the minimum amount of
2530              work necessary to make that safe.  */
2531           if (warn_return_type)
2532             {
2533               int saved_optimize = optimize;
2534
2535               optimize = 0;
2536               rebuild_jump_labels (insns);
2537               find_exception_handler_labels ();
2538               find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2539               cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2540               optimize = saved_optimize;
2541
2542               /* CFG is no longer maintained up-to-date.  */
2543               free_bb_for_insn ();
2544             }
2545
2546           set_nothrow_function_flags ();
2547           if (current_function_nothrow)
2548             /* Now we know that this can't throw; set the flag for the benefit
2549                of other functions later in this translation unit.  */
2550             TREE_NOTHROW (current_function_decl) = 1;
2551
2552           timevar_push (TV_INTEGRATION);
2553           save_for_inline (decl);
2554           timevar_pop (TV_INTEGRATION);
2555           DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2556           goto exit_rest_of_compilation;
2557         }
2558
2559       /* If specified extern inline but we aren't inlining it, we are
2560          done.  This goes for anything that gets here with DECL_EXTERNAL
2561          set, not just things with DECL_INLINE.  */
2562       if (DECL_EXTERNAL (decl))
2563         goto exit_rest_of_compilation;
2564     }
2565
2566   /* If we're emitting a nested function, make sure its parent gets
2567      emitted as well.  Doing otherwise confuses debug info.  */
2568   {
2569     tree parent;
2570     for (parent = DECL_CONTEXT (current_function_decl);
2571          parent != NULL_TREE;
2572          parent = get_containing_scope (parent))
2573       if (TREE_CODE (parent) == FUNCTION_DECL)
2574         TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
2575   }
2576
2577   /* We are now committed to emitting code for this function.  Do any
2578      preparation, such as emitting abstract debug info for the inline
2579      before it gets mangled by optimization.  */
2580   if (DECL_INLINE (decl))
2581     (*debug_hooks->outlining_inline_function) (decl);
2582
2583   /* Remove any notes we don't need.  That will make iterating
2584      over the instruction sequence faster, and allow the garbage
2585      collector to reclaim the memory used by the notes.  */
2586   remove_unnecessary_notes ();
2587   reorder_blocks ();
2588
2589   ggc_collect ();
2590
2591   /* Initialize some variables used by the optimizers.  */
2592   init_function_for_compilation ();
2593
2594   if (! DECL_DEFER_OUTPUT (decl))
2595     TREE_ASM_WRITTEN (decl) = 1;
2596
2597   /* Now that integrate will no longer see our rtl, we need not
2598      distinguish between the return value of this function and the
2599      return value of called functions.  Also, we can remove all SETs
2600      of subregs of hard registers; they are only here because of
2601      integrate.  Also, we can now initialize pseudos intended to
2602      carry magic hard reg data throughout the function.  */
2603   rtx_equal_function_value_matters = 0;
2604   purge_hard_subreg_sets (get_insns ());
2605
2606   /* Early return if there were errors.  We can run afoul of our
2607      consistency checks, and there's not really much point in fixing them.
2608      Don't return yet if -Wreturn-type; we need to do cleanup_cfg.  */
2609   if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2610       || errorcount || sorrycount)
2611     goto exit_rest_of_compilation;
2612
2613   timevar_push (TV_JUMP);
2614   open_dump_file (DFI_sibling, decl);
2615   insns = get_insns ();
2616   rebuild_jump_labels (insns);
2617   find_exception_handler_labels ();
2618   find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2619
2620   delete_unreachable_blocks ();
2621
2622   /* Turn NOTE_INSN_PREDICTIONs into branch predictions.  */
2623   if (flag_guess_branch_prob)
2624     {
2625       timevar_push (TV_BRANCH_PROB);
2626       note_prediction_to_br_prob ();
2627       timevar_pop (TV_BRANCH_PROB);
2628     }
2629
2630   /* We may have potential sibling or tail recursion sites.  Select one
2631      (of possibly multiple) methods of performing the call.  */
2632   if (flag_optimize_sibling_calls)
2633     {
2634       rtx insn;
2635       optimize_sibling_and_tail_recursive_calls ();
2636
2637       /* Recompute the CFG as sibling optimization clobbers it randomly.  */
2638       free_bb_for_insn ();
2639       find_exception_handler_labels ();
2640       rebuild_jump_labels (insns);
2641       find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2642
2643       /* There is pass ordering problem - we must lower NOTE_INSN_PREDICTION
2644          notes before simplifying cfg and we must do lowering after sibcall
2645          that unhides parts of RTL chain and cleans up the CFG.
2646
2647          Until sibcall is replaced by tree-level optimizer, lets just
2648          sweep away the NOTE_INSN_PREDICTION notes that leaked out.  */
2649       for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2650         if (GET_CODE (insn) == NOTE
2651             && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PREDICTION)
2652           delete_insn (insn);
2653     }
2654   close_dump_file (DFI_sibling, print_rtl, get_insns ());
2655   timevar_pop (TV_JUMP);
2656
2657   scope_to_insns_initialize ();
2658   /* Complete generation of exception handling code.  */
2659   if (doing_eh (0))
2660     {
2661       timevar_push (TV_JUMP);
2662       open_dump_file (DFI_eh, decl);
2663
2664       finish_eh_generation ();
2665
2666       close_dump_file (DFI_eh, print_rtl, get_insns ());
2667       timevar_pop (TV_JUMP);
2668     }
2669
2670   /* Delay emitting hard_reg_initial_value sets until after EH landing pad
2671      generation, which might create new sets.  */
2672   emit_initial_value_sets ();
2673
2674 #ifdef FINALIZE_PIC
2675   /* If we are doing position-independent code generation, now
2676      is the time to output special prologues and epilogues.
2677      We do not want to do this earlier, because it just clutters
2678      up inline functions with meaningless insns.  */
2679   if (flag_pic)
2680     FINALIZE_PIC;
2681 #endif
2682
2683   insns = get_insns ();
2684
2685   /* Copy any shared structure that should not be shared.  */
2686   unshare_all_rtl (current_function_decl, insns);
2687
2688 #ifdef SETJMP_VIA_SAVE_AREA
2689   /* This must be performed before virtual register instantiation.
2690      Please be aware the everything in the compiler that can look
2691      at the RTL up to this point must understand that REG_SAVE_AREA
2692      is just like a use of the REG contained inside.  */
2693   if (current_function_calls_alloca)
2694     optimize_save_area_alloca (insns);
2695 #endif
2696
2697   /* Instantiate all virtual registers.  */
2698   instantiate_virtual_regs (current_function_decl, insns);
2699
2700   open_dump_file (DFI_jump, decl);
2701
2702   /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2703      are initialized and to compute whether control can drop off the end
2704      of the function.  */
2705
2706   timevar_push (TV_JUMP);
2707   /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB.  Do this
2708      before jump optimization switches branch directions.  */
2709   if (flag_guess_branch_prob)
2710     expected_value_to_br_prob ();
2711
2712   reg_scan (insns, max_reg_num (), 0);
2713   rebuild_jump_labels (insns);
2714   find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2715   delete_trivially_dead_insns (insns, max_reg_num ());
2716   if (rtl_dump_file)
2717     dump_flow_info (rtl_dump_file);
2718   cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
2719                | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2720
2721   if (optimize)
2722     {
2723       free_bb_for_insn ();
2724       copy_loop_headers (insns);
2725       find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2726     }
2727   purge_line_number_notes (insns);
2728
2729   timevar_pop (TV_JUMP);
2730   close_dump_file (DFI_jump, print_rtl, insns);
2731
2732   /* Now is when we stop if -fsyntax-only and -Wreturn-type.  */
2733   if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2734     {
2735       goto exit_rest_of_compilation;
2736     }
2737
2738   /* Long term, this should probably move before the jump optimizer too,
2739      but I didn't want to disturb the rtl_dump_and_exit and related
2740      stuff at this time.  */
2741   if (optimize > 0 && flag_ssa)
2742     {
2743       /* Convert to SSA form.  */
2744
2745       timevar_push (TV_TO_SSA);
2746       open_dump_file (DFI_ssa, decl);
2747
2748       cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2749       convert_to_ssa ();
2750
2751       close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2752       timevar_pop (TV_TO_SSA);
2753
2754       /* Perform sparse conditional constant propagation, if requested.  */
2755       if (flag_ssa_ccp)
2756         {
2757           timevar_push (TV_SSA_CCP);
2758           open_dump_file (DFI_ssa_ccp, decl);
2759
2760           ssa_const_prop ();
2761
2762           close_dump_file (DFI_ssa_ccp, print_rtl_with_bb, get_insns ());
2763           timevar_pop (TV_SSA_CCP);
2764         }
2765
2766       /* It would be useful to cleanup the CFG at this point, but block
2767          merging and possibly other transformations might leave a PHI
2768          node in the middle of a basic block, which is a strict no-no.  */
2769
2770       /* The SSA implementation uses basic block numbers in its phi
2771          nodes.  Thus, changing the control-flow graph or the basic
2772          blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
2773          may cause problems.  */
2774
2775       if (flag_ssa_dce)
2776         {
2777           /* Remove dead code.  */
2778
2779           timevar_push (TV_SSA_DCE);
2780           open_dump_file (DFI_ssa_dce, decl);
2781
2782           insns = get_insns ();
2783           ssa_eliminate_dead_code ();
2784
2785           close_dump_file (DFI_ssa_dce, print_rtl_with_bb, insns);
2786           timevar_pop (TV_SSA_DCE);
2787         }
2788
2789       /* Convert from SSA form.  */
2790
2791       timevar_push (TV_FROM_SSA);
2792       open_dump_file (DFI_ussa, decl);
2793
2794       convert_from_ssa ();
2795       /* New registers have been created.  Rescan their usage.  */
2796       reg_scan (insns, max_reg_num (), 1);
2797
2798       close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
2799       timevar_pop (TV_FROM_SSA);
2800
2801       ggc_collect ();
2802     }
2803
2804   timevar_push (TV_JUMP);
2805   cleanup_cfg (optimize ? CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP: 0);
2806
2807   /* Try to identify useless null pointer tests and delete them.  */
2808   if (flag_delete_null_pointer_checks)
2809     {
2810       open_dump_file (DFI_null, decl);
2811       if (rtl_dump_file)
2812         dump_flow_info (rtl_dump_file);
2813
2814       if (delete_null_pointer_checks (insns))
2815         cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2816
2817       close_dump_file (DFI_null, print_rtl_with_bb, insns);
2818     }
2819
2820   /* Jump optimization, and the removal of NULL pointer checks, may
2821      have reduced the number of instructions substantially.  CSE, and
2822      future passes, allocate arrays whose dimensions involve the
2823      maximum instruction UID, so if we can reduce the maximum UID
2824      we'll save big on memory.  */
2825   renumber_insns (rtl_dump_file);
2826   timevar_pop (TV_JUMP);
2827
2828   close_dump_file (DFI_jump, print_rtl_with_bb, insns);
2829
2830   ggc_collect ();
2831
2832   /* Perform common subexpression elimination.
2833      Nonzero value from `cse_main' means that jumps were simplified
2834      and some code may now be unreachable, so do
2835      jump optimization again.  */
2836
2837   if (optimize > 0)
2838     {
2839       open_dump_file (DFI_cse, decl);
2840       if (rtl_dump_file)
2841         dump_flow_info (rtl_dump_file);
2842       timevar_push (TV_CSE);
2843
2844       reg_scan (insns, max_reg_num (), 1);
2845
2846       tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2847       if (tem)
2848         rebuild_jump_labels (insns);
2849       purge_all_dead_edges (0);
2850
2851       delete_trivially_dead_insns (insns, max_reg_num ());
2852
2853       /* If we are not running more CSE passes, then we are no longer
2854          expecting CSE to be run.  But always rerun it in a cheap mode.  */
2855       cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
2856
2857       if (tem || optimize > 1)
2858         cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2859       /* Try to identify useless null pointer tests and delete them.  */
2860       if (flag_delete_null_pointer_checks)
2861         {
2862           timevar_push (TV_JUMP);
2863
2864           if (delete_null_pointer_checks (insns))
2865             cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2866           timevar_pop (TV_JUMP);
2867         }
2868
2869       /* The second pass of jump optimization is likely to have
2870          removed a bunch more instructions.  */
2871       renumber_insns (rtl_dump_file);
2872
2873       timevar_pop (TV_CSE);
2874       close_dump_file (DFI_cse, print_rtl_with_bb, insns);
2875     }
2876
2877   open_dump_file (DFI_addressof, decl);
2878
2879   purge_addressof (insns);
2880   if (optimize)
2881     purge_all_dead_edges (0);
2882   reg_scan (insns, max_reg_num (), 1);
2883
2884   close_dump_file (DFI_addressof, print_rtl, insns);
2885
2886   ggc_collect ();
2887
2888   /* Perform global cse.  */
2889
2890   if (optimize > 0 && flag_gcse)
2891     {
2892       int save_csb, save_cfj;
2893       int tem2 = 0;
2894
2895       timevar_push (TV_GCSE);
2896       open_dump_file (DFI_gcse, decl);
2897
2898       tem = gcse_main (insns, rtl_dump_file);
2899       rebuild_jump_labels (insns);
2900       delete_trivially_dead_insns (insns, max_reg_num ());
2901
2902       save_csb = flag_cse_skip_blocks;
2903       save_cfj = flag_cse_follow_jumps;
2904       flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
2905
2906       /* If -fexpensive-optimizations, re-run CSE to clean up things done
2907          by gcse.  */
2908       if (flag_expensive_optimizations)
2909         {
2910           timevar_push (TV_CSE);
2911           reg_scan (insns, max_reg_num (), 1);
2912           tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2913           purge_all_dead_edges (0);
2914           delete_trivially_dead_insns (insns, max_reg_num ());
2915           timevar_pop (TV_CSE);
2916           cse_not_expected = !flag_rerun_cse_after_loop;
2917         }
2918
2919       /* If gcse or cse altered any jumps, rerun jump optimizations to clean
2920          things up.  Then possibly re-run CSE again.  */
2921       while (tem || tem2)
2922         {
2923           tem = tem2 = 0;
2924           timevar_push (TV_JUMP);
2925           rebuild_jump_labels (insns);
2926           cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2927           timevar_pop (TV_JUMP);
2928
2929           if (flag_expensive_optimizations)
2930             {
2931               timevar_push (TV_CSE);
2932               reg_scan (insns, max_reg_num (), 1);
2933               tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2934               purge_all_dead_edges (0);
2935               delete_trivially_dead_insns (insns, max_reg_num ());
2936               timevar_pop (TV_CSE);
2937             }
2938         }
2939
2940       close_dump_file (DFI_gcse, print_rtl_with_bb, insns);
2941       timevar_pop (TV_GCSE);
2942
2943       ggc_collect ();
2944       flag_cse_skip_blocks = save_csb;
2945       flag_cse_follow_jumps = save_cfj;
2946 #ifdef ENABLE_CHECKING
2947       verify_flow_info ();
2948 #endif
2949     }
2950
2951   /* Instantiate any remaining CONSTANT_P_RTX nodes.  */
2952   if (optimize > 0 && flag_gcse && current_function_calls_constant_p)
2953     purge_builtin_constant_p ();
2954
2955   /* Move constant computations out of loops.  */
2956
2957   if (optimize > 0 && flag_loop_optimize)
2958     {
2959       int do_unroll, do_prefetch;
2960
2961       timevar_push (TV_LOOP);
2962       delete_dead_jumptables ();
2963       cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2964       open_dump_file (DFI_loop, decl);
2965       /* CFG is no longer maintained up-to-date.  */
2966       free_bb_for_insn ();
2967
2968       if (flag_unroll_loops)
2969         do_unroll = 0;          /* Having two unrollers is useless.  */
2970       else
2971         do_unroll = flag_old_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
2972       do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
2973       if (flag_rerun_loop_opt)
2974         {
2975           cleanup_barriers ();
2976
2977           /* We only want to perform unrolling once.  */
2978           loop_optimize (insns, rtl_dump_file, do_unroll);
2979           do_unroll = 0;
2980
2981           /* The first call to loop_optimize makes some instructions
2982              trivially dead.  We delete those instructions now in the
2983              hope that doing so will make the heuristics in loop work
2984              better and possibly speed up compilation.  */
2985           delete_trivially_dead_insns (insns, max_reg_num ());
2986
2987           /* The regscan pass is currently necessary as the alias
2988                   analysis code depends on this information.  */
2989           reg_scan (insns, max_reg_num (), 1);
2990         }
2991       cleanup_barriers ();
2992       loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch);
2993
2994       /* Loop can create trivially dead instructions.  */
2995       delete_trivially_dead_insns (insns, max_reg_num ());
2996       close_dump_file (DFI_loop, print_rtl, insns);
2997       timevar_pop (TV_LOOP);
2998       find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2999
3000       ggc_collect ();
3001     }
3002
3003   /* Perform jump bypassing and control flow optimizations.  */
3004   if (optimize > 0 && flag_gcse)
3005     {
3006       timevar_push (TV_BYPASS);
3007       open_dump_file (DFI_bypass, decl);
3008
3009       cleanup_cfg (CLEANUP_EXPENSIVE);
3010       tem = bypass_jumps (rtl_dump_file);
3011
3012       if (tem)
3013         {
3014           rebuild_jump_labels (insns);
3015           cleanup_cfg (CLEANUP_EXPENSIVE);
3016           delete_trivially_dead_insns (insns, max_reg_num ());
3017         }
3018
3019       close_dump_file (DFI_bypass, print_rtl_with_bb, insns);
3020       timevar_pop (TV_BYPASS);
3021
3022       ggc_collect ();
3023
3024 #ifdef ENABLE_CHECKING
3025       verify_flow_info ();
3026 #endif
3027     }
3028
3029   /* Do control and data flow analysis; wrote some of the results to
3030      the dump file.  */
3031
3032   timevar_push (TV_FLOW);
3033   open_dump_file (DFI_cfg, decl);
3034   if (rtl_dump_file)
3035     dump_flow_info (rtl_dump_file);
3036   cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0)
3037                | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3038
3039   /* It may make more sense to mark constant functions after dead code is
3040      eliminated by life_analysis, but we need to do it early, as -fprofile-arcs
3041      may insert code making function non-constant, but we still must consider
3042      it as constant, otherwise -fbranch-probabilities will not read data back.
3043
3044      life_analysis rarely eliminates modification of external memory.
3045    */
3046   if (optimize)
3047     mark_constant_function ();
3048
3049   close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
3050
3051   /* Do branch profiling and static profile estimation passes.  */
3052   if (optimize > 0 || cfun->arc_profile || flag_branch_probabilities)
3053     {
3054       struct loops loops;
3055
3056       timevar_push (TV_BRANCH_PROB);
3057       open_dump_file (DFI_bp, decl);
3058       if (cfun->arc_profile || flag_branch_probabilities)
3059         branch_prob ();
3060
3061       /* Discover and record the loop depth at the head of each basic
3062          block.  The loop infrastructure does the real job for us.  */
3063       flow_loops_find (&loops, LOOP_TREE);
3064
3065       if (rtl_dump_file)
3066         flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
3067
3068       /* Estimate using heuristics if no profiling info is available.  */
3069       if (flag_guess_branch_prob)
3070         estimate_probability (&loops);
3071
3072       flow_loops_free (&loops);
3073       close_dump_file (DFI_bp, print_rtl_with_bb, insns);
3074       timevar_pop (TV_BRANCH_PROB);
3075     }
3076   if (optimize > 0)
3077     {
3078       open_dump_file (DFI_ce1, decl);
3079       if (flag_if_conversion)
3080         {
3081           timevar_push (TV_IFCVT);
3082           if (rtl_dump_file)
3083             dump_flow_info (rtl_dump_file);
3084           cleanup_cfg (CLEANUP_EXPENSIVE);
3085           reg_scan (insns, max_reg_num (), 0);
3086           if_convert (0);
3087           timevar_pop (TV_IFCVT);
3088         }
3089       timevar_push (TV_JUMP);
3090       cleanup_cfg (CLEANUP_EXPENSIVE);
3091       reg_scan (insns, max_reg_num (), 0);
3092       timevar_pop (TV_JUMP);
3093       close_dump_file (DFI_ce1, print_rtl_with_bb, get_insns ());
3094     }
3095   if (flag_tracer)
3096     {
3097       timevar_push (TV_TRACER);
3098       open_dump_file (DFI_tracer, decl);
3099       if (rtl_dump_file)
3100         dump_flow_info (rtl_dump_file);
3101       tracer ();
3102       cleanup_cfg (CLEANUP_EXPENSIVE);
3103       reg_scan (insns, max_reg_num (), 0);
3104       close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
3105       timevar_pop (TV_TRACER);
3106     }
3107
3108   /* Perform loop optimalizations.  It might be better to do them a bit
3109      sooner, but we want the profile feedback to work more efficiently.  */
3110   if (optimize > 0
3111       && (flag_unswitch_loops
3112           || flag_peel_loops
3113           || flag_unroll_loops))
3114     {
3115       struct loops *loops;
3116       timevar_push (TV_LOOP);
3117       open_dump_file (DFI_loop2, decl);
3118       if (rtl_dump_file)
3119         dump_flow_info (rtl_dump_file);
3120
3121       loops = loop_optimizer_init (rtl_dump_file);
3122
3123       if (loops)
3124         {
3125           /* The optimalizations:  */
3126           if (flag_unswitch_loops)
3127             unswitch_loops (loops);
3128
3129           if (flag_peel_loops || flag_unroll_loops)
3130             unroll_and_peel_loops (loops,
3131                 (flag_peel_loops ? UAP_PEEL : 0) |
3132                 (flag_unroll_loops ? UAP_UNROLL : 0) |
3133                 (flag_unroll_all_loops ? UAP_UNROLL_ALL : 0));
3134
3135           loop_optimizer_finalize (loops, rtl_dump_file);
3136         }
3137
3138       cleanup_cfg (CLEANUP_EXPENSIVE);
3139       delete_trivially_dead_insns (insns, max_reg_num ());
3140       reg_scan (insns, max_reg_num (), 0);
3141       if (rtl_dump_file)
3142         dump_flow_info (rtl_dump_file);
3143       close_dump_file (DFI_loop2, print_rtl_with_bb, get_insns ());
3144       timevar_pop (TV_LOOP);
3145       ggc_collect ();
3146     }
3147
3148   if (flag_rerun_cse_after_loop)
3149     {
3150       timevar_push (TV_CSE2);
3151       open_dump_file (DFI_cse2, decl);
3152       if (rtl_dump_file)
3153         dump_flow_info (rtl_dump_file);
3154       /* CFG is no longer maintained up-to-date.  */
3155       tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3156       purge_all_dead_edges (0);
3157       delete_trivially_dead_insns (insns, max_reg_num ());
3158
3159       if (tem)
3160         {
3161           timevar_push (TV_JUMP);
3162           rebuild_jump_labels (insns);
3163           cleanup_cfg (CLEANUP_EXPENSIVE);
3164           timevar_pop (TV_JUMP);
3165         }
3166       reg_scan (insns, max_reg_num (), 0);
3167       close_dump_file (DFI_cse2, print_rtl_with_bb, insns);
3168       ggc_collect ();
3169       timevar_pop (TV_CSE2);
3170     }
3171
3172   cse_not_expected = 1;
3173
3174   open_dump_file (DFI_life, decl);
3175   regclass_init ();
3176
3177   check_function_return_warnings ();
3178
3179 #ifdef ENABLE_CHECKING
3180   verify_flow_info ();
3181 #endif
3182   life_analysis (insns, rtl_dump_file, PROP_FINAL);
3183   if (optimize)
3184     cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_UPDATE_LIFE
3185                  | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3186   timevar_pop (TV_FLOW);
3187
3188   no_new_pseudos = 1;
3189
3190   if (warn_uninitialized || extra_warnings)
3191     {
3192       uninitialized_vars_warning (DECL_INITIAL (decl));
3193       if (extra_warnings)
3194         setjmp_args_warning ();
3195     }
3196
3197   if (optimize)
3198     {
3199       clear_bb_flags ();
3200       if (!flag_new_regalloc && initialize_uninitialized_subregs ())
3201         {
3202           /* Insns were inserted, so things might look a bit different.  */
3203           insns = get_insns ();
3204           update_life_info_in_dirty_blocks (UPDATE_LIFE_GLOBAL_RM_NOTES,
3205                                             PROP_LOG_LINKS | PROP_REG_INFO
3206                                             | PROP_DEATH_NOTES);
3207         }
3208     }
3209
3210   close_dump_file (DFI_life, print_rtl_with_bb, insns);
3211
3212   ggc_collect ();
3213
3214   /* If -opt, try combining insns through substitution.  */
3215
3216   if (optimize > 0)
3217     {
3218       int rebuild_jump_labels_after_combine = 0;
3219
3220       timevar_push (TV_COMBINE);
3221       open_dump_file (DFI_combine, decl);
3222
3223       rebuild_jump_labels_after_combine
3224         = combine_instructions (insns, max_reg_num ());
3225
3226       /* Combining insns may have turned an indirect jump into a
3227          direct jump.  Rebuild the JUMP_LABEL fields of jumping
3228          instructions.  */
3229       if (rebuild_jump_labels_after_combine)
3230         {
3231           timevar_push (TV_JUMP);
3232           rebuild_jump_labels (insns);
3233           timevar_pop (TV_JUMP);
3234
3235           cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3236         }
3237
3238       close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3239       timevar_pop (TV_COMBINE);
3240
3241       ggc_collect ();
3242     }
3243
3244   /* Rerun if-conversion, as combine may have simplified things enough to
3245      now meet sequence length restrictions.  */
3246   if (flag_if_conversion)
3247     {
3248       timevar_push (TV_IFCVT);
3249       open_dump_file (DFI_ce2, decl);
3250
3251       no_new_pseudos = 0;
3252       if_convert (1);
3253       no_new_pseudos = 1;
3254
3255       close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3256       timevar_pop (TV_IFCVT);
3257     }
3258
3259   /* Register allocation pre-pass, to reduce number of moves
3260      necessary for two-address machines.  */
3261   if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3262     {
3263       timevar_push (TV_REGMOVE);
3264       open_dump_file (DFI_regmove, decl);
3265
3266       regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3267
3268       cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3269       close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3270       timevar_pop (TV_REGMOVE);
3271
3272       ggc_collect ();
3273     }
3274
3275   /* Do unconditional splitting before register allocation to allow machine
3276      description to add extra information not needed previously.  */
3277   split_all_insns (1);
3278
3279 #ifdef OPTIMIZE_MODE_SWITCHING
3280   timevar_push (TV_MODE_SWITCH);
3281
3282   no_new_pseudos = 0;
3283   optimize_mode_switching (NULL);
3284   no_new_pseudos = 1;
3285
3286   timevar_pop (TV_MODE_SWITCH);
3287 #endif
3288
3289   /* Any of the several passes since flow1 will have munged register
3290      lifetime data a bit.  We need it to be up to date for scheduling
3291      (see handling of reg_known_equiv in init_alias_analysis).  */
3292   recompute_reg_usage (insns, !optimize_size);
3293
3294   timevar_push (TV_SCHED);
3295
3296 #ifdef INSN_SCHEDULING
3297
3298   /* Print function header into sched dump now
3299      because doing the sched analysis makes some of the dump.  */
3300   if (optimize > 0 && flag_schedule_insns)
3301     {
3302       open_dump_file (DFI_sched, decl);
3303
3304       /* Do control and data sched analysis,
3305          and write some of the results to dump file.  */
3306
3307       schedule_insns (rtl_dump_file);
3308
3309       close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3310     }
3311 #endif
3312   timevar_pop (TV_SCHED);
3313
3314   ggc_collect ();
3315
3316   /* Determine if the current function is a leaf before running reload
3317      since this can impact optimizations done by the prologue and
3318      epilogue thus changing register elimination offsets.  */
3319   current_function_is_leaf = leaf_function_p ();
3320
3321   timevar_push (TV_LOCAL_ALLOC);
3322   open_dump_file (DFI_lreg, decl);
3323
3324   /* Allocate pseudo-regs that are used only within 1 basic block.
3325
3326      RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3327      jump optimizer after register allocation and reloading are finished.  */
3328
3329   if (flag_new_regalloc)
3330     {
3331       delete_trivially_dead_insns (insns, max_reg_num ());
3332       reg_alloc ();
3333
3334       timevar_pop (TV_LOCAL_ALLOC);
3335       if (dump_file[DFI_lreg].enabled)
3336         {
3337           timevar_push (TV_DUMP);
3338
3339           close_dump_file (DFI_lreg, NULL, NULL);
3340           timevar_pop (TV_DUMP);
3341         }
3342
3343       /* XXX clean up the whole mess to bring live info in shape again.  */
3344       timevar_push (TV_GLOBAL_ALLOC);
3345       open_dump_file (DFI_greg, decl);
3346
3347       build_insn_chain (insns);
3348       failure = reload (insns, 0);
3349
3350       timevar_pop (TV_GLOBAL_ALLOC);
3351
3352       if (dump_file[DFI_greg].enabled)
3353         {
3354           timevar_push (TV_DUMP);
3355
3356           dump_global_regs (rtl_dump_file);
3357
3358           close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3359           timevar_pop (TV_DUMP);
3360         }
3361
3362       if (failure)
3363         goto exit_rest_of_compilation;
3364       reload_completed = 1;
3365       rebuild_label_notes_after_reload = 0;
3366     }
3367   else
3368     {
3369       /* Allocate the reg_renumber array.  */
3370       allocate_reg_info (max_regno, FALSE, TRUE);
3371
3372       /* And the reg_equiv_memory_loc array.  */
3373       reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
3374
3375       allocate_initial_values (reg_equiv_memory_loc);
3376
3377       regclass (insns, max_reg_num (), rtl_dump_file);
3378       rebuild_label_notes_after_reload = local_alloc ();
3379
3380       timevar_pop (TV_LOCAL_ALLOC);
3381
3382       if (dump_file[DFI_lreg].enabled)
3383         {
3384           timevar_push (TV_DUMP);
3385
3386           dump_flow_info (rtl_dump_file);
3387           dump_local_alloc (rtl_dump_file);
3388
3389           close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3390           timevar_pop (TV_DUMP);
3391         }
3392
3393       ggc_collect ();
3394
3395       timevar_push (TV_GLOBAL_ALLOC);
3396       open_dump_file (DFI_greg, decl);
3397
3398       /* If optimizing, allocate remaining pseudo-regs.  Do the reload
3399          pass fixing up any insns that are invalid.  */
3400
3401       if (optimize)
3402         failure = global_alloc (rtl_dump_file);
3403       else
3404         {
3405           build_insn_chain (insns);
3406           failure = reload (insns, 0);
3407         }
3408
3409       timevar_pop (TV_GLOBAL_ALLOC);
3410
3411       if (dump_file[DFI_greg].enabled)
3412         {
3413           timevar_push (TV_DUMP);
3414
3415           dump_global_regs (rtl_dump_file);
3416
3417           close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3418           timevar_pop (TV_DUMP);
3419         }
3420
3421       if (failure)
3422         goto exit_rest_of_compilation;
3423     }
3424
3425   ggc_collect ();
3426
3427   open_dump_file (DFI_postreload, decl);
3428
3429   /* Do a very simple CSE pass over just the hard registers.  */
3430   if (optimize > 0)
3431     {
3432       timevar_push (TV_RELOAD_CSE_REGS);
3433       reload_cse_regs (insns);
3434       timevar_pop (TV_RELOAD_CSE_REGS);
3435     }
3436
3437   /* Register allocation and reloading may have turned an indirect jump into
3438      a direct jump.  If so, we must rebuild the JUMP_LABEL fields of
3439      jumping instructions.  */
3440   if (rebuild_label_notes_after_reload)
3441     {
3442       timevar_push (TV_JUMP);
3443
3444       rebuild_jump_labels (insns);
3445       purge_all_dead_edges (0);
3446
3447       timevar_pop (TV_JUMP);
3448     }
3449
3450   close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3451
3452   /* Re-create the death notes which were deleted during reload.  */
3453   timevar_push (TV_FLOW2);
3454   open_dump_file (DFI_flow2, decl);
3455
3456 #ifdef ENABLE_CHECKING
3457   verify_flow_info ();
3458 #endif
3459
3460   /* If optimizing, then go ahead and split insns now.  */
3461   if (optimize > 0)
3462     split_all_insns (0);
3463
3464   cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
3465
3466   /* On some machines, the prologue and epilogue code, or parts thereof,
3467      can be represented as RTL.  Doing so lets us schedule insns between
3468      it and the rest of the code and also allows delayed branch
3469      scheduling to operate in the epilogue.  */
3470   thread_prologue_and_epilogue_insns (insns);
3471
3472   if (optimize)
3473     {
3474       life_analysis (insns, rtl_dump_file, PROP_FINAL);
3475       cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
3476                    | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3477
3478       /* This is kind of a heuristic.  We need to run combine_stack_adjustments
3479          even for machines with possibly nonzero RETURN_POPS_ARGS
3480          and ACCUMULATE_OUTGOING_ARGS.  We expect that only ports having
3481          push instructions will have popping returns.  */
3482 #ifndef PUSH_ROUNDING
3483       if (!ACCUMULATE_OUTGOING_ARGS)
3484 #endif
3485         combine_stack_adjustments ();
3486
3487       ggc_collect ();
3488     }
3489
3490   flow2_completed = 1;
3491
3492   close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3493   timevar_pop (TV_FLOW2);
3494
3495 #ifdef HAVE_peephole2
3496   if (optimize > 0 && flag_peephole2)
3497     {
3498       timevar_push (TV_PEEPHOLE2);
3499       open_dump_file (DFI_peephole2, decl);
3500
3501       peephole2_optimize (rtl_dump_file);
3502
3503       close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3504       timevar_pop (TV_PEEPHOLE2);
3505     }
3506 #endif
3507
3508   if (optimize > 0 && (flag_rename_registers || flag_cprop_registers))
3509     {
3510       timevar_push (TV_RENAME_REGISTERS);
3511       open_dump_file (DFI_rnreg, decl);
3512
3513       if (flag_rename_registers)
3514         regrename_optimize ();
3515       if (flag_cprop_registers)
3516         copyprop_hardreg_forward ();
3517
3518       close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3519       timevar_pop (TV_RENAME_REGISTERS);
3520     }
3521
3522   if (optimize > 0)
3523     {
3524       timevar_push (TV_REORDER_BLOCKS);
3525       open_dump_file (DFI_bbro, decl);
3526
3527       /* Last attempt to optimize CFG, as scheduling, peepholing and insn
3528          splitting possibly introduced more crossjumping opportunities. */
3529       cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
3530                    | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3531
3532       if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
3533         tracer ();
3534       if (flag_reorder_blocks)
3535         reorder_basic_blocks ();
3536       if (flag_reorder_blocks
3537           || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
3538           cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3539
3540       close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3541       timevar_pop (TV_REORDER_BLOCKS);
3542     }
3543
3544   if (flag_if_conversion2)
3545     {
3546       timevar_push (TV_IFCVT2);
3547       open_dump_file (DFI_ce3, decl);
3548
3549       if_convert (1);
3550
3551       close_dump_file (DFI_ce3, print_rtl_with_bb, insns);
3552       timevar_pop (TV_IFCVT2);
3553     }
3554 #ifdef STACK_REGS
3555   if (optimize)
3556     split_all_insns (1);
3557 #endif
3558
3559 #ifdef INSN_SCHEDULING
3560   if (optimize > 0 && flag_schedule_insns_after_reload)
3561     {
3562       timevar_push (TV_SCHED2);
3563       open_dump_file (DFI_sched2, decl);
3564
3565       /* Do control and data sched analysis again,
3566          and write some more of the results to dump file.  */
3567
3568       split_all_insns (1);
3569
3570       if (flag_sched2_use_superblocks || flag_sched2_use_traces)
3571         {
3572           schedule_ebbs (rtl_dump_file);
3573           /* No liveness updating code yet, but it should be easy to do.
3574              reg-stack recompute the liveness when needed for now.  */
3575           count_or_remove_death_notes (NULL, 1);
3576           cleanup_cfg (CLEANUP_EXPENSIVE);
3577         }
3578       else
3579         schedule_insns (rtl_dump_file);
3580
3581       close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3582       timevar_pop (TV_SCHED2);
3583
3584       ggc_collect ();
3585     }
3586 #endif
3587
3588 #ifdef LEAF_REGISTERS
3589   current_function_uses_only_leaf_regs
3590     = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3591 #endif
3592
3593 #ifdef STACK_REGS
3594   timevar_push (TV_REG_STACK);
3595   open_dump_file (DFI_stack, decl);
3596
3597   if (reg_to_stack (insns, rtl_dump_file) && optimize)
3598     {
3599       if (cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
3600                        | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
3601           && flag_reorder_blocks)
3602         {
3603           reorder_basic_blocks ();
3604           cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
3605         }
3606     }
3607
3608   close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3609   timevar_pop (TV_REG_STACK);
3610
3611   ggc_collect ();
3612 #endif
3613   compute_alignments ();
3614
3615   /* CFG is no longer maintained up-to-date.  */
3616   free_bb_for_insn ();
3617
3618   /* If a machine dependent reorganization is needed, call it.  */
3619 #ifdef MACHINE_DEPENDENT_REORG
3620   timevar_push (TV_MACH_DEP);
3621   open_dump_file (DFI_mach, decl);
3622
3623   MACHINE_DEPENDENT_REORG (insns);
3624
3625   close_dump_file (DFI_mach, print_rtl, insns);
3626   timevar_pop (TV_MACH_DEP);
3627
3628   ggc_collect ();
3629 #endif
3630
3631   purge_line_number_notes (insns);
3632   cleanup_barriers ();
3633
3634   /* If a scheduling pass for delayed branches is to be done,
3635      call the scheduling code.  */
3636
3637 #ifdef DELAY_SLOTS
3638   if (optimize > 0 && flag_delayed_branch)
3639     {
3640       timevar_push (TV_DBR_SCHED);
3641       open_dump_file (DFI_dbr, decl);
3642
3643       dbr_schedule (insns, rtl_dump_file);
3644
3645       close_dump_file (DFI_dbr, print_rtl, insns);
3646       timevar_pop (TV_DBR_SCHED);
3647
3648       ggc_collect ();
3649     }
3650 #endif
3651
3652 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3653   timevar_push (TV_SHORTEN_BRANCH);
3654   split_all_insns_noflow ();
3655   timevar_pop (TV_SHORTEN_BRANCH);
3656 #endif
3657
3658   convert_to_eh_region_ranges ();
3659
3660   /* Shorten branches.  */
3661   timevar_push (TV_SHORTEN_BRANCH);
3662   shorten_branches (get_insns ());
3663   timevar_pop (TV_SHORTEN_BRANCH);
3664
3665   set_nothrow_function_flags ();
3666   if (current_function_nothrow)
3667     /* Now we know that this can't throw; set the flag for the benefit
3668        of other functions later in this translation unit.  */
3669     TREE_NOTHROW (current_function_decl) = 1;
3670
3671   /* Now turn the rtl into assembler code.  */
3672
3673   timevar_push (TV_FINAL);
3674   {
3675     rtx x;
3676     const char *fnname;
3677
3678     /* Get the function's name, as described by its RTL.  This may be
3679        different from the DECL_NAME name used in the source file.  */
3680
3681     x = DECL_RTL (decl);
3682     if (GET_CODE (x) != MEM)
3683       abort ();
3684     x = XEXP (x, 0);
3685     if (GET_CODE (x) != SYMBOL_REF)
3686       abort ();
3687     fnname = XSTR (x, 0);
3688
3689     assemble_start_function (decl, fnname);
3690     final_start_function (insns, asm_out_file, optimize);
3691     final (insns, asm_out_file, optimize, 0);
3692     final_end_function ();
3693
3694 #ifdef IA64_UNWIND_INFO
3695     /* ??? The IA-64 ".handlerdata" directive must be issued before
3696        the ".endp" directive that closes the procedure descriptor.  */
3697     output_function_exception_table ();
3698 #endif
3699
3700     assemble_end_function (decl, fnname);
3701
3702 #ifndef IA64_UNWIND_INFO
3703     /* Otherwise, it feels unclean to switch sections in the middle.  */
3704     output_function_exception_table ();
3705 #endif
3706
3707     if (! quiet_flag)
3708       fflush (asm_out_file);
3709
3710     /* Release all memory allocated by flow.  */
3711     free_basic_block_vars (0);
3712
3713     /* Release all memory held by regsets now.  */
3714     regset_release_memory ();
3715   }
3716   timevar_pop (TV_FINAL);
3717
3718   ggc_collect ();
3719
3720   /* Write DBX symbols if requested.  */
3721
3722   /* Note that for those inline functions where we don't initially
3723      know for certain that we will be generating an out-of-line copy,
3724      the first invocation of this routine (rest_of_compilation) will
3725      skip over this code by doing a `goto exit_rest_of_compilation;'.
3726      Later on, wrapup_global_declarations will (indirectly) call
3727      rest_of_compilation again for those inline functions that need
3728      to have out-of-line copies generated.  During that call, we
3729      *will* be routed past here.  */
3730
3731   timevar_push (TV_SYMOUT);
3732   (*debug_hooks->function_decl) (decl);
3733   timevar_pop (TV_SYMOUT);
3734
3735  exit_rest_of_compilation:
3736
3737   /* In case the function was not output,
3738      don't leave any temporary anonymous types
3739      queued up for sdb output.  */
3740 #ifdef SDB_DEBUGGING_INFO
3741   if (write_symbols == SDB_DEBUG)
3742     sdbout_types (NULL_TREE);
3743 #endif
3744
3745   reload_completed = 0;
3746   flow2_completed = 0;
3747   no_new_pseudos = 0;
3748
3749   timevar_push (TV_FINAL);
3750
3751   /* Clear out the insn_length contents now that they are no
3752      longer valid.  */
3753   init_insn_lengths ();
3754
3755   /* Show no temporary slots allocated.  */
3756   init_temp_slots ();
3757
3758   free_basic_block_vars (0);
3759   free_bb_for_insn ();
3760
3761   timevar_pop (TV_FINAL);
3762
3763   /* Make sure volatile mem refs aren't considered valid operands for
3764      arithmetic insns.  We must call this here if this is a nested inline
3765      function, since the above code leaves us in the init_recog state
3766      (from final.c), and the function context push/pop code does not
3767      save/restore volatile_ok.
3768
3769      ??? Maybe it isn't necessary for expand_start_function to call this
3770      anymore if we do it here?  */
3771
3772   init_recog_no_volatile ();
3773
3774   /* We're done with this function.  Free up memory if we can.  */
3775   free_after_parsing (cfun);
3776   if (! DECL_DEFER_OUTPUT (decl))
3777     {
3778       free_after_compilation (cfun);
3779
3780       /* Clear integrate.c's pointer to the cfun structure we just
3781          destroyed.  */
3782       DECL_SAVED_INSNS (decl) = 0;
3783     }
3784   cfun = 0;
3785
3786   ggc_collect ();
3787
3788   timevar_pop (TV_REST_OF_COMPILATION);
3789 }
3790 \f
3791 static void
3792 display_help ()
3793 {
3794   int undoc;
3795   unsigned long i;
3796   const char *lang;
3797
3798   printf (_("  -ffixed-<register>      Mark <register> as being unavailable to the compiler\n"));
3799   printf (_("  -fcall-used-<register>  Mark <register> as being corrupted by function calls\n"));
3800   printf (_("  -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3801   printf (_("  -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3802   printf (_("  -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line.  0 suppresses line-wrapping\n"));
3803   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"));
3804   printf (_("  -ftls-model=[global-dynamic | local-dynamic | initial-exec | local-exec] Indicates the default thread-local storage code generation model\n"));
3805
3806   for (i = ARRAY_SIZE (f_options); i--;)
3807     {
3808       const char *description = f_options[i].description;
3809
3810       if (description != NULL && *description != 0)
3811         printf ("  -f%-21s %s\n",
3812                 f_options[i].string, _(description));
3813     }
3814
3815   printf (_("  -O[number]              Set optimization level to [number]\n"));
3816   printf (_("  -Os                     Optimize for space rather than speed\n"));
3817   for (i = LAST_PARAM; i--;)
3818     {
3819       const char *description = compiler_params[i].help;
3820       const int length = 21 - strlen (compiler_params[i].option);
3821
3822       if (description != NULL && *description != 0)
3823         printf ("  --param %s=<value>%.*s%s\n",
3824                 compiler_params[i].option,
3825                 length > 0 ? length : 1, "                     ",
3826                 _(description));
3827     }
3828   printf (_("  -pedantic               Issue warnings needed by strict compliance to ISO C\n"));
3829   printf (_("  -pedantic-errors        Like -pedantic except that errors are produced\n"));
3830   printf (_("  -w                      Suppress warnings\n"));
3831
3832   for (i = ARRAY_SIZE (W_options); i--;)
3833     {
3834       const char *description = W_options[i].description;
3835
3836       if (description != NULL && *description != 0)
3837         printf ("  -W%-21s %s\n",
3838                 W_options[i].string, _(description));
3839     }
3840
3841   printf (_("  -Wunused                Enable unused warnings\n"));
3842   printf (_("  -Wlarger-than-<number>  Warn if an object is larger than <number> bytes\n"));
3843   printf (_("  -p                      Enable function profiling\n"));
3844   printf (_("  -o <file>               Place output into <file> \n"));
3845   printf (_("\
3846   -G <number>             Put global and static data smaller than <number>\n\
3847                           bytes into a special section (on some targets)\n"));
3848
3849   for (i = ARRAY_SIZE (debug_args); i--;)
3850     {
3851       if (debug_args[i].description != NULL)
3852         printf ("  -g%-21s %s\n",
3853                 debug_args[i].arg, _(debug_args[i].description));
3854     }
3855
3856   printf (_("  -aux-info <file>        Emit declaration info into <file>\n"));
3857   printf (_("  -quiet                  Do not display functions compiled or elapsed time\n"));
3858   printf (_("  -version                Display the compiler's version\n"));
3859   printf (_("  -d[letters]             Enable dumps from specific passes of the compiler\n"));
3860   printf (_("  -dumpbase <file>        Base name to be used for dumps from specific passes\n"));
3861 #if defined INSN_SCHEDULING
3862   printf (_("  -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3863 #endif
3864   printf (_("  --help                  Display this information\n"));
3865
3866   undoc = 0;
3867   lang  = "language";
3868
3869   /* Display descriptions of language specific options.
3870      If there is no description, note that there is an undocumented option.
3871      If the description is empty, do not display anything.  (This allows
3872      options to be deliberately undocumented, for whatever reason).
3873      If the option string is missing, then this is a marker, indicating
3874      that the description string is in fact the name of a language, whose
3875      language specific options are to follow.  */
3876
3877   if (ARRAY_SIZE (documented_lang_options) > 1)
3878     {
3879       printf (_("\nLanguage specific options:\n"));
3880
3881       for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3882         {
3883           const char *description = documented_lang_options[i].description;
3884           const char *option      = documented_lang_options[i].option;
3885
3886           if (description == NULL)
3887             {
3888               undoc = 1;
3889
3890               if (extra_warnings)
3891                 printf (_("  %-23.23s [undocumented]\n"), option);
3892             }
3893           else if (*description == 0)
3894             continue;
3895           else if (option == NULL)
3896             {
3897               if (undoc)
3898                 printf
3899                   (_("\nThere are undocumented %s specific options as well.\n"),
3900                         lang);
3901               undoc = 0;
3902
3903               printf (_("\n Options for %s:\n"), description);
3904
3905               lang = description;
3906             }
3907           else
3908             printf ("  %-23.23s %s\n", option, _(description));
3909         }
3910     }
3911
3912   if (undoc)
3913     printf (_("\nThere are undocumented %s specific options as well.\n"),
3914             lang);
3915
3916   display_target_options ();
3917 }
3918
3919 static void
3920 display_target_options ()
3921 {
3922   int undoc, i;
3923   static bool displayed = false;
3924
3925   /* Avoid double printing for --help --target-help.  */
3926   if (displayed)
3927     return;
3928   displayed = true;
3929
3930   if (ARRAY_SIZE (target_switches) > 1
3931 #ifdef TARGET_OPTIONS
3932       || ARRAY_SIZE (target_options) > 1
3933 #endif
3934       )
3935     {
3936       int doc = 0;
3937
3938       undoc = 0;
3939
3940       printf (_("\nTarget specific options:\n"));
3941
3942       for (i = ARRAY_SIZE (target_switches); i--;)
3943         {
3944           const char *option      = target_switches[i].name;
3945           const char *description = target_switches[i].description;
3946
3947           if (option == NULL || *option == 0)
3948             continue;
3949           else if (description == NULL)
3950             {
3951               undoc = 1;
3952
3953               if (extra_warnings)
3954                 printf (_("  -m%-23.23s [undocumented]\n"), option);
3955             }
3956           else if (*description != 0)
3957             doc += printf ("  -m%-23.23s %s\n", option, _(description));
3958         }
3959
3960 #ifdef TARGET_OPTIONS
3961       for (i = ARRAY_SIZE (target_options); i--;)
3962         {
3963           const char *option      = target_options[i].prefix;
3964           const char *description = target_options[i].description;
3965
3966           if (option == NULL || *option == 0)
3967             continue;
3968           else if (description == NULL)
3969             {
3970               undoc = 1;
3971
3972               if (extra_warnings)
3973                 printf (_("  -m%-23.23s [undocumented]\n"), option);
3974             }
3975           else if (*description != 0)
3976             doc += printf ("  -m%-23.23s %s\n", option, _(description));
3977         }
3978 #endif
3979       if (undoc)
3980         {
3981           if (doc)
3982             printf (_("\nThere are undocumented target specific options as well.\n"));
3983           else
3984             printf (_("  They exist, but they are not documented.\n"));
3985         }
3986     }
3987 }
3988 \f
3989 /* Parse a -d... command line switch.  */
3990
3991 static void
3992 decode_d_option (arg)
3993      const char *arg;
3994 {
3995   int i, c, matched;
3996
3997   while (*arg)
3998     switch (c = *arg++)
3999       {
4000       case 'a':
4001         for (i = 0; i < (int) DFI_MAX; ++i)
4002           dump_file[i].enabled = 1;
4003         break;
4004       case 'A':
4005         flag_debug_asm = 1;
4006         break;
4007       case 'p':
4008         flag_print_asm_name = 1;
4009         break;
4010       case 'P':
4011         flag_dump_rtl_in_asm = 1;
4012         flag_print_asm_name = 1;
4013         break;
4014       case 'v':
4015         graph_dump_format = vcg;
4016         break;
4017       case 'x':
4018         rtl_dump_and_exit = 1;
4019         break;
4020       case 'y':
4021         set_yydebug = 1;
4022         break;
4023       case 'D': /* These are handled by the preprocessor.  */
4024       case 'I':
4025         break;
4026       case 'H':
4027         setup_core_dumping();
4028         break;
4029
4030       default:
4031         matched = 0;
4032         for (i = 0; i < (int) DFI_MAX; ++i)
4033           if (c == dump_file[i].debug_switch)
4034             {
4035               dump_file[i].enabled = 1;
4036               matched = 1;
4037             }
4038
4039         if (! matched)
4040           warning ("unrecognized gcc debugging option: %c", c);
4041         break;
4042       }
4043 }
4044
4045 /* Parse a -f... command line switch.  ARG is the value after the -f.
4046    It is safe to access 'ARG - 2' to generate the full switch name.
4047    Return the number of strings consumed.  */
4048
4049 static int
4050 decode_f_option (arg)
4051      const char *arg;
4052 {
4053   int j;
4054   const char *option_value = NULL;
4055
4056   /* Search for the option in the table of binary f options.  */
4057   for (j = ARRAY_SIZE (f_options); j--;)
4058     {
4059       if (!strcmp (arg, f_options[j].string))
4060         {
4061           *f_options[j].variable = f_options[j].on_value;
4062           return 1;
4063         }
4064
4065       if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4066           && ! strcmp (arg + 3, f_options[j].string))
4067         {
4068           *f_options[j].variable = ! f_options[j].on_value;
4069           return 1;
4070         }
4071     }
4072
4073   if (!strcmp (arg, "fast-math"))
4074     set_fast_math_flags (1);
4075   else if (!strcmp (arg, "no-fast-math"))
4076     set_fast_math_flags (0);
4077   else if ((option_value = skip_leading_substring (arg, "inline-limit-"))
4078            || (option_value = skip_leading_substring (arg, "inline-limit=")))
4079     {
4080       int val =
4081         read_integral_parameter (option_value, arg - 2,
4082                                  MAX_INLINE_INSNS);
4083       set_param_value ("max-inline-insns", val);
4084     }
4085   else if ((option_value = skip_leading_substring (arg, "tls-model=")))
4086     {
4087       if (strcmp (option_value, "global-dynamic") == 0)
4088         flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
4089       else if (strcmp (option_value, "local-dynamic") == 0)
4090         flag_tls_default = TLS_MODEL_LOCAL_DYNAMIC;
4091       else if (strcmp (option_value, "initial-exec") == 0)
4092         flag_tls_default = TLS_MODEL_INITIAL_EXEC;
4093       else if (strcmp (option_value, "local-exec") == 0)
4094         flag_tls_default = TLS_MODEL_LOCAL_EXEC;
4095       else
4096         warning ("`%s': unknown tls-model option", arg - 2);
4097     }
4098 #ifdef INSN_SCHEDULING
4099   else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
4100     fix_sched_param ("verbose", option_value);
4101 #endif
4102   else if ((option_value = skip_leading_substring (arg, "fixed-")))
4103     fix_register (option_value, 1, 1);
4104   else if ((option_value = skip_leading_substring (arg, "call-used-")))
4105     fix_register (option_value, 0, 1);
4106   else if ((option_value = skip_leading_substring (arg, "call-saved-")))
4107     fix_register (option_value, 0, 0);
4108   else if ((option_value = skip_leading_substring (arg, "align-loops=")))
4109     align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
4110   else if ((option_value = skip_leading_substring (arg, "align-functions=")))
4111     align_functions
4112       = read_integral_parameter (option_value, arg - 2, align_functions);
4113   else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
4114     align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
4115   else if ((option_value = skip_leading_substring (arg, "align-labels=")))
4116     align_labels
4117       = read_integral_parameter (option_value, arg - 2, align_labels);
4118   else if ((option_value
4119             = skip_leading_substring (arg, "stack-limit-register=")))
4120     {
4121       int reg = decode_reg_name (option_value);
4122       if (reg < 0)
4123         error ("unrecognized register name `%s'", option_value);
4124       else
4125         stack_limit_rtx = gen_rtx_REG (Pmode, reg);
4126     }
4127   else if ((option_value
4128             = skip_leading_substring (arg, "stack-limit-symbol=")))
4129     {
4130       const char *nm;
4131       nm = ggc_strdup (option_value);
4132       stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
4133     }
4134   else if ((option_value
4135             = skip_leading_substring (arg, "message-length=")))
4136     output_set_maximum_length
4137       (&global_dc->buffer, read_integral_parameter
4138        (option_value, arg - 2, diagnostic_line_cutoff (global_dc)));
4139   else if ((option_value
4140             = skip_leading_substring (arg, "diagnostics-show-location=")))
4141     {
4142       if (!strcmp (option_value, "once"))
4143         diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
4144       else if (!strcmp (option_value, "every-line"))
4145         diagnostic_prefixing_rule (global_dc)
4146           = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
4147       else
4148         error ("unrecognized option `%s'", arg - 2);
4149     }
4150   else if (!strcmp (arg, "no-stack-limit"))
4151     stack_limit_rtx = NULL_RTX;
4152   else if (!strcmp (arg, "preprocessed"))
4153     /* Recognize this switch but do nothing.  This prevents warnings
4154        about an unrecognized switch if cpplib has not been linked in.  */
4155     ;
4156   else
4157     return 0;
4158
4159   return 1;
4160 }
4161
4162 /* Parse a -W... command line switch.  ARG is the value after the -W.
4163    It is safe to access 'ARG - 2' to generate the full switch name.
4164    Return the number of strings consumed.  */
4165
4166 static int
4167 decode_W_option (arg)
4168      const char *arg;
4169 {
4170   const char *option_value = NULL;
4171   int j;
4172
4173   /* Search for the option in the table of binary W options.  */
4174
4175   for (j = ARRAY_SIZE (W_options); j--;)
4176     {
4177       if (!strcmp (arg, W_options[j].string))
4178         {
4179           *W_options[j].variable = W_options[j].on_value;
4180           return 1;
4181         }
4182
4183       if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4184           && ! strcmp (arg + 3, W_options[j].string))
4185         {
4186           *W_options[j].variable = ! W_options[j].on_value;
4187           return 1;
4188         }
4189     }
4190
4191   if ((option_value = skip_leading_substring (arg, "id-clash-")))
4192     warning ("-Wid-clash-LEN is no longer supported");
4193   else if ((option_value = skip_leading_substring (arg, "larger-than-")))
4194     {
4195       larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
4196
4197       warn_larger_than = larger_than_size != -1;
4198     }
4199   else if (!strcmp (arg, "unused"))
4200     {
4201       set_Wunused (1);
4202     }
4203   else if (!strcmp (arg, "no-unused"))
4204     {
4205       set_Wunused (0);
4206     }
4207   else if (!strcmp (arg, "extra"))
4208     {
4209       /* We save the value of warn_uninitialized, since if they put
4210          -Wuninitialized on the command line, we need to generate a
4211          warning about not using it without also specifying -O.  */
4212       if (warn_uninitialized != 1)
4213         warn_uninitialized = 2;
4214     }
4215   else
4216     return 0;
4217
4218   return 1;
4219 }
4220
4221 /* Parse a -g... command line switch.  ARG is the value after the -g.
4222    It is safe to access 'ARG - 2' to generate the full switch name.
4223    Return the number of strings consumed.  */
4224
4225 static int
4226 decode_g_option (arg)
4227      const char *arg;
4228 {
4229   static unsigned level = 0;
4230   /* A lot of code assumes write_symbols == NO_DEBUG if the
4231      debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4232      of what debugging type has been selected).  This records the
4233      selected type.  It is an error to specify more than one
4234      debugging type.  */
4235   static enum debug_info_type selected_debug_type = NO_DEBUG;
4236   /* Nonzero if debugging format has been explicitly set.
4237      -g and -ggdb don't explicitly set the debugging format so
4238      -gdwarf -g3 is equivalent to -gdwarf3.  */
4239   static int type_explicitly_set_p = 0;
4240   /* Indexed by enum debug_info_type.  */
4241   static const char *const debug_type_names[] =
4242   {
4243     "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
4244   };
4245
4246   /* The maximum admissible debug level value.  */
4247   static const unsigned max_debug_level = 3;
4248
4249   /* Look up ARG in the table.  */
4250   for (da = debug_args; da->arg; da++)
4251     {
4252       const int da_len = strlen (da->arg);
4253
4254       if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4255         {
4256           enum debug_info_type type = da->debug_type;
4257           const char *p = arg + da_len;
4258
4259           if (*p && ! ISDIGIT (*p))
4260             continue;
4261
4262           /* A debug flag without a level defaults to level 2.
4263              Note we do not want to call read_integral_parameter
4264              for that case since it will call atoi which
4265              will return zero.
4266
4267              ??? We may want to generalize the interface to
4268              read_integral_parameter to better handle this case
4269              if this case shows up often.  */
4270           if (*p)
4271             level = read_integral_parameter (p, 0, max_debug_level + 1);
4272           else
4273             level = (level == 0) ? 2 : level;
4274
4275           if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4276             {
4277               error ("use -gdwarf -g%d for DWARF v1, level %d",
4278                      level, level);
4279               if (level == 2)
4280                 error ("use -gdwarf-2   for DWARF v2");
4281             }
4282
4283           if (level > max_debug_level)
4284             {
4285               warning ("\
4286 ignoring option `%s' due to invalid debug level specification",
4287                        arg - 2);
4288               level = debug_info_level;
4289             }
4290
4291           if (type == NO_DEBUG)
4292             {
4293               type = PREFERRED_DEBUGGING_TYPE;
4294
4295               if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4296                 {
4297 #ifdef DWARF2_DEBUGGING_INFO
4298                   type = DWARF2_DEBUG;
4299 #else
4300 #ifdef DBX_DEBUGGING_INFO
4301                   type = DBX_DEBUG;
4302 #endif
4303 #endif
4304                 }
4305             }
4306
4307           if (type == NO_DEBUG)
4308             warning ("`%s': unknown or unsupported -g option", arg - 2);
4309
4310           /* Does it conflict with an already selected type?  */
4311           if (type_explicitly_set_p
4312               /* -g/-ggdb don't conflict with anything.  */
4313               && da->debug_type != NO_DEBUG
4314               && type != selected_debug_type)
4315             warning ("`%s' ignored, conflicts with `-g%s'",
4316                      arg - 2, debug_type_names[(int) selected_debug_type]);
4317           else
4318             {
4319               /* If the format has already been set, -g/-ggdb
4320                  only change the debug level.  */
4321               if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4322                 /* Don't change debugging type.  */
4323                 ;
4324               else
4325                 {
4326                   selected_debug_type = type;
4327                   type_explicitly_set_p = da->debug_type != NO_DEBUG;
4328                 }
4329
4330               write_symbols = (level == 0
4331                                ? NO_DEBUG
4332                                : selected_debug_type);
4333               use_gnu_debug_info_extensions = da->use_extensions_p;
4334               debug_info_level = (enum debug_info_level) level;
4335             }
4336
4337           break;
4338         }
4339     }
4340
4341   if (! da->arg)
4342     return 0;
4343
4344   return 1;
4345 }
4346
4347 /* Decode the first argument in the argv as a language-independent option.
4348    Return the number of strings consumed.  */
4349
4350 static unsigned int
4351 independent_decode_option (argc, argv)
4352      int argc;
4353      char **argv;
4354 {
4355   char *arg = argv[0];
4356
4357   if (arg[0] != '-' || arg[1] == 0)
4358     {
4359       if (arg[0] == '+')
4360         return 0;
4361
4362       filename = arg;
4363
4364       return 1;
4365     }
4366
4367   arg++;
4368
4369   if (!strcmp (arg, "-help"))
4370     {
4371       display_help ();
4372       exit_after_options = 1;
4373     }
4374
4375   if (!strcmp (arg, "-target-help"))
4376     {
4377       display_target_options ();
4378       exit_after_options = 1;
4379     }
4380
4381   if (!strcmp (arg, "-version"))
4382     {
4383       print_version (stderr, "");
4384       exit_after_options = 1;
4385     }
4386
4387   /* Handle '--param <name>=<value>'.  */
4388   if (strcmp (arg, "-param") == 0)
4389     {
4390       char *equal;
4391
4392       if (argc == 1)
4393         {
4394           error ("-param option missing argument");
4395           return 1;
4396         }
4397
4398       /* Get the '<name>=<value>' parameter.  */
4399       arg = argv[1];
4400       /* Look for the `='.  */
4401       equal = strchr (arg, '=');
4402       if (!equal)
4403         error ("invalid --param option: %s", arg);
4404       else
4405         {
4406           int val;
4407
4408           /* Zero out the `=' sign so that we get two separate strings.  */
4409           *equal = '\0';
4410           /* Figure out what value is specified.  */
4411           val = read_integral_parameter (equal + 1, NULL, INVALID_PARAM_VAL);
4412           if (val != INVALID_PARAM_VAL)
4413             set_param_value (arg, val);
4414           else
4415             error ("invalid parameter value `%s'", equal + 1);
4416         }
4417
4418       return 2;
4419     }
4420
4421   if (*arg == 'Y')
4422     arg++;
4423
4424   switch (*arg)
4425     {
4426     default:
4427       return 0;
4428
4429     case 'O':
4430       /* Already been treated in main (). Do nothing.  */
4431       break;
4432
4433     case 'm':
4434       set_target_switch (arg + 1);
4435       break;
4436
4437     case 'f':
4438       return decode_f_option (arg + 1);
4439
4440     case 'g':
4441       return decode_g_option (arg + 1);
4442
4443     case 'd':
4444       if (!strcmp (arg, "dumpbase"))
4445         {
4446           if (argc == 1)
4447             return 0;
4448
4449           if (argv[1][0])
4450             dump_base_name = argv[1];
4451
4452           return 2;
4453         }
4454       else
4455         decode_d_option (arg + 1);
4456       break;
4457
4458     case 'p':
4459       if (!strcmp (arg, "pedantic"))
4460         pedantic = 1;
4461       else if (!strcmp (arg, "pedantic-errors"))
4462         flag_pedantic_errors = pedantic = 1;
4463       else if (arg[1] == 0)
4464         profile_flag = 1;
4465       else
4466         return 0;
4467       break;
4468
4469     case 'q':
4470       if (!strcmp (arg, "quiet"))
4471         quiet_flag = 1;
4472       else
4473         return 0;
4474       break;
4475
4476     case 'v':
4477       if (!strcmp (arg, "version"))
4478         version_flag = 1;
4479       else
4480         return 0;
4481       break;
4482
4483     case 'w':
4484       if (arg[1] == 0)
4485         inhibit_warnings = 1;
4486       else
4487         return 0;
4488       break;
4489
4490     case 'W':
4491       if (arg[1] == 0)
4492         {
4493           extra_warnings = 1;
4494           /* We save the value of warn_uninitialized, since if they put
4495              -Wuninitialized on the command line, we need to generate a
4496              warning about not using it without also specifying -O.  */
4497           if (warn_uninitialized != 1)
4498             warn_uninitialized = 2;
4499         }
4500       else
4501         return decode_W_option (arg + 1);
4502       break;
4503
4504     case 'a':
4505       if (!strncmp (arg, "aux-info", 8))
4506         {
4507           if (arg[8] == '\0')
4508             {
4509               if (argc == 1)
4510                 return 0;
4511
4512               aux_info_file_name = argv[1];
4513               flag_gen_aux_info = 1;
4514               return 2;
4515             }
4516           else if (arg[8] == '=')
4517             {
4518               aux_info_file_name = arg + 9;
4519               flag_gen_aux_info = 1;
4520             }
4521           else
4522             return 0;
4523         }
4524       else if (!strcmp (arg, "auxbase"))
4525         {
4526           if (argc == 1)
4527             return 0;
4528
4529           if (argv[1][0])
4530             aux_base_name = argv[1];
4531
4532           return 2;
4533         }
4534       else if (!strcmp (arg, "auxbase-strip"))
4535         {
4536           if (argc == 1)
4537             return 0;
4538
4539           if (argv[1][0])
4540             {
4541               strip_off_ending (argv[1], strlen (argv[1]));
4542               if (argv[1][0])
4543                 aux_base_name = argv[1];
4544             }
4545
4546           return 2;
4547         }
4548       else
4549         return 0;
4550       break;
4551
4552     case 'o':
4553       if (arg[1] == 0)
4554         {
4555           if (argc == 1)
4556             return 0;
4557
4558           asm_file_name = argv[1];
4559           return 2;
4560         }
4561       return 0;
4562
4563     case 'G':
4564       {
4565         int g_switch_val;
4566         int return_val;
4567
4568         if (arg[1] == 0)
4569           {
4570             if (argc == 1)
4571               return 0;
4572
4573             g_switch_val = read_integral_parameter (argv[1], 0, -1);
4574             return_val = 2;
4575           }
4576         else
4577           {
4578             g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4579             return_val = 1;
4580           }
4581
4582         if (g_switch_val == -1)
4583           return_val = 0;
4584         else
4585           {
4586             g_switch_set = TRUE;
4587             g_switch_value = g_switch_val;
4588           }
4589
4590         return return_val;
4591       }
4592     }
4593
4594   return 1;
4595 }
4596 \f
4597 /* Decode -m switches.  */
4598 /* Decode the switch -mNAME.  */
4599
4600 static void
4601 set_target_switch (name)
4602      const char *name;
4603 {
4604   size_t j;
4605   int valid_target_option = 0;
4606
4607   for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4608     if (!strcmp (target_switches[j].name, name))
4609       {
4610         if (target_switches[j].value < 0)
4611           target_flags &= ~-target_switches[j].value;
4612         else
4613           target_flags |= target_switches[j].value;
4614         if (name[0] != 0)
4615           {
4616             if (target_switches[j].value < 0)
4617               target_flags_explicit |= -target_switches[j].value;
4618             else
4619               target_flags_explicit |= target_switches[j].value;
4620           }
4621         valid_target_option = 1;
4622       }
4623
4624 #ifdef TARGET_OPTIONS
4625   if (!valid_target_option)
4626     for (j = 0; j < ARRAY_SIZE (target_options); j++)
4627       {
4628         int len = strlen (target_options[j].prefix);
4629         if (!strncmp (target_options[j].prefix, name, len))
4630           {
4631             *target_options[j].variable = name + len;
4632             valid_target_option = 1;
4633           }
4634       }
4635 #endif
4636
4637   if (!valid_target_option)
4638     error ("invalid option `%s'", name);
4639 }
4640 \f
4641 /* Print version information to FILE.
4642    Each line begins with INDENT (for the case where FILE is the
4643    assembler output file).  */
4644
4645 static void
4646 print_version (file, indent)
4647      FILE *file;
4648      const char *indent;
4649 {
4650 #ifndef __VERSION__
4651 #define __VERSION__ "[?]"
4652 #endif
4653   fnotice (file,
4654 #ifdef __GNUC__
4655            "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
4656 #else
4657            "%s%s%s version %s (%s) compiled by CC.\n"
4658 #endif
4659            , indent, *indent != 0 ? " " : "",
4660            lang_hooks.name, version_string, TARGET_NAME,
4661            indent, __VERSION__);
4662   fnotice (file, "%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n",
4663            indent, *indent != 0 ? " " : "",
4664            PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
4665 }
4666
4667 /* Print an option value and return the adjusted position in the line.
4668    ??? We don't handle error returns from fprintf (disk full); presumably
4669    other code will catch a disk full though.  */
4670
4671 static int
4672 print_single_switch (file, pos, max, indent, sep, term, type, name)
4673      FILE *file;
4674      int pos, max;
4675      const char *indent, *sep, *term, *type, *name;
4676 {
4677   /* The ultrix fprintf returns 0 on success, so compute the result we want
4678      here since we need it for the following test.  */
4679   int len = strlen (sep) + strlen (type) + strlen (name);
4680
4681   if (pos != 0
4682       && pos + len > max)
4683     {
4684       fprintf (file, "%s", term);
4685       pos = 0;
4686     }
4687   if (pos == 0)
4688     {
4689       fprintf (file, "%s", indent);
4690       pos = strlen (indent);
4691     }
4692   fprintf (file, "%s%s%s", sep, type, name);
4693   pos += len;
4694   return pos;
4695 }
4696
4697 /* Print active target switches to FILE.
4698    POS is the current cursor position and MAX is the size of a "line".
4699    Each line begins with INDENT and ends with TERM.
4700    Each switch is separated from the next by SEP.  */
4701
4702 static void
4703 print_switch_values (file, pos, max, indent, sep, term)
4704      FILE *file;
4705      int pos, max;
4706      const char *indent, *sep, *term;
4707 {
4708   size_t j;
4709   char **p;
4710
4711   /* Print the options as passed.  */
4712
4713   pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4714                              _("options passed: "), "");
4715
4716   for (p = &save_argv[1]; *p != NULL; p++)
4717     if (**p == '-')
4718       {
4719         /* Ignore these.  */
4720         if (strcmp (*p, "-o") == 0)
4721           {
4722             if (p[1] != NULL)
4723               p++;
4724             continue;
4725           }
4726         if (strcmp (*p, "-quiet") == 0)
4727           continue;
4728         if (strcmp (*p, "-version") == 0)
4729           continue;
4730         if ((*p)[1] == 'd')
4731           continue;
4732
4733         pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4734       }
4735   if (pos > 0)
4736     fprintf (file, "%s", term);
4737
4738   /* Print the -f and -m options that have been enabled.
4739      We don't handle language specific options but printing argv
4740      should suffice.  */
4741
4742   pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4743                              _("options enabled: "), "");
4744
4745   for (j = 0; j < ARRAY_SIZE (f_options); j++)
4746     if (*f_options[j].variable == f_options[j].on_value)
4747       pos = print_single_switch (file, pos, max, indent, sep, term,
4748                                  "-f", f_options[j].string);
4749
4750   /* Print target specific options.  */
4751
4752   for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4753     if (target_switches[j].name[0] != '\0'
4754         && target_switches[j].value > 0
4755         && ((target_switches[j].value & target_flags)
4756             == target_switches[j].value))
4757       {
4758         pos = print_single_switch (file, pos, max, indent, sep, term,
4759                                    "-m", target_switches[j].name);
4760       }
4761
4762 #ifdef TARGET_OPTIONS
4763   for (j = 0; j < ARRAY_SIZE (target_options); j++)
4764     if (*target_options[j].variable != NULL)
4765       {
4766         char prefix[256];
4767         sprintf (prefix, "-m%s", target_options[j].prefix);
4768         pos = print_single_switch (file, pos, max, indent, sep, term,
4769                                    prefix, *target_options[j].variable);
4770       }
4771 #endif
4772
4773   fprintf (file, "%s", term);
4774 }
4775 \f
4776 /* Open assembly code output file.  Do this even if -fsyntax-only is
4777    on, because then the driver will have provided the name of a
4778    temporary file or bit bucket for us.  NAME is the file specified on
4779    the command line, possibly NULL.  */
4780 static void
4781 init_asm_output (name)
4782      const char *name;
4783 {
4784   if (name == NULL && asm_file_name == 0)
4785     asm_out_file = stdout;
4786   else
4787     {
4788       if (asm_file_name == 0)
4789         {
4790           int len = strlen (dump_base_name);
4791           char *dumpname = (char *) xmalloc (len + 6);
4792           memcpy (dumpname, dump_base_name, len + 1);
4793           strip_off_ending (dumpname, len);
4794           strcat (dumpname, ".s");
4795           asm_file_name = dumpname;
4796         }
4797       if (!strcmp (asm_file_name, "-"))
4798         asm_out_file = stdout;
4799       else
4800         asm_out_file = fopen (asm_file_name, "w+");
4801       if (asm_out_file == 0)
4802         fatal_io_error ("can't open %s for writing", asm_file_name);
4803     }
4804
4805 #ifdef IO_BUFFER_SIZE
4806   setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
4807            _IOFBF, IO_BUFFER_SIZE);
4808 #endif
4809
4810   if (!flag_syntax_only)
4811     {
4812 #ifdef ASM_FILE_START
4813       ASM_FILE_START (asm_out_file);
4814 #endif
4815
4816 #ifdef ASM_COMMENT_START
4817       if (flag_verbose_asm)
4818         {
4819           /* Print the list of options in effect.  */
4820           print_version (asm_out_file, ASM_COMMENT_START);
4821           print_switch_values (asm_out_file, 0, MAX_LINE,
4822                                ASM_COMMENT_START, " ", "\n");
4823           /* Add a blank line here so it appears in assembler output but not
4824              screen output.  */
4825           fprintf (asm_out_file, "\n");
4826         }
4827 #endif
4828     }
4829 }
4830 \f
4831 /* Initialization of the front end environment, before command line
4832    options are parsed.  Signal handlers, internationalization etc.
4833    ARGV0 is main's argv[0].  */
4834 static void
4835 general_init (argv0)
4836      char *argv0;
4837 {
4838   char *p;
4839
4840   p = argv0 + strlen (argv0);
4841   while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4842     --p;
4843   progname = p;
4844
4845   xmalloc_set_program_name (progname);
4846
4847   hex_init ();
4848
4849   gcc_init_libintl ();
4850
4851   /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages.  */
4852 #ifdef SIGSEGV
4853   signal (SIGSEGV, crash_signal);
4854 #endif
4855 #ifdef SIGILL
4856   signal (SIGILL, crash_signal);
4857 #endif
4858 #ifdef SIGBUS
4859   signal (SIGBUS, crash_signal);
4860 #endif
4861 #ifdef SIGABRT
4862   signal (SIGABRT, crash_signal);
4863 #endif
4864 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4865   signal (SIGIOT, crash_signal);
4866 #endif
4867 #ifdef SIGFPE
4868   signal (SIGFPE, crash_signal);
4869 #endif
4870
4871   /* Other host-specific signal setup.  */
4872   (*host_hooks.extra_signals)();
4873
4874   /* Initialize the diagnostics reporting machinery, so option parsing
4875      can give warnings and errors.  */
4876   diagnostic_initialize (global_dc);
4877
4878   /* Initialize the garbage-collector, string pools and tree type hash
4879      table.  */
4880   init_ggc ();
4881   init_stringpool ();
4882   init_ttree ();
4883 }
4884 \f
4885 /* Parse command line options and set default flag values, called
4886    after language-independent option-independent initialization.  Do
4887    minimal options processing.  Outputting diagnostics is OK, but GC
4888    and identifier hashtables etc. are not initialized yet.
4889
4890    Return nonzero to suppress compiler back end initialization.  */
4891 static void
4892 parse_options_and_default_flags (argc, argv)
4893      int argc;
4894      char **argv;
4895 {
4896   int i;
4897
4898   /* Save in case md file wants to emit args as a comment.  */
4899   save_argc = argc;
4900   save_argv = argv;
4901
4902   /* Initialize register usage now so switches may override.  */
4903   init_reg_sets ();
4904
4905   /* Register the language-independent parameters.  */
4906   add_params (lang_independent_params, LAST_PARAM);
4907
4908   /* This must be done after add_params but before argument processing.  */
4909   init_ggc_heuristics();
4910
4911   /* Perform language-specific options initialization.  */
4912   (*lang_hooks.init_options) ();
4913
4914   /* Scan to see what optimization level has been specified.  That will
4915      determine the default value of many flags.  */
4916   for (i = 1; i < argc; i++)
4917     {
4918       if (!strcmp (argv[i], "-O"))
4919         {
4920           optimize = 1;
4921           optimize_size = 0;
4922         }
4923       else if (argv[i][0] == '-' && argv[i][1] == 'O')
4924         {
4925           /* Handle -Os, -O2, -O3, -O69, ...  */
4926           char *p = &argv[i][2];
4927
4928           if ((p[0] == 's') && (p[1] == 0))
4929             {
4930               optimize_size = 1;
4931
4932               /* Optimizing for size forces optimize to be 2.  */
4933               optimize = 2;
4934             }
4935           else
4936             {
4937               const int optimize_val = read_integral_parameter (p, p - 2, -1);
4938               if (optimize_val != -1)
4939                 {
4940                   optimize = optimize_val;
4941                   optimize_size = 0;
4942                 }
4943             }
4944         }
4945     }
4946
4947   if (!optimize)
4948     {
4949       flag_merge_constants = 0;
4950     }
4951
4952   if (optimize >= 1)
4953     {
4954       flag_defer_pop = 1;
4955       flag_thread_jumps = 1;
4956 #ifdef DELAY_SLOTS
4957       flag_delayed_branch = 1;
4958 #endif
4959 #ifdef CAN_DEBUG_WITHOUT_FP
4960       flag_omit_frame_pointer = 1;
4961 #endif
4962       flag_guess_branch_prob = 1;
4963       flag_cprop_registers = 1;
4964       flag_loop_optimize = 1;
4965       flag_crossjumping = 1;
4966       flag_if_conversion = 1;
4967       flag_if_conversion2 = 1;
4968     }
4969
4970   if (optimize >= 2)
4971     {
4972       flag_optimize_sibling_calls = 1;
4973       flag_cse_follow_jumps = 1;
4974       flag_cse_skip_blocks = 1;
4975       flag_gcse = 1;
4976       flag_expensive_optimizations = 1;
4977       flag_strength_reduce = 1;
4978       flag_rerun_cse_after_loop = 1;
4979       flag_rerun_loop_opt = 1;
4980       flag_caller_saves = 1;
4981       flag_force_mem = 1;
4982       flag_peephole2 = 1;
4983 #ifdef INSN_SCHEDULING
4984       flag_schedule_insns = 1;
4985       flag_schedule_insns_after_reload = 1;
4986 #endif
4987       flag_regmove = 1;
4988       flag_strict_aliasing = 1;
4989       flag_delete_null_pointer_checks = 1;
4990       flag_reorder_blocks = 1;
4991       flag_reorder_functions = 1;
4992     }
4993
4994   if (optimize >= 3)
4995     {
4996       flag_inline_functions = 1;
4997       flag_rename_registers = 1;
4998       flag_unswitch_loops = 1;
4999     }
5000
5001   if (optimize < 2 || optimize_size)
5002     {
5003       align_loops = 1;
5004       align_jumps = 1;
5005       align_labels = 1;
5006       align_functions = 1;
5007
5008       /* Don't reorder blocks when optimizing for size because extra
5009          jump insns may be created; also barrier may create extra padding.
5010
5011          More correctly we should have a block reordering mode that tried
5012          to minimize the combined size of all the jumps.  This would more
5013          or less automatically remove extra jumps, but would also try to
5014          use more short jumps instead of long jumps.  */
5015       flag_reorder_blocks = 0;
5016     }
5017
5018   /* Initialize whether `char' is signed.  */
5019   flag_signed_char = DEFAULT_SIGNED_CHAR;
5020 #ifdef DEFAULT_SHORT_ENUMS
5021   /* Initialize how much space enums occupy, by default.  */
5022   flag_short_enums = DEFAULT_SHORT_ENUMS;
5023 #endif
5024
5025   /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
5026      modify it.  */
5027   target_flags = 0;
5028   set_target_switch ("");
5029
5030   /* Unwind tables are always present in an ABI-conformant IA-64
5031      object file, so the default should be ON.  */
5032 #ifdef IA64_UNWIND_INFO
5033   flag_unwind_tables = IA64_UNWIND_INFO;
5034 #endif
5035
5036 #ifdef OPTIMIZATION_OPTIONS
5037   /* Allow default optimizations to be specified on a per-machine basis.  */
5038   OPTIMIZATION_OPTIONS (optimize, optimize_size);
5039 #endif
5040
5041   /* Perform normal command line switch decoding.  */
5042   for (i = 1; i < argc;)
5043     {
5044       int lang_processed;
5045       int indep_processed;
5046
5047       /* Give the language a chance to decode the option for itself.  */
5048       lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
5049
5050       if (lang_processed >= 0)
5051         /* Now see if the option also has a language independent meaning.
5052            Some options are both language specific and language independent,
5053            eg --help.  */
5054         indep_processed = independent_decode_option (argc - i, argv + i);
5055       else
5056         {
5057           lang_processed = -lang_processed;
5058           indep_processed = 0;
5059         }
5060
5061       if (lang_processed || indep_processed)
5062         i += MAX (lang_processed, indep_processed);
5063       else
5064         {
5065           const char *option = NULL;
5066           const char *lang = NULL;
5067           unsigned int j;
5068
5069           /* It is possible that the command line switch is not valid for the
5070              current language, but it is valid for another language.  In order
5071              to be compatible with previous versions of the compiler (which
5072              did not issue an error message in this case) we check for this
5073              possibility here.  If we do find a match, then if extra_warnings
5074              is set we generate a warning message, otherwise we will just
5075              ignore the option.  */
5076           for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
5077             {
5078               option = documented_lang_options[j].option;
5079
5080               if (option == NULL)
5081                 lang = documented_lang_options[j].description;
5082               else if (! strncmp (argv[i], option, strlen (option)))
5083                 break;
5084             }
5085
5086           if (j != ARRAY_SIZE (documented_lang_options))
5087             {
5088               if (extra_warnings)
5089                 {
5090                   warning ("ignoring command line option '%s'", argv[i]);
5091                   if (lang)
5092                     warning
5093                       ("(it is valid for %s but not the selected language)",
5094                        lang);
5095                 }
5096             }
5097           else if (argv[i][0] == '-' && argv[i][1] == 'g')
5098             warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
5099           else
5100             error ("unrecognized option `%s'", argv[i]);
5101
5102           i++;
5103         }
5104     }
5105
5106   if (flag_no_inline == 2)
5107     flag_no_inline = 0;
5108   else
5109     flag_really_no_inline = flag_no_inline;
5110
5111   /* Set flag_no_inline before the post_options () hook.  The C front
5112      ends use it to determine tree inlining defaults.  FIXME: such
5113      code should be lang-independent when all front ends use tree
5114      inlining, in which case it, and this condition, should be moved
5115      to the top of process_options() instead.  */
5116   if (optimize == 0)
5117     {
5118       /* Inlining does not work if not optimizing,
5119          so force it not to be done.  */
5120       flag_no_inline = 1;
5121       warn_inline = 0;
5122
5123       /* The c_decode_option function and decode_option hook set
5124          this to `2' if -Wall is used, so we can avoid giving out
5125          lots of errors for people who don't realize what -Wall does.  */
5126       if (warn_uninitialized == 1)
5127         warning ("-Wuninitialized is not supported without -O");
5128     }
5129
5130   if (flag_really_no_inline == 2)
5131     flag_really_no_inline = flag_no_inline;
5132 }
5133 \f
5134 /* Process the options that have been parsed.  */
5135 static void
5136 process_options ()
5137 {
5138 #ifdef OVERRIDE_OPTIONS
5139   /* Some machines may reject certain combinations of options.  */
5140   OVERRIDE_OPTIONS;
5141 #endif
5142
5143   /* Set up the align_*_log variables, defaulting them to 1 if they
5144      were still unset.  */
5145   if (align_loops <= 0) align_loops = 1;
5146   if (align_loops_max_skip > align_loops || !align_loops)
5147     align_loops_max_skip = align_loops - 1;
5148   align_loops_log = floor_log2 (align_loops * 2 - 1);
5149   if (align_jumps <= 0) align_jumps = 1;
5150   if (align_jumps_max_skip > align_jumps || !align_jumps)
5151     align_jumps_max_skip = align_jumps - 1;
5152   align_jumps_log = floor_log2 (align_jumps * 2 - 1);
5153   if (align_labels <= 0) align_labels = 1;
5154   align_labels_log = floor_log2 (align_labels * 2 - 1);
5155   if (align_labels_max_skip > align_labels || !align_labels)
5156     align_labels_max_skip = align_labels - 1;
5157   if (align_functions <= 0) align_functions = 1;
5158   align_functions_log = floor_log2 (align_functions * 2 - 1);
5159
5160   /* Unrolling all loops implies that standard loop unrolling must also
5161      be done.  */
5162   if (flag_unroll_all_loops)
5163     flag_unroll_loops = 1;
5164
5165   if (flag_unroll_loops)
5166     {
5167       flag_old_unroll_loops = 0;
5168       flag_old_unroll_all_loops = 0;
5169     }
5170
5171   if (flag_old_unroll_all_loops)
5172     flag_old_unroll_loops = 1;
5173
5174   /* Old loop unrolling requires that strength_reduction be on also.  Silently
5175      turn on strength reduction here if it isn't already on.  Also, the loop
5176      unrolling code assumes that cse will be run after loop, so that must
5177      be turned on also.  */
5178   if (flag_old_unroll_loops)
5179     {
5180       flag_strength_reduce = 1;
5181       flag_rerun_cse_after_loop = 1;
5182     }
5183   if (flag_unroll_loops || flag_peel_loops)
5184     flag_rerun_cse_after_loop = 1;
5185
5186   if (flag_non_call_exceptions)
5187     flag_asynchronous_unwind_tables = 1;
5188   if (flag_asynchronous_unwind_tables)
5189     flag_unwind_tables = 1;
5190
5191   /* Disable unit-at-a-time mode for frontends not supporting callgraph
5192      interface.  */
5193   if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
5194     flag_unit_at_a_time = 0;
5195
5196   /* Warn about options that are not supported on this machine.  */
5197 #ifndef INSN_SCHEDULING
5198   if (flag_schedule_insns || flag_schedule_insns_after_reload)
5199     warning ("instruction scheduling not supported on this target machine");
5200 #endif
5201 #ifndef DELAY_SLOTS
5202   if (flag_delayed_branch)
5203     warning ("this target machine does not have delayed branches");
5204 #endif
5205
5206   user_label_prefix = USER_LABEL_PREFIX;
5207   if (flag_leading_underscore != -1)
5208     {
5209       /* If the default prefix is more complicated than "" or "_",
5210          issue a warning and ignore this option.  */
5211       if (user_label_prefix[0] == 0 ||
5212           (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5213         {
5214           user_label_prefix = flag_leading_underscore ? "_" : "";
5215         }
5216       else
5217         warning ("-f%sleading-underscore not supported on this target machine",
5218                  flag_leading_underscore ? "" : "no-");
5219     }
5220
5221   /* If we are in verbose mode, write out the version and maybe all the
5222      option flags in use.  */
5223   if (version_flag)
5224     {
5225       print_version (stderr, "");
5226       if (! quiet_flag)
5227         print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5228     }
5229
5230   if (! quiet_flag  || flag_detailed_statistics)
5231     time_report = 1;
5232
5233   if (flag_syntax_only)
5234     {
5235       write_symbols = NO_DEBUG;
5236       profile_flag = 0;
5237     }
5238
5239   /* Now we know write_symbols, set up the debug hooks based on it.
5240      By default we do nothing for debug output.  */
5241 #if defined(DBX_DEBUGGING_INFO)
5242   if (write_symbols == DBX_DEBUG)
5243     debug_hooks = &dbx_debug_hooks;
5244 #endif
5245 #if defined(XCOFF_DEBUGGING_INFO)
5246   if (write_symbols == XCOFF_DEBUG)
5247     debug_hooks = &xcoff_debug_hooks;
5248 #endif
5249 #ifdef SDB_DEBUGGING_INFO
5250   if (write_symbols == SDB_DEBUG)
5251     debug_hooks = &sdb_debug_hooks;
5252 #endif
5253 #ifdef DWARF_DEBUGGING_INFO
5254   if (write_symbols == DWARF_DEBUG)
5255     debug_hooks = &dwarf_debug_hooks;
5256 #endif
5257 #ifdef DWARF2_DEBUGGING_INFO
5258   if (write_symbols == DWARF2_DEBUG)
5259     debug_hooks = &dwarf2_debug_hooks;
5260 #endif
5261 #ifdef VMS_DEBUGGING_INFO
5262   if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
5263     debug_hooks = &vmsdbg_debug_hooks;
5264 #endif
5265
5266   /* If auxiliary info generation is desired, open the output file.
5267      This goes in the same directory as the source file--unlike
5268      all the other output files.  */
5269   if (flag_gen_aux_info)
5270     {
5271       aux_info_file = fopen (aux_info_file_name, "w");
5272       if (aux_info_file == 0)
5273         fatal_io_error ("can't open %s", aux_info_file_name);
5274     }
5275
5276   if (! targetm.have_named_sections)
5277     {
5278       if (flag_function_sections)
5279         {
5280           warning ("-ffunction-sections not supported for this target");
5281           flag_function_sections = 0;
5282         }
5283       if (flag_data_sections)
5284         {
5285           warning ("-fdata-sections not supported for this target");
5286           flag_data_sections = 0;
5287         }
5288     }
5289
5290   if (flag_function_sections && profile_flag)
5291     {
5292       warning ("-ffunction-sections disabled; it makes profiling impossible");
5293       flag_function_sections = 0;
5294     }
5295
5296 #ifndef HAVE_prefetch
5297   if (flag_prefetch_loop_arrays)
5298     {
5299       warning ("-fprefetch-loop-arrays not supported for this target");
5300       flag_prefetch_loop_arrays = 0;
5301     }
5302 #else
5303   if (flag_prefetch_loop_arrays && !HAVE_prefetch)
5304     {
5305       warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
5306       flag_prefetch_loop_arrays = 0;
5307     }
5308 #endif
5309
5310   /* This combination of options isn't handled for i386 targets and doesn't
5311      make much sense anyway, so don't allow it.  */
5312   if (flag_prefetch_loop_arrays && optimize_size)
5313     {
5314       warning ("-fprefetch-loop-arrays is not supported with -Os");
5315       flag_prefetch_loop_arrays = 0;
5316     }
5317
5318 #ifndef OBJECT_FORMAT_ELF
5319   if (flag_function_sections && write_symbols != NO_DEBUG)
5320     warning ("-ffunction-sections may affect debugging on some targets");
5321 #endif
5322
5323     /* The presence of IEEE signaling NaNs, implies all math can trap.  */
5324     if (flag_signaling_nans)
5325       flag_trapping_math = 1;
5326 }
5327 \f
5328 /* Initialize the compiler back end.  */
5329 static void
5330 backend_init ()
5331 {
5332   /* init_emit_once uses reg_raw_mode and therefore must be called
5333      after init_regs which initialized reg_raw_mode.  */
5334   init_regs ();
5335   init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
5336                   || debug_info_level == DINFO_LEVEL_VERBOSE
5337 #ifdef VMS_DEBUGGING_INFO
5338                     /* Enable line number info for traceback */
5339                     || debug_info_level > DINFO_LEVEL_NONE
5340 #endif
5341                     || flag_test_coverage
5342                     || warn_notreached);
5343   init_fake_stack_mems ();
5344   init_alias_once ();
5345   init_loop ();
5346   init_reload ();
5347   init_function_once ();
5348   init_varasm_once ();
5349
5350   /* The following initialization functions need to generate rtl, so
5351      provide a dummy function context for them.  */
5352   init_dummy_function_start ();
5353   init_expmed ();
5354   if (flag_caller_saves)
5355     init_caller_save ();
5356   expand_dummy_function_end ();
5357 }
5358 \f
5359 /* Language-dependent initialization.  Returns nonzero on success.  */
5360 static int
5361 lang_dependent_init (name)
5362      const char *name;
5363 {
5364   if (dump_base_name == 0)
5365     dump_base_name = name ? name : "gccdump";
5366
5367   /* Front-end initialization.  This hook can assume that GC,
5368      identifier hashes etc. are set up, but debug initialization is
5369      not done yet.  This routine must return the original filename
5370      (e.g. foo.i -> foo.c) so can correctly initialize debug output.  */
5371   name = (*lang_hooks.init) (name);
5372   if (name == NULL)
5373     return 0;
5374
5375   /* Is this duplication necessary?  */
5376   name = ggc_strdup (name);
5377   main_input_filename = input_filename = name;
5378   init_asm_output (name);
5379
5380   /* These create various _DECL nodes, so need to be called after the
5381      front end is initialized.  */
5382   init_eh ();
5383   init_optabs ();
5384
5385   /* The following initialization functions need to generate rtl, so
5386      provide a dummy function context for them.  */
5387   init_dummy_function_start ();
5388   init_expr_once ();
5389   expand_dummy_function_end ();
5390
5391   /* Put an entry on the input file stack for the main input file.  */
5392   push_srcloc (input_filename, 0);
5393
5394   /* If dbx symbol table desired, initialize writing it and output the
5395      predefined types.  */
5396   timevar_push (TV_SYMOUT);
5397
5398 #ifdef DWARF2_UNWIND_INFO
5399   if (dwarf2out_do_frame ())
5400     dwarf2out_frame_init ();
5401 #endif
5402
5403   /* Now we have the correct original filename, we can initialize
5404      debug output.  */
5405   (*debug_hooks->init) (name);
5406
5407   timevar_pop (TV_SYMOUT);
5408
5409   return 1;
5410 }
5411 \f
5412 /* Clean up: close opened files, etc.  */
5413
5414 static void
5415 finalize ()
5416 {
5417   /* Close the dump files.  */
5418   if (flag_gen_aux_info)
5419     {
5420       fclose (aux_info_file);
5421       if (errorcount)
5422         unlink (aux_info_file_name);
5423     }
5424
5425   /* Close non-debugging input and output files.  Take special care to note
5426      whether fclose returns an error, since the pages might still be on the
5427      buffer chain while the file is open.  */
5428
5429   if (asm_out_file)
5430     {
5431       if (ferror (asm_out_file) != 0)
5432         fatal_io_error ("error writing to %s", asm_file_name);
5433       if (fclose (asm_out_file) != 0)
5434         fatal_io_error ("error closing %s", asm_file_name);
5435     }
5436
5437   /* Do whatever is necessary to finish printing the graphs.  */
5438   if (graph_dump_format != no_graph)
5439     {
5440       int i;
5441
5442       for (i = 0; i < (int) DFI_MAX; ++i)
5443         if (dump_file[i].initialized && dump_file[i].graph_dump_p)
5444           {
5445             char seq[16];
5446             char *suffix;
5447
5448             sprintf (seq, DUMPFILE_FORMAT, i);
5449             suffix = concat (seq, dump_file[i].extension, NULL);
5450             finish_graph_dump_file (dump_base_name, suffix);
5451             free (suffix);
5452           }
5453     }
5454
5455   if (mem_report)
5456     {
5457       ggc_print_statistics ();
5458       stringpool_statistics ();
5459       dump_tree_statistics ();
5460     }
5461
5462   /* Free up memory for the benefit of leak detectors.  */
5463   free_reg_info ();
5464
5465   /* Language-specific end of compilation actions.  */
5466   (*lang_hooks.finish) ();
5467 }
5468 \f
5469 /* Initialize the compiler, and compile the input file.  */
5470 static void
5471 do_compile ()
5472 {
5473   /* All command line options have been parsed; allow the front end to
5474      perform consistency checks, etc.  */
5475   bool no_backend = (*lang_hooks.post_options) ();
5476
5477   /* The bulk of command line switch processing.  */
5478   process_options ();
5479
5480   /* If an error has already occurred, give up.  */
5481   if (errorcount)
5482     return;
5483
5484   if (aux_base_name)
5485     /*NOP*/;
5486   else if (filename)
5487     {
5488       char *name = xstrdup (lbasename (filename));
5489
5490       aux_base_name = name;
5491       strip_off_ending (name, strlen (name));
5492     }
5493   else
5494     aux_base_name = "gccaux";
5495
5496   /* We cannot start timing until after options are processed since that
5497      says if we run timers or not.  */
5498   init_timevar ();
5499   timevar_start (TV_TOTAL);
5500
5501   /* Set up the back-end if requested.  */
5502   if (!no_backend)
5503     backend_init ();
5504
5505   /* Language-dependent initialization.  Returns true on success.  */
5506   if (lang_dependent_init (filename))
5507     compile_file ();
5508
5509   finalize ();
5510
5511   /* Stop timing and print the times.  */
5512   timevar_stop (TV_TOTAL);
5513   timevar_print (stderr);
5514 }
5515 \f
5516 /* Entry point of cc1, cc1plus, jc1, f771, etc.
5517    Decode command args, then call compile_file.
5518    Exit code is FATAL_EXIT_CODE if can't open files or if there were
5519    any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
5520
5521    It is not safe to call this function more than once.  */
5522
5523 int
5524 toplev_main (argc, argv)
5525      int argc;
5526      char **argv;
5527 {
5528   /* Initialization of GCC's environment, and diagnostics.  */
5529   general_init (argv[0]);
5530
5531   /* Parse the options and do minimal processing; basically just
5532      enough to default flags appropriately.  */
5533   parse_options_and_default_flags (argc, argv);
5534
5535   /* Exit early if we can (e.g. -help).  */
5536   if (!exit_after_options)
5537     do_compile ();
5538
5539   if (errorcount || sorrycount)
5540     return (FATAL_EXIT_CODE);
5541
5542   return (SUCCESS_EXIT_CODE);
5543 }