OSDN Git Service

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