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