OSDN Git Service

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