OSDN Git Service

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