OSDN Git Service

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