OSDN Git Service

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