OSDN Git Service

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