OSDN Git Service

* cse.c: Update comments.
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
1 /* Top level of GNU C compiler
2    Copyright (C) 1987, 88, 89, 92-98, 1999 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 #undef FLOAT /* This is for hpux. They should change hpux.  */
28 #undef FFS  /* Some systems define this in param.h.  */
29 #include "system.h"
30 #include <signal.h>
31 #include <setjmp.h>
32
33 #ifdef HAVE_SYS_RESOURCE_H
34 # include <sys/resource.h>
35 #endif
36
37 #ifdef HAVE_SYS_TIMES_H
38 # include <sys/times.h>
39 #endif
40
41 #include "input.h"
42 #include "tree.h"
43 #include "rtl.h"
44 #include "tm_p.h"
45 #include "flags.h"
46 #include "insn-attr.h"
47 #include "insn-codes.h"
48 #include "insn-config.h"
49 #include "recog.h"
50 #include "defaults.h"
51 #include "output.h"
52 #include "except.h"
53 #include "function.h"
54 #include "toplev.h"
55 #include "expr.h"
56 #include "basic-block.h"
57 #include "intl.h"
58 #include "ggc.h"
59
60 #ifdef DWARF_DEBUGGING_INFO
61 #include "dwarfout.h"
62 #endif
63
64 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
65 #include "dwarf2out.h"
66 #endif
67
68 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
69 #include "dbxout.h"
70 #endif
71
72 #ifdef SDB_DEBUGGING_INFO
73 #include "sdbout.h"
74 #endif
75
76 #ifdef XCOFF_DEBUGGING_INFO
77 #include "xcoffout.h"
78 #endif
79 \f
80 #ifdef VMS
81 /* The extra parameters substantially improve the I/O performance.  */
82 static FILE *
83 vms_fopen (fname, type)
84      char * fname;
85      char * type;
86 {
87   /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
88      fixed arguments, which matches ANSI's specification but not VAXCRTL's
89      pre-ANSI implementation.  This hack circumvents the mismatch problem.  */
90   FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
91
92   if (*type == 'w')
93     return (*vmslib_fopen) (fname, type, "mbc=32",
94                             "deq=64", "fop=tef", "shr=nil");
95   else
96     return (*vmslib_fopen) (fname, type, "mbc=32");
97 }
98 #define fopen vms_fopen
99 #endif  /* VMS */
100
101 #ifndef DEFAULT_GDB_EXTENSIONS
102 #define DEFAULT_GDB_EXTENSIONS 1
103 #endif
104
105 /* If more than one debugging type is supported, you must define
106    PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way. 
107
108    This is one long line cause VAXC can't handle a \-newline.  */
109 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
110 #ifndef PREFERRED_DEBUGGING_TYPE
111 You Lose!  You must define PREFERRED_DEBUGGING_TYPE!
112 #endif /* no PREFERRED_DEBUGGING_TYPE */
113 #else /* Only one debugging format supported.  Define PREFERRED_DEBUGGING_TYPE
114          so the following code needn't care.  */
115 #ifdef DBX_DEBUGGING_INFO
116 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
117 #endif
118 #ifdef SDB_DEBUGGING_INFO
119 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
120 #endif
121 #ifdef DWARF_DEBUGGING_INFO
122 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
123 #endif
124 #ifdef DWARF2_DEBUGGING_INFO
125 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
126 #endif
127 #ifdef XCOFF_DEBUGGING_INFO
128 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
129 #endif
130 #endif /* More than one debugger format enabled.  */
131
132 /* If still not defined, must have been because no debugging formats
133    are supported.  */
134 #ifndef PREFERRED_DEBUGGING_TYPE
135 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
136 #endif
137
138 #ifndef DIR_SEPARATOR
139 #define DIR_SEPARATOR '/'
140 #endif
141
142 #if ! (defined (VMS) || defined (OS2))
143 extern char **environ;
144 #endif
145 extern char *version_string;
146
147 /* Carry information from ASM_DECLARE_OBJECT_NAME
148    to ASM_FINISH_DECLARE_OBJECT.  */
149
150 extern int size_directive_output;
151 extern tree last_assemble_variable_decl;
152
153 static void notice PVPROTO((const char *s, ...)) ATTRIBUTE_PRINTF_1;
154 static void set_target_switch PROTO((const char *));
155 static const char *decl_name PROTO((tree, int));
156 static void vmessage PROTO((const char *, const char *, va_list));
157 static void v_message_with_file_and_line PROTO((const char *, int, int,
158                                                 const char *, va_list));
159 static void v_message_with_decl PROTO((tree, int, const char *, va_list));
160 static void file_and_line_for_asm PROTO((rtx, char **, int *));
161 static void v_error_with_file_and_line PROTO((const char *, int,
162                                               const char *, va_list));
163 static void v_error_with_decl PROTO((tree, const char *, va_list));
164 static void v_error_for_asm PROTO((rtx, const char *, va_list));
165 static void verror PROTO((const char *, va_list));
166 static void vfatal PROTO((const char *, va_list)) ATTRIBUTE_NORETURN;
167 static void v_warning_with_file_and_line PROTO ((const char *, int,
168                                                  const char *, va_list));
169 static void v_warning_with_decl PROTO((tree, const char *, va_list));
170 static void v_warning_for_asm PROTO((rtx, const char *, va_list));
171 static void vwarning PROTO((const char *, va_list));
172 static void vpedwarn PROTO((const char *, va_list));
173 static void v_pedwarn_with_decl PROTO((tree, const char *, va_list));
174 static void v_pedwarn_with_file_and_line PROTO((const char *, int,
175                                                 const char *, va_list));
176 static void vsorry PROTO((const char *, va_list));
177 extern void set_fatal_function PROTO((void (*)(const char *, va_list)));
178 static void float_signal PROTO((int)) ATTRIBUTE_NORETURN;
179 static void pipe_closed PROTO((int)) ATTRIBUTE_NORETURN;
180 #ifdef ASM_IDENTIFY_LANGUAGE
181 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
182 static void output_lang_identify PROTO((FILE *)) ATTRIBUTE_UNUSED;
183 #endif
184 static void open_dump_file PROTO((const char *, const char *));
185 static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
186 static void dump_rtl PROTO((const char *, tree, void (*) (FILE *, rtx), rtx));
187 static void clean_dump_file PROTO((const char *));
188 static void compile_file PROTO((char *));
189 static void display_help PROTO ((void));
190 static void report_file_and_line PROTO ((const char *, int, int));
191 static void vnotice PROTO ((FILE *, const char *, va_list));
192 static void mark_file_stack PROTO ((void *));
193
194 static void decode_d_option PROTO ((const char *));
195 static int  decode_f_option PROTO ((const char *));
196 static int  decode_W_option PROTO ((const char *));
197 static int  decode_g_option PROTO ((const char *));
198 static unsigned independent_decode_option PROTO ((int, char **, unsigned));
199
200 static void print_version PROTO((FILE *, const char *));
201 static int print_single_switch PROTO((FILE *, int, int, const char *,
202                                       const char *, const char *,
203                                       const char *, const char *));
204 static void print_switch_values PROTO((FILE *, int, int, const char *,
205                                        const char *, const char *));
206
207 void print_rtl_graph_with_bb PROTO ((const char *, const char *, rtx));
208 void clean_graph_dump_file PROTO ((const char *, const char *));
209 void finish_graph_dump_file PROTO ((const char *, const char *));
210 /* Length of line when printing switch values.  */
211 #define MAX_LINE 75
212
213 /* Name of program invoked, sans directories.  */
214
215 const char *progname;
216
217 /* Copy of arguments to main.  */
218 int save_argc;
219 char **save_argv;
220 \f
221 /* Name of current original source file (what was input to cpp).
222    This comes from each #-command in the actual input.  */
223
224 char *input_filename;
225
226 /* Name of top-level original source file (what was input to cpp).
227    This comes from the #-command at the beginning of the actual input.
228    If there isn't any there, then this is the cc1 input file name.  */
229
230 char *main_input_filename;
231
232 /* Current line number in real source file.  */
233
234 int lineno;
235
236 /* Nonzero if it is unsafe to create any new pseudo registers.  */
237 int no_new_pseudos;
238
239 /* Stack of currently pending input files.  */
240
241 struct file_stack *input_file_stack;
242
243 /* Incremented on each change to input_file_stack.  */
244 int input_file_stack_tick;
245
246 /* Name to use as base of names for dump output files.  */
247
248 const char *dump_base_name;
249
250 /* Bit flags that specify the machine subtype we are compiling for.
251    Bits are tested using macros TARGET_... defined in the tm.h file
252    and set by `-m...' switches.  Must be defined in rtlanal.c.  */
253
254 extern int target_flags;
255
256 /* Flags saying which kinds of debugging dump have been requested.  */
257
258 int rtl_dump = 0;
259 int rtl_dump_and_exit = 0;
260 int jump_opt_dump = 0;
261 int addressof_dump = 0;
262 int cse_dump = 0;
263 int gcse_dump = 0;
264 int loop_dump = 0;
265 int cse2_dump = 0;
266 int branch_prob_dump = 0;
267 int flow_dump = 0;
268 int combine_dump = 0;
269 int regmove_dump = 0;
270 int sched_dump = 0;
271 int local_reg_dump = 0;
272 int global_reg_dump = 0;
273 int flow2_dump = 0;
274 int peephole2_dump = 0;
275 int sched2_dump = 0;
276 int jump2_opt_dump = 0;
277 #ifdef DELAY_SLOTS
278 int dbr_sched_dump = 0;
279 #endif
280 int flag_print_asm_name = 0;
281 #ifdef STACK_REGS
282 int stack_reg_dump = 0;
283 #endif
284 #ifdef MACHINE_DEPENDENT_REORG
285 int mach_dep_reorg_dump = 0;
286 #endif
287 static int flag_print_mem = 0;
288 static int version_flag = 0;
289 static char * filename = 0;
290 enum graph_dump_types graph_dump_format;
291
292 /* Name for output file of assembly code, specified with -o.  */
293
294 char *asm_file_name;
295
296 /* Value of the -G xx switch, and whether it was passed or not.  */
297 int g_switch_value;
298 int g_switch_set;
299
300 /* Type(s) of debugging information we are producing (if any).
301    See flags.h for the definitions of the different possible
302    types of debugging information.  */
303 enum debug_info_type write_symbols = NO_DEBUG;
304
305 /* Level of debugging information we are producing.  See flags.h
306    for the definitions of the different possible levels.  */
307 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
308
309 /* Nonzero means use GNU-only extensions in the generated symbolic
310    debugging information.  */
311 /* Currently, this only has an effect when write_symbols is set to
312    DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG.  */
313 int use_gnu_debug_info_extensions = 0;
314
315 /* Nonzero means do optimizations.  -O.
316    Particular numeric values stand for particular amounts of optimization;
317    thus, -O2 stores 2 here.  However, the optimizations beyond the basic
318    ones are not controlled directly by this variable.  Instead, they are
319    controlled by individual `flag_...' variables that are defaulted
320    based on this variable.  */
321
322 int optimize = 0;
323
324 /* Nonzero means optimize for size.  -Os.
325    The only valid values are zero and non-zero. When optimize_size is
326    non-zero, optimize defaults to 2, but certain individual code
327    bloating optimizations are disabled.  */
328
329 int optimize_size = 0;
330
331 /* Number of error messages and warning messages so far.  */
332
333 int errorcount = 0;
334 int warningcount = 0;
335 int sorrycount = 0;
336
337 /* Pointer to function to compute the name to use to print a declaration.
338    DECL is the declaration in question.
339    VERBOSITY determines what information will be printed:
340      0: DECL_NAME, demangled as necessary.
341      1: and scope information.
342      2: and any other information that might be interesting, such as function
343         parameter types in C++.  */
344
345 const char *(*decl_printable_name)      PROTO ((tree, int));
346
347 /* Pointer to function to compute rtl for a language-specific tree code.  */
348
349 typedef rtx (*lang_expand_expr_t)
350   PROTO ((union tree_node *, rtx, enum machine_mode,
351           enum expand_modifier modifier));
352
353 lang_expand_expr_t lang_expand_expr = 0;
354
355 tree (*lang_expand_constant) PROTO((tree)) = 0;
356
357 /* Pointer to function to finish handling an incomplete decl at the
358    end of compilation.  */
359
360 void (*incomplete_decl_finalize_hook) PROTO((tree)) = 0;
361
362 /* Nonzero if generating code to do profiling.  */
363
364 int profile_flag = 0;
365
366 /* Nonzero if generating code to do profiling on a line-by-line basis.  */
367
368 int profile_block_flag;
369
370 /* Nonzero if generating code to profile program flow graph arcs.  */
371
372 int profile_arc_flag = 0;
373
374 /* Nonzero if generating info for gcov to calculate line test coverage.  */
375
376 int flag_test_coverage = 0;
377
378 /* Nonzero indicates that branch taken probabilities should be calculated.  */
379
380 int flag_branch_probabilities = 0;
381
382 /* Nonzero for -pedantic switch: warn about anything
383    that standard spec forbids.  */
384
385 int pedantic = 0;
386
387 /* Temporarily suppress certain warnings.
388    This is set while reading code from a system header file.  */
389
390 int in_system_header = 0;
391
392 /* Nonzero means do stupid register allocation.
393    Currently, this is 1 if `optimize' is 0.  */
394
395 int obey_regdecls = 0;
396
397 /* Don't print functions as they are compiled and don't print
398    times taken by the various passes.  -quiet.  */
399
400 int quiet_flag = 0;
401 \f
402 /* -f flags.  */
403
404 /* Nonzero means `char' should be signed.  */
405
406 int flag_signed_char;
407
408 /* Nonzero means give an enum type only as many bytes as it needs.  */
409
410 int flag_short_enums;
411
412 /* Nonzero for -fcaller-saves: allocate values in regs that need to
413    be saved across function calls, if that produces overall better code.
414    Optional now, so people can test it.  */
415
416 #ifdef DEFAULT_CALLER_SAVES
417 int flag_caller_saves = 1;
418 #else
419 int flag_caller_saves = 0;
420 #endif
421
422 /* Nonzero if structures and unions should be returned in memory.
423
424    This should only be defined if compatibility with another compiler or
425    with an ABI is needed, because it results in slower code.  */
426
427 #ifndef DEFAULT_PCC_STRUCT_RETURN
428 #define DEFAULT_PCC_STRUCT_RETURN 1
429 #endif
430
431 /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
432
433 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
434
435 /* Nonzero for -fforce-mem: load memory value into a register
436    before arithmetic on it.  This makes better cse but slower compilation.  */
437
438 int flag_force_mem = 0;
439
440 /* Nonzero for -fforce-addr: load memory address into a register before
441    reference to memory.  This makes better cse but slower compilation.  */
442
443 int flag_force_addr = 0;
444
445 /* Nonzero for -fdefer-pop: don't pop args after each function call;
446    instead save them up to pop many calls' args with one insns.  */
447
448 int flag_defer_pop = 0;
449
450 /* Nonzero for -ffloat-store: don't allocate floats and doubles
451    in extended-precision registers.  */
452
453 int flag_float_store = 0;
454
455 /* Nonzero for -fcse-follow-jumps:
456    have cse follow jumps to do a more extensive job.  */
457
458 int flag_cse_follow_jumps;
459
460 /* Nonzero for -fcse-skip-blocks:
461    have cse follow a branch around a block.  */
462 int flag_cse_skip_blocks;
463
464 /* Nonzero for -fexpensive-optimizations:
465    perform miscellaneous relatively-expensive optimizations.  */
466 int flag_expensive_optimizations;
467
468 /* Nonzero for -fthread-jumps:
469    have jump optimize output of loop.  */
470
471 int flag_thread_jumps;
472
473 /* Nonzero enables strength-reduction in loop.c.  */
474
475 int flag_strength_reduce = 0;
476
477 /* Nonzero enables loop unrolling in unroll.c.  Only loops for which the
478    number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
479    UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
480    unrolled.  */
481
482 int flag_unroll_loops;
483
484 /* Nonzero enables loop unrolling in unroll.c.  All loops are unrolled.
485    This is generally not a win.  */
486
487 int flag_unroll_all_loops;
488
489 /* Nonzero forces all invariant computations in loops to be moved
490    outside the loop. */
491
492 int flag_move_all_movables = 0;
493
494 /* Nonzero forces all general induction variables in loops to be
495    strength reduced. */
496
497 int flag_reduce_all_givs = 0;
498
499 /* Nonzero to perform full register move optimization passes.  This is the
500    default for -O2.  */
501
502 int flag_regmove = 0;
503
504 /* Nonzero for -fwritable-strings:
505    store string constants in data segment and don't uniquize them.  */
506
507 int flag_writable_strings = 0;
508
509 /* Nonzero means don't put addresses of constant functions in registers.
510    Used for compiling the Unix kernel, where strange substitutions are
511    done on the assembly output.  */
512
513 int flag_no_function_cse = 0;
514
515 /* Nonzero for -fomit-frame-pointer:
516    don't make a frame pointer in simple functions that don't require one.  */
517
518 int flag_omit_frame_pointer = 0;
519
520 /* Nonzero means place each function into its own section on those platforms
521    which support arbitrary section names and unlimited numbers of sections.  */
522
523 int flag_function_sections = 0;
524
525 /* ... and similar for data.  */
526  
527 int flag_data_sections = 0;
528
529 /* Nonzero to inhibit use of define_optimization peephole opts.  */
530
531 int flag_no_peephole = 0;
532
533 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
534    operations in the interest of optimization.  For example it allows
535    GCC to assume arguments to sqrt are nonnegative numbers, allowing
536    faster code for sqrt to be generated.  */
537
538 int flag_fast_math = 0;
539
540 /* Nonzero means the front end generally wants `errno' maintained by math
541    operations, like built-in SQRT, unless overridden by flag_fast_math.  */
542
543 int flag_errno_math = 1;
544
545 /* 0 means straightforward implementation of complex divide acceptable.
546    1 means wide ranges of inputs must work for complex divide.
547    2 means C9X-like requirements for complex divide (not yet implemented).  */
548
549 int flag_complex_divide_method = 0;
550
551 /* Nonzero means all references through pointers are volatile.  */
552
553 int flag_volatile;
554
555 /* Nonzero means treat all global and extern variables as volatile.  */
556
557 int flag_volatile_global;
558
559 /* Nonzero means treat all static variables as volatile.  */
560
561 int flag_volatile_static;
562
563 /* Nonzero means just do syntax checking; don't output anything.  */
564
565 int flag_syntax_only = 0;
566
567 /* Nonzero means perform global cse.  */
568
569 static int flag_gcse;
570
571 /* Nonzero means to use global dataflow analysis to eliminate
572    useless null pointer tests.  */
573
574 static int flag_delete_null_pointer_checks;
575
576 /* Nonzero means to rerun cse after loop optimization.  This increases
577    compilation time about 20% and picks up a few more common expressions.  */
578
579 static int flag_rerun_cse_after_loop;
580
581 /* Nonzero means to run loop optimizations twice.  */
582
583 int flag_rerun_loop_opt;
584
585 /* Nonzero for -finline-functions: ok to inline functions that look like
586    good inline candidates.  */
587
588 int flag_inline_functions;
589
590 /* Nonzero for -fkeep-inline-functions: even if we make a function
591    go inline everywhere, keep its definition around for debugging
592    purposes.  */
593
594 int flag_keep_inline_functions;
595
596 /* Nonzero means that functions will not be inlined.  */
597
598 int flag_no_inline;
599
600 /* Nonzero means that we should emit static const variables
601    regardless of whether or not optimization is turned on.  */
602
603 int flag_keep_static_consts = 1;
604
605 /* Nonzero means we should be saving declaration info into a .X file.  */
606
607 int flag_gen_aux_info = 0;
608
609 /* Specified name of aux-info file.  */
610
611 static char *aux_info_file_name;
612
613 /* Nonzero means make the text shared if supported.  */
614
615 int flag_shared_data;
616
617 /* Nonzero means schedule into delayed branch slots if supported.  */
618
619 int flag_delayed_branch;
620
621 /* Nonzero if we are compiling pure (sharable) code.
622    Value is 1 if we are doing reasonable (i.e. simple
623    offset into offset table) pic.  Value is 2 if we can
624    only perform register offsets.  */
625
626 int flag_pic;
627
628 /* Nonzero means generate extra code for exception handling and enable
629    exception handling.  */
630
631 int flag_exceptions;
632
633 /* Nonzero means use the new model for exception handling. Replaces 
634    -DNEW_EH_MODEL as a compile option. */
635
636 int flag_new_exceptions = 1;
637
638 /* Nonzero means don't place uninitialized global data in common storage
639    by default.  */
640
641 int flag_no_common;
642
643 /* Nonzero means pretend it is OK to examine bits of target floats,
644    even if that isn't true.  The resulting code will have incorrect constants,
645    but the same series of instructions that the native compiler would make.  */
646
647 int flag_pretend_float;
648
649 /* Nonzero means change certain warnings into errors.
650    Usually these are warnings about failure to conform to some standard.  */
651
652 int flag_pedantic_errors = 0;
653
654 /* flag_schedule_insns means schedule insns within basic blocks (before
655    local_alloc).
656    flag_schedule_insns_after_reload means schedule insns after
657    global_alloc.  */
658
659 int flag_schedule_insns = 0;
660 int flag_schedule_insns_after_reload = 0;
661
662 /* The following flags have effect only for scheduling before register
663    allocation:
664
665    flag_schedule_interblock means schedule insns accross basic blocks.
666    flag_schedule_speculative means allow speculative motion of non-load insns.
667    flag_schedule_speculative_load means allow speculative motion of some
668    load insns.
669    flag_schedule_speculative_load_dangerous allows speculative motion of more
670    load insns.  */
671
672 int flag_schedule_interblock = 1;
673 int flag_schedule_speculative = 1;
674 int flag_schedule_speculative_load = 0;
675 int flag_schedule_speculative_load_dangerous = 0;
676
677 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
678    by a cheaper branch, on a count register. */
679 int flag_branch_on_count_reg;
680
681 /* -finhibit-size-directive inhibits output of .size for ELF.
682    This is used only for compiling crtstuff.c, 
683    and it may be extended to other effects
684    needed for crtstuff.c on other systems.  */
685 int flag_inhibit_size_directive = 0;
686
687 /* -fverbose-asm causes extra commentary information to be produced in
688    the generated assembly code (to make it more readable).  This option
689    is generally only of use to those who actually need to read the
690    generated assembly code (perhaps while debugging the compiler itself).
691    -fno-verbose-asm, the default, causes the extra information
692    to be omitted and is useful when comparing two assembler files.  */
693
694 int flag_verbose_asm = 0;
695
696 /* -dA causes debug commentary information to be produced in
697    the generated assembly code (to make it more readable).  This option
698    is generally only of use to those who actually need to read the
699    generated assembly code (perhaps while debugging the compiler itself).
700    Currently, this switch is only used by dwarfout.c; however, it is intended
701    to be a catchall for printing debug information in the assembler file.  */
702
703 int flag_debug_asm = 0;
704
705 /* -fgnu-linker specifies use of the GNU linker for initializations.
706    (Or, more generally, a linker that handles initializations.)
707    -fno-gnu-linker says that collect2 will be used.  */
708 #ifdef USE_COLLECT2
709 int flag_gnu_linker = 0;
710 #else
711 int flag_gnu_linker = 1;
712 #endif
713
714 /* Tag all structures with __attribute__(packed) */
715 int flag_pack_struct = 0;
716
717 /* Emit code to check for stack overflow; also may cause large objects
718    to be allocated dynamically.  */
719 int flag_stack_check;
720
721 /* -fcheck-memory-usage causes extra code to be generated in order to check
722    memory accesses.  This is used by a detector of bad memory accesses such
723    as Checker.  */
724 int flag_check_memory_usage = 0;
725
726 /* -fprefix-function-name causes function name to be prefixed.  This
727    can be used with -fcheck-memory-usage to isolate code compiled with
728    -fcheck-memory-usage.  */
729 int flag_prefix_function_name = 0;
730
731 /* 0 if pointer arguments may alias each other.  True in C.
732    1 if pointer arguments may not alias each other but may alias
733    global variables.
734    2 if pointer arguments may not alias each other and may not
735    alias global variables.  True in Fortran.
736    This defaults to 0 for C.  */
737 int flag_argument_noalias = 0;
738
739 /* Nonzero if we should do (language-dependent) alias analysis.
740    Typically, this analysis will assume that expressions of certain
741    types do not alias expressions of certain other types.  Only used
742    if alias analysis (in general) is enabled.  */
743 int flag_strict_aliasing = 0;
744
745 /* Instrument functions with calls at entry and exit, for profiling.  */
746 int flag_instrument_function_entry_exit = 0;
747
748 /* Nonzero means ignore `#ident' directives.  0 means handle them.
749    On SVR4 targets, it also controls whether or not to emit a
750    string identifying the compiler.  */
751
752 int flag_no_ident = 0;
753
754 /* This will perform a peephole pass before sched2. */
755 int flag_peephole2 = 0;
756
757 /* Values of the -falign-* flags: how much to align labels in code. 
758    0 means `use default', 1 means `don't align'.  
759    For each variable, there is an _log variant which is the power
760    of two not less than the variable, for .align output.  */
761
762 int align_loops;
763 int align_loops_log;
764 int align_jumps;
765 int align_jumps_log;
766 int align_labels;
767 int align_labels_log;
768 int align_functions;
769 int align_functions_log;
770
771 /* Table of supported debugging formats.  */
772 static struct
773 {
774   const char * arg;
775   /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
776      constant expression, we use NO_DEBUG in its place.  */
777   enum debug_info_type debug_type;
778   int use_extensions_p;
779   const char * description;
780 } *da,
781 debug_args[] =
782 {
783   { "",       NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
784     "Generate default debug format output" },
785   { "gdb",    NO_DEBUG, 1, "Generate default extended debug format output" },
786 #ifdef DBX_DEBUGGING_INFO
787   { "stabs",  DBX_DEBUG, 0, "Generate STABS format debug output" },
788   { "stabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
789 #endif
790 #ifdef DWARF_DEBUGGING_INFO
791   { "dwarf",  DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
792   { "dwarf+", DWARF_DEBUG, 1,
793     "Generated extended DWARF-1 format debug output" },
794 #endif
795 #ifdef DWARF2_DEBUGGING_INFO
796   { "dwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
797 #endif
798 #ifdef XCOFF_DEBUGGING_INFO
799   { "xcoff",  XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
800   { "xcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
801 #endif
802 #ifdef SDB_DEBUGGING_INFO
803   { "coff", SDB_DEBUG, 0, "Generate COFF format debug output" },
804 #endif
805   { 0, 0, 0, 0 }
806 };
807
808 typedef struct
809 {
810   const char * string;
811   int *  variable;
812   int    on_value;
813   const char * description;
814 }
815 lang_independent_options;
816
817 /* Add or remove a leading underscore from user symbols.  */
818 int flag_leading_underscore = -1;
819
820 /* The user symbol prefix after having resolved same.  */
821 const char *user_label_prefix;
822
823 /* A default for same.  */
824 #ifndef USER_LABEL_PREFIX
825 #define USER_LABEL_PREFIX ""
826 #endif
827
828 /* Table of language-independent -f options.
829    STRING is the option name.  VARIABLE is the address of the variable.
830    ON_VALUE is the value to store in VARIABLE
831     if `-fSTRING' is seen as an option.
832    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
833
834 lang_independent_options f_options[] =
835 {
836   {"float-store", &flag_float_store, 1,
837    "Do not store floats in registers" },
838   {"volatile", &flag_volatile, 1,
839    "Consider all mem refs through pointers as volatile"},
840   {"volatile-global", &flag_volatile_global, 1,
841    "Consider all mem refs to global data to be volatile" },
842   {"volatile-static", &flag_volatile_static, 1,
843    "Consider all mem refs to static data to be volatile" },
844   {"defer-pop", &flag_defer_pop, 1,
845    "Defer popping functions args from stack until later" },
846   {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
847    "When possible do not generate stack frames"},
848   {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
849    "When running CSE, follow jumps to their targets" },
850   {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
851    "When running CSE, follow conditional jumps" },
852   {"expensive-optimizations", &flag_expensive_optimizations, 1,
853    "Perform a number of minor, expensive optimisations" },
854   {"thread-jumps", &flag_thread_jumps, 1,
855    "Perform jump threading optimisations"},
856   {"strength-reduce", &flag_strength_reduce, 1,
857    "Perform strength reduction optimisations" },
858   {"unroll-loops", &flag_unroll_loops, 1,
859    "Perform loop unrolling when iteration count is known" },
860   {"unroll-all-loops", &flag_unroll_all_loops, 1,
861    "Perform loop unrolling for all loops" },
862   {"move-all-movables", &flag_move_all_movables, 1,
863    "Force all loop invariant computations out of loops" },
864   {"reduce-all-givs", &flag_reduce_all_givs, 1,
865    "Strength reduce all loop general induction variables" },
866   {"writable-strings", &flag_writable_strings, 1,
867    "Store strings in writable data section" },
868   {"peephole", &flag_no_peephole, 0,
869    "Enable machine specific peephole optimisations" },
870   {"force-mem", &flag_force_mem, 1,
871    "Copy memory operands into registers before using" },
872   {"force-addr", &flag_force_addr, 1,
873    "Copy memory address constants into regs before using" },
874   {"function-cse", &flag_no_function_cse, 0,
875    "Allow function addresses to be held in registers" },
876   {"inline-functions", &flag_inline_functions, 1,
877    "Integrate simple functions into their callers" },
878   {"keep-inline-functions", &flag_keep_inline_functions, 1,
879    "Generate code for funcs even if they are fully inlined" },
880   {"inline", &flag_no_inline, 0,
881    "Pay attention to the 'inline' keyword"},
882   {"keep-static-consts", &flag_keep_static_consts, 1,
883    "Emit static const variables even if they are not used" },
884   {"syntax-only", &flag_syntax_only, 1,
885    "Check for syntax errors, then stop" },
886   {"shared-data", &flag_shared_data, 1,
887    "Mark data as shared rather than private" },
888   {"caller-saves", &flag_caller_saves, 1,
889    "Enable saving registers around function calls" },
890   {"pcc-struct-return", &flag_pcc_struct_return, 1,
891    "Return 'short' aggregates in memory, not registers" },
892   {"reg-struct-return", &flag_pcc_struct_return, 0,
893    "Return 'short' aggregates in registers" },
894   {"delayed-branch", &flag_delayed_branch, 1,
895    "Attempt to fill delay slots of branch instructions" },
896   {"gcse", &flag_gcse, 1,
897    "Perform the global common subexpression elimination" },
898   {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
899    "Run CSE pass after loop optimisations"},
900   {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
901    "Run the loop optimiser twice"},
902   {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
903    "Delete useless null pointer checks" },
904   {"pretend-float", &flag_pretend_float, 1,
905    "Pretend that host and target use the same FP format"},
906   {"schedule-insns", &flag_schedule_insns, 1,
907    "Reschedule instructions to avoid pipeline stalls"},
908   {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
909   "Run two passes of the instruction scheduler"},
910   {"sched-interblock",&flag_schedule_interblock, 1,
911    "Enable scheduling across basic blocks" },
912   {"sched-spec",&flag_schedule_speculative, 1,
913    "Allow speculative motion of non-loads" },
914   {"sched-spec-load",&flag_schedule_speculative_load, 1,
915    "Allow speculative motion of some loads" },
916   {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
917    "Allow speculative motion of more loads" },
918   {"branch-count-reg",&flag_branch_on_count_reg, 1,
919    "Replace add,compare,branch with branch on count reg"},
920   {"pic", &flag_pic, 1,
921    "Generate position independent code, if possible"},
922   {"PIC", &flag_pic, 2, ""},
923   {"exceptions", &flag_exceptions, 1,
924    "Enable exception handling" },
925   {"new-exceptions", &flag_new_exceptions, 1,
926    "Use the new model for exception handling" },
927   {"sjlj-exceptions", &exceptions_via_longjmp, 1,
928    "Use setjmp/longjmp to handle exceptions" },
929   {"asynchronous-exceptions", &asynchronous_exceptions, 1,
930    "Support asynchronous exceptions" },
931   {"profile-arcs", &profile_arc_flag, 1,
932    "Insert arc based program profiling code" },
933   {"test-coverage", &flag_test_coverage, 1,
934    "Create data files needed by gcov" },
935   {"branch-probabilities", &flag_branch_probabilities, 1,
936    "Use profiling information for branch probabilities" },
937   {"fast-math", &flag_fast_math, 1,
938    "Improve FP speed by violating ANSI & IEEE rules" },
939   {"common", &flag_no_common, 0,
940    "Do not put unitialised globals in the common section" },
941   {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
942    "Do not generate .size directives" },
943   {"function-sections", &flag_function_sections, 1,
944    "place each function into its own section" },
945   {"data-sections", &flag_data_sections, 1,
946    "place data items into their own section" },
947   {"verbose-asm", &flag_verbose_asm, 1,
948    "Add extra commentry to assembler output"},
949   {"gnu-linker", &flag_gnu_linker, 1,
950    "Output GNU ld formatted global initialisers"},
951   {"regmove", &flag_regmove, 1,
952    "Enables a register move optimisation"},
953   {"optimize-register-move", &flag_regmove, 1,
954    "Do the full regmove optimization pass"},
955   {"pack-struct", &flag_pack_struct, 1,
956    "Pack structure members together without holes" },
957   {"stack-check", &flag_stack_check, 1,
958    "Insert stack checking code into the program" },
959   {"argument-alias", &flag_argument_noalias, 0,
960    "Specify that arguments may alias each other & globals"},
961   {"argument-noalias", &flag_argument_noalias, 1,
962    "Assume arguments may alias globals but not each other"},
963   {"argument-noalias-global", &flag_argument_noalias, 2,
964    "Assume arguments do not alias each other or globals" },
965   {"strict-aliasing", &flag_strict_aliasing, 1,
966    "Assume strict aliasing rules apply" },
967   {"align-loops", &align_loops, 0, 
968    "Align the start of loops" },
969   {"align-jumps", &align_jumps, 0, 
970    "Align labels which are only reached by jumping" },
971   {"align-labels", &align_labels, 0,
972    "Align all labels" },
973   {"align-functions", &align_functions, 0,
974    "Align the start of functions" },
975   {"check-memory-usage", &flag_check_memory_usage, 1,
976    "Generate code to check every memory access" },
977   {"prefix-function-name", &flag_prefix_function_name, 1,
978    "Add a prefix to all function names" },
979   {"dump-unnumbered", &flag_dump_unnumbered, 1,
980    "Suppress output of instruction numbers and line number notes in debugging dumps"},
981   {"instrument-functions", &flag_instrument_function_entry_exit, 1,
982    "Instrument function entry/exit with profiling calls"},
983   {"leading-underscore", &flag_leading_underscore, 1,
984    "External symbols have a leading underscore" },
985   {"ident", &flag_no_ident, 0,
986    "Process #ident directives"},
987   { "peephole2", &flag_peephole2, 1,
988     "Enables an rtl peephole pass run before sched2" },
989   {"math-errno", &flag_errno_math, 1,
990    "Set errno after built-in math functions"}
991 };
992
993 #define NUM_ELEM(a)  (sizeof (a) / sizeof ((a)[0]))
994
995 /* Table of language-specific options.  */
996
997 static struct lang_opt
998 {
999   const char * option;
1000   const char * description;
1001 }
1002 documented_lang_options[] =
1003 {
1004   /* In order not to overload the --help output, the convention
1005      used here is to only describe those options which are not
1006      enabled by default.  */
1007
1008   { "-ansi", "Compile just for ANSI C" },
1009   { "-fallow-single-precision",
1010     "Do not promote floats to double if using -traditional" },
1011   { "-std= ", "Determine language standard"},
1012
1013   { "-fsigned-bitfields", "" },
1014   { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1015   { "-fno-signed-bitfields", "" },
1016   { "-fno-unsigned-bitfields","" },
1017   { "-fsigned-char", "Make 'char' be signed by default"},
1018   { "-funsigned-char", "Make 'char' be unsigned by default"},
1019   { "-fno-signed-char", "" },
1020   { "-fno-unsigned-char", "" },
1021
1022   { "-ftraditional", "" },
1023   { "-traditional", "Attempt to support traditional K&R style C"},
1024   { "-fnotraditional", "" },
1025   { "-fno-traditional", "" },
1026
1027   { "-fasm", "" },
1028   { "-fno-asm", "Do not recognise the 'asm' keyword" },
1029   { "-fbuiltin", "" },
1030   { "-fno-builtin", "Do not recognise any built in functions" },
1031   { "-fhosted", "Assume normal C execution environment" },
1032   { "-fno-hosted", "" },
1033   { "-ffreestanding",
1034     "Assume that standard libraries & main might not exist" },
1035   { "-fno-freestanding", "" },
1036   { "-fcond-mismatch", "Allow different types as args of ? operator"},
1037   { "-fno-cond-mismatch", "" },
1038   { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1039   { "-fno-dollars-in-identifiers", "" },
1040   { "-fpreprocessed", "" },
1041   { "-fno-preprocessed", "" },
1042   { "-fshort-double", "Use the same size for double as for float" },
1043   { "-fno-short-double", "" },
1044   { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1045   { "-fno-short-enums", "" },
1046   { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1047   { "-fno-short-wchar", "" },
1048
1049   { "-Wall", "Enable most warning messages" },
1050   { "-Wbad-function-cast",
1051     "Warn about casting functions to incompatible types" },
1052   { "-Wno-bad-function-cast", "" },
1053   { "-Wmissing-noreturn",
1054     "Warn about functions which might be candidates for attribute noreturn" },
1055   { "-Wno-missing-noreturn", "" },
1056   { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1057   { "-Wno-cast-qual", "" },
1058   { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1059   { "-Wno-char-subscripts", "" },
1060   { "-Wcomment", "Warn if nested comments are detected" },
1061   { "-Wno-comment", "" },
1062   { "-Wcomments", "Warn if nested comments are detected" },
1063   { "-Wno-comments", "" },
1064   { "-Wconversion", "Warn about possibly confusing type conversions" },
1065   { "-Wno-conversion", "" },
1066   { "-Wformat", "Warn about printf format anomalies" },
1067   { "-Wno-format", "" },
1068   { "-Wimplicit-function-declaration",
1069     "Warn about implicit function declarations" },
1070   { "-Wno-implicit-function-declaration", "" },
1071   { "-Werror-implicit-function-declaration", "" },
1072   { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1073   { "-Wno-implicit-int", "" },
1074   { "-Wimplicit", "" },
1075   { "-Wno-implicit", "" },
1076   { "-Wimport", "Warn about the use of the #import directive" },
1077   { "-Wno-import", "" },
1078   { "-Wlong-long","" },
1079   { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1080   { "-Wmain", "Warn about suspicious declarations of main" },
1081   { "-Wno-main", "" },
1082   { "-Wmissing-braces",
1083     "Warn about possibly missing braces around initialisers" },
1084   { "-Wno-missing-braces", "" },
1085   { "-Wmissing-declarations",
1086     "Warn about global funcs without previous declarations"},
1087   { "-Wno-missing-declarations", "" },
1088   { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1089   { "-Wno-missing-prototypes", "" },
1090   { "-Wmultichar", "Warn about use of multicharacter literals"},
1091   { "-Wno-multichar", "" },
1092   { "-Wnested-externs", "Warn about externs not at file scope level" },
1093   { "-Wno-nested-externs", "" },
1094   { "-Wparentheses", "Warn about possible missing parentheses" },
1095   { "-Wno-parentheses", "" },
1096   { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1097   { "-Wno-pointer-arith", "" },
1098   { "-Wredundant-decls",
1099     "Warn about multiple declarations of the same object" },
1100   { "-Wno-redundant-decls", "" },
1101   { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1102   { "-Wno-sign-compare", "" },
1103   { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1104   { "-Wno-unknown-pragmas", "" },
1105   { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1106   { "-Wno-strict-prototypes", "" },
1107   { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1108   { "-Wno-traditional", "" },
1109   { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1110   { "-Wno-trigraphs", "" },
1111   { "-Wundef", "" },
1112   { "-Wno-undef", "" },
1113   { "-Wwrite-strings", "Mark strings as 'const char *'"},
1114   { "-Wno-write-strings", "" },
1115   
1116 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1117   
1118   /* These are for Objective C.  */
1119   DEFINE_LANG_NAME ("Objective C")
1120   
1121   { "-lang-objc", "" },
1122   { "-gen-decls", "Dump decls to a .decl file" },
1123   { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1124   { "-fno-gnu-runtime", "" },
1125   { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1126   { "-fno-next-runtime", "" },
1127   { "-Wselector", "Warn if a selector has multiple methods" },
1128   { "-Wno-selector", "" },
1129   { "-Wprotocol", "" },
1130   { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1131   { "-print-objc-runtime-info",
1132     "Generate C header of platform specific features" },
1133
1134 #include "options.h"
1135   
1136 };
1137
1138 /* Here is a table, controlled by the tm.h file, listing each -m switch
1139    and which bits in `target_switches' it should set or clear.
1140    If VALUE is positive, it is bits to set.
1141    If VALUE is negative, -VALUE is bits to clear.
1142    (The sign bit is not used so there is no confusion.)  */
1143
1144 struct
1145 {
1146   const char * name;
1147   int    value;
1148   const char * description;
1149 }
1150 target_switches [] = TARGET_SWITCHES;
1151
1152 /* This table is similar, but allows the switch to have a value.  */
1153
1154 #ifdef TARGET_OPTIONS
1155 struct
1156 {
1157   const char *  prefix;
1158   const char ** variable;
1159   const char *  description;
1160 }
1161 target_options [] = TARGET_OPTIONS;
1162 #endif
1163 \f
1164 /* Options controlling warnings */
1165
1166 /* Don't print warning messages.  -w.  */
1167
1168 int inhibit_warnings = 0;
1169
1170 /* Print various extra warnings.  -W.  */
1171
1172 int extra_warnings = 0;
1173
1174 /* Treat warnings as errors.  -Werror.  */
1175
1176 int warnings_are_errors = 0;
1177
1178 /* Nonzero to warn about unused local variables.  */
1179
1180 int warn_unused;
1181
1182 /* Nonzero to warn about code which is never reached.  */
1183
1184 int warn_notreached;
1185
1186 /* Nonzero to warn about variables used before they are initialized.  */
1187
1188 int warn_uninitialized;
1189
1190 /* Nonzero means warn about all declarations which shadow others.   */
1191
1192 int warn_shadow;
1193
1194 /* Warn if a switch on an enum fails to have a case for every enum value.  */
1195
1196 int warn_switch;
1197
1198 /* Nonzero means warn about function definitions that default the return type
1199    or that use a null return and have a return-type other than void.  */
1200
1201 int warn_return_type;
1202
1203 /* Nonzero means warn about pointer casts that increase the required
1204    alignment of the target type (and might therefore lead to a crash
1205    due to a misaligned access).  */
1206
1207 int warn_cast_align;
1208
1209 /* Nonzero means warn about any identifiers that match in the first N
1210    characters.  The value N is in `id_clash_len'.  */
1211
1212 int warn_id_clash;
1213 unsigned id_clash_len;
1214
1215 /* Nonzero means warn about any objects definitions whose size is larger
1216    than N bytes.  Also want about function definitions whose returned
1217    values are larger than N bytes. The value N is in `larger_than_size'.  */
1218  
1219 int warn_larger_than;
1220 unsigned larger_than_size;
1221
1222 /* Nonzero means warn if inline function is too large.  */
1223
1224 int warn_inline;
1225
1226 /* Warn if a function returns an aggregate,
1227    since there are often incompatible calling conventions for doing this.  */
1228
1229 int warn_aggregate_return;
1230
1231 /* Likewise for -W.  */
1232
1233 lang_independent_options W_options[] =
1234 {
1235   {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1236   {"error", &warnings_are_errors, 1, ""},
1237   {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1238   {"switch", &warn_switch, 1,
1239    "Warn about enumerated switches missing a specific case" },
1240   {"aggregate-return", &warn_aggregate_return, 1,
1241    "Warn about returning structures, unions or arrays" },
1242   {"cast-align", &warn_cast_align, 1,
1243    "Warn about pointer casts which increase alignment" },
1244   {"unreachable-code", &warn_notreached, 1, 
1245    "Warn about code that will never be executed" },
1246   {"uninitialized", &warn_uninitialized, 1,
1247    "Warn about unitialized automatic variables"},
1248   {"inline", &warn_inline, 1,
1249    "Warn when an inlined function cannot be inlined"}
1250 };
1251 \f
1252 /* Output files for assembler code (real compiler output)
1253    and debugging dumps.  */
1254
1255 FILE *asm_out_file;
1256 FILE *aux_info_file;
1257 FILE *rtl_dump_file = NULL;
1258
1259 /* Decode the string P as an integral parameter.
1260    If the string is indeed an integer return its numeric value else
1261    issue an Invalid Option error for the option PNAME and return DEFVAL.
1262    If PNAME is zero just return DEFVAL, do not call error.               */
1263    
1264 int
1265 read_integral_parameter (p, pname, defval)
1266      const char *p;
1267      const char *pname;
1268      const int  defval;
1269 {
1270   const char *endp = p;
1271
1272   while (*endp)
1273     {
1274       if (*endp >= '0' && *endp <= '9')
1275         endp++;
1276       else
1277         break;
1278     }
1279
1280   if (*endp != 0)
1281     {
1282       if (pname != 0)
1283         error ("Invalid option `%s'", pname);
1284       return defval;
1285     }
1286
1287   return atoi (p);
1288 }
1289
1290
1291 /* Time accumulators, to count the total time spent in various passes.  */
1292
1293 int parse_time;
1294 int varconst_time;
1295 int integration_time;
1296 int jump_time;
1297 int cse_time;
1298 int gcse_time;
1299 int loop_time;
1300 int cse2_time;
1301 int branch_prob_time;
1302 int flow_time;
1303 int combine_time;
1304 int regmove_time;
1305 int sched_time;
1306 int local_alloc_time;
1307 int global_alloc_time;
1308 int flow2_time;
1309 int sched2_time;
1310 #ifdef DELAY_SLOTS
1311 int dbr_sched_time;
1312 #endif
1313 int shorten_branch_time;
1314 int stack_reg_time;
1315 int final_time;
1316 int symout_time;
1317 int dump_time;
1318 int gc_time;
1319 int all_time;
1320 \f
1321 /* Return time used so far, in microseconds.  */
1322
1323 long
1324 get_run_time ()
1325 {
1326   if (quiet_flag)
1327     return 0;
1328
1329 #ifdef __BEOS__
1330   return 0;
1331 #else /* not BeOS */
1332 #if defined (_WIN32) && !defined (__CYGWIN__)
1333   if (clock() < 0)
1334     return 0;
1335   else
1336     return (clock() * 1000);
1337 #else /* not _WIN32 */
1338 #ifdef _SC_CLK_TCK
1339   {
1340     static int tick;
1341     struct tms tms;
1342     if (tick == 0)
1343       tick = 1000000 / sysconf(_SC_CLK_TCK);
1344     times (&tms);
1345     return (tms.tms_utime + tms.tms_stime) * tick;
1346   }
1347 #else
1348 #ifdef USG
1349   {
1350     struct tms tms;
1351 #   if HAVE_SYSCONF && defined _SC_CLK_TCK
1352 #    define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1353 #   else
1354 #    ifdef CLK_TCK
1355 #     define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1356 #    else
1357 #     define TICKS_PER_SECOND HZ /* traditional UNIX */
1358 #    endif
1359 #   endif
1360     times (&tms);
1361     return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1362   }
1363 #else
1364 #ifndef VMS
1365   {
1366     struct rusage rusage;
1367     getrusage (0, &rusage);
1368     return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1369             + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1370   }
1371 #else /* VMS */
1372   {
1373     struct
1374       {
1375         int proc_user_time;
1376         int proc_system_time;
1377         int child_user_time;
1378         int child_system_time;
1379       } vms_times;
1380     times ((void *) &vms_times);
1381     return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1382   }
1383 #endif  /* VMS */
1384 #endif  /* USG */
1385 #endif  /* _SC_CLK_TCK */
1386 #endif  /* _WIN32 */
1387 #endif  /* __BEOS__ */
1388 }
1389
1390 #define TIMEVAR(VAR, BODY)    \
1391 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1392
1393 void
1394 print_time (str, total)
1395      const char *str;
1396      int total;
1397 {
1398   fprintf (stderr,
1399            "time in %s: %d.%06d (%.0f%%)\n",
1400            str, total / 1000000, total % 1000000,
1401            (double)total / (double)all_time * 100.0);
1402 }
1403
1404 /* Count an error or warning.  Return 1 if the message should be printed.  */
1405
1406 int
1407 count_error (warningp)
1408      int warningp;
1409 {
1410   if (warningp && inhibit_warnings)
1411     return 0;
1412
1413   if (warningp && !warnings_are_errors)
1414     warningcount++;
1415   else
1416     {
1417       static int warning_message = 0;
1418
1419       if (warningp && !warning_message)
1420         {
1421           notice ("%s: warnings being treated as errors\n", progname);
1422           warning_message = 1;
1423         }
1424       errorcount++;
1425     }
1426
1427   return 1;
1428 }
1429
1430 /* Print a fatal error message.  NAME is the text.
1431    Also include a system error message based on `errno'.  */
1432
1433 void
1434 pfatal_with_name (name)
1435   const char *name;
1436 {
1437   fprintf (stderr, "%s: ", progname);
1438   perror (name);
1439   exit (FATAL_EXIT_CODE);
1440 }
1441
1442 void
1443 fatal_io_error (name)
1444   const char *name;
1445 {
1446   notice ("%s: %s: I/O error\n", progname, name);
1447   exit (FATAL_EXIT_CODE);
1448 }
1449
1450 /* This is the default decl_printable_name function.  */
1451
1452 static const char *
1453 decl_name (decl, verbosity)
1454      tree decl;
1455      int verbosity ATTRIBUTE_UNUSED;
1456 {
1457   return IDENTIFIER_POINTER (DECL_NAME (decl));
1458 }
1459 \f
1460 /* Mark P for GC.  Also mark main_input_filename and input_filename.  */
1461 static void
1462 mark_file_stack (p)
1463      void *p;
1464 {
1465   struct file_stack *stack = *(struct file_stack **)p;
1466
1467   /* We're only called for input_file_stack, so we can mark the current
1468      input_filename here as well.  */
1469   ggc_mark_string (main_input_filename);
1470   ggc_mark_string (input_filename);
1471
1472   while (stack)
1473     {
1474       ggc_mark_string (stack->name);
1475       stack = stack->next;
1476     }
1477 }
1478
1479 static int need_error_newline;
1480
1481 /* Function of last error message;
1482    more generally, function such that if next error message is in it
1483    then we don't have to mention the function name.  */
1484 static tree last_error_function = NULL;
1485
1486 /* Used to detect when input_file_stack has changed since last described.  */
1487 static int last_error_tick;
1488
1489 /* Called when the start of a function definition is parsed,
1490    this function prints on stderr the name of the function.  */
1491
1492 void
1493 announce_function (decl)
1494      tree decl;
1495 {
1496   if (! quiet_flag)
1497     {
1498       if (rtl_dump_and_exit)
1499         fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1500       else
1501         fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1502       fflush (stderr);
1503       need_error_newline = 1;
1504       last_error_function = current_function_decl;
1505     }
1506 }
1507
1508 /* The default function to print out name of current function that caused
1509    an error.  */
1510
1511 void
1512 default_print_error_function (file)
1513   const char *file;
1514 {
1515   if (last_error_function != current_function_decl)
1516     {
1517       if (file)
1518         fprintf (stderr, "%s: ", file);
1519
1520       if (current_function_decl == NULL)
1521         notice ("At top level:\n");
1522       else
1523         notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE
1524                  ? "In method `%s':\n"
1525                  : "In function `%s':\n"),
1526                 (*decl_printable_name) (current_function_decl, 2));
1527
1528       last_error_function = current_function_decl;
1529     }
1530 }
1531
1532 /* Called by report_error_function to print out function name.
1533  * Default may be overridden by language front-ends.  */
1534
1535 void (*print_error_function) PROTO((const char *)) =
1536   default_print_error_function;
1537
1538 /* Prints out, if necessary, the name of the current function
1539   that caused an error.  Called from all error and warning functions.
1540   We ignore the FILE parameter, as it cannot be relied upon.  */
1541
1542 void
1543 report_error_function (file)
1544   const char *file ATTRIBUTE_UNUSED;
1545 {
1546   struct file_stack *p;
1547
1548   if (need_error_newline)
1549     {
1550       fprintf (stderr, "\n");
1551       need_error_newline = 0;
1552     }
1553
1554   if (input_file_stack && input_file_stack->next != 0
1555       && input_file_stack_tick != last_error_tick)
1556     {
1557       for (p = input_file_stack->next; p; p = p->next)
1558         notice ((p == input_file_stack->next
1559                  ?    "In file included from %s:%d"
1560                  : ",\n                 from %s:%d"),
1561                 p->name, p->line);
1562       fprintf (stderr, ":\n");
1563       last_error_tick = input_file_stack_tick;
1564     }
1565
1566   (*print_error_function) (input_filename);
1567 }
1568 \f
1569 /* Print a message.  */
1570
1571 static void
1572 vnotice (file, msgid, ap)
1573      FILE *file;
1574      const char *msgid;
1575      va_list ap;
1576 {
1577   vfprintf (file, _(msgid), ap);
1578 }
1579
1580 static void
1581 notice VPROTO((const char *msgid, ...))
1582 {
1583 #ifndef ANSI_PROTOTYPES
1584   char *msgid;
1585 #endif
1586   va_list ap;
1587
1588   VA_START (ap, msgid);
1589
1590 #ifndef ANSI_PROTOTYPES
1591   msgid = va_arg (ap, char *);
1592 #endif
1593
1594   vnotice (stderr, msgid, ap);
1595   va_end (ap);
1596 }
1597
1598 void
1599 fnotice VPROTO((FILE *file, const char *msgid, ...))
1600 {
1601 #ifndef ANSI_PROTOTYPES
1602   FILE *file;
1603   const char *msgid;
1604 #endif
1605   va_list ap;
1606
1607   VA_START (ap, msgid);
1608
1609 #ifndef ANSI_PROTOTYPES
1610   file = va_arg (ap, FILE *);
1611   msgid = va_arg (ap, const char *);
1612 #endif
1613
1614   vnotice (file, msgid, ap);
1615   va_end (ap);
1616 }
1617
1618 /* Report FILE and LINE (or program name), and optionally just WARN.  */
1619
1620 static void
1621 report_file_and_line (file, line, warn)
1622      const char *file;
1623      int line;
1624      int warn;
1625 {
1626   if (file)
1627     fprintf (stderr, "%s:%d: ", file, line);
1628   else
1629     fprintf (stderr, "%s: ", progname);
1630
1631   if (warn)
1632     notice ("warning: ");
1633 }
1634
1635 /* Print a message.  */
1636
1637 static void
1638 vmessage (prefix, msgid, ap)
1639      const char *prefix;
1640      const char *msgid;
1641      va_list ap;
1642 {
1643   if (prefix)
1644     fprintf (stderr, "%s: ", prefix);
1645
1646   vfprintf (stderr, msgid, ap);
1647 }
1648
1649 /* Print a message relevant to line LINE of file FILE.  */
1650
1651 static void
1652 v_message_with_file_and_line (file, line, warn, msgid, ap)
1653      const char *file;
1654      int line;
1655      int warn;
1656      const char *msgid;
1657      va_list ap;
1658 {
1659   report_file_and_line (file, line, warn);
1660   vnotice (stderr, msgid, ap);
1661   fputc ('\n', stderr);
1662 }
1663
1664 /* Print a message relevant to the given DECL.  */
1665
1666 static void
1667 v_message_with_decl (decl, warn, msgid, ap)
1668      tree decl;
1669      int warn;
1670      const char *msgid;
1671      va_list ap;
1672 {
1673   const char *p;
1674
1675   report_file_and_line (DECL_SOURCE_FILE (decl),
1676                         DECL_SOURCE_LINE (decl), warn);
1677
1678   /* Do magic to get around lack of varargs support for insertion
1679      of arguments into existing list.  We know that the decl is first;
1680      we ass_u_me that it will be printed with "%s".  */
1681
1682   for (p = _(msgid); *p; ++p)
1683     {
1684       if (*p == '%')
1685         {
1686           if (*(p + 1) == '%')
1687             ++p;
1688           else if (*(p + 1) != 's')
1689             abort ();
1690           else
1691             break;
1692         }
1693     }
1694
1695   if (p > _(msgid))                     /* Print the left-hand substring.  */
1696     {
1697       char fmt[sizeof "%.255s"];
1698       long width = p - _(msgid);
1699              
1700       if (width > 255L) width = 255L;   /* arbitrary */
1701       sprintf (fmt, "%%.%lds", width);
1702       fprintf (stderr, fmt, _(msgid));
1703     }
1704
1705   if (*p == '%')                /* Print the name.  */
1706     {
1707       const char *n = (DECL_NAME (decl)
1708                  ? (*decl_printable_name) (decl, 2)
1709                  : "((anonymous))");
1710       fputs (n, stderr);
1711       while (*p)
1712         {
1713           ++p;
1714           if (ISALPHA (*(p - 1) & 0xFF))
1715             break;
1716         }
1717     }
1718
1719   if (*p)                       /* Print the rest of the message.  */
1720     vmessage ((char *)NULL, p, ap);
1721
1722   fputc ('\n', stderr);
1723 }
1724
1725 /* Figure file and line of the given INSN.  */
1726
1727 static void
1728 file_and_line_for_asm (insn, pfile, pline)
1729      rtx insn;
1730      char **pfile;
1731      int *pline;
1732 {
1733   rtx body = PATTERN (insn);
1734   rtx asmop;
1735
1736   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
1737   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1738     asmop = SET_SRC (body);
1739   else if (GET_CODE (body) == ASM_OPERANDS)
1740     asmop = body;
1741   else if (GET_CODE (body) == PARALLEL
1742            && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1743     asmop = SET_SRC (XVECEXP (body, 0, 0));
1744   else if (GET_CODE (body) == PARALLEL
1745            && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1746     asmop = XVECEXP (body, 0, 0);
1747   else
1748     asmop = NULL;
1749
1750   if (asmop)
1751     {
1752       *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1753       *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1754     }
1755   else
1756     {
1757       *pfile = input_filename;
1758       *pline = lineno;
1759     }
1760 }
1761
1762 /* Report an error at line LINE of file FILE.  */
1763
1764 static void
1765 v_error_with_file_and_line (file, line, msgid, ap)
1766      const char *file;
1767      int line;
1768      const char *msgid;
1769      va_list ap;
1770 {
1771   count_error (0);
1772   report_error_function (file);
1773   v_message_with_file_and_line (file, line, 0, msgid, ap);
1774 }
1775
1776 void
1777 error_with_file_and_line VPROTO((const char *file, int line,
1778                                  const char *msgid, ...))
1779 {
1780 #ifndef ANSI_PROTOTYPES
1781   const char *file;
1782   int line;
1783   const char *msgid;
1784 #endif
1785   va_list ap;
1786
1787   VA_START (ap, msgid);
1788
1789 #ifndef ANSI_PROTOTYPES
1790   file = va_arg (ap, const char *);
1791   line = va_arg (ap, int);
1792   msgid = va_arg (ap, const char *);
1793 #endif
1794
1795   v_error_with_file_and_line (file, line, msgid, ap);
1796   va_end (ap);
1797 }
1798
1799 /* Report an error at the declaration DECL.
1800    MSGID is a format string which uses %s to substitute the declaration
1801    name; subsequent substitutions are a la printf.  */
1802
1803 static void
1804 v_error_with_decl (decl, msgid, ap)
1805      tree decl;
1806      const char *msgid;
1807      va_list ap;
1808 {
1809   count_error (0);
1810   report_error_function (DECL_SOURCE_FILE (decl));
1811   v_message_with_decl (decl, 0, msgid, ap);
1812 }
1813
1814 void
1815 error_with_decl VPROTO((tree decl, const char *msgid, ...))
1816 {
1817 #ifndef ANSI_PROTOTYPES
1818   tree decl;
1819   const char *msgid;
1820 #endif
1821   va_list ap;
1822
1823   VA_START (ap, msgid);
1824
1825 #ifndef ANSI_PROTOTYPES
1826   decl = va_arg (ap, tree);
1827   msgid = va_arg (ap, const char *);
1828 #endif
1829
1830   v_error_with_decl (decl, msgid, ap);
1831   va_end (ap);
1832 }
1833
1834 /* Report an error at the line number of the insn INSN.
1835    This is used only when INSN is an `asm' with operands,
1836    and each ASM_OPERANDS records its own source file and line.  */
1837
1838 static void
1839 v_error_for_asm (insn, msgid, ap)
1840      rtx insn;
1841      const char *msgid;
1842      va_list ap;
1843 {
1844   char *file;
1845   int line;
1846
1847   count_error (0);
1848   file_and_line_for_asm (insn, &file, &line);
1849   report_error_function (file);
1850   v_message_with_file_and_line (file, line, 0, msgid, ap);
1851 }
1852
1853 void
1854 error_for_asm VPROTO((rtx insn, const char *msgid, ...))
1855 {
1856 #ifndef ANSI_PROTOTYPES
1857   rtx insn;
1858   const char *msgid;
1859 #endif
1860   va_list ap;
1861
1862   VA_START (ap, msgid);
1863
1864 #ifndef ANSI_PROTOTYPES
1865   insn = va_arg (ap, rtx);
1866   msgid = va_arg (ap, const char *);
1867 #endif
1868
1869   v_error_for_asm (insn, msgid, ap);
1870   va_end (ap);
1871 }
1872
1873 /* Report an error at the current line number.  */
1874
1875 static void
1876 verror (msgid, ap)
1877      const char *msgid;
1878      va_list ap;
1879 {
1880   v_error_with_file_and_line (input_filename, lineno, msgid, ap);
1881 }
1882
1883 void
1884 error VPROTO((const char *msgid, ...))
1885 {
1886 #ifndef ANSI_PROTOTYPES
1887   const char *msgid;
1888 #endif
1889   va_list ap;
1890
1891   VA_START (ap, msgid);
1892
1893 #ifndef ANSI_PROTOTYPES
1894   msgid = va_arg (ap, const char *);
1895 #endif
1896
1897   verror (msgid, ap);
1898   va_end (ap);
1899 }
1900
1901 /* Report a fatal error at the current line number.  Allow a front end to
1902    intercept the message.  */
1903
1904 static void (*fatal_function) PROTO ((const char *, va_list));
1905
1906 /* Set the function to call when a fatal error occurs.  */
1907
1908 void
1909 set_fatal_function (f)
1910      void (*f) PROTO ((const char *, va_list));
1911 {
1912   fatal_function = f;
1913 }
1914
1915 static void
1916 vfatal (msgid, ap)
1917      const char *msgid;
1918      va_list ap;
1919 {
1920    if (fatal_function != 0)
1921      (*fatal_function) (_(msgid), ap);
1922
1923   verror (msgid, ap);
1924   exit (FATAL_EXIT_CODE);
1925 }
1926
1927 void
1928 fatal VPROTO((const char *msgid, ...))
1929 {
1930 #ifndef ANSI_PROTOTYPES
1931   const char *msgid;
1932 #endif
1933   va_list ap;
1934
1935   VA_START (ap, msgid);
1936
1937 #ifndef ANSI_PROTOTYPES
1938   msgid = va_arg (ap, const char *);
1939 #endif
1940
1941   vfatal (msgid, ap);
1942   va_end (ap);
1943 }
1944
1945 void
1946 _fatal_insn (msgid, insn, file, line, function)
1947      const char *msgid;
1948      rtx insn;
1949      const char *file;
1950      int line;
1951      const char *function;
1952 {
1953   error (msgid);
1954   debug_rtx (insn);
1955   fancy_abort (file, line, function);
1956 }
1957
1958 void
1959 _fatal_insn_not_found (insn, file, line, function)
1960      rtx insn;
1961      const char *file;
1962      int line;
1963      const char *function;
1964 {
1965   if (INSN_CODE (insn) < 0)
1966     _fatal_insn ("Unrecognizable insn:", insn, file, line, function);
1967   else
1968     _fatal_insn ("Insn does not satisfy its constraints:",
1969                 insn, file, line, function);
1970 }
1971
1972 /* Report a warning at line LINE of file FILE.  */
1973
1974 static void
1975 v_warning_with_file_and_line (file, line, msgid, ap)
1976      const char *file;
1977      int line;
1978      const char *msgid;
1979      va_list ap;
1980 {
1981   if (count_error (1))
1982     {
1983       report_error_function (file);
1984       v_message_with_file_and_line (file, line, 1, msgid, ap);
1985     }
1986 }
1987
1988 void
1989 warning_with_file_and_line VPROTO((const char *file, int line,
1990                                    const char *msgid, ...))
1991 {
1992 #ifndef ANSI_PROTOTYPES
1993   const char *file;
1994   int line;
1995   const char *msgid;
1996 #endif
1997   va_list ap;
1998
1999   VA_START (ap, msgid);
2000
2001 #ifndef ANSI_PROTOTYPES
2002   file = va_arg (ap, const char *);
2003   line = va_arg (ap, int);
2004   msgid = va_arg (ap, const char *);
2005 #endif
2006
2007   v_warning_with_file_and_line (file, line, msgid, ap);
2008   va_end (ap);
2009 }
2010
2011 /* Report a warning at the declaration DECL.
2012    MSGID is a format string which uses %s to substitute the declaration
2013    name; subsequent substitutions are a la printf.  */
2014
2015 static void
2016 v_warning_with_decl (decl, msgid, ap)
2017      tree decl;
2018      const char *msgid;
2019      va_list ap;
2020 {
2021   if (count_error (1))
2022     {
2023       report_error_function (DECL_SOURCE_FILE (decl));
2024       v_message_with_decl (decl, 1, msgid, ap);
2025     }
2026 }
2027
2028 void
2029 warning_with_decl VPROTO((tree decl, const char *msgid, ...))
2030 {
2031 #ifndef ANSI_PROTOTYPES
2032   tree decl;
2033   const char *msgid;
2034 #endif
2035   va_list ap;
2036
2037   VA_START (ap, msgid);
2038
2039 #ifndef ANSI_PROTOTYPES
2040   decl = va_arg (ap, tree);
2041   msgid = va_arg (ap, const char *);
2042 #endif
2043
2044   v_warning_with_decl (decl, msgid, ap);
2045   va_end (ap);
2046 }
2047
2048 /* Report a warning at the line number of the insn INSN.
2049    This is used only when INSN is an `asm' with operands,
2050    and each ASM_OPERANDS records its own source file and line.  */
2051
2052 static void
2053 v_warning_for_asm (insn, msgid, ap)
2054      rtx insn;
2055      const char *msgid;
2056      va_list ap;
2057 {
2058   if (count_error (1))
2059     {
2060       char *file;
2061       int line;
2062
2063       file_and_line_for_asm (insn, &file, &line);
2064       report_error_function (file);
2065       v_message_with_file_and_line (file, line, 1, msgid, ap);
2066     }
2067 }
2068
2069 void
2070 warning_for_asm VPROTO((rtx insn, const char *msgid, ...))
2071 {
2072 #ifndef ANSI_PROTOTYPES
2073   rtx insn;
2074   const char *msgid;
2075 #endif
2076   va_list ap;
2077
2078   VA_START (ap, msgid);
2079
2080 #ifndef ANSI_PROTOTYPES
2081   insn = va_arg (ap, rtx);
2082   msgid = va_arg (ap, const char *);
2083 #endif
2084
2085   v_warning_for_asm (insn, msgid, ap);
2086   va_end (ap);
2087 }
2088
2089 /* Report a warning at the current line number.  */
2090
2091 static void
2092 vwarning (msgid, ap)
2093      const char *msgid;
2094      va_list ap;
2095 {
2096   v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
2097 }
2098
2099 void
2100 warning VPROTO((const char *msgid, ...))
2101 {
2102 #ifndef ANSI_PROTOTYPES
2103   const char *msgid;
2104 #endif
2105   va_list ap;
2106
2107   VA_START (ap, msgid);
2108
2109 #ifndef ANSI_PROTOTYPES
2110   msgid = va_arg (ap, const char *);
2111 #endif
2112
2113   vwarning (msgid, ap);
2114   va_end (ap);
2115 }
2116
2117 /* These functions issue either warnings or errors depending on
2118    -pedantic-errors.  */
2119
2120 static void
2121 vpedwarn (msgid, ap)
2122      const char *msgid;
2123      va_list ap;
2124 {
2125   if (flag_pedantic_errors)
2126     verror (msgid, ap);
2127   else
2128     vwarning (msgid, ap);
2129 }
2130
2131 void
2132 pedwarn VPROTO((const char *msgid, ...))
2133 {
2134 #ifndef ANSI_PROTOTYPES
2135   const char *msgid;
2136 #endif
2137   va_list ap;
2138
2139   VA_START (ap, msgid);
2140
2141 #ifndef ANSI_PROTOTYPES
2142   msgid = va_arg (ap, const char *);
2143 #endif
2144
2145   vpedwarn (msgid, ap);
2146   va_end (ap);
2147 }
2148
2149 static void
2150 v_pedwarn_with_decl (decl, msgid, ap)
2151      tree decl;
2152      const char *msgid;
2153      va_list ap;
2154 {
2155   /* We don't want -pedantic-errors to cause the compilation to fail from
2156      "errors" in system header files.  Sometimes fixincludes can't fix what's
2157      broken (eg: unsigned char bitfields - fixing it may change the alignment
2158      which will cause programs to mysteriously fail because the C library
2159      or kernel uses the original layout).  There's no point in issuing a
2160      warning either, it's just unnecessary noise.  */
2161
2162   if (! DECL_IN_SYSTEM_HEADER (decl))
2163     {
2164       if (flag_pedantic_errors)
2165         v_error_with_decl (decl, msgid, ap);
2166       else
2167         v_warning_with_decl (decl, msgid, ap);
2168     }
2169 }
2170
2171 void
2172 pedwarn_with_decl VPROTO((tree decl, const char *msgid, ...))
2173 {
2174 #ifndef ANSI_PROTOTYPES
2175   tree decl;
2176   const char *msgid;
2177 #endif
2178   va_list ap;
2179
2180   VA_START (ap, msgid);
2181
2182 #ifndef ANSI_PROTOTYPES
2183   decl = va_arg (ap, tree);
2184   msgid = va_arg (ap, const char *);
2185 #endif
2186
2187   v_pedwarn_with_decl (decl, msgid, ap);
2188   va_end (ap);
2189 }
2190
2191 static void
2192 v_pedwarn_with_file_and_line (file, line, msgid, ap)
2193      const char *file;
2194      int line;
2195      const char *msgid;
2196      va_list ap;
2197 {
2198   if (flag_pedantic_errors)
2199     v_error_with_file_and_line (file, line, msgid, ap);
2200   else
2201     v_warning_with_file_and_line (file, line, msgid, ap);
2202 }
2203
2204 void
2205 pedwarn_with_file_and_line VPROTO((const char *file, int line,
2206                                    const char *msgid, ...))
2207 {
2208 #ifndef ANSI_PROTOTYPES
2209   const char *file;
2210   int line;
2211   const char *msgid;
2212 #endif
2213   va_list ap;
2214
2215   VA_START (ap, msgid);
2216
2217 #ifndef ANSI_PROTOTYPES
2218   file = va_arg (ap, const char *);
2219   line = va_arg (ap, int);
2220   msgid = va_arg (ap, const char *);
2221 #endif
2222
2223   v_pedwarn_with_file_and_line (file, line, msgid, ap);
2224   va_end (ap);
2225 }
2226
2227 /* Apologize for not implementing some feature.  */
2228
2229 static void
2230 vsorry (msgid, ap)
2231      const char *msgid;
2232      va_list ap;
2233 {
2234   sorrycount++;
2235   if (input_filename)
2236     fprintf (stderr, "%s:%d: ", input_filename, lineno);
2237   else
2238     fprintf (stderr, "%s: ", progname);
2239   notice ("sorry, not implemented: ");
2240   vnotice (stderr, msgid, ap);
2241   fputc ('\n', stderr);
2242 }
2243
2244 void
2245 sorry VPROTO((const char *msgid, ...))
2246 {
2247 #ifndef ANSI_PROTOTYPES
2248   const char *msgid;
2249 #endif
2250   va_list ap;
2251
2252   VA_START (ap, msgid);
2253
2254 #ifndef ANSI_PROTOTYPES
2255   msgid = va_arg (ap, const char *);
2256 #endif
2257
2258   vsorry (msgid, ap);
2259   va_end (ap);
2260 }
2261 \f
2262
2263 /* This calls abort and is used to avoid problems when abort if a macro.
2264    It is used when we need to pass the address of abort.  */
2265
2266 void
2267 do_abort ()
2268 {
2269   abort ();
2270 }
2271
2272 /* When `malloc.c' is compiled with `rcheck' defined,
2273    it calls this function to report clobberage.  */
2274
2275 void
2276 botch (s)
2277   const char * s ATTRIBUTE_UNUSED;
2278 {
2279   abort ();
2280 }
2281 \f
2282 /* Return the logarithm of X, base 2, considering X unsigned,
2283    if X is a power of 2.  Otherwise, returns -1.
2284
2285    This should be used via the `exact_log2' macro.  */
2286
2287 int
2288 exact_log2_wide (x)
2289      register unsigned HOST_WIDE_INT x;
2290 {
2291   register int log = 0;
2292   /* Test for 0 or a power of 2.  */
2293   if (x == 0 || x != (x & -x))
2294     return -1;
2295   while ((x >>= 1) != 0)
2296     log++;
2297   return log;
2298 }
2299
2300 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2301    If X is 0, return -1.
2302
2303    This should be used via the floor_log2 macro.  */
2304
2305 int
2306 floor_log2_wide (x)
2307      register unsigned HOST_WIDE_INT x;
2308 {
2309   register int log = -1;
2310   while (x != 0)
2311     log++,
2312     x >>= 1;
2313   return log;
2314 }
2315
2316 static int float_handler_set;
2317 int float_handled;
2318 jmp_buf float_handler;
2319
2320 /* Signals actually come here.  */
2321
2322 static void
2323 float_signal (signo)
2324      /* If this is missing, some compilers complain.  */
2325      int signo ATTRIBUTE_UNUSED;
2326 {
2327   if (float_handled == 0)
2328     abort ();
2329 #if defined (USG) || defined (hpux)
2330   signal (SIGFPE, float_signal);  /* re-enable the signal catcher */
2331 #endif
2332   float_handled = 0;
2333   signal (SIGFPE, float_signal);
2334   longjmp (float_handler, 1);
2335 }
2336
2337 /* Specify where to longjmp to when a floating arithmetic error happens.
2338    If HANDLER is 0, it means don't handle the errors any more.  */
2339
2340 void
2341 set_float_handler (handler)
2342      jmp_buf handler;
2343 {
2344   float_handled = (handler != 0);
2345   if (handler)
2346     bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2347
2348   if (float_handled && ! float_handler_set)
2349     {
2350       signal (SIGFPE, float_signal);
2351       float_handler_set = 1;
2352     }
2353 }
2354
2355 /* This is a wrapper function for code which might elicit an
2356    arithmetic exception.  That code should be passed in as a function
2357    pointer FN, and one argument DATA.  DATA is usually a struct which
2358    contains the real input and output for function FN.  This function
2359    returns 0 (failure) if longjmp was called (i.e. an exception
2360    occured.)  It returns 1 (success) otherwise. */
2361
2362 int
2363 do_float_handler (fn, data)
2364   void (*fn) PROTO ((PTR));
2365   PTR data;
2366 {
2367   jmp_buf buf;
2368
2369   if (setjmp (buf))
2370     {
2371       /* We got here via longjmp() caused by an exception in function fn() */
2372       set_float_handler (NULL);
2373       return 0;
2374     }
2375
2376   set_float_handler (buf);
2377   (*fn)(data);
2378   set_float_handler (NULL);
2379   return 1;
2380 }
2381
2382 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2383    error happens, pushing the previous specification into OLD_HANDLER.
2384    Return an indication of whether there was a previous handler in effect.  */
2385
2386 int
2387 push_float_handler (handler, old_handler)
2388      jmp_buf handler, old_handler;
2389 {
2390   int was_handled = float_handled;
2391
2392   float_handled = 1;
2393   if (was_handled)
2394     memcpy ((char *) old_handler, (char *) float_handler,
2395            sizeof (float_handler));
2396
2397   memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
2398   return was_handled;
2399 }
2400
2401 /* Restore the previous specification of whether and where to longjmp to
2402    when a floating arithmetic error happens.  */
2403
2404 void
2405 pop_float_handler (handled, handler)
2406      int handled;
2407      jmp_buf handler;
2408 {
2409   float_handled = handled;
2410   if (handled)
2411     bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2412 }
2413
2414 /* Handler for SIGPIPE.  */
2415
2416 static void
2417 pipe_closed (signo)
2418      /* If this is missing, some compilers complain.  */
2419      int signo ATTRIBUTE_UNUSED;
2420 {
2421   fatal ("output pipe has been closed");
2422 }
2423
2424 /* Strip off a legitimate source ending from the input string NAME of
2425    length LEN.  Rather than having to know the names used by all of
2426    our front ends, we strip off an ending of a period followed by
2427    up to five characters.  (Java uses ".class".) */
2428
2429 void
2430 strip_off_ending (name, len)
2431      char *name;
2432      int len;
2433 {
2434   int i;
2435   for (i = 2;  i < 6 && len > i;  i++)
2436     {
2437       if (name[len - i] == '.')
2438         {
2439           name[len - i] = '\0';
2440           break;
2441         }
2442     }
2443 }
2444
2445 /* Output a quoted string.  */
2446
2447 void
2448 output_quoted_string (asm_file, string)
2449      FILE *asm_file;
2450      const char *string;
2451 {
2452 #ifdef OUTPUT_QUOTED_STRING
2453   OUTPUT_QUOTED_STRING (asm_file, string);
2454 #else
2455   char c;
2456
2457   putc ('\"', asm_file);
2458   while ((c = *string++) != 0)
2459     {
2460       if (c == '\"' || c == '\\')
2461         putc ('\\', asm_file);
2462       putc (c, asm_file);
2463     }
2464   putc ('\"', asm_file);
2465 #endif
2466 }
2467
2468 /* Output a file name in the form wanted by System V.  */
2469
2470 void
2471 output_file_directive (asm_file, input_name)
2472      FILE *asm_file;
2473      const char *input_name;
2474 {
2475   int len = strlen (input_name);
2476   const char *na = input_name + len;
2477
2478   /* NA gets INPUT_NAME sans directory names.  */
2479   while (na > input_name)
2480     {
2481       if (na[-1] == '/')
2482         break;
2483 #ifdef DIR_SEPARATOR
2484       if (na[-1] == DIR_SEPARATOR)
2485         break;
2486 #endif
2487       na--;
2488     }
2489
2490 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2491   ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2492 #else
2493 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2494   ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2495 #else
2496   fprintf (asm_file, "\t.file\t");
2497   output_quoted_string (asm_file, na);
2498   fputc ('\n', asm_file);
2499 #endif
2500 #endif
2501 }
2502 \f
2503 #ifdef ASM_IDENTIFY_LANGUAGE
2504 /* Routine to build language identifier for object file.  */
2505 static void
2506 output_lang_identify (asm_out_file)
2507      FILE *asm_out_file;
2508 {
2509   int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2510   char *s = (char *) alloca (len);
2511   sprintf (s, "__gnu_compiled_%s", lang_identify ());
2512   ASM_OUTPUT_LABEL (asm_out_file, s);
2513 }
2514 #endif
2515
2516 /* Routine to open a dump file.  */
2517 static void
2518 open_dump_file (suffix, function_name)
2519      const char *suffix;
2520      const char *function_name;
2521 {
2522   char *dumpname;
2523
2524   TIMEVAR
2525     (dump_time,
2526      {
2527        dumpname = concat (dump_base_name, suffix, NULL);
2528
2529        if (rtl_dump_file != NULL)
2530          fclose (rtl_dump_file);
2531   
2532        rtl_dump_file = fopen (dumpname, "a");
2533        
2534        if (rtl_dump_file == NULL)
2535          pfatal_with_name (dumpname);
2536        
2537        free (dumpname);
2538
2539        if (function_name)
2540          fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2541      });
2542   
2543   return;
2544 }
2545
2546 /* Routine to close a dump file.  */
2547 static void
2548 close_dump_file (func, insns)
2549      void (*func) PROTO ((FILE *, rtx));
2550      rtx    insns;
2551 {
2552   TIMEVAR
2553     (dump_time,
2554      {
2555        if (func)
2556          func (rtl_dump_file, insns);
2557        
2558        fflush (rtl_dump_file);
2559        fclose (rtl_dump_file);
2560        
2561        rtl_dump_file = NULL;
2562      });
2563
2564   return;
2565 }
2566
2567 /* Routine to dump rtl into a file.  */
2568 static void
2569 dump_rtl (suffix, decl, func, insns)
2570      const char *suffix;
2571      tree   decl;
2572      void (*func) PROTO ((FILE *, rtx));
2573      rtx    insns;
2574 {
2575   open_dump_file (suffix, decl_printable_name (decl, 2));
2576   close_dump_file (func, insns);
2577 }
2578
2579 /* Routine to empty a dump file.  */
2580 static void
2581 clean_dump_file (suffix)
2582   const char *suffix;
2583 {
2584   char * const dumpname = concat (dump_base_name, suffix, NULL);
2585
2586   rtl_dump_file = fopen (dumpname, "w");
2587
2588   if (rtl_dump_file == NULL)
2589     pfatal_with_name (dumpname);       
2590
2591   free (dumpname);
2592
2593   fclose (rtl_dump_file);
2594   rtl_dump_file = NULL;
2595   
2596   return;
2597 }
2598
2599 /* Do any final processing required for the declarations in VEC, of
2600    which there are LEN.  We write out inline functions and variables
2601    that have been deferred until this point, but which are required.
2602    Returns non-zero if anything was put out.  */ 
2603 int
2604 wrapup_global_declarations (vec, len)
2605      tree *vec;
2606      int len;
2607 {
2608   tree decl;
2609   int i;
2610   int reconsider;
2611   int output_something = 0;
2612
2613   for (i = 0; i < len; i++)
2614     {
2615       decl = vec[i];
2616       
2617       /* We're not deferring this any longer.  */
2618       DECL_DEFER_OUTPUT (decl) = 0;
2619       
2620       if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2621           && incomplete_decl_finalize_hook != 0)
2622         (*incomplete_decl_finalize_hook) (decl);
2623     }
2624
2625   /* Now emit any global variables or functions that we have been
2626      putting off.  We need to loop in case one of the things emitted
2627      here references another one which comes earlier in the list.  */
2628   do
2629     {
2630       reconsider = 0;
2631       for (i = 0; i < len; i++)
2632         {
2633           decl = vec[i];
2634
2635           if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2636             continue;
2637
2638           /* Don't write out static consts, unless we still need them.
2639
2640              We also keep static consts if not optimizing (for debugging),
2641              unless the user specified -fno-keep-static-consts.
2642              ??? They might be better written into the debug information.
2643              This is possible when using DWARF.
2644
2645              A language processor that wants static constants to be always
2646              written out (even if it is not used) is responsible for
2647              calling rest_of_decl_compilation itself.  E.g. the C front-end
2648              calls rest_of_decl_compilation from finish_decl.
2649              One motivation for this is that is conventional in some
2650              environments to write things like:
2651              static const char rcsid[] = "... version string ...";
2652              intending to force the string to be in the executable.
2653
2654              A language processor that would prefer to have unneeded
2655              static constants "optimized away" would just defer writing
2656              them out until here.  E.g. C++ does this, because static
2657              constants are often defined in header files.
2658
2659              ??? A tempting alternative (for both C and C++) would be
2660              to force a constant to be written if and only if it is
2661              defined in a main file, as opposed to an include file.  */
2662
2663           if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2664               && (! TREE_READONLY (decl)
2665                   || TREE_PUBLIC (decl)
2666                   || (!optimize && flag_keep_static_consts)
2667                   || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2668             {
2669               reconsider = 1;
2670               rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2671             }
2672
2673           if (TREE_CODE (decl) == FUNCTION_DECL
2674               && DECL_INITIAL (decl) != 0
2675               && DECL_SAVED_INSNS (decl) != 0
2676               && (flag_keep_inline_functions
2677                   || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2678                   || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2679             {
2680               reconsider = 1;
2681               temporary_allocation ();
2682               output_inline_function (decl);
2683               permanent_allocation (1);
2684             }
2685         }
2686
2687       if (reconsider)
2688         output_something = 1;
2689     }
2690   while (reconsider);
2691
2692   return output_something;
2693 }
2694
2695 /* Issue appropriate warnings for the global declarations in VEC (of
2696    which there are LEN).  Output debugging information for them.  */
2697 void
2698 check_global_declarations (vec, len)
2699      tree *vec;
2700      int len;
2701 {
2702   tree decl;
2703   int i;
2704
2705   for (i = 0; i < len; i++)
2706     {
2707       decl = vec[i];
2708
2709       if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2710           && ! TREE_ASM_WRITTEN (decl))
2711         /* Cancel the RTL for this decl so that, if debugging info
2712            output for global variables is still to come,
2713            this one will be omitted.  */
2714         DECL_RTL (decl) = NULL;
2715
2716       /* Warn about any function
2717          declared static but not defined.
2718          We don't warn about variables,
2719          because many programs have static variables
2720          that exist only to get some text into the object file.  */
2721       if (TREE_CODE (decl) == FUNCTION_DECL
2722           && (warn_unused
2723               || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2724           && DECL_INITIAL (decl) == 0
2725           && DECL_EXTERNAL (decl)
2726           && ! DECL_ARTIFICIAL (decl)
2727           && ! TREE_PUBLIC (decl))
2728         {
2729           if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2730             pedwarn_with_decl (decl,
2731                                "`%s' used but never defined");
2732           else
2733             warning_with_decl (decl,
2734                                "`%s' declared `static' but never defined");
2735           /* This symbol is effectively an "extern" declaration now.  */
2736           TREE_PUBLIC (decl) = 1;
2737           assemble_external (decl);
2738         }
2739
2740       /* Warn about static fns or vars defined but not used,
2741          but not about inline functions or static consts
2742          since defining those in header files is normal practice.  */
2743       if (warn_unused
2744           && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2745               || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2746           && ! DECL_IN_SYSTEM_HEADER (decl)
2747           && ! DECL_EXTERNAL (decl)
2748           && ! TREE_PUBLIC (decl)
2749           && ! TREE_USED (decl)
2750           && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2751           /* The TREE_USED bit for file-scope decls
2752              is kept in the identifier, to handle multiple
2753              external decls in different scopes.  */
2754           && ! TREE_USED (DECL_NAME (decl)))
2755         warning_with_decl (decl, "`%s' defined but not used");
2756
2757 #ifdef SDB_DEBUGGING_INFO
2758       /* The COFF linker can move initialized global vars to the end.
2759          And that can screw up the symbol ordering.
2760          By putting the symbols in that order to begin with,
2761          we avoid a problem.  mcsun!unido!fauern!tumuc!pes@uunet.uu.net.  */
2762       if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2763           && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2764           && ! DECL_EXTERNAL (decl)
2765           && DECL_RTL (decl) != 0)
2766         TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2767
2768       /* Output COFF information for non-global
2769          file-scope initialized variables.  */
2770       if (write_symbols == SDB_DEBUG
2771           && TREE_CODE (decl) == VAR_DECL
2772           && DECL_INITIAL (decl)
2773           && ! DECL_EXTERNAL (decl)
2774           && DECL_RTL (decl) != 0
2775           && GET_CODE (DECL_RTL (decl)) == MEM)
2776         TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2777 #endif /* SDB_DEBUGGING_INFO */
2778 #ifdef DWARF_DEBUGGING_INFO
2779       /* Output DWARF information for file-scope tentative data object
2780          declarations, file-scope (extern) function declarations (which
2781          had no corresponding body) and file-scope tagged type declarations
2782          and definitions which have not yet been forced out.  */
2783
2784       if (write_symbols == DWARF_DEBUG
2785           && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2786         TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2787 #endif
2788 #ifdef DWARF2_DEBUGGING_INFO
2789       /* Output DWARF2 information for file-scope tentative data object
2790          declarations, file-scope (extern) function declarations (which
2791          had no corresponding body) and file-scope tagged type declarations
2792          and definitions which have not yet been forced out.  */
2793
2794       if (write_symbols == DWARF2_DEBUG
2795           && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2796         TIMEVAR (symout_time, dwarf2out_decl (decl));
2797 #endif
2798     }
2799 }
2800
2801 /* Compile an entire file of output from cpp, named NAME.
2802    Write a file of assembly output and various debugging dumps.  */
2803
2804 static void
2805 compile_file (name)
2806      char *name;
2807 {
2808   tree globals;
2809   int start_time;
2810
2811   int name_specified = name != 0;
2812
2813   if (dump_base_name == 0)
2814     dump_base_name = name ? name : "gccdump";
2815
2816   parse_time = 0;
2817   varconst_time = 0;
2818   integration_time = 0;
2819   jump_time = 0;
2820   cse_time = 0;
2821   gcse_time = 0;
2822   loop_time = 0;
2823   cse2_time = 0;
2824   branch_prob_time = 0;
2825   flow_time = 0;
2826   combine_time = 0;
2827   regmove_time = 0;
2828   sched_time = 0;
2829   local_alloc_time = 0;
2830   global_alloc_time = 0;
2831   flow2_time = 0;
2832   sched2_time = 0;
2833 #ifdef DELAY_SLOTS
2834   dbr_sched_time = 0;
2835 #endif
2836   shorten_branch_time = 0;
2837   stack_reg_time = 0;
2838   final_time = 0;
2839   symout_time = 0;
2840   dump_time = 0;
2841
2842   /* Initialize data in various passes.  */
2843
2844   init_obstacks ();
2845   init_tree_codes ();
2846   name = init_parse (name);
2847   init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2848                   || debug_info_level == DINFO_LEVEL_VERBOSE
2849                   || flag_test_coverage
2850                   || warn_notreached);
2851   init_regs ();
2852   init_decl_processing ();
2853   init_optabs ();
2854   init_stmt ();
2855   init_eh ();
2856   init_loop ();
2857   init_reload ();
2858   init_alias_once ();
2859   init_function_once ();
2860   init_stor_layout_once ();
2861   init_varasm_once ();
2862
2863   /* The following initialization functions need to generate rtl, so
2864      provide a dummy function context for them.  */
2865   init_dummy_function_start ();
2866   init_expmed ();
2867   init_expr_once ();
2868   if (flag_caller_saves)
2869     init_caller_save ();
2870   expand_dummy_function_end ();
2871
2872   /* If auxiliary info generation is desired, open the output file.
2873      This goes in the same directory as the source file--unlike
2874      all the other output files.  */
2875   if (flag_gen_aux_info)
2876     {
2877       aux_info_file = fopen (aux_info_file_name, "w");
2878       if (aux_info_file == 0)
2879         pfatal_with_name (aux_info_file_name);
2880     }
2881
2882   /* Clear the dump files.  */
2883   if (rtl_dump)
2884     clean_dump_file (".rtl");
2885   if (jump_opt_dump)
2886     {
2887       clean_dump_file (".jump");
2888       if (graph_dump_format != no_graph)
2889         clean_graph_dump_file (dump_base_name, ".jump");
2890     }
2891   if (addressof_dump)
2892     {
2893       clean_dump_file (".addressof");
2894       if (graph_dump_format != no_graph)
2895         clean_graph_dump_file (dump_base_name, ".addressof");
2896     }
2897   if (cse_dump)
2898     {
2899       clean_dump_file (".cse");
2900       if (graph_dump_format != no_graph)
2901         clean_graph_dump_file (dump_base_name, ".cse");
2902     }
2903   if (loop_dump)
2904     {
2905       clean_dump_file (".loop");
2906       if (graph_dump_format != no_graph)
2907         clean_graph_dump_file (dump_base_name, ".loop");
2908     }
2909   if (cse2_dump)
2910     {
2911       clean_dump_file (".cse2");
2912       if (graph_dump_format != no_graph)
2913         clean_graph_dump_file (dump_base_name, ".cse2");
2914     }
2915   if (branch_prob_dump)
2916     {
2917       clean_dump_file (".bp");
2918       if (graph_dump_format != no_graph)
2919         clean_graph_dump_file (dump_base_name, ".bp");
2920     }
2921   if (flow_dump)
2922     {
2923       clean_dump_file (".flow");
2924       if (graph_dump_format != no_graph)
2925         clean_graph_dump_file (dump_base_name, ".flow");
2926     }
2927   if (combine_dump)
2928     {
2929       clean_dump_file (".combine");
2930       if (graph_dump_format != no_graph)
2931         clean_graph_dump_file (dump_base_name, ".combine");
2932     }
2933   if (regmove_dump)
2934     {
2935       clean_dump_file (".regmove");
2936       if (graph_dump_format != no_graph)
2937         clean_graph_dump_file (dump_base_name, ".regmove");
2938     }
2939   if (sched_dump)
2940     {
2941       clean_dump_file (".sched");
2942       if (graph_dump_format != no_graph)
2943         clean_graph_dump_file (dump_base_name, ".sched");
2944     }
2945   if (local_reg_dump)
2946     {
2947       clean_dump_file (".lreg");
2948       if (graph_dump_format != no_graph)
2949         clean_graph_dump_file (dump_base_name, ".lreg");
2950     }
2951   if (global_reg_dump)
2952     {
2953       clean_dump_file (".greg");
2954       if (graph_dump_format != no_graph)
2955         clean_graph_dump_file (dump_base_name, ".greg");
2956     }
2957   if (flow2_dump)
2958     {
2959       clean_dump_file (".flow2");
2960       if (graph_dump_format != no_graph)
2961         clean_graph_dump_file (dump_base_name, ".flow2");
2962     }
2963   if (peephole2_dump)
2964     {
2965       clean_dump_file (".peephole2");
2966       if (graph_dump_format != no_graph)
2967         clean_graph_dump_file (dump_base_name, ".peephole2");
2968     }
2969   if (sched2_dump)
2970     {
2971       clean_dump_file (".sched2");
2972       if (graph_dump_format != no_graph)
2973         clean_graph_dump_file (dump_base_name, ".sched2");
2974     }
2975   if (jump2_opt_dump)
2976     {
2977       clean_dump_file (".jump2");
2978       if (graph_dump_format != no_graph)
2979         clean_graph_dump_file (dump_base_name, ".jump2");
2980     }
2981 #ifdef DELAY_SLOTS
2982   if (dbr_sched_dump)
2983     {
2984       clean_dump_file (".dbr");
2985       if (graph_dump_format != no_graph)
2986         clean_graph_dump_file (dump_base_name, ".dbr");
2987     }
2988 #endif
2989   if (gcse_dump)
2990     {
2991       clean_dump_file (".gcse");
2992       if (graph_dump_format != no_graph)
2993         clean_graph_dump_file (dump_base_name, ".gcse");
2994     }
2995 #ifdef STACK_REGS
2996   if (stack_reg_dump)
2997     {
2998       clean_dump_file (".stack");
2999       if (graph_dump_format != no_graph)
3000         clean_graph_dump_file (dump_base_name, ".stack");
3001     }
3002 #endif
3003 #ifdef MACHINE_DEPENDENT_REORG
3004   if (mach_dep_reorg_dump)
3005     {
3006       clean_dump_file (".mach");
3007       if (graph_dump_format != no_graph)
3008         clean_graph_dump_file (dump_base_name, ".mach");
3009     }
3010 #endif
3011
3012   /* Open assembler code output file.  */
3013
3014   if (flag_syntax_only)
3015     asm_out_file = NULL;
3016   else
3017     {
3018       if (! name_specified && asm_file_name == 0)
3019         asm_out_file = stdout;
3020       else
3021         {
3022           int len = strlen (dump_base_name);
3023           register char *dumpname = (char *) xmalloc (len + 6);
3024           strcpy (dumpname, dump_base_name);
3025           strip_off_ending (dumpname, len);
3026           strcat (dumpname, ".s");
3027           if (asm_file_name == 0)
3028             asm_file_name = xstrdup (dumpname);
3029           if (!strcmp (asm_file_name, "-"))
3030             asm_out_file = stdout;
3031           else
3032             asm_out_file = fopen (asm_file_name, "w");
3033           if (asm_out_file == 0)
3034             pfatal_with_name (asm_file_name);
3035         }
3036
3037 #ifdef IO_BUFFER_SIZE
3038       setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
3039                _IOFBF, IO_BUFFER_SIZE);
3040 #endif
3041     }
3042
3043   if (ggc_p)
3044     name = ggc_alloc_string (name, strlen (name));
3045   input_filename = name;
3046
3047   /* Put an entry on the input file stack for the main input file.  */
3048   input_file_stack
3049     = (struct file_stack *) xmalloc (sizeof (struct file_stack));
3050   input_file_stack->next = 0;
3051   input_file_stack->name = input_filename;
3052
3053   /* Perform language-specific initialization.
3054      This may set main_input_filename.  */
3055   lang_init ();
3056
3057   /* If the input doesn't start with a #line, use the input name
3058      as the official input file name.  */
3059   if (main_input_filename == 0)
3060     main_input_filename = name;
3061
3062   if (flag_syntax_only)
3063     {
3064       write_symbols = NO_DEBUG;
3065       profile_flag = 0;
3066       profile_block_flag = 0;
3067     }
3068   else
3069     {
3070       ASM_FILE_START (asm_out_file);
3071
3072 #ifdef ASM_COMMENT_START
3073       if (flag_verbose_asm)
3074         {
3075           /* Print the list of options in effect.  */
3076           print_version (asm_out_file, ASM_COMMENT_START);
3077           print_switch_values (asm_out_file, 0, MAX_LINE,
3078                                ASM_COMMENT_START, " ", "\n");
3079           /* Add a blank line here so it appears in assembler output but not
3080              screen output.  */
3081           fprintf (asm_out_file, "\n");
3082         }
3083 #endif
3084
3085       /* Output something to inform GDB that this compilation was by GCC.  */
3086 #ifndef ASM_IDENTIFY_GCC
3087       fprintf (asm_out_file, "gcc2_compiled.:\n");
3088 #else
3089       ASM_IDENTIFY_GCC (asm_out_file);
3090 #endif
3091
3092   /* Output something to identify which front-end produced this file.  */
3093 #ifdef ASM_IDENTIFY_LANGUAGE
3094       ASM_IDENTIFY_LANGUAGE (asm_out_file);
3095 #endif
3096     } /* ! flag_syntax_only */
3097
3098 #ifndef ASM_OUTPUT_SECTION_NAME
3099   if (flag_function_sections)
3100     {
3101       warning ("-ffunction-sections not supported for this target.");
3102       flag_function_sections = 0;
3103     }
3104   if (flag_data_sections)
3105     {
3106       warning ("-fdata-sections not supported for this target.");
3107       flag_data_sections = 0;
3108     }
3109 #endif
3110
3111   if (flag_function_sections
3112       && (profile_flag || profile_block_flag))
3113     {
3114       warning ("-ffunction-sections disabled; it makes profiling impossible.");
3115       flag_function_sections = 0;
3116     }
3117
3118 #ifndef OBJECT_FORMAT_ELF
3119   if (flag_function_sections && write_symbols != NO_DEBUG)
3120     warning ("-ffunction-sections may affect debugging on some targets.");
3121 #endif
3122
3123   /* ??? Note: There used to be a conditional here
3124       to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
3125       This was to guarantee separation between gcc_compiled. and
3126       the first function, for the sake of dbx on Suns.
3127       However, having the extra zero here confused the Emacs
3128       code for unexec, and might confuse other programs too.
3129       Therefore, I took out that change.
3130       In future versions we should find another way to solve
3131       that dbx problem.  -- rms, 23 May 93.  */
3132       
3133   /* Don't let the first function fall at the same address
3134      as gcc_compiled., if profiling.  */
3135   if (profile_flag || profile_block_flag)
3136     {
3137       /* It's best if we can write a nop here since some
3138          assemblers don't tolerate zeros in the text section.  */
3139       output_asm_insn (get_insn_template (CODE_FOR_nop, NULL), NULL_PTR);
3140     }
3141
3142   /* If dbx symbol table desired, initialize writing it
3143      and output the predefined types.  */
3144 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3145   if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3146     TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
3147                                        getdecls ()));
3148 #endif
3149 #ifdef SDB_DEBUGGING_INFO
3150   if (write_symbols == SDB_DEBUG)
3151     TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
3152                                        getdecls ()));
3153 #endif
3154 #ifdef DWARF_DEBUGGING_INFO
3155   if (write_symbols == DWARF_DEBUG)
3156     TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
3157 #endif
3158 #ifdef DWARF2_UNWIND_INFO
3159   if (dwarf2out_do_frame ())
3160     dwarf2out_frame_init ();
3161 #endif
3162 #ifdef DWARF2_DEBUGGING_INFO
3163   if (write_symbols == DWARF2_DEBUG)
3164     TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
3165 #endif
3166
3167   /* Initialize yet another pass.  */
3168
3169   init_final (main_input_filename);
3170   init_branch_prob (dump_base_name);
3171
3172   start_time = get_run_time ();
3173
3174   /* Call the parser, which parses the entire file
3175      (calling rest_of_compilation for each function).  */
3176
3177   if (yyparse () != 0)
3178     {
3179       if (errorcount == 0)
3180         notice ("Errors detected in input file (your bison.simple is out of date)\n");
3181
3182       /* In case there were missing closebraces,
3183          get us back to the global binding level.  */
3184       while (! global_bindings_p ())
3185         poplevel (0, 0, 0);
3186     }
3187
3188   /* Compilation is now finished except for writing
3189      what's left of the symbol table output.  */
3190
3191   parse_time += get_run_time () - start_time;
3192
3193   parse_time -= integration_time;
3194   parse_time -= varconst_time;
3195
3196   if (flag_syntax_only)
3197     goto finish_syntax;
3198
3199   globals = getdecls ();
3200
3201   /* Really define vars that have had only a tentative definition.
3202      Really output inline functions that must actually be callable
3203      and have not been output so far.  */
3204
3205   {
3206     int len = list_length (globals);
3207     tree *vec = (tree *) alloca (sizeof (tree) * len);
3208     int i;
3209     tree decl;
3210
3211     /* Process the decls in reverse order--earliest first.
3212        Put them into VEC from back to front, then take out from front.  */
3213
3214     for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
3215       vec[len - i - 1] = decl;
3216
3217     wrapup_global_declarations (vec, len);
3218
3219     /* This must occur after the loop to output deferred functions.  Else
3220        the profiler initializer would not be emitted if all the functions
3221        in this compilation unit were deferred.
3222
3223        output_func_start_profiler can not cause any additional functions or
3224        data to need to be output, so it need not be in the deferred function
3225        loop above.  */
3226     output_func_start_profiler ();
3227
3228     /* Now that all possible functions have been output, we can dump
3229        the exception table.  */
3230
3231     output_exception_table ();
3232
3233     check_global_declarations (vec, len);
3234   }
3235
3236   /* Write out any pending weak symbol declarations.  */
3237
3238   weak_finish ();
3239
3240   /* Do dbx symbols */
3241 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3242   if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3243     TIMEVAR (symout_time,
3244              {
3245                dbxout_finish (asm_out_file, main_input_filename);
3246              });
3247 #endif
3248
3249 #ifdef DWARF_DEBUGGING_INFO
3250   if (write_symbols == DWARF_DEBUG)
3251     TIMEVAR (symout_time,
3252              {
3253                dwarfout_finish ();
3254              });
3255 #endif
3256
3257 #ifdef DWARF2_UNWIND_INFO
3258   if (dwarf2out_do_frame ())
3259     dwarf2out_frame_finish ();
3260 #endif
3261
3262 #ifdef DWARF2_DEBUGGING_INFO
3263   if (write_symbols == DWARF2_DEBUG)
3264     TIMEVAR (symout_time,
3265              {
3266                dwarf2out_finish ();
3267              });
3268 #endif
3269
3270   /* Output some stuff at end of file if nec.  */
3271
3272   end_final (dump_base_name);
3273    
3274   if (branch_prob_dump)
3275     open_dump_file (".bp", NULL);
3276    
3277   TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
3278    
3279   if (branch_prob_dump)
3280     close_dump_file (NULL, NULL_RTX);
3281    
3282 #ifdef ASM_FILE_END
3283   ASM_FILE_END (asm_out_file);
3284 #endif
3285
3286
3287   /* Language-specific end of compilation actions.  */
3288  finish_syntax:
3289   lang_finish ();
3290
3291   /* Close the dump files.  */
3292
3293   if (flag_gen_aux_info)
3294     {
3295       fclose (aux_info_file);
3296       if (errorcount)
3297         unlink (aux_info_file_name);
3298     }
3299
3300   if (combine_dump)
3301     {
3302       open_dump_file (".combine", NULL);
3303       TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
3304       close_dump_file (NULL, NULL_RTX);
3305     }
3306
3307   /* Close non-debugging input and output files.  Take special care to note
3308      whether fclose returns an error, since the pages might still be on the
3309      buffer chain while the file is open.  */
3310
3311   finish_parse ();
3312
3313   if (! flag_syntax_only
3314       && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
3315     fatal_io_error (asm_file_name);
3316
3317   /* Do whatever is necessary to finish printing the graphs.  */
3318   if (graph_dump_format != no_graph)
3319     {
3320       if (jump_opt_dump)
3321         finish_graph_dump_file (dump_base_name, ".jump");
3322       if (addressof_dump)
3323         finish_graph_dump_file (dump_base_name, ".addressof");
3324       if (cse_dump)
3325         finish_graph_dump_file (dump_base_name, ".cse");
3326       if (loop_dump)
3327         finish_graph_dump_file (dump_base_name, ".loop");
3328       if (cse2_dump)
3329         finish_graph_dump_file (dump_base_name, ".cse2");
3330       if (branch_prob_dump)
3331         finish_graph_dump_file (dump_base_name, ".bp");
3332       if (flow_dump)
3333         finish_graph_dump_file (dump_base_name, ".flow");
3334       if (combine_dump)
3335         finish_graph_dump_file (dump_base_name, ".combine");
3336       if (regmove_dump)
3337         finish_graph_dump_file (dump_base_name, ".regmove");
3338       if (sched_dump)
3339         finish_graph_dump_file (dump_base_name, ".sched");
3340       if (local_reg_dump)
3341         finish_graph_dump_file (dump_base_name, ".lreg");
3342       if (global_reg_dump)
3343         finish_graph_dump_file (dump_base_name, ".greg");
3344       if (flow2_dump)
3345         finish_graph_dump_file (dump_base_name, ".flow2");
3346       if (sched2_dump)
3347         finish_graph_dump_file (dump_base_name, ".sched2");
3348       if (jump2_opt_dump)
3349         finish_graph_dump_file (dump_base_name, ".jump2");
3350 #ifdef DELAY_SLOTS
3351       if (dbr_sched_dump)
3352         finish_graph_dump_file (dump_base_name, ".dbr");
3353 #endif
3354       if (gcse_dump)
3355         finish_graph_dump_file (dump_base_name, ".gcse");
3356 #ifdef STACK_REGS
3357       if (stack_reg_dump)
3358         finish_graph_dump_file (dump_base_name, ".stack");
3359 #endif
3360 #ifdef MACHINE_DEPENDENT_REORG
3361       if (mach_dep_reorg_dump)
3362         finish_graph_dump_file (dump_base_name, ".mach");
3363 #endif
3364     }
3365
3366   /* Free up memory for the benefit of leak detectors.  */
3367   free_reg_info ();
3368
3369   /* Print the times.  */
3370
3371   if (! quiet_flag)
3372     {
3373       all_time = get_run_time ();
3374
3375       fprintf (stderr,"\n");
3376
3377       print_time ("parse", parse_time);
3378       print_time ("integration", integration_time);
3379       print_time ("jump", jump_time);
3380       print_time ("cse", cse_time);
3381       print_time ("gcse", gcse_time);
3382       print_time ("loop", loop_time);
3383       print_time ("cse2", cse2_time);
3384       print_time ("branch-prob", branch_prob_time);
3385       print_time ("flow", flow_time);
3386       print_time ("combine", combine_time);
3387       print_time ("regmove", regmove_time);
3388       print_time ("sched", sched_time);
3389       print_time ("local-alloc", local_alloc_time);
3390       print_time ("global-alloc", global_alloc_time);
3391       print_time ("flow2", flow2_time);
3392       print_time ("sched2", sched2_time);
3393 #ifdef DELAY_SLOTS
3394       print_time ("dbranch", dbr_sched_time);
3395 #endif
3396       print_time ("shorten-branch", shorten_branch_time);
3397       print_time ("stack-reg", stack_reg_time);
3398       print_time ("final", final_time);
3399       print_time ("varconst", varconst_time);
3400       print_time ("symout", symout_time);
3401       print_time ("dump", dump_time);
3402       print_time ("gc", gc_time);
3403     }
3404 }
3405 \f
3406 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3407    and TYPE_DECL nodes.
3408
3409    This does nothing for local (non-static) variables, unless the
3410    variable is a register variable with an ASMSPEC.  In that case, or
3411    if the variable is not an automatice, it sets up the RTL and
3412    outputs any assembler code (label definition, storage allocation
3413    and initialization).
3414
3415    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
3416    the assembler symbol name to be used.  TOP_LEVEL is nonzero
3417    if this declaration is not within a function.  */
3418
3419 void
3420 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
3421      tree decl;
3422      const char *asmspec;
3423      int top_level;
3424      int at_end;
3425 {
3426   /* Declarations of variables, and of functions defined elsewhere.  */
3427
3428 /* The most obvious approach, to put an #ifndef around where
3429    this macro is used, doesn't work since it's inside a macro call.  */
3430 #ifndef ASM_FINISH_DECLARE_OBJECT
3431 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3432 #endif
3433
3434   /* Forward declarations for nested functions are not "external",
3435      but we need to treat them as if they were.  */
3436   if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
3437       || TREE_CODE (decl) == FUNCTION_DECL)
3438     TIMEVAR (varconst_time,
3439              {
3440                make_decl_rtl (decl, asmspec, top_level);
3441                /* Initialized extern variable exists to be replaced
3442                   with its value, or represents something that will be
3443                   output in another file.  */
3444                if (! (TREE_CODE (decl) == VAR_DECL
3445                       && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
3446                       && DECL_INITIAL (decl) != 0
3447                       && DECL_INITIAL (decl) != error_mark_node))
3448                  /* Don't output anything
3449                     when a tentative file-scope definition is seen.
3450                     But at end of compilation, do output code for them.  */
3451                  if (! (! at_end && top_level
3452                         && (DECL_INITIAL (decl) == 0
3453                             || DECL_INITIAL (decl) == error_mark_node)))
3454                    assemble_variable (decl, top_level, at_end, 0);
3455                if (decl == last_assemble_variable_decl)
3456                  {
3457                    ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
3458                                               top_level, at_end);
3459                  }
3460              });
3461   else if (DECL_REGISTER (decl) && asmspec != 0)
3462     {
3463       if (decode_reg_name (asmspec) >= 0)
3464         {
3465           DECL_RTL (decl) = 0;
3466           make_decl_rtl (decl, asmspec, top_level);
3467         }
3468       else
3469         error ("invalid register name `%s' for register variable", asmspec);
3470     }
3471 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3472   else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3473            && TREE_CODE (decl) == TYPE_DECL)
3474     TIMEVAR (symout_time, dbxout_symbol (decl, 0));
3475 #endif
3476 #ifdef SDB_DEBUGGING_INFO
3477   else if (write_symbols == SDB_DEBUG && top_level
3478            && TREE_CODE (decl) == TYPE_DECL)
3479     TIMEVAR (symout_time, sdbout_symbol (decl, 0));
3480 #endif
3481 }
3482
3483 /* Called after finishing a record, union or enumeral type.  */
3484
3485 void
3486 rest_of_type_compilation (type, toplev)
3487 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3488      tree type;
3489      int toplev;
3490 #else
3491      tree type ATTRIBUTE_UNUSED;
3492      int toplev ATTRIBUTE_UNUSED;
3493 #endif
3494 {
3495 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3496   if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3497     TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3498 #endif
3499 #ifdef SDB_DEBUGGING_INFO
3500   if (write_symbols == SDB_DEBUG)
3501     TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3502 #endif
3503 }
3504
3505 /* This is called from finish_function (within yyparse)
3506    after each top-level definition is parsed.
3507    It is supposed to compile that function or variable
3508    and output the assembler code for it.
3509    After we return, the tree storage is freed.  */
3510
3511 void
3512 rest_of_compilation (decl)
3513      tree decl;
3514 {
3515   register rtx insns;
3516   int start_time = get_run_time ();
3517   int tem;
3518   /* Nonzero if we have saved the original DECL_INITIAL of the function,
3519      to be restored after we finish compiling the function
3520      (for use when compiling inline calls to this function).  */
3521   tree saved_block_tree = 0;
3522   /* Likewise, for DECL_ARGUMENTS.  */
3523   tree saved_arguments = 0;
3524   int failure = 0;
3525   int rebuild_label_notes_after_reload;
3526
3527   /* If we are reconsidering an inline function
3528      at the end of compilation, skip the stuff for making it inline.  */
3529
3530   if (DECL_SAVED_INSNS (decl) == 0)
3531     {
3532       int inlinable = 0;
3533       const char *lose;
3534
3535       /* If requested, consider whether to make this function inline.  */
3536       if (DECL_INLINE (decl) || flag_inline_functions)
3537         TIMEVAR (integration_time,
3538                  {
3539                    lose = function_cannot_inline_p (decl);
3540                    if (lose || ! optimize)
3541                      {
3542                        if (warn_inline && DECL_INLINE (decl))
3543                          warning_with_decl (decl, lose);
3544                        DECL_ABSTRACT_ORIGIN (decl) = 0;
3545                        /* Don't really compile an extern inline function.
3546                           If we can't make it inline, pretend
3547                           it was only declared.  */
3548                        if (DECL_EXTERNAL (decl))
3549                          {
3550                            DECL_INITIAL (decl) = 0;
3551                            goto exit_rest_of_compilation;
3552                          }
3553                      }
3554                    else
3555                      /* ??? Note that this has the effect of making it look
3556                         like "inline" was specified for a function if we choose
3557                         to inline it.  This isn't quite right, but it's
3558                         probably not worth the trouble to fix.  */
3559                      inlinable = DECL_INLINE (decl) = 1;
3560                  });
3561
3562       insns = get_insns ();
3563
3564       /* Dump the rtl code if we are dumping rtl.  */
3565
3566       if (rtl_dump)
3567         {
3568           open_dump_file (".rtl", decl_printable_name (decl, 2));
3569           
3570           if (DECL_SAVED_INSNS (decl))
3571             fprintf (rtl_dump_file, ";; (integrable)\n\n");
3572           
3573           close_dump_file (print_rtl, insns);
3574         }
3575
3576       /* If function is inline, and we don't yet know whether to
3577          compile it by itself, defer decision till end of compilation.
3578          finish_compilation will call rest_of_compilation again
3579          for those functions that need to be output.  Also defer those
3580          functions that we are supposed to defer.  */
3581
3582       if (inlinable)
3583         DECL_DEFER_OUTPUT (decl) = 1;
3584
3585       if (DECL_DEFER_OUTPUT (decl)
3586           || (DECL_INLINE (decl)
3587               && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3588                    && ! flag_keep_inline_functions)
3589                   || DECL_EXTERNAL (decl))))
3590         {
3591           DECL_DEFER_OUTPUT (decl) = 1;
3592
3593           /* If -Wreturn-type, we have to do a bit of compilation.
3594              However, if we just fall through we will call
3595              save_for_inline_copying() which results in excessive
3596              memory use.  Instead, we just want to call
3597              jump_optimize() to figure out whether or not we can fall
3598              off the end of the function; we do the minimum amount of
3599              work necessary to make that safe.  And, we set optimize
3600              to zero to keep jump_optimize from working too hard.  */
3601           if (warn_return_type)
3602             {
3603               int saved_optimize = optimize;
3604               optimize = 0;
3605               find_exception_handler_labels ();
3606               jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3607                              !JUMP_AFTER_REGSCAN);
3608               optimize = saved_optimize;
3609             }
3610
3611 #ifdef DWARF_DEBUGGING_INFO
3612           /* Generate the DWARF info for the "abstract" instance
3613              of a function which we may later generate inlined and/or
3614              out-of-line instances of.  */
3615           if (write_symbols == DWARF_DEBUG)
3616             {
3617               set_decl_abstract_flags (decl, 1);
3618               TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3619               set_decl_abstract_flags (decl, 0);
3620             }
3621 #endif
3622 #ifdef DWARF2_DEBUGGING_INFO
3623           /* Generate the DWARF2 info for the "abstract" instance
3624              of a function which we may later generate inlined and/or
3625              out-of-line instances of.  */
3626           if (write_symbols == DWARF2_DEBUG)
3627             {
3628               set_decl_abstract_flags (decl, 1);
3629               TIMEVAR (symout_time, dwarf2out_decl (decl));
3630               set_decl_abstract_flags (decl, 0);
3631             }
3632 #endif
3633           TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3634           DECL_SAVED_INSNS (decl)->inlinable = inlinable;
3635           goto exit_rest_of_compilation;
3636         }
3637
3638       /* If specified extern inline but we aren't inlining it, we are
3639          done.  This goes for anything that gets here with DECL_EXTERNAL
3640          set, not just things with DECL_INLINE.  */
3641       if (DECL_EXTERNAL (decl))
3642         goto exit_rest_of_compilation;
3643     }
3644
3645   /* Initialize some variables used by the optimizers.  */
3646   init_function_for_compilation ();
3647
3648   if (! DECL_DEFER_OUTPUT (decl))
3649     TREE_ASM_WRITTEN (decl) = 1;
3650
3651   /* Now that integrate will no longer see our rtl, we need not distinguish
3652      between the return value of this function and the return value of called
3653      functions.  */
3654   rtx_equal_function_value_matters = 0;
3655
3656   /* Don't return yet if -Wreturn-type; we need to do jump_optimize.  */
3657   if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3658     {
3659       goto exit_rest_of_compilation;
3660     }
3661
3662   /* Emit code to get eh context, if needed. */
3663   emit_eh_context ();
3664
3665 #ifdef FINALIZE_PIC
3666   /* If we are doing position-independent code generation, now
3667      is the time to output special prologues and epilogues.
3668      We do not want to do this earlier, because it just clutters
3669      up inline functions with meaningless insns.  */
3670   if (flag_pic)
3671     FINALIZE_PIC;
3672 #endif
3673
3674   /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3675      Note that that may have been done above, in save_for_inline_copying.
3676      The call to resume_temporary_allocation near the end of this function
3677      goes back to the usual state of affairs.  This must be done after
3678      we've built up any unwinders for exception handling, and done
3679      the FINALIZE_PIC work, if necessary.  */
3680
3681   rtl_in_current_obstack ();
3682
3683   insns = get_insns ();
3684
3685   /* Copy any shared structure that should not be shared.  */
3686
3687   unshare_all_rtl (insns);
3688
3689   init_EXPR_INSN_LIST_cache ();
3690
3691 #ifdef SETJMP_VIA_SAVE_AREA
3692   /* This must be performed before virutal register instantiation.  */
3693   if (current_function_calls_alloca)
3694     optimize_save_area_alloca (insns);
3695 #endif
3696
3697   /* Instantiate all virtual registers.  */
3698
3699   instantiate_virtual_regs (current_function_decl, get_insns ());
3700
3701   /* See if we have allocated stack slots that are not directly addressable.
3702      If so, scan all the insns and create explicit address computation
3703      for all references to such slots.  */
3704   /* fixup_stack_slots (); */
3705
3706   /* Find all the EH handlers.  */
3707   find_exception_handler_labels ();
3708
3709   /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3710      are initialized and to compute whether control can drop off the end
3711      of the function.  */
3712   TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3713   TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3714                                      JUMP_AFTER_REGSCAN));
3715
3716   /* Now is when we stop if -fsyntax-only and -Wreturn-type.  */
3717   if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3718     goto exit_rest_of_compilation;
3719
3720   /* Try to identify useless null pointer tests and delete them.  */
3721   if (flag_delete_null_pointer_checks)
3722     TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
3723
3724   /* Dump rtl code after jump, if we are doing that.  */
3725   if (jump_opt_dump)
3726     dump_rtl (".jump", decl, print_rtl, insns);
3727
3728   if (ggc_p)
3729     ggc_collect ();
3730
3731   /* Perform common subexpression elimination.
3732      Nonzero value from `cse_main' means that jumps were simplified
3733      and some code may now be unreachable, so do
3734      jump optimization again.  */
3735
3736   if (optimize > 0)
3737     {
3738       if (cse_dump)
3739         open_dump_file (".cse", decl_printable_name (decl, 2));
3740
3741       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3742
3743       if (flag_thread_jumps)
3744         TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3745
3746       TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3747                                          0, rtl_dump_file));
3748       /* If we are not running the second CSE pass, then we are no longer
3749          expecting CSE to be run.  */
3750       cse_not_expected = !flag_rerun_cse_after_loop;
3751
3752       if (tem || optimize > 1)
3753         TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3754                                            !JUMP_NOOP_MOVES,
3755                                            !JUMP_AFTER_REGSCAN));
3756  
3757       /* Run this after jump optmizations remove all the unreachable code
3758          so that unreachable code will not keep values live.  */
3759       TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3760
3761       /* Try to identify useless null pointer tests and delete them.  */
3762       if (flag_delete_null_pointer_checks)
3763         TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
3764
3765       /* Dump rtl code after cse, if we are doing that.  */
3766
3767       if (cse_dump)
3768         {
3769           close_dump_file (print_rtl, insns);
3770           if (graph_dump_format != no_graph)
3771             print_rtl_graph_with_bb (dump_base_name, ".cse", insns);
3772         }
3773     }
3774
3775   purge_addressof (insns);
3776   reg_scan (insns, max_reg_num (), 1);
3777
3778   if (addressof_dump)
3779     {
3780       dump_rtl (".addressof", decl, print_rtl, insns);
3781       if (graph_dump_format != no_graph)
3782         print_rtl_graph_with_bb (dump_base_name, ".addressof", insns);
3783     }
3784
3785   if (ggc_p)
3786     ggc_collect ();
3787
3788   /* Perform global cse.  */
3789
3790   if (optimize > 0 && flag_gcse)
3791     {
3792       if (gcse_dump)
3793         open_dump_file (".gcse", decl_printable_name (decl, 2));
3794
3795       TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file));
3796
3797       /* If gcse altered any jumps, rerun jump optimizations to clean
3798          things up.  */
3799       if (tem)
3800         {
3801           TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3802                                              !JUMP_NOOP_MOVES,
3803                                              !JUMP_AFTER_REGSCAN));
3804         }
3805
3806       if (gcse_dump)
3807         {
3808           close_dump_file (print_rtl, insns);
3809           if (graph_dump_format != no_graph)
3810             print_rtl_graph_with_bb (dump_base_name, ".gcse", insns);
3811         }
3812
3813       if (ggc_p)
3814         ggc_collect ();
3815     }
3816   /* Move constant computations out of loops.  */
3817
3818   if (optimize > 0)
3819     {
3820       if (loop_dump)
3821         open_dump_file (".loop", decl_printable_name (decl, 2));
3822         
3823       TIMEVAR
3824         (loop_time,
3825          {
3826            if (flag_rerun_loop_opt)
3827              {
3828                /* We only want to perform unrolling once.  */
3829                
3830                loop_optimize (insns, rtl_dump_file, 0, 0);
3831                
3832         
3833                /* The first call to loop_optimize makes some instructions
3834                   trivially dead.  We delete those instructions now in the
3835                   hope that doing so will make the heuristics in loop work
3836                   better and possibly speed up compilation.  */
3837                delete_trivially_dead_insns (insns, max_reg_num ());
3838
3839                /* The regscan pass is currently necessary as the alias
3840                   analysis code depends on this information.  */
3841                reg_scan (insns, max_reg_num (), 1);
3842              }
3843            loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
3844          });
3845
3846       /* Dump rtl code after loop opt, if we are doing that.  */
3847
3848       if (loop_dump)
3849         {
3850           close_dump_file (print_rtl, insns);
3851           if (graph_dump_format != no_graph)
3852             print_rtl_graph_with_bb (dump_base_name, ".loop", insns);
3853         }
3854
3855       if (ggc_p)
3856         ggc_collect ();
3857     }
3858
3859   if (optimize > 0)
3860     {
3861       if (cse2_dump)
3862         open_dump_file (".cse2", decl_printable_name (decl, 2));
3863
3864       if (flag_rerun_cse_after_loop)
3865         {
3866           /* Running another jump optimization pass before the second
3867              cse pass sometimes simplifies the RTL enough to allow
3868              the second CSE pass to do a better job.  Jump_optimize can change
3869              max_reg_num so we must rerun reg_scan afterwards.
3870              ??? Rework to not call reg_scan so often.  */
3871           TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3872           TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3873                                              !JUMP_NOOP_MOVES,
3874                                              JUMP_AFTER_REGSCAN));
3875           
3876           TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3877           TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3878                                               1, rtl_dump_file));
3879           if (tem)
3880             TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3881                                                !JUMP_NOOP_MOVES,
3882                                                !JUMP_AFTER_REGSCAN));
3883         }
3884
3885       if (flag_thread_jumps)
3886         {
3887           /* This pass of jump threading straightens out code
3888              that was kinked by loop optimization.  */
3889           TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3890           TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3891         }
3892
3893       /* Dump rtl code after cse, if we are doing that.  */
3894
3895       if (cse2_dump)
3896         {
3897           close_dump_file (print_rtl, insns);
3898           if (graph_dump_format != no_graph)
3899             print_rtl_graph_with_bb (dump_base_name, ".cse2", insns);
3900         }
3901
3902       if (ggc_p)
3903         ggc_collect ();
3904     }
3905
3906   if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3907     {
3908       if (branch_prob_dump)
3909         open_dump_file (".bp", decl_printable_name (decl, 2));
3910
3911       TIMEVAR
3912         (branch_prob_time,
3913          {
3914            branch_prob (insns, rtl_dump_file);
3915          });
3916
3917       if (branch_prob_dump)
3918         {
3919           close_dump_file (print_rtl, insns);
3920           if (graph_dump_format != no_graph)
3921             print_rtl_graph_with_bb (dump_base_name, ".bp", insns);
3922         }
3923
3924       if (ggc_p)
3925         ggc_collect ();
3926     }
3927
3928   /* We are no longer anticipating cse in this function, at least.  */
3929
3930   cse_not_expected = 1;
3931
3932   /* Now we choose between stupid (pcc-like) register allocation
3933      (if we got the -noreg switch and not -opt)
3934      and smart register allocation.  */
3935
3936   if (optimize > 0)             /* Stupid allocation probably won't work */
3937     obey_regdecls = 0;          /* if optimizations being done.  */
3938
3939   regclass_init ();
3940
3941   /* Print function header into flow dump now
3942      because doing the flow analysis makes some of the dump.  */
3943
3944   if (flow_dump)
3945     open_dump_file (".flow", decl_printable_name (decl, 2));
3946   
3947   if (obey_regdecls)
3948     {
3949       TIMEVAR (flow_time,
3950                {
3951                  regclass (insns, max_reg_num ());
3952                  stupid_life_analysis (insns, max_reg_num (),
3953                                        rtl_dump_file);
3954                });
3955     }
3956   else
3957     {
3958       /* Do control and data flow analysis,
3959          and write some of the results to dump file.  */
3960
3961       TIMEVAR
3962         (flow_time,
3963          {
3964            find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
3965            life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
3966          });
3967
3968       if (warn_uninitialized)
3969         {
3970           uninitialized_vars_warning (DECL_INITIAL (decl));
3971           setjmp_args_warning ();
3972         }
3973     }
3974
3975   /* Dump rtl after flow analysis.  */
3976
3977   if (flow_dump)
3978     {
3979       close_dump_file (print_rtl_with_bb, insns);
3980       if (graph_dump_format != no_graph)
3981         print_rtl_graph_with_bb (dump_base_name, ".flow", insns);
3982     }
3983
3984   if (ggc_p)
3985     ggc_collect ();
3986
3987   /* The first life analysis pass has finished.  From now on we can not
3988      generate any new pseudos.  */
3989   no_new_pseudos = 1;
3990
3991   /* If -opt, try combining insns through substitution.  */
3992
3993   if (optimize > 0)
3994     {
3995       TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3996
3997       /* Dump rtl code after insn combination.  */
3998
3999       if (combine_dump)
4000         {
4001           dump_rtl (".combine", decl, print_rtl_with_bb, insns);
4002           if (graph_dump_format != no_graph)
4003             print_rtl_graph_with_bb (dump_base_name, ".combine", insns);
4004         }
4005
4006       if (ggc_p)
4007         ggc_collect ();
4008     }
4009
4010   /* Register allocation pre-pass, to reduce number of moves
4011      necessary for two-address machines.  */
4012   if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
4013     {
4014       if (regmove_dump)
4015         open_dump_file (".regmove", decl_printable_name (decl, 2));
4016
4017       TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
4018                                                rtl_dump_file));
4019
4020       if (regmove_dump)
4021         {
4022           close_dump_file (print_rtl_with_bb, insns);
4023           if (graph_dump_format != no_graph)
4024             print_rtl_graph_with_bb (dump_base_name, ".regmove", insns);
4025         }
4026
4027       if (ggc_p)
4028         ggc_collect ();
4029     }
4030
4031   /* Print function header into sched dump now
4032      because doing the sched analysis makes some of the dump.  */
4033
4034   if (optimize > 0 && flag_schedule_insns)
4035     {
4036       if (sched_dump)
4037         open_dump_file (".sched", decl_printable_name (decl, 2));
4038
4039       /* Do control and data sched analysis,
4040          and write some of the results to dump file.  */
4041
4042       TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
4043
4044       /* Dump rtl after instruction scheduling.  */
4045
4046       if (sched_dump)
4047         {
4048           close_dump_file (print_rtl_with_bb, insns);
4049           if (graph_dump_format != no_graph)
4050             print_rtl_graph_with_bb (dump_base_name, ".sched", insns);
4051         }
4052
4053       if (ggc_p)
4054         ggc_collect ();
4055     }
4056
4057   /* Determine if the current function is a leaf before running reload
4058      since this can impact optimizations done by the prologue and
4059      epilogue thus changing register elimination offsets.  */
4060   current_function_is_leaf = leaf_function_p ();
4061
4062   /* Unless we did stupid register allocation,
4063      allocate pseudo-regs that are used only within 1 basic block. 
4064
4065      RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
4066      jump optimizer after register allocation and reloading are finished.  */
4067
4068   if (!obey_regdecls)
4069     TIMEVAR (local_alloc_time,
4070              {
4071                recompute_reg_usage (insns, ! optimize_size);
4072                regclass (insns, max_reg_num ());
4073                rebuild_label_notes_after_reload = local_alloc ();
4074              });
4075   else
4076     rebuild_label_notes_after_reload = 0;
4077
4078   /* Dump rtl code after allocating regs within basic blocks.  */
4079
4080   if (local_reg_dump)
4081     {
4082       open_dump_file (".lreg", decl_printable_name (decl, 2));
4083
4084       TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
4085       TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
4086
4087       close_dump_file (print_rtl_with_bb, insns);
4088       if (graph_dump_format != no_graph)
4089         print_rtl_graph_with_bb (dump_base_name, ".lreg", insns);
4090     }
4091
4092   if (ggc_p)
4093     ggc_collect ();
4094
4095   if (global_reg_dump)
4096     open_dump_file (".greg", decl_printable_name (decl, 2));
4097
4098   /* Unless we did stupid register allocation,
4099      allocate remaining pseudo-regs, then do the reload pass
4100      fixing up any insns that are invalid.  */
4101
4102   TIMEVAR (global_alloc_time,
4103            {
4104              if (!obey_regdecls)
4105                failure = global_alloc (rtl_dump_file);
4106              else
4107                failure = reload (insns, 0, rtl_dump_file);
4108            });
4109
4110
4111   if (failure)
4112     goto exit_rest_of_compilation;
4113
4114   if (ggc_p)
4115     ggc_collect ();
4116
4117   /* Do a very simple CSE pass over just the hard registers.  */
4118   if (optimize > 0)
4119     reload_cse_regs (insns);
4120
4121   /* Register allocation and reloading may have turned an indirect jump into
4122      a direct jump.  If so, we must rebuild the JUMP_LABEL fields of
4123      jumping instructions.  */
4124   if (rebuild_label_notes_after_reload)
4125     TIMEVAR (jump_time, rebuild_jump_labels (insns));
4126
4127   /* If optimizing and we are performing instruction scheduling after
4128      reload, then go ahead and split insns now since we are about to
4129      recompute flow information anyway.
4130
4131      reload_cse_regs may expose more splitting opportunities, expecially
4132      for double-word operations.  */
4133   if (optimize > 0 && flag_schedule_insns_after_reload)
4134     {
4135       rtx insn;
4136
4137       for (insn = insns; insn; insn = NEXT_INSN (insn))
4138         {
4139           rtx last;
4140
4141           if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
4142             continue;
4143
4144           last = try_split (PATTERN (insn), insn, 1);
4145
4146           if (last != insn)
4147             {
4148               PUT_CODE (insn, NOTE);
4149               NOTE_SOURCE_FILE (insn) = 0;
4150               NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
4151             }
4152         }
4153     }
4154
4155   if (global_reg_dump)
4156     {
4157       TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
4158       close_dump_file (print_rtl_with_bb, insns);
4159       if (graph_dump_format != no_graph)
4160         print_rtl_graph_with_bb (dump_base_name, ".greg", insns);
4161     }
4162
4163   /* Re-create the death notes which were deleted during reload.  */
4164   if (flow2_dump)
4165     open_dump_file (".flow2", decl_printable_name (decl, 2));
4166   
4167   if (optimize)
4168     {
4169       TIMEVAR
4170         (flow2_time,
4171          {
4172            find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4173            life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4174          });
4175
4176       if (ggc_p)
4177         ggc_collect ();
4178     }
4179
4180   flow2_completed = 1;
4181
4182   /* On some machines, the prologue and epilogue code, or parts thereof,
4183      can be represented as RTL.  Doing so lets us schedule insns between
4184      it and the rest of the code and also allows delayed branch
4185      scheduling to operate in the epilogue.  */
4186
4187   thread_prologue_and_epilogue_insns (insns);
4188
4189   if (flow2_dump)
4190     {
4191       close_dump_file (print_rtl_with_bb, insns);
4192       if (graph_dump_format != no_graph)
4193         print_rtl_graph_with_bb (dump_base_name, ".flow2", insns);
4194     }
4195
4196 #ifdef HAVE_peephole2
4197   if (optimize > 0 && flag_peephole2)
4198     {
4199       if (peephole2_dump)
4200         open_dump_file (".peephole2", decl_printable_name (decl, 2));
4201
4202       peephole2_optimize (rtl_dump_file);
4203
4204       if (peephole2_dump)
4205         {
4206           close_dump_file (print_rtl_with_bb, insns);
4207           if (graph_dump_format != no_graph)
4208             print_rtl_graph_with_bb (dump_base_name, ".peephole2", insns);
4209         }
4210     }
4211 #endif
4212
4213   if (optimize > 0 && flag_schedule_insns_after_reload)
4214     {
4215       if (sched2_dump)
4216         open_dump_file (".sched2", decl_printable_name (decl, 2));
4217
4218       /* Do control and data sched analysis again,
4219          and write some more of the results to dump file.  */
4220
4221       TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
4222
4223       /* Dump rtl after post-reorder instruction scheduling.  */
4224
4225       if (sched2_dump)
4226         {
4227           close_dump_file (print_rtl_with_bb, insns);
4228           if (graph_dump_format != no_graph)
4229             print_rtl_graph_with_bb (dump_base_name, ".sched2", insns);
4230         }
4231
4232       if (ggc_p)
4233         ggc_collect ();
4234     }
4235
4236 #ifdef LEAF_REGISTERS
4237   current_function_uses_only_leaf_regs
4238     = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
4239 #endif
4240
4241   /* One more attempt to remove jumps to .+1
4242      left by dead-store-elimination.
4243      Also do cross-jumping this time
4244      and delete no-op move insns.  */
4245
4246   if (optimize > 0)
4247     {
4248       TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
4249                                          JUMP_NOOP_MOVES,
4250                                          !JUMP_AFTER_REGSCAN));
4251
4252       /* Dump rtl code after jump, if we are doing that.  */
4253
4254       if (jump2_opt_dump)
4255         {
4256           dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
4257           if (graph_dump_format != no_graph)
4258             print_rtl_graph_with_bb (dump_base_name, ".jump2", insns);
4259         }
4260     }
4261
4262   /* If a machine dependent reorganization is needed, call it.  */
4263 #ifdef MACHINE_DEPENDENT_REORG
4264   if (mach_dep_reorg_dump)
4265     open_dump_file (".mach", decl_printable_name (decl, 2));
4266
4267    MACHINE_DEPENDENT_REORG (insns);
4268
4269    if (mach_dep_reorg_dump)
4270      {
4271        close_dump_file (print_rtl_with_bb, insns);
4272        if (graph_dump_format != no_graph)
4273          print_rtl_graph_with_bb (dump_base_name, ".mach", insns);
4274      }
4275
4276    if (ggc_p)
4277      ggc_collect ();
4278 #endif
4279
4280   /* If a scheduling pass for delayed branches is to be done,
4281      call the scheduling code.  */
4282
4283 #ifdef DELAY_SLOTS
4284   if (optimize > 0 && flag_delayed_branch)
4285     {
4286       if (dbr_sched_dump)
4287         open_dump_file (".dbr", decl_printable_name (decl, 2));
4288
4289       TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
4290
4291       if (dbr_sched_dump)
4292         {
4293           close_dump_file (print_rtl_with_bb, insns);
4294           if (graph_dump_format != no_graph)
4295             print_rtl_graph_with_bb (dump_base_name, ".dbr", insns);
4296         }
4297     }
4298
4299    if (ggc_p)
4300      ggc_collect ();
4301 #endif
4302
4303   /* Shorten branches.  */
4304   TIMEVAR (shorten_branch_time,
4305            {
4306              shorten_branches (get_insns ());
4307            });
4308
4309 #ifdef STACK_REGS
4310   if (stack_reg_dump)
4311     open_dump_file (".stack", decl_printable_name (decl, 2));
4312
4313   TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
4314
4315   if (stack_reg_dump)
4316     {
4317       dump_rtl (".stack", decl, print_rtl_with_bb, insns);
4318       if (graph_dump_format != no_graph)
4319         print_rtl_graph_with_bb (dump_base_name, ".stack", insns);
4320     }
4321
4322    if (ggc_p)
4323      ggc_collect ();
4324 #endif
4325
4326   /* Now turn the rtl into assembler code.  */
4327
4328   TIMEVAR (final_time,
4329            {
4330              rtx x;
4331              char *fnname;
4332
4333              /* Get the function's name, as described by its RTL.
4334                 This may be different from the DECL_NAME name used
4335                 in the source file.  */
4336
4337              x = DECL_RTL (decl);
4338              if (GET_CODE (x) != MEM)
4339                abort ();
4340              x = XEXP (x, 0);
4341              if (GET_CODE (x) != SYMBOL_REF)
4342                abort ();
4343              fnname = XSTR (x, 0);
4344
4345              assemble_start_function (decl, fnname);
4346              final_start_function (insns, asm_out_file, optimize);
4347              final (insns, asm_out_file, optimize, 0);
4348              final_end_function (insns, asm_out_file, optimize);
4349              assemble_end_function (decl, fnname);
4350              if (! quiet_flag)
4351                fflush (asm_out_file);
4352
4353              /* Release all memory allocated by flow.  */
4354              free_basic_block_vars (0);
4355
4356              /* Release all memory held by regsets now */
4357              regset_release_memory ();
4358            });
4359
4360    if (ggc_p)
4361      ggc_collect ();
4362
4363   /* Write DBX symbols if requested */
4364
4365   /* Note that for those inline functions where we don't initially
4366      know for certain that we will be generating an out-of-line copy,
4367      the first invocation of this routine (rest_of_compilation) will
4368      skip over this code by doing a `goto exit_rest_of_compilation;'.
4369      Later on, finish_compilation will call rest_of_compilation again
4370      for those inline functions that need to have out-of-line copies
4371      generated.  During that call, we *will* be routed past here.  */
4372
4373 #ifdef DBX_DEBUGGING_INFO
4374   if (write_symbols == DBX_DEBUG)
4375     TIMEVAR (symout_time, dbxout_function (decl));
4376 #endif
4377
4378 #ifdef DWARF_DEBUGGING_INFO
4379   if (write_symbols == DWARF_DEBUG)
4380     TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
4381 #endif
4382
4383 #ifdef DWARF2_DEBUGGING_INFO
4384   if (write_symbols == DWARF2_DEBUG)
4385     TIMEVAR (symout_time, dwarf2out_decl (decl));
4386 #endif
4387
4388  exit_rest_of_compilation:
4389
4390   free_bb_mem ();
4391
4392   /* In case the function was not output,
4393      don't leave any temporary anonymous types
4394      queued up for sdb output.  */
4395 #ifdef SDB_DEBUGGING_INFO
4396   if (write_symbols == SDB_DEBUG)
4397     sdbout_types (NULL_TREE);
4398 #endif
4399
4400   /* Put back the tree of subblocks and list of arguments
4401      from before we copied them.
4402      Code generation and the output of debugging info may have modified
4403      the copy, but the original is unchanged.  */
4404
4405   if (saved_block_tree != 0)
4406     {
4407       DECL_INITIAL (decl) = saved_block_tree;
4408       DECL_ARGUMENTS (decl) = saved_arguments;
4409       DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
4410     }
4411
4412   reload_completed = 0;
4413   flow2_completed = 0;
4414   no_new_pseudos = 0;
4415
4416   TIMEVAR (final_time,
4417            {
4418               /* Clear out the insn_length contents now that they are no
4419                  longer valid.  */
4420               init_insn_lengths ();
4421
4422               /* Clear out the real_constant_chain before some of the rtx's
4423                  it runs through become garbage.  */
4424               clear_const_double_mem ();
4425
4426               /* Cancel the effect of rtl_in_current_obstack.  */
4427               resume_temporary_allocation ();
4428
4429               /* Show no temporary slots allocated.  */
4430               init_temp_slots ();
4431
4432               free_basic_block_vars (0);
4433            });
4434
4435   /* Make sure volatile mem refs aren't considered valid operands for
4436      arithmetic insns.  We must call this here if this is a nested inline
4437      function, since the above code leaves us in the init_recog state
4438      (from final.c), and the function context push/pop code does not
4439      save/restore volatile_ok.
4440
4441      ??? Maybe it isn't necessary for expand_start_function to call this
4442      anymore if we do it here?  */
4443
4444   init_recog_no_volatile ();
4445
4446   /* We're done with this function.  Free up memory if we can.  */
4447   free_after_parsing (current_function);
4448   if (! DECL_DEFER_OUTPUT (decl))
4449     free_after_compilation (current_function);
4450   current_function = 0;
4451
4452   if (ggc_p)
4453     ggc_collect ();
4454
4455   /* The parsing time is all the time spent in yyparse
4456      *except* what is spent in this function.  */
4457
4458   parse_time -= get_run_time () - start_time;
4459 }
4460 \f
4461 static void
4462 display_help ()
4463 {
4464   int    undoc;
4465   unsigned long  i;
4466   const char * lang;
4467   
4468 #ifndef USE_CPPLIB  
4469   printf ("Usage: %s input [switches]\n", progname);
4470   printf ("Switches:\n");
4471 #endif
4472   printf ("  -ffixed-<register>      Mark <register> as being unavailable to the compiler\n");
4473   printf ("  -fcall-used-<register>  Mark <register> as being corrupted by function calls\n");
4474   printf ("  -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4475   printf ("  -finline-limit=<number> Limits the size of inlined functions to <number>\n");
4476
4477   for (i = NUM_ELEM (f_options); i--;)
4478     {
4479       const char * description = f_options[i].description;
4480       
4481       if (description != NULL && * description != 0)
4482         printf ("  -f%-21s %s\n",
4483                 f_options[i].string, description);
4484     }
4485   
4486   printf ("  -O[number]              Set optimisation level to [number]\n");
4487   printf ("  -Os                     Optimise for space rather than speed\n");
4488   printf ("  -pedantic               Issue warnings needed by strict compliance to ANSI C\n");
4489   printf ("  -pedantic-errors        Like -pedantic except that errors are produced\n");
4490   printf ("  -w                      Suppress warnings\n");
4491   printf ("  -W                      Enable extra warnings\n");
4492   
4493   for (i = NUM_ELEM (W_options); i--;)
4494     {
4495       const char * description = W_options[i].description;
4496       
4497       if (description != NULL && * description != 0)
4498         printf ("  -W%-21s %s\n",
4499                 W_options[i].string, description);
4500     }
4501   
4502   printf ("  -Wid-clash-<num>        Warn if 2 identifiers have the same first <num> chars\n");
4503   printf ("  -Wlarger-than-<number>  Warn if an object is larger than <number> bytes\n");
4504   printf ("  -p                      Enable function profiling\n");
4505 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4506   printf ("  -a                      Enable block profiling \n");
4507 #endif  
4508 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4509   printf ("  -ax                     Enable jump profiling \n");
4510 #endif  
4511   printf ("  -o <file>               Place output into <file> \n");
4512   printf ("  -G <number>             Put global and static data smaller than <number>\n");
4513   printf ("                           bytes into a special section (on some targets)\n");
4514   
4515   for (i = NUM_ELEM (debug_args); i--;)
4516     {
4517       if (debug_args[i].description != NULL)
4518         printf ("  -g%-21s %s\n", debug_args[i].arg, debug_args[i].description);
4519     }
4520   
4521   printf ("  -aux-info <file>        Emit declaration info into <file>.X\n");
4522   printf ("  -quiet                  Do not display functions compiled or elapsed time\n");
4523   printf ("  -version                Display the compiler's version\n");
4524   printf ("  -d[letters]             Enable dumps from specific passes of the compiler\n");
4525   printf ("  -dumpbase <file>        Base name to be used for dumps from specific passes\n");
4526 #if defined INSN_SCHEDULING
4527   printf ("  -sched-verbose=<number> Set the verbosity level of the scheduler\n");
4528 #endif
4529   printf ("  --help                  Display this information\n");
4530
4531   undoc = 0;
4532   lang  = "language";
4533   
4534   /* Display descriptions of language specific options.
4535      If there is no description, note that there is an undocumented option.
4536      If the description is empty, do not display anything.  (This allows
4537      options to be deliberately undocumented, for whatever reason).
4538      If the option string is missing, then this is a marker, indicating
4539      that the description string is in fact the name of a language, whose
4540      language specific options are to follow.  */
4541   
4542   if (NUM_ELEM (documented_lang_options) > 1)
4543     {
4544       printf ("\nLanguage specific options:\n");
4545
4546       for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
4547         {
4548           const char * description = documented_lang_options[i].description;
4549           const char * option      = documented_lang_options[i].option;
4550
4551           if (description == NULL)
4552             {
4553               undoc = 1;
4554
4555               if (extra_warnings)
4556                 printf ("  %-23.23s [undocumented]\n", option);
4557             }
4558           else if (* description == 0)
4559             continue;
4560           else if (option == NULL)
4561             {
4562               if (undoc)
4563                 printf
4564                   ("\nThere are undocumented %s specific options as well.\n",
4565                         lang);
4566               undoc = 0;
4567               
4568               printf ("\n Options for %s:\n", description);
4569
4570               lang = description;
4571             }
4572           else
4573             printf ("  %-23.23s %s\n", option, description);
4574         }
4575     }
4576
4577   if (undoc)
4578     printf ("\nThere are undocumented %s specific options as well.\n", lang);
4579
4580   if (NUM_ELEM (target_switches) > 1
4581 #ifdef TARGET_OPTIONS
4582       || NUM_ELEM (target_options) > 1
4583 #endif
4584       )
4585     {
4586       int doc = 0;
4587       
4588       undoc = 0;
4589   
4590       printf ("\nTarget specific options:\n");
4591
4592       for (i = NUM_ELEM (target_switches); i--;)
4593         {
4594           const char * option      = target_switches[i].name;
4595           const char * description = target_switches[i].description;
4596
4597           if (option == NULL || * option == 0)
4598             continue;
4599           else if (description == NULL)
4600             {
4601               undoc = 1;
4602               
4603               if (extra_warnings)
4604                 printf ("  -m%-21.21s [undocumented]\n", option);
4605             }
4606           else if (* description != 0)
4607             doc += printf ("  -m%-21.21s %s\n", option, description);
4608         }
4609       
4610 #ifdef TARGET_OPTIONS      
4611       for (i = NUM_ELEM (target_options); i--;)
4612         {
4613           const char * option      = target_options[i].prefix;
4614           const char * description = target_options[i].description;
4615
4616           if (option == NULL || * option == 0)
4617             continue;
4618           else if (description == NULL)
4619             {
4620               undoc = 1;
4621               
4622               if (extra_warnings)
4623                 printf ("  -m%-21.21s [undocumented]\n", option);
4624             }
4625           else if (* description != 0)
4626             doc += printf ("  -m%-21.21s %s\n", option, description);
4627         }
4628 #endif
4629       if (undoc)
4630         {
4631           if (doc)
4632             printf ("\nThere are undocumented target specific options as well.\n");
4633           else
4634             printf ("  They exist, but they are not documented.\n");
4635         }
4636     }
4637 }
4638 \f
4639 /* Parse a -d... comand line switch.  */
4640
4641 static void
4642 decode_d_option (arg)
4643      const char * arg;
4644 {
4645   while (* arg)
4646     switch (* arg ++)
4647       {
4648       case 'a':
4649         branch_prob_dump = 1;
4650         combine_dump = 1;
4651 #ifdef DELAY_SLOTS
4652         dbr_sched_dump = 1;
4653 #endif
4654         flow_dump = 1;
4655         flow2_dump = 1;
4656         global_reg_dump = 1;
4657         jump_opt_dump = 1;
4658         addressof_dump = 1;
4659         jump2_opt_dump = 1;
4660         local_reg_dump = 1;
4661         loop_dump = 1;
4662         regmove_dump = 1;
4663         rtl_dump = 1;
4664         cse_dump = 1;
4665         cse2_dump = 1;
4666         gcse_dump = 1;
4667         sched_dump = 1;
4668         sched2_dump = 1;
4669 #ifdef STACK_REGS
4670         stack_reg_dump = 1;
4671 #endif
4672 #ifdef MACHINE_DEPENDENT_REORG
4673         mach_dep_reorg_dump = 1;
4674 #endif
4675         peephole2_dump = 1;
4676         break;
4677       case 'A':
4678         flag_debug_asm = 1;
4679         break;
4680       case 'b':
4681         branch_prob_dump = 1;
4682         break;
4683       case 'c':
4684         combine_dump = 1;
4685         break;
4686 #ifdef DELAY_SLOTS
4687       case 'd':
4688         dbr_sched_dump = 1;
4689         break;
4690 #endif
4691       case 'f':
4692         flow_dump = 1;
4693         break;
4694       case 'F':
4695         addressof_dump = 1;
4696         break;
4697       case 'g':
4698         global_reg_dump = 1;
4699         break;
4700       case 'G':
4701         gcse_dump = 1;
4702         break;
4703       case 'j':
4704         jump_opt_dump = 1;
4705         break;
4706       case 'J':
4707         jump2_opt_dump = 1;
4708         break;
4709 #ifdef STACK_REGS                   
4710       case 'k':
4711         stack_reg_dump = 1;
4712         break;
4713 #endif
4714       case 'l':
4715         local_reg_dump = 1;
4716         break;
4717       case 'L':
4718         loop_dump = 1;
4719         break;
4720       case 'm':
4721         flag_print_mem = 1;
4722         break;
4723 #ifdef MACHINE_DEPENDENT_REORG
4724       case 'M':
4725         mach_dep_reorg_dump = 1;
4726         break;
4727 #endif
4728       case 'p':
4729         flag_print_asm_name = 1;
4730         break;
4731       case 'r':
4732         rtl_dump = 1;
4733         break;
4734       case 'R':
4735         sched2_dump = 1;
4736         break;
4737       case 's':
4738         cse_dump = 1;
4739         break;
4740       case 'S':
4741         sched_dump = 1;
4742         break;
4743       case 't':
4744         cse2_dump = 1;
4745         break;
4746       case 'N':
4747         regmove_dump = 1;
4748         break;
4749       case 'v':
4750         graph_dump_format = vcg;
4751         break;
4752       case 'w':
4753         flow2_dump = 1;
4754         break;
4755       case 'x':
4756         rtl_dump_and_exit = 1;
4757         break;
4758       case 'y':
4759         set_yydebug (1);
4760         break;
4761       case 'z':
4762         peephole2_dump = 1;
4763         break;
4764       case 'D': /* These are handled by the preprocessor.  */
4765       case 'I':
4766         break;
4767       default:
4768         warning ("unrecognised gcc debugging option: %c", arg[-1]);
4769         break;
4770       }
4771 }
4772
4773 /* Parse a -f... comand line switch.  ARG is the value after the -f.
4774    It is safe to access 'ARG - 2' to generate the full switch name.
4775    Return the number of strings consumed.  */
4776
4777 static int
4778 decode_f_option (arg)
4779      const char * arg;
4780 {
4781   int j;
4782
4783   /* Search for the option in the table of binary f options.  */
4784   for (j = sizeof (f_options) / sizeof (f_options[0]); j--;)
4785     {
4786       if (!strcmp (arg, f_options[j].string))
4787         {
4788           *f_options[j].variable = f_options[j].on_value;
4789           return 1;
4790         }
4791     
4792       if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4793           && ! strcmp (arg + 3, f_options[j].string))
4794         {
4795           *f_options[j].variable = ! f_options[j].on_value;
4796           return 1;
4797         }
4798     }
4799
4800   if (!strncmp (arg, "inline-limit-", 13)
4801       || !strncmp (arg, "inline-limit=", 13))
4802     inline_max_insns =
4803       read_integral_parameter (arg + 13, arg - 2, inline_max_insns);
4804 #ifdef INSN_SCHEDULING
4805   else if (!strncmp (arg, "sched-verbose=", 14))
4806     fix_sched_param ("verbose", (char *)(arg + 14));
4807 #endif
4808   else if (!strncmp (arg, "fixed-", 6))
4809     fix_register ((char *)(arg + 6), 1, 1);
4810   else if (!strncmp (arg, "call-used-", 10))
4811     fix_register ((char *)(arg + 10), 0, 1);
4812   else if (!strncmp (arg, "call-saved-", 11))
4813     fix_register ((char *)(arg + 11), 0, 0);
4814   else if (!strncmp (arg, "align-loops=", 12))
4815     align_loops = read_integral_parameter (arg + 12, arg - 2, align_loops);
4816   else if (!strncmp (arg, "align-functions=", 16))
4817     align_functions =
4818       read_integral_parameter (arg + 16, arg - 2, align_functions);
4819   else if (!strncmp (arg, "align-jumps=", 12))
4820     align_jumps = read_integral_parameter (arg + 12, arg - 2, align_jumps);
4821   else if (!strncmp (arg, "align-labels=", 13))
4822     align_labels = read_integral_parameter (arg + 13, arg - 2, align_labels);
4823   else if (!strcmp (arg, "preprocessed"))
4824     /* Recognise this switch but do nothing.  This prevents warnings
4825        about an unrecognised switch if cpplib has not been linked in.  */
4826     ;
4827   else
4828     return 0;
4829
4830   return 1;
4831 }
4832
4833 /* Parse a -W... comand line switch.  ARG is the value after the -W.
4834    It is safe to access 'ARG - 2' to generate the full switch name.
4835    Return the number of strings consumed.  */
4836 static int
4837 decode_W_option (arg)
4838      const char * arg;
4839 {
4840   int j;
4841   
4842   /* Search for the option in the table of binary W options.  */
4843
4844   for (j = sizeof (W_options) / sizeof (W_options[0]); j--;)
4845     {
4846       if (!strcmp (arg, W_options[j].string))
4847         {
4848           *W_options[j].variable = W_options[j].on_value;
4849           return 1;
4850         }
4851
4852       if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4853           && ! strcmp (arg + 3, W_options[j].string))
4854         {
4855           *W_options[j].variable = ! W_options[j].on_value;
4856           return 1;
4857         }
4858     }
4859
4860   if (!strncmp (arg, "id-clash-", 9))
4861     {
4862       const int id_clash_val = read_integral_parameter (arg + 9, arg - 2, -1);
4863       
4864       if (id_clash_val != -1)
4865         {
4866           id_clash_len = id_clash_val;
4867           warn_id_clash = 1;
4868         }
4869     }
4870   else if (!strncmp (arg, "larger-than-", 12))
4871     {
4872       const int larger_than_val =
4873         read_integral_parameter (arg + 12, arg - 2, -1);
4874       if (larger_than_val != -1)
4875         {
4876           larger_than_size = larger_than_val;
4877           warn_larger_than = 1;
4878         }
4879     }
4880   else
4881     return 0;
4882
4883   return 1;
4884 }
4885
4886 /* Parse a -g... comand line switch.  ARG is the value after the -g.
4887    It is safe to access 'ARG - 2' to generate the full switch name.
4888    Return the number of strings consumed.  */
4889 static int
4890 decode_g_option (arg)
4891      const char * arg;
4892 {
4893   unsigned level;
4894   /* A lot of code assumes write_symbols == NO_DEBUG if the
4895      debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4896      of what debugging type has been selected).  This records the
4897      selected type.  It is an error to specify more than one
4898      debugging type.  */
4899   static enum debug_info_type selected_debug_type = NO_DEBUG;
4900   /* Non-zero if debugging format has been explicitly set.
4901      -g and -ggdb don't explicitly set the debugging format so
4902      -gdwarf -g3 is equivalent to -gdwarf3.  */
4903   static int type_explicitly_set_p = 0;
4904   /* Indexed by enum debug_info_type.  */
4905   static const char * debug_type_names[] =
4906   {
4907     "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4908   };
4909   
4910   /* The maximum admissible debug level value.  */
4911   static const unsigned max_debug_level = 3;
4912   
4913   /* Look up ARG in the table.  */
4914   for (da = debug_args; da->arg; da++)
4915     {
4916       const int da_len = strlen (da->arg);
4917
4918       if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4919         {
4920           enum debug_info_type type = da->debug_type;
4921           const char * p = arg + da_len;
4922           
4923           if (*p && (*p < '0' || *p > '9'))
4924             continue;
4925           
4926           /* A debug flag without a level defaults to level 2.
4927              Note we do not want to call read_integral_parameter
4928              for that case since it will call atoi which 
4929              will return zero.
4930              
4931              ??? We may want to generalize the interface to 
4932              read_integral_parameter to better handle this case
4933              if this case shows up often.  */
4934           if (*p)
4935             level = read_integral_parameter (p, 0, max_debug_level + 1);
4936           else
4937             level = 2;
4938           
4939           if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4940             {
4941               error ("use -gdwarf -g%d for DWARF v1, level %d",
4942                      level, level);
4943               if (level == 2)
4944                 error ("use -gdwarf-2   for DWARF v2");
4945             }
4946           
4947           if (level > max_debug_level)
4948             {
4949               warning ("\
4950 ignoring option `%s' due to invalid debug level specification",
4951                        arg - 2);
4952               level = debug_info_level;
4953             }
4954
4955           if (type == NO_DEBUG)
4956             {
4957               type = PREFERRED_DEBUGGING_TYPE;
4958               
4959               if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4960                 {
4961 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4962                   type = DWARF2_DEBUG;
4963 #else
4964 #ifdef DBX_DEBUGGING_INFO
4965                   type = DBX_DEBUG;
4966 #endif
4967 #endif
4968                 }
4969             }
4970           
4971           if (type == NO_DEBUG)
4972             warning ("`%s' not supported by this configuration of GCC",
4973                      arg - 2);
4974
4975           /* Does it conflict with an already selected type?  */
4976           if (type_explicitly_set_p
4977               /* -g/-ggdb don't conflict with anything */
4978               && da->debug_type != NO_DEBUG
4979               && type != selected_debug_type)
4980             warning ("`%s' ignored, conflicts with `-g%s'",
4981                      arg - 2, debug_type_names[(int) selected_debug_type]);
4982           else
4983             {
4984               /* If the format has already been set, -g/-ggdb
4985                  only change the debug level.  */
4986               if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4987                 ; /* don't change debugging type */
4988               else
4989                 {
4990                   selected_debug_type = type;
4991                   type_explicitly_set_p = da->debug_type != NO_DEBUG;
4992                 }
4993               
4994               write_symbols = (level == 0
4995                                ? NO_DEBUG
4996                                : selected_debug_type);
4997               use_gnu_debug_info_extensions = da->use_extensions_p;
4998               debug_info_level = (enum debug_info_level) level;
4999             }
5000           
5001           break;
5002         }
5003     }
5004   
5005   if (! da->arg)
5006     warning ("`%s' not supported by this configuration of GCC", arg - 2);
5007
5008   return 1;
5009 }
5010
5011 /* Decode the first argument in the argv as a language-independent option.
5012    Return the number of strings consumed.  'strings_processed' is the
5013    number of strings that have already been decoded in a language
5014    specific fashion before this function was invoked.  */
5015    
5016 static unsigned
5017 independent_decode_option (argc, argv, strings_processed)
5018      int argc;
5019      char ** argv;
5020      unsigned strings_processed ATTRIBUTE_UNUSED;
5021 {
5022   char * arg = argv[0];
5023   
5024   if (arg[0] != '-' || arg[1] == 0)
5025     {
5026       if (arg[0] == '+')
5027         return 0;
5028       
5029       filename = arg;
5030
5031       return 1;
5032     }
5033
5034   arg ++;
5035   
5036   if (!strcmp (arg, "-help"))
5037     {
5038       display_help ();
5039       exit (0);
5040     }
5041
5042   if (* arg == 'Y')
5043     arg ++;
5044   
5045   switch (* arg)
5046     {
5047     default:
5048       return 0;
5049       
5050     case 'O':
5051       /* Already been treated in main (). Do nothing.  */
5052       break;
5053           
5054     case 'm':
5055       set_target_switch (arg + 1);
5056       break;
5057
5058     case 'f':
5059       return decode_f_option (arg + 1);
5060             
5061     case 'g':
5062       return decode_g_option (arg + 1);
5063
5064     case 'd':
5065       if (!strcmp (arg, "dumpbase"))
5066         {
5067           if (argc == 1)
5068             return 0;
5069           
5070           dump_base_name = argv[1];
5071           return 2;
5072         }
5073       else
5074         decode_d_option (arg + 1);
5075       break;
5076
5077     case 'p':
5078       if (!strcmp (arg, "pedantic"))
5079         pedantic = 1;
5080       else if (!strcmp (arg, "pedantic-errors"))
5081         flag_pedantic_errors = pedantic = 1;
5082       else if (arg[1] == 0)
5083         profile_flag = 1;
5084       else
5085         return 0;
5086       break;
5087
5088     case 'q':
5089       if (!strcmp (arg, "quiet"))
5090         quiet_flag = 1;
5091       else
5092         return 0;
5093       break;
5094
5095     case 'v':
5096       if (!strcmp (arg, "version"))
5097         version_flag = 1;
5098       else
5099         return 0;
5100       break;
5101
5102     case 'w':
5103       if (arg[1] == 0)
5104         inhibit_warnings = 1;
5105       else
5106         return 0;
5107       break;
5108
5109     case 'W':
5110       if (arg[1] == 0)
5111         {
5112           extra_warnings = 1;
5113           /* We save the value of warn_uninitialized, since if they put
5114              -Wuninitialized on the command line, we need to generate a
5115              warning about not using it without also specifying -O.  */
5116           if (warn_uninitialized != 1)
5117             warn_uninitialized = 2;
5118         }
5119       else
5120         return decode_W_option (arg + 1);
5121       break;
5122           
5123     case 'a':
5124       if (arg[1] == 0)
5125         {
5126 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5127           warning ("`-a' option (basic block profile) not supported");
5128 #else
5129           profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
5130 #endif
5131         }
5132       else if (!strcmp (arg, "ax"))
5133         {
5134 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5135           warning ("`-ax' option (jump profiling) not supported");
5136 #else
5137           profile_block_flag = (!profile_block_flag 
5138                                 || profile_block_flag == 2) ? 2 : 3;
5139 #endif
5140         }
5141       else if (!strncmp (arg, "aux-info", 8))
5142         {
5143           flag_gen_aux_info = 1;
5144           if (arg[8] == '\0')
5145             {
5146               if (argc == 1)
5147                 return 0;
5148               
5149               aux_info_file_name = argv[1];
5150               return 2;
5151             }
5152           else
5153             aux_info_file_name = arg + 8;
5154         }
5155       else
5156         return 0;
5157       break;
5158
5159     case 'o':
5160       if (arg[1] == 0)
5161         {
5162           if (argc == 1)
5163             return 0;
5164           
5165           asm_file_name = argv[1];
5166           return 2;
5167         }
5168       return 0;
5169
5170     case 'G':
5171       {
5172         int g_switch_val;
5173         int return_val;
5174             
5175         if (arg[1] == 0)
5176           {
5177             if (argc == 1)
5178               return 0;
5179             
5180             g_switch_val = read_integral_parameter (argv[1], 0, -1);
5181             return_val = 2;
5182           }
5183         else
5184           {
5185             g_switch_val = read_integral_parameter (arg + 1, 0, -1);
5186             return_val = 1;
5187           }
5188             
5189         if (g_switch_val == -1)
5190           return_val = 0;
5191         else
5192           {
5193             g_switch_set = TRUE;
5194             g_switch_value = g_switch_val;
5195           }
5196             
5197         return return_val;
5198       }
5199     }
5200   
5201   return 1;
5202 }
5203 \f
5204 /* Entry point of cc1/c++.  Decode command args, then call compile_file.
5205    Exit code is 35 if can't open files, 34 if fatal error,
5206    33 if had nonfatal errors, else success.  */
5207
5208 extern int main PROTO ((int, char **));
5209
5210 int
5211 main (argc, argv)
5212      int argc;
5213      char **argv;
5214 {
5215   register int i;
5216   char *p;
5217
5218   /* save in case md file wants to emit args as a comment.  */
5219   save_argc = argc;
5220   save_argv = argv;
5221
5222   p = argv[0] + strlen (argv[0]);
5223   while (p != argv[0] && p[-1] != '/'
5224 #ifdef DIR_SEPARATOR
5225          && p[-1] != DIR_SEPARATOR
5226 #endif
5227          )
5228     --p;
5229   progname = p;
5230
5231 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
5232   /* Get rid of any avoidable limit on stack size.  */
5233   {
5234     struct rlimit rlim;
5235
5236     /* Set the stack limit huge so that alloca does not fail.  */
5237     getrlimit (RLIMIT_STACK, &rlim);
5238     rlim.rlim_cur = rlim.rlim_max;
5239     setrlimit (RLIMIT_STACK, &rlim);
5240   }
5241 #endif
5242
5243 #ifdef HAVE_LC_MESSAGES
5244   setlocale (LC_MESSAGES, "");
5245 #endif
5246   (void) bindtextdomain (PACKAGE, localedir);
5247   (void) textdomain (PACKAGE);
5248
5249   signal (SIGFPE, float_signal);
5250
5251 #ifdef SIGPIPE
5252   signal (SIGPIPE, pipe_closed);
5253 #endif
5254
5255   decl_printable_name = decl_name;
5256   lang_expand_expr = (lang_expand_expr_t) do_abort;
5257
5258   /* Initialize whether `char' is signed.  */
5259   flag_signed_char = DEFAULT_SIGNED_CHAR;
5260 #ifdef DEFAULT_SHORT_ENUMS
5261   /* Initialize how much space enums occupy, by default.  */
5262   flag_short_enums = DEFAULT_SHORT_ENUMS;
5263 #endif
5264
5265   /* Initialize the garbage-collector.  */
5266   init_ggc ();
5267   ggc_add_root (&input_file_stack, 1, sizeof input_file_stack,
5268                 &mark_file_stack);
5269
5270   /* Perform language-specific options intialization.  */
5271   lang_init_options ();
5272
5273   /* Scan to see what optimization level has been specified.  That will
5274      determine the default value of many flags.  */
5275   for (i = 1; i < argc; i++)
5276     {
5277       if (!strcmp (argv[i], "-O"))
5278         {
5279           optimize = 1;
5280           optimize_size = 0;
5281         }
5282       else if (argv[i][0] == '-' && argv[i][1] == 'O')
5283         {
5284           /* Handle -Os, -O2, -O3, -O69, ...  */
5285           char *p = &argv[i][2];
5286           
5287           if ((p[0] == 's') && (p[1] == 0))
5288             {
5289               optimize_size = 1;
5290               
5291               /* Optimizing for size forces optimize to be 2. */
5292               optimize = 2;
5293             }
5294           else
5295             {       
5296               const int optimize_val = read_integral_parameter (p, p - 2, -1);
5297               if (optimize_val != -1)
5298                 {
5299                   optimize = optimize_val;
5300                   optimize_size = 0;
5301                 }
5302             }
5303         }
5304     }
5305
5306   obey_regdecls = (optimize == 0);
5307
5308   if (optimize >= 1)
5309     {
5310       flag_defer_pop = 1;
5311       flag_thread_jumps = 1;
5312 #ifdef DELAY_SLOTS
5313       flag_delayed_branch = 1;
5314 #endif
5315 #ifdef CAN_DEBUG_WITHOUT_FP
5316       flag_omit_frame_pointer = 1;
5317 #endif
5318     }
5319
5320   if (optimize >= 2)
5321     {
5322       flag_cse_follow_jumps = 1;
5323       flag_cse_skip_blocks = 1;
5324       flag_gcse = 1;
5325       flag_expensive_optimizations = 1;
5326       flag_strength_reduce = 1;
5327       flag_rerun_cse_after_loop = 1;
5328       flag_rerun_loop_opt = 1;
5329       flag_caller_saves = 1;
5330       flag_force_mem = 1;
5331       flag_peephole2 = 1;
5332 #ifdef INSN_SCHEDULING
5333       flag_schedule_insns = 1;
5334       flag_schedule_insns_after_reload = 1;
5335 #endif
5336       flag_regmove = 1;
5337       flag_strict_aliasing = 1;
5338       flag_delete_null_pointer_checks = 1;
5339     }
5340
5341   if (optimize >= 3)
5342     {
5343       flag_inline_functions = 1;
5344     }
5345
5346   if (optimize < 2 || optimize_size)
5347     {
5348       align_loops = 1;
5349       align_jumps = 1;
5350       align_labels = 1;
5351       align_functions = 1;
5352     }
5353
5354   /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
5355      modify it.  */
5356   target_flags = 0;
5357   set_target_switch ("");
5358
5359 #ifdef OPTIMIZATION_OPTIONS
5360   /* Allow default optimizations to be specified on a per-machine basis.  */
5361   OPTIMIZATION_OPTIONS (optimize, optimize_size);
5362 #endif
5363
5364   /* Initialize register usage now so switches may override.  */
5365   init_reg_sets ();
5366
5367   /* Perform normal command line switch decoding.  */
5368   for (i = 1; i < argc;)
5369     {
5370       unsigned lang_processed;
5371       unsigned indep_processed;
5372       
5373       /* Give the language a chance to decode the option for itself.  */
5374       lang_processed = lang_decode_option (argc - i, argv + i);
5375  
5376       /* Now see if the option also has a language independent meaning.
5377          Some options are both language specific and language independent,
5378          eg --help.  It is possible that there might be options that should
5379          only be decoded in a language independent way if the were not
5380          decoded in a langauge specific way, which is why 'lang_processed'
5381          is passed in.  */
5382       indep_processed = independent_decode_option (argc - i, argv + i, lang_processed);
5383
5384       if (lang_processed || indep_processed)
5385         i += lang_processed > indep_processed ? lang_processed : indep_processed;
5386       else
5387         {
5388           error ("Invalid option `%s'", argv[i]);
5389           i++;
5390         }
5391     }
5392
5393   /* Checker uses the frame pointer.  */
5394   if (flag_check_memory_usage)
5395     flag_omit_frame_pointer = 0;
5396
5397   if (optimize == 0)
5398     {
5399       /* Inlining does not work if not optimizing,
5400          so force it not to be done.  */
5401       flag_no_inline = 1;
5402       warn_inline = 0;
5403
5404       /* The c_decode_option and lang_decode_option functions set
5405          this to `2' if -Wall is used, so we can avoid giving out
5406          lots of errors for people who don't realize what -Wall does.  */
5407       if (warn_uninitialized == 1)
5408         warning ("-Wuninitialized is not supported without -O");
5409     }
5410
5411 #ifdef OVERRIDE_OPTIONS
5412   /* Some machines may reject certain combinations of options.  */
5413   OVERRIDE_OPTIONS;
5414 #endif
5415
5416   if (exceptions_via_longjmp == 2)
5417     {
5418 #ifdef DWARF2_UNWIND_INFO
5419       exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
5420 #else
5421       exceptions_via_longjmp = 1;
5422 #endif
5423     }
5424
5425   /* Set up the align_*_log variables, defaulting them to 1 if they
5426      were still unset.  */
5427   if (align_loops <= 0) align_loops = 1;
5428   align_loops_log = floor_log2 (align_loops*2-1);
5429   if (align_jumps <= 0) align_jumps = 1;
5430   align_jumps_log = floor_log2 (align_jumps*2-1);
5431   if (align_labels <= 0) align_labels = 1;
5432   align_labels_log = floor_log2 (align_labels*2-1);
5433   if (align_functions <= 0) align_functions = 1;
5434   align_functions_log = floor_log2 (align_functions*2-1);
5435   
5436   if (profile_block_flag == 3)
5437     {
5438       warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
5439       profile_block_flag = 2;
5440     }
5441
5442   /* Unrolling all loops implies that standard loop unrolling must also
5443      be done.  */
5444   if (flag_unroll_all_loops)
5445     flag_unroll_loops = 1;
5446   /* Loop unrolling requires that strength_reduction be on also.  Silently
5447      turn on strength reduction here if it isn't already on.  Also, the loop
5448      unrolling code assumes that cse will be run after loop, so that must
5449      be turned on also.  */
5450   if (flag_unroll_loops)
5451     {
5452       flag_strength_reduce = 1;
5453       flag_rerun_cse_after_loop = 1;
5454     }
5455
5456   /* Warn about options that are not supported on this machine.  */
5457 #ifndef INSN_SCHEDULING
5458   if (flag_schedule_insns || flag_schedule_insns_after_reload)
5459     warning ("instruction scheduling not supported on this target machine");
5460 #endif
5461 #ifndef DELAY_SLOTS
5462   if (flag_delayed_branch)
5463     warning ("this target machine does not have delayed branches");
5464 #endif
5465
5466   user_label_prefix = USER_LABEL_PREFIX;
5467   if (flag_leading_underscore != -1)
5468     {
5469       /* If the default prefix is more complicated than "" or "_", 
5470          issue a warning and ignore this option.  */
5471       if (user_label_prefix[0] == 0 ||
5472           (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5473         {
5474           user_label_prefix = flag_leading_underscore ? "_" : "";
5475         }
5476       else
5477         warning ("-f%sleading-underscore not supported on this target machine",
5478                  flag_leading_underscore ? "" : "no-");
5479     }
5480
5481   /* If we are in verbose mode, write out the version and maybe all the
5482      option flags in use.  */
5483   if (version_flag)
5484     {
5485       print_version (stderr, "");
5486       if (! quiet_flag)
5487         print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5488     }
5489
5490   compile_file (filename);
5491
5492 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
5493   if (flag_print_mem)
5494     {
5495       char *lim = (char *) sbrk (0);
5496
5497       notice ("Data size %ld.\n", (long) (lim - (char *) &environ));
5498       fflush (stderr);
5499
5500 #ifndef __MSDOS__
5501 #ifdef USG
5502       system ("ps -l 1>&2");
5503 #else /* not USG */
5504       system ("ps v");
5505 #endif /* not USG */
5506 #endif
5507     }
5508 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
5509
5510   if (errorcount)
5511     return (FATAL_EXIT_CODE);
5512   if (sorrycount)
5513     return (FATAL_EXIT_CODE);
5514   return (SUCCESS_EXIT_CODE);
5515 }
5516 \f
5517 /* Decode -m switches.  */
5518 /* Decode the switch -mNAME.  */
5519
5520 static void
5521 set_target_switch (name)
5522   const char *name;
5523 {
5524   register size_t j;
5525   int valid_target_option = 0;
5526
5527   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5528     if (!strcmp (target_switches[j].name, name))
5529       {
5530         if (target_switches[j].value < 0)
5531           target_flags &= ~-target_switches[j].value;
5532         else
5533           target_flags |= target_switches[j].value;
5534         valid_target_option = 1;
5535       }
5536
5537 #ifdef TARGET_OPTIONS
5538   if (!valid_target_option)
5539     for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5540       {
5541         int len = strlen (target_options[j].prefix);
5542         if (!strncmp (target_options[j].prefix, name, len))
5543           {
5544             *target_options[j].variable = name + len;
5545             valid_target_option = 1;
5546           }
5547       }
5548 #endif
5549
5550   if (!valid_target_option)
5551     error ("Invalid option `%s'", name);
5552 }
5553 \f
5554 /* Print version information to FILE.
5555    Each line begins with INDENT (for the case where FILE is the
5556    assembler output file).  */
5557
5558 static void
5559 print_version (file, indent)
5560      FILE *file;
5561      const char *indent;
5562 {
5563 #ifndef __VERSION__
5564 #define __VERSION__ "[?]"
5565 #endif
5566   fnotice (file,
5567 #ifdef __GNUC__
5568            "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
5569 #else
5570            "%s%s%s version %s (%s) compiled by CC.\n"
5571 #endif
5572            , indent, *indent != 0 ? " " : "",
5573            language_string, version_string, TARGET_NAME, __VERSION__);
5574 }
5575
5576 /* Print an option value and return the adjusted position in the line.
5577    ??? We don't handle error returns from fprintf (disk full); presumably
5578    other code will catch a disk full though.  */
5579
5580 static int
5581 print_single_switch (file, pos, max, indent, sep, term, type, name)
5582      FILE *file;
5583      int pos, max;
5584      const char *indent, *sep, *term, *type, *name;
5585 {
5586   /* The ultrix fprintf returns 0 on success, so compute the result we want
5587      here since we need it for the following test.  */
5588   int len = strlen (sep) + strlen (type) + strlen (name);
5589
5590   if (pos != 0
5591       && pos + len > max)
5592     {
5593       fprintf (file, "%s", term);
5594       pos = 0;
5595     }
5596   if (pos == 0)
5597     {
5598       fprintf (file, "%s", indent);
5599       pos = strlen (indent);
5600     }
5601   fprintf (file, "%s%s%s", sep, type, name);
5602   pos += len;
5603   return pos;
5604 }
5605      
5606 /* Print active target switches to FILE.
5607    POS is the current cursor position and MAX is the size of a "line".
5608    Each line begins with INDENT and ends with TERM.
5609    Each switch is separated from the next by SEP.  */
5610
5611 static void
5612 print_switch_values (file, pos, max, indent, sep, term)
5613      FILE *file;
5614      int pos, max;
5615      const char *indent, *sep, *term;
5616 {
5617   size_t j;
5618   char **p;
5619
5620   /* Print the options as passed.  */
5621
5622   pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5623                              _("options passed: "), "");
5624
5625   for (p = &save_argv[1]; *p != NULL; p++)
5626     if (**p == '-')
5627       {
5628         /* Ignore these.  */
5629         if (strcmp (*p, "-o") == 0)
5630           {
5631             if (p[1] != NULL)
5632               p++;
5633             continue;
5634           }
5635         if (strcmp (*p, "-quiet") == 0)
5636           continue;
5637         if (strcmp (*p, "-version") == 0)
5638           continue;
5639         if ((*p)[1] == 'd')
5640           continue;
5641
5642         pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5643       }
5644   if (pos > 0)
5645     fprintf (file, "%s", term);
5646
5647   /* Print the -f and -m options that have been enabled.
5648      We don't handle language specific options but printing argv
5649      should suffice.  */
5650
5651   pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5652                              _("options enabled: "), "");
5653
5654   for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
5655     if (*f_options[j].variable == f_options[j].on_value)
5656       pos = print_single_switch (file, pos, max, indent, sep, term,
5657                                  "-f", f_options[j].string);
5658
5659   /* Print target specific options.  */
5660
5661   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5662     if (target_switches[j].name[0] != '\0'
5663         && target_switches[j].value > 0
5664         && ((target_switches[j].value & target_flags)
5665             == target_switches[j].value))
5666       {
5667         pos = print_single_switch (file, pos, max, indent, sep, term,
5668                                    "-m", target_switches[j].name);
5669       }
5670
5671 #ifdef TARGET_OPTIONS
5672   for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5673     if (*target_options[j].variable != NULL)
5674       {
5675         char prefix[256];
5676         sprintf (prefix, "-m%s", target_options[j].prefix);
5677         pos = print_single_switch (file, pos, max, indent, sep, term,
5678                                    prefix, *target_options[j].variable);
5679       }
5680 #endif
5681
5682   fprintf (file, "%s", term);
5683 }
5684
5685 /* Record the beginning of a new source file, named FILENAME.  */
5686
5687 void
5688 debug_start_source_file (filename)
5689      register char *filename ATTRIBUTE_UNUSED;
5690 {
5691 #ifdef DBX_DEBUGGING_INFO
5692   if (write_symbols == DBX_DEBUG)
5693     dbxout_start_new_source_file (filename);
5694 #endif
5695 #ifdef DWARF_DEBUGGING_INFO
5696   if (debug_info_level == DINFO_LEVEL_VERBOSE
5697       && write_symbols == DWARF_DEBUG)
5698     dwarfout_start_new_source_file (filename);
5699 #endif /* DWARF_DEBUGGING_INFO */
5700 #ifdef DWARF2_DEBUGGING_INFO
5701   if (debug_info_level == DINFO_LEVEL_VERBOSE
5702       && write_symbols == DWARF2_DEBUG)
5703     dwarf2out_start_source_file (filename);
5704 #endif /* DWARF2_DEBUGGING_INFO */  
5705 #ifdef SDB_DEBUGGING_INFO
5706   if (write_symbols == SDB_DEBUG)
5707     sdbout_start_new_source_file (filename);
5708 #endif
5709 }
5710
5711 /* Record the resumption of a source file.  LINENO is the line number in
5712    the source file we are returning to.  */
5713
5714 void
5715 debug_end_source_file (lineno)
5716      register unsigned lineno ATTRIBUTE_UNUSED;
5717 {
5718 #ifdef DBX_DEBUGGING_INFO
5719   if (write_symbols == DBX_DEBUG)
5720     dbxout_resume_previous_source_file ();
5721 #endif
5722 #ifdef DWARF_DEBUGGING_INFO
5723   if (debug_info_level == DINFO_LEVEL_VERBOSE
5724       && write_symbols == DWARF_DEBUG)
5725     dwarfout_resume_previous_source_file (lineno);
5726 #endif /* DWARF_DEBUGGING_INFO */
5727 #ifdef DWARF2_DEBUGGING_INFO
5728   if (debug_info_level == DINFO_LEVEL_VERBOSE
5729       && write_symbols == DWARF2_DEBUG)
5730     dwarf2out_end_source_file ();
5731 #endif /* DWARF2_DEBUGGING_INFO */
5732 #ifdef SDB_DEBUGGING_INFO
5733   if (write_symbols == SDB_DEBUG)
5734     sdbout_resume_previous_source_file ();
5735 #endif
5736 }
5737
5738 /* Called from check_newline in c-parse.y.  The `buffer' parameter contains
5739    the tail part of the directive line, i.e. the part which is past the
5740    initial whitespace, #, whitespace, directive-name, whitespace part.  */
5741
5742 void
5743 debug_define (lineno, buffer)
5744      register unsigned lineno ATTRIBUTE_UNUSED;
5745      register char *buffer ATTRIBUTE_UNUSED;
5746 {
5747 #ifdef DWARF_DEBUGGING_INFO
5748   if (debug_info_level == DINFO_LEVEL_VERBOSE
5749       && write_symbols == DWARF_DEBUG)
5750     dwarfout_define (lineno, buffer);
5751 #endif /* DWARF_DEBUGGING_INFO */
5752 #ifdef DWARF2_DEBUGGING_INFO
5753   if (debug_info_level == DINFO_LEVEL_VERBOSE
5754       && write_symbols == DWARF2_DEBUG)
5755     dwarf2out_define (lineno, buffer);
5756 #endif /* DWARF2_DEBUGGING_INFO */
5757 }
5758
5759 /* Called from check_newline in c-parse.y.  The `buffer' parameter contains
5760    the tail part of the directive line, i.e. the part which is past the
5761    initial whitespace, #, whitespace, directive-name, whitespace part.  */
5762
5763 void
5764 debug_undef (lineno, buffer)
5765      register unsigned lineno ATTRIBUTE_UNUSED;
5766      register char *buffer ATTRIBUTE_UNUSED;
5767 {
5768 #ifdef DWARF_DEBUGGING_INFO
5769   if (debug_info_level == DINFO_LEVEL_VERBOSE
5770       && write_symbols == DWARF_DEBUG)
5771     dwarfout_undef (lineno, buffer);
5772 #endif /* DWARF_DEBUGGING_INFO */
5773 #ifdef DWARF2_DEBUGGING_INFO
5774   if (debug_info_level == DINFO_LEVEL_VERBOSE
5775       && write_symbols == DWARF2_DEBUG)
5776     dwarf2out_undef (lineno, buffer);
5777 #endif /* DWARF2_DEBUGGING_INFO */
5778 }