toplev.c revision 50615
14Srgrimes/* Top level of GNU C compiler
24Srgrimes   Copyright (C) 1987, 88, 89, 92-7, 1998 Free Software Foundation, Inc.
34Srgrimes
44SrgrimesThis file is part of GNU CC.
54Srgrimes
64SrgrimesGNU CC is free software; you can redistribute it and/or modify
74Srgrimesit under the terms of the GNU General Public License as published by
84Srgrimesthe Free Software Foundation; either version 2, or (at your option)
94Srgrimesany later version.
104Srgrimes
114SrgrimesGNU CC is distributed in the hope that it will be useful,
124Srgrimesbut WITHOUT ANY WARRANTY; without even the implied warranty of
134SrgrimesMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
144SrgrimesGNU General Public License for more details.
154Srgrimes
164SrgrimesYou should have received a copy of the GNU General Public License
174Srgrimesalong with GNU CC; see the file COPYING.  If not, write to
184Srgrimesthe Free Software Foundation, 59 Temple Place - Suite 330,
194SrgrimesBoston, MA 02111-1307, USA.  */
204Srgrimes
214Srgrimes/* This is the top level of cc1/c++.
224Srgrimes   It parses command args, opens files, invokes the various passes
234Srgrimes   in the proper order, and counts the time used by each.
244Srgrimes   Error messages and low-level interface to malloc also handled here.  */
254Srgrimes
264Srgrimes#include "config.h"
274Srgrimes#ifdef __STDC__
284Srgrimes#include <stdarg.h>
294Srgrimes#else
304Srgrimes#include <varargs.h>
314Srgrimes#endif
324Srgrimes#undef FLOAT /* This is for hpux. They should change hpux.  */
334Srgrimes#undef FFS  /* Some systems define this in param.h.  */
344Srgrimes#include "system.h"
354Srgrimes#include <signal.h>
36556Srgrimes#include <setjmp.h>
37757Sdg#include <sys/stat.h>
384Srgrimes
394Srgrimes#ifdef HAVE_SYS_RESOURCE_H
404Srgrimes# include <sys/resource.h>
41757Sdg#endif
42757Sdg
43757Sdg#ifdef HAVE_SYS_TIMES_H
44757Sdg# include <sys/times.h>
45757Sdg#endif
464Srgrimes
474Srgrimes#include "input.h"
48757Sdg#include "tree.h"
49556Srgrimes#include "rtl.h"
50757Sdg#include "flags.h"
51757Sdg#include "insn-attr.h"
52757Sdg#include "insn-codes.h"
534Srgrimes#include "insn-config.h"
54757Sdg#include "recog.h"
554Srgrimes#include "defaults.h"
56757Sdg#include "output.h"
57757Sdg#include "except.h"
58757Sdg#include "toplev.h"
594Srgrimes
60757Sdg#ifdef DWARF_DEBUGGING_INFO
614Srgrimes#include "dwarfout.h"
62757Sdg#endif
634Srgrimes
644Srgrimes#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
65757Sdg#include "dwarf2out.h"
66757Sdg#endif
674Srgrimes
684Srgrimes#if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
694Srgrimes#include "dbxout.h"
704Srgrimes#endif
714Srgrimes
72200Sdg#ifdef SDB_DEBUGGING_INFO
734Srgrimes#include "sdbout.h"
744Srgrimes#endif
754Srgrimes
76592Srgrimes#ifdef XCOFF_DEBUGGING_INFO
77592Srgrimes#include "xcoffout.h"
78592Srgrimes#endif
79757Sdg
80592Srgrimes#ifdef VMS
81757Sdg/* The extra parameters substantially improve the I/O performance.  */
82608Srgrimesstatic FILE *
834Srgrimesvms_fopen (fname, type)
844Srgrimes     char * fname;
854Srgrimes     char * type;
864Srgrimes{
874Srgrimes  /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
88592Srgrimes     fixed arguments, which matches ANSI's specification but not VAXCRTL's
89592Srgrimes     pre-ANSI implementation.  This hack circumvents the mismatch problem.  */
90592Srgrimes  FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
91757Sdg
924Srgrimes  if (*type == 'w')
934Srgrimes    return (*vmslib_fopen) (fname, type, "mbc=32",
944Srgrimes			    "deq=64", "fop=tef", "shr=nil");
954Srgrimes  else
964Srgrimes    return (*vmslib_fopen) (fname, type, "mbc=32");
974Srgrimes}
98570Srgrimes#define fopen vms_fopen
99134Sdg#endif	/* VMS */
1004Srgrimes
101556Srgrimes#ifndef DEFAULT_GDB_EXTENSIONS
102556Srgrimes#define DEFAULT_GDB_EXTENSIONS 1
103556Srgrimes#endif
104556Srgrimes
105556Srgrimes/* If more than one debugging type is supported, you must define
106757Sdg   PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
107134Sdg
108592Srgrimes   This is one long line cause VAXC can't handle a \-newline.  */
109134Sdg#if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
110592Srgrimes#ifndef PREFERRED_DEBUGGING_TYPE
111757SdgYou Lose!  You must define PREFERRED_DEBUGGING_TYPE!
112757Sdg#endif /* no PREFERRED_DEBUGGING_TYPE */
113757Sdg#else /* Only one debugging format supported.  Define PREFERRED_DEBUGGING_TYPE
114757Sdg	 so the following code needn't care.  */
1154Srgrimes#ifdef DBX_DEBUGGING_INFO
116757Sdg#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
117757Sdg#endif
118757Sdg#ifdef SDB_DEBUGGING_INFO
119592Srgrimes#define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
120757Sdg#endif
121757Sdg#ifdef DWARF_DEBUGGING_INFO
1224Srgrimes#define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
123757Sdg#endif
124757Sdg#ifdef DWARF2_DEBUGGING_INFO
125718Swollman#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
126757Sdg#endif
127757Sdg#ifdef XCOFF_DEBUGGING_INFO
128134Sdg#define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
129757Sdg#endif
130757Sdg#endif /* More than one debugger format enabled.  */
131757Sdg
132757Sdg/* If still not defined, must have been because no debugging formats
133718Swollman   are supported.  */
134757Sdg#ifndef PREFERRED_DEBUGGING_TYPE
1354Srgrimes#define PREFERRED_DEBUGGING_TYPE NO_DEBUG
1364Srgrimes#endif
137134Sdg
138134Sdgextern int rtx_equal_function_value_matters;
139556Srgrimes
140556Srgrimes#if ! (defined (VMS) || defined (OS2))
141556Srgrimesextern char **environ;
1424Srgrimes#endif
143134Sdgextern char *version_string, *language_string;
144134Sdg
145200Sdg/* Carry information from ASM_DECLARE_OBJECT_NAME
146200Sdg   to ASM_FINISH_DECLARE_OBJECT.  */
147134Sdg
148200Sdgextern int size_directive_output;
149757Sdgextern tree last_assemble_variable_decl;
1504Srgrimes
151757Sdgextern char *init_parse PVPROTO((char *));
1524Srgrimesextern void finish_parse ();
1534Srgrimesextern void init_decl_processing ();
154556Srgrimesextern void init_obstacks ();
1554Srgrimesextern void init_tree_codes ();
1564Srgrimesextern void init_rtl ();
1574Srgrimesextern void init_regs ();
1584Srgrimesextern void init_optabs ();
1594Srgrimesextern void init_stmt ();
160570Srgrimesextern void init_reg_sets ();
1614Srgrimesextern void dump_flow_info ();
162570Srgrimesextern void dump_sched_info ();
1634Srgrimesextern void dump_local_alloc ();
164570Srgrimesextern void regset_release_memory ();
165556Srgrimes
166570Srgrimesextern void print_rtl ();
167570Srgrimesextern void print_rtl_with_bb ();
1684Srgrimes
169556Srgrimesvoid rest_of_decl_compilation ();
170556Srgrimesvoid error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
171556Srgrimesvoid error_with_decl PVPROTO((tree decl, char *s, ...));
172556Srgrimesvoid error PVPROTO((char *s, ...));
173556Srgrimesvoid fatal PVPROTO((char *s, ...));
174556Srgrimesvoid warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
175556Srgrimesvoid warning_with_decl PVPROTO((tree decl, char *s, ...));
176556Srgrimesvoid warning PVPROTO((char *s, ...));
177556Srgrimesvoid pedwarn PVPROTO((char *s, ...));
178556Srgrimesvoid pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
179556Srgrimesvoid pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
180556Srgrimesvoid sorry PVPROTO((char *s, ...));
181556Srgrimesvoid really_sorry PVPROTO((char *s, ...));
182556Srgrimesvoid fancy_abort ();
183556Srgrimesvoid set_target_switch ();
184556Srgrimesstatic char *decl_name PROTO((tree, int));
185556Srgrimesstatic void vmessage PROTO((char *, char *, va_list));
186570Srgrimesstatic void v_message_with_file_and_line PROTO((char *, int, char *,
187556Srgrimes						char *, va_list));
188570Srgrimesstatic void v_message_with_decl PROTO((tree, char *, char *, va_list));
189556Srgrimesstatic void file_and_line_for_asm PROTO((rtx, char **, int *));
190556Srgrimesstatic void v_error_with_file_and_line PROTO((char *, int, char *, va_list));
1914Srgrimesstatic void v_error_with_decl PROTO((tree, char *, va_list));
1924Srgrimesstatic void v_error_for_asm PROTO((rtx, char *, va_list));
1934Srgrimesstatic void verror PROTO((char *, va_list));
1944Srgrimesstatic void vfatal PROTO((char *, va_list));
1954Srgrimesstatic void v_warning_with_file_and_line PROTO ((char *, int, char *, va_list));
1964Srgrimesstatic void v_warning_with_decl PROTO((tree, char *, va_list));
1974Srgrimesstatic void v_warning_for_asm PROTO((rtx, char *, va_list));
1984Srgrimesstatic void vwarning PROTO((char *, va_list));
1994Srgrimesstatic void vpedwarn PROTO((char *, va_list));
2004Srgrimesstatic void v_pedwarn_with_decl PROTO((tree, char *, va_list));
2014Srgrimesstatic void v_pedwarn_with_file_and_line PROTO((char *, int, char *, va_list));
2024Srgrimesstatic void vsorry PROTO((char *, va_list));
2034Srgrimesstatic void v_really_sorry PROTO((char *, va_list));
2044Srgrimesstatic void float_signal PROTO((int));
205757Sdgstatic void pipe_closed PROTO((int));
2064Srgrimesstatic void output_lang_identify PROTO((FILE *));
207570Srgrimesstatic void open_dump_file PROTO((char *, char *));
208570Srgrimesstatic void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
209570Srgrimesstatic void dump_rtl PROTO((char *, tree, void (*) (FILE *, rtx), rtx));
210570Srgrimesstatic void clean_dump_file PROTO((char *));
211757Sdgstatic void compile_file PROTO((char *));
212570Srgrimesstatic void display_help PROTO ((void));
213570Srgrimes
2144Srgrimesvoid print_version ();
215570Srgrimesint print_single_switch ();
216757Sdgvoid print_switch_values ();
2174Srgrimes/* Length of line when printing switch values.  */
218757Sdg#define MAX_LINE 75
219757Sdg
2204Srgrimes/* Name of program invoked, sans directories.  */
221757Sdg
222570Srgrimeschar *progname;
223757Sdg
224757Sdg/* Copy of arguments to main.  */
2254Srgrimesint save_argc;
2264Srgrimeschar **save_argv;
2274Srgrimes
2284Srgrimes/* Name of current original source file (what was input to cpp).
229608Srgrimes   This comes from each #-command in the actual input.  */
230757Sdg
231757Sdgchar *input_filename;
232757Sdg
233757Sdg/* Name of top-level original source file (what was input to cpp).
234757Sdg   This comes from the #-command at the beginning of the actual input.
235757Sdg   If there isn't any there, then this is the cc1 input file name.  */
236757Sdg
237757Sdgchar *main_input_filename;
238757Sdg
239608Srgrimes/* Current line number in real source file.  */
240757Sdg
241757Sdgint lineno;
242757Sdg
243757Sdg/* Stack of currently pending input files.  */
244757Sdg
245757Sdgstruct file_stack *input_file_stack;
246757Sdg
247757Sdg/* Incremented on each change to input_file_stack.  */
248608Srgrimesint input_file_stack_tick;
249608Srgrimes
250757Sdg/* FUNCTION_DECL for function now being parsed or compiled.  */
251757Sdg
252757Sdgextern tree current_function_decl;
253757Sdg
254757Sdg/* Name to use as base of names for dump output files.  */
255757Sdg
256757Sdgchar *dump_base_name;
257757Sdg
258757Sdg/* Bit flags that specify the machine subtype we are compiling for.
259570Srgrimes   Bits are tested using macros TARGET_... defined in the tm.h file
2604Srgrimes   and set by `-m...' switches.  Must be defined in rtlanal.c.  */
261592Srgrimes
262592Srgrimesextern int target_flags;
263592Srgrimes
264592Srgrimes/* Flags saying which kinds of debugging dump have been requested.  */
265592Srgrimes
266592Srgrimesint rtl_dump = 0;
2674Srgrimesint rtl_dump_and_exit = 0;
2684Srgrimesint jump_opt_dump = 0;
269570Srgrimesint addressof_dump = 0;
2704Srgrimesint cse_dump = 0;
2714Srgrimesint gcse_dump = 0;
2724Srgrimesint loop_dump = 0;
2734Srgrimesint cse2_dump = 0;
2744Srgrimesint branch_prob_dump = 0;
2754Srgrimesint flow_dump = 0;
2764Srgrimesint combine_dump = 0;
2774Srgrimesint regmove_dump = 0;
278757Sdgint sched_dump = 0;
279757Sdgint local_reg_dump = 0;
280757Sdgint global_reg_dump = 0;
281757Sdgint sched2_dump = 0;
282757Sdgint jump2_opt_dump = 0;
283200Sdg#ifdef DELAY_SLOTS
284200Sdgint dbr_sched_dump = 0;
285200Sdg#endif
286757Sdgint flag_print_asm_name = 0;
287757Sdg#ifdef STACK_REGS
288757Sdgint stack_reg_dump = 0;
289757Sdg#endif
2904Srgrimes#ifdef MACHINE_DEPENDENT_REORG
2914Srgrimesint mach_dep_reorg_dump = 0;
292757Sdg#endif
293757Sdg
294757Sdg/* Name for output file of assembly code, specified with -o.  */
295757Sdg
296757Sdgchar *asm_file_name;
297757Sdg
298757Sdg/* Value of the -G xx switch, and whether it was passed or not.  */
299757Sdgint g_switch_value;
300757Sdgint g_switch_set;
301757Sdg
302757Sdg/* Type(s) of debugging information we are producing (if any).
303757Sdg   See flags.h for the definitions of the different possible
304757Sdg   types of debugging information.  */
305757Sdgenum debug_info_type write_symbols = NO_DEBUG;
306757Sdg
307757Sdg/* Level of debugging information we are producing.  See flags.h
308757Sdg   for the definitions of the different possible levels.  */
309757Sdgenum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
310757Sdg
311757Sdg/* Nonzero means use GNU-only extensions in the generated symbolic
312757Sdg   debugging information.  */
313757Sdg/* Currently, this only has an effect when write_symbols is set to
314757Sdg   DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG.  */
315757Sdgint use_gnu_debug_info_extensions = 0;
316757Sdg
317757Sdg/* Nonzero means do optimizations.  -O.
318757Sdg   Particular numeric values stand for particular amounts of optimization;
319757Sdg   thus, -O2 stores 2 here.  However, the optimizations beyond the basic
320757Sdg   ones are not controlled directly by this variable.  Instead, they are
321757Sdg   controlled by individual `flag_...' variables that are defaulted
3224Srgrimes   based on this variable.  */
3234Srgrimes
324757Sdgint optimize = 0;
325757Sdg
326757Sdg/* Nonzero means optimize for size.  -Os.
327757Sdg   The only valid values are zero and non-zero. When optimize_size is
328757Sdg   non-zero, optimize defaults to 2, but certain individual code
3294Srgrimes   bloating optimizations are disabled.  */
3304Srgrimes
3314Srgrimesint optimize_size = 0;
3324Srgrimes
333757Sdg/* Number of error messages and warning messages so far.  */
334757Sdg
335757Sdgint errorcount = 0;
336757Sdgint warningcount = 0;
337757Sdgint sorrycount = 0;
338757Sdg
339757Sdg/* Pointer to function to compute the name to use to print a declaration.
3404Srgrimes   DECL is the declaration in question.
3414Srgrimes   VERBOSITY determines what information will be printed:
3424Srgrimes     0: DECL_NAME, demangled as necessary.
343757Sdg     1: and scope information.
3444Srgrimes     2: and any other information that might be interesting, such as function
3454Srgrimes        parameter types in C++.  */
346757Sdg
347757Sdgchar *(*decl_printable_name) (/* tree decl, int verbosity */);
348757Sdg
3494Srgrimes/* Pointer to function to compute rtl for a language-specific tree code.  */
350757Sdg
351757Sdgstruct rtx_def *(*lang_expand_expr) ();
352757Sdg
3534Srgrimes/* Pointer to function to finish handling an incomplete decl at the
3544Srgrimes   end of compilation.  */
3554Srgrimes
356757Sdgvoid (*incomplete_decl_finalize_hook) () = 0;
357757Sdg
358757Sdg/* Highest label number used at the end of reload.  */
3594Srgrimes
3604Srgrimesint max_label_num_after_reload;
361757Sdg
362757Sdg/* Nonzero if generating code to do profiling.  */
363757Sdg
3644Srgrimesint profile_flag = 0;
365757Sdg
3664Srgrimes/* Nonzero if generating code to do profiling on a line-by-line basis.  */
3674Srgrimes
368757Sdgint profile_block_flag;
3694Srgrimes
370570Srgrimes/* Nonzero if generating code to profile program flow graph arcs.  */
3714Srgrimes
3724Srgrimesint profile_arc_flag = 0;
3734Srgrimes
3744Srgrimes/* Nonzero if generating info for gcov to calculate line test coverage.  */
3754Srgrimes
376757Sdgint flag_test_coverage = 0;
377570Srgrimes
3784Srgrimes/* Nonzero indicates that branch taken probabilities should be calculated.  */
3794Srgrimes
380757Sdgint flag_branch_probabilities = 0;
3814Srgrimes
382570Srgrimes/* Nonzero for -pedantic switch: warn about anything
3834Srgrimes   that standard spec forbids.  */
3844Srgrimes
3854Srgrimesint pedantic = 0;
386757Sdg
387757Sdg/* Temporarily suppress certain warnings.
3884Srgrimes   This is set while reading code from a system header file.  */
389570Srgrimes
3904Srgrimesint in_system_header = 0;
391570Srgrimes
392757Sdg/* Nonzero means do stupid register allocation.
3934Srgrimes   Currently, this is 1 if `optimize' is 0.  */
394570Srgrimes
3954Srgrimesint obey_regdecls = 0;
396570Srgrimes
3974Srgrimes/* Don't print functions as they are compiled and don't print
398570Srgrimes   times taken by the various passes.  -quiet.  */
3994Srgrimes
4004Srgrimesint quiet_flag = 0;
401757Sdg
4024Srgrimes/* -f flags.  */
4034Srgrimes
4044Srgrimes/* Nonzero means `char' should be signed.  */
4054Srgrimes
4064Srgrimesint flag_signed_char;
4074Srgrimes
4084Srgrimes/* Nonzero means give an enum type only as many bytes as it needs.  */
409757Sdg
4104Srgrimesint flag_short_enums;
411592Srgrimes
412757Sdg/* Nonzero for -fcaller-saves: allocate values in regs that need to
413570Srgrimes   be saved across function calls, if that produces overall better code.
414757Sdg   Optional now, so people can test it.  */
415757Sdg
416200Sdg#ifdef DEFAULT_CALLER_SAVES
417200Sdgint flag_caller_saves = 1;
418200Sdg#else
419200Sdgint flag_caller_saves = 0;
420200Sdg#endif
421200Sdg
4224Srgrimes/* Nonzero if structures and unions should be returned in memory.
423570Srgrimes
4244Srgrimes   This should only be defined if compatibility with another compiler or
425757Sdg   with an ABI is needed, because it results in slower code.  */
4264Srgrimes
427757Sdg#ifndef DEFAULT_PCC_STRUCT_RETURN
4284Srgrimes#define DEFAULT_PCC_STRUCT_RETURN 1
429757Sdg#endif
4304Srgrimes
4314Srgrimes/* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
432570Srgrimes
4334Srgrimesint flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
434757Sdg
435757Sdg/* Nonzero for -fforce-mem: load memory value into a register
436592Srgrimes   before arithmetic on it.  This makes better cse but slower compilation.  */
437757Sdg
438757Sdgint flag_force_mem = 0;
439757Sdg
440757Sdg/* Nonzero for -fforce-addr: load memory address into a register before
441570Srgrimes   reference to memory.  This makes better cse but slower compilation.  */
4424Srgrimes
4434Srgrimesint flag_force_addr = 0;
4444Srgrimes
445757Sdg/* Nonzero for -fdefer-pop: don't pop args after each function call;
446570Srgrimes   instead save them up to pop many calls' args with one insns.  */
447757Sdg
4484Srgrimesint flag_defer_pop = 0;
449570Srgrimes
450570Srgrimes/* Nonzero for -ffloat-store: don't allocate floats and doubles
4514Srgrimes   in extended-precision registers.  */
452757Sdg
4534Srgrimesint flag_float_store = 0;
4544Srgrimes
455757Sdg/* Nonzero for -fcse-follow-jumps:
4564Srgrimes   have cse follow jumps to do a more extensive job.  */
4574Srgrimes
458757Sdgint flag_cse_follow_jumps;
459757Sdg
4604Srgrimes/* Nonzero for -fcse-skip-blocks:
4614Srgrimes   have cse follow a branch around a block.  */
4624Srgrimesint flag_cse_skip_blocks;
4634Srgrimes
4644Srgrimes/* Nonzero for -fexpensive-optimizations:
4654Srgrimes   perform miscellaneous relatively-expensive optimizations.  */
466757Sdgint flag_expensive_optimizations;
4674Srgrimes
468608Srgrimes/* Nonzero for -fthread-jumps:
469608Srgrimes   have jump optimize output of loop.  */
470608Srgrimes
471757Sdgint flag_thread_jumps;
472608Srgrimes
473757Sdg/* Nonzero enables strength-reduction in loop.c.  */
474757Sdg
475200Sdgint flag_strength_reduce = 0;
4764Srgrimes
477757Sdg/* Nonzero enables loop unrolling in unroll.c.  Only loops for which the
4784Srgrimes   number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
4794Srgrimes   UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
480134Sdg   unrolled.  */
481570Srgrimes
482570Srgrimesint flag_unroll_loops;
483134Sdg
484134Sdg/* Nonzero enables loop unrolling in unroll.c.  All loops are unrolled.
485134Sdg   This is generally not a win.  */
486134Sdg
487570Srgrimesint flag_unroll_all_loops;
4884Srgrimes
4894Srgrimes/* Nonzero forces all invariant computations in loops to be moved
490570Srgrimes   outside the loop. */
491757Sdg
492757Sdgint flag_move_all_movables = 0;
493757Sdg
494757Sdg/* Nonzero forces all general induction variables in loops to be
4954Srgrimes   strength reduced. */
4964Srgrimes
497757Sdgint flag_reduce_all_givs = 0;
498757Sdg
499757Sdg/* Nonzero to perform full register move optimization passes.  This is the
5004Srgrimes   default for -O2.  */
501757Sdg
5024Srgrimesint flag_regmove = 0;
5034Srgrimes
5044Srgrimes/* Nonzero for -fwritable-strings:
5054Srgrimes   store string constants in data segment and don't uniquize them.  */
5064Srgrimes
5074Srgrimesint flag_writable_strings = 0;
5084Srgrimes
509134Sdg/* Nonzero means don't put addresses of constant functions in registers.
510134Sdg   Used for compiling the Unix kernel, where strange substitutions are
511200Sdg   done on the assembly output.  */
5124Srgrimes
513200Sdgint flag_no_function_cse = 0;
514757Sdg
515200Sdg/* Nonzero for -fomit-frame-pointer:
516757Sdg   don't make a frame pointer in simple functions that don't require one.  */
5174Srgrimes
5184Srgrimesint flag_omit_frame_pointer = 0;
519757Sdg
5204Srgrimes/* Nonzero means place each function into its own section on those platforms
521570Srgrimes   which support arbitrary section names and unlimited numbers of sections.  */
5224Srgrimes
5234Srgrimesint flag_function_sections = 0;
524757Sdg
5254Srgrimes/* Nonzero to inhibit use of define_optimization peephole opts.  */
526757Sdg
527200Sdgint flag_no_peephole = 0;
528757Sdg
5294Srgrimes/* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
530200Sdg   operations in the interest of optimization.  For example it allows
531570Srgrimes   GCC to assume arguments to sqrt are nonnegative numbers, allowing
532757Sdg   faster code for sqrt to be generated.  */
533757Sdg
534757Sdgint flag_fast_math = 0;
535757Sdg
5364Srgrimes/* Nonzero means all references through pointers are volatile.  */
5374Srgrimes
5384Srgrimesint flag_volatile;
5394Srgrimes
5404Srgrimes/* Nonzero means treat all global and extern variables as global.  */
5414Srgrimes
542757Sdgint flag_volatile_global;
543757Sdg
5444Srgrimes/* Nonzero means just do syntax checking; don't output anything.  */
5454Srgrimes
5464Srgrimesint flag_syntax_only = 0;
5474Srgrimes
5484Srgrimes/* Nonzero means perform global cse.  */
5494Srgrimes
5504Srgrimesstatic int flag_gcse;
551200Sdg
552592Srgrimes/* Nonzero means to rerun cse after loop optimization.  This increases
553757Sdg   compilation time about 20% and picks up a few more common expressions.  */
554757Sdg
5554Srgrimesstatic int flag_rerun_cse_after_loop;
556757Sdg
557757Sdg/* Nonzero means to assume that a structure or an array reference at
558757Sdg   a varying address cannot alias a scalar at a fixed address. */
559757Sdg
5604Srgrimesint flag_structure_noalias = 0;
5614Srgrimes
5624Srgrimes/* Nonzero means to run loop optimizations twice.  */
5634Srgrimes
564int flag_rerun_loop_opt;
565
566/* Nonzero for -finline-functions: ok to inline functions that look like
567   good inline candidates.  */
568
569int flag_inline_functions;
570
571/* Nonzero for -fkeep-inline-functions: even if we make a function
572   go inline everywhere, keep its definition around for debugging
573   purposes.  */
574
575int flag_keep_inline_functions;
576
577/* Nonzero means that functions will not be inlined.  */
578
579int flag_no_inline;
580
581/* Nonzero means that we should emit static const variables
582   regardless of whether or not optimization is turned on.  */
583
584int flag_keep_static_consts = 1;
585
586/* Nonzero means we should be saving declaration info into a .X file.  */
587
588int flag_gen_aux_info = 0;
589
590/* Specified name of aux-info file.  */
591
592static char *aux_info_file_name;
593
594/* Nonzero means make the text shared if supported.  */
595
596int flag_shared_data;
597
598/* Nonzero means schedule into delayed branch slots if supported.  */
599
600int flag_delayed_branch;
601
602/* Nonzero if we are compiling pure (sharable) code.
603   Value is 1 if we are doing reasonable (i.e. simple
604   offset into offset table) pic.  Value is 2 if we can
605   only perform register offsets.  */
606
607int flag_pic;
608
609/* Nonzero means generate extra code for exception handling and enable
610   exception handling.  */
611
612int flag_exceptions;
613
614/* Nonzero means use the new model for exception handling. Replaces
615   -DNEW_EH_MODEL as a compile option. */
616
617int flag_new_exceptions = 0;
618
619/* Nonzero means don't place uninitialized global data in common storage
620   by default.  */
621
622int flag_no_common;
623
624/* Nonzero means pretend it is OK to examine bits of target floats,
625   even if that isn't true.  The resulting code will have incorrect constants,
626   but the same series of instructions that the native compiler would make.  */
627
628int flag_pretend_float;
629
630/* Nonzero means change certain warnings into errors.
631   Usually these are warnings about failure to conform to some standard.  */
632
633int flag_pedantic_errors = 0;
634
635/* flag_schedule_insns means schedule insns within basic blocks (before
636   local_alloc).
637   flag_schedule_insns_after_reload means schedule insns after
638   global_alloc.  */
639
640int flag_schedule_insns = 0;
641int flag_schedule_insns_after_reload = 0;
642
643#ifdef HAIFA
644/* The following flags have effect only for scheduling before register
645   allocation:
646
647   flag_schedule_interblock means schedule insns accross basic blocks.
648   flag_schedule_speculative means allow speculative motion of non-load insns.
649   flag_schedule_speculative_load means allow speculative motion of some
650   load insns.
651   flag_schedule_speculative_load_dangerous allows speculative motion of more
652   load insns.  */
653
654int flag_schedule_interblock = 1;
655int flag_schedule_speculative = 1;
656int flag_schedule_speculative_load = 0;
657int flag_schedule_speculative_load_dangerous = 0;
658
659/* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
660   by a cheaper branch, on a count register. */
661int flag_branch_on_count_reg;
662#endif  /* HAIFA */
663
664
665/* -finhibit-size-directive inhibits output of .size for ELF.
666   This is used only for compiling crtstuff.c,
667   and it may be extended to other effects
668   needed for crtstuff.c on other systems.  */
669int flag_inhibit_size_directive = 0;
670
671/* -fverbose-asm causes extra commentary information to be produced in
672   the generated assembly code (to make it more readable).  This option
673   is generally only of use to those who actually need to read the
674   generated assembly code (perhaps while debugging the compiler itself).
675   -fno-verbose-asm, the default, causes the extra information
676   to be omitted and is useful when comparing two assembler files.  */
677
678int flag_verbose_asm = 0;
679
680/* -dA causes debug commentary information to be produced in
681   the generated assembly code (to make it more readable).  This option
682   is generally only of use to those who actually need to read the
683   generated assembly code (perhaps while debugging the compiler itself).
684   Currently, this switch is only used by dwarfout.c; however, it is intended
685   to be a catchall for printing debug information in the assembler file.  */
686
687int flag_debug_asm = 0;
688
689/* -fgnu-linker specifies use of the GNU linker for initializations.
690   (Or, more generally, a linker that handles initializations.)
691   -fno-gnu-linker says that collect2 will be used.  */
692#ifdef USE_COLLECT2
693int flag_gnu_linker = 0;
694#else
695int flag_gnu_linker = 1;
696#endif
697
698/* Tag all structures with __attribute__(packed) */
699int flag_pack_struct = 0;
700
701/* Nonzero means that -Wformat accepts certain system-dependent formats.  */
702
703int flag_format_extensions = 0;
704
705/* Emit code to check for stack overflow; also may cause large objects
706   to be allocated dynamically.  */
707int flag_stack_check;
708
709/* -fcheck-memory-usage causes extra code to be generated in order to check
710   memory accesses.  This is used by a detector of bad memory accesses such
711   as Checker.  */
712int flag_check_memory_usage = 0;
713
714/* -fprefix-function-name causes function name to be prefixed.  This
715   can be used with -fcheck-memory-usage to isolate code compiled with
716   -fcheck-memory-usage.  */
717int flag_prefix_function_name = 0;
718
719/* 0 if pointer arguments may alias each other.  True in C.
720   1 if pointer arguments may not alias each other but may alias
721   global variables.
722   2 if pointer arguments may not alias each other and may not
723   alias global variables.  True in Fortran.
724   This defaults to 0 for C.  */
725int flag_argument_noalias = 0;
726
727/* Nonzero if we should do (language-dependent) alias analysis.
728   Typically, this analysis will assume that expressions of certain
729   types do not alias expressions of certain other types.  Only used
730   if alias analysis (in general) is enabled.  */
731int flag_strict_aliasing = 0;
732
733extern int flag_dump_unnumbered;
734
735
736/* Table of supported debugging formats.  */
737static struct
738{
739  char * arg;
740  /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
741     constant expression, we use NO_DEBUG in its place.  */
742  enum debug_info_type debug_type;
743  int use_extensions_p;
744  char * description;
745} *da,
746debug_args[] =
747{
748  { "g",    NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
749    "Generate default debug format output" },
750  { "ggdb", NO_DEBUG, 1, "Generate default extended debug format output" },
751#ifdef DBX_DEBUGGING_INFO
752  { "gstabs",  DBX_DEBUG, 0, "Generate STABS format debug output" },
753  { "gstabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
754#endif
755#ifdef DWARF_DEBUGGING_INFO
756  { "gdwarf",  DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
757  { "gdwarf+", DWARF_DEBUG, 1,
758    "Generated extended DWARF-1 format debug output" },
759#endif
760#ifdef DWARF2_DEBUGGING_INFO
761  { "gdwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
762#endif
763#ifdef XCOFF_DEBUGGING_INFO
764  { "gxcoff",  XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
765  { "gxcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
766#endif
767#ifdef SDB_DEBUGGING_INFO
768  { "gcoff", SDB_DEBUG, 0, "Generate COFF format debug output" },
769#endif
770  { 0, 0, 0 }
771};
772
773typedef struct
774{
775  char * string;
776  int *  variable;
777  int    on_value;
778  char * description;
779}
780lang_independent_options;
781
782/* Table of language-independent -f options.
783   STRING is the option name.  VARIABLE is the address of the variable.
784   ON_VALUE is the value to store in VARIABLE
785    if `-fSTRING' is seen as an option.
786   (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
787
788lang_independent_options f_options[] =
789{
790  {"float-store", &flag_float_store, 1,
791   "Do not store floats in registers" },
792  {"volatile", &flag_volatile, 1,
793   "Consider all mem refs through pointers as volatile"},
794  {"volatile-global", &flag_volatile_global, 1,
795   "Consider all mem refs to global data to be volatile" },
796  {"defer-pop", &flag_defer_pop, 1,
797   "Defer popping functions args from stack until later" },
798  {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
799   "When possible do not generate stack frames"},
800  {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
801   "When running CSE, follow jumps to their targets" },
802  {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
803   "When running CSE, follow conditional jumps" },
804  {"expensive-optimizations", &flag_expensive_optimizations, 1,
805   "Perform a number of minor, expensive optimisations" },
806  {"thread-jumps", &flag_thread_jumps, 1,
807   "Perform jump threading optimisations"},
808  {"strength-reduce", &flag_strength_reduce, 1,
809   "Perform strength reduction optimisations" },
810  {"unroll-loops", &flag_unroll_loops, 1,
811   "Perform loop unrolling when interation count is known" },
812  {"unroll-all-loops", &flag_unroll_all_loops, 1,
813   "Perofm loop onrolling for all loops" },
814  {"move-all-movables", &flag_move_all_movables, 1,
815   "Force all loop invariant computations out of loops" },
816  {"reduce-all-givs", &flag_reduce_all_givs, 1,
817   "Strength reduce all loop general induction variables" },
818  {"writable-strings", &flag_writable_strings, 1,
819   "Store strings in writable data section" },
820  {"peephole", &flag_no_peephole, 0,
821   "Enable machine specific peephole optimisations" },
822  {"force-mem", &flag_force_mem, 1,
823   "Copy memory operands into registers before using" },
824  {"force-addr", &flag_force_addr, 1,
825   "Copy memory address constants into regs before using" },
826  {"function-cse", &flag_no_function_cse, 0,
827   "Allow function addresses to be held in registers" },
828  {"inline-functions", &flag_inline_functions, 1,
829   "Integrate simple functions into their callers" },
830  {"keep-inline-functions", &flag_keep_inline_functions, 1,
831   "Generate code for funcs even if they are fully inlined" },
832  {"inline", &flag_no_inline, 0,
833   "Pay attention to the 'inline' keyword"},
834  {"keep-static-consts", &flag_keep_static_consts, 1,
835   "Emit static const variables even if they are not used" },
836  {"syntax-only", &flag_syntax_only, 1,
837   "Check for syntax errors, then stop" },
838  {"shared-data", &flag_shared_data, 1,
839   "Mark data as shared rather than private" },
840  {"caller-saves", &flag_caller_saves, 1,
841   "Enable saving registers around function calls" },
842  {"pcc-struct-return", &flag_pcc_struct_return, 1,
843   "Return 'short' aggregates in memory, not registers" },
844  {"reg-struct-return", &flag_pcc_struct_return, 0,
845   "Return 'short' aggregates in registers" },
846  {"delayed-branch", &flag_delayed_branch, 1,
847   "Attempt to fill delay slots of branch instructions" },
848  {"gcse", &flag_gcse, 1,
849   "Perform the global common subexpression elimination" },
850  {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
851   "Run CSE pass after loop optimisations"},
852  {"structure-noalias", &flag_structure_noalias, 1,
853   "Assume structure / array reference and fixed scalar cannot alias"},
854  {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
855   "Run the loop optimiser twice"},
856  {"pretend-float", &flag_pretend_float, 1,
857   "Pretend that host and target use the same FP format"},
858  {"schedule-insns", &flag_schedule_insns, 1,
859   "Reschedule instructions to avoid pipeline stalls"},
860  {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
861  "Run two passes of the instruction scheduler"},
862#ifdef HAIFA
863  {"sched-interblock",&flag_schedule_interblock, 1,
864   "Enable scheduling across basic blocks" },
865  {"sched-spec",&flag_schedule_speculative, 1,
866   "Allow speculative motion of non-loads" },
867  {"sched-spec-load",&flag_schedule_speculative_load, 1,
868   "Allow speculative motion of some loads" },
869  {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
870   "Allow speculative motion of more loads" },
871  {"branch-count-reg",&flag_branch_on_count_reg, 1,
872   "Replace add,compare,branch with branch on count reg"},
873#endif  /* HAIFA */
874  {"pic", &flag_pic, 1,
875   "Generate position independent code, if possible"},
876  {"PIC", &flag_pic, 2, ""},
877  {"exceptions", &flag_exceptions, 1,
878   "Enable exception handling" },
879  {"new-exceptions", &flag_new_exceptions, 1,
880   "Use the new model for exception handling" },
881  {"sjlj-exceptions", &exceptions_via_longjmp, 1,
882   "Use setjmp/longjmp to handle exceptions" },
883  {"asynchronous-exceptions", &asynchronous_exceptions, 1,
884   "Support asynchronous exceptions" },
885  {"profile-arcs", &profile_arc_flag, 1,
886   "Insert arc based program profiling code" },
887  {"test-coverage", &flag_test_coverage, 1,
888   "Create data files needed by gcov" },
889  {"branch-probabilities", &flag_branch_probabilities, 1,
890   "Use profiling information for branch porbabilities" },
891  {"fast-math", &flag_fast_math, 1,
892   "Improve FP speed by violating ANSI & IEEE rules" },
893  {"common", &flag_no_common, 0,
894   "Do not put unitialised globals in the common section" },
895  {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
896   "Do not generate .size directives" },
897  {"function-sections", &flag_function_sections, 1,
898   "place each function into its own section" },
899  {"verbose-asm", &flag_verbose_asm, 1,
900   "Add extra commentry to assembler output"},
901  {"gnu-linker", &flag_gnu_linker, 1,
902   "Output GNU ld formatted global initialisers"},
903  {"regmove", &flag_regmove, 1,
904   "Enables a regoster move optimisation"},
905  {"optimize-register-move", &flag_regmove, 1},
906  {"pack-struct", &flag_pack_struct, 1,
907   "Pack structure members together without holes" },
908  {"format-extensions", &flag_format_extensions, 1,
909   "-Wformat accepts certain FreeBSD system-dependent formats" },
910  {"stack-check", &flag_stack_check, 1,
911   "Insert stack checking code into the program" },
912  {"argument-alias", &flag_argument_noalias, 0,
913   "Specify that arguments may alias each other & globals"},
914  {"argument-noalias", &flag_argument_noalias, 1,
915   "Assume arguments may alias globals but not each other"},
916  {"argument-noalias-global", &flag_argument_noalias, 2,
917   "Assume arguments do not alias each other or globals" },
918  {"strict-aliasing", &flag_strict_aliasing, 1,
919   "Assume strict aliasing rules apply" },
920  {"check-memory-usage", &flag_check_memory_usage, 1,
921   "Generate code to check every memory access" },
922  {"prefix-function-name", &flag_prefix_function_name, 1,
923   "Add a prefix to all function names" },
924  {"dump-unnumbered", &flag_dump_unnumbered, 1}
925};
926
927#define NUM_ELEM(a)  (sizeof (a) / sizeof ((a)[0]))
928
929/* Table of language-specific options.  */
930
931static struct lang_opt
932{
933  char * option;
934  char * description;
935}
936documented_lang_options[] =
937{
938  /* In order not to overload the --help output, the convention
939     used here is to only describe those options which are not
940     enabled by default.  */
941
942  { "-ansi", "Compile just for ANSI C" },
943  { "-fallow-single-precision",
944    "Do not promote floats to double if using -traditional" },
945
946  { "-fsigned-bitfields", "" },
947  { "-funsigned-bitfields","Make bitfields by unsigned by default" },
948  { "-fno-signed-bitfields", "" },
949  { "-fno-unsigned-bitfields","" },
950  { "-fsigned-char", "Make 'char' be signed by default"},
951  { "-funsigned-char", "Make 'char' be unsigned by default"},
952  { "-fno-signed-char", "" },
953  { "-fno-unsigned-char", "" },
954
955  { "-ftraditional", "" },
956  { "-traditional", "Attempt to support traditional K&R style C"},
957  { "-fnotraditional", "" },
958  { "-fno-traditional", "" },
959
960  { "-fasm", "" },
961  { "-fno-asm", "Do not recognise the 'asm' keyword" },
962  { "-fbuiltin", "" },
963  { "-fno-builtin", "Do not recognise any built in functions" },
964  { "-fhosted", "Assume normal C execution environment" },
965  { "-fno-hosted", "" },
966  { "-ffreestanding",
967    "Assume that standard libraries & main might not exist" },
968  { "-fno-freestanding", "" },
969  { "-fcond-mismatch", "Allow different types as args of ? operator"},
970  { "-fno-cond-mismatch", "" },
971  { "-fdollars-in-identifiers", "Allow the use of $ inside indentifiers" },
972  { "-fno-dollars-in-identifiers", "" },
973  { "-fident", "" },
974  { "-fno-ident", "Ignore #ident directives" },
975  { "-fshort-double", "Use the same size for double as for float" },
976  { "-fno-short-double", "" },
977  { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
978  { "-fno-short-enums", "" },
979
980  { "-Wall", "Enable most warning messages" },
981  { "-Wbad-function-cast",
982    "Warn about casting functions to incompatible types" },
983  { "-Wno-bad-function-cast", "" },
984  { "-Wcast-qual", "Warn about casts which discard qualifiers"},
985  { "-Wno-cast-qual", "" },
986  { "-Wchar-subscripts", "Warn about subscripts whoes type is 'char'"},
987  { "-Wno-char-subscripts", "" },
988  { "-Wcomment", "Warn if nested comments are detected" },
989  { "-Wno-comment", },
990  { "-Wcomments", },
991  { "-Wno-comments", },
992  { "-Wconversion", "Warn about possibly confusing type conversions" },
993  { "-Wno-conversion", "" },
994  { "-Wformat", "Warn about printf format anomalies" },
995  { "-Wno-format", "" },
996  { "-Wimplicit-function-declaration",
997    "Warn about implicit function declarations" },
998  { "-Wno-implicit-function-declaration", "" },
999  { "-Werror-implicit-function-declaration", "" },
1000  { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1001  { "-Wno-implicit-int", "" },
1002  { "-Wimplicit", "" },
1003  { "-Wno-implicit", "" },
1004  { "-Wimport", "Warn about the use of the #import directive" },
1005  { "-Wno-import", "" },
1006  { "-Wlong-long","" },
1007  { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1008  { "-Wmain", "Warn about suspicious declarations of main" },
1009  { "-Wno-main", "" },
1010  { "-Wmissing-braces",
1011    "Warn about possibly missing braces around initialisers" },
1012  { "-Wno-missing-braces", "" },
1013  { "-Wmissing-declarations",
1014    "Warn about global funcs without previous declarations"},
1015  { "-Wno-missing-declarations", "" },
1016  { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1017  { "-Wno-missing-prototypes", "" },
1018  { "-Wmultichar", "Warn about use of multicharacter literals"},
1019  { "-Wno-multichar", "" },
1020  { "-Wnested-externs", "Warn about externs not at file scope level" },
1021  { "-Wno-nested-externs", "" },
1022  { "-Wparentheses", "Warn about possible missing parentheses" },
1023  { "-Wno-parentheses", "" },
1024  { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1025  { "-Wno-pointer-arith", "" },
1026  { "-Wredundant-decls",
1027    "Warn about multiple declarations of the same object" },
1028  { "-Wno-redundant-decls", "" },
1029  { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1030  { "-Wno-sign-compare", "" },
1031  { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1032  { "-Wno-unknown-pragmas", "" },
1033  { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1034  { "-Wno-strict-prototypes", "" },
1035  { "-Wtraditional", "Warn about constructs whoes meaning change in ANSI C"},
1036  { "-Wno-traditional", "" },
1037  { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1038  { "-Wno-trigraphs", "" },
1039  { "-Wundef", "" },
1040  { "-Wno-undef", "" },
1041  { "-Wwrite-strings", "Mark strings as 'const char *'"},
1042  { "-Wno-write-strings", "" },
1043
1044  /* These are for languages with USE_CPPLIB.  */
1045  /* These options are already documented in cpplib.c */
1046  { "--help", "" },
1047  { "-A", "" },
1048  { "-D", "" },
1049  { "-I", "" },
1050  { "-U", "" },
1051  { "-idirafter", "" },
1052  { "-iprefix", "" },
1053  { "-isystem", "" },
1054  { "-lang-c", "" },
1055  { "-lang-c89", "" },
1056  { "-lang-c++", "" },
1057  { "-nostdinc", "" },
1058  { "-nostdinc++", "" },
1059  { "-trigraphs", "" },
1060  { "-undef", "" },
1061  { "-remap", "" },
1062
1063#define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1064
1065  /* These are for obj c.  */
1066  DEFINE_LANG_NAME ("Objective C")
1067
1068  { "-lang-objc", "" },
1069  { "-gen-decls", "Dump decls to a .decl file" },
1070  { "-fgnu-runtime", "Generate code for GNU runtime envrionment" },
1071  { "-fno-gnu-runtime", "" },
1072  { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1073  { "-fno-next-runtime", "" },
1074  { "-Wselector", "Warn if a selector has multiple methods" },
1075  { "-Wno-selector", "" },
1076  { "-Wprotocol", "" },
1077  { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1078  { "-print-objc-runtime-info",
1079    "Generate C header of platform specific features" },
1080
1081#include "options.h"
1082
1083};
1084
1085/* Here is a table, controlled by the tm.h file, listing each -m switch
1086   and which bits in `target_switches' it should set or clear.
1087   If VALUE is positive, it is bits to set.
1088   If VALUE is negative, -VALUE is bits to clear.
1089   (The sign bit is not used so there is no confusion.)  */
1090
1091struct
1092{
1093  char * name;
1094  int    value;
1095  char * description;
1096}
1097target_switches [] = TARGET_SWITCHES;
1098
1099/* This table is similar, but allows the switch to have a value.  */
1100
1101#ifdef TARGET_OPTIONS
1102struct
1103{
1104  char *  prefix;
1105  char ** variable;
1106  char *  description;
1107}
1108target_options [] = TARGET_OPTIONS;
1109#endif
1110
1111/* Options controlling warnings */
1112
1113/* Don't print warning messages.  -w.  */
1114
1115int inhibit_warnings = 0;
1116
1117/* Print various extra warnings.  -W.  */
1118
1119int extra_warnings = 0;
1120
1121/* Treat warnings as errors.  -Werror.  */
1122
1123int warnings_are_errors = 0;
1124
1125/* Nonzero to warn about unused local variables.  */
1126
1127int warn_unused;
1128
1129/* Nonzero to warn about variables used before they are initialized.  */
1130
1131int warn_uninitialized;
1132
1133/* Nonzero means warn about all declarations which shadow others.   */
1134
1135int warn_shadow;
1136
1137/* Warn if a switch on an enum fails to have a case for every enum value.  */
1138
1139int warn_switch;
1140
1141/* Nonzero means warn about function definitions that default the return type
1142   or that use a null return and have a return-type other than void.  */
1143
1144int warn_return_type;
1145
1146/* Nonzero means warn about pointer casts that increase the required
1147   alignment of the target type (and might therefore lead to a crash
1148   due to a misaligned access).  */
1149
1150int warn_cast_align;
1151
1152/* Nonzero means warn about any identifiers that match in the first N
1153   characters.  The value N is in `id_clash_len'.  */
1154
1155int warn_id_clash;
1156unsigned id_clash_len;
1157
1158/* Nonzero means warn about any objects definitions whose size is larger
1159   than N bytes.  Also want about function definitions whose returned
1160   values are larger than N bytes. The value N is in `larger_than_size'.  */
1161
1162int warn_larger_than;
1163unsigned larger_than_size;
1164
1165/* Nonzero means warn if inline function is too large.  */
1166
1167int warn_inline;
1168
1169/* Warn if a function returns an aggregate,
1170   since there are often incompatible calling conventions for doing this.  */
1171
1172int warn_aggregate_return;
1173
1174/* Likewise for -W.  */
1175
1176lang_independent_options W_options[] =
1177{
1178  {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1179  {"error", &warnings_are_errors, 1, ""},
1180  {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1181  {"switch", &warn_switch, 1,
1182   "Warn about enumerated switches missing a specific case" },
1183  {"aggregate-return", &warn_aggregate_return, 1,
1184   "Warn about returning structures, unions or arrays" },
1185  {"cast-align", &warn_cast_align, 1,
1186   "Warn about pointer casts which increase alignment" },
1187  {"uninitialized", &warn_uninitialized, 1,
1188   "Warn about unitialized automatic variables"},
1189  {"inline", &warn_inline, 1,
1190   "Warn when an inlined function cannot be inlined"}
1191};
1192
1193/* Output files for assembler code (real compiler output)
1194   and debugging dumps.  */
1195
1196FILE *asm_out_file;
1197FILE *aux_info_file;
1198FILE *rtl_dump_file = NULL;
1199
1200/* Time accumulators, to count the total time spent in various passes.  */
1201
1202int parse_time;
1203int varconst_time;
1204int integration_time;
1205int jump_time;
1206int cse_time;
1207int gcse_time;
1208int loop_time;
1209int cse2_time;
1210int branch_prob_time;
1211int flow_time;
1212int combine_time;
1213int regmove_time;
1214int sched_time;
1215int local_alloc_time;
1216int global_alloc_time;
1217int sched2_time;
1218#ifdef DELAY_SLOTS
1219int dbr_sched_time;
1220#endif
1221int shorten_branch_time;
1222int stack_reg_time;
1223int final_time;
1224int symout_time;
1225int dump_time;
1226
1227/* Return time used so far, in microseconds.  */
1228
1229int
1230get_run_time ()
1231{
1232  if (quiet_flag)
1233    return 0;
1234
1235#ifdef __BEOS__
1236  return 0;
1237#else /* not BeOS */
1238#if defined (_WIN32) && !defined (__CYGWIN32__)
1239  if (clock() < 0)
1240    return 0;
1241  else
1242    return (clock() * 1000);
1243#else /* not _WIN32 */
1244#ifdef _SC_CLK_TCK
1245  {
1246    static int tick;
1247    struct tms tms;
1248    if (tick == 0)
1249      tick = 1000000 / sysconf(_SC_CLK_TCK);
1250    times (&tms);
1251    return (tms.tms_utime + tms.tms_stime) * tick;
1252  }
1253#else
1254#ifdef USG
1255  {
1256    struct tms tms;
1257#   if HAVE_SYSCONF && defined _SC_CLK_TCK
1258#    define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1259#   else
1260#    ifdef CLK_TCK
1261#     define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1262#    else
1263#     define TICKS_PER_SECOND HZ /* traditional UNIX */
1264#    endif
1265#   endif
1266    times (&tms);
1267    return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1268  }
1269#else
1270#ifndef VMS
1271  {
1272    struct rusage rusage;
1273    getrusage (0, &rusage);
1274    return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1275	    + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1276  }
1277#else /* VMS */
1278  {
1279    struct
1280      {
1281        int proc_user_time;
1282        int proc_system_time;
1283        int child_user_time;
1284        int child_system_time;
1285      } vms_times;
1286    times ((void *) &vms_times);
1287    return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1288  }
1289#endif	/* VMS */
1290#endif	/* USG */
1291#endif  /* _SC_CLK_TCK */
1292#endif	/* _WIN32 */
1293#endif	/* __BEOS__ */
1294}
1295
1296#define TIMEVAR(VAR, BODY)    \
1297do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1298
1299void
1300print_time (str, total)
1301     char *str;
1302     int total;
1303{
1304  fprintf (stderr,
1305	   "time in %s: %d.%06d\n",
1306	   str, total / 1000000, total % 1000000);
1307}
1308
1309/* Count an error or warning.  Return 1 if the message should be printed.  */
1310
1311int
1312count_error (warningp)
1313     int warningp;
1314{
1315  if (warningp && inhibit_warnings)
1316    return 0;
1317
1318  if (warningp && !warnings_are_errors)
1319    warningcount++;
1320  else
1321    {
1322      static int warning_message = 0;
1323
1324      if (warningp && !warning_message)
1325	{
1326	  fprintf (stderr, "%s: warnings being treated as errors\n", progname);
1327	  warning_message = 1;
1328	}
1329      errorcount++;
1330    }
1331
1332  return 1;
1333}
1334
1335/* Print a fatal error message.  NAME is the text.
1336   Also include a system error message based on `errno'.  */
1337
1338void
1339pfatal_with_name (name)
1340     char *name;
1341{
1342  fprintf (stderr, "%s: ", progname);
1343  perror (name);
1344  exit (FATAL_EXIT_CODE);
1345}
1346
1347void
1348fatal_io_error (name)
1349     char *name;
1350{
1351  fprintf (stderr, "%s: %s: I/O error\n", progname, name);
1352  exit (FATAL_EXIT_CODE);
1353}
1354
1355/* Called to give a better error message for a bad insn rather than
1356   just calling abort().  */
1357
1358void
1359fatal_insn (message, insn)
1360     char *message;
1361     rtx insn;
1362{
1363  error (message);
1364  debug_rtx (insn);
1365  if (asm_out_file)
1366    fflush (asm_out_file);
1367  if (aux_info_file)
1368    fflush (aux_info_file);
1369  if (rtl_dump_file != NULL)
1370    fflush (rtl_dump_file);
1371  fflush (stdout);
1372  fflush (stderr);
1373  abort ();
1374}
1375
1376/* Called to give a better error message when we don't have an insn to match
1377   what we are looking for or if the insn's constraints aren't satisfied,
1378   rather than just calling abort().  */
1379
1380void
1381fatal_insn_not_found (insn)
1382     rtx insn;
1383{
1384  if (INSN_CODE (insn) < 0)
1385    fatal_insn ("internal error--unrecognizable insn:", insn);
1386  else
1387    fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1388}
1389
1390/* This is the default decl_printable_name function.  */
1391
1392static char *
1393decl_name (decl, verbosity)
1394     tree decl;
1395     int verbosity;
1396{
1397  return IDENTIFIER_POINTER (DECL_NAME (decl));
1398}
1399
1400static int need_error_newline;
1401
1402/* Function of last error message;
1403   more generally, function such that if next error message is in it
1404   then we don't have to mention the function name.  */
1405static tree last_error_function = NULL;
1406
1407/* Used to detect when input_file_stack has changed since last described.  */
1408static int last_error_tick;
1409
1410/* Called when the start of a function definition is parsed,
1411   this function prints on stderr the name of the function.  */
1412
1413void
1414announce_function (decl)
1415     tree decl;
1416{
1417  if (! quiet_flag)
1418    {
1419      if (rtl_dump_and_exit)
1420	fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1421      else
1422	fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1423      fflush (stderr);
1424      need_error_newline = 1;
1425      last_error_function = current_function_decl;
1426    }
1427}
1428
1429/* The default function to print out name of current function that caused
1430   an error.  */
1431
1432void
1433default_print_error_function (file)
1434     char *file;
1435{
1436  if (last_error_function != current_function_decl)
1437    {
1438      char *kind = "function";
1439      if (current_function_decl != 0
1440	  && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1441	kind = "method";
1442
1443      if (file)
1444	fprintf (stderr, "%s: ", file);
1445
1446      if (current_function_decl == NULL)
1447	fprintf (stderr, "At top level:\n");
1448      else
1449	{
1450	  char *name = (*decl_printable_name) (current_function_decl, 2);
1451	  fprintf (stderr, "In %s `%s':\n", kind, name);
1452	}
1453
1454      last_error_function = current_function_decl;
1455    }
1456}
1457
1458/* Called by report_error_function to print out function name.
1459 * Default may be overridden by language front-ends.  */
1460
1461void (*print_error_function) PROTO((char *)) = default_print_error_function;
1462
1463/* Prints out, if necessary, the name of the current function
1464  that caused an error.  Called from all error and warning functions.  */
1465
1466void
1467report_error_function (file)
1468     char *file;
1469{
1470  struct file_stack *p;
1471
1472  if (need_error_newline)
1473    {
1474      fprintf (stderr, "\n");
1475      need_error_newline = 0;
1476    }
1477
1478  (*print_error_function) (file);
1479
1480  if (input_file_stack && input_file_stack->next != 0
1481      && input_file_stack_tick != last_error_tick
1482      && file == input_filename)
1483    {
1484      fprintf (stderr, "In file included");
1485      for (p = input_file_stack->next; p; p = p->next)
1486	{
1487	  fprintf (stderr, " from %s:%d", p->name, p->line);
1488	  if (p->next)
1489	    fprintf (stderr, ",\n                ");
1490	}
1491      fprintf (stderr, ":\n");
1492      last_error_tick = input_file_stack_tick;
1493    }
1494}
1495
1496/* Print a message.  */
1497
1498static void
1499vmessage (prefix, s, ap)
1500     char *prefix;
1501     char *s;
1502     va_list ap;
1503{
1504  if (prefix)
1505    fprintf (stderr, "%s: ", prefix);
1506
1507  vfprintf (stderr, s, ap);
1508}
1509
1510/* Print a message relevant to line LINE of file FILE.  */
1511
1512static void
1513v_message_with_file_and_line (file, line, prefix, s, ap)
1514     char *file;
1515     int line;
1516     char *prefix;
1517     char *s;
1518     va_list ap;
1519{
1520  if (file)
1521    fprintf (stderr, "%s:%d: ", file, line);
1522  else
1523    fprintf (stderr, "%s: ", progname);
1524
1525  vmessage (prefix, s, ap);
1526  fputc ('\n', stderr);
1527}
1528
1529/* Print a message relevant to the given DECL.  */
1530
1531static void
1532v_message_with_decl (decl, prefix, s, ap)
1533     tree decl;
1534     char *prefix;
1535     char *s;
1536     va_list ap;
1537{
1538  char *p;
1539
1540  fprintf (stderr, "%s:%d: ",
1541	   DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1542
1543  if (prefix)
1544    fprintf (stderr, "%s: ", prefix);
1545
1546  /* Do magic to get around lack of varargs support for insertion
1547     of arguments into existing list.  We know that the decl is first;
1548     we ass_u_me that it will be printed with "%s".  */
1549
1550  for (p = s; *p; ++p)
1551    {
1552      if (*p == '%')
1553	{
1554	  if (*(p + 1) == '%')
1555	    ++p;
1556	  else
1557	    break;
1558	}
1559    }
1560
1561  if (p > s)			/* Print the left-hand substring.  */
1562    {
1563      char fmt[sizeof "%.255s"];
1564      long width = p - s;
1565
1566      if (width > 255L) width = 255L;	/* arbitrary */
1567      sprintf (fmt, "%%.%lds", width);
1568      fprintf (stderr, fmt, s);
1569    }
1570
1571  if (*p == '%')		/* Print the name.  */
1572    {
1573      char *n = (DECL_NAME (decl)
1574		 ? (*decl_printable_name) (decl, 2)
1575		 : "((anonymous))");
1576      fputs (n, stderr);
1577      while (*p)
1578	{
1579	  ++p;
1580	  if (ISALPHA (*(p - 1) & 0xFF))
1581	    break;
1582	}
1583    }
1584
1585  if (*p)			/* Print the rest of the message.  */
1586    vmessage ((char *)NULL, p, ap);
1587
1588  fputc ('\n', stderr);
1589}
1590
1591/* Figure file and line of the given INSN.  */
1592
1593static void
1594file_and_line_for_asm (insn, pfile, pline)
1595     rtx insn;
1596     char **pfile;
1597     int *pline;
1598{
1599  rtx body = PATTERN (insn);
1600  rtx asmop;
1601
1602  /* Find the (or one of the) ASM_OPERANDS in the insn.  */
1603  if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1604    asmop = SET_SRC (body);
1605  else if (GET_CODE (body) == ASM_OPERANDS)
1606    asmop = body;
1607  else if (GET_CODE (body) == PARALLEL
1608	   && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1609    asmop = SET_SRC (XVECEXP (body, 0, 0));
1610  else if (GET_CODE (body) == PARALLEL
1611	   && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1612    asmop = XVECEXP (body, 0, 0);
1613  else
1614    asmop = NULL;
1615
1616  if (asmop)
1617    {
1618      *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1619      *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1620    }
1621  else
1622    {
1623      *pfile = input_filename;
1624      *pline = lineno;
1625    }
1626}
1627
1628/* Report an error at line LINE of file FILE.  */
1629
1630static void
1631v_error_with_file_and_line (file, line, s, ap)
1632     char *file;
1633     int line;
1634     char *s;
1635     va_list ap;
1636{
1637  count_error (0);
1638  report_error_function (file);
1639  v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1640}
1641
1642void
1643error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1644{
1645#ifndef __STDC__
1646  char *file;
1647  int line;
1648  char *s;
1649#endif
1650  va_list ap;
1651
1652  VA_START (ap, s);
1653
1654#ifndef __STDC__
1655  file = va_arg (ap, char *);
1656  line = va_arg (ap, int);
1657  s = va_arg (ap, char *);
1658#endif
1659
1660  v_error_with_file_and_line (file, line, s, ap);
1661  va_end (ap);
1662}
1663
1664/* Report an error at the declaration DECL.
1665   S is a format string which uses %s to substitute the declaration
1666   name; subsequent substitutions are a la printf.  */
1667
1668static void
1669v_error_with_decl (decl, s, ap)
1670     tree decl;
1671     char *s;
1672     va_list ap;
1673{
1674  count_error (0);
1675  report_error_function (DECL_SOURCE_FILE (decl));
1676  v_message_with_decl (decl, (char *)NULL, s, ap);
1677}
1678
1679void
1680error_with_decl VPROTO((tree decl, char *s, ...))
1681{
1682#ifndef __STDC__
1683  tree decl;
1684  char *s;
1685#endif
1686  va_list ap;
1687
1688  VA_START (ap, s);
1689
1690#ifndef __STDC__
1691  decl = va_arg (ap, tree);
1692  s = va_arg (ap, char *);
1693#endif
1694
1695  v_error_with_decl (decl, s, ap);
1696  va_end (ap);
1697}
1698
1699/* Report an error at the line number of the insn INSN.
1700   This is used only when INSN is an `asm' with operands,
1701   and each ASM_OPERANDS records its own source file and line.  */
1702
1703static void
1704v_error_for_asm (insn, s, ap)
1705     rtx insn;
1706     char *s;
1707     va_list ap;
1708{
1709  char *file;
1710  int line;
1711
1712  count_error (0);
1713  file_and_line_for_asm (insn, &file, &line);
1714  report_error_function (file);
1715  v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1716}
1717
1718void
1719error_for_asm VPROTO((rtx insn, char *s, ...))
1720{
1721#ifndef __STDC__
1722  rtx insn;
1723  char *s;
1724#endif
1725  va_list ap;
1726
1727  VA_START (ap, s);
1728
1729#ifndef __STDC__
1730  insn = va_arg (ap, rtx);
1731  s = va_arg (ap, char *);
1732#endif
1733
1734  v_error_for_asm (insn, s, ap);
1735  va_end (ap);
1736}
1737
1738/* Report an error at the current line number.  */
1739
1740static void
1741verror (s, ap)
1742     char *s;
1743     va_list ap;
1744{
1745  v_error_with_file_and_line (input_filename, lineno, s, ap);
1746}
1747
1748void
1749error VPROTO((char *s, ...))
1750{
1751#ifndef __STDC__
1752  char *s;
1753#endif
1754  va_list ap;
1755
1756  VA_START (ap, s);
1757
1758#ifndef __STDC__
1759  s = va_arg (ap, char *);
1760#endif
1761
1762  verror (s, ap);
1763  va_end (ap);
1764}
1765
1766/* Report a fatal error at the current line number.  */
1767
1768static void
1769vfatal (s, ap)
1770     char *s;
1771     va_list ap;
1772{
1773  verror (s, ap);
1774  exit (FATAL_EXIT_CODE);
1775}
1776
1777void
1778fatal VPROTO((char *s, ...))
1779{
1780#ifndef __STDC__
1781  char *s;
1782#endif
1783  va_list ap;
1784
1785  VA_START (ap, s);
1786
1787#ifndef __STDC__
1788  s = va_arg (ap, char *);
1789#endif
1790
1791  vfatal (s, ap);
1792  va_end (ap);
1793}
1794
1795/* Report a warning at line LINE of file FILE.  */
1796
1797static void
1798v_warning_with_file_and_line (file, line, s, ap)
1799     char *file;
1800     int line;
1801     char *s;
1802     va_list ap;
1803{
1804  if (count_error (1))
1805    {
1806      report_error_function (file);
1807      v_message_with_file_and_line (file, line, "warning", s, ap);
1808    }
1809}
1810
1811void
1812warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1813{
1814#ifndef __STDC__
1815  char *file;
1816  int line;
1817  char *s;
1818#endif
1819  va_list ap;
1820
1821  VA_START (ap, s);
1822
1823#ifndef __STDC__
1824  file = va_arg (ap, char *);
1825  line = va_arg (ap, int);
1826  s = va_arg (ap, char *);
1827#endif
1828
1829  v_warning_with_file_and_line (file, line, s, ap);
1830  va_end (ap);
1831}
1832
1833/* Report a warning at the declaration DECL.
1834   S is a format string which uses %s to substitute the declaration
1835   name; subsequent substitutions are a la printf.  */
1836
1837static void
1838v_warning_with_decl (decl, s, ap)
1839     tree decl;
1840     char *s;
1841     va_list ap;
1842{
1843  if (count_error (1))
1844    {
1845      report_error_function (DECL_SOURCE_FILE (decl));
1846      v_message_with_decl (decl, "warning", s, ap);
1847    }
1848}
1849
1850void
1851warning_with_decl VPROTO((tree decl, char *s, ...))
1852{
1853#ifndef __STDC__
1854  tree decl;
1855  char *s;
1856#endif
1857  va_list ap;
1858
1859  VA_START (ap, s);
1860
1861#ifndef __STDC__
1862  decl = va_arg (ap, tree);
1863  s = va_arg (ap, char *);
1864#endif
1865
1866  v_warning_with_decl (decl, s, ap);
1867  va_end (ap);
1868}
1869
1870/* Report a warning at the line number of the insn INSN.
1871   This is used only when INSN is an `asm' with operands,
1872   and each ASM_OPERANDS records its own source file and line.  */
1873
1874static void
1875v_warning_for_asm (insn, s, ap)
1876     rtx insn;
1877     char *s;
1878     va_list ap;
1879{
1880  if (count_error (1))
1881    {
1882      char *file;
1883      int line;
1884
1885      file_and_line_for_asm (insn, &file, &line);
1886      report_error_function (file);
1887      v_message_with_file_and_line (file, line, "warning", s, ap);
1888    }
1889}
1890
1891void
1892warning_for_asm VPROTO((rtx insn, char *s, ...))
1893{
1894#ifndef __STDC__
1895  rtx insn;
1896  char *s;
1897#endif
1898  va_list ap;
1899
1900  VA_START (ap, s);
1901
1902#ifndef __STDC__
1903  insn = va_arg (ap, rtx);
1904  s = va_arg (ap, char *);
1905#endif
1906
1907  v_warning_for_asm (insn, s, ap);
1908  va_end (ap);
1909}
1910
1911/* Report a warning at the current line number.  */
1912
1913static void
1914vwarning (s, ap)
1915     char *s;
1916     va_list ap;
1917{
1918  v_warning_with_file_and_line (input_filename, lineno, s, ap);
1919}
1920
1921void
1922warning VPROTO((char *s, ...))
1923{
1924#ifndef __STDC__
1925  char *s;
1926#endif
1927  va_list ap;
1928
1929  VA_START (ap, s);
1930
1931#ifndef __STDC__
1932  s = va_arg (ap, char *);
1933#endif
1934
1935  vwarning (s, ap);
1936  va_end (ap);
1937}
1938
1939/* These functions issue either warnings or errors depending on
1940   -pedantic-errors.  */
1941
1942static void
1943vpedwarn (s, ap)
1944     char *s;
1945     va_list ap;
1946{
1947  if (flag_pedantic_errors)
1948    verror (s, ap);
1949  else
1950    vwarning (s, ap);
1951}
1952
1953void
1954pedwarn VPROTO((char *s, ...))
1955{
1956#ifndef __STDC__
1957  char *s;
1958#endif
1959  va_list ap;
1960
1961  VA_START (ap, s);
1962
1963#ifndef __STDC__
1964  s = va_arg (ap, char *);
1965#endif
1966
1967  vpedwarn (s, ap);
1968  va_end (ap);
1969}
1970
1971static void
1972v_pedwarn_with_decl (decl, s, ap)
1973     tree decl;
1974     char *s;
1975     va_list ap;
1976{
1977  /* We don't want -pedantic-errors to cause the compilation to fail from
1978     "errors" in system header files.  Sometimes fixincludes can't fix what's
1979     broken (eg: unsigned char bitfields - fixing it may change the alignment
1980     which will cause programs to mysteriously fail because the C library
1981     or kernel uses the original layout).  There's no point in issuing a
1982     warning either, it's just unnecessary noise.  */
1983
1984  if (! DECL_IN_SYSTEM_HEADER (decl))
1985    {
1986      if (flag_pedantic_errors)
1987	v_error_with_decl (decl, s, ap);
1988      else
1989	v_warning_with_decl (decl, s, ap);
1990    }
1991}
1992
1993void
1994pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1995{
1996#ifndef __STDC__
1997  tree decl;
1998  char *s;
1999#endif
2000  va_list ap;
2001
2002  VA_START (ap, s);
2003
2004#ifndef __STDC__
2005  decl = va_arg (ap, tree);
2006  s = va_arg (ap, char *);
2007#endif
2008
2009  v_pedwarn_with_decl (decl, s, ap);
2010  va_end (ap);
2011}
2012
2013static void
2014v_pedwarn_with_file_and_line (file, line, s, ap)
2015     char *file;
2016     int line;
2017     char *s;
2018     va_list ap;
2019{
2020  if (flag_pedantic_errors)
2021    v_error_with_file_and_line (file, line, s, ap);
2022  else
2023    v_warning_with_file_and_line (file, line, s, ap);
2024}
2025
2026void
2027pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
2028{
2029#ifndef __STDC__
2030  char *file;
2031  int line;
2032  char *s;
2033#endif
2034  va_list ap;
2035
2036  VA_START (ap, s);
2037
2038#ifndef __STDC__
2039  file = va_arg (ap, char *);
2040  line = va_arg (ap, int);
2041  s = va_arg (ap, char *);
2042#endif
2043
2044  v_pedwarn_with_file_and_line (file, line, s, ap);
2045  va_end (ap);
2046}
2047
2048/* Apologize for not implementing some feature.  */
2049
2050static void
2051vsorry (s, ap)
2052     char *s;
2053     va_list ap;
2054{
2055  sorrycount++;
2056  if (input_filename)
2057    fprintf (stderr, "%s:%d: ", input_filename, lineno);
2058  else
2059    fprintf (stderr, "%s: ", progname);
2060  vmessage ("sorry, not implemented", s, ap);
2061  fputc ('\n', stderr);
2062}
2063
2064void
2065sorry VPROTO((char *s, ...))
2066{
2067#ifndef __STDC__
2068  char *s;
2069#endif
2070  va_list ap;
2071
2072  VA_START (ap, s);
2073
2074#ifndef __STDC__
2075  s = va_arg (ap, char *);
2076#endif
2077
2078  vsorry (s, ap);
2079  va_end (ap);
2080}
2081
2082/* Apologize for not implementing some feature, then quit.  */
2083
2084static void
2085v_really_sorry (s, ap)
2086     char *s;
2087     va_list ap;
2088{
2089  sorrycount++;
2090  if (input_filename)
2091    fprintf (stderr, "%s:%d: ", input_filename, lineno);
2092  else
2093    fprintf (stderr, "%s: ", progname);
2094  vmessage ("sorry, not implemented", s, ap);
2095  fatal (" (fatal)\n");
2096}
2097
2098void
2099really_sorry VPROTO((char *s, ...))
2100{
2101#ifndef __STDC__
2102  char *s;
2103#endif
2104  va_list ap;
2105
2106  VA_START (ap, s);
2107
2108#ifndef __STDC__
2109  s = va_arg (ap, char *);
2110#endif
2111
2112  v_really_sorry (s, ap);
2113  va_end (ap);
2114}
2115
2116/* More 'friendly' abort that prints the line and file.
2117   config.h can #define abort fancy_abort if you like that sort of thing.
2118
2119   I don't think this is actually a good idea.
2120   Other sorts of crashes will look a certain way.
2121   It is a good thing if crashes from calling abort look the same way.
2122     -- RMS  */
2123
2124void
2125fancy_abort ()
2126{
2127  fatal ("internal gcc abort");
2128}
2129
2130/* This calls abort and is used to avoid problems when abort if a macro.
2131   It is used when we need to pass the address of abort.  */
2132
2133void
2134do_abort ()
2135{
2136  abort ();
2137}
2138
2139/* When `malloc.c' is compiled with `rcheck' defined,
2140   it calls this function to report clobberage.  */
2141
2142void
2143botch (s)
2144  char * s;
2145{
2146  abort ();
2147}
2148
2149/* Same as `malloc' but report error if no memory available.  */
2150
2151char *
2152xmalloc (size)
2153     unsigned size;
2154{
2155  register char *value;
2156
2157  if (size == 0)
2158    size = 1;
2159
2160  value = (char *) malloc (size);
2161  if (value == 0)
2162    fatal ("virtual memory exhausted");
2163  return value;
2164}
2165
2166/* Same as `calloc' but report error if no memory available.  */
2167
2168char *
2169xcalloc (size1, size2)
2170     unsigned size1, size2;
2171{
2172  register char *value;
2173
2174  if (size1 == 0 || size2 == 0)
2175    size1 = size2 = 1;
2176
2177  value = (char *) calloc (size1, size2);
2178  if (value == 0)
2179    fatal ("virtual memory exhausted");
2180  return value;
2181}
2182
2183
2184/* Same as `realloc' but report error if no memory available.
2185   Also handle null PTR even if the vendor realloc gets it wrong.  */
2186
2187char *
2188xrealloc (ptr, size)
2189     char *ptr;
2190     int size;
2191{
2192  char *result;
2193
2194  if (size == 0)
2195    size = 1;
2196
2197  result = (ptr
2198	    ? (char *) realloc (ptr, size)
2199	    : (char *) malloc (size));
2200
2201  if (!result)
2202    fatal ("virtual memory exhausted");
2203
2204  return result;
2205}
2206
2207/* Same as `strdup' but report error if no memory available.  */
2208
2209char *
2210xstrdup (s)
2211     register char *s;
2212{
2213  register char *result = (char *) malloc (strlen (s) + 1);
2214
2215  if (! result)
2216    fatal ("virtual memory exhausted");
2217  strcpy (result, s);
2218  return result;
2219}
2220
2221/* Return the logarithm of X, base 2, considering X unsigned,
2222   if X is a power of 2.  Otherwise, returns -1.
2223
2224   This should be used via the `exact_log2' macro.  */
2225
2226int
2227exact_log2_wide (x)
2228     register unsigned HOST_WIDE_INT x;
2229{
2230  register int log = 0;
2231  /* Test for 0 or a power of 2.  */
2232  if (x == 0 || x != (x & -x))
2233    return -1;
2234  while ((x >>= 1) != 0)
2235    log++;
2236  return log;
2237}
2238
2239/* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2240   If X is 0, return -1.
2241
2242   This should be used via the floor_log2 macro.  */
2243
2244int
2245floor_log2_wide (x)
2246     register unsigned HOST_WIDE_INT x;
2247{
2248  register int log = -1;
2249  while (x != 0)
2250    log++,
2251    x >>= 1;
2252  return log;
2253}
2254
2255static int float_handler_set;
2256int float_handled;
2257jmp_buf float_handler;
2258
2259/* Signals actually come here.  */
2260
2261static void
2262float_signal (signo)
2263     /* If this is missing, some compilers complain.  */
2264     int signo ATTRIBUTE_UNUSED;
2265{
2266  if (float_handled == 0)
2267    abort ();
2268#if defined (USG) || defined (hpux)
2269  signal (SIGFPE, float_signal);  /* re-enable the signal catcher */
2270#endif
2271  float_handled = 0;
2272  signal (SIGFPE, float_signal);
2273  longjmp (float_handler, 1);
2274}
2275
2276/* Specify where to longjmp to when a floating arithmetic error happens.
2277   If HANDLER is 0, it means don't handle the errors any more.  */
2278
2279void
2280set_float_handler (handler)
2281     jmp_buf handler;
2282{
2283  float_handled = (handler != 0);
2284  if (handler)
2285    bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2286
2287  if (float_handled && ! float_handler_set)
2288    {
2289      signal (SIGFPE, float_signal);
2290      float_handler_set = 1;
2291    }
2292}
2293
2294/* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2295   error happens, pushing the previous specification into OLD_HANDLER.
2296   Return an indication of whether there was a previous handler in effect.  */
2297
2298int
2299push_float_handler (handler, old_handler)
2300     jmp_buf handler, old_handler;
2301{
2302  int was_handled = float_handled;
2303
2304  float_handled = 1;
2305  if (was_handled)
2306    bcopy ((char *) float_handler, (char *) old_handler,
2307	   sizeof (float_handler));
2308
2309  bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2310  return was_handled;
2311}
2312
2313/* Restore the previous specification of whether and where to longjmp to
2314   when a floating arithmetic error happens.  */
2315
2316void
2317pop_float_handler (handled, handler)
2318     int handled;
2319     jmp_buf handler;
2320{
2321  float_handled = handled;
2322  if (handled)
2323    bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2324}
2325
2326/* Handler for SIGPIPE.  */
2327
2328static void
2329pipe_closed (signo)
2330     /* If this is missing, some compilers complain.  */
2331     int signo ATTRIBUTE_UNUSED;
2332{
2333  fatal ("output pipe has been closed");
2334}
2335
2336/* Strip off a legitimate source ending from the input string NAME of
2337   length LEN.  Rather than having to know the names used by all of
2338   our front ends, we strip off an ending of a period followed by
2339   up to five characters.  (Java uses ".class".) */
2340
2341void
2342strip_off_ending (name, len)
2343     char *name;
2344     int len;
2345{
2346  int i;
2347  for (i = 2;  i < 6 && len > i;  i++)
2348    {
2349      if (name[len - i] == '.')
2350	{
2351	  name[len - i] = '\0';
2352	  break;
2353	}
2354    }
2355}
2356
2357/* Output a quoted string.  */
2358
2359void
2360output_quoted_string (asm_file, string)
2361     FILE *asm_file;
2362     char *string;
2363{
2364#ifdef OUTPUT_QUOTED_STRING
2365  OUTPUT_QUOTED_STRING (asm_file, string);
2366#else
2367  char c;
2368
2369  putc ('\"', asm_file);
2370  while ((c = *string++) != 0)
2371    {
2372      if (c == '\"' || c == '\\')
2373	putc ('\\', asm_file);
2374      putc (c, asm_file);
2375    }
2376  putc ('\"', asm_file);
2377#endif
2378}
2379
2380/* Output a file name in the form wanted by System V.  */
2381
2382void
2383output_file_directive (asm_file, input_name)
2384     FILE *asm_file;
2385     char *input_name;
2386{
2387  int len = strlen (input_name);
2388  char *na = input_name + len;
2389
2390  /* NA gets INPUT_NAME sans directory names.  */
2391  while (na > input_name)
2392    {
2393      if (na[-1] == '/')
2394	break;
2395      na--;
2396    }
2397
2398#ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2399  ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2400#else
2401#ifdef ASM_OUTPUT_SOURCE_FILENAME
2402  ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2403#else
2404  fprintf (asm_file, "\t.file\t");
2405  output_quoted_string (asm_file, na);
2406  fputc ('\n', asm_file);
2407#endif
2408#endif
2409}
2410
2411/* Routine to build language identifier for object file.  */
2412
2413static void
2414output_lang_identify (asm_out_file)
2415     FILE *asm_out_file;
2416{
2417  int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2418  char *s = (char *) alloca (len);
2419  sprintf (s, "__gnu_compiled_%s", lang_identify ());
2420  ASM_OUTPUT_LABEL (asm_out_file, s);
2421}
2422
2423/* Routine to open a dump file.  */
2424static void
2425open_dump_file (suffix, function_name)
2426     char *suffix;
2427     char *function_name;
2428{
2429  char *dumpname;
2430
2431  TIMEVAR
2432    (dump_time,
2433     {
2434       dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2435
2436       if (rtl_dump_file != NULL)
2437	 fclose (rtl_dump_file);
2438
2439       strcpy (dumpname, dump_base_name);
2440       strcat (dumpname, suffix);
2441
2442       rtl_dump_file = fopen (dumpname, "a");
2443
2444       if (rtl_dump_file == NULL)
2445	 pfatal_with_name (dumpname);
2446
2447       free (dumpname);
2448
2449       if (function_name)
2450	 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2451     });
2452
2453  return;
2454}
2455
2456/* Routine to close a dump file.  */
2457static void
2458close_dump_file (func, insns)
2459     void (*func) PROTO ((FILE *, rtx));
2460     rtx    insns;
2461{
2462  TIMEVAR
2463    (dump_time,
2464     {
2465       if (func)
2466	 func (rtl_dump_file, insns);
2467
2468       fflush (rtl_dump_file);
2469       fclose (rtl_dump_file);
2470
2471       rtl_dump_file = NULL;
2472     });
2473
2474  return;
2475}
2476
2477/* Routine to dump rtl into a file.  */
2478static void
2479dump_rtl (suffix, decl, func, insns)
2480     char *suffix;
2481     tree   decl;
2482     void (*func) PROTO ((FILE *, rtx));
2483     rtx    insns;
2484{
2485  open_dump_file (suffix, decl_printable_name (decl, 2));
2486  close_dump_file (func, insns);
2487}
2488
2489/* Routine to empty a dump file.  */
2490static void
2491clean_dump_file (suffix)
2492     char * suffix;
2493{
2494  char * dumpname;
2495
2496  dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2497
2498  strcpy (dumpname, dump_base_name);
2499  strcat (dumpname, suffix);
2500
2501  rtl_dump_file = fopen (dumpname, "w");
2502
2503  if (rtl_dump_file == NULL)
2504    pfatal_with_name (dumpname);
2505
2506  free (dumpname);
2507
2508  fclose (rtl_dump_file);
2509  rtl_dump_file = NULL;
2510
2511  return;
2512}
2513
2514
2515/* Compile an entire file of output from cpp, named NAME.
2516   Write a file of assembly output and various debugging dumps.  */
2517
2518static void
2519compile_file (name)
2520     char *name;
2521{
2522  tree globals;
2523  int start_time;
2524
2525  int name_specified = name != 0;
2526
2527  if (dump_base_name == 0)
2528    dump_base_name = name ? name : "gccdump";
2529
2530  parse_time = 0;
2531  varconst_time = 0;
2532  integration_time = 0;
2533  jump_time = 0;
2534  cse_time = 0;
2535  gcse_time = 0;
2536  loop_time = 0;
2537  cse2_time = 0;
2538  branch_prob_time = 0;
2539  flow_time = 0;
2540  combine_time = 0;
2541  regmove_time = 0;
2542  sched_time = 0;
2543  local_alloc_time = 0;
2544  global_alloc_time = 0;
2545  sched2_time = 0;
2546#ifdef DELAY_SLOTS
2547  dbr_sched_time = 0;
2548#endif
2549  shorten_branch_time = 0;
2550  stack_reg_time = 0;
2551  final_time = 0;
2552  symout_time = 0;
2553  dump_time = 0;
2554
2555  /* Initialize data in various passes.  */
2556
2557  init_obstacks ();
2558  init_tree_codes ();
2559  name = init_parse (name);
2560  init_rtl ();
2561  init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2562		  || debug_info_level == DINFO_LEVEL_VERBOSE
2563		  || flag_test_coverage);
2564  init_regs ();
2565  init_decl_processing ();
2566  init_optabs ();
2567  init_stmt ();
2568  init_expmed ();
2569  init_expr_once ();
2570  init_loop ();
2571  init_reload ();
2572  init_alias_once ();
2573
2574  if (flag_caller_saves)
2575    init_caller_save ();
2576
2577  /* If auxiliary info generation is desired, open the output file.
2578     This goes in the same directory as the source file--unlike
2579     all the other output files.  */
2580  if (flag_gen_aux_info)
2581    {
2582      aux_info_file = fopen (aux_info_file_name, "w");
2583      if (aux_info_file == 0)
2584	pfatal_with_name (aux_info_file_name);
2585    }
2586
2587  /* Clear the dump files file.  */
2588  if (rtl_dump)
2589    clean_dump_file (".rtl");
2590  if (jump_opt_dump)
2591    clean_dump_file (".jump");
2592  if (addressof_dump)
2593    clean_dump_file (".addressof");
2594  if (cse_dump)
2595    clean_dump_file (".cse");
2596  if (loop_dump)
2597    clean_dump_file (".loop");
2598  if (cse2_dump)
2599    clean_dump_file (".cse2");
2600  if (branch_prob_dump)
2601    clean_dump_file (".bp");
2602  if (flow_dump)
2603    clean_dump_file (".flow");
2604  if (combine_dump)
2605    clean_dump_file (".combine");
2606  if (regmove_dump)
2607    clean_dump_file (".regmove");
2608  if (sched_dump)
2609    clean_dump_file (".sched");
2610  if (local_reg_dump)
2611    clean_dump_file (".lreg");
2612  if (global_reg_dump)
2613    clean_dump_file (".greg");
2614  if (sched2_dump)
2615    clean_dump_file (".sched2");
2616  if (jump2_opt_dump)
2617    clean_dump_file (".jump2");
2618#ifdef DELAY_SLOTS
2619  if (dbr_sched_dump)
2620    clean_dump_file (".dbr");
2621#endif
2622  if (gcse_dump)
2623    clean_dump_file (".gcse");
2624#ifdef STACK_REGS
2625  if (stack_reg_dump)
2626    clean_dump_file (".stack");
2627#endif
2628#ifdef MACHINE_DEPENDENT_REORG
2629  if (mach_dep_reorg_dump)
2630    clean_dump_file (".mach");
2631#endif
2632
2633  /* Open assembler code output file.  */
2634
2635  if (! name_specified && asm_file_name == 0)
2636    asm_out_file = stdout;
2637  else
2638    {
2639      int len = strlen (dump_base_name);
2640      register char *dumpname = (char *) xmalloc (len + 6);
2641      strcpy (dumpname, dump_base_name);
2642      strip_off_ending (dumpname, len);
2643      strcat (dumpname, ".s");
2644      if (asm_file_name == 0)
2645	{
2646	  asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2647	  strcpy (asm_file_name, dumpname);
2648	}
2649      if (!strcmp (asm_file_name, "-"))
2650	asm_out_file = stdout;
2651      else
2652	asm_out_file = fopen (asm_file_name, "w");
2653      if (asm_out_file == 0)
2654	pfatal_with_name (asm_file_name);
2655    }
2656
2657#ifdef IO_BUFFER_SIZE
2658  setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2659	   _IOFBF, IO_BUFFER_SIZE);
2660#endif
2661
2662  input_filename = name;
2663
2664  /* Put an entry on the input file stack for the main input file.  */
2665  input_file_stack
2666    = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2667  input_file_stack->next = 0;
2668  input_file_stack->name = input_filename;
2669
2670  /* Perform language-specific initialization.
2671     This may set main_input_filename.  */
2672  lang_init ();
2673
2674  /* If the input doesn't start with a #line, use the input name
2675     as the official input file name.  */
2676  if (main_input_filename == 0)
2677    main_input_filename = name;
2678
2679  ASM_FILE_START (asm_out_file);
2680
2681#ifdef ASM_COMMENT_START
2682  if (flag_verbose_asm)
2683    {
2684      /* Print the list of options in effect.  */
2685      print_version (asm_out_file, ASM_COMMENT_START);
2686      print_switch_values (asm_out_file, 0, MAX_LINE,
2687			       ASM_COMMENT_START, " ", "\n");
2688      /* Add a blank line here so it appears in assembler output but not
2689	 screen output.  */
2690      fprintf (asm_out_file, "\n");
2691    }
2692#endif
2693
2694  /* Output something to inform GDB that this compilation was by GCC.  */
2695#ifndef ASM_IDENTIFY_GCC
2696  fprintf (asm_out_file, "gcc2_compiled.:\n");
2697#else
2698  ASM_IDENTIFY_GCC (asm_out_file);
2699#endif
2700
2701  /* Output something to identify which front-end produced this file.  */
2702#ifdef ASM_IDENTIFY_LANGUAGE
2703  ASM_IDENTIFY_LANGUAGE (asm_out_file);
2704#endif
2705
2706#ifndef ASM_OUTPUT_SECTION_NAME
2707  if (flag_function_sections)
2708    {
2709      warning ("-ffunction-sections not supported for this target.");
2710      flag_function_sections = 0;
2711    }
2712#endif
2713
2714  if (flag_function_sections
2715      && (profile_flag || profile_block_flag))
2716    {
2717      warning ("-ffunction-sections disabled; it makes profiling impossible.");
2718      flag_function_sections = 0;
2719    }
2720
2721  if (flag_function_sections && write_symbols != NO_DEBUG)
2722    warning ("-ffunction-sections may affect debugging on some targets.");
2723
2724  /* ??? Note: There used to be a conditional here
2725      to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2726      This was to guarantee separation between gcc_compiled. and
2727      the first function, for the sake of dbx on Suns.
2728      However, having the extra zero here confused the Emacs
2729      code for unexec, and might confuse other programs too.
2730      Therefore, I took out that change.
2731      In future versions we should find another way to solve
2732      that dbx problem.  -- rms, 23 May 93.  */
2733
2734  /* Don't let the first function fall at the same address
2735     as gcc_compiled., if profiling.  */
2736  if (profile_flag || profile_block_flag)
2737    {
2738      /* It's best if we can write a nop here since some
2739	 assemblers don't tolerate zeros in the text section.  */
2740      if (insn_template[CODE_FOR_nop] != 0)
2741	output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR);
2742      else
2743	assemble_zeros (UNITS_PER_WORD);
2744    }
2745
2746  /* If dbx symbol table desired, initialize writing it
2747     and output the predefined types.  */
2748#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2749  if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2750    TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2751				       getdecls ()));
2752#endif
2753#ifdef SDB_DEBUGGING_INFO
2754  if (write_symbols == SDB_DEBUG)
2755    TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2756				       getdecls ()));
2757#endif
2758#ifdef DWARF_DEBUGGING_INFO
2759  if (write_symbols == DWARF_DEBUG)
2760    TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2761#endif
2762#ifdef DWARF2_UNWIND_INFO
2763  if (dwarf2out_do_frame ())
2764    dwarf2out_frame_init ();
2765#endif
2766#ifdef DWARF2_DEBUGGING_INFO
2767  if (write_symbols == DWARF2_DEBUG)
2768    TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2769#endif
2770
2771  /* Initialize yet another pass.  */
2772
2773  init_final (main_input_filename);
2774  init_branch_prob (dump_base_name);
2775
2776  start_time = get_run_time ();
2777
2778  /* Call the parser, which parses the entire file
2779     (calling rest_of_compilation for each function).  */
2780
2781  if (yyparse () != 0)
2782    {
2783      if (errorcount == 0)
2784	fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2785
2786      /* In case there were missing closebraces,
2787	 get us back to the global binding level.  */
2788      while (! global_bindings_p ())
2789	poplevel (0, 0, 0);
2790    }
2791
2792  output_func_start_profiler ();
2793
2794  /* Compilation is now finished except for writing
2795     what's left of the symbol table output.  */
2796
2797  parse_time += get_run_time () - start_time;
2798
2799  parse_time -= integration_time;
2800  parse_time -= varconst_time;
2801
2802  globals = getdecls ();
2803
2804  /* Really define vars that have had only a tentative definition.
2805     Really output inline functions that must actually be callable
2806     and have not been output so far.  */
2807
2808  {
2809    int len = list_length (globals);
2810    tree *vec = (tree *) alloca (sizeof (tree) * len);
2811    int i;
2812    tree decl;
2813    int reconsider = 1;
2814
2815    /* Process the decls in reverse order--earliest first.
2816       Put them into VEC from back to front, then take out from front.  */
2817
2818    for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2819      vec[len - i - 1] = decl;
2820
2821    for (i = 0; i < len; i++)
2822      {
2823	decl = vec[i];
2824
2825	/* We're not deferring this any longer.  */
2826	DECL_DEFER_OUTPUT (decl) = 0;
2827
2828	if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2829	    && incomplete_decl_finalize_hook != 0)
2830	  (*incomplete_decl_finalize_hook) (decl);
2831      }
2832
2833    /* Now emit any global variables or functions that we have been putting
2834       off.  We need to loop in case one of the things emitted here
2835       references another one which comes earlier in the list.  */
2836    while (reconsider)
2837      {
2838	reconsider = 0;
2839	for (i = 0; i < len; i++)
2840	  {
2841	    decl = vec[i];
2842
2843	    if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2844	      continue;
2845
2846	    /* Don't write out static consts, unless we still need them.
2847
2848	       We also keep static consts if not optimizing (for debugging),
2849	       unless the user specified -fno-keep-static-consts.
2850	       ??? They might be better written into the debug information.
2851	       This is possible when using DWARF.
2852
2853	       A language processor that wants static constants to be always
2854	       written out (even if it is not used) is responsible for
2855	       calling rest_of_decl_compilation itself.  E.g. the C front-end
2856	       calls rest_of_decl_compilation from finish_decl.
2857	       One motivation for this is that is conventional in some
2858	       environments to write things like:
2859	           static const char rcsid[] = "... version string ...";
2860	       intending to force the string to be in the executable.
2861
2862	       A language processor that would prefer to have unneeded
2863	       static constants "optimized away" would just defer writing
2864	       them out until here.  E.g. C++ does this, because static
2865	       constants are often defined in header files.
2866
2867	       ??? A tempting alternative (for both C and C++) would be
2868	       to force a constant to be written if and only if it is
2869	       defined in a main file, as opposed to an include file.  */
2870
2871	    if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2872		&& (! TREE_READONLY (decl)
2873		    || TREE_PUBLIC (decl)
2874		    || (!optimize && flag_keep_static_consts)
2875		    || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2876	      {
2877		reconsider = 1;
2878		rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2879	      }
2880
2881	    if (TREE_CODE (decl) == FUNCTION_DECL
2882		&& DECL_INITIAL (decl) != 0
2883		&& DECL_SAVED_INSNS (decl) != 0
2884		&& (flag_keep_inline_functions
2885		    || TREE_PUBLIC (decl)
2886		    || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2887	      {
2888		reconsider = 1;
2889		temporary_allocation ();
2890		output_inline_function (decl);
2891		permanent_allocation (1);
2892	      }
2893	  }
2894      }
2895
2896    /* Now that all possible functions have been output, we can dump
2897       the exception table.  */
2898
2899    output_exception_table ();
2900
2901    for (i = 0; i < len; i++)
2902      {
2903	decl = vec[i];
2904
2905	if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2906	    && ! TREE_ASM_WRITTEN (decl))
2907	  /* Cancel the RTL for this decl so that, if debugging info
2908	     output for global variables is still to come,
2909	     this one will be omitted.  */
2910	  DECL_RTL (decl) = NULL;
2911
2912	/* Warn about any function
2913	   declared static but not defined.
2914	   We don't warn about variables,
2915	   because many programs have static variables
2916	   that exist only to get some text into the object file.  */
2917	if (TREE_CODE (decl) == FUNCTION_DECL
2918	    && (warn_unused
2919		|| TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2920	    && DECL_INITIAL (decl) == 0
2921	    && DECL_EXTERNAL (decl)
2922	    && ! DECL_ARTIFICIAL (decl)
2923	    && ! TREE_PUBLIC (decl))
2924	  {
2925	    pedwarn_with_decl (decl,
2926			       "`%s' declared `static' but never defined");
2927	    /* This symbol is effectively an "extern" declaration now.  */
2928	    TREE_PUBLIC (decl) = 1;
2929	    assemble_external (decl);
2930	  }
2931
2932	/* Warn about static fns or vars defined but not used,
2933	   but not about inline functions or static consts
2934	   since defining those in header files is normal practice.  */
2935	if (warn_unused
2936	    && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2937		|| (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2938	    && ! DECL_IN_SYSTEM_HEADER (decl)
2939	    && ! DECL_EXTERNAL (decl)
2940	    && ! TREE_PUBLIC (decl)
2941	    && ! TREE_USED (decl)
2942	    && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2943	    /* The TREE_USED bit for file-scope decls
2944	       is kept in the identifier, to handle multiple
2945	       external decls in different scopes.  */
2946	    && ! TREE_USED (DECL_NAME (decl)))
2947	  warning_with_decl (decl, "`%s' defined but not used");
2948
2949#ifdef SDB_DEBUGGING_INFO
2950	/* The COFF linker can move initialized global vars to the end.
2951	   And that can screw up the symbol ordering.
2952	   By putting the symbols in that order to begin with,
2953	   we avoid a problem.  mcsun!unido!fauern!tumuc!pes@uunet.uu.net.  */
2954	if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2955	    && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2956	    && ! DECL_EXTERNAL (decl)
2957	    && DECL_RTL (decl) != 0)
2958	  TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2959
2960	/* Output COFF information for non-global
2961	   file-scope initialized variables.  */
2962	if (write_symbols == SDB_DEBUG
2963	    && TREE_CODE (decl) == VAR_DECL
2964	    && DECL_INITIAL (decl)
2965	    && ! DECL_EXTERNAL (decl)
2966	    && DECL_RTL (decl) != 0
2967	    && GET_CODE (DECL_RTL (decl)) == MEM)
2968	  TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2969#endif /* SDB_DEBUGGING_INFO */
2970#ifdef DWARF_DEBUGGING_INFO
2971	/* Output DWARF information for file-scope tentative data object
2972	   declarations, file-scope (extern) function declarations (which
2973	   had no corresponding body) and file-scope tagged type declarations
2974	   and definitions which have not yet been forced out.  */
2975
2976	if (write_symbols == DWARF_DEBUG
2977	    && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2978	  TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2979#endif
2980#ifdef DWARF2_DEBUGGING_INFO
2981	/* Output DWARF2 information for file-scope tentative data object
2982	   declarations, file-scope (extern) function declarations (which
2983	   had no corresponding body) and file-scope tagged type declarations
2984	   and definitions which have not yet been forced out.  */
2985
2986	if (write_symbols == DWARF2_DEBUG
2987	    && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2988	  TIMEVAR (symout_time, dwarf2out_decl (decl));
2989#endif
2990      }
2991  }
2992
2993  /* Write out any pending weak symbol declarations.  */
2994
2995  weak_finish ();
2996
2997  /* Do dbx symbols */
2998#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2999  if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3000    TIMEVAR (symout_time,
3001	     {
3002	       dbxout_finish (asm_out_file, main_input_filename);
3003	     });
3004#endif
3005
3006#ifdef DWARF_DEBUGGING_INFO
3007  if (write_symbols == DWARF_DEBUG)
3008    TIMEVAR (symout_time,
3009	     {
3010	       dwarfout_finish ();
3011	     });
3012#endif
3013
3014#ifdef DWARF2_UNWIND_INFO
3015  if (dwarf2out_do_frame ())
3016    dwarf2out_frame_finish ();
3017#endif
3018
3019#ifdef DWARF2_DEBUGGING_INFO
3020  if (write_symbols == DWARF2_DEBUG)
3021    TIMEVAR (symout_time,
3022	     {
3023	       dwarf2out_finish ();
3024	     });
3025#endif
3026
3027  /* Output some stuff at end of file if nec.  */
3028
3029  end_final (dump_base_name);
3030
3031  if (branch_prob_dump)
3032    open_dump_file (".bp", NULL);
3033
3034  TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
3035
3036  if (branch_prob_dump)
3037    close_dump_file (NULL, NULL_RTX);
3038
3039#ifdef ASM_FILE_END
3040  ASM_FILE_END (asm_out_file);
3041#endif
3042
3043  /* Language-specific end of compilation actions.  */
3044
3045  lang_finish ();
3046
3047  /* Close the dump files.  */
3048
3049  if (flag_gen_aux_info)
3050    {
3051      fclose (aux_info_file);
3052      if (errorcount)
3053	unlink (aux_info_file_name);
3054    }
3055
3056  if (combine_dump)
3057    {
3058      open_dump_file (".combine", NULL);
3059      TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
3060      close_dump_file (NULL, NULL_RTX);
3061    }
3062
3063  /* Close non-debugging input and output files.  Take special care to note
3064     whether fclose returns an error, since the pages might still be on the
3065     buffer chain while the file is open.  */
3066
3067  finish_parse ();
3068
3069  if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
3070    fatal_io_error (asm_file_name);
3071
3072  /* Print the times.  */
3073
3074  if (! quiet_flag)
3075    {
3076      fprintf (stderr,"\n");
3077      print_time ("parse", parse_time);
3078
3079      print_time ("integration", integration_time);
3080      print_time ("jump", jump_time);
3081      print_time ("cse", cse_time);
3082      print_time ("gcse", gcse_time);
3083      print_time ("loop", loop_time);
3084      print_time ("cse2", cse2_time);
3085      print_time ("branch-prob", branch_prob_time);
3086      print_time ("flow", flow_time);
3087      print_time ("combine", combine_time);
3088      print_time ("regmove", regmove_time);
3089      print_time ("sched", sched_time);
3090      print_time ("local-alloc", local_alloc_time);
3091      print_time ("global-alloc", global_alloc_time);
3092      print_time ("sched2", sched2_time);
3093#ifdef DELAY_SLOTS
3094      print_time ("dbranch", dbr_sched_time);
3095#endif
3096      print_time ("shorten-branch", shorten_branch_time);
3097      print_time ("stack-reg", stack_reg_time);
3098      print_time ("final", final_time);
3099      print_time ("varconst", varconst_time);
3100      print_time ("symout", symout_time);
3101      print_time ("dump", dump_time);
3102    }
3103}
3104
3105/* This is called from various places for FUNCTION_DECL, VAR_DECL,
3106   and TYPE_DECL nodes.
3107
3108   This does nothing for local (non-static) variables.
3109   Otherwise, it sets up the RTL and outputs any assembler code
3110   (label definition, storage allocation and initialization).
3111
3112   DECL is the declaration.  If ASMSPEC is nonzero, it specifies
3113   the assembler symbol name to be used.  TOP_LEVEL is nonzero
3114   if this declaration is not within a function.  */
3115
3116void
3117rest_of_decl_compilation (decl, asmspec, top_level, at_end)
3118     tree decl;
3119     char *asmspec;
3120     int top_level;
3121     int at_end;
3122{
3123  /* Declarations of variables, and of functions defined elsewhere.  */
3124
3125/* The most obvious approach, to put an #ifndef around where
3126   this macro is used, doesn't work since it's inside a macro call.  */
3127#ifndef ASM_FINISH_DECLARE_OBJECT
3128#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3129#endif
3130
3131  /* Forward declarations for nested functions are not "external",
3132     but we need to treat them as if they were.  */
3133  if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
3134      || TREE_CODE (decl) == FUNCTION_DECL)
3135    TIMEVAR (varconst_time,
3136	     {
3137	       make_decl_rtl (decl, asmspec, top_level);
3138	       /* Initialized extern variable exists to be replaced
3139		  with its value, or represents something that will be
3140		  output in another file.  */
3141	       if (! (TREE_CODE (decl) == VAR_DECL
3142		      && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
3143		      && DECL_INITIAL (decl) != 0
3144		      && DECL_INITIAL (decl) != error_mark_node))
3145		 /* Don't output anything
3146		    when a tentative file-scope definition is seen.
3147		    But at end of compilation, do output code for them.  */
3148		 if (! (! at_end && top_level
3149			&& (DECL_INITIAL (decl) == 0
3150			    || DECL_INITIAL (decl) == error_mark_node)))
3151		   assemble_variable (decl, top_level, at_end, 0);
3152	       if (decl == last_assemble_variable_decl)
3153		 {
3154		   ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
3155					      top_level, at_end);
3156		 }
3157	     });
3158  else if (DECL_REGISTER (decl) && asmspec != 0)
3159    {
3160      if (decode_reg_name (asmspec) >= 0)
3161	{
3162	  DECL_RTL (decl) = 0;
3163	  make_decl_rtl (decl, asmspec, top_level);
3164	}
3165      else
3166	error ("invalid register name `%s' for register variable", asmspec);
3167    }
3168#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3169  else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3170	   && TREE_CODE (decl) == TYPE_DECL)
3171    TIMEVAR (symout_time, dbxout_symbol (decl, 0));
3172#endif
3173#ifdef SDB_DEBUGGING_INFO
3174  else if (write_symbols == SDB_DEBUG && top_level
3175	   && TREE_CODE (decl) == TYPE_DECL)
3176    TIMEVAR (symout_time, sdbout_symbol (decl, 0));
3177#endif
3178}
3179
3180/* Called after finishing a record, union or enumeral type.  */
3181
3182void
3183rest_of_type_compilation (type, toplev)
3184     tree type;
3185     int toplev;
3186{
3187#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3188  if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3189    TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3190#endif
3191#ifdef SDB_DEBUGGING_INFO
3192  if (write_symbols == SDB_DEBUG)
3193    TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3194#endif
3195}
3196
3197/* This is called from finish_function (within yyparse)
3198   after each top-level definition is parsed.
3199   It is supposed to compile that function or variable
3200   and output the assembler code for it.
3201   After we return, the tree storage is freed.  */
3202
3203void
3204rest_of_compilation (decl)
3205     tree decl;
3206{
3207  register rtx insns;
3208  int start_time = get_run_time ();
3209  int tem;
3210  /* Nonzero if we have saved the original DECL_INITIAL of the function,
3211     to be restored after we finish compiling the function
3212     (for use when compiling inline calls to this function).  */
3213  tree saved_block_tree = 0;
3214  /* Likewise, for DECL_ARGUMENTS.  */
3215  tree saved_arguments = 0;
3216  int failure = 0;
3217
3218  /* If we are reconsidering an inline function
3219     at the end of compilation, skip the stuff for making it inline.  */
3220
3221  if (DECL_SAVED_INSNS (decl) == 0)
3222    {
3223      int inlinable = 0;
3224      char *lose;
3225
3226      /* If requested, consider whether to make this function inline.  */
3227      if (DECL_INLINE (decl) || flag_inline_functions)
3228	TIMEVAR (integration_time,
3229		 {
3230		   lose = function_cannot_inline_p (decl);
3231		   if (lose || ! optimize)
3232		     {
3233		       if (warn_inline && DECL_INLINE (decl))
3234			 warning_with_decl (decl, lose);
3235		       DECL_ABSTRACT_ORIGIN (decl) = 0;
3236		       /* Don't really compile an extern inline function.
3237			  If we can't make it inline, pretend
3238			  it was only declared.  */
3239		       if (DECL_EXTERNAL (decl))
3240			 {
3241			   DECL_INITIAL (decl) = 0;
3242			   goto exit_rest_of_compilation;
3243			 }
3244		     }
3245		   else
3246		     /* ??? Note that this has the effect of making it look
3247			like "inline" was specified for a function if we choose
3248			to inline it.  This isn't quite right, but it's
3249			probably not worth the trouble to fix.  */
3250		     inlinable = DECL_INLINE (decl) = 1;
3251		 });
3252
3253      insns = get_insns ();
3254
3255      /* Dump the rtl code if we are dumping rtl.  */
3256
3257      if (rtl_dump)
3258	{
3259	  open_dump_file (".rtl", decl_printable_name (decl, 2));
3260
3261	  if (DECL_SAVED_INSNS (decl))
3262	    fprintf (rtl_dump_file, ";; (integrable)\n\n");
3263
3264	  close_dump_file (print_rtl, insns);
3265	}
3266
3267      /* If we can, defer compiling inlines until EOF.
3268	 save_for_inline_copying can be extremely expensive.  */
3269      if (inlinable && ! decl_function_context (decl))
3270	DECL_DEFER_OUTPUT (decl) = 1;
3271
3272      /* If function is inline, and we don't yet know whether to
3273	 compile it by itself, defer decision till end of compilation.
3274	 finish_compilation will call rest_of_compilation again
3275	 for those functions that need to be output.  Also defer those
3276	 functions that we are supposed to defer.  We cannot defer
3277	 functions containing nested functions since the nested function
3278	 data is in our non-saved obstack.  We cannot defer nested
3279	 functions for the same reason.  */
3280
3281      /* If this is a nested inline, remove ADDRESSOF now so we can
3282	 finish compiling ourselves.  Otherwise, wait until EOF.
3283	 We have to do this because the purge_addressof transformation
3284	 changes the DECL_RTL for many variables, which confuses integrate.  */
3285      if (inlinable)
3286	{
3287	  if (decl_function_context (decl))
3288	    purge_addressof (insns);
3289	  else
3290	    DECL_DEFER_OUTPUT (decl) = 1;
3291	}
3292
3293      if (! current_function_contains_functions
3294	  && (DECL_DEFER_OUTPUT (decl)
3295	      || (DECL_INLINE (decl)
3296		  && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3297		       && ! flag_keep_inline_functions)
3298		      || DECL_EXTERNAL (decl)))))
3299	{
3300	  DECL_DEFER_OUTPUT (decl) = 1;
3301
3302	  /* If -Wreturn-type, we have to do a bit of compilation.
3303	     However, if we just fall through we will call
3304	     save_for_inline_copying() which results in excessive
3305	     memory use.  Instead, we just want to call
3306	     jump_optimize() to figure out whether or not we can fall
3307	     off the end of the function; we do the minimum amount of
3308	     work necessary to make that safe.  And, we set optimize
3309	     to zero to keep jump_optimize from working too hard.  */
3310	  if (warn_return_type)
3311	    {
3312	      int saved_optimize = optimize;
3313	      optimize = 0;
3314	      find_exception_handler_labels ();
3315	      jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3316			     !JUMP_AFTER_REGSCAN);
3317	      optimize = saved_optimize;
3318	    }
3319
3320#ifdef DWARF_DEBUGGING_INFO
3321	  /* Generate the DWARF info for the "abstract" instance
3322	     of a function which we may later generate inlined and/or
3323	     out-of-line instances of.  */
3324	  if (write_symbols == DWARF_DEBUG)
3325	    {
3326	      set_decl_abstract_flags (decl, 1);
3327	      TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3328	      set_decl_abstract_flags (decl, 0);
3329	    }
3330#endif
3331#ifdef DWARF2_DEBUGGING_INFO
3332	  /* Generate the DWARF2 info for the "abstract" instance
3333	     of a function which we may later generate inlined and/or
3334	     out-of-line instances of.  */
3335	  if (write_symbols == DWARF2_DEBUG)
3336	    {
3337	      set_decl_abstract_flags (decl, 1);
3338	      TIMEVAR (symout_time, dwarf2out_decl (decl));
3339	      set_decl_abstract_flags (decl, 0);
3340	    }
3341#endif
3342	  TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3343	  RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3344	  goto exit_rest_of_compilation;
3345	}
3346
3347      /* If we have to compile the function now, save its rtl and subdecls
3348	 so that its compilation will not affect what others get.  */
3349      if (inlinable || DECL_DEFER_OUTPUT (decl))
3350	{
3351#ifdef DWARF_DEBUGGING_INFO
3352	  /* Generate the DWARF info for the "abstract" instance of
3353	     a function which we will generate an out-of-line instance
3354	     of almost immediately (and which we may also later generate
3355	     various inlined instances of).  */
3356	  if (write_symbols == DWARF_DEBUG)
3357	    {
3358	      set_decl_abstract_flags (decl, 1);
3359	      TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3360	      set_decl_abstract_flags (decl, 0);
3361	    }
3362#endif
3363#ifdef DWARF2_DEBUGGING_INFO
3364	  /* Generate the DWARF2 info for the "abstract" instance of
3365	     a function which we will generate an out-of-line instance
3366	     of almost immediately (and which we may also later generate
3367	     various inlined instances of).  */
3368	  if (write_symbols == DWARF2_DEBUG)
3369	    {
3370	      set_decl_abstract_flags (decl, 1);
3371	      TIMEVAR (symout_time, dwarf2out_decl (decl));
3372	      set_decl_abstract_flags (decl, 0);
3373	    }
3374#endif
3375	  saved_block_tree = DECL_INITIAL (decl);
3376	  saved_arguments = DECL_ARGUMENTS (decl);
3377	  TIMEVAR (integration_time, save_for_inline_copying (decl));
3378	  RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3379	}
3380
3381      /* If specified extern inline but we aren't inlining it, we are
3382	 done.  */
3383      if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
3384	goto exit_rest_of_compilation;
3385    }
3386
3387  if (! DECL_DEFER_OUTPUT (decl))
3388    TREE_ASM_WRITTEN (decl) = 1;
3389
3390  /* Now that integrate will no longer see our rtl, we need not distinguish
3391     between the return value of this function and the return value of called
3392     functions.  */
3393  rtx_equal_function_value_matters = 0;
3394
3395  /* Don't return yet if -Wreturn-type; we need to do jump_optimize.  */
3396  if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3397    {
3398      goto exit_rest_of_compilation;
3399    }
3400
3401  /* Emit code to get eh context, if needed. */
3402  emit_eh_context ();
3403
3404#ifdef FINALIZE_PIC
3405  /* If we are doing position-independent code generation, now
3406     is the time to output special prologues and epilogues.
3407     We do not want to do this earlier, because it just clutters
3408     up inline functions with meaningless insns.  */
3409  if (flag_pic)
3410    FINALIZE_PIC;
3411#endif
3412
3413  /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3414     Note that that may have been done above, in save_for_inline_copying.
3415     The call to resume_temporary_allocation near the end of this function
3416     goes back to the usual state of affairs.  This must be done after
3417     we've built up any unwinders for exception handling, and done
3418     the FINALIZE_PIC work, if necessary.  */
3419
3420  rtl_in_current_obstack ();
3421
3422  insns = get_insns ();
3423
3424  /* Copy any shared structure that should not be shared.  */
3425
3426  unshare_all_rtl (insns);
3427
3428#ifdef SETJMP_VIA_SAVE_AREA
3429  /* This must be performed before virutal register instantiation.  */
3430  if (current_function_calls_alloca)
3431    optimize_save_area_alloca (insns);
3432#endif
3433
3434  /* Instantiate all virtual registers.  */
3435
3436  instantiate_virtual_regs (current_function_decl, get_insns ());
3437
3438  /* See if we have allocated stack slots that are not directly addressable.
3439     If so, scan all the insns and create explicit address computation
3440     for all references to such slots.  */
3441/*   fixup_stack_slots (); */
3442
3443  /* Find all the EH handlers.  */
3444  find_exception_handler_labels ();
3445
3446  /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3447     are initialized and to compute whether control can drop off the end
3448     of the function.  */
3449  TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3450  TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3451				     JUMP_AFTER_REGSCAN));
3452
3453  /* Now is when we stop if -fsyntax-only and -Wreturn-type.  */
3454  if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3455    goto exit_rest_of_compilation;
3456
3457  /* Dump rtl code after jump, if we are doing that.  */
3458
3459    if (jump_opt_dump)
3460      dump_rtl (".jump", decl, print_rtl, insns);
3461
3462  /* Perform common subexpression elimination.
3463     Nonzero value from `cse_main' means that jumps were simplified
3464     and some code may now be unreachable, so do
3465     jump optimization again.  */
3466
3467  if (optimize > 0)
3468    {
3469      if (cse_dump)
3470	open_dump_file (".cse", decl_printable_name (decl, 2));
3471
3472      TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3473
3474      if (flag_thread_jumps)
3475	/* Hacks by tiemann & kenner.  */
3476	TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3477
3478      TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3479					 0, rtl_dump_file));
3480      TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3481
3482      if (tem || optimize > 1)
3483	TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3484					   !JUMP_NOOP_MOVES,
3485					   !JUMP_AFTER_REGSCAN));
3486
3487      /* Dump rtl code after cse, if we are doing that.  */
3488
3489      if (cse_dump)
3490	close_dump_file (print_rtl, insns);
3491    }
3492
3493  purge_addressof (insns);
3494  reg_scan (insns, max_reg_num (), 1);
3495
3496  if (addressof_dump)
3497    dump_rtl (".addressof", decl, print_rtl, insns);
3498
3499  /* Perform global cse.  */
3500
3501  if (optimize > 0 && flag_gcse)
3502    {
3503      if (gcse_dump)
3504	open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl)));
3505
3506      TIMEVAR (gcse_time, gcse_main (insns, rtl_dump_file));
3507
3508      if (gcse_dump)
3509	close_dump_file (print_rtl, insns);
3510    }
3511  /* Move constant computations out of loops.  */
3512
3513  if (optimize > 0)
3514    {
3515      if (loop_dump)
3516	open_dump_file (".loop", decl_printable_name (decl, 2));
3517
3518      TIMEVAR
3519	(loop_time,
3520	 {
3521	   if (flag_rerun_loop_opt)
3522	     {
3523	       /* We only want to perform unrolling once.  */
3524
3525	       loop_optimize (insns, rtl_dump_file, 0);
3526
3527
3528	       /* The first call to loop_optimize makes some instructions
3529		  trivially dead.  We delete those instructions now in the
3530		  hope that doing so will make the heuristics in loop work
3531		  better and possibly speed up compilation.  */
3532	       delete_trivially_dead_insns (insns, max_reg_num ());
3533
3534	       /* The regscan pass is currently necessary as the alias
3535		  analysis code depends on this information.  */
3536	       reg_scan (insns, max_reg_num (), 1);
3537	     }
3538	   loop_optimize (insns, rtl_dump_file, flag_unroll_loops);
3539	 });
3540
3541      /* Dump rtl code after loop opt, if we are doing that.  */
3542
3543      if (loop_dump)
3544	close_dump_file (print_rtl, insns);
3545    }
3546
3547  if (optimize > 0)
3548    {
3549      if (cse2_dump)
3550	open_dump_file (".cse2", decl_printable_name (decl, 2));
3551
3552      if (flag_rerun_cse_after_loop)
3553	{
3554	  /* Running another jump optimization pass before the second
3555	     cse pass sometimes simplifies the RTL enough to allow
3556	     the second CSE pass to do a better job.  Jump_optimize can change
3557	     max_reg_num so we must rerun reg_scan afterwards.
3558	     ??? Rework to not call reg_scan so often.  */
3559	  TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3560	  TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3561					     !JUMP_NOOP_MOVES,
3562					     JUMP_AFTER_REGSCAN));
3563
3564	  TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3565	  TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3566					      1, rtl_dump_file));
3567	  if (tem)
3568	    TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3569					       !JUMP_NOOP_MOVES,
3570					       !JUMP_AFTER_REGSCAN));
3571	}
3572
3573      if (flag_thread_jumps)
3574	{
3575	  /* This pass of jump threading straightens out code
3576	     that was kinked by loop optimization.  */
3577	  TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3578	  TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3579	}
3580
3581      /* Dump rtl code after cse, if we are doing that.  */
3582
3583      if (cse2_dump)
3584	close_dump_file (print_rtl, insns);
3585    }
3586
3587  if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3588    {
3589      if (branch_prob_dump)
3590	open_dump_file (".bp", decl_printable_name (decl, 2));
3591
3592      TIMEVAR
3593	(branch_prob_time,
3594	 {
3595	   branch_prob (insns, rtl_dump_file);
3596	 });
3597
3598      if (branch_prob_dump)
3599	close_dump_file (print_rtl, insns);
3600    }
3601
3602  /* We are no longer anticipating cse in this function, at least.  */
3603
3604  cse_not_expected = 1;
3605
3606  /* Now we choose between stupid (pcc-like) register allocation
3607     (if we got the -noreg switch and not -opt)
3608     and smart register allocation.  */
3609
3610  if (optimize > 0)			/* Stupid allocation probably won't work */
3611    obey_regdecls = 0;		/* if optimizations being done.  */
3612
3613  regclass_init ();
3614
3615  /* Print function header into flow dump now
3616     because doing the flow analysis makes some of the dump.  */
3617
3618  if (flow_dump)
3619    open_dump_file (".flow", decl_printable_name (decl, 2));
3620
3621  if (obey_regdecls)
3622    {
3623      TIMEVAR (flow_time,
3624	       {
3625		 regclass (insns, max_reg_num ());
3626		 stupid_life_analysis (insns, max_reg_num (),
3627				       rtl_dump_file);
3628	       });
3629    }
3630  else
3631    {
3632      /* Do control and data flow analysis,
3633	 and write some of the results to dump file.  */
3634
3635      TIMEVAR
3636	(flow_time,
3637	 {
3638	   find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
3639	   life_analysis (insns, max_reg_num (), rtl_dump_file);
3640	 });
3641
3642      if (warn_uninitialized)
3643	{
3644	  uninitialized_vars_warning (DECL_INITIAL (decl));
3645	  setjmp_args_warning ();
3646	}
3647    }
3648
3649  /* Dump rtl after flow analysis.  */
3650
3651  if (flow_dump)
3652    close_dump_file (print_rtl_with_bb, insns);
3653
3654  /* If -opt, try combining insns through substitution.  */
3655
3656  if (optimize > 0)
3657    {
3658      TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3659
3660      /* Dump rtl code after insn combination.  */
3661
3662      if (combine_dump)
3663	dump_rtl (".combine", decl, print_rtl_with_bb, insns);
3664    }
3665
3666  /* Register allocation pre-pass, to reduce number of moves
3667     necessary for two-address machines.  */
3668  if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3669    {
3670      if (regmove_dump)
3671	open_dump_file (".regmove", decl_printable_name (decl, 2));
3672
3673      TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
3674					       rtl_dump_file));
3675
3676      if (regmove_dump)
3677	close_dump_file (print_rtl_with_bb, insns);
3678    }
3679
3680  /* Print function header into sched dump now
3681     because doing the sched analysis makes some of the dump.  */
3682
3683  if (optimize > 0 && flag_schedule_insns)
3684    {
3685      if (sched_dump)
3686	open_dump_file (".sched", decl_printable_name (decl, 2));
3687
3688      /* Do control and data sched analysis,
3689	 and write some of the results to dump file.  */
3690
3691      TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
3692
3693      /* Dump rtl after instruction scheduling.  */
3694
3695      if (sched_dump)
3696	close_dump_file (print_rtl_with_bb, insns);
3697    }
3698
3699  /* Unless we did stupid register allocation,
3700     allocate pseudo-regs that are used only within 1 basic block.  */
3701
3702  if (!obey_regdecls)
3703    TIMEVAR (local_alloc_time,
3704	     {
3705	       recompute_reg_usage (insns);
3706	       regclass (insns, max_reg_num ());
3707	       local_alloc ();
3708	     });
3709
3710  /* Dump rtl code after allocating regs within basic blocks.  */
3711
3712  if (local_reg_dump)
3713    {
3714      open_dump_file (".lreg", decl_printable_name (decl, 2));
3715
3716      TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
3717      TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
3718
3719      close_dump_file (print_rtl_with_bb, insns);
3720    }
3721
3722  if (global_reg_dump)
3723    open_dump_file (".greg", decl_printable_name (decl, 2));
3724
3725  /* Save the last label number used so far, so reorg can tell
3726     when it's safe to kill spill regs.  */
3727  max_label_num_after_reload = max_label_num ();
3728
3729  /* Unless we did stupid register allocation,
3730     allocate remaining pseudo-regs, then do the reload pass
3731     fixing up any insns that are invalid.  */
3732
3733  TIMEVAR (global_alloc_time,
3734	   {
3735	     if (!obey_regdecls)
3736	       failure = global_alloc (rtl_dump_file);
3737	     else
3738	       failure = reload (insns, 0, rtl_dump_file);
3739	   });
3740
3741
3742  if (failure)
3743    goto exit_rest_of_compilation;
3744
3745  reload_completed = 1;
3746
3747  /* Do a very simple CSE pass over just the hard registers.  */
3748  if (optimize > 0)
3749    reload_cse_regs (insns);
3750
3751  /* On some machines, the prologue and epilogue code, or parts thereof,
3752     can be represented as RTL.  Doing so lets us schedule insns between
3753     it and the rest of the code and also allows delayed branch
3754     scheduling to operate in the epilogue.  */
3755
3756  thread_prologue_and_epilogue_insns (insns);
3757
3758  if (global_reg_dump)
3759    {
3760      TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
3761      close_dump_file (print_rtl_with_bb, insns);
3762    }
3763  if (optimize > 0 && flag_schedule_insns_after_reload)
3764    {
3765      if (sched2_dump)
3766	open_dump_file (".sched2", decl_printable_name (decl, 2));
3767
3768      /* Do control and data sched analysis again,
3769	 and write some more of the results to dump file.  */
3770
3771      TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
3772
3773      /* Dump rtl after post-reorder instruction scheduling.  */
3774
3775      if (sched2_dump)
3776	close_dump_file (print_rtl_with_bb, insns);
3777    }
3778
3779#ifdef LEAF_REGISTERS
3780  leaf_function = 0;
3781  if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3782    leaf_function = 1;
3783#endif
3784
3785  /* One more attempt to remove jumps to .+1
3786     left by dead-store-elimination.
3787     Also do cross-jumping this time
3788     and delete no-op move insns.  */
3789
3790  if (optimize > 0)
3791    {
3792      TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
3793					 JUMP_NOOP_MOVES,
3794					 !JUMP_AFTER_REGSCAN));
3795
3796      /* Dump rtl code after jump, if we are doing that.  */
3797
3798      if (jump2_opt_dump)
3799	dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
3800    }
3801
3802  /* If a machine dependent reorganization is needed, call it.  */
3803#ifdef MACHINE_DEPENDENT_REORG
3804   MACHINE_DEPENDENT_REORG (insns);
3805
3806   if (mach_dep_reorg_dump)
3807     dump_rtl (".mach", decl, print_rtl_with_bb, insns);
3808#endif
3809
3810  /* If a scheduling pass for delayed branches is to be done,
3811     call the scheduling code.  */
3812
3813#ifdef DELAY_SLOTS
3814  if (optimize > 0 && flag_delayed_branch)
3815    {
3816      TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
3817
3818      if (dbr_sched_dump)
3819	dump_rtl (".dbr", decl, print_rtl_with_bb, insns);
3820    }
3821#endif
3822
3823  /* Shorten branches.  */
3824  TIMEVAR (shorten_branch_time,
3825	   {
3826	     shorten_branches (get_insns ());
3827	   });
3828
3829#ifdef STACK_REGS
3830  TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
3831
3832  if (stack_reg_dump)
3833    dump_rtl (".stack", decl, print_rtl_with_bb, insns);
3834#endif
3835
3836  /* Now turn the rtl into assembler code.  */
3837
3838  TIMEVAR (final_time,
3839	   {
3840	     rtx x;
3841	     char *fnname;
3842
3843	     /* Get the function's name, as described by its RTL.
3844		This may be different from the DECL_NAME name used
3845		in the source file.  */
3846
3847	     x = DECL_RTL (decl);
3848	     if (GET_CODE (x) != MEM)
3849	       abort ();
3850	     x = XEXP (x, 0);
3851	     if (GET_CODE (x) != SYMBOL_REF)
3852	       abort ();
3853	     fnname = XSTR (x, 0);
3854
3855	     assemble_start_function (decl, fnname);
3856	     final_start_function (insns, asm_out_file, optimize);
3857	     final (insns, asm_out_file, optimize, 0);
3858	     final_end_function (insns, asm_out_file, optimize);
3859	     assemble_end_function (decl, fnname);
3860	     if (! quiet_flag)
3861	       fflush (asm_out_file);
3862
3863	     /* Release all memory held by regsets now */
3864	     regset_release_memory ();
3865	   });
3866
3867  /* Write DBX symbols if requested */
3868
3869  /* Note that for those inline functions where we don't initially
3870     know for certain that we will be generating an out-of-line copy,
3871     the first invocation of this routine (rest_of_compilation) will
3872     skip over this code by doing a `goto exit_rest_of_compilation;'.
3873     Later on, finish_compilation will call rest_of_compilation again
3874     for those inline functions that need to have out-of-line copies
3875     generated.  During that call, we *will* be routed past here.  */
3876
3877#ifdef DBX_DEBUGGING_INFO
3878  if (write_symbols == DBX_DEBUG)
3879    TIMEVAR (symout_time, dbxout_function (decl));
3880#endif
3881
3882#ifdef DWARF_DEBUGGING_INFO
3883  if (write_symbols == DWARF_DEBUG)
3884    TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3885#endif
3886
3887#ifdef DWARF2_DEBUGGING_INFO
3888  if (write_symbols == DWARF2_DEBUG)
3889    TIMEVAR (symout_time, dwarf2out_decl (decl));
3890#endif
3891
3892 exit_rest_of_compilation:
3893
3894  /* In case the function was not output,
3895     don't leave any temporary anonymous types
3896     queued up for sdb output.  */
3897#ifdef SDB_DEBUGGING_INFO
3898  if (write_symbols == SDB_DEBUG)
3899    sdbout_types (NULL_TREE);
3900#endif
3901
3902  /* Put back the tree of subblocks and list of arguments
3903     from before we copied them.
3904     Code generation and the output of debugging info may have modified
3905     the copy, but the original is unchanged.  */
3906
3907  if (saved_block_tree != 0)
3908    {
3909      DECL_INITIAL (decl) = saved_block_tree;
3910      DECL_ARGUMENTS (decl) = saved_arguments;
3911      DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3912    }
3913
3914  reload_completed = 0;
3915
3916  TIMEVAR (final_time,
3917	   {
3918	      /* Clear out the insn_length contents now that they are no
3919		 longer valid.  */
3920	      init_insn_lengths ();
3921
3922	      /* Clear out the real_constant_chain before some of the rtx's
3923		 it runs through become garbage.  */
3924	      clear_const_double_mem ();
3925
3926	      /* Cancel the effect of rtl_in_current_obstack.  */
3927	      resume_temporary_allocation ();
3928
3929	      /* Show no temporary slots allocated.  */
3930	      init_temp_slots ();
3931	   });
3932
3933  /* Make sure volatile mem refs aren't considered valid operands for
3934     arithmetic insns.  We must call this here if this is a nested inline
3935     function, since the above code leaves us in the init_recog state
3936     (from final.c), and the function context push/pop code does not
3937     save/restore volatile_ok.
3938
3939     ??? Maybe it isn't necessary for expand_start_function to call this
3940     anymore if we do it here?  */
3941
3942  init_recog_no_volatile ();
3943
3944  /* The parsing time is all the time spent in yyparse
3945     *except* what is spent in this function.  */
3946
3947  parse_time -= get_run_time () - start_time;
3948}
3949
3950static void
3951display_help ()
3952{
3953  int    undoc;
3954  long	 i;
3955  char * lang;
3956
3957#ifndef USE_CPPLIB
3958  printf ("Usage: %s input [switches]\n", progname);
3959  printf ("Switches:\n");
3960#endif
3961  printf ("  -ffixed-<register>      Mark <register> as being unavailable to the compiler\n");
3962  printf ("  -fcall-used-<register>  Mark <register> as being corrupted by function calls\n");
3963  printf ("  -fcall-saved-<register> Mark <register> as being preserved across functions\n");
3964
3965  for (i = NUM_ELEM (f_options); i--;)
3966    {
3967      char * description = f_options[i].description;
3968
3969      if (description != NULL && * description != 0)
3970	printf ("  -f%-21s %s\n",
3971		f_options[i].string, description);
3972    }
3973
3974  printf ("  -O[number]              Set optimisation level to [number]\n");
3975  printf ("  -Os                     Optimise for space rather than speed\n");
3976  printf ("  -pedantic               Issue warnings needed by strict compliance to ANSI C\n");
3977  printf ("  -pedantic-errors        Like -pedantic except that errors are produced\n");
3978  printf ("  -w                      Suppress warnings\n");
3979  printf ("  -W                      Enable extra warnings\n");
3980
3981  for (i = NUM_ELEM (W_options); i--;)
3982    {
3983      char * description = W_options[i].description;
3984
3985      if (description != NULL && * description != 0)
3986	printf ("  -W%-21s %s\n",
3987		W_options[i].string, description);
3988    }
3989
3990  printf ("  -Wid-clash-<num>        Warn if 2 identifiers have the same first <num> chars\n");
3991  printf ("  -Wlarger-than-<number>  Warn if an object is larger than <number> bytes\n");
3992  printf ("  -p                      Enable function profiling\n");
3993#if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3994  printf ("  -a                      Enable block profiling \n");
3995#endif
3996#if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3997  printf ("  -ax                     Enable jump profiling \n");
3998#endif
3999  printf ("  -o <file>               Place output into <file> \n");
4000  printf ("  -G <number>             Put global and static data smaller than <number>\n");
4001  printf ("                           bytes into a special section (on some targets)\n");
4002
4003  for (i = NUM_ELEM (debug_args); i--;)
4004    {
4005      if (debug_args[i].description != NULL)
4006	printf ("  -%-22s %s\n", debug_args[i].arg, debug_args[i].description);
4007    }
4008
4009  printf ("  -aux-info <file>        Emit declaration info into <file>.X\n");
4010  printf ("  -quiet                  Do not display functions compiled or elapsed time\n");
4011  printf ("  -version                Display the compiler's version\n");
4012  printf ("  -d[letters]             Enable dumps from specific passes of the compiler\n");
4013  printf ("  -dumpbase <file>        Base name to be used for dumps from specific passes\n");
4014#if defined HAIFA || defined INSN_SCHEDULING
4015  printf ("  -sched-verbose-<number> Set the verbosity level of the scheduler\n");
4016#endif
4017  printf ("  --help                  Display this information\n");
4018
4019  undoc = 0;
4020  lang  = "language";
4021
4022  /* Display descriptions of language specific options.
4023     If there is no description, note that there is an undocumented option.
4024     If the description is empty, do not display anything.  (This allows
4025     options to be deliberately undocumented, for whatever reason).
4026     If the option string is missing, then this is a marker, indicating
4027     that the description string is in fact the name of a language, whoes
4028     language specific options are to follow.  */
4029
4030  if (NUM_ELEM (documented_lang_options) > 1)
4031    {
4032      int       looking_for_start = 0;
4033
4034      printf ("\nLanguage specific options:\n");
4035
4036      for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
4037	{
4038	  char * description = documented_lang_options[i].description;
4039	  char * option      = documented_lang_options[i].option;
4040
4041	  if (description == NULL)
4042	    undoc = 1;
4043	  else if (* description == 0)
4044	    continue;
4045	  else if (option == NULL)
4046	    {
4047	      if (undoc)
4048		printf
4049		  ("\nThere are undocumented %s specific options as well.\n",
4050			lang);
4051	      undoc = 0;
4052
4053	      printf ("\n Options for %s:\n", description);
4054
4055	      lang = description;
4056	    }
4057	  else
4058	    printf ("  %-23.23s %s\n", option, description);
4059	}
4060    }
4061
4062  if (undoc)
4063    printf ("\nThere are undocumented %s specific options as well.\n", lang);
4064
4065  if (NUM_ELEM (target_switches) > 1
4066#ifdef TARGET_OPTIONS
4067      || NUM_ELEM (target_options) > 1
4068#endif
4069      )
4070    {
4071      int doc = 0;
4072
4073      undoc = 0;
4074
4075      printf ("\nTarget specific options:\n");
4076
4077      for (i = NUM_ELEM (target_switches); i--;)
4078	{
4079	  char * option      = target_switches[i].name;
4080	  char * description = target_switches[i].description;
4081
4082	  if (option == NULL)
4083	    continue;
4084	  else if (description == NULL)
4085	    undoc = 1;
4086	  else if (* description != 0)
4087	    doc += printf ("  %-23.23s %s\n", option, description);
4088	}
4089
4090#ifdef TARGET_OPTIONS
4091      for (i = NUM_ELEM (target_options); i--;)
4092	{
4093	  char * option      = target_options[i].prefix;
4094	  char * description = target_options[i].description;
4095
4096	  if (option == NULL)
4097	    continue;
4098	  else if (description == NULL)
4099	    undoc = 1;
4100	  else if (* description != 0)
4101	    doc += printf ("  %-23.23s %s\n", option, description);
4102	}
4103#endif
4104      if (undoc)
4105	if (doc)
4106	  printf ("\nThere are undocumented target specific options as well.\n");
4107	else
4108	  printf ("  They exist, but they are not documented.\n");
4109    }
4110}
4111
4112/* Compare the user specified 'option' with the language
4113   specific 'lang_option'.  Return true if they match, or
4114   if 'option' is a viable prefix of 'lang_option'.  */
4115
4116static int
4117check_lang_option (option, lang_option)
4118     char * option;
4119     char * lang_option;
4120{
4121  lang_independent_options * indep_options;
4122  int    len;
4123  long    k;
4124
4125  /* Ignore NULL entries.  */
4126  if (option == NULL || lang_option == NULL)
4127    return 0;
4128
4129  len = strlen (lang_option);
4130
4131  /* If they do not match to the first n characters then fail.  */
4132  if (strncmp (option, lang_option, len) != 0)
4133    return 0;
4134
4135  /* Do not accept a lang option, if it matches a normal -f or -W
4136     option.  Chill defines a -fpack, but we want to support
4137     -fpack-struct.  */
4138
4139  /* An exact match is OK  */
4140  if (strlen (option) == len)
4141    return 1;
4142
4143  /* If it is not an -f or -W option allow the match */
4144  if (option[0] != '-')
4145    return 1;
4146
4147  switch (option[1])
4148    {
4149    case 'f': indep_options = f_options; break;
4150    case 'W': indep_options = W_options; break;
4151    default:  return 1;
4152    }
4153
4154  /* The option is a -f or -W option.
4155     Skip past the prefix and search for the remainder in the
4156     appropriate table of options.  */
4157  option += 2;
4158
4159  if (option[0] == 'n' && option[1] == 'o' && option[2] == '-')
4160    option += 3;
4161
4162  for (k = NUM_ELEM (indep_options); k--;)
4163    {
4164      if (!strcmp (option, indep_options[k].string))
4165	{
4166	  /* The option matched a language independent option,
4167	     do not allow the language specific match.  */
4168
4169	  return 0;
4170	}
4171    }
4172
4173  /* The option matches the start of the langauge specific option
4174     and it is not an exact match for a language independent option.  */
4175  return 1;
4176}
4177
4178/* Entry point of cc1/c++.  Decode command args, then call compile_file.
4179   Exit code is 35 if can't open files, 34 if fatal error,
4180   33 if had nonfatal errors, else success.  */
4181
4182int
4183main (argc, argv, envp)
4184     int argc;
4185     char **argv;
4186     char **envp;
4187{
4188  register int i;
4189  char *filename = 0;
4190  int flag_print_mem = 0;
4191  int version_flag = 0;
4192  char *p;
4193
4194  /* save in case md file wants to emit args as a comment.  */
4195  save_argc = argc;
4196  save_argv = argv;
4197
4198  p = argv[0] + strlen (argv[0]);
4199  while (p != argv[0] && p[-1] != '/'
4200#ifdef DIR_SEPARATOR
4201	 && p[-1] != DIR_SEPARATOR
4202#endif
4203	 )
4204    --p;
4205  progname = p;
4206
4207#if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
4208  /* Get rid of any avoidable limit on stack size.  */
4209  {
4210    struct rlimit rlim;
4211
4212    /* Set the stack limit huge so that alloca does not fail.  */
4213    getrlimit (RLIMIT_STACK, &rlim);
4214    rlim.rlim_cur = rlim.rlim_max;
4215    setrlimit (RLIMIT_STACK, &rlim);
4216  }
4217#endif
4218
4219  signal (SIGFPE, float_signal);
4220
4221#ifdef SIGPIPE
4222  signal (SIGPIPE, pipe_closed);
4223#endif
4224
4225  decl_printable_name = decl_name;
4226  lang_expand_expr = (struct rtx_def *(*)()) do_abort;
4227
4228  /* Initialize whether `char' is signed.  */
4229  flag_signed_char = DEFAULT_SIGNED_CHAR;
4230#ifdef DEFAULT_SHORT_ENUMS
4231  /* Initialize how much space enums occupy, by default.  */
4232  flag_short_enums = DEFAULT_SHORT_ENUMS;
4233#endif
4234
4235  /* Perform language-specific options intialization.  */
4236  lang_init_options ();
4237
4238  /* Scan to see what optimization level has been specified.  That will
4239     determine the default value of many flags.  */
4240  for (i = 1; i < argc; i++)
4241    {
4242      if (!strcmp (argv[i], "-O"))
4243	{
4244	  optimize = 1;
4245	}
4246      else if (argv[i][0] == '-' && argv[i][1] == 'O')
4247	{
4248	  /* Handle -Os, -O2, -O3, -O69, ...  */
4249	  char *p = &argv[i][2];
4250	  int c;
4251
4252	  if ((p[0] == 's') && (p[1] == 0))
4253	    optimize_size = 1;
4254	  else
4255	    {
4256	      while ((c = *p++))
4257		if (! (c >= '0' && c <= '9'))
4258		  break;
4259	      if (c == 0)
4260		optimize = atoi (&argv[i][2]);
4261	    }
4262	}
4263    }
4264
4265  /* Optimizing for size forces optimize to be no less than 2. */
4266  if (optimize_size && (optimize < 2))
4267    optimize = 2;
4268
4269  obey_regdecls = (optimize == 0);
4270
4271  if (optimize >= 1)
4272    {
4273      flag_defer_pop = 1;
4274      flag_thread_jumps = 1;
4275#ifdef DELAY_SLOTS
4276      flag_delayed_branch = 1;
4277#endif
4278#ifdef CAN_DEBUG_WITHOUT_FP
4279      flag_omit_frame_pointer = 1;
4280#endif
4281    }
4282
4283  if (optimize >= 2)
4284    {
4285      flag_cse_follow_jumps = 1;
4286      flag_cse_skip_blocks = 1;
4287      flag_gcse = 1;
4288      flag_expensive_optimizations = 1;
4289      flag_strength_reduce = 1;
4290      flag_rerun_cse_after_loop = 1;
4291      flag_rerun_loop_opt = 1;
4292      flag_caller_saves = 1;
4293      flag_force_mem = 1;
4294#ifdef INSN_SCHEDULING
4295      flag_schedule_insns = 1;
4296      flag_schedule_insns_after_reload = 1;
4297#endif
4298      flag_regmove = 1;
4299      /* We don't set flag_strict_aliasing here because we're still
4300	 testing the functionality.  After it has been tested, it
4301	 should be turned on here.  */
4302    }
4303
4304  if (optimize >= 3)
4305    {
4306      flag_inline_functions = 1;
4307    }
4308
4309  /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4310     modify it.  */
4311  target_flags = 0;
4312  set_target_switch ("");
4313
4314#ifdef OPTIMIZATION_OPTIONS
4315  /* Allow default optimizations to be specified on a per-machine basis.  */
4316  OPTIMIZATION_OPTIONS (optimize, optimize_size);
4317#endif
4318
4319  /* Initialize register usage now so switches may override.  */
4320  init_reg_sets ();
4321
4322  for (i = 1; i < argc; i++)
4323    {
4324      size_t j;
4325
4326      /* If this is a language-specific option,
4327	 decode it in a language-specific way.  */
4328      for (j = NUM_ELEM (documented_lang_options); j--;)
4329	if (check_lang_option (argv[i], documented_lang_options[j].option))
4330	  break;
4331
4332      if (j != -1)
4333	{
4334	  /* If the option is valid for *some* language,
4335	     treat it as valid even if this language doesn't understand it.  */
4336	  int strings_processed = lang_decode_option (argc - i, argv + i);
4337
4338	  /* BEGIN CYGNUS LOCAL  --help/nickc */
4339	  if (!strcmp (argv[i], "--help"))
4340	    {
4341	      display_help ();
4342	      exit (0);
4343	    }
4344	  /* END CYGNUS LOCAL */
4345
4346	  if (strings_processed != 0)
4347	    i += strings_processed - 1;
4348	}
4349      else if (argv[i][0] == '-' && argv[i][1] != 0)
4350	{
4351	  register char *str = argv[i] + 1;
4352	  if (str[0] == 'Y')
4353	    str++;
4354
4355	  if (str[0] == 'm')
4356	    set_target_switch (&str[1]);
4357	  else if (!strcmp (str, "dumpbase"))
4358	    {
4359	      dump_base_name = argv[++i];
4360	    }
4361	  else if (str[0] == 'd')
4362	    {
4363	      register char *p = &str[1];
4364	      while (*p)
4365		switch (*p++)
4366		  {
4367 		  case 'a':
4368		    branch_prob_dump = 1;
4369 		    combine_dump = 1;
4370#ifdef DELAY_SLOTS
4371 		    dbr_sched_dump = 1;
4372#endif
4373 		    flow_dump = 1;
4374 		    global_reg_dump = 1;
4375 		    jump_opt_dump = 1;
4376 		    addressof_dump = 1;
4377 		    jump2_opt_dump = 1;
4378 		    local_reg_dump = 1;
4379 		    loop_dump = 1;
4380		    regmove_dump = 1;
4381 		    rtl_dump = 1;
4382 		    cse_dump = 1, cse2_dump = 1;
4383		    gcse_dump = 1;
4384 		    sched_dump = 1;
4385 		    sched2_dump = 1;
4386#ifdef STACK_REGS
4387		    stack_reg_dump = 1;
4388#endif
4389#ifdef MACHINE_DEPENDENT_REORG
4390		    mach_dep_reorg_dump = 1;
4391#endif
4392		    break;
4393		  case 'A':
4394		    flag_debug_asm = 1;
4395		    break;
4396		  case 'b':
4397		    branch_prob_dump = 1;
4398		    break;
4399		  case 'c':
4400		    combine_dump = 1;
4401		    break;
4402#ifdef DELAY_SLOTS
4403		  case 'd':
4404		    dbr_sched_dump = 1;
4405		    break;
4406#endif
4407		  case 'f':
4408		    flow_dump = 1;
4409		    break;
4410		  case 'F':
4411		    addressof_dump = 1;
4412		    break;
4413		  case 'g':
4414		    global_reg_dump = 1;
4415		    break;
4416		  case 'G':
4417		    gcse_dump = 1;
4418		    break;
4419		  case 'j':
4420		    jump_opt_dump = 1;
4421		    break;
4422		  case 'J':
4423		    jump2_opt_dump = 1;
4424		    break;
4425#ifdef STACK_REGS
4426		  case 'k':
4427		    stack_reg_dump = 1;
4428		    break;
4429#endif
4430		  case 'l':
4431		    local_reg_dump = 1;
4432		    break;
4433		  case 'L':
4434		    loop_dump = 1;
4435		    break;
4436		  case 'm':
4437		    flag_print_mem = 1;
4438		    break;
4439#ifdef MACHINE_DEPENDENT_REORG
4440		  case 'M':
4441		    mach_dep_reorg_dump = 1;
4442		    break;
4443#endif
4444		  case 'p':
4445		    flag_print_asm_name = 1;
4446		    break;
4447		  case 'r':
4448		    rtl_dump = 1;
4449		    break;
4450		  case 'R':
4451		    sched2_dump = 1;
4452		    break;
4453		  case 's':
4454		    cse_dump = 1;
4455		    break;
4456		  case 'S':
4457		    sched_dump = 1;
4458		    break;
4459		  case 't':
4460		    cse2_dump = 1;
4461		    break;
4462		  case 'N':
4463		    regmove_dump = 1;
4464		    break;
4465		  case 'y':
4466		    set_yydebug (1);
4467		    break;
4468		  case 'x':
4469		    rtl_dump_and_exit = 1;
4470		    break;
4471		  default:
4472		    warning ("unrecognised gcc debugging option: %c", p[-1]);
4473		    break;
4474		  }
4475	    }
4476	  else if (str[0] == 'f')
4477	    {
4478	      register char *p = &str[1];
4479	      int found = 0;
4480
4481	      /* Some kind of -f option.
4482		 P's value is the option sans `-f'.
4483		 Search for it in the table of options.  */
4484
4485	      for (j = 0;
4486		   !found && j < sizeof (f_options) / sizeof (f_options[0]);
4487		   j++)
4488		{
4489		  if (!strcmp (p, f_options[j].string))
4490		    {
4491		      *f_options[j].variable = f_options[j].on_value;
4492		      /* A goto here would be cleaner,
4493			 but breaks the vax pcc.  */
4494		      found = 1;
4495		    }
4496		  if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4497		      && ! strcmp (p+3, f_options[j].string))
4498		    {
4499		      *f_options[j].variable = ! f_options[j].on_value;
4500		      found = 1;
4501		    }
4502		}
4503
4504	      if (found)
4505		;
4506#ifdef HAIFA
4507#ifdef INSN_SCHEDULING
4508	      else if (!strncmp (p, "sched-verbose-",14))
4509		fix_sched_param("verbose",&p[14]);
4510#endif
4511#endif  /* HAIFA */
4512	      else if (!strncmp (p, "fixed-", 6))
4513		fix_register (&p[6], 1, 1);
4514	      else if (!strncmp (p, "call-used-", 10))
4515		fix_register (&p[10], 0, 1);
4516	      else if (!strncmp (p, "call-saved-", 11))
4517		fix_register (&p[11], 0, 0);
4518	      else
4519		error ("Invalid option `%s'", argv[i]);
4520	    }
4521	  else if (str[0] == 'O')
4522	    {
4523	      register char *p = str+1;
4524	      if (*p == 's')
4525		p++;
4526	      else
4527		while (*p && *p >= '0' && *p <= '9')
4528		  p++;
4529	      if (*p == '\0')
4530		;
4531	      else
4532		error ("Invalid option `%s'", argv[i]);
4533	    }
4534	  else if (!strcmp (str, "pedantic"))
4535	    pedantic = 1;
4536	  else if (!strcmp (str, "pedantic-errors"))
4537	    flag_pedantic_errors = pedantic = 1;
4538	  else if (!strcmp (str, "quiet"))
4539	    quiet_flag = 1;
4540	  else if (!strcmp (str, "version"))
4541	    version_flag = 1;
4542	  else if (!strcmp (str, "w"))
4543	    inhibit_warnings = 1;
4544	  else if (!strcmp (str, "W"))
4545	    {
4546	      extra_warnings = 1;
4547	      /* We save the value of warn_uninitialized, since if they put
4548		 -Wuninitialized on the command line, we need to generate a
4549		 warning about not using it without also specifying -O.  */
4550	      if (warn_uninitialized != 1)
4551		warn_uninitialized = 2;
4552	    }
4553	  else if (str[0] == 'W')
4554	    {
4555	      register char *p = &str[1];
4556	      int found = 0;
4557
4558	      /* Some kind of -W option.
4559		 P's value is the option sans `-W'.
4560		 Search for it in the table of options.  */
4561
4562	      for (j = 0;
4563		   !found && j < sizeof (W_options) / sizeof (W_options[0]);
4564		   j++)
4565		{
4566		  if (!strcmp (p, W_options[j].string))
4567		    {
4568		      *W_options[j].variable = W_options[j].on_value;
4569		      /* A goto here would be cleaner,
4570			 but breaks the vax pcc.  */
4571		      found = 1;
4572		    }
4573		  if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4574		      && ! strcmp (p+3, W_options[j].string))
4575		    {
4576		      *W_options[j].variable = ! W_options[j].on_value;
4577		      found = 1;
4578		    }
4579		}
4580
4581	      if (found)
4582		;
4583	      else if (!strncmp (p, "id-clash-", 9))
4584		{
4585		  char *endp = p + 9;
4586
4587		  while (*endp)
4588		    {
4589		      if (*endp >= '0' && *endp <= '9')
4590			endp++;
4591		      else
4592			{
4593			  error ("Invalid option `%s'", argv[i]);
4594			  goto id_clash_lose;
4595			}
4596		    }
4597		  warn_id_clash = 1;
4598		  id_clash_len = atoi (str + 10);
4599		id_clash_lose: ;
4600		}
4601	      else if (!strncmp (p, "larger-than-", 12))
4602		{
4603		  char *endp = p + 12;
4604
4605		  while (*endp)
4606		    {
4607		      if (*endp >= '0' && *endp <= '9')
4608			endp++;
4609		      else
4610			{
4611			  error ("Invalid option `%s'", argv[i]);
4612			  goto larger_than_lose;
4613			}
4614		    }
4615		  warn_larger_than = 1;
4616		  larger_than_size = atoi (str + 13);
4617		larger_than_lose: ;
4618		}
4619	      else
4620		error ("Invalid option `%s'", argv[i]);
4621	    }
4622	  else if (!strcmp (str, "p"))
4623	    {
4624	      profile_flag = 1;
4625	    }
4626	  else if (!strcmp (str, "a"))
4627	    {
4628#if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4629	      warning ("`-a' option (basic block profile) not supported");
4630#else
4631              profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4632#endif
4633	    }
4634	  else if (!strcmp (str, "ax"))
4635	    {
4636#if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4637	      warning ("`-ax' option (jump profiling) not supported");
4638#else
4639	      profile_block_flag = (!profile_block_flag
4640	                               || profile_block_flag == 2) ? 2 : 3;
4641#endif
4642	    }
4643	  else if (str[0] == 'g')
4644	    {
4645	      unsigned len;
4646	      unsigned level;
4647	      /* A lot of code assumes write_symbols == NO_DEBUG if the
4648		 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4649		 of what debugging type has been selected).  This records the
4650		 selected type.  It is an error to specify more than one
4651		 debugging type.  */
4652	      static enum debug_info_type selected_debug_type = NO_DEBUG;
4653	      /* Non-zero if debugging format has been explicitly set.
4654		 -g and -ggdb don't explicitly set the debugging format so
4655		 -gdwarf -g3 is equivalent to -gdwarf3.  */
4656	      static int type_explicitly_set_p = 0;
4657	      /* Indexed by enum debug_info_type.  */
4658	      static char *debug_type_names[] =
4659	      {
4660		"none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4661	      };
4662
4663	      /* Look up STR in the table.  */
4664	      for (da = debug_args; da->arg; da++)
4665		{
4666		  if (! strncmp (str, da->arg, strlen (da->arg)))
4667		    {
4668		      enum debug_info_type type = da->debug_type;
4669		      char *p, *q;
4670
4671		      p = str + strlen (da->arg);
4672		      if (*p && (*p < '0' || *p > '9'))
4673			continue;
4674		      len = p - str;
4675		      q = p;
4676		      while (*q && (*q >= '0' && *q <= '9'))
4677			q++;
4678		      if (*p)
4679			{
4680			  level = atoi (p);
4681			  if (len > 1 && !strncmp (str, "gdwarf", len))
4682			    {
4683			      error ("use -gdwarf -g%d for DWARF v1, level %d",
4684				       level, level);
4685			      if (level == 2)
4686				error ("use -gdwarf-2   for DWARF v2");
4687			    }
4688			}
4689		      else
4690			level = 2;	/* default debugging info level */
4691		      if (*q || level > 3)
4692			{
4693			  warning ("invalid debug level specification in option: `-%s'",
4694				   str);
4695			  /* ??? This error message is incorrect in the case of
4696			     -g4 -g.  */
4697			  warning ("no debugging information will be generated");
4698			  level = 0;
4699			}
4700
4701		      if (type == NO_DEBUG)
4702			{
4703			  type = PREFERRED_DEBUGGING_TYPE;
4704			  if (len > 1 && strncmp (str, "ggdb", len) == 0)
4705			    {
4706#if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4707			      type = DWARF2_DEBUG;
4708#else
4709#ifdef DBX_DEBUGGING_INFO
4710			      type = DBX_DEBUG;
4711#endif
4712#endif
4713			    }
4714			}
4715
4716		      if (type == NO_DEBUG)
4717			warning ("`-%s' not supported by this configuration of GCC",
4718				 str);
4719
4720		      /* Does it conflict with an already selected type?  */
4721		      if (type_explicitly_set_p
4722			  /* -g/-ggdb don't conflict with anything */
4723			  && da->debug_type != NO_DEBUG
4724			  && type != selected_debug_type)
4725			warning ("`-%s' ignored, conflicts with `-g%s'",
4726				 str, debug_type_names[(int) selected_debug_type]);
4727		      else
4728			{
4729			  /* If the format has already been set, -g/-ggdb
4730			     only change the debug level.  */
4731			  if (type_explicitly_set_p
4732			      && da->debug_type == NO_DEBUG)
4733			    ; /* don't change debugging type */
4734			  else
4735			    {
4736			      selected_debug_type = type;
4737			      type_explicitly_set_p = da->debug_type != NO_DEBUG;
4738			    }
4739			  write_symbols = (level == 0
4740					   ? NO_DEBUG
4741					   : selected_debug_type);
4742			  use_gnu_debug_info_extensions = da->use_extensions_p;
4743			  debug_info_level = (enum debug_info_level) level;
4744			}
4745		      break;
4746		    }
4747		}
4748	      if (! da->arg)
4749		warning ("`-%s' not supported by this configuration of GCC",
4750			 str);
4751	    }
4752	  else if (!strcmp (str, "o"))
4753	    {
4754	      asm_file_name = argv[++i];
4755	    }
4756	  else if (str[0] == 'G')
4757	    {
4758	      g_switch_set = TRUE;
4759	      g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
4760	    }
4761	  else if (!strncmp (str, "aux-info", 8))
4762	    {
4763	      flag_gen_aux_info = 1;
4764	      aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
4765	    }
4766	  else if (!strcmp (str, "-help"))
4767	    {
4768	      display_help ();
4769	      exit (0);
4770	    }
4771	  else
4772	    error ("Invalid option `%s'", argv[i]);
4773	}
4774      else if (argv[i][0] == '+')
4775	error ("Invalid option `%s'", argv[i]);
4776      else
4777	filename = argv[i];
4778    }
4779
4780  /* Checker uses the frame pointer.  */
4781  if (flag_check_memory_usage)
4782    flag_omit_frame_pointer = 0;
4783
4784  if (optimize == 0)
4785    {
4786      /* Inlining does not work if not optimizing,
4787	 so force it not to be done.  */
4788      flag_no_inline = 1;
4789      warn_inline = 0;
4790
4791      /* The c_decode_option and lang_decode_option functions set
4792	 this to `2' if -Wall is used, so we can avoid giving out
4793	 lots of errors for people who don't realize what -Wall does.  */
4794      if (warn_uninitialized == 1)
4795	warning ("-Wuninitialized is not supported without -O");
4796    }
4797
4798#ifdef OVERRIDE_OPTIONS
4799  /* Some machines may reject certain combinations of options.  */
4800  OVERRIDE_OPTIONS;
4801#endif
4802
4803  if (exceptions_via_longjmp == 2)
4804    {
4805#ifdef DWARF2_UNWIND_INFO
4806      exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4807#else
4808      exceptions_via_longjmp = 1;
4809#endif
4810    }
4811
4812  if (profile_block_flag == 3)
4813    {
4814      warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4815      profile_block_flag = 2;
4816    }
4817
4818  /* Unrolling all loops implies that standard loop unrolling must also
4819     be done.  */
4820  if (flag_unroll_all_loops)
4821    flag_unroll_loops = 1;
4822  /* Loop unrolling requires that strength_reduction be on also.  Silently
4823     turn on strength reduction here if it isn't already on.  Also, the loop
4824     unrolling code assumes that cse will be run after loop, so that must
4825     be turned on also.  */
4826  if (flag_unroll_loops)
4827    {
4828      flag_strength_reduce = 1;
4829      flag_rerun_cse_after_loop = 1;
4830    }
4831
4832  /* Warn about options that are not supported on this machine.  */
4833#ifndef INSN_SCHEDULING
4834  if (flag_schedule_insns || flag_schedule_insns_after_reload)
4835    warning ("instruction scheduling not supported on this target machine");
4836#endif
4837#ifndef DELAY_SLOTS
4838  if (flag_delayed_branch)
4839    warning ("this target machine does not have delayed branches");
4840#endif
4841
4842  /* If we are in verbose mode, write out the version and maybe all the
4843     option flags in use.  */
4844  if (version_flag)
4845    {
4846      print_version (stderr, "");
4847      if (! quiet_flag)
4848	print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4849    }
4850
4851  compile_file (filename);
4852
4853#if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4854  if (flag_print_mem)
4855    {
4856      char *lim = (char *) sbrk (0);
4857
4858      fprintf (stderr, "Data size %ld.\n", (long)(lim - (char *) &environ));
4859      fflush (stderr);
4860
4861#ifndef __MSDOS__
4862#ifdef USG
4863      system ("ps -l 1>&2");
4864#else /* not USG */
4865      system ("ps v");
4866#endif /* not USG */
4867#endif
4868    }
4869#endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4870
4871  if (errorcount)
4872    exit (FATAL_EXIT_CODE);
4873  if (sorrycount)
4874    exit (FATAL_EXIT_CODE);
4875  exit (SUCCESS_EXIT_CODE);
4876  return 0;
4877}
4878
4879/* Decode -m switches.  */
4880/* Decode the switch -mNAME.  */
4881
4882void
4883set_target_switch (name)
4884     char *name;
4885{
4886  register size_t j;
4887  int valid = 0;
4888
4889  for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4890    if (!strcmp (target_switches[j].name, name))
4891      {
4892	if (target_switches[j].value < 0)
4893	  target_flags &= ~-target_switches[j].value;
4894	else
4895	  target_flags |= target_switches[j].value;
4896	valid = 1;
4897      }
4898
4899#ifdef TARGET_OPTIONS
4900  if (!valid)
4901    for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4902      {
4903	int len = strlen (target_options[j].prefix);
4904	if (!strncmp (target_options[j].prefix, name, len))
4905	  {
4906	    *target_options[j].variable = name + len;
4907	    valid = 1;
4908	  }
4909      }
4910#endif
4911
4912  if (!valid)
4913    error ("Invalid option `%s'", name);
4914}
4915
4916/* Print version information to FILE.
4917   Each line begins with INDENT (for the case where FILE is the
4918   assembler output file).  */
4919
4920void
4921print_version (file, indent)
4922     FILE *file;
4923     char *indent;
4924{
4925  fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4926	   language_string, version_string);
4927  fprintf (file, " (%s)", TARGET_NAME);
4928#ifdef __GNUC__
4929#ifndef __VERSION__
4930#define __VERSION__ "[unknown]"
4931#endif
4932  fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4933#else
4934  fprintf (file, " compiled by CC.\n");
4935#endif
4936}
4937
4938/* Print an option value and return the adjusted position in the line.
4939   ??? We don't handle error returns from fprintf (disk full); presumably
4940   other code will catch a disk full though.  */
4941
4942int
4943print_single_switch (file, pos, max, indent, sep, term, type, name)
4944     FILE *file;
4945     int pos, max;
4946     char *indent, *sep, *term, *type, *name;
4947{
4948  /* The ultrix fprintf returns 0 on success, so compute the result we want
4949     here since we need it for the following test.  */
4950  int len = strlen (sep) + strlen (type) + strlen (name);
4951
4952  if (pos != 0
4953      && pos + len > max)
4954    {
4955      fprintf (file, "%s", term);
4956      pos = 0;
4957    }
4958  if (pos == 0)
4959    {
4960      fprintf (file, "%s", indent);
4961      pos = strlen (indent);
4962    }
4963  fprintf (file, "%s%s%s", sep, type, name);
4964  pos += len;
4965  return pos;
4966}
4967
4968/* Print active target switches to FILE.
4969   POS is the current cursor position and MAX is the size of a "line".
4970   Each line begins with INDENT and ends with TERM.
4971   Each switch is separated from the next by SEP.  */
4972
4973void
4974print_switch_values (file, pos, max, indent, sep, term)
4975     FILE *file;
4976     int pos, max;
4977     char *indent, *sep, *term;
4978{
4979  size_t j;
4980  char **p;
4981
4982  /* Print the options as passed.  */
4983
4984  pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4985			     "options passed: ", "");
4986
4987  for (p = &save_argv[1]; *p != NULL; p++)
4988    if (**p == '-')
4989      {
4990	/* Ignore these.  */
4991	if (strcmp (*p, "-o") == 0)
4992	  {
4993	    if (p[1] != NULL)
4994	      p++;
4995	    continue;
4996	  }
4997	if (strcmp (*p, "-quiet") == 0)
4998	  continue;
4999	if (strcmp (*p, "-version") == 0)
5000	  continue;
5001	if ((*p)[1] == 'd')
5002	  continue;
5003
5004	pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5005      }
5006  if (pos > 0)
5007    fprintf (file, "%s", term);
5008
5009  /* Print the -f and -m options that have been enabled.
5010     We don't handle language specific options but printing argv
5011     should suffice.  */
5012
5013  pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5014			     "options enabled: ", "");
5015
5016  for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
5017    if (*f_options[j].variable == f_options[j].on_value)
5018      pos = print_single_switch (file, pos, max, indent, sep, term,
5019				 "-f", f_options[j].string);
5020
5021  /* Print target specific options.  */
5022
5023  for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5024    if (target_switches[j].name[0] != '\0'
5025	&& target_switches[j].value > 0
5026	&& ((target_switches[j].value & target_flags)
5027	    == target_switches[j].value))
5028      {
5029	pos = print_single_switch (file, pos, max, indent, sep, term,
5030				   "-m", target_switches[j].name);
5031      }
5032
5033#ifdef TARGET_OPTIONS
5034  for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5035    if (*target_options[j].variable != NULL)
5036      {
5037	char prefix[256];
5038	sprintf (prefix, "-m%s", target_options[j].prefix);
5039	pos = print_single_switch (file, pos, max, indent, sep, term,
5040				   prefix, *target_options[j].variable);
5041      }
5042#endif
5043
5044  fprintf (file, "%s", term);
5045}
5046
5047/* Record the beginning of a new source file, named FILENAME.  */
5048
5049void
5050debug_start_source_file (filename)
5051     register char *filename;
5052{
5053#ifdef DBX_DEBUGGING_INFO
5054  if (write_symbols == DBX_DEBUG)
5055    dbxout_start_new_source_file (filename);
5056#endif
5057#ifdef DWARF_DEBUGGING_INFO
5058  if (debug_info_level == DINFO_LEVEL_VERBOSE
5059      && write_symbols == DWARF_DEBUG)
5060    dwarfout_start_new_source_file (filename);
5061#endif /* DWARF_DEBUGGING_INFO */
5062#ifdef DWARF2_DEBUGGING_INFO
5063  if (debug_info_level == DINFO_LEVEL_VERBOSE
5064      && write_symbols == DWARF2_DEBUG)
5065    dwarf2out_start_source_file (filename);
5066#endif /* DWARF2_DEBUGGING_INFO */
5067#ifdef SDB_DEBUGGING_INFO
5068  if (write_symbols == SDB_DEBUG)
5069    sdbout_start_new_source_file (filename);
5070#endif
5071}
5072
5073/* Record the resumption of a source file.  LINENO is the line number in
5074   the source file we are returning to.  */
5075
5076void
5077debug_end_source_file (lineno)
5078     register unsigned lineno;
5079{
5080#ifdef DBX_DEBUGGING_INFO
5081  if (write_symbols == DBX_DEBUG)
5082    dbxout_resume_previous_source_file ();
5083#endif
5084#ifdef DWARF_DEBUGGING_INFO
5085  if (debug_info_level == DINFO_LEVEL_VERBOSE
5086      && write_symbols == DWARF_DEBUG)
5087    dwarfout_resume_previous_source_file (lineno);
5088#endif /* DWARF_DEBUGGING_INFO */
5089#ifdef DWARF2_DEBUGGING_INFO
5090  if (debug_info_level == DINFO_LEVEL_VERBOSE
5091      && write_symbols == DWARF2_DEBUG)
5092    dwarf2out_end_source_file ();
5093#endif /* DWARF2_DEBUGGING_INFO */
5094#ifdef SDB_DEBUGGING_INFO
5095  if (write_symbols == SDB_DEBUG)
5096    sdbout_resume_previous_source_file ();
5097#endif
5098}
5099
5100/* Called from check_newline in c-parse.y.  The `buffer' parameter contains
5101   the tail part of the directive line, i.e. the part which is past the
5102   initial whitespace, #, whitespace, directive-name, whitespace part.  */
5103
5104void
5105debug_define (lineno, buffer)
5106     register unsigned lineno;
5107     register char *buffer;
5108{
5109#ifdef DWARF_DEBUGGING_INFO
5110  if (debug_info_level == DINFO_LEVEL_VERBOSE
5111      && write_symbols == DWARF_DEBUG)
5112    dwarfout_define (lineno, buffer);
5113#endif /* DWARF_DEBUGGING_INFO */
5114#ifdef DWARF2_DEBUGGING_INFO
5115  if (debug_info_level == DINFO_LEVEL_VERBOSE
5116      && write_symbols == DWARF2_DEBUG)
5117    dwarf2out_define (lineno, buffer);
5118#endif /* DWARF2_DEBUGGING_INFO */
5119}
5120
5121/* Called from check_newline in c-parse.y.  The `buffer' parameter contains
5122   the tail part of the directive line, i.e. the part which is past the
5123   initial whitespace, #, whitespace, directive-name, whitespace part.  */
5124
5125void
5126debug_undef (lineno, buffer)
5127     register unsigned lineno;
5128     register char *buffer;
5129{
5130#ifdef DWARF_DEBUGGING_INFO
5131  if (debug_info_level == DINFO_LEVEL_VERBOSE
5132      && write_symbols == DWARF_DEBUG)
5133    dwarfout_undef (lineno, buffer);
5134#endif /* DWARF_DEBUGGING_INFO */
5135#ifdef DWARF2_DEBUGGING_INFO
5136  if (debug_info_level == DINFO_LEVEL_VERBOSE
5137      && write_symbols == DWARF2_DEBUG)
5138    dwarf2out_undef (lineno, buffer);
5139#endif /* DWARF2_DEBUGGING_INFO */
5140}
5141