OSDN Git Service

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