OSDN Git Service

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