OSDN Git Service

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