OSDN Git Service

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