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