OSDN Git Service

* recog.c (general_operand, immediate_operand,
[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           reg_scan (insns, max_reg_num (), 0);
3228           jump_optimize (insns, !JUMP_CROSS_JUMP,
3229                          !JUMP_NOOP_MOVES, JUMP_AFTER_REGSCAN);
3230
3231           timevar_push (TV_IFCVT);
3232
3233           find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3234           cleanup_cfg ();
3235           if_convert (0);
3236
3237           timevar_pop(TV_IFCVT);
3238
3239           timevar_pop (TV_JUMP);
3240
3241           reg_scan (insns, max_reg_num (), 0);
3242           tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3243
3244           if (tem)
3245             {
3246               timevar_push (TV_JUMP);
3247               jump_optimize (insns, !JUMP_CROSS_JUMP,
3248                              !JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3249               timevar_pop (TV_JUMP);
3250             }
3251         }
3252
3253       if (flag_thread_jumps)
3254         {
3255           /* This pass of jump threading straightens out code
3256              that was kinked by loop optimization.  */
3257           timevar_push (TV_JUMP);
3258           reg_scan (insns, max_reg_num (), 0);
3259           thread_jumps (insns, max_reg_num (), 0);
3260           timevar_pop (TV_JUMP);
3261         }
3262
3263       close_dump_file (DFI_cse2, print_rtl, insns);
3264       timevar_pop (TV_CSE2);
3265
3266       ggc_collect ();
3267     }
3268
3269   cse_not_expected = 1;
3270
3271   regclass_init ();
3272
3273   /* Do control and data flow analysis; wrote some of the results to
3274      the dump file.  */
3275
3276   timevar_push (TV_FLOW);
3277   open_dump_file (DFI_cfg, decl);
3278
3279   find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3280   cleanup_cfg ();
3281   check_function_return_warnings ();
3282
3283   close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
3284
3285   if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3286     {
3287       timevar_push (TV_BRANCH_PROB);
3288       open_dump_file (DFI_bp, decl);
3289
3290       branch_prob ();
3291
3292       close_dump_file (DFI_bp, print_rtl_with_bb, insns);
3293       timevar_pop (TV_BRANCH_PROB);
3294     }
3295
3296   open_dump_file (DFI_life, decl);
3297   if (optimize)
3298     {
3299       struct loops loops;
3300
3301       /* Discover and record the loop depth at the head of each basic
3302          block.  The loop infrastructure does the real job for us.  */
3303       flow_loops_find (&loops, LOOP_TREE);
3304
3305       /* Estimate using heuristics if no profiling info is available.  */
3306       if (flag_guess_branch_prob)
3307         estimate_probability (&loops);
3308
3309       if (rtl_dump_file)
3310         flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
3311
3312       flow_loops_free (&loops);
3313     }
3314   life_analysis (insns, rtl_dump_file, PROP_FINAL);
3315   mark_constant_function ();
3316   timevar_pop (TV_FLOW);
3317
3318   register_life_up_to_date = 1;
3319   no_new_pseudos = 1;
3320
3321   if (warn_uninitialized || extra_warnings)
3322     {
3323       uninitialized_vars_warning (DECL_INITIAL (decl));
3324       if (extra_warnings)
3325         setjmp_args_warning ();
3326     }
3327
3328   close_dump_file (DFI_life, print_rtl_with_bb, insns);
3329
3330   ggc_collect ();
3331
3332   /* If -opt, try combining insns through substitution.  */
3333
3334   if (optimize > 0)
3335     {
3336       int rebuild_jump_labels_after_combine = 0;
3337
3338       timevar_push (TV_COMBINE);
3339       open_dump_file (DFI_combine, decl);
3340
3341       rebuild_jump_labels_after_combine
3342         = combine_instructions (insns, max_reg_num ());
3343
3344       /* Combining insns may have turned an indirect jump into a
3345          direct jump.  Rebuid the JUMP_LABEL fields of jumping
3346          instructions.  */
3347       if (rebuild_jump_labels_after_combine)
3348         {
3349           timevar_push (TV_JUMP);
3350           rebuild_jump_labels (insns);
3351           timevar_pop (TV_JUMP);
3352
3353           timevar_push (TV_FLOW);
3354           find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3355           cleanup_cfg ();
3356
3357           /* Blimey.  We've got to have the CFG up to date for the call to
3358              if_convert below.  However, the random deletion of blocks
3359              without updating life info can wind up with Wierd Stuff in
3360              global_live_at_end.  We then run sched1, which updates things
3361              properly, discovers the wierdness and aborts.  */
3362           update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
3363                             PROP_DEATH_NOTES | PROP_KILL_DEAD_CODE
3364                             | PROP_SCAN_DEAD_CODE);
3365
3366           timevar_pop (TV_FLOW);
3367         }
3368
3369       close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3370       timevar_pop (TV_COMBINE);
3371
3372       ggc_collect ();
3373     }
3374
3375   /* Rerun if-conversion, as combine may have simplified things enough to
3376      now meet sequence length restrictions.  */
3377   if (optimize > 0)
3378     {
3379       timevar_push (TV_IFCVT);
3380       open_dump_file (DFI_ce, decl);
3381
3382       no_new_pseudos = 0;
3383       if_convert (1);
3384       no_new_pseudos = 1;
3385
3386       close_dump_file (DFI_ce, print_rtl_with_bb, insns);
3387       timevar_pop (TV_IFCVT);
3388     }
3389
3390   /* Register allocation pre-pass, to reduce number of moves
3391      necessary for two-address machines.  */
3392   if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3393     {
3394       timevar_push (TV_REGMOVE);
3395       open_dump_file (DFI_regmove, decl);
3396
3397       regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3398
3399       close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3400       timevar_pop (TV_REGMOVE);
3401
3402       ggc_collect ();
3403     }
3404
3405   /* Any of the several passes since flow1 will have munged register
3406      lifetime data a bit.  */
3407   if (optimize > 0)
3408     register_life_up_to_date = 0;
3409
3410 #ifdef OPTIMIZE_MODE_SWITCHING
3411   timevar_push (TV_GCSE);
3412
3413   if (optimize_mode_switching (NULL_PTR))
3414     {
3415       /* We did work, and so had to regenerate global life information.
3416          Take advantage of this and don't re-recompute register life
3417          information below.  */
3418       register_life_up_to_date = 1;
3419     }
3420
3421   timevar_pop (TV_GCSE);
3422 #endif
3423
3424 #ifdef INSN_SCHEDULING
3425
3426   /* Print function header into sched dump now
3427      because doing the sched analysis makes some of the dump.  */
3428   if (optimize > 0 && flag_schedule_insns)
3429     {
3430       timevar_push (TV_SCHED);
3431       open_dump_file (DFI_sched, decl);
3432
3433       /* Do control and data sched analysis,
3434          and write some of the results to dump file.  */
3435
3436       schedule_insns (rtl_dump_file);
3437
3438       close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3439       timevar_pop (TV_SCHED);
3440
3441       ggc_collect ();
3442
3443       /* Register lifetime information was updated as part of verifying
3444          the schedule.  */
3445       register_life_up_to_date = 1;
3446     }
3447 #endif
3448
3449   /* Determine if the current function is a leaf before running reload
3450      since this can impact optimizations done by the prologue and
3451      epilogue thus changing register elimination offsets.  */
3452   current_function_is_leaf = leaf_function_p ();
3453
3454   timevar_push (TV_LOCAL_ALLOC);
3455   open_dump_file (DFI_lreg, decl);
3456
3457   /* Allocate pseudo-regs that are used only within 1 basic block.
3458
3459      RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3460      jump optimizer after register allocation and reloading are finished.  */
3461
3462   if (! register_life_up_to_date)
3463     recompute_reg_usage (insns, ! optimize_size);
3464   regclass (insns, max_reg_num (), rtl_dump_file);
3465   rebuild_label_notes_after_reload = local_alloc ();
3466
3467   timevar_pop (TV_LOCAL_ALLOC);
3468
3469   if (dump_file[DFI_lreg].enabled)
3470     {
3471       timevar_push (TV_DUMP);
3472
3473       dump_flow_info (rtl_dump_file);
3474       dump_local_alloc (rtl_dump_file);
3475
3476       close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3477       timevar_pop (TV_DUMP);
3478     }
3479
3480   ggc_collect ();
3481
3482   timevar_push (TV_GLOBAL_ALLOC);
3483   open_dump_file (DFI_greg, decl);
3484
3485   /* If optimizing, allocate remaining pseudo-regs.  Do the reload
3486      pass fixing up any insns that are invalid.  */
3487
3488   if (optimize)
3489     failure = global_alloc (rtl_dump_file);
3490   else
3491     {
3492       build_insn_chain (insns);
3493       failure = reload (insns, 0);
3494     }
3495
3496   timevar_pop (TV_GLOBAL_ALLOC);
3497
3498   if (dump_file[DFI_greg].enabled)
3499     {
3500       timevar_push (TV_DUMP);
3501
3502       dump_global_regs (rtl_dump_file);
3503
3504       close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3505       timevar_pop (TV_DUMP);
3506     }
3507
3508   if (failure)
3509     goto exit_rest_of_compilation;
3510
3511   ggc_collect ();
3512
3513   open_dump_file (DFI_postreload, decl);
3514
3515   /* Do a very simple CSE pass over just the hard registers.  */
3516   if (optimize > 0)
3517     {
3518       timevar_push (TV_RELOAD_CSE_REGS);
3519       reload_cse_regs (insns);
3520       timevar_pop (TV_RELOAD_CSE_REGS);
3521     }
3522
3523   /* If optimizing, then go ahead and split insns now since we are about
3524      to recompute flow information anyway.  Since we can't split insns after
3525      reload, do the splitting unconditionally here to avoid gcc from losing
3526      REG_DEAD notes.  */
3527 #ifdef STACK_REGS
3528   if (1)
3529 #else
3530   if (optimize > 0)
3531 #endif
3532     {
3533       int old_labelnum = max_label_num ();
3534
3535       split_all_insns (0);
3536       rebuild_label_notes_after_reload |= old_labelnum != max_label_num ();
3537     }
3538
3539   /* Register allocation and reloading may have turned an indirect jump into
3540      a direct jump.  If so, we must rebuild the JUMP_LABEL fields of
3541      jumping instructions.  */
3542   if (rebuild_label_notes_after_reload)
3543     {
3544       timevar_push (TV_JUMP);
3545
3546       rebuild_jump_labels (insns);
3547
3548       timevar_pop (TV_JUMP);
3549     }
3550
3551   close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3552
3553   /* Re-create the death notes which were deleted during reload.  */
3554   timevar_push (TV_FLOW2);
3555   open_dump_file (DFI_flow2, decl);
3556
3557   jump_optimize (insns, !JUMP_CROSS_JUMP,
3558                  JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3559   find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3560
3561   /* On some machines, the prologue and epilogue code, or parts thereof,
3562      can be represented as RTL.  Doing so lets us schedule insns between
3563      it and the rest of the code and also allows delayed branch
3564      scheduling to operate in the epilogue.  */
3565   thread_prologue_and_epilogue_insns (insns);
3566
3567   if (optimize)
3568     {
3569       cleanup_cfg ();
3570       life_analysis (insns, rtl_dump_file, PROP_FINAL);
3571
3572       /* This is kind of a heuristic.  We need to run combine_stack_adjustments
3573          even for machines with possibly nonzero RETURN_POPS_ARGS
3574          and ACCUMULATE_OUTGOING_ARGS.  We expect that only ports having
3575          push instructions will have popping returns.  */
3576 #ifndef PUSH_ROUNDING
3577       if (!ACCUMULATE_OUTGOING_ARGS)
3578 #endif
3579         combine_stack_adjustments ();
3580
3581       ggc_collect ();
3582     }
3583
3584   flow2_completed = 1;
3585
3586   close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3587   timevar_pop (TV_FLOW2);
3588
3589 #ifdef HAVE_peephole2
3590   if (optimize > 0 && flag_peephole2)
3591     {
3592       timevar_push (TV_PEEPHOLE2);
3593       open_dump_file (DFI_peephole2, decl);
3594
3595       peephole2_optimize (rtl_dump_file);
3596
3597       close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3598       timevar_pop (TV_PEEPHOLE2);
3599     }
3600 #endif
3601
3602   if (optimize > 0 && flag_rename_registers)
3603     {
3604       timevar_push (TV_RENAME_REGISTERS);
3605       open_dump_file (DFI_rnreg, decl);
3606
3607       regrename_optimize ();
3608
3609       close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3610       timevar_pop (TV_RENAME_REGISTERS);
3611     }
3612
3613   if (optimize > 0)
3614     {
3615       timevar_push (TV_IFCVT2);
3616       open_dump_file (DFI_ce2, decl);
3617
3618       if_convert (1);
3619
3620       close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3621       timevar_pop (TV_IFCVT2);
3622     }
3623
3624 #ifdef INSN_SCHEDULING
3625   if (optimize > 0 && flag_schedule_insns_after_reload)
3626     {
3627       timevar_push (TV_SCHED2);
3628       open_dump_file (DFI_sched2, decl);
3629
3630       /* Do control and data sched analysis again,
3631          and write some more of the results to dump file.  */
3632
3633       schedule_insns (rtl_dump_file);
3634
3635       close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3636       timevar_pop (TV_SCHED2);
3637
3638       ggc_collect ();
3639     }
3640 #endif
3641
3642 #ifdef LEAF_REGISTERS
3643   current_function_uses_only_leaf_regs
3644     = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3645 #endif
3646
3647   if (optimize > 0 && flag_reorder_blocks)
3648     {
3649       timevar_push (TV_REORDER_BLOCKS);
3650       open_dump_file (DFI_bbro, decl);
3651
3652       reorder_basic_blocks ();
3653
3654       close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3655       timevar_pop (TV_REORDER_BLOCKS);
3656     }
3657
3658   /* One more attempt to remove jumps to .+1 left by dead-store elimination.
3659      Also do cross-jumping this time and delete no-op move insns.  */
3660
3661   if (optimize > 0)
3662     {
3663       timevar_push (TV_JUMP);
3664       open_dump_file (DFI_jump2, decl);
3665
3666       jump_optimize (insns, JUMP_CROSS_JUMP, JUMP_NOOP_MOVES,
3667                      !JUMP_AFTER_REGSCAN);
3668
3669       /* CFG no longer kept up to date.  */
3670
3671       close_dump_file (DFI_jump2, print_rtl, insns);
3672       timevar_pop (TV_JUMP);
3673     }
3674
3675   /* If a machine dependent reorganization is needed, call it.  */
3676 #ifdef MACHINE_DEPENDENT_REORG
3677   open_dump_file (DFI_mach, decl);
3678
3679   MACHINE_DEPENDENT_REORG (insns);
3680
3681   close_dump_file (DFI_mach, print_rtl, insns);
3682
3683   ggc_collect ();
3684 #endif
3685
3686   /* If a scheduling pass for delayed branches is to be done,
3687      call the scheduling code.  */
3688
3689 #ifdef DELAY_SLOTS
3690   if (optimize > 0 && flag_delayed_branch)
3691     {
3692       timevar_push (TV_DBR_SCHED);
3693       open_dump_file (DFI_dbr, decl);
3694
3695       dbr_schedule (insns, rtl_dump_file);
3696
3697       close_dump_file (DFI_dbr, print_rtl, insns);
3698       timevar_pop (TV_DBR_SCHED);
3699
3700       ggc_collect ();
3701     }
3702 #endif
3703
3704 #ifndef STACK_REGS
3705   /* ??? Do this before shorten branches so that we aren't creating
3706      insns too late and fail sanity checks in final. */
3707   convert_to_eh_region_ranges ();
3708 #endif
3709
3710   /* Shorten branches.
3711
3712      Note this must run before reg-stack because of death note (ab)use
3713      in the ia32 backend.  */
3714   timevar_push (TV_SHORTEN_BRANCH);
3715   shorten_branches (get_insns ());
3716   timevar_pop (TV_SHORTEN_BRANCH);
3717
3718 #ifdef STACK_REGS
3719   timevar_push (TV_REG_STACK);
3720   open_dump_file (DFI_stack, decl);
3721
3722   reg_to_stack (insns, rtl_dump_file);
3723
3724   close_dump_file (DFI_stack, print_rtl, insns);
3725   timevar_pop (TV_REG_STACK);
3726
3727   ggc_collect ();
3728
3729   convert_to_eh_region_ranges ();
3730 #endif
3731
3732   current_function_nothrow = nothrow_function_p ();
3733   if (current_function_nothrow)
3734     /* Now we know that this can't throw; set the flag for the benefit
3735        of other functions later in this translation unit.  */
3736     TREE_NOTHROW (current_function_decl) = 1;
3737
3738   /* Now turn the rtl into assembler code.  */
3739
3740   timevar_push (TV_FINAL);
3741   {
3742     rtx x;
3743     const char *fnname;
3744
3745     /* Get the function's name, as described by its RTL.  This may be
3746        different from the DECL_NAME name used in the source file.  */
3747
3748     x = DECL_RTL (decl);
3749     if (GET_CODE (x) != MEM)
3750       abort ();
3751     x = XEXP (x, 0);
3752     if (GET_CODE (x) != SYMBOL_REF)
3753       abort ();
3754     fnname = XSTR (x, 0);
3755
3756     assemble_start_function (decl, fnname);
3757     final_start_function (insns, asm_out_file, optimize);
3758     final (insns, asm_out_file, optimize, 0);
3759     final_end_function (insns, asm_out_file, optimize);
3760     assemble_end_function (decl, fnname);
3761
3762     output_function_exception_table ();
3763
3764     if (! quiet_flag)
3765       fflush (asm_out_file);
3766
3767     /* Release all memory allocated by flow.  */
3768     free_basic_block_vars (0);
3769
3770     /* Release all memory held by regsets now.  */
3771     regset_release_memory ();
3772   }
3773   timevar_pop (TV_FINAL);
3774
3775   ggc_collect ();
3776
3777   /* Write DBX symbols if requested.  */
3778
3779   /* Note that for those inline functions where we don't initially
3780      know for certain that we will be generating an out-of-line copy,
3781      the first invocation of this routine (rest_of_compilation) will
3782      skip over this code by doing a `goto exit_rest_of_compilation;'.
3783      Later on, finish_compilation will call rest_of_compilation again
3784      for those inline functions that need to have out-of-line copies
3785      generated.  During that call, we *will* be routed past here.  */
3786
3787   timevar_push (TV_SYMOUT);
3788 #ifdef DBX_DEBUGGING_INFO
3789   if (write_symbols == DBX_DEBUG)
3790     dbxout_function (decl);
3791 #endif
3792
3793 #ifdef DWARF_DEBUGGING_INFO
3794   if (write_symbols == DWARF_DEBUG)
3795     dwarfout_file_scope_decl (decl, 0);
3796 #endif
3797
3798 #ifdef DWARF2_DEBUGGING_INFO
3799   if (write_symbols == DWARF2_DEBUG)
3800     dwarf2out_decl (decl);
3801 #endif
3802   timevar_pop (TV_SYMOUT);
3803
3804  exit_rest_of_compilation:
3805
3806   /* In case the function was not output,
3807      don't leave any temporary anonymous types
3808      queued up for sdb output.  */
3809 #ifdef SDB_DEBUGGING_INFO
3810   if (write_symbols == SDB_DEBUG)
3811     sdbout_types (NULL_TREE);
3812 #endif
3813
3814   reload_completed = 0;
3815   flow2_completed = 0;
3816   no_new_pseudos = 0;
3817
3818   timevar_push (TV_FINAL);
3819
3820   /* Clear out the insn_length contents now that they are no
3821      longer valid.  */
3822   init_insn_lengths ();
3823
3824   /* Clear out the real_constant_chain before some of the rtx's
3825      it runs through become garbage.  */
3826   clear_const_double_mem ();
3827
3828   /* Show no temporary slots allocated.  */
3829   init_temp_slots ();
3830
3831   free_basic_block_vars (0);
3832
3833   timevar_pop (TV_FINAL);
3834
3835   /* Make sure volatile mem refs aren't considered valid operands for
3836      arithmetic insns.  We must call this here if this is a nested inline
3837      function, since the above code leaves us in the init_recog state
3838      (from final.c), and the function context push/pop code does not
3839      save/restore volatile_ok.
3840
3841      ??? Maybe it isn't necessary for expand_start_function to call this
3842      anymore if we do it here?  */
3843
3844   init_recog_no_volatile ();
3845
3846   /* We're done with this function.  Free up memory if we can.  */
3847   free_after_parsing (cfun);
3848   if (! DECL_DEFER_OUTPUT (decl))
3849     free_after_compilation (cfun);
3850   cfun = 0;
3851
3852   ggc_collect ();
3853
3854   timevar_pop (TV_REST_OF_COMPILATION);
3855 }
3856 \f
3857 static void
3858 display_help ()
3859 {
3860   int undoc;
3861   unsigned long i;
3862   const char *lang;
3863
3864   printf (_("  -ffixed-<register>      Mark <register> as being unavailable to the compiler\n"));
3865   printf (_("  -fcall-used-<register>  Mark <register> as being corrupted by function calls\n"));
3866   printf (_("  -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3867   printf (_("  -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3868   printf (_("  -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line.  0 suppresses line-wrapping\n"));
3869   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"));
3870
3871   for (i = ARRAY_SIZE (f_options); i--;)
3872     {
3873       const char *description = f_options[i].description;
3874
3875       if (description != NULL && * description != 0)
3876         printf ("  -f%-21s %s\n",
3877                 f_options[i].string, description);
3878     }
3879
3880   printf (_("  -O[number]              Set optimisation level to [number]\n"));
3881   printf (_("  -Os                     Optimise for space rather than speed\n"));
3882   printf (_("  --param <name>=<value>  Set constant controlling optimization\n"));
3883   printf (_("  -pedantic               Issue warnings needed by strict compliance to ISO C\n"));
3884   printf (_("  -pedantic-errors        Like -pedantic except that errors are produced\n"));
3885   printf (_("  -w                      Suppress warnings\n"));
3886   printf (_("  -W                      Enable extra warnings\n"));
3887
3888   for (i = ARRAY_SIZE (W_options); i--;)
3889     {
3890       const char *description = W_options[i].description;
3891
3892       if (description != NULL && * description != 0)
3893         printf ("  -W%-21s %s\n",
3894                 W_options[i].string, description);
3895     }
3896
3897   printf (_("  -Wunused                Enable unused warnings\n"));
3898   printf (_("  -Wid-clash-<num>        Warn if 2 identifiers have the same first <num> chars\n"));
3899   printf (_("  -Wlarger-than-<number>  Warn if an object is larger than <number> bytes\n"));
3900   printf (_("  -p                      Enable function profiling\n"));
3901 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3902   printf (_("  -a                      Enable block profiling \n"));
3903 #endif
3904 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3905   printf (_("  -ax                     Enable jump profiling \n"));
3906 #endif
3907   printf (_("  -o <file>               Place output into <file> \n"));
3908   printf (_("\
3909   -G <number>             Put global and static data smaller than <number>\n\
3910                           bytes into a special section (on some targets)\n"));
3911
3912   for (i = ARRAY_SIZE (debug_args); i--;)
3913     {
3914       if (debug_args[i].description != NULL)
3915         printf ("  -g%-21s %s\n",
3916                 debug_args[i].arg, debug_args[i].description);
3917     }
3918
3919   printf (_("  -aux-info <file>        Emit declaration info into <file>.X\n"));
3920   printf (_("  -quiet                  Do not display functions compiled or elapsed time\n"));
3921   printf (_("  -version                Display the compiler's version\n"));
3922   printf (_("  -d[letters]             Enable dumps from specific passes of the compiler\n"));
3923   printf (_("  -dumpbase <file>        Base name to be used for dumps from specific passes\n"));
3924 #if defined INSN_SCHEDULING
3925   printf (_("  -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3926 #endif
3927   printf (_("  --help                  Display this information\n"));
3928
3929   undoc = 0;
3930   lang  = "language";
3931
3932   /* Display descriptions of language specific options.
3933      If there is no description, note that there is an undocumented option.
3934      If the description is empty, do not display anything.  (This allows
3935      options to be deliberately undocumented, for whatever reason).
3936      If the option string is missing, then this is a marker, indicating
3937      that the description string is in fact the name of a language, whose
3938      language specific options are to follow.  */
3939
3940   if (ARRAY_SIZE (documented_lang_options) > 1)
3941     {
3942       printf (_("\nLanguage specific options:\n"));
3943
3944       for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3945         {
3946           const char *description = documented_lang_options[i].description;
3947           const char *option      = documented_lang_options[i].option;
3948
3949           if (description == NULL)
3950             {
3951               undoc = 1;
3952
3953               if (extra_warnings)
3954                 printf (_("  %-23.23s [undocumented]\n"), option);
3955             }
3956           else if (*description == 0)
3957             continue;
3958           else if (option == NULL)
3959             {
3960               if (undoc)
3961                 printf
3962                   (_("\nThere are undocumented %s specific options as well.\n"),
3963                         lang);
3964               undoc = 0;
3965
3966               printf (_("\n Options for %s:\n"), description);
3967
3968               lang = description;
3969             }
3970           else
3971             printf ("  %-23.23s %s\n", option, description);
3972         }
3973     }
3974
3975   if (undoc)
3976     printf (_("\nThere are undocumented %s specific options as well.\n"),
3977             lang);
3978
3979   display_target_options ();
3980 }
3981
3982 static void
3983 display_target_options ()
3984 {
3985   int undoc,i;
3986
3987   if (ARRAY_SIZE (target_switches) > 1
3988 #ifdef TARGET_OPTIONS
3989       || ARRAY_SIZE (target_options) > 1
3990 #endif
3991       )
3992     {
3993       int doc = 0;
3994
3995       undoc = 0;
3996
3997       printf (_("\nTarget specific options:\n"));
3998
3999       for (i = ARRAY_SIZE (target_switches); i--;)
4000         {
4001           const char *option      = target_switches[i].name;
4002           const char *description = target_switches[i].description;
4003
4004           if (option == NULL || *option == 0)
4005             continue;
4006           else if (description == NULL)
4007             {
4008               undoc = 1;
4009
4010               if (extra_warnings)
4011                 printf (_("  -m%-23.23s [undocumented]\n"), option);
4012             }
4013           else if (* description != 0)
4014             doc += printf ("  -m%-23.23s %s\n", option, description);
4015         }
4016
4017 #ifdef TARGET_OPTIONS
4018       for (i = ARRAY_SIZE (target_options); i--;)
4019         {
4020           const char *option      = target_options[i].prefix;
4021           const char *description = target_options[i].description;
4022
4023           if (option == NULL || *option == 0)
4024             continue;
4025           else if (description == NULL)
4026             {
4027               undoc = 1;
4028
4029               if (extra_warnings)
4030                 printf (_("  -m%-23.23s [undocumented]\n"), option);
4031             }
4032           else if (* description != 0)
4033             doc += printf ("  -m%-23.23s %s\n", option, description);
4034         }
4035 #endif
4036       if (undoc)
4037         {
4038           if (doc)
4039             printf (_("\nThere are undocumented target specific options as well.\n"));
4040           else
4041             printf (_("  They exist, but they are not documented.\n"));
4042         }
4043     }
4044 }
4045 \f
4046 /* Parse a -d... comand line switch.  */
4047
4048 static void
4049 decode_d_option (arg)
4050      const char *arg;
4051 {
4052   int i, c, matched;
4053
4054   while (*arg)
4055     switch (c = *arg++)
4056       {
4057       case 'a':
4058         for (i = 0; i < (int) DFI_MAX; ++i)
4059           dump_file[i].enabled = 1;
4060         break;
4061       case 'A':
4062         flag_debug_asm = 1;
4063         break;
4064       case 'm':
4065         flag_print_mem = 1;
4066         break;
4067       case 'p':
4068         flag_print_asm_name = 1;
4069         break;
4070       case 'P':
4071         flag_dump_rtl_in_asm = 1;
4072         flag_print_asm_name = 1;
4073         break;
4074       case 'v':
4075         graph_dump_format = vcg;
4076         break;
4077       case 'x':
4078         rtl_dump_and_exit = 1;
4079         break;
4080       case 'y':
4081         set_yydebug (1);
4082         break;
4083       case 'D': /* These are handled by the preprocessor.  */
4084       case 'I':
4085         break;
4086
4087       default:
4088         matched = 0;
4089         for (i = 0; i < (int) DFI_MAX; ++i)
4090           if (c == dump_file[i].debug_switch)
4091             {
4092               dump_file[i].enabled = 1;
4093               matched = 1;
4094             }
4095
4096         if (! matched)
4097           warning ("unrecognized gcc debugging option: %c", c);
4098         break;
4099       }
4100 }
4101
4102 /* Parse a -f... comand line switch.  ARG is the value after the -f.
4103    It is safe to access 'ARG - 2' to generate the full switch name.
4104    Return the number of strings consumed.  */
4105
4106 static int
4107 decode_f_option (arg)
4108      const char *arg;
4109 {
4110   int j;
4111   const char *option_value = NULL;
4112
4113   /* Search for the option in the table of binary f options.  */
4114   for (j = ARRAY_SIZE (f_options); j--;)
4115     {
4116       if (!strcmp (arg, f_options[j].string))
4117         {
4118           *f_options[j].variable = f_options[j].on_value;
4119           return 1;
4120         }
4121
4122       if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4123           && ! strcmp (arg + 3, f_options[j].string))
4124         {
4125           *f_options[j].variable = ! f_options[j].on_value;
4126           return 1;
4127         }
4128     }
4129
4130   if (!strcmp (arg, "fast-math"))
4131     set_fast_math_flags();
4132   else if (!strcmp (arg, "no-fast-math"))
4133     set_no_fast_math_flags();
4134   else if ((option_value = skip_leading_substring (arg, "inline-limit-"))
4135            || (option_value = skip_leading_substring (arg, "inline-limit=")))
4136     {
4137       int val = 
4138         read_integral_parameter (option_value, arg - 2,
4139                                  MAX_INLINE_INSNS);
4140       set_param_value ("max-inline-insns", val);
4141     }
4142 #ifdef INSN_SCHEDULING
4143   else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
4144     fix_sched_param ("verbose", option_value);
4145 #endif
4146   else if ((option_value = skip_leading_substring (arg, "fixed-")))
4147     fix_register (option_value, 1, 1);
4148   else if ((option_value = skip_leading_substring (arg, "call-used-")))
4149     fix_register (option_value, 0, 1);
4150   else if ((option_value = skip_leading_substring (arg, "call-saved-")))
4151     fix_register (option_value, 0, 0);
4152   else if ((option_value = skip_leading_substring (arg, "align-loops=")))
4153     align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
4154   else if ((option_value = skip_leading_substring (arg, "align-functions=")))
4155     align_functions
4156       = read_integral_parameter (option_value, arg - 2, align_functions);
4157   else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
4158     align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
4159   else if ((option_value = skip_leading_substring (arg, "align-labels=")))
4160     align_labels
4161       = read_integral_parameter (option_value, arg - 2, align_labels);
4162   else if ((option_value
4163             = skip_leading_substring (arg, "stack-limit-register=")))
4164     {
4165       int reg = decode_reg_name (option_value);
4166       if (reg < 0)
4167         error ("unrecognized register name `%s'", option_value);
4168       else
4169         stack_limit_rtx = gen_rtx_REG (Pmode, reg);
4170     }
4171   else if ((option_value
4172             = skip_leading_substring (arg, "stack-limit-symbol=")))
4173     {
4174       const char *nm;
4175       nm = ggc_strdup (option_value);
4176       stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
4177     }
4178   else if ((option_value
4179             = skip_leading_substring (arg, "message-length=")))
4180     diagnostic_message_length_per_line =
4181       read_integral_parameter (option_value, arg - 2,
4182                                diagnostic_message_length_per_line);
4183   else if ((option_value
4184             = skip_leading_substring (arg, "diagnostics-show-location=")))
4185     {
4186       if (!strcmp (option_value, "once"))
4187         set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
4188       else if (!strcmp (option_value, "every-line"))
4189         set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE);
4190       else
4191         error ("Unrecognized option `%s'", arg - 2);
4192     }
4193   else if (!strcmp (arg, "no-stack-limit"))
4194     stack_limit_rtx = NULL_RTX;
4195   else if (!strcmp (arg, "preprocessed"))
4196     /* Recognise this switch but do nothing.  This prevents warnings
4197        about an unrecognized switch if cpplib has not been linked in.  */
4198     ;
4199   else
4200     return 0;
4201
4202   return 1;
4203 }
4204
4205 /* Parse a -W... comand line switch.  ARG is the value after the -W.
4206    It is safe to access 'ARG - 2' to generate the full switch name.
4207    Return the number of strings consumed.  */
4208
4209 static int
4210 decode_W_option (arg)
4211      const char *arg;
4212 {
4213   const char *option_value = NULL;
4214   int j;
4215
4216   /* Search for the option in the table of binary W options.  */
4217
4218   for (j = ARRAY_SIZE (W_options); j--;)
4219     {
4220       if (!strcmp (arg, W_options[j].string))
4221         {
4222           *W_options[j].variable = W_options[j].on_value;
4223           return 1;
4224         }
4225
4226       if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4227           && ! strcmp (arg + 3, W_options[j].string))
4228         {
4229           *W_options[j].variable = ! W_options[j].on_value;
4230           return 1;
4231         }
4232     }
4233
4234   if ((option_value = skip_leading_substring (arg, "id-clash-")))
4235     {
4236       id_clash_len = read_integral_parameter (option_value, arg - 2, -1);
4237
4238       if (id_clash_len != -1)
4239         warn_id_clash = 1;
4240     }
4241   else if ((option_value = skip_leading_substring (arg, "larger-than-")))
4242     {
4243       larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
4244
4245       warn_larger_than = larger_than_size != -1;
4246     }
4247   else if (!strcmp (arg, "unused"))
4248     {
4249       set_Wunused (1);
4250     }
4251   else if (!strcmp (arg, "no-unused"))
4252     {
4253       set_Wunused (0);
4254     }
4255   else
4256     return 0;
4257
4258   return 1;
4259 }
4260
4261 /* Parse a -g... comand line switch.  ARG is the value after the -g.
4262    It is safe to access 'ARG - 2' to generate the full switch name.
4263    Return the number of strings consumed.  */
4264
4265 static int
4266 decode_g_option (arg)
4267      const char *arg;
4268 {
4269   unsigned level;
4270   /* A lot of code assumes write_symbols == NO_DEBUG if the
4271      debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4272      of what debugging type has been selected).  This records the
4273      selected type.  It is an error to specify more than one
4274      debugging type.  */
4275   static enum debug_info_type selected_debug_type = NO_DEBUG;
4276   /* Non-zero if debugging format has been explicitly set.
4277      -g and -ggdb don't explicitly set the debugging format so
4278      -gdwarf -g3 is equivalent to -gdwarf3.  */
4279   static int type_explicitly_set_p = 0;
4280   /* Indexed by enum debug_info_type.  */
4281   static const char *debug_type_names[] =
4282   {
4283     "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4284   };
4285
4286   /* The maximum admissible debug level value.  */
4287   static const unsigned max_debug_level = 3;
4288
4289   /* Look up ARG in the table.  */
4290   for (da = debug_args; da->arg; da++)
4291     {
4292       const int da_len = strlen (da->arg);
4293
4294       if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4295         {
4296           enum debug_info_type type = da->debug_type;
4297           const char *p = arg + da_len;
4298
4299           if (*p && (*p < '0' || *p > '9'))
4300             continue;
4301
4302           /* A debug flag without a level defaults to level 2.
4303              Note we do not want to call read_integral_parameter
4304              for that case since it will call atoi which
4305              will return zero.
4306
4307              ??? We may want to generalize the interface to
4308              read_integral_parameter to better handle this case
4309              if this case shows up often.  */
4310           if (*p)
4311             level = read_integral_parameter (p, 0, max_debug_level + 1);
4312           else
4313             level = 2;
4314
4315           if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4316             {
4317               error ("use -gdwarf -g%d for DWARF v1, level %d",
4318                      level, level);
4319               if (level == 2)
4320                 error ("use -gdwarf-2   for DWARF v2");
4321             }
4322
4323           if (level > max_debug_level)
4324             {
4325               warning ("\
4326 ignoring option `%s' due to invalid debug level specification",
4327                        arg - 2);
4328               level = debug_info_level;
4329             }
4330
4331           if (type == NO_DEBUG)
4332             {
4333               type = PREFERRED_DEBUGGING_TYPE;
4334
4335               if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4336                 {
4337 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4338                   type = DWARF2_DEBUG;
4339 #else
4340 #ifdef DBX_DEBUGGING_INFO
4341                   type = DBX_DEBUG;
4342 #endif
4343 #endif
4344                 }
4345             }
4346
4347           if (type == NO_DEBUG)
4348             warning ("`%s': unknown or unsupported -g option", arg - 2);
4349
4350           /* Does it conflict with an already selected type?  */
4351           if (type_explicitly_set_p
4352               /* -g/-ggdb don't conflict with anything.  */
4353               && da->debug_type != NO_DEBUG
4354               && type != selected_debug_type)
4355             warning ("`%s' ignored, conflicts with `-g%s'",
4356                      arg - 2, debug_type_names[(int) selected_debug_type]);
4357           else
4358             {
4359               /* If the format has already been set, -g/-ggdb
4360                  only change the debug level.  */
4361               if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4362                 /* Don't change debugging type.  */
4363                 ;
4364               else
4365                 {
4366                   selected_debug_type = type;
4367                   type_explicitly_set_p = da->debug_type != NO_DEBUG;
4368                 }
4369
4370               write_symbols = (level == 0
4371                                ? NO_DEBUG
4372                                : selected_debug_type);
4373               use_gnu_debug_info_extensions = da->use_extensions_p;
4374               debug_info_level = (enum debug_info_level) level;
4375             }
4376
4377           break;
4378         }
4379     }
4380
4381   if (! da->arg)
4382     return 0;
4383
4384   return 1;
4385 }
4386
4387 /* Decode the first argument in the argv as a language-independent option.
4388    Return the number of strings consumed.  */
4389
4390 static unsigned int
4391 independent_decode_option (argc, argv)
4392      int argc;
4393      char **argv;
4394 {
4395   char *arg = argv[0];
4396
4397   if (arg[0] != '-' || arg[1] == 0)
4398     {
4399       if (arg[0] == '+')
4400         return 0;
4401
4402       filename = arg;
4403
4404       return 1;
4405     }
4406
4407   arg++;
4408
4409   if (!strcmp (arg, "-help"))
4410     {
4411       display_help ();
4412       exit_after_options = 1;
4413     }
4414
4415   if (!strcmp (arg, "-target-help"))
4416     {
4417       display_target_options ();
4418       exit_after_options = 1;
4419     }
4420
4421   if (!strcmp (arg, "-version"))
4422     {
4423       print_version (stderr, "");
4424       exit_after_options = 1;
4425     }
4426
4427   /* Handle '--param <name>=<value>'.  */
4428   if (strcmp (arg, "-param") == 0)
4429     {
4430       char *equal;
4431
4432       if (argc == 1)
4433         {
4434           error ("-param option missing argument");
4435           return 1;
4436         }
4437
4438       /* Get the '<name>=<value>' parameter.  */
4439       arg = argv[1];
4440       /* Look for the `='.  */
4441       equal = strchr (arg, '=');
4442       if (!equal) 
4443         error ("invalid --param option: %s", arg);
4444       else 
4445         {
4446           int val;
4447
4448           /* Zero out the `=' sign so that we get two separate strings.  */
4449           *equal = '\0';
4450           /* Figure out what value is specified.  */
4451           val = read_integral_parameter (equal + 1, NULL, INVALID_PARAM_VAL);
4452           if (val != INVALID_PARAM_VAL)
4453             set_param_value (arg, val);
4454           else
4455             error ("invalid parameter value `%s'", equal + 1);
4456         }
4457
4458       return 2;
4459     }
4460       
4461   if (*arg == 'Y')
4462     arg++;
4463
4464   switch (*arg)
4465     {
4466     default:
4467       return 0;
4468
4469     case 'O':
4470       /* Already been treated in main (). Do nothing.  */
4471       break;
4472
4473     case 'm':
4474       set_target_switch (arg + 1);
4475       break;
4476
4477     case 'f':
4478       return decode_f_option (arg + 1);
4479
4480     case 'g':
4481       return decode_g_option (arg + 1);
4482
4483     case 'd':
4484       if (!strcmp (arg, "dumpbase"))
4485         {
4486           if (argc == 1)
4487             return 0;
4488
4489           dump_base_name = argv[1];
4490           return 2;
4491         }
4492       else
4493         decode_d_option (arg + 1);
4494       break;
4495
4496     case 'p':
4497       if (!strcmp (arg, "pedantic"))
4498         pedantic = 1;
4499       else if (!strcmp (arg, "pedantic-errors"))
4500         flag_pedantic_errors = pedantic = 1;
4501       else if (arg[1] == 0)
4502         profile_flag = 1;
4503       else
4504         return 0;
4505       break;
4506
4507     case 'q':
4508       if (!strcmp (arg, "quiet"))
4509         quiet_flag = 1;
4510       else
4511         return 0;
4512       break;
4513
4514     case 'v':
4515       if (!strcmp (arg, "version"))
4516         version_flag = 1;
4517       else
4518         return 0;
4519       break;
4520
4521     case 'w':
4522       if (arg[1] == 0)
4523         inhibit_warnings = 1;
4524       else
4525         return 0;
4526       break;
4527
4528     case 'W':
4529       if (arg[1] == 0)
4530         {
4531           extra_warnings = 1;
4532           /* We save the value of warn_uninitialized, since if they put
4533              -Wuninitialized on the command line, we need to generate a
4534              warning about not using it without also specifying -O.  */
4535           if (warn_uninitialized != 1)
4536             warn_uninitialized = 2;
4537         }
4538       else
4539         return decode_W_option (arg + 1);
4540       break;
4541
4542     case 'a':
4543       if (arg[1] == 0)
4544         {
4545 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4546           warning ("`-a' option (basic block profile) not supported");
4547 #else
4548           profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4549 #endif
4550         }
4551       else if (!strcmp (arg, "ax"))
4552         {
4553 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4554           warning ("`-ax' option (jump profiling) not supported");
4555 #else
4556           profile_block_flag = (!profile_block_flag
4557                                 || profile_block_flag == 2) ? 2 : 3;
4558 #endif
4559         }
4560       else if (!strncmp (arg, "aux-info", 8))
4561         {
4562           flag_gen_aux_info = 1;
4563           if (arg[8] == '\0')
4564             {
4565               if (argc == 1)
4566                 return 0;
4567
4568               aux_info_file_name = argv[1];
4569               return 2;
4570             }
4571           else
4572             aux_info_file_name = arg + 8;
4573         }
4574       else
4575         return 0;
4576       break;
4577
4578     case 'o':
4579       if (arg[1] == 0)
4580         {
4581           if (argc == 1)
4582             return 0;
4583
4584           asm_file_name = argv[1];
4585           return 2;
4586         }
4587       return 0;
4588
4589     case 'G':
4590       {
4591         int g_switch_val;
4592         int return_val;
4593
4594         if (arg[1] == 0)
4595           {
4596             if (argc == 1)
4597               return 0;
4598
4599             g_switch_val = read_integral_parameter (argv[1], 0, -1);
4600             return_val = 2;
4601           }
4602         else
4603           {
4604             g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4605             return_val = 1;
4606           }
4607
4608         if (g_switch_val == -1)
4609           return_val = 0;
4610         else
4611           {
4612             g_switch_set = TRUE;
4613             g_switch_value = g_switch_val;
4614           }
4615
4616         return return_val;
4617       }
4618     }
4619
4620   return 1;
4621 }
4622 \f
4623 /* Entry point of cc1, cc1plus, jc1, f771, etc.
4624    Decode command args, then call compile_file.
4625    Exit code is FATAL_EXIT_CODE if can't open files or if there were
4626    any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
4627    
4628    It is not safe to call this function more than once.  */
4629
4630 int
4631 toplev_main (argc, argv)
4632      int argc;
4633      char **argv;
4634 {
4635   register int i;
4636   char *p;
4637
4638   /* save in case md file wants to emit args as a comment.  */
4639   save_argc = argc;
4640   save_argv = argv;
4641
4642   p = argv[0] + strlen (argv[0]);
4643   while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
4644     --p;
4645   progname = p;
4646
4647   xmalloc_set_program_name (progname);
4648
4649 /* LC_CTYPE determines the character set used by the terminal so it has be set
4650    to output messages correctly.  */
4651
4652 #ifdef HAVE_LC_MESSAGES
4653   setlocale (LC_CTYPE, "");
4654   setlocale (LC_MESSAGES, "");
4655 #else
4656   setlocale (LC_ALL, "");
4657 #endif
4658
4659   (void) bindtextdomain (PACKAGE, localedir);
4660   (void) textdomain (PACKAGE);
4661
4662   /* Install handler for SIGFPE, which may be received while we do
4663      compile-time floating point arithmetic.  */
4664   signal (SIGFPE, float_signal);
4665
4666   /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages.  */
4667 #ifdef SIGSEGV
4668   signal (SIGSEGV, crash_signal);
4669 #endif
4670 #ifdef SIGILL
4671   signal (SIGILL, crash_signal);
4672 #endif
4673 #ifdef SIGBUS
4674   signal (SIGBUS, crash_signal);
4675 #endif
4676 #ifdef SIGABRT
4677   signal (SIGABRT, crash_signal);
4678 #endif
4679 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4680   signal (SIGIOT, crash_signal);
4681 #endif
4682
4683   decl_printable_name = decl_name;
4684   lang_expand_expr = (lang_expand_expr_t) do_abort;
4685
4686   /* Initialize whether `char' is signed.  */
4687   flag_signed_char = DEFAULT_SIGNED_CHAR;
4688 #ifdef DEFAULT_SHORT_ENUMS
4689   /* Initialize how much space enums occupy, by default.  */
4690   flag_short_enums = DEFAULT_SHORT_ENUMS;
4691 #endif
4692
4693   /* Initialize the garbage-collector.  */
4694   init_ggc ();
4695   init_stringpool ();
4696   ggc_add_rtx_root (&stack_limit_rtx, 1);
4697   ggc_add_tree_root (&current_function_decl, 1);
4698   ggc_add_tree_root (&current_function_func_begin_label, 1);
4699
4700   /* Initialize the diagnostics reporting machinery.  */
4701   initialize_diagnostics ();
4702
4703   /* Register the language-independent parameters.  */
4704   add_params (lang_independent_params, LAST_PARAM);
4705
4706   /* Perform language-specific options intialization.  */
4707   if (lang_hooks.init_options)
4708     (*lang_hooks.init_options) ();
4709
4710   /* Scan to see what optimization level has been specified.  That will
4711      determine the default value of many flags.  */
4712   for (i = 1; i < argc; i++)
4713     {
4714       if (!strcmp (argv[i], "-O"))
4715         {
4716           optimize = 1;
4717           optimize_size = 0;
4718         }
4719       else if (argv[i][0] == '-' && argv[i][1] == 'O')
4720         {
4721           /* Handle -Os, -O2, -O3, -O69, ...  */
4722           char *p = &argv[i][2];
4723
4724           if ((p[0] == 's') && (p[1] == 0))
4725             {
4726               optimize_size = 1;
4727
4728               /* Optimizing for size forces optimize to be 2.  */
4729               optimize = 2;
4730             }
4731           else
4732             {
4733               const int optimize_val = read_integral_parameter (p, p - 2, -1);
4734               if (optimize_val != -1)
4735                 {
4736                   optimize = optimize_val;
4737                   optimize_size = 0;
4738                 }
4739             }
4740         }
4741     }
4742
4743   if (optimize >= 1)
4744     {
4745       flag_defer_pop = 1;
4746       flag_thread_jumps = 1;
4747 #ifdef DELAY_SLOTS
4748       flag_delayed_branch = 1;
4749 #endif
4750 #ifdef CAN_DEBUG_WITHOUT_FP
4751       flag_omit_frame_pointer = 1;
4752 #endif
4753       flag_guess_branch_prob = 1;
4754     }
4755
4756   if (optimize >= 2)
4757     {
4758       flag_optimize_sibling_calls = 1;
4759       flag_cse_follow_jumps = 1;
4760       flag_cse_skip_blocks = 1;
4761       flag_gcse = 1;
4762       flag_expensive_optimizations = 1;
4763       flag_strength_reduce = 1;
4764       flag_rerun_cse_after_loop = 1;
4765       flag_rerun_loop_opt = 1;
4766       flag_caller_saves = 1;
4767       flag_force_mem = 1;
4768       flag_peephole2 = 1;
4769 #ifdef INSN_SCHEDULING
4770       flag_schedule_insns = 1;
4771       flag_schedule_insns_after_reload = 1;
4772 #endif
4773       flag_regmove = 1;
4774       flag_strict_aliasing = 1;
4775       flag_delete_null_pointer_checks = 1;
4776       flag_reorder_blocks = 1;
4777     }
4778
4779   if (optimize >= 3)
4780     {
4781       flag_inline_functions = 1;
4782       flag_rename_registers = 1;
4783     }
4784
4785   if (optimize < 2 || optimize_size)
4786     {
4787       align_loops = 1;
4788       align_jumps = 1;
4789       align_labels = 1;
4790       align_functions = 1;
4791     }
4792
4793   /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4794      modify it.  */
4795   target_flags = 0;
4796   set_target_switch ("");
4797
4798   /* Unwind tables are always present in an ABI-conformant IA-64
4799      object file, so the default should be ON.  */
4800 #ifdef IA64_UNWIND_INFO
4801   flag_unwind_tables = IA64_UNWIND_INFO;
4802 #endif
4803
4804 #ifdef OPTIMIZATION_OPTIONS
4805   /* Allow default optimizations to be specified on a per-machine basis.  */
4806   OPTIMIZATION_OPTIONS (optimize, optimize_size);
4807 #endif
4808
4809   /* Initialize register usage now so switches may override.  */
4810   init_reg_sets ();
4811
4812   /* Perform normal command line switch decoding.  */
4813   for (i = 1; i < argc;)
4814     {
4815       unsigned int lang_processed;
4816       unsigned int indep_processed;
4817
4818       /* Give the language a chance to decode the option for itself.  */
4819       lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
4820
4821       /* Now see if the option also has a language independent meaning.
4822          Some options are both language specific and language independent,
4823          eg --help.  */
4824       indep_processed = independent_decode_option (argc - i, argv + i);
4825
4826       if (lang_processed || indep_processed)
4827         i += MAX (lang_processed, indep_processed);
4828       else
4829         {
4830           const char *option = NULL;
4831           const char *lang = NULL;
4832           unsigned int j;
4833
4834           /* It is possible that the command line switch is not valid for the
4835              current language, but it is valid for another language.  In order
4836              to be compatible with previous versions of the compiler (which
4837              did not issue an error message in this case) we check for this
4838              possibility here.  If we do find a match, then if extra_warnings
4839              is set we generate a warning message, otherwise we will just
4840              ignore the option.  */
4841           for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4842             {
4843               option = documented_lang_options[j].option;
4844
4845               if (option == NULL)
4846                 lang = documented_lang_options[j].description;
4847               else if (! strncmp (argv[i], option, strlen (option)))
4848                 break;
4849             }
4850
4851           if (j != ARRAY_SIZE (documented_lang_options))
4852             {
4853               if (extra_warnings)
4854                 {
4855                   warning ("Ignoring command line option '%s'", argv[i]);
4856                   if (lang)
4857                     warning
4858                       ("(It is valid for %s but not the selected language)",
4859                        lang);
4860                 }
4861             }
4862           else if (argv[i][0] == '-' && argv[i][1] == 'g')
4863             warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
4864           else
4865             error ("Unrecognized option `%s'", argv[i]);
4866
4867           i++;
4868         }
4869     }
4870
4871   /* All command line options have been processed.  */
4872   if (lang_hooks.post_options)
4873     (*lang_hooks.post_options) ();
4874
4875   if (exit_after_options)
4876     exit (0);
4877
4878   /* Reflect any language-specific diagnostic option setting.  */
4879   reshape_diagnostic_buffer ();
4880
4881   /* Checker uses the frame pointer.  */
4882   if (flag_check_memory_usage)
4883     flag_omit_frame_pointer = 0;
4884
4885   if (optimize == 0)
4886     {
4887       /* Inlining does not work if not optimizing,
4888          so force it not to be done.  */
4889       flag_no_inline = 1;
4890       warn_inline = 0;
4891
4892       /* The c_decode_option function and decode_option hook set
4893          this to `2' if -Wall is used, so we can avoid giving out
4894          lots of errors for people who don't realize what -Wall does.  */
4895       if (warn_uninitialized == 1)
4896         warning ("-Wuninitialized is not supported without -O");
4897     }
4898
4899 #ifdef OVERRIDE_OPTIONS
4900   /* Some machines may reject certain combinations of options.  */
4901   OVERRIDE_OPTIONS;
4902 #endif
4903
4904   /* Set up the align_*_log variables, defaulting them to 1 if they
4905      were still unset.  */
4906   if (align_loops <= 0) align_loops = 1;
4907   align_loops_log = floor_log2 (align_loops * 2 - 1);
4908   if (align_jumps <= 0) align_jumps = 1;
4909   align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4910   if (align_labels <= 0) align_labels = 1;
4911   align_labels_log = floor_log2 (align_labels * 2 - 1);
4912   if (align_functions <= 0) align_functions = 1;
4913   align_functions_log = floor_log2 (align_functions * 2 - 1);
4914
4915   if (profile_block_flag == 3)
4916     {
4917       warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4918       profile_block_flag = 2;
4919     }
4920
4921   /* Unrolling all loops implies that standard loop unrolling must also
4922      be done.  */
4923   if (flag_unroll_all_loops)
4924     flag_unroll_loops = 1;
4925   /* Loop unrolling requires that strength_reduction be on also.  Silently
4926      turn on strength reduction here if it isn't already on.  Also, the loop
4927      unrolling code assumes that cse will be run after loop, so that must
4928      be turned on also.  */
4929   if (flag_unroll_loops)
4930     {
4931       flag_strength_reduce = 1;
4932       flag_rerun_cse_after_loop = 1;
4933     }
4934
4935   /* Warn about options that are not supported on this machine.  */
4936 #ifndef INSN_SCHEDULING
4937   if (flag_schedule_insns || flag_schedule_insns_after_reload)
4938     warning ("instruction scheduling not supported on this target machine");
4939 #endif
4940 #ifndef DELAY_SLOTS
4941   if (flag_delayed_branch)
4942     warning ("this target machine does not have delayed branches");
4943 #endif
4944
4945   user_label_prefix = USER_LABEL_PREFIX;
4946   if (flag_leading_underscore != -1)
4947     {
4948       /* If the default prefix is more complicated than "" or "_",
4949          issue a warning and ignore this option.  */
4950       if (user_label_prefix[0] == 0 ||
4951           (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4952         {
4953           user_label_prefix = flag_leading_underscore ? "_" : "";
4954         }
4955       else
4956         warning ("-f%sleading-underscore not supported on this target machine",
4957                  flag_leading_underscore ? "" : "no-");
4958     }
4959
4960   /* If we are in verbose mode, write out the version and maybe all the
4961      option flags in use.  */
4962   if (version_flag)
4963     {
4964       print_version (stderr, "");
4965       if (! quiet_flag)
4966         print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4967     }
4968
4969   compile_file (filename);
4970
4971 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
4972   if (flag_print_mem)
4973     {
4974       char *lim = (char *) sbrk (0);
4975
4976       fnotice (stderr, "Data size %ld.\n", (long) (lim - (char *) &environ));
4977       fflush (stderr);
4978
4979 #ifndef __MSDOS__
4980 #ifdef USG
4981       system ("ps -l 1>&2");
4982 #else /* not USG  */
4983       system ("ps v");
4984 #endif /* not USG  */
4985 #endif
4986     }
4987 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX  */
4988
4989   if (errorcount)
4990     return (FATAL_EXIT_CODE);
4991   if (sorrycount)
4992     return (FATAL_EXIT_CODE);
4993   return (SUCCESS_EXIT_CODE);
4994 }
4995 \f
4996 /* Decode -m switches.  */
4997 /* Decode the switch -mNAME.  */
4998
4999 static void
5000 set_target_switch (name)
5001      const char *name;
5002 {
5003   register size_t j;
5004   int valid_target_option = 0;
5005
5006   for (j = 0; j < ARRAY_SIZE (target_switches); j++)
5007     if (!strcmp (target_switches[j].name, name))
5008       {
5009         if (target_switches[j].value < 0)
5010           target_flags &= ~-target_switches[j].value;
5011         else
5012           target_flags |= target_switches[j].value;
5013         valid_target_option = 1;
5014       }
5015
5016 #ifdef TARGET_OPTIONS
5017   if (!valid_target_option)
5018     for (j = 0; j < ARRAY_SIZE (target_options); j++)
5019       {
5020         int len = strlen (target_options[j].prefix);
5021         if (!strncmp (target_options[j].prefix, name, len))
5022           {
5023             *target_options[j].variable = name + len;
5024             valid_target_option = 1;
5025           }
5026       }
5027 #endif
5028
5029   if (!valid_target_option)
5030     error ("Invalid option `%s'", name);
5031 }
5032 \f
5033 /* Print version information to FILE.
5034    Each line begins with INDENT (for the case where FILE is the
5035    assembler output file).  */
5036
5037 static void
5038 print_version (file, indent)
5039      FILE *file;
5040      const char *indent;
5041 {
5042 #ifndef __VERSION__
5043 #define __VERSION__ "[?]"
5044 #endif
5045   fnotice (file,
5046 #ifdef __GNUC__
5047            "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
5048 #else
5049            "%s%s%s version %s (%s) compiled by CC.\n"
5050 #endif
5051            , indent, *indent != 0 ? " " : "",
5052            language_string, version_string, TARGET_NAME,
5053            indent, __VERSION__);
5054 }
5055
5056 /* Print an option value and return the adjusted position in the line.
5057    ??? We don't handle error returns from fprintf (disk full); presumably
5058    other code will catch a disk full though.  */
5059
5060 static int
5061 print_single_switch (file, pos, max, indent, sep, term, type, name)
5062      FILE *file;
5063      int pos, max;
5064      const char *indent, *sep, *term, *type, *name;
5065 {
5066   /* The ultrix fprintf returns 0 on success, so compute the result we want
5067      here since we need it for the following test.  */
5068   int len = strlen (sep) + strlen (type) + strlen (name);
5069
5070   if (pos != 0
5071       && pos + len > max)
5072     {
5073       fprintf (file, "%s", term);
5074       pos = 0;
5075     }
5076   if (pos == 0)
5077     {
5078       fprintf (file, "%s", indent);
5079       pos = strlen (indent);
5080     }
5081   fprintf (file, "%s%s%s", sep, type, name);
5082   pos += len;
5083   return pos;
5084 }
5085
5086 /* Print active target switches to FILE.
5087    POS is the current cursor position and MAX is the size of a "line".
5088    Each line begins with INDENT and ends with TERM.
5089    Each switch is separated from the next by SEP.  */
5090
5091 static void
5092 print_switch_values (file, pos, max, indent, sep, term)
5093      FILE *file;
5094      int pos, max;
5095      const char *indent, *sep, *term;
5096 {
5097   size_t j;
5098   char **p;
5099
5100   /* Print the options as passed.  */
5101
5102   pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5103                              _("options passed: "), "");
5104
5105   for (p = &save_argv[1]; *p != NULL; p++)
5106     if (**p == '-')
5107       {
5108         /* Ignore these.  */
5109         if (strcmp (*p, "-o") == 0)
5110           {
5111             if (p[1] != NULL)
5112               p++;
5113             continue;
5114           }
5115         if (strcmp (*p, "-quiet") == 0)
5116           continue;
5117         if (strcmp (*p, "-version") == 0)
5118           continue;
5119         if ((*p)[1] == 'd')
5120           continue;
5121
5122         pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5123       }
5124   if (pos > 0)
5125     fprintf (file, "%s", term);
5126
5127   /* Print the -f and -m options that have been enabled.
5128      We don't handle language specific options but printing argv
5129      should suffice.  */
5130
5131   pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5132                              _("options enabled: "), "");
5133
5134   for (j = 0; j < ARRAY_SIZE (f_options); j++)
5135     if (*f_options[j].variable == f_options[j].on_value)
5136       pos = print_single_switch (file, pos, max, indent, sep, term,
5137                                  "-f", f_options[j].string);
5138
5139   /* Print target specific options.  */
5140
5141   for (j = 0; j < ARRAY_SIZE (target_switches); j++)
5142     if (target_switches[j].name[0] != '\0'
5143         && target_switches[j].value > 0
5144         && ((target_switches[j].value & target_flags)
5145             == target_switches[j].value))
5146       {
5147         pos = print_single_switch (file, pos, max, indent, sep, term,
5148                                    "-m", target_switches[j].name);
5149       }
5150
5151 #ifdef TARGET_OPTIONS
5152   for (j = 0; j < ARRAY_SIZE (target_options); j++)
5153     if (*target_options[j].variable != NULL)
5154       {
5155         char prefix[256];
5156         sprintf (prefix, "-m%s", target_options[j].prefix);
5157         pos = print_single_switch (file, pos, max, indent, sep, term,
5158                                    prefix, *target_options[j].variable);
5159       }
5160 #endif
5161
5162   fprintf (file, "%s", term);
5163 }
5164
5165 /* Record the beginning of a new source file, named FILENAME.  */
5166
5167 void
5168 debug_start_source_file (filename)
5169      register const char *filename ATTRIBUTE_UNUSED;
5170 {
5171 #ifdef DBX_DEBUGGING_INFO
5172   if (write_symbols == DBX_DEBUG)
5173     dbxout_start_new_source_file (filename);
5174 #endif
5175 #ifdef DWARF_DEBUGGING_INFO
5176   if (debug_info_level == DINFO_LEVEL_VERBOSE
5177       && write_symbols == DWARF_DEBUG)
5178     dwarfout_start_new_source_file (filename);
5179 #endif /* DWARF_DEBUGGING_INFO  */
5180 #ifdef DWARF2_DEBUGGING_INFO
5181   if (write_symbols == DWARF2_DEBUG)
5182     dwarf2out_start_source_file (filename);
5183 #endif /* DWARF2_DEBUGGING_INFO  */
5184 #ifdef SDB_DEBUGGING_INFO
5185   if (write_symbols == SDB_DEBUG)
5186     sdbout_start_new_source_file (filename);
5187 #endif
5188 }
5189
5190 /* Record the resumption of a source file.  LINENO is the line number in
5191    the source file we are returning to.  */
5192
5193 void
5194 debug_end_source_file (lineno)
5195      register unsigned lineno ATTRIBUTE_UNUSED;
5196 {
5197 #ifdef DBX_DEBUGGING_INFO
5198   if (write_symbols == DBX_DEBUG)
5199     dbxout_resume_previous_source_file ();
5200 #endif
5201 #ifdef DWARF_DEBUGGING_INFO
5202   if (debug_info_level == DINFO_LEVEL_VERBOSE
5203       && write_symbols == DWARF_DEBUG)
5204     dwarfout_resume_previous_source_file (lineno);
5205 #endif /* DWARF_DEBUGGING_INFO  */
5206 #ifdef DWARF2_DEBUGGING_INFO
5207   if (write_symbols == DWARF2_DEBUG)
5208     dwarf2out_end_source_file ();
5209 #endif /* DWARF2_DEBUGGING_INFO  */
5210 #ifdef SDB_DEBUGGING_INFO
5211   if (write_symbols == SDB_DEBUG)
5212     sdbout_resume_previous_source_file ();
5213 #endif
5214 }
5215
5216 /* Called from cb_define in c-lex.c.  The `buffer' parameter contains
5217    the tail part of the directive line, i.e. the part which is past the
5218    initial whitespace, #, whitespace, directive-name, whitespace part.  */
5219
5220 void
5221 debug_define (lineno, buffer)
5222      register unsigned lineno ATTRIBUTE_UNUSED;
5223      register const char *buffer ATTRIBUTE_UNUSED;
5224 {
5225 #ifdef DWARF_DEBUGGING_INFO
5226   if (write_symbols == DWARF_DEBUG)
5227     dwarfout_define (lineno, buffer);
5228 #endif /* DWARF_DEBUGGING_INFO  */
5229 #ifdef DWARF2_DEBUGGING_INFO
5230   if (write_symbols == DWARF2_DEBUG)
5231     dwarf2out_define (lineno, buffer);
5232 #endif /* DWARF2_DEBUGGING_INFO  */
5233 }
5234
5235 /* Called from cb_undef in c-lex.c.  The `buffer' parameter contains
5236    the tail part of the directive line, i.e. the part which is past the
5237    initial whitespace, #, whitespace, directive-name, whitespace part.  */
5238
5239 void
5240 debug_undef (lineno, buffer)
5241      register unsigned lineno ATTRIBUTE_UNUSED;
5242      register const char *buffer ATTRIBUTE_UNUSED;
5243 {
5244 #ifdef DWARF_DEBUGGING_INFO
5245   if (write_symbols == DWARF_DEBUG)
5246     dwarfout_undef (lineno, buffer);
5247 #endif /* DWARF_DEBUGGING_INFO  */
5248 #ifdef DWARF2_DEBUGGING_INFO
5249   if (write_symbols == DWARF2_DEBUG)
5250     dwarf2out_undef (lineno, buffer);
5251 #endif /* DWARF2_DEBUGGING_INFO  */
5252 }
5253
5254 /* Returns nonzero if it is appropriate not to emit any debugging
5255    information for BLOCK, because it doesn't contain any instructions.
5256    This may not be the case for blocks containing nested functions, since
5257    we may actually call such a function even though the BLOCK information
5258    is messed up.  */
5259
5260 int
5261 debug_ignore_block (block)
5262      tree block ATTRIBUTE_UNUSED;
5263 {
5264   /* Never delete the BLOCK for the outermost scope
5265      of the function; we can refer to names from
5266      that scope even if the block notes are messed up.  */
5267   if (is_body_block (block))
5268     return 0;
5269
5270 #ifdef DWARF2_DEBUGGING_INFO
5271   if (write_symbols == DWARF2_DEBUG)
5272     return dwarf2out_ignore_block (block);
5273 #endif
5274
5275   return 1;
5276 }