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