OSDN Git Service

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