OSDN Git Service

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