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