OSDN Git Service

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