OSDN Git Service

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