OSDN Git Service

(main): Really accept -gstabs+.
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
1 /* Top level of GNU C compiler
2    Copyright (C) 1987, 1988, 1989, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
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 #include <sys/types.h>
28 #include <stdio.h>
29 #include <signal.h>
30 #include <setjmp.h>
31
32 #include <sys/stat.h>
33
34 #ifdef USG
35 #undef FLOAT
36 #include <sys/param.h>
37 /* This is for hpux.  It is a real screw.  They should change hpux.  */
38 #undef FLOAT
39 #include <sys/times.h>
40 #include <time.h>   /* Correct for hpux at least.  Is it good on other USG?  */
41 #undef FFS  /* Some systems define this in param.h.  */
42 #else
43 #ifndef VMS
44 #include <sys/time.h>
45 #include <sys/resource.h>
46 #endif
47 #endif
48
49 #include "input.h"
50 #include "tree.h"
51 /* #include "c-tree.h" */
52 #include "rtl.h"
53 #include "flags.h"
54 #include "insn-attr.h"
55
56 #ifdef XCOFF_DEBUGGING_INFO
57 #include "xcoffout.h"
58 #endif
59 \f
60 #ifdef VMS
61 /* The extra parameters substantially improve the I/O performance.  */
62 static FILE *
63 VMS_fopen (fname, type)
64      char * fname;
65      char * type;
66 {
67   if (strcmp (type, "w") == 0)
68     return fopen (fname, type, "mbc=16", "deq=64", "fop=tef", "shr=nil");
69   return fopen (fname, type, "mbc=16");
70 }
71 #define fopen VMS_fopen
72 #endif
73
74 #ifndef DEFAULT_GDB_EXTENSIONS
75 #define DEFAULT_GDB_EXTENSIONS 1
76 #endif
77
78 extern int rtx_equal_function_value_matters;
79
80 #if ! (defined (VMS) || defined (OS2))
81 extern char **environ;
82 #endif
83 extern char *version_string, *language_string;
84
85 extern void init_lex ();
86 extern void init_decl_processing ();
87 extern void init_obstacks ();
88 extern void init_tree_codes ();
89 extern void init_rtl ();
90 extern void init_optabs ();
91 extern void init_stmt ();
92 extern void init_reg_sets ();
93 extern void dump_flow_info ();
94 extern void dump_sched_info ();
95 extern void dump_local_alloc ();
96
97 void rest_of_decl_compilation ();
98 void error ();
99 void error_with_file_and_line ();
100 void fancy_abort ();
101 #ifndef abort
102 void abort ();
103 #endif
104 void set_target_switch ();
105 static void print_switch_values ();
106 static char *decl_name ();
107
108 /* Name of program invoked, sans directories.  */
109
110 char *progname;
111
112 /* Copy of arguments to main.  */
113 int save_argc;
114 char **save_argv;
115 \f
116 /* Name of current original source file (what was input to cpp).
117    This comes from each #-command in the actual input.  */
118
119 char *input_filename;
120
121 /* Name of top-level original source file (what was input to cpp).
122    This comes from the #-command at the beginning of the actual input.
123    If there isn't any there, then this is the cc1 input file name.  */
124
125 char *main_input_filename;
126
127 /* Stream for reading from the input file.  */
128
129 FILE *finput;
130
131 /* Current line number in real source file.  */
132
133 int lineno;
134
135 /* Stack of currently pending input files.  */
136
137 struct file_stack *input_file_stack;
138
139 /* Incremented on each change to input_file_stack.  */
140 int input_file_stack_tick;
141
142 /* FUNCTION_DECL for function now being parsed or compiled.  */
143
144 extern tree current_function_decl;
145
146 /* Name to use as base of names for dump output files.  */
147
148 char *dump_base_name;
149
150 /* Bit flags that specify the machine subtype we are compiling for.
151    Bits are tested using macros TARGET_... defined in the tm.h file
152    and set by `-m...' switches.  Must be defined in rtlanal.c.  */
153
154 extern int target_flags;
155
156 /* Flags saying which kinds of debugging dump have been requested.  */
157
158 int rtl_dump = 0;
159 int rtl_dump_and_exit = 0;
160 int jump_opt_dump = 0;
161 int cse_dump = 0;
162 int loop_dump = 0;
163 int cse2_dump = 0;
164 int flow_dump = 0;
165 int combine_dump = 0;
166 int sched_dump = 0;
167 int local_reg_dump = 0;
168 int global_reg_dump = 0;
169 int sched2_dump = 0;
170 int jump2_opt_dump = 0;
171 int dbr_sched_dump = 0;
172 int flag_print_asm_name = 0;
173 int stack_reg_dump = 0;
174
175 /* Name for output file of assembly code, specified with -o.  */
176
177 char *asm_file_name;
178
179 /* Value of the -G xx switch, and whether it was passed or not.  */
180 int g_switch_value;
181 int g_switch_set;
182
183 /* Type(s) of debugging information we are producing (if any).
184    See flags.h for the definitions of the different possible
185    types of debugging information.  */
186 enum debug_info_type write_symbols = NO_DEBUG;
187
188 /* Level of debugging information we are producing.  See flags.h
189    for the definitions of the different possible levels.  */
190 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
191
192 /* Nonzero means use GNU-only extensions in the generated symbolic
193    debugging information.  */
194 /* Currently, this only has an effect when write_symbols is set to
195    DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG.  */
196 int use_gnu_debug_info_extensions = 0;
197
198 /* Nonzero means do optimizations.  -O.
199    Particular numeric values stand for particular amounts of optimization;
200    thus, -O2 stores 2 here.  However, the optimizations beyond the basic
201    ones are not controlled directly by this variable.  Instead, they are
202    controlled by individual `flag_...' variables that are defaulted
203    based on this variable.  */
204
205 int optimize = 0;
206
207 /* Number of error messages and warning messages so far.  */
208
209 int errorcount = 0;
210 int warningcount = 0;
211 int sorrycount = 0;
212
213 /* Pointer to function to compute the name to use to print a declaration.  */
214
215 char *(*decl_printable_name) ();
216
217 /* Pointer to function to compute rtl for a language-specific tree code.  */
218
219 struct rtx_def *(*lang_expand_expr) ();
220
221 /* Nonzero if generating code to do profiling.  */
222
223 int profile_flag = 0;
224
225 /* Nonzero if generating code to do profiling on a line-by-line basis.  */
226
227 int profile_block_flag;
228
229 /* Nonzero for -pedantic switch: warn about anything
230    that standard spec forbids.  */
231
232 int pedantic = 0;
233
234 /* Temporarily suppress certain warnings.
235    This is set while reading code from a system header file.  */
236
237 int in_system_header = 0;
238
239 /* Nonzero means do stupid register allocation.
240    Currently, this is 1 if `optimize' is 0.  */
241
242 int obey_regdecls = 0;
243
244 /* Don't print functions as they are compiled and don't print
245    times taken by the various passes.  -quiet.  */
246
247 int quiet_flag = 0;
248 \f
249 /* -f flags.  */
250
251 /* Nonzero means `char' should be signed.  */
252
253 int flag_signed_char;
254
255 /* Nonzero means give an enum type only as many bytes as it needs.  */
256
257 int flag_short_enums;
258
259 /* Nonzero for -fcaller-saves: allocate values in regs that need to
260    be saved across function calls, if that produces overall better code.
261    Optional now, so people can test it.  */
262
263 #ifdef DEFAULT_CALLER_SAVES
264 int flag_caller_saves = 1;
265 #else
266 int flag_caller_saves = 0;
267 #endif
268
269 /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
270
271 int flag_pcc_struct_return = 0;
272
273 /* Nonzero for -fforce-mem: load memory value into a register
274    before arithmetic on it.  This makes better cse but slower compilation.  */
275
276 int flag_force_mem = 0;
277
278 /* Nonzero for -fforce-addr: load memory address into a register before
279    reference to memory.  This makes better cse but slower compilation.  */
280
281 int flag_force_addr = 0;
282
283 /* Nonzero for -fdefer-pop: don't pop args after each function call;
284    instead save them up to pop many calls' args with one insns.  */
285
286 int flag_defer_pop = 1;
287
288 /* Nonzero for -ffloat-store: don't allocate floats and doubles
289    in extended-precision registers.  */
290
291 int flag_float_store = 0;
292
293 /* Nonzero for -fcse-follow-jumps:
294    have cse follow jumps to do a more extensive job.  */
295
296 int flag_cse_follow_jumps;
297
298 /* Nonzero for -fcse-skip-blocks:
299    have cse follow a branch around a block.  */
300 int flag_cse_skip_blocks;
301
302 /* Nonzero for -fexpensive-optimizations:
303    perform miscellaneous relatively-expensive optimizations.  */
304 int flag_expensive_optimizations;
305
306 /* Nonzero for -fthread-jumps:
307    have jump optimize output of loop.  */
308
309 int flag_thread_jumps;
310
311 /* Nonzero enables strength-reduction in loop.c.  */
312
313 int flag_strength_reduce = 0;
314
315 /* Nonzero enables loop unrolling in unroll.c.  Only loops for which the
316    number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
317    UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
318    unrolled.  */
319
320 int flag_unroll_loops;
321
322 /* Nonzero enables loop unrolling in unroll.c.  All loops are unrolled.
323    This is generally not a win.  */
324
325 int flag_unroll_all_loops;
326
327 /* Nonzero for -fwritable-strings:
328    store string constants in data segment and don't uniquize them.  */
329
330 int flag_writable_strings = 0;
331
332 /* Nonzero means don't put addresses of constant functions in registers.
333    Used for compiling the Unix kernel, where strange substitutions are
334    done on the assembly output.  */
335
336 int flag_no_function_cse = 0;
337
338 /* Nonzero for -fomit-frame-pointer:
339    don't make a frame pointer in simple functions that don't require one.  */
340
341 int flag_omit_frame_pointer = 0;
342
343 /* Nonzero to inhibit use of define_optimization peephole opts.  */
344
345 int flag_no_peephole = 0;
346
347 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
348    operations in the interest of optimization.  For example it allows
349    GCC to assume arguments to sqrt are nonnegative numbers, allowing
350    faster code for sqrt to be generated. */
351
352 int flag_fast_math = 0;
353
354 /* Nonzero means all references through pointers are volatile.  */
355
356 int flag_volatile;
357
358 /* Nonzero means just do syntax checking; don't output anything.  */
359
360 int flag_syntax_only = 0;
361
362 /* Nonzero means to rerun cse after loop optimization.  This increases
363    compilation time about 20% and picks up a few more common expressions.  */
364
365 static int flag_rerun_cse_after_loop;
366
367 /* Nonzero for -finline-functions: ok to inline functions that look like
368    good inline candidates.  */
369
370 int flag_inline_functions;
371
372 /* Nonzero for -fkeep-inline-functions: even if we make a function
373    go inline everywhere, keep its defintion around for debugging
374    purposes.  */
375
376 int flag_keep_inline_functions;
377
378 /* Nonzero means that functions declared `inline' will be treated
379    as `static'.  Prevents generation of zillions of copies of unused
380    static inline functions; instead, `inlines' are written out
381    only when actually used.  Used in conjunction with -g.  Also
382    does the right thing with #pragma interface.  */
383
384 int flag_no_inline;
385
386 /* Nonzero means we should be saving declaration info into a .X file.  */
387
388 int flag_gen_aux_info = 0;
389
390 /* Specified name of aux-info file.  */
391
392 static char *aux_info_file_name;
393
394 /* Nonzero means make the text shared if supported.  */
395
396 int flag_shared_data;
397
398 /* Nonzero means schedule into delayed branch slots if supported.  */
399
400 int flag_delayed_branch;
401
402 /* Nonzero if we are compiling pure (sharable) code.
403    Value is 1 if we are doing reasonable (i.e. simple
404    offset into offset table) pic.  Value is 2 if we can
405    only perform register offsets.  */
406
407 int flag_pic;
408
409 /* Nonzero means place uninitialized global data in the bss section. */
410
411 int flag_no_common;
412
413 /* Nonzero means pretend it is OK to examine bits of target floats,
414    even if that isn't true.  The resulting code will have incorrect constants,
415    but the same series of instructions that the native compiler would make.  */
416
417 int flag_pretend_float;
418
419 /* Nonzero means change certain warnings into errors.
420    Usually these are warnings about failure to conform to some standard.  */
421
422 int flag_pedantic_errors = 0;
423
424 /* flag_schedule_insns means schedule insns within basic blocks (before
425    local_alloc).
426    flag_schedule_insns_after_reload means schedule insns after
427    global_alloc.  */
428
429 int flag_schedule_insns = 0;
430 int flag_schedule_insns_after_reload = 0;
431
432 /* -finhibit-size-directive inhibits output of .size for ELF.
433    This is used only for compiling crtstuff.c, 
434    and it may be extended to other effects
435    needed for crtstuff.c on other systems.  */
436 int flag_inhibit_size_directive = 0;
437
438 /* -fverbose-asm causes extra commentary information to be produced in
439    the generated assembly code (to make it more readable).  This option
440    is generally only of use to those who actually need to read the
441    generated assembly code (perhaps while debugging the compiler itself).  */
442
443 int flag_verbose_asm = 0;
444
445 /* -fgnu-linker specifies use of the GNU linker for initializations.
446    (Or, more generally, a linker that handles initializations.)
447    -fno-gnu-linker says that collect2 will be used.  */
448 #ifdef USE_COLLECT2
449 int flag_gnu_linker = 0;
450 #else
451 int flag_gnu_linker = 1;
452 #endif
453
454 /* Table of language-independent -f options.
455    STRING is the option name.  VARIABLE is the address of the variable.
456    ON_VALUE is the value to store in VARIABLE
457     if `-fSTRING' is seen as an option.
458    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
459
460 struct { char *string; int *variable; int on_value;} f_options[] =
461 {
462   {"float-store", &flag_float_store, 1},
463   {"volatile", &flag_volatile, 1},
464   {"defer-pop", &flag_defer_pop, 1},
465   {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
466   {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
467   {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
468   {"expensive-optimizations", &flag_expensive_optimizations, 1},
469   {"thread-jumps", &flag_thread_jumps, 1},
470   {"strength-reduce", &flag_strength_reduce, 1},
471   {"unroll-loops", &flag_unroll_loops, 1},
472   {"unroll-all-loops", &flag_unroll_all_loops, 1},
473   {"writable-strings", &flag_writable_strings, 1},
474   {"peephole", &flag_no_peephole, 0},
475   {"force-mem", &flag_force_mem, 1},
476   {"force-addr", &flag_force_addr, 1},
477   {"function-cse", &flag_no_function_cse, 0},
478   {"inline-functions", &flag_inline_functions, 1},
479   {"keep-inline-functions", &flag_keep_inline_functions, 1},
480   {"inline", &flag_no_inline, 0},
481   {"syntax-only", &flag_syntax_only, 1},
482   {"shared-data", &flag_shared_data, 1},
483   {"caller-saves", &flag_caller_saves, 1},
484   {"pcc-struct-return", &flag_pcc_struct_return, 1},
485   {"delayed-branch", &flag_delayed_branch, 1},
486   {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
487   {"pretend-float", &flag_pretend_float, 1},
488   {"schedule-insns", &flag_schedule_insns, 1},
489   {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
490   {"pic", &flag_pic, 1},
491   {"PIC", &flag_pic, 2},
492   {"fast-math", &flag_fast_math, 1},
493   {"common", &flag_no_common, 0},
494   {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
495   {"verbose-asm", &flag_verbose_asm, 1},
496   {"gnu-linker", &flag_gnu_linker, 1}
497 };
498
499 /* Table of language-specific options.  */
500
501 char *lang_options[] =
502 {
503   "-ftraditional",
504   "-traditional",
505   "-fnotraditional",
506   "-fno-traditional",
507   "-fsigned-char",
508   "-funsigned-char",
509   "-fno-signed-char",
510   "-fno-unsigned-char",
511   "-fsigned-bitfields",
512   "-funsigned-bitfields",
513   "-fno-signed-bitfields",
514   "-fno-unsigned-bitfields",
515   "-fshort-enums",
516   "-fno-short-enums",
517   "-fcond-mismatch",
518   "-fno-cond-mismatch",
519   "-fshort-double",
520   "-fno-short-double",
521   "-fasm",
522   "-fno-asm",
523   "-fbuiltin",
524   "-fno-builtin",
525   "-fno-ident",
526   "-fident",
527   "-ansi",
528   "-Wimplicit",
529   "-Wno-implicit",
530   "-Wwrite-strings",
531   "-Wno-write-strings",
532   "-Wcast-qual",
533   "-Wno-cast-qual",
534   "-Wpointer-arith",
535   "-Wno-pointer-arith",
536   "-Wstrict-prototypes",
537   "-Wno-strict-prototypes",
538   "-Wmissing-prototypes",
539   "-Wno-missing-prototypes",
540   "-Wredundant-decls",
541   "-Wno-redundant-decls",
542   "-Wnested-externs",
543   "-Wno-nested-externs",
544   "-Wtraditional",
545   "-Wno-traditional",
546   "-Wformat",
547   "-Wno-format",
548   "-Wchar-subscripts",
549   "-Wno-char-subscripts",
550   "-Wconversion",
551   "-Wno-conversion",
552   "-Wparentheses",
553   "-Wno-parentheses",
554   "-Wcomment",
555   "-Wno-comment",
556   "-Wcomments",
557   "-Wno-comments",
558   "-Wtrigraphs",
559   "-Wno-trigraphs",
560   "-Wimport",
561   "-Wno-import",
562   "-Wall",
563
564   /* These are for C++.  */
565   "+e0",
566   "+e1",
567   "+e2",
568   "-fsave-memoized",
569   "-fno-save-memoized",
570   "-fSOS",
571   "-fno-SOS",
572   "-fcadillac",
573   "-fno-cadillac",
574   "-fgc",
575   "-fno-gc",
576   "-flabels-ok",
577   "-fno-labels-ok",
578   "-fstats",
579   "-fno-stats",
580   "-fthis-is-variable",
581   "-fno-this-is-variable",
582   "-fstrict-prototype",
583   "-fno-strict-prototype",
584   "-fall-virtual",
585   "-fno-all-virtual",
586   "-fmemoize-lookups",
587   "-fno-memoize-lookups",
588   "-felide-constructors",
589   "-fno-elide-constructors",
590   "-finline-debug",
591   "-fno-inline-debug",
592   "-fhandle-exceptions",
593   "-fno-handle-exceptions",
594   "-fansi-exceptions",
595   "-fno-ansi-exceptions",
596   "-fspring-exceptions",
597   "-fno-spring-exceptions",
598   "-fdefault-inline",
599   "-fno-default-inline",
600   "-fenum-int-equiv",
601   "-fno-enum-int-equiv",
602   "-fdossier",
603   "-fno-dossier",
604   "-fxref",
605   "-fno-xref",
606   "-fnonnull-objects",
607   "-fno-nonnull-objects",
608
609   "-Wreturn-type",
610   "-Wno-return-type",
611   "-Woverloaded-virtual",
612   "-Wno-overloaded-virtual",
613   "-Wenum-clash",
614   "-Wno-enum-clash",
615
616   /* these are for obj c */
617   "-lang-objc",
618   "-gen-decls",
619   "-Wselector",
620   "-Wno-selector",
621   0
622 };
623 \f
624 /* Options controlling warnings */
625
626 /* Don't print warning messages.  -w.  */
627
628 int inhibit_warnings = 0;
629
630 /* Print various extra warnings.  -W.  */
631
632 int extra_warnings = 0;
633
634 /* Treat warnings as errors.  -Werror.  */
635
636 int warnings_are_errors = 0;
637
638 /* Nonzero to warn about unused local variables.  */
639
640 int warn_unused;
641
642 /* Nonzero to warn about variables used before they are initialized.  */
643
644 int warn_uninitialized;
645
646 /* Nonzero means warn about all declarations which shadow others.   */
647
648 int warn_shadow;
649
650 /* Warn if a switch on an enum fails to have a case for every enum value.  */
651
652 int warn_switch;
653
654 /* Nonzero means warn about function definitions that default the return type
655    or that use a null return and have a return-type other than void.  */
656
657 int warn_return_type;
658
659 /* Nonzero means warn about pointer casts that increase the required
660    alignment of the target type (and might therefore lead to a crash
661    due to a misaligned access).  */
662
663 int warn_cast_align;
664
665 /* Nonzero means warn about any identifiers that match in the first N
666    characters.  The value N is in `id_clash_len'.  */
667
668 int warn_id_clash;
669 int id_clash_len;
670
671 /* Nonzero means warn if inline function is too large.  */
672
673 int warn_inline;
674
675 /* Warn if a function returns an aggregate,
676    since there are often incompatible calling conventions for doing this.  */
677
678 int warn_aggregate_return;
679
680 /* Likewise for -W.  */
681
682 struct { char *string; int *variable; int on_value;} W_options[] =
683 {
684   {"unused", &warn_unused, 1},
685   {"error", &warnings_are_errors, 1},
686   {"shadow", &warn_shadow, 1},
687   {"switch", &warn_switch, 1},
688   {"return-type", &warn_return_type, 1},
689   {"aggregate-return", &warn_aggregate_return, 1},
690   {"cast-align", &warn_cast_align, 1},
691   {"uninitialized", &warn_uninitialized, 1},
692   {"inline", &warn_inline, 1}
693 };
694 \f
695 /* Output files for assembler code (real compiler output)
696    and debugging dumps.  */
697
698 FILE *asm_out_file;
699 FILE *aux_info_file;
700 FILE *rtl_dump_file;
701 FILE *jump_opt_dump_file;
702 FILE *cse_dump_file;
703 FILE *loop_dump_file;
704 FILE *cse2_dump_file;
705 FILE *flow_dump_file;
706 FILE *combine_dump_file;
707 FILE *sched_dump_file;
708 FILE *local_reg_dump_file;
709 FILE *global_reg_dump_file;
710 FILE *sched2_dump_file;
711 FILE *jump2_opt_dump_file;
712 FILE *dbr_sched_dump_file;
713 FILE *stack_reg_dump_file;
714
715 /* Time accumulators, to count the total time spent in various passes.  */
716
717 int parse_time;
718 int varconst_time;
719 int integration_time;
720 int jump_time;
721 int cse_time;
722 int loop_time;
723 int cse2_time;
724 int flow_time;
725 int combine_time;
726 int sched_time;
727 int local_alloc_time;
728 int global_alloc_time;
729 int sched2_time;
730 int dbr_sched_time;
731 int shorten_branch_time;
732 int stack_reg_time;
733 int final_time;
734 int symout_time;
735 int dump_time;
736 \f
737 /* Return time used so far, in microseconds.  */
738
739 int
740 get_run_time ()
741 {
742 #ifdef USG
743   struct tms tms;
744 #else
745 #ifndef VMS
746   struct rusage rusage;
747 #else /* VMS */
748   struct
749     {
750       int proc_user_time;
751       int proc_system_time;
752       int child_user_time;
753       int child_system_time;
754     } vms_times;
755 #endif
756 #endif
757
758   if (quiet_flag)
759     return 0;
760
761 #ifdef USG
762   times (&tms);
763   return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
764 #else
765 #ifndef VMS
766   getrusage (0, &rusage);
767   return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
768           + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
769 #else /* VMS */
770   times (&vms_times);
771   return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
772 #endif
773 #endif
774 }
775
776 #define TIMEVAR(VAR, BODY)    \
777 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
778
779 void
780 print_time (str, total)
781      char *str;
782      int total;
783 {
784   fprintf (stderr,
785            "time in %s: %d.%06d\n",
786            str, total / 1000000, total % 1000000);
787 }
788
789 /* Count an error or warning.  Return 1 if the message should be printed.  */
790
791 int
792 count_error (warningp)
793      int warningp;
794 {
795   if (warningp && inhibit_warnings)
796     return 0;
797
798   if (warningp && !warnings_are_errors)
799     warningcount++;
800   else
801     {
802       static int warning_message = 0;
803
804       if (warningp && !warning_message)
805         {
806           fprintf (stderr, "%s: warnings being treated as errors\n", progname);
807           warning_message = 1;
808         }
809       errorcount++;
810     }
811
812   return 1;
813 }
814
815 /* Print a fatal error message.  NAME is the text.
816    Also include a system error message based on `errno'.  */
817
818 void
819 pfatal_with_name (name)
820      char *name;
821 {
822   fprintf (stderr, "%s: ", progname);
823   perror (name);
824   exit (35);
825 }
826
827 void
828 fatal_io_error (name)
829      char *name;
830 {
831   fprintf (stderr, "%s: %s: I/O error\n", progname, name);
832   exit (35);
833 }
834
835 void
836 fatal (s, v)
837      char *s;
838      int v;
839 {
840   error (s, v);
841   exit (34);
842 }
843
844 /* Called to give a better error message when we don't have an insn to match
845    what we are looking for or if the insn's constraints aren't satisfied,
846    rather than just calling abort().  */
847
848 void
849 fatal_insn_not_found (insn)
850      rtx insn;
851 {
852   if (INSN_CODE (insn) < 0)
853     error ("internal error--unrecognizable insn:", 0);
854   else
855     error ("internal error--insn does not satisfy its constraints:", 0);
856   debug_rtx (insn);
857   if (asm_out_file)
858     fflush (asm_out_file);
859   if (aux_info_file)
860     fflush (aux_info_file);
861   if (rtl_dump_file)
862     fflush (rtl_dump_file);
863   if (jump_opt_dump_file)
864     fflush (jump_opt_dump_file);
865   if (cse_dump_file)
866     fflush (cse_dump_file);
867   if (loop_dump_file)
868     fflush (loop_dump_file);
869   if (cse2_dump_file)
870     fflush (cse2_dump_file);
871   if (flow_dump_file)
872     fflush (flow_dump_file);
873   if (combine_dump_file)
874     fflush (combine_dump_file);
875   if (sched_dump_file)
876     fflush (sched_dump_file);
877   if (local_reg_dump_file)
878     fflush (local_reg_dump_file);
879   if (global_reg_dump_file)
880     fflush (global_reg_dump_file);
881   if (sched2_dump_file)
882     fflush (sched2_dump_file);
883   if (jump2_opt_dump_file)
884     fflush (jump2_opt_dump_file);
885   if (dbr_sched_dump_file)
886     fflush (dbr_sched_dump_file);
887   if (stack_reg_dump_file)
888     fflush (stack_reg_dump_file);
889   abort ();
890 }
891
892 /* This is the default decl_printable_name function.  */
893
894 static char *
895 decl_name (decl, kind)
896      tree decl;
897      char **kind;
898 {
899   return IDENTIFIER_POINTER (DECL_NAME (decl));
900 }
901 \f
902 static int need_error_newline;
903
904 /* Function of last error message;
905    more generally, function such that if next error message is in it
906    then we don't have to mention the function name.  */
907 static tree last_error_function = NULL;
908
909 /* Used to detect when input_file_stack has changed since last described.  */
910 static int last_error_tick;
911
912 /* Called when the start of a function definition is parsed,
913    this function prints on stderr the name of the function.  */
914
915 void
916 announce_function (decl)
917      tree decl;
918 {
919   if (! quiet_flag)
920     {
921       char *junk;
922       if (rtl_dump_and_exit)
923         fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
924       else
925         fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
926       fflush (stderr);
927       need_error_newline = 1;
928       last_error_function = current_function_decl;
929     }
930 }
931
932 /* Prints out, if necessary, the name of the current function
933    which caused an error.  Called from all error and warning functions.  */
934
935 void
936 report_error_function (file)
937      char *file;
938 {
939   struct file_stack *p;
940
941   if (need_error_newline)
942     {
943       fprintf (stderr, "\n");
944       need_error_newline = 0;
945     }
946
947   if (last_error_function != current_function_decl)
948     {
949       char *kind = "function";
950       if (current_function_decl != 0
951           && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
952         kind = "method";
953
954       if (file)
955         fprintf (stderr, "%s: ", file);
956
957       if (current_function_decl == NULL)
958         fprintf (stderr, "At top level:\n");
959       else
960         {
961           char *name = (*decl_printable_name) (current_function_decl, &kind);
962           fprintf (stderr, "In %s `%s':\n", kind, name);
963         }
964
965       last_error_function = current_function_decl;
966     }
967   if (input_file_stack && input_file_stack->next != 0
968       && input_file_stack_tick != last_error_tick)
969     {
970       fprintf (stderr, "In file included");
971       for (p = input_file_stack->next; p; p = p->next)
972         {
973           fprintf (stderr, " from %s:%d", p->name, p->line);
974           if (p->next)
975             fprintf (stderr, ",");
976         }
977       fprintf (stderr, ":\n");
978       last_error_tick = input_file_stack_tick;
979     }
980 }
981
982 /* Report an error at the current line number.
983    S is a string and V and V2 are args for `printf'.  We use HOST_WIDE_INT
984    as the type for these args assuming it is wide enough to hold a
985    pointer.  This isn't terribly portable, but is the best we can do
986    without vprintf universally available.  */
987
988 void
989 error (s, v, v2)
990      char *s;
991      HOST_WIDE_INT v;           /* Also used as pointer */
992      HOST_WIDE_INT v2;          /* Also used as pointer */
993 {
994   error_with_file_and_line (input_filename, lineno, s, v, v2);
995 }
996
997 /* Report an error at line LINE of file FILE.
998    S and V are a string and an arg for `printf'.  */
999
1000 void
1001 error_with_file_and_line (file, line, s, v, v2)
1002      char *file;
1003      int line;
1004      char *s;
1005      HOST_WIDE_INT v;
1006      HOST_WIDE_INT v2;
1007 {
1008   count_error (0);
1009
1010   report_error_function (file);
1011
1012   if (file)
1013     fprintf (stderr, "%s:%d: ", file, line);
1014   else
1015     fprintf (stderr, "%s: ", progname);
1016   fprintf (stderr, s, v, v2);
1017   fprintf (stderr, "\n");
1018 }
1019
1020 /* Report an error at the declaration DECL.
1021    S and V are a string and an arg which uses %s to substitute
1022    the declaration name.  */
1023
1024 void
1025 error_with_decl (decl, s, v)
1026      tree decl;
1027      char *s;
1028      HOST_WIDE_INT v;
1029 {
1030   char *junk;
1031   count_error (0);
1032
1033   report_error_function (DECL_SOURCE_FILE (decl));
1034
1035   fprintf (stderr, "%s:%d: ",
1036            DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1037
1038   if (DECL_NAME (decl))
1039     fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1040   else
1041     fprintf (stderr, s, "((anonymous))", v);
1042   fprintf (stderr, "\n");
1043 }
1044
1045 /* Report an error at the line number of the insn INSN.
1046    S and V are a string and an arg for `printf'.
1047    This is used only when INSN is an `asm' with operands,
1048    and each ASM_OPERANDS records its own source file and line.  */
1049
1050 void
1051 error_for_asm (insn, s, v, v2)
1052      rtx insn;
1053      char *s;
1054      HOST_WIDE_INT v;           /* Also used as pointer */
1055      HOST_WIDE_INT v2;          /* Also used as pointer */
1056 {
1057   char *filename;
1058   int line;
1059   rtx body = PATTERN (insn);
1060   rtx asmop;
1061
1062   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
1063   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1064     asmop = SET_SRC (body);
1065   else if (GET_CODE (body) == ASM_OPERANDS)
1066     asmop = body;
1067   else if (GET_CODE (body) == PARALLEL
1068            && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1069     asmop = SET_SRC (XVECEXP (body, 0, 0));
1070   else if (GET_CODE (body) == PARALLEL
1071            && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1072     asmop = XVECEXP (body, 0, 0);
1073
1074   filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1075   line = ASM_OPERANDS_SOURCE_LINE (asmop);
1076
1077   error_with_file_and_line (filename, line, s, v, v2);
1078 }
1079
1080 /* Report a warning at line LINE.
1081    S and V are a string and an arg for `printf'.  */
1082
1083 void
1084 warning_with_file_and_line (file, line, s, v, v2, v3)
1085      char *file;
1086      int line;
1087      char *s;
1088      HOST_WIDE_INT v, v2, v3;
1089 {
1090   if (count_error (1) == 0)
1091     return;
1092
1093   report_error_function (file);
1094
1095   if (file)
1096     fprintf (stderr, "%s:%d: ", file, line);
1097   else
1098     fprintf (stderr, "%s: ", progname);
1099
1100   fprintf (stderr, "warning: ");
1101   fprintf (stderr, s, v, v2, v3);
1102   fprintf (stderr, "\n");
1103 }
1104
1105 /* Report a warning at the current line number.
1106    S and V are a string and an arg for `printf'.  */
1107
1108 void
1109 warning (s, v, v2, v3)
1110      char *s;
1111      HOST_WIDE_INT v, v2, v3;   /* Also used as pointer */
1112 {
1113   warning_with_file_and_line (input_filename, lineno, s, v, v2, v3);
1114 }
1115
1116 /* Report a warning at the declaration DECL.
1117    S is string which uses %s to substitute the declaration name.
1118    V is a second parameter that S can refer to.  */
1119
1120 void
1121 warning_with_decl (decl, s, v)
1122      tree decl;
1123      char *s;
1124      HOST_WIDE_INT v;
1125 {
1126   char *junk;
1127
1128   if (count_error (1) == 0)
1129     return;
1130
1131   report_error_function (DECL_SOURCE_FILE (decl));
1132
1133   fprintf (stderr, "%s:%d: ",
1134            DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1135
1136   fprintf (stderr, "warning: ");
1137   if (DECL_NAME (decl))
1138     fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1139   else
1140     fprintf (stderr, s, "((anonymous))", v);
1141   fprintf (stderr, "\n");
1142 }
1143
1144 /* Report a warning at the line number of the insn INSN.
1145    S and V are a string and an arg for `printf'.
1146    This is used only when INSN is an `asm' with operands,
1147    and each ASM_OPERANDS records its own source file and line.  */
1148
1149 void
1150 warning_for_asm (insn, s, v, v2)
1151      rtx insn;
1152      char *s;
1153      HOST_WIDE_INT v;           /* Also used as pointer */
1154      HOST_WIDE_INT v2;          /* Also used as pointer */
1155 {
1156   char *filename;
1157   int line;
1158   rtx body = PATTERN (insn);
1159   rtx asmop;
1160
1161   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
1162   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1163     asmop = SET_SRC (body);
1164   else if (GET_CODE (body) == ASM_OPERANDS)
1165     asmop = body;
1166   else if (GET_CODE (body) == PARALLEL
1167            && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1168     asmop = SET_SRC (XVECEXP (body, 0, 0));
1169   else if (GET_CODE (body) == PARALLEL
1170            && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1171     asmop = XVECEXP (body, 0, 0);
1172
1173   filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1174   line = ASM_OPERANDS_SOURCE_LINE (asmop);
1175
1176   warning_with_file_and_line (filename, line, s, v, v2);
1177 }
1178 \f
1179 /* These functions issue either warnings or errors depending on
1180    -pedantic-errors.  */
1181
1182 void
1183 pedwarn (s, v, v2)
1184      char *s;
1185      HOST_WIDE_INT v;           /* Also used as pointer */
1186      HOST_WIDE_INT v2;
1187 {
1188   if (flag_pedantic_errors)
1189     error (s, v, v2);
1190   else
1191     warning (s, v, v2);
1192 }
1193
1194 void
1195 pedwarn_with_decl (decl, s, v)
1196      tree decl;
1197      char *s;
1198      HOST_WIDE_INT v;
1199 {
1200   if (flag_pedantic_errors)
1201     error_with_decl (decl, s, v);
1202   else
1203     warning_with_decl (decl, s, v);
1204 }
1205
1206 void
1207 pedwarn_with_file_and_line (file, line, s, v, v2)
1208      char *file;
1209      int line;
1210      char *s;
1211      HOST_WIDE_INT v;
1212      HOST_WIDE_INT v2;
1213 {
1214   if (flag_pedantic_errors)
1215     error_with_file_and_line (file, line, s, v, v2);
1216   else
1217     warning_with_file_and_line (file, line, s, v, v2);
1218 }
1219
1220 /* Apologize for not implementing some feature.
1221    S, V, and V2 are a string and args for `printf'.  */
1222
1223 void
1224 sorry (s, v, v2)
1225      char *s;
1226      HOST_WIDE_INT v, v2;
1227 {
1228   sorrycount++;
1229   if (input_filename)
1230     fprintf (stderr, "%s:%d: ", input_filename, lineno);
1231   else
1232     fprintf (stderr, "%s: ", progname);
1233
1234   fprintf (stderr, "sorry, not implemented: ");
1235   fprintf (stderr, s, v, v2);
1236   fprintf (stderr, "\n");
1237 }
1238
1239 /* Apologize for not implementing some feature, then quit.
1240    S, V, and V2 are a string and args for `printf'.  */
1241
1242 void
1243 really_sorry (s, v, v2)
1244      char *s;
1245      HOST_WIDE_INT v, v2;
1246 {
1247   if (input_filename)
1248     fprintf (stderr, "%s:%d: ", input_filename, lineno);
1249   else
1250     fprintf (stderr, "c++: ");
1251
1252   fprintf (stderr, "sorry, not implemented: ");
1253   fprintf (stderr, s, v, v2);
1254   fatal (" (fatal)\n");
1255 }
1256 \f
1257 /* More 'friendly' abort that prints the line and file.
1258    config.h can #define abort fancy_abort if you like that sort of thing.
1259
1260    I don't think this is actually a good idea.
1261    Other sorts of crashes will look a certain way.
1262    It is a good thing if crashes from calling abort look the same way.
1263      -- RMS  */
1264
1265 void
1266 fancy_abort ()
1267 {
1268   fatal ("internal gcc abort");
1269 }
1270
1271 /* This calls abort and is used to avoid problems when abort if a macro.
1272    It is used when we need to pass the address of abort.  */
1273
1274 void
1275 do_abort ()
1276 {
1277   abort ();
1278 }
1279
1280 /* When `malloc.c' is compiled with `rcheck' defined,
1281    it calls this function to report clobberage.  */
1282
1283 void
1284 botch (s)
1285 {
1286   abort ();
1287 }
1288
1289 /* Same as `malloc' but report error if no memory available.  */
1290
1291 char *
1292 xmalloc (size)
1293      unsigned size;
1294 {
1295   register char *value = (char *) malloc (size);
1296   if (value == 0)
1297     fatal ("virtual memory exhausted");
1298   return value;
1299 }
1300
1301 /* Same as `realloc' but report error if no memory available.  */
1302
1303 char *
1304 xrealloc (ptr, size)
1305      char *ptr;
1306      int size;
1307 {
1308   char *result = (char *) realloc (ptr, size);
1309   if (!result)
1310     fatal ("virtual memory exhausted");
1311   return result;
1312 }
1313 \f
1314 /* Return the logarithm of X, base 2, considering X unsigned,
1315    if X is a power of 2.  Otherwise, returns -1.
1316
1317    This should be used via the `exact_log2' macro.  */
1318
1319 int
1320 exact_log2_wide (x)
1321      register unsigned HOST_WIDE_INT x;
1322 {
1323   register int log = 0;
1324   /* Test for 0 or a power of 2.  */
1325   if (x == 0 || x != (x & -x))
1326     return -1;
1327   while ((x >>= 1) != 0)
1328     log++;
1329   return log;
1330 }
1331
1332 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1333    If X is 0, return -1.
1334
1335    This should be used via the floor_log2 macro.  */
1336
1337 int
1338 floor_log2_wide (x)
1339      register unsigned HOST_WIDE_INT x;
1340 {
1341   register int log = -1;
1342   while (x != 0)
1343     log++,
1344     x >>= 1;
1345   return log;
1346 }
1347
1348 int float_handled;
1349 jmp_buf float_handler;
1350
1351 /* Specify where to longjmp to when a floating arithmetic error happens.
1352    If HANDLER is 0, it means don't handle the errors any more.  */
1353
1354 void
1355 set_float_handler (handler)
1356      jmp_buf handler;
1357 {
1358   float_handled = (handler != 0);
1359   if (handler)
1360     bcopy (handler, float_handler, sizeof (float_handler));
1361 }
1362
1363 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1364    error happens, pushing the previous specification into OLD_HANDLER.
1365    Return an indication of whether there was a previous handler in effect.  */
1366
1367 int
1368 push_float_handler (handler, old_handler)
1369      jmp_buf handler, old_handler;
1370 {
1371   int was_handled = float_handled;
1372
1373   float_handled = 1;
1374   if (was_handled)
1375     bcopy (float_handler, old_handler, sizeof (float_handler));
1376   bcopy (handler, float_handler, sizeof (float_handler));
1377   return was_handled;
1378 }
1379
1380 /* Restore the previous specification of whether and where to longjmp to
1381    when a floating arithmetic error happens.  */
1382
1383 void
1384 pop_float_handler (handled, handler)
1385      int handled;
1386      jmp_buf handler;
1387 {
1388   float_handled = handled;
1389   if (handled)
1390     bcopy (handler, float_handler, sizeof (float_handler));
1391 }
1392
1393 /* Signals actually come here.  */
1394
1395 static void
1396 float_signal (signo)
1397      /* If this is missing, some compilers complain.  */
1398      int signo;
1399 {
1400   if (float_handled == 0)
1401     abort ();
1402 #if defined (USG) || defined (hpux)
1403   signal (SIGFPE, float_signal);  /* re-enable the signal catcher */
1404 #endif
1405   float_handled = 0;
1406   signal (SIGFPE, float_signal);
1407   longjmp (float_handler, 1);
1408 }
1409
1410 /* Handler for SIGPIPE.  */
1411
1412 static void
1413 pipe_closed (signo)
1414      /* If this is missing, some compilers complain.  */
1415      int signo;
1416 {
1417   fatal ("output pipe has been closed");
1418 }
1419
1420 /* Strip off a legitimate source ending from the input string NAME of
1421    length LEN. */
1422
1423 void
1424 strip_off_ending (name, len)
1425      char *name;
1426      int len;
1427 {
1428   if (len > 2 && ! strcmp (".c", name + len - 2))
1429     name[len - 2] = 0;
1430   else if (len > 2 && ! strcmp (".m", name + len - 2))
1431     name[len - 2] = 0;
1432   else if (len > 2 && ! strcmp (".i", name + len - 2))
1433     name[len - 2] = 0;
1434   else if (len > 3 && ! strcmp (".ii", name + len - 3))
1435     name[len - 3] = 0;
1436   else if (len > 3 && ! strcmp (".co", name + len - 3))
1437     name[len - 3] = 0;
1438   else if (len > 3 && ! strcmp (".cc", name + len - 3))
1439     name[len - 3] = 0;
1440   else if (len > 2 && ! strcmp (".C", name + len - 2))
1441     name[len - 2] = 0;
1442   else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1443     name[len - 4] = 0;
1444   else if (len > 2 && ! strcmp (".f", name + len - 2))
1445     name[len - 2] = 0;
1446   else if (len > 4 && ! strcmp (".ada", name + len - 4))
1447     name[len - 4] = 0;
1448 }
1449
1450 /* Output a file name in the form wanted by System V.  */
1451
1452 void
1453 output_file_directive (asm_file, input_name)
1454      FILE *asm_file;
1455      char *input_name;
1456 {
1457   int len = strlen (input_name);
1458   char *na = input_name + len;
1459
1460   /* NA gets INPUT_NAME sans directory names.  */
1461   while (na > input_name)
1462     {
1463       if (na[-1] == '/')
1464         break;
1465       na--;
1466     }
1467
1468 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1469   ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1470 #else
1471 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1472   ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1473 #else
1474   fprintf (asm_file, "\t.file\t\"%s\"\n", na);
1475 #endif
1476 #endif
1477 }
1478 \f
1479 /* Compile an entire file of output from cpp, named NAME.
1480    Write a file of assembly output and various debugging dumps.  */
1481
1482 static void
1483 compile_file (name)
1484      char *name;
1485 {
1486   tree globals;
1487   int start_time;
1488   int dump_base_name_length;
1489
1490   int name_specified = name != 0;
1491
1492   if (dump_base_name == 0)
1493     dump_base_name = name ? name : "gccdump";
1494   dump_base_name_length = strlen (dump_base_name);
1495
1496   parse_time = 0;
1497   varconst_time = 0;
1498   integration_time = 0;
1499   jump_time = 0;
1500   cse_time = 0;
1501   loop_time = 0;
1502   cse2_time = 0;
1503   flow_time = 0;
1504   combine_time = 0;
1505   sched_time = 0;
1506   local_alloc_time = 0;
1507   global_alloc_time = 0;
1508   sched2_time = 0;
1509   dbr_sched_time = 0;
1510   shorten_branch_time = 0;
1511   stack_reg_time = 0;
1512   final_time = 0;
1513   symout_time = 0;
1514   dump_time = 0;
1515
1516   /* Open input file.  */
1517
1518   if (name == 0 || !strcmp (name, "-"))
1519     {
1520       finput = stdin;
1521       name = "stdin";
1522     }
1523   else
1524     finput = fopen (name, "r");
1525   if (finput == 0)
1526     pfatal_with_name (name);
1527
1528 #ifdef IO_BUFFER_SIZE
1529   setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
1530 #endif
1531
1532   /* Initialize data in various passes.  */
1533
1534   init_obstacks ();
1535   init_tree_codes ();
1536   init_lex ();
1537   init_rtl ();
1538   init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
1539                   || debug_info_level == DINFO_LEVEL_VERBOSE);
1540   init_decl_processing ();
1541   init_optabs ();
1542   init_stmt ();
1543   init_expmed ();
1544   init_expr_once ();
1545   init_loop ();
1546   init_reload ();
1547
1548   if (flag_caller_saves)
1549     init_caller_save ();
1550
1551   /* If auxiliary info generation is desired, open the output file.
1552      This goes in the same directory as the source file--unlike
1553      all the other output files.  */
1554   if (flag_gen_aux_info)
1555     {
1556       aux_info_file = fopen (aux_info_file_name, "w");
1557       if (aux_info_file == 0)
1558         pfatal_with_name (aux_info_file_name);
1559     }
1560
1561   /* If rtl dump desired, open the output file.  */
1562   if (rtl_dump)
1563     {
1564       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1565       strcpy (dumpname, dump_base_name);
1566       strcat (dumpname, ".rtl");
1567       rtl_dump_file = fopen (dumpname, "w");
1568       if (rtl_dump_file == 0)
1569         pfatal_with_name (dumpname);
1570     }
1571
1572   /* If jump_opt dump desired, open the output file.  */
1573   if (jump_opt_dump)
1574     {
1575       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1576       strcpy (dumpname, dump_base_name);
1577       strcat (dumpname, ".jump");
1578       jump_opt_dump_file = fopen (dumpname, "w");
1579       if (jump_opt_dump_file == 0)
1580         pfatal_with_name (dumpname);
1581     }
1582
1583   /* If cse dump desired, open the output file.  */
1584   if (cse_dump)
1585     {
1586       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1587       strcpy (dumpname, dump_base_name);
1588       strcat (dumpname, ".cse");
1589       cse_dump_file = fopen (dumpname, "w");
1590       if (cse_dump_file == 0)
1591         pfatal_with_name (dumpname);
1592     }
1593
1594   /* If loop dump desired, open the output file.  */
1595   if (loop_dump)
1596     {
1597       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1598       strcpy (dumpname, dump_base_name);
1599       strcat (dumpname, ".loop");
1600       loop_dump_file = fopen (dumpname, "w");
1601       if (loop_dump_file == 0)
1602         pfatal_with_name (dumpname);
1603     }
1604
1605   /* If cse2 dump desired, open the output file.  */
1606   if (cse2_dump)
1607     {
1608       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1609       strcpy (dumpname, dump_base_name);
1610       strcat (dumpname, ".cse2");
1611       cse2_dump_file = fopen (dumpname, "w");
1612       if (cse2_dump_file == 0)
1613         pfatal_with_name (dumpname);
1614     }
1615
1616   /* If flow dump desired, open the output file.  */
1617   if (flow_dump)
1618     {
1619       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1620       strcpy (dumpname, dump_base_name);
1621       strcat (dumpname, ".flow");
1622       flow_dump_file = fopen (dumpname, "w");
1623       if (flow_dump_file == 0)
1624         pfatal_with_name (dumpname);
1625     }
1626
1627   /* If combine dump desired, open the output file.  */
1628   if (combine_dump)
1629     {
1630       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1631       strcpy (dumpname, dump_base_name);
1632       strcat (dumpname, ".combine");
1633       combine_dump_file = fopen (dumpname, "w");
1634       if (combine_dump_file == 0)
1635         pfatal_with_name (dumpname);
1636     }
1637
1638   /* If scheduling dump desired, open the output file.  */
1639   if (sched_dump)
1640     {
1641       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1642       strcpy (dumpname, dump_base_name);
1643       strcat (dumpname, ".sched");
1644       sched_dump_file = fopen (dumpname, "w");
1645       if (sched_dump_file == 0)
1646         pfatal_with_name (dumpname);
1647     }
1648
1649   /* If local_reg dump desired, open the output file.  */
1650   if (local_reg_dump)
1651     {
1652       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1653       strcpy (dumpname, dump_base_name);
1654       strcat (dumpname, ".lreg");
1655       local_reg_dump_file = fopen (dumpname, "w");
1656       if (local_reg_dump_file == 0)
1657         pfatal_with_name (dumpname);
1658     }
1659
1660   /* If global_reg dump desired, open the output file.  */
1661   if (global_reg_dump)
1662     {
1663       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1664       strcpy (dumpname, dump_base_name);
1665       strcat (dumpname, ".greg");
1666       global_reg_dump_file = fopen (dumpname, "w");
1667       if (global_reg_dump_file == 0)
1668         pfatal_with_name (dumpname);
1669     }
1670
1671   /* If 2nd scheduling dump desired, open the output file.  */
1672   if (sched2_dump)
1673     {
1674       register char *dumpname = (char *) xmalloc (dump_base_name_length + 8);
1675       strcpy (dumpname, dump_base_name);
1676       strcat (dumpname, ".sched2");
1677       sched2_dump_file = fopen (dumpname, "w");
1678       if (sched2_dump_file == 0)
1679         pfatal_with_name (dumpname);
1680     }
1681
1682   /* If jump2_opt dump desired, open the output file.  */
1683   if (jump2_opt_dump)
1684     {
1685       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1686       strcpy (dumpname, dump_base_name);
1687       strcat (dumpname, ".jump2");
1688       jump2_opt_dump_file = fopen (dumpname, "w");
1689       if (jump2_opt_dump_file == 0)
1690         pfatal_with_name (dumpname);
1691     }
1692
1693   /* If dbr_sched dump desired, open the output file.  */
1694   if (dbr_sched_dump)
1695     {
1696       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1697       strcpy (dumpname, dump_base_name);
1698       strcat (dumpname, ".dbr");
1699       dbr_sched_dump_file = fopen (dumpname, "w");
1700       if (dbr_sched_dump_file == 0)
1701         pfatal_with_name (dumpname);
1702     }
1703
1704 #ifdef STACK_REGS
1705
1706   /* If stack_reg dump desired, open the output file.  */
1707   if (stack_reg_dump)
1708     {
1709       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1710       strcpy (dumpname, dump_base_name);
1711       strcat (dumpname, ".stack");
1712       stack_reg_dump_file = fopen (dumpname, "w");
1713       if (stack_reg_dump_file == 0)
1714         pfatal_with_name (dumpname);
1715     }
1716
1717 #endif
1718
1719   /* Open assembler code output file.  */
1720
1721   if (! name_specified && asm_file_name == 0)
1722     asm_out_file = stdout;
1723   else
1724     {
1725       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1726       int len = strlen (dump_base_name);
1727       strcpy (dumpname, dump_base_name);
1728       strip_off_ending (dumpname, len);
1729       strcat (dumpname, ".s");
1730       if (asm_file_name == 0)
1731         {
1732           asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
1733           strcpy (asm_file_name, dumpname);
1734         }
1735       if (!strcmp (asm_file_name, "-"))
1736         asm_out_file = stdout;
1737       else
1738         asm_out_file = fopen (asm_file_name, "w");
1739       if (asm_out_file == 0)
1740         pfatal_with_name (asm_file_name);
1741     }
1742
1743 #ifdef IO_BUFFER_SIZE
1744   setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
1745            _IOFBF, IO_BUFFER_SIZE);
1746 #endif
1747
1748   input_filename = name;
1749
1750   /* Perform language-specific initialization.
1751      This may set main_input_filename.  */
1752   lang_init ();
1753
1754   /* If the input doesn't start with a #line, use the input name
1755      as the official input file name.  */
1756   if (main_input_filename == 0)
1757     main_input_filename = name;
1758
1759   /* Put an entry on the input file stack for the main input file.  */
1760   input_file_stack
1761     = (struct file_stack *) xmalloc (sizeof (struct file_stack));
1762   input_file_stack->next = 0;
1763   input_file_stack->name = input_filename;
1764
1765   ASM_FILE_START (asm_out_file);
1766
1767   /* Output something to inform GDB that this compilation was by GCC.  */
1768 #ifndef ASM_IDENTIFY_GCC
1769   fprintf (asm_out_file, "gcc2_compiled.:\n");
1770 #else
1771   ASM_IDENTIFY_GCC (asm_out_file);
1772 #endif
1773   /* Don't let the first function fall at the same address
1774      as gcc_compiled., if profiling.  */
1775   if (profile_flag || profile_block_flag)
1776     assemble_zeros (UNITS_PER_WORD);
1777
1778   /* If dbx symbol table desired, initialize writing it
1779      and output the predefined types.  */
1780 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1781   if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1782     TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
1783                                        getdecls ()));
1784 #endif
1785 #ifdef SDB_DEBUGGING_INFO
1786   if (write_symbols == SDB_DEBUG)
1787     TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
1788                                        getdecls ()));
1789 #endif
1790 #ifdef DWARF_DEBUGGING_INFO
1791   if (write_symbols == DWARF_DEBUG)
1792     TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
1793 #endif
1794
1795   /* Initialize yet another pass.  */
1796
1797   init_final (main_input_filename);
1798
1799   start_time = get_run_time ();
1800
1801   /* Call the parser, which parses the entire file
1802      (calling rest_of_compilation for each function).  */
1803
1804   if (yyparse () != 0)
1805     if (errorcount == 0)
1806       fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
1807
1808   /* Compilation is now finished except for writing
1809      what's left of the symbol table output.  */
1810
1811   parse_time += get_run_time () - start_time;
1812
1813   parse_time -= integration_time;
1814   parse_time -= varconst_time;
1815
1816   globals = getdecls ();
1817
1818   /* Really define vars that have had only a tentative definition.
1819      Really output inline functions that must actually be callable
1820      and have not been output so far.  */
1821
1822   {
1823     int len = list_length (globals);
1824     tree *vec = (tree *) alloca (sizeof (tree) * len);
1825     int i;
1826     tree decl;
1827
1828     /* Process the decls in reverse order--earliest first.
1829        Put them into VEC from back to front, then take out from front.  */
1830
1831     for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
1832       vec[len - i - 1] = decl;
1833
1834     for (i = 0; i < len; i++)
1835       {
1836         decl = vec[i];
1837         if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1838             && ! TREE_ASM_WRITTEN (decl))
1839           {
1840             /* Don't write out static consts, unless we used them.
1841                (This used to write them out only if the address was
1842                taken, but that was wrong; if the variable was simply
1843                referred to, it still needs to exist or else it will
1844                be undefined in the linker.)  */
1845             if (! TREE_READONLY (decl)
1846                 || TREE_PUBLIC (decl)
1847                 || TREE_USED (decl)
1848                 || TREE_ADDRESSABLE (decl)
1849                 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1850               rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1851             else
1852               /* Cancel the RTL for this decl so that, if debugging info
1853                  output for global variables is still to come,
1854                  this one will be omitted.  */
1855               DECL_RTL (decl) = NULL;
1856           }
1857
1858         if (TREE_CODE (decl) == FUNCTION_DECL
1859             && ! TREE_ASM_WRITTEN (decl)
1860             && DECL_INITIAL (decl) != 0
1861             && (TREE_ADDRESSABLE (decl)
1862                 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1863             && ! DECL_EXTERNAL (decl))
1864           output_inline_function (decl);
1865
1866         /* Warn about any function
1867            declared static but not defined.
1868            We don't warn about variables,
1869            because many programs have static variables
1870            that exist only to get some text into the object file.  */
1871         if ((warn_unused
1872              || TREE_USED (decl)
1873              || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))))
1874             && TREE_CODE (decl) == FUNCTION_DECL
1875             && DECL_INITIAL (decl) == 0
1876             && DECL_EXTERNAL (decl)
1877             && ! TREE_PUBLIC (decl))
1878           warning_with_decl (decl, "`%s' declared `static' but never defined");
1879         /* Warn about static fns or vars defined but not used,
1880            but not about inline functions
1881            since unused inline statics is normal practice.  */
1882         if (warn_unused
1883             && (TREE_CODE (decl) == FUNCTION_DECL
1884                 || TREE_CODE (decl) == VAR_DECL)
1885             && ! DECL_IN_SYSTEM_HEADER (decl)
1886             && ! DECL_EXTERNAL (decl)
1887             && ! TREE_PUBLIC (decl)
1888             && ! TREE_USED (decl)
1889             && ! DECL_INLINE (decl)
1890             /* The TREE_USED bit for file-scope decls
1891                is kept in the identifier, to handle multiple
1892                external decls in different scopes.  */
1893             && ! TREE_USED (DECL_NAME (decl)))
1894           warning_with_decl (decl, "`%s' defined but not used");
1895
1896 #ifdef SDB_DEBUGGING_INFO
1897         /* The COFF linker can move initialized global vars to the end.
1898            And that can screw up the symbol ordering.
1899            By putting the symbols in that order to begin with,
1900            we avoid a problem.  mcsun!unido!fauern!tumuc!pes@uunet.uu.net.  */
1901         if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
1902             && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
1903             && DECL_RTL (decl) != 0)
1904           TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1905
1906         /* Output COFF information for non-global
1907            file-scope initialized variables. */
1908         if (write_symbols == SDB_DEBUG
1909             && TREE_CODE (decl) == VAR_DECL
1910             && DECL_INITIAL (decl)
1911             && DECL_RTL (decl) != 0
1912             && GET_CODE (DECL_RTL (decl)) == MEM)
1913           TIMEVAR (symout_time, sdbout_toplevel_data (decl));
1914 #endif /* SDB_DEBUGGING_INFO */
1915 #ifdef DWARF_DEBUGGING_INFO
1916         /* Output DWARF information for file-scope tentative data object
1917            declarations, file-scope (extern) function declarations (which
1918            had no corresponding body) and file-scope tagged type declarations
1919            and definitions which have not yet been forced out.  */
1920
1921         if (write_symbols == DWARF_DEBUG
1922             && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1923           TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
1924 #endif
1925       }
1926   }
1927
1928   /* Do dbx symbols */
1929 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1930   if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1931     TIMEVAR (symout_time,
1932              {
1933                dbxout_finish (asm_out_file, main_input_filename);
1934              });
1935 #endif
1936
1937 #ifdef DWARF_DEBUGGING_INFO
1938   if (write_symbols == DWARF_DEBUG)
1939     TIMEVAR (symout_time,
1940              {
1941                dwarfout_finish ();
1942              });
1943 #endif
1944
1945   /* Output some stuff at end of file if nec.  */
1946
1947   end_final (main_input_filename);
1948
1949 #ifdef ASM_FILE_END
1950   ASM_FILE_END (asm_out_file);
1951 #endif
1952
1953  after_finish_compilation:
1954
1955   /* Language-specific end of compilation actions.  */
1956
1957   lang_finish ();
1958
1959   /* Close the dump files.  */
1960
1961   if (flag_gen_aux_info)
1962     {
1963       fclose (aux_info_file);
1964       if (errorcount)
1965         unlink (aux_info_file_name);
1966     }
1967
1968   if (rtl_dump)
1969     fclose (rtl_dump_file);
1970
1971   if (jump_opt_dump)
1972     fclose (jump_opt_dump_file);
1973
1974   if (cse_dump)
1975     fclose (cse_dump_file);
1976
1977   if (loop_dump)
1978     fclose (loop_dump_file);
1979
1980   if (cse2_dump)
1981     fclose (cse2_dump_file);
1982
1983   if (flow_dump)
1984     fclose (flow_dump_file);
1985
1986   if (combine_dump)
1987     {
1988       dump_combine_total_stats (combine_dump_file);
1989       fclose (combine_dump_file);
1990     }
1991
1992   if (sched_dump)
1993     fclose (sched_dump_file);
1994
1995   if (local_reg_dump)
1996     fclose (local_reg_dump_file);
1997
1998   if (global_reg_dump)
1999     fclose (global_reg_dump_file);
2000
2001   if (sched2_dump)
2002     fclose (sched2_dump_file);
2003
2004   if (jump2_opt_dump)
2005     fclose (jump2_opt_dump_file);
2006
2007   if (dbr_sched_dump)
2008     fclose (dbr_sched_dump_file);
2009
2010 #ifdef STACK_REGS
2011   if (stack_reg_dump)
2012     fclose (stack_reg_dump_file);
2013 #endif
2014
2015   /* Close non-debugging input and output files.  Take special care to note
2016      whether fclose returns an error, since the pages might still be on the
2017      buffer chain while the file is open.  */
2018
2019   fclose (finput);
2020   if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2021     fatal_io_error (asm_file_name);
2022
2023   /* Print the times.  */
2024
2025   if (! quiet_flag)
2026     {
2027       fprintf (stderr,"\n");
2028       print_time ("parse", parse_time);
2029       print_time ("integration", integration_time);
2030       print_time ("jump", jump_time);
2031       print_time ("cse", cse_time);
2032       print_time ("loop", loop_time);
2033       print_time ("cse2", cse2_time);
2034       print_time ("flow", flow_time);
2035       print_time ("combine", combine_time);
2036       print_time ("sched", sched_time);
2037       print_time ("local-alloc", local_alloc_time);
2038       print_time ("global-alloc", global_alloc_time);
2039       print_time ("sched2", sched2_time);
2040       print_time ("dbranch", dbr_sched_time);
2041       print_time ("shorten-branch", shorten_branch_time);
2042       print_time ("stack-reg", stack_reg_time);
2043       print_time ("final", final_time);
2044       print_time ("varconst", varconst_time);
2045       print_time ("symout", symout_time);
2046       print_time ("dump", dump_time);
2047     }
2048 }
2049 \f
2050 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2051    and TYPE_DECL nodes.
2052
2053    This does nothing for local (non-static) variables.
2054    Otherwise, it sets up the RTL and outputs any assembler code
2055    (label definition, storage allocation and initialization).
2056
2057    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
2058    the assembler symbol name to be used.  TOP_LEVEL is nonzero
2059    if this declaration is not within a function.  */
2060
2061 void
2062 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2063      tree decl;
2064      char *asmspec;
2065      int top_level;
2066      int at_end;
2067 {
2068   /* Declarations of variables, and of functions defined elsewhere.  */
2069
2070   /* Forward declarations for nested functions are not "external",
2071      but we need to treat them as if they were.  */
2072   if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2073       || TREE_CODE (decl) == FUNCTION_DECL)
2074     TIMEVAR (varconst_time,
2075              {
2076                make_decl_rtl (decl, asmspec, top_level);
2077                /* For a user-invisible decl that should be replaced
2078                   by its value when used, don't output anything.  */
2079                if (! (TREE_CODE (decl) == VAR_DECL
2080                       && DECL_IGNORED_P (decl) && TREE_READONLY (decl)
2081                       && DECL_INITIAL (decl) != 0))
2082                  /* Don't output anything
2083                     when a tentative file-scope definition is seen.
2084                     But at end of compilation, do output code for them.  */
2085                  if (! (! at_end && top_level
2086                         && (DECL_INITIAL (decl) == 0
2087                             || DECL_INITIAL (decl) == error_mark_node
2088                             || DECL_IGNORED_P (decl))))
2089                    assemble_variable (decl, top_level, at_end);
2090              });
2091   else if (DECL_REGISTER (decl) && asmspec != 0)
2092     {
2093       if (decode_reg_name (asmspec) >= 0)
2094         {
2095           DECL_RTL (decl) = 0;
2096           make_decl_rtl (decl, asmspec, top_level);
2097         }
2098       else
2099         error ("invalid register name `%s' for register variable", asmspec);
2100     }
2101 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2102   else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2103            && TREE_CODE (decl) == TYPE_DECL)
2104     TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2105 #endif
2106 #ifdef SDB_DEBUGGING_INFO
2107   else if (write_symbols == SDB_DEBUG && top_level
2108            && TREE_CODE (decl) == TYPE_DECL)
2109     TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2110 #endif
2111 }
2112
2113 /* Called after finishing a record, union or enumeral type.  */
2114
2115 void
2116 rest_of_type_compilation (type, toplev)
2117      tree type;
2118      int toplev;
2119 {
2120 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2121   if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2122     TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2123 #endif
2124 #ifdef SDB_DEBUGGING_INFO
2125   if (write_symbols == SDB_DEBUG)
2126     TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2127 #endif
2128 }
2129
2130 /* This is called from finish_function (within yyparse)
2131    after each top-level definition is parsed.
2132    It is supposed to compile that function or variable
2133    and output the assembler code for it.
2134    After we return, the tree storage is freed.  */
2135
2136 void
2137 rest_of_compilation (decl)
2138      tree decl;
2139 {
2140   register rtx insns;
2141   int start_time = get_run_time ();
2142   int tem;
2143   /* Nonzero if we have saved the original DECL_INITIAL of the function,
2144      to be restored after we finish compiling the function
2145      (for use when compiling inline calls to this function).  */
2146   tree saved_block_tree = 0;
2147   /* Likewise, for DECL_ARGUMENTS.  */
2148   tree saved_arguments = 0;
2149   int failure = 0;
2150
2151   /* If we are reconsidering an inline function
2152      at the end of compilation, skip the stuff for making it inline.  */
2153
2154   if (DECL_SAVED_INSNS (decl) == 0)
2155     {
2156       int specd = DECL_INLINE (decl);
2157       char *lose;
2158
2159       /* If requested, consider whether to make this function inline.  */
2160       if (specd || flag_inline_functions)
2161         TIMEVAR (integration_time,
2162                  {
2163                    lose = function_cannot_inline_p (decl);
2164                    if (lose)
2165                      {
2166                        if (warn_inline && specd)
2167                          warning_with_decl (decl, lose);
2168                        DECL_INLINE (decl) = 0;
2169                      }
2170                    else
2171                      DECL_INLINE (decl) = 1;
2172                  });
2173
2174       insns = get_insns ();
2175
2176       /* Dump the rtl code if we are dumping rtl.  */
2177
2178       if (rtl_dump)
2179         TIMEVAR (dump_time,
2180                  {
2181                    fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2182                             IDENTIFIER_POINTER (DECL_NAME (decl)));
2183                    if (DECL_SAVED_INSNS (decl))
2184                      fprintf (rtl_dump_file, ";; (integrable)\n\n");
2185                    print_rtl (rtl_dump_file, insns);
2186                    fflush (rtl_dump_file);
2187                  });
2188
2189       /* If function is inline, and we don't yet know whether to
2190          compile it by itself, defer decision till end of compilation.
2191          finish_compilation will call rest_of_compilation again
2192          for those functions that need to be output.  */
2193
2194       if (DECL_INLINE (decl)
2195           && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2196                && ! flag_keep_inline_functions)
2197               || DECL_EXTERNAL (decl)))
2198         {
2199 #ifdef DWARF_DEBUGGING_INFO
2200           /* Generate the DWARF info for the "abstract" instance
2201              of a function which we may later generate inlined and/or
2202              out-of-line instances of.  */
2203           if (write_symbols == DWARF_DEBUG)
2204             {
2205               set_decl_abstract_flags (decl, 1);
2206               TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2207               set_decl_abstract_flags (decl, 0);
2208             }
2209 #endif
2210           TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2211           goto exit_rest_of_compilation;
2212         }
2213
2214       /* If we have to compile the function now, save its rtl and subdecls
2215          so that its compilation will not affect what others get.  */
2216       if (DECL_INLINE (decl))
2217         {
2218 #ifdef DWARF_DEBUGGING_INFO
2219           /* Generate the DWARF info for the "abstract" instance of
2220              a function which we will generate an out-of-line instance
2221              of almost immediately (and which we may also later generate
2222              various inlined instances of).  */
2223           if (write_symbols == DWARF_DEBUG)
2224             {
2225               set_decl_abstract_flags (decl, 1);
2226               TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2227               set_decl_abstract_flags (decl, 0);
2228             }
2229 #endif
2230           saved_block_tree = DECL_INITIAL (decl);
2231           saved_arguments = DECL_ARGUMENTS (decl);
2232           TIMEVAR (integration_time, save_for_inline_copying (decl));
2233         }
2234     }
2235
2236   TREE_ASM_WRITTEN (decl) = 1;
2237
2238   /* Now that integrate will no longer see our rtl, we need not distinguish
2239      between the return value of this function and the return value of called
2240      functions.  */
2241   rtx_equal_function_value_matters = 0;
2242
2243   /* Don't return yet if -Wreturn-type; we need to do jump_optimize.  */
2244   if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2245     {
2246       goto exit_rest_of_compilation;
2247     }
2248
2249   /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2250      Note that that may have been done above, in save_for_inline_copying.
2251      The call to resume_temporary_allocation near the end of this function
2252      goes back to the usual state of affairs.  */
2253
2254   rtl_in_current_obstack ();
2255
2256 #ifdef FINALIZE_PIC
2257   /* If we are doing position-independent code generation, now
2258      is the time to output special prologues and epilogues.
2259      We do not want to do this earlier, because it just clutters
2260      up inline functions with meaningless insns.  */
2261   if (flag_pic)
2262     FINALIZE_PIC;
2263 #endif
2264
2265   insns = get_insns ();
2266
2267   /* Copy any shared structure that should not be shared.  */
2268
2269   unshare_all_rtl (insns);
2270
2271   /* Instantiate all virtual registers.  */
2272
2273   instantiate_virtual_regs (current_function_decl, get_insns ());
2274
2275   /* See if we have allocated stack slots that are not directly addressable.
2276      If so, scan all the insns and create explicit address computation
2277      for all references to such slots.  */
2278 /*   fixup_stack_slots (); */
2279
2280   /* Do jump optimization the first time, if -opt.
2281      Also do it if -W, but in that case it doesn't change the rtl code,
2282      it only computes whether control can drop off the end of the function.  */
2283
2284   if (optimize > 0 || extra_warnings || warn_return_type
2285       /* If function is `volatile', we should warn if it tries to return.  */
2286       || TREE_THIS_VOLATILE (decl))
2287     {
2288       TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2289       TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2290     }
2291
2292   /* Now is when we stop if -fsyntax-only and -Wreturn-type.  */
2293   if (rtl_dump_and_exit || flag_syntax_only)
2294     goto exit_rest_of_compilation;
2295
2296   /* Dump rtl code after jump, if we are doing that.  */
2297
2298   if (jump_opt_dump)
2299     TIMEVAR (dump_time,
2300              {
2301                fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2302                         IDENTIFIER_POINTER (DECL_NAME (decl)));
2303                print_rtl (jump_opt_dump_file, insns);
2304                fflush (jump_opt_dump_file);
2305              });
2306
2307   /* Perform common subexpression elimination.
2308      Nonzero value from `cse_main' means that jumps were simplified
2309      and some code may now be unreachable, so do
2310      jump optimization again.  */
2311
2312   if (cse_dump)
2313     TIMEVAR (dump_time,
2314              {
2315                fprintf (cse_dump_file, "\n;; Function %s\n\n",
2316                         IDENTIFIER_POINTER (DECL_NAME (decl)));
2317              });
2318
2319   if (optimize > 0)
2320     {
2321       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2322
2323       if (flag_thread_jumps)
2324         /* Hacks by tiemann & kenner.  */
2325         TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2326
2327       TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2328                                          0, cse_dump_file));
2329       TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2330
2331       if (tem)
2332         TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2333     }
2334
2335   /* Dump rtl code after cse, if we are doing that.  */
2336
2337   if (cse_dump)
2338     TIMEVAR (dump_time,
2339              {
2340                print_rtl (cse_dump_file, insns);
2341                fflush (cse_dump_file);
2342              });
2343
2344   if (loop_dump)
2345     TIMEVAR (dump_time,
2346              {
2347                fprintf (loop_dump_file, "\n;; Function %s\n\n",
2348                         IDENTIFIER_POINTER (DECL_NAME (decl)));
2349              });
2350
2351   /* Move constant computations out of loops.  */
2352
2353   if (optimize > 0)
2354     {
2355       TIMEVAR (loop_time,
2356                {
2357                  loop_optimize (insns, loop_dump_file);
2358                });
2359     }
2360
2361   /* Dump rtl code after loop opt, if we are doing that.  */
2362
2363   if (loop_dump)
2364     TIMEVAR (dump_time,
2365              {
2366                print_rtl (loop_dump_file, insns);
2367                fflush (loop_dump_file);
2368              });
2369
2370   if (cse2_dump)
2371     TIMEVAR (dump_time,
2372              {
2373                fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2374                         IDENTIFIER_POINTER (DECL_NAME (decl)));
2375              });
2376
2377   if (optimize > 0 && flag_rerun_cse_after_loop)
2378     {
2379       TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2380
2381       TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2382                                           1, cse2_dump_file));
2383       if (tem)
2384         TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2385     }
2386
2387   if (optimize > 0 && flag_thread_jumps)
2388     /* This pass of jump threading straightens out code
2389        that was kinked by loop optimization.  */
2390     TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2391
2392   /* Dump rtl code after cse, if we are doing that.  */
2393
2394   if (cse2_dump)
2395     TIMEVAR (dump_time,
2396              {
2397                print_rtl (cse2_dump_file, insns);
2398                fflush (cse2_dump_file);
2399              });
2400
2401   /* We are no longer anticipating cse in this function, at least.  */
2402
2403   cse_not_expected = 1;
2404
2405   /* Now we choose between stupid (pcc-like) register allocation
2406      (if we got the -noreg switch and not -opt)
2407      and smart register allocation.  */
2408
2409   if (optimize > 0)                     /* Stupid allocation probably won't work */
2410     obey_regdecls = 0;          /* if optimizations being done.  */
2411
2412   regclass_init ();
2413
2414   /* Print function header into flow dump now
2415      because doing the flow analysis makes some of the dump.  */
2416
2417   if (flow_dump)
2418     TIMEVAR (dump_time,
2419              {
2420                fprintf (flow_dump_file, "\n;; Function %s\n\n",
2421                         IDENTIFIER_POINTER (DECL_NAME (decl)));
2422              });
2423
2424   if (obey_regdecls)
2425     {
2426       TIMEVAR (flow_time,
2427                {
2428                  regclass (insns, max_reg_num ());
2429                  stupid_life_analysis (insns, max_reg_num (),
2430                                        flow_dump_file);
2431                });
2432     }
2433   else
2434     {
2435       /* Do control and data flow analysis,
2436          and write some of the results to dump file.  */
2437
2438       TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2439                                          flow_dump_file));
2440       if (warn_uninitialized)
2441         {
2442           uninitialized_vars_warning (DECL_INITIAL (decl));
2443           setjmp_args_warning ();
2444         }
2445     }
2446
2447   /* Dump rtl after flow analysis.  */
2448
2449   if (flow_dump)
2450     TIMEVAR (dump_time,
2451              {
2452                print_rtl (flow_dump_file, insns);
2453                fflush (flow_dump_file);
2454              });
2455
2456   /* If -opt, try combining insns through substitution.  */
2457
2458   if (optimize > 0)
2459     TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2460
2461   /* Dump rtl code after insn combination.  */
2462
2463   if (combine_dump)
2464     TIMEVAR (dump_time,
2465              {
2466                fprintf (combine_dump_file, "\n;; Function %s\n\n",
2467                         IDENTIFIER_POINTER (DECL_NAME (decl)));
2468                dump_combine_stats (combine_dump_file);
2469                print_rtl (combine_dump_file, insns);
2470                fflush (combine_dump_file);
2471              });
2472
2473   /* Print function header into sched dump now
2474      because doing the sched analysis makes some of the dump.  */
2475
2476   if (sched_dump)
2477     TIMEVAR (dump_time,
2478              {
2479                fprintf (sched_dump_file, "\n;; Function %s\n\n",
2480                         IDENTIFIER_POINTER (DECL_NAME (decl)));
2481              });
2482
2483   if (optimize > 0 && flag_schedule_insns)
2484     {
2485       /* Do control and data sched analysis,
2486          and write some of the results to dump file.  */
2487
2488       TIMEVAR (sched_time, schedule_insns (sched_dump_file));
2489     }
2490
2491   /* Dump rtl after instruction scheduling.  */
2492
2493   if (sched_dump)
2494     TIMEVAR (dump_time,
2495              {
2496                print_rtl (sched_dump_file, insns);
2497                fflush (sched_dump_file);
2498              });
2499
2500   /* Unless we did stupid register allocation,
2501      allocate pseudo-regs that are used only within 1 basic block.  */
2502
2503   if (!obey_regdecls)
2504     TIMEVAR (local_alloc_time,
2505              {
2506                regclass (insns, max_reg_num ());
2507                local_alloc ();
2508              });
2509
2510   /* Dump rtl code after allocating regs within basic blocks.  */
2511
2512   if (local_reg_dump)
2513     TIMEVAR (dump_time,
2514              {
2515                fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
2516                         IDENTIFIER_POINTER (DECL_NAME (decl)));
2517                dump_flow_info (local_reg_dump_file);
2518                dump_local_alloc (local_reg_dump_file);
2519                print_rtl (local_reg_dump_file, insns);
2520                fflush (local_reg_dump_file);
2521              });
2522
2523   if (global_reg_dump)
2524     TIMEVAR (dump_time,
2525              fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
2526                       IDENTIFIER_POINTER (DECL_NAME (decl))));
2527
2528   /* Unless we did stupid register allocation,
2529      allocate remaining pseudo-regs, then do the reload pass
2530      fixing up any insns that are invalid.  */
2531
2532   TIMEVAR (global_alloc_time,
2533            {
2534              if (!obey_regdecls)
2535                failure = global_alloc (global_reg_dump_file);
2536              else
2537                failure = reload (insns, 0, global_reg_dump_file);
2538            });
2539
2540   if (global_reg_dump)
2541     TIMEVAR (dump_time,
2542              {
2543                dump_global_regs (global_reg_dump_file);
2544                print_rtl (global_reg_dump_file, insns);
2545                fflush (global_reg_dump_file);
2546              });
2547
2548   if (failure)
2549     goto exit_rest_of_compilation;
2550
2551   reload_completed = 1;
2552
2553   /* On some machines, the prologue and epilogue code, or parts thereof,
2554      can be represented as RTL.  Doing so lets us schedule insns between
2555      it and the rest of the code and also allows delayed branch
2556      scheduling to operate in the epilogue.  */
2557
2558   thread_prologue_and_epilogue_insns (insns);
2559
2560   if (optimize > 0 && flag_schedule_insns_after_reload)
2561     {
2562       if (sched2_dump)
2563         TIMEVAR (dump_time,
2564                  {
2565                    fprintf (sched2_dump_file, "\n;; Function %s\n\n",
2566                             IDENTIFIER_POINTER (DECL_NAME (decl)));
2567                  });
2568
2569       /* Do control and data sched analysis again,
2570          and write some more of the results to dump file.  */
2571
2572       TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
2573
2574       /* Dump rtl after post-reorder instruction scheduling.  */
2575
2576       if (sched2_dump)
2577         TIMEVAR (dump_time,
2578                  {
2579                    print_rtl (sched2_dump_file, insns);
2580                    fflush (sched2_dump_file);
2581                  });
2582     }
2583
2584 #ifdef LEAF_REGISTERS
2585   leaf_function = 0;
2586   if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
2587     leaf_function = 1;
2588 #endif
2589
2590   /* One more attempt to remove jumps to .+1
2591      left by dead-store-elimination.
2592      Also do cross-jumping this time
2593      and delete no-op move insns.  */
2594
2595   if (optimize > 0)
2596     {
2597       TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
2598     }
2599
2600   /* Dump rtl code after jump, if we are doing that.  */
2601
2602   if (jump2_opt_dump)
2603     TIMEVAR (dump_time,
2604              {
2605                fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
2606                         IDENTIFIER_POINTER (DECL_NAME (decl)));
2607                print_rtl (jump2_opt_dump_file, insns);
2608                fflush (jump2_opt_dump_file);
2609              });
2610
2611   /* If a scheduling pass for delayed branches is to be done,
2612      call the scheduling code. */
2613
2614 #ifdef DELAY_SLOTS
2615   if (optimize > 0 && flag_delayed_branch)
2616     {
2617       TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
2618       if (dbr_sched_dump)
2619         {
2620           TIMEVAR (dump_time,
2621                  {
2622                    fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
2623                             IDENTIFIER_POINTER (DECL_NAME (decl)));
2624                    print_rtl (dbr_sched_dump_file, insns);
2625                    fflush (dbr_sched_dump_file);
2626                  });
2627         }
2628     }
2629 #endif
2630
2631   if (optimize > 0)
2632     /* Shorten branches.  */
2633     TIMEVAR (shorten_branch_time,
2634              {
2635                shorten_branches (get_insns ());
2636              });
2637
2638 #ifdef STACK_REGS
2639   TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
2640   if (stack_reg_dump)
2641     {
2642       TIMEVAR (dump_time,
2643                {
2644                  fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
2645                           IDENTIFIER_POINTER (DECL_NAME (decl)));
2646                  print_rtl (stack_reg_dump_file, insns);
2647                  fflush (stack_reg_dump_file);
2648                });
2649     }
2650 #endif
2651
2652   /* Now turn the rtl into assembler code.  */
2653
2654   TIMEVAR (final_time,
2655            {
2656              rtx x;
2657              char *fnname;
2658
2659              /* Get the function's name, as described by its RTL.
2660                 This may be different from the DECL_NAME name used
2661                 in the source file.  */
2662
2663              x = DECL_RTL (decl);
2664              if (GET_CODE (x) != MEM)
2665                abort ();
2666              x = XEXP (x, 0);
2667              if (GET_CODE (x) != SYMBOL_REF)
2668                abort ();
2669              fnname = XSTR (x, 0);
2670
2671              assemble_start_function (decl, fnname);
2672              final_start_function (insns, asm_out_file, optimize);
2673              final (insns, asm_out_file, optimize, 0);
2674              final_end_function (insns, asm_out_file, optimize);
2675              assemble_end_function (decl, fnname);
2676              fflush (asm_out_file);
2677            });
2678
2679   /* Write DBX symbols if requested */
2680
2681   /* Note that for those inline functions where we don't initially
2682      know for certain that we will be generating an out-of-line copy,
2683      the first invocation of this routine (rest_of_compilation) will
2684      skip over this code by doing a `goto exit_rest_of_compilation;'.
2685      Later on, finish_compilation will call rest_of_compilation again
2686      for those inline functions that need to have out-of-line copies
2687      generated.  During that call, we *will* be routed past here.  */
2688
2689 #ifdef DBX_DEBUGGING_INFO
2690   if (write_symbols == DBX_DEBUG)
2691     TIMEVAR (symout_time, dbxout_function (decl));
2692 #endif
2693
2694 #ifdef DWARF_DEBUGGING_INFO
2695   if (write_symbols == DWARF_DEBUG)
2696     TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2697 #endif
2698
2699  exit_rest_of_compilation:
2700
2701   /* In case the function was not output,
2702      don't leave any temporary anonymous types
2703      queued up for sdb output.  */
2704 #ifdef SDB_DEBUGGING_INFO
2705   if (write_symbols == SDB_DEBUG)
2706     sdbout_types (NULL_TREE);
2707 #endif
2708
2709   /* Put back the tree of subblocks and list of arguments
2710      from before we copied them.
2711      Code generation and the output of debugging info may have modified
2712      the copy, but the original is unchanged.  */
2713
2714   if (saved_block_tree != 0)
2715     DECL_INITIAL (decl) = saved_block_tree;
2716   if (saved_arguments != 0)
2717     DECL_ARGUMENTS (decl) = saved_arguments;
2718
2719   reload_completed = 0;
2720
2721   /* Clear out the real_constant_chain before some of the rtx's
2722      it runs through become garbage.  */
2723
2724   clear_const_double_mem ();
2725
2726   /* Cancel the effect of rtl_in_current_obstack.  */
2727
2728   resume_temporary_allocation ();
2729
2730   /* The parsing time is all the time spent in yyparse
2731      *except* what is spent in this function.  */
2732
2733   parse_time -= get_run_time () - start_time;
2734 }
2735 \f
2736 /* Entry point of cc1/c++.  Decode command args, then call compile_file.
2737    Exit code is 35 if can't open files, 34 if fatal error,
2738    33 if had nonfatal errors, else success.  */
2739
2740 int
2741 main (argc, argv, envp)
2742      int argc;
2743      char **argv;
2744      char **envp;
2745 {
2746   register int i;
2747   char *filename = 0;
2748   int flag_print_mem = 0;
2749   int version_flag = 0;
2750   char *p;
2751
2752   /* save in case md file wants to emit args as a comment.  */
2753   save_argc = argc;
2754   save_argv = argv;
2755
2756   p = argv[0] + strlen (argv[0]);
2757   while (p != argv[0] && p[-1] != '/') --p;
2758   progname = p;
2759
2760 #ifdef RLIMIT_STACK
2761   /* Get rid of any avoidable limit on stack size.  */
2762   {
2763     struct rlimit rlim;
2764
2765     /* Set the stack limit huge so that alloca does not fail. */
2766     getrlimit (RLIMIT_STACK, &rlim);
2767     rlim.rlim_cur = rlim.rlim_max;
2768     setrlimit (RLIMIT_STACK, &rlim);
2769   }
2770 #endif /* RLIMIT_STACK */
2771
2772   signal (SIGFPE, float_signal);
2773
2774   signal (SIGPIPE, pipe_closed);
2775
2776   decl_printable_name = decl_name;
2777   lang_expand_expr = (struct rtx_def *(*)()) do_abort;
2778
2779   /* Initialize whether `char' is signed.  */
2780   flag_signed_char = DEFAULT_SIGNED_CHAR;
2781 #ifdef DEFAULT_SHORT_ENUMS
2782   /* Initialize how much space enums occupy, by default.  */
2783   flag_short_enums = DEFAULT_SHORT_ENUMS;
2784 #endif
2785
2786   /* Scan to see what optimization level has been specified.  That will
2787      determine the default value of many flags.  */
2788   for (i = 1; i < argc; i++)
2789     {
2790       if (!strcmp (argv[i], "-O"))
2791         {
2792           optimize = 1;
2793         }
2794       else if (argv[i][0] == '-' && argv[i][1] == 'O')
2795         {
2796           /* Handle -O2, -O3, -O69, ...  */
2797           char *p = &argv[i][2];
2798           int c;
2799
2800           while (c = *p++)
2801             if (! (c >= '0' && c <= '9'))
2802               break;
2803           if (c == 0)
2804             optimize = atoi (&argv[i][2]);
2805         }
2806     }
2807
2808   obey_regdecls = (optimize == 0);
2809   if (optimize == 0)
2810     {
2811       flag_no_inline = 1;
2812       warn_inline = 0;
2813     }
2814
2815   if (optimize >= 1)
2816     {
2817       flag_thread_jumps = 1;
2818 #ifdef DELAY_SLOTS
2819       flag_delayed_branch = 1;
2820 #endif
2821     }
2822
2823   if (optimize >= 2)
2824     {
2825       flag_cse_follow_jumps = 1;
2826       flag_cse_skip_blocks = 1;
2827       flag_expensive_optimizations = 1;
2828       flag_strength_reduce = 1;
2829       flag_rerun_cse_after_loop = 1;
2830       flag_caller_saves = 1;
2831 #ifdef INSN_SCHEDULING
2832       flag_schedule_insns = 1;
2833       flag_schedule_insns_after_reload = 1;
2834 #endif
2835     }
2836
2837 #ifdef OPTIMIZATION_OPTIONS
2838   /* Allow default optimizations to be specified on a per-machine basis.  */
2839   OPTIMIZATION_OPTIONS (optimize);
2840 #endif
2841
2842   /* Initialize register usage now so switches may override.  */
2843   init_reg_sets ();
2844
2845   target_flags = 0;
2846   set_target_switch ("");
2847
2848   for (i = 1; i < argc; i++)
2849     {
2850       int j;
2851       /* If this is a language-specific option,
2852          decode it in a language-specific way.  */
2853       for (j = 0; lang_options[j] != 0; j++)
2854         if (!strncmp (argv[i], lang_options[j],
2855                       strlen (lang_options[j])))
2856           break;
2857       if (lang_options[j] != 0)
2858         /* If the option is valid for *some* language,
2859            treat it as valid even if this language doesn't understand it.  */
2860         lang_decode_option (argv[i]);
2861       else if (argv[i][0] == '-' && argv[i][1] != 0)
2862         {
2863           register char *str = argv[i] + 1;
2864           if (str[0] == 'Y')
2865             str++;
2866
2867           if (str[0] == 'm')
2868             set_target_switch (&str[1]);
2869           else if (!strcmp (str, "dumpbase"))
2870             {
2871               dump_base_name = argv[++i];
2872             }
2873           else if (str[0] == 'd')
2874             {
2875               register char *p = &str[1];
2876               while (*p)
2877                 switch (*p++)
2878                   {
2879                   case 'a':
2880                     combine_dump = 1;
2881                     dbr_sched_dump = 1;
2882                     flow_dump = 1;
2883                     global_reg_dump = 1;
2884                     jump_opt_dump = 1;
2885                     jump2_opt_dump = 1;
2886                     local_reg_dump = 1;
2887                     loop_dump = 1;
2888                     rtl_dump = 1;
2889                     cse_dump = 1, cse2_dump = 1;
2890                     sched_dump = 1;
2891                     sched2_dump = 1;
2892                     stack_reg_dump = 1;
2893                     break;
2894                   case 'k':
2895                     stack_reg_dump = 1;
2896                     break;
2897                   case 'c':
2898                     combine_dump = 1;
2899                     break;
2900                   case 'd':
2901                     dbr_sched_dump = 1;
2902                     break;
2903                   case 'f':
2904                     flow_dump = 1;
2905                     break;
2906                   case 'g':
2907                     global_reg_dump = 1;
2908                     break;
2909                   case 'j':
2910                     jump_opt_dump = 1;
2911                     break;
2912                   case 'J':
2913                     jump2_opt_dump = 1;
2914                     break;
2915                   case 'l':
2916                     local_reg_dump = 1;
2917                     break;
2918                   case 'L':
2919                     loop_dump = 1;
2920                     break;
2921                   case 'm':
2922                     flag_print_mem = 1;
2923                     break;
2924                   case 'p':
2925                     flag_print_asm_name = 1;
2926                     break;
2927                   case 'r':
2928                     rtl_dump = 1;
2929                     break;
2930                   case 's':
2931                     cse_dump = 1;
2932                     break;
2933                   case 't':
2934                     cse2_dump = 1;
2935                     break;
2936                   case 'S':
2937                     sched_dump = 1;
2938                     break;
2939                   case 'R':
2940                     sched2_dump = 1;
2941                     break;
2942                   case 'y':
2943                     set_yydebug (1);
2944                     break;
2945
2946                   case 'x':
2947                     rtl_dump_and_exit = 1;
2948                     break;
2949                   }
2950             }
2951           else if (str[0] == 'f')
2952             {
2953               register char *p = &str[1];
2954               int found = 0;
2955
2956               /* Some kind of -f option.
2957                  P's value is the option sans `-f'.
2958                  Search for it in the table of options.  */
2959
2960               for (j = 0;
2961                    !found && j < sizeof (f_options) / sizeof (f_options[0]);
2962                    j++)
2963                 {
2964                   if (!strcmp (p, f_options[j].string))
2965                     {
2966                       *f_options[j].variable = f_options[j].on_value;
2967                       /* A goto here would be cleaner,
2968                          but breaks the vax pcc.  */
2969                       found = 1;
2970                     }
2971                   if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
2972                       && ! strcmp (p+3, f_options[j].string))
2973                     {
2974                       *f_options[j].variable = ! f_options[j].on_value;
2975                       found = 1;
2976                     }
2977                 }
2978
2979               if (found)
2980                 ;
2981               else if (!strncmp (p, "fixed-", 6))
2982                 fix_register (&p[6], 1, 1);
2983               else if (!strncmp (p, "call-used-", 10))
2984                 fix_register (&p[10], 0, 1);
2985               else if (!strncmp (p, "call-saved-", 11))
2986                 fix_register (&p[11], 0, 0);
2987               else
2988                 error ("Invalid option `%s'", argv[i]);
2989             }
2990           else if (str[0] == 'O')
2991             {
2992               register char *p = str+1;
2993               while (*p && *p >= '0' && *p <= '9')
2994                 p++;
2995               if (*p == '\0')
2996                 ;
2997               else
2998                 error ("Invalid option `%s'", argv[i]);
2999             }
3000           else if (!strcmp (str, "pedantic"))
3001             pedantic = 1;
3002           else if (!strcmp (str, "pedantic-errors"))
3003             flag_pedantic_errors = pedantic = 1;
3004           else if (!strcmp (str, "quiet"))
3005             quiet_flag = 1;
3006           else if (!strcmp (str, "version"))
3007             version_flag = 1;
3008           else if (!strcmp (str, "w"))
3009             inhibit_warnings = 1;
3010           else if (!strcmp (str, "W"))
3011             {
3012               extra_warnings = 1;
3013               warn_uninitialized = 1;
3014             }
3015           else if (str[0] == 'W')
3016             {
3017               register char *p = &str[1];
3018               int found = 0;
3019
3020               /* Some kind of -W option.
3021                  P's value is the option sans `-W'.
3022                  Search for it in the table of options.  */
3023
3024               for (j = 0;
3025                    !found && j < sizeof (W_options) / sizeof (W_options[0]);
3026                    j++)
3027                 {
3028                   if (!strcmp (p, W_options[j].string))
3029                     {
3030                       *W_options[j].variable = W_options[j].on_value;
3031                       /* A goto here would be cleaner,
3032                          but breaks the vax pcc.  */
3033                       found = 1;
3034                     }
3035                   if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3036                       && ! strcmp (p+3, W_options[j].string))
3037                     {
3038                       *W_options[j].variable = ! W_options[j].on_value;
3039                       found = 1;
3040                     }
3041                 }
3042
3043               if (found)
3044                 ;
3045               else if (!strncmp (p, "id-clash-", 9))
3046                 {
3047                   char *endp = p + 9;
3048
3049                   while (*endp)
3050                     {
3051                       if (*endp >= '0' && *endp <= '9')
3052                         endp++;
3053                       else
3054                         {
3055                           error ("Invalid option `%s'", argv[i]);
3056                           goto id_clash_lose;
3057                         }
3058                     }
3059                   warn_id_clash = 1;
3060                   id_clash_len = atoi (str + 10);
3061                 id_clash_lose: ;
3062                 }
3063               else
3064                 error ("Invalid option `%s'", argv[i]);
3065             }
3066           else if (!strcmp (str, "p"))
3067             profile_flag = 1;
3068           else if (!strcmp (str, "a"))
3069             {
3070 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3071               warning ("`-a' option (basic block profile) not supported");
3072 #else
3073               profile_block_flag = 1;
3074 #endif
3075             }
3076           else if (str[0] == 'g')
3077             {
3078               char *p = str + 1;
3079               char *q;
3080               unsigned len;
3081               unsigned level;
3082
3083               while (*p && (*p < '0' || *p > '9'))
3084                 p++;
3085               len = p - str;
3086               q = p;
3087               while (*q && (*q >= '0' && *q <= '9'))
3088                 q++;
3089               if (*p)
3090                 level = atoi (p);
3091               else
3092                 level = 2;      /* default debugging info level */
3093               if (*q || level > 3)
3094                 {
3095                   warning ("invalid debug level specification in option: `-%s'",
3096                            str);
3097                   warning ("no debugging information will be generated");
3098                   level = 0;
3099                 }
3100
3101               /* If more than one debugging type is supported,
3102                  you must define PREFERRED_DEBUGGING_TYPE
3103                  to choose a format in a system-dependent way.  */
3104               /* This is one long line cause VAXC can't handle a \-newline.  */
3105 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3106 #ifdef PREFERRED_DEBUGGING_TYPE
3107               if (!strncmp (str, "ggdb", len))
3108                 write_symbols = PREFERRED_DEBUGGING_TYPE;
3109 #else /* no PREFERRED_DEBUGGING_TYPE */
3110 You Lose!  You must define PREFERRED_DEBUGGING_TYPE!
3111 #endif /* no PREFERRED_DEBUGGING_TYPE */
3112 #endif /* More than one debugger format enabled.  */
3113 #ifdef DBX_DEBUGGING_INFO
3114               if (write_symbols != NO_DEBUG)
3115                 ;
3116               else if (!strncmp (str, "ggdb", len))
3117                 write_symbols = DBX_DEBUG;
3118               else if (!strncmp (str, "gstabs", len))
3119                 write_symbols = DBX_DEBUG;
3120               else if (!strncmp (str, "gstabs+", len))
3121                 write_symbols = DBX_DEBUG;
3122
3123               /* Always enable extensions for -ggdb or -gstabs+, 
3124                  always disable for -gstabs.
3125                  For plain -g, use system-specific default.  */
3126               if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3127                   && len >= 2)
3128                 use_gnu_debug_info_extensions = 1;
3129               else if (write_symbols == DBX_DEBUG && !strcmp (str, "gstabs+"))
3130                 use_gnu_debug_info_extensions = 1;
3131               else if (write_symbols == DBX_DEBUG
3132                        && !strncmp (str, "gstabs", len) && len >= 2)
3133                 use_gnu_debug_info_extensions = 0;
3134               else
3135                 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3136 #endif /* DBX_DEBUGGING_INFO */
3137 #ifdef DWARF_DEBUGGING_INFO
3138               if (write_symbols != NO_DEBUG)
3139                 ;
3140               else if (!strncmp (str, "g", len))
3141                 write_symbols = DWARF_DEBUG;
3142               else if (!strncmp (str, "ggdb", len))
3143                 write_symbols = DWARF_DEBUG;
3144               else if (!strncmp (str, "gdwarf", len))
3145                 write_symbols = DWARF_DEBUG;
3146
3147               /* Always enable extensions for -ggdb or -gdwarf+, 
3148                  always disable for -gdwarf.
3149                  For plain -g, use system-specific default.  */
3150               if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3151                   && len >= 2)
3152                 use_gnu_debug_info_extensions = 1;
3153               else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3154                 use_gnu_debug_info_extensions = 1;
3155               else if (write_symbols == DWARF_DEBUG
3156                        && !strncmp (str, "gdwarf", len) && len >= 2)
3157                 use_gnu_debug_info_extensions = 0;
3158               else
3159                 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3160 #endif
3161 #ifdef SDB_DEBUGGING_INFO
3162               if (write_symbols != NO_DEBUG)
3163                 ;
3164               else if (!strncmp (str, "g", len))
3165                 write_symbols = SDB_DEBUG;
3166               else if (!strncmp (str, "gdb", len))
3167                 write_symbols = SDB_DEBUG;
3168               else if (!strncmp (str, "gcoff", len))
3169                 write_symbols = SDB_DEBUG;
3170 #endif /* SDB_DEBUGGING_INFO */
3171 #ifdef XCOFF_DEBUGGING_INFO
3172               if (write_symbols != NO_DEBUG)
3173                 ;
3174               else if (!strncmp (str, "g", len))
3175                 write_symbols = XCOFF_DEBUG;
3176               else if (!strncmp (str, "ggdb", len))
3177                 write_symbols = XCOFF_DEBUG;
3178               else if (!strncmp (str, "gxcoff", len))
3179                 write_symbols = XCOFF_DEBUG;
3180
3181               /* Always enable extensions for -ggdb or -gxcoff+,
3182                  always disable for -gxcoff.
3183                  For plain -g, use system-specific default.  */
3184               if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3185                   && len >= 2)
3186                 use_gnu_debug_info_extensions = 1;
3187               else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3188                 use_gnu_debug_info_extensions = 1;
3189               else if (write_symbols == XCOFF_DEBUG
3190                        && !strncmp (str, "gxcoff", len) && len >= 2)
3191                 use_gnu_debug_info_extensions = 0;
3192               else
3193                 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3194 #endif        
3195               if (write_symbols == NO_DEBUG)
3196                 warning ("`-%s' option not supported on this version of GCC", str);
3197               else if (level == 0)
3198                 write_symbols = NO_DEBUG;
3199               else
3200                 debug_info_level = (enum debug_info_level) level;
3201             }
3202           else if (!strcmp (str, "o"))
3203             {
3204               asm_file_name = argv[++i];
3205             }
3206           else if (str[0] == 'G')
3207             {
3208               g_switch_set = TRUE;
3209               g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3210             }
3211           else if (!strncmp (str, "aux-info", 8))
3212             {
3213               flag_gen_aux_info = 1;
3214               aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3215             }
3216           else
3217             error ("Invalid option `%s'", argv[i]);
3218         }
3219       else if (argv[i][0] == '+')
3220         error ("Invalid option `%s'", argv[i]);
3221       else
3222         filename = argv[i];
3223     }
3224
3225   /* Inlining does not work if not optimizing,
3226      so force it not to be done.  */
3227   if (optimize == 0)
3228     {
3229       flag_no_inline = 1;
3230       warn_inline = 0;
3231     }
3232
3233 #ifdef OVERRIDE_OPTIONS
3234   /* Some machines may reject certain combinations of options.  */
3235   OVERRIDE_OPTIONS;
3236 #endif
3237
3238   /* Unrolling all loops implies that standard loop unrolling must also
3239      be done.  */
3240   if (flag_unroll_all_loops)
3241     flag_unroll_loops = 1;
3242   /* Loop unrolling requires that strength_reduction be on also.  Silently
3243      turn on strength reduction here if it isn't already on.  Also, the loop
3244      unrolling code assumes that cse will be run after loop, so that must
3245      be turned on also.  */
3246   if (flag_unroll_loops)
3247     {
3248       flag_strength_reduce = 1;
3249       flag_rerun_cse_after_loop = 1;
3250     }
3251
3252   /* Warn about options that are not supported on this machine.  */
3253 #ifndef INSN_SCHEDULING
3254   if (flag_schedule_insns || flag_schedule_insns_after_reload)
3255     warning ("instruction scheduling not supported on this target machine");
3256 #endif
3257 #ifndef DELAY_SLOTS
3258   if (flag_delayed_branch)
3259     warning ("this target machine does not have delayed branches");
3260 #endif
3261
3262   /* If we are in verbose mode, write out the version and maybe all the
3263      option flags in use.  */
3264   if (version_flag)
3265     {
3266       fprintf (stderr, "%s version %s", language_string, version_string);
3267 #ifdef TARGET_VERSION
3268       TARGET_VERSION;
3269 #endif
3270 #ifdef __GNUC__
3271 #ifndef __VERSION__
3272 #define __VERSION__ "[unknown]"
3273 #endif
3274       fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3275 #else
3276       fprintf (stderr, " compiled by CC.\n");
3277 #endif
3278       if (! quiet_flag)
3279         print_switch_values ();
3280     }
3281
3282   /* Now that register usage is specified, convert it to HARD_REG_SETs.  */
3283   init_reg_sets_1 ();
3284
3285   compile_file (filename);
3286
3287 #ifndef OS2
3288 #ifndef VMS
3289   if (flag_print_mem)
3290     {
3291       char *lim = (char *) sbrk (0);
3292
3293       fprintf (stderr, "Data size %d.\n",
3294                lim - (char *) &environ);
3295       fflush (stderr);
3296
3297 #ifdef USG
3298       system ("ps -l 1>&2");
3299 #else /* not USG */
3300       system ("ps v");
3301 #endif /* not USG */
3302     }
3303 #endif /* not VMS */
3304 #endif /* not OS2 */
3305
3306   if (errorcount)
3307     exit (FATAL_EXIT_CODE);
3308   if (sorrycount)
3309     exit (FATAL_EXIT_CODE);
3310   exit (SUCCESS_EXIT_CODE);
3311   return 34;
3312 }
3313 \f
3314 /* Decode -m switches.  */
3315
3316 /* Here is a table, controlled by the tm.h file, listing each -m switch
3317    and which bits in `target_switches' it should set or clear.
3318    If VALUE is positive, it is bits to set.
3319    If VALUE is negative, -VALUE is bits to clear.
3320    (The sign bit is not used so there is no confusion.)  */
3321
3322 struct {char *name; int value;} target_switches []
3323   = TARGET_SWITCHES;
3324
3325 /* This table is similar, but allows the switch to have a value.  */
3326
3327 #ifdef TARGET_OPTIONS
3328 struct {char *prefix; char ** variable;} target_options []
3329   = TARGET_OPTIONS;
3330 #endif
3331
3332 /* Decode the switch -mNAME.  */
3333
3334 void
3335 set_target_switch (name)
3336      char *name;
3337 {
3338   register int j;
3339   int valid = 0;
3340
3341   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3342     if (!strcmp (target_switches[j].name, name))
3343       {
3344         if (target_switches[j].value < 0)
3345           target_flags &= ~-target_switches[j].value;
3346         else
3347           target_flags |= target_switches[j].value;
3348         valid = 1;
3349       }
3350
3351 #ifdef TARGET_OPTIONS
3352   if (!valid)
3353     for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3354       {
3355         int len = strlen (target_options[j].prefix);
3356         if (!strncmp (target_options[j].prefix, name, len))
3357           {
3358             *target_options[j].variable = name + len;
3359             valid = 1;
3360           }
3361       }
3362 #endif
3363
3364   if (!valid)
3365     error ("Invalid option `%s'", name);
3366 }
3367 \f
3368 /* Variable used for communication between the following two routines.  */
3369
3370 static int line_position;
3371
3372 /* Print an option value and adjust the position in the line.  */
3373
3374 static void
3375 print_single_switch (type, name)
3376      char *type, *name;
3377 {
3378   fprintf (stderr, " %s%s", type, name);
3379
3380   line_position += strlen (type) + strlen (name) + 1;
3381
3382   if (line_position > 65)
3383     {
3384       fprintf (stderr, "\n\t");
3385       line_position = 8;
3386     }
3387 }
3388      
3389 /* Print default target switches for -version.  */
3390
3391 static void
3392 print_switch_values ()
3393 {
3394   register int j;
3395
3396   fprintf (stderr, "enabled:");
3397   line_position = 8;
3398
3399   for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3400     if (*f_options[j].variable == f_options[j].on_value)
3401       print_single_switch ("-f", f_options[j].string);
3402
3403   for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
3404     if (*W_options[j].variable == W_options[j].on_value)
3405       print_single_switch ("-W", W_options[j].string);
3406
3407   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3408     if (target_switches[j].name[0] != '\0'
3409         && target_switches[j].value > 0
3410         && ((target_switches[j].value & target_flags)
3411             == target_switches[j].value))
3412       print_single_switch ("-m", target_switches[j].name);
3413
3414   fprintf (stderr, "\n");
3415 }