OSDN Git Service

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