OSDN Git Service

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