OSDN Git Service

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