OSDN Git Service

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