OSDN Git Service

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