OSDN Git Service

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