OSDN Git Service

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