OSDN Git Service

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