OSDN Git Service

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