OSDN Git Service

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