OSDN Git Service

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