OSDN Git Service

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