OSDN Git Service

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