OSDN Git Service

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