OSDN Git Service

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