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