* defaults.h (TARGET_ALLOWS_PROFILING_WITHOUT_FRAME_POINTER): New
[official-gcc.git] / gcc / toplev.c
blobe825a30d7040b0dbc492074ca6880f9691f88259
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.
5 This file is part of GNU CC.
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.
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.
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. */
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. */
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>
34 #ifdef HAVE_SYS_RESOURCE_H
35 # include <sys/resource.h>
36 #endif
38 #ifdef HAVE_SYS_TIMES_H
39 # include <sys/times.h>
40 #endif
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 #include "dwarf2asm.h"
68 #ifndef ACCUMULATE_OUTGOING_ARGS
69 #define ACCUMULATE_OUTGOING_ARGS 0
70 #endif
72 #ifdef DWARF_DEBUGGING_INFO
73 #include "dwarfout.h"
74 #endif
76 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
77 #include "dwarf2out.h"
78 #endif
80 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
81 #include "dbxout.h"
82 #endif
84 #ifdef SDB_DEBUGGING_INFO
85 #include "sdbout.h"
86 #endif
88 #ifdef XCOFF_DEBUGGING_INFO
89 #include "xcoffout.h"
90 #endif
92 #ifdef VMS
93 /* The extra parameters substantially improve the I/O performance. */
95 static FILE *
96 vms_fopen (fname, type)
97 char *fname;
98 char *type;
100 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
101 fixed arguments, which matches ANSI's specification but not VAXCRTL's
102 pre-ANSI implementation. This hack circumvents the mismatch problem. */
103 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
105 if (*type == 'w')
106 return (*vmslib_fopen) (fname, type, "mbc=32",
107 "deq=64", "fop=tef", "shr=nil");
108 else
109 return (*vmslib_fopen) (fname, type, "mbc=32");
112 #define fopen vms_fopen
113 #endif /* VMS */
115 #ifndef DEFAULT_GDB_EXTENSIONS
116 #define DEFAULT_GDB_EXTENSIONS 1
117 #endif
119 /* If more than one debugging type is supported, you must define
120 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
122 This is one long line cause VAXC can't handle a \-newline. */
123 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
124 #ifndef PREFERRED_DEBUGGING_TYPE
125 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
126 #endif /* no PREFERRED_DEBUGGING_TYPE */
127 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
128 so the following code needn't care. */
129 #ifdef DBX_DEBUGGING_INFO
130 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
131 #endif
132 #ifdef SDB_DEBUGGING_INFO
133 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
134 #endif
135 #ifdef DWARF_DEBUGGING_INFO
136 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
137 #endif
138 #ifdef DWARF2_DEBUGGING_INFO
139 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
140 #endif
141 #ifdef XCOFF_DEBUGGING_INFO
142 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
143 #endif
144 #endif /* More than one debugger format enabled. */
146 /* If still not defined, must have been because no debugging formats
147 are supported. */
148 #ifndef PREFERRED_DEBUGGING_TYPE
149 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
150 #endif
152 #if defined (HAVE_DECL_ENVIRON) && !HAVE_DECL_ENVIRON
153 extern char **environ;
154 #endif
156 /* Carry information from ASM_DECLARE_OBJECT_NAME
157 to ASM_FINISH_DECLARE_OBJECT. */
159 extern int size_directive_output;
160 extern tree last_assemble_variable_decl;
162 static void set_target_switch PARAMS ((const char *));
163 static const char *decl_name PARAMS ((tree, int));
165 static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
166 static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
167 static void compile_file PARAMS ((const char *));
168 static void display_help PARAMS ((void));
169 static void display_target_options PARAMS ((void));
171 static void decode_d_option PARAMS ((const char *));
172 static int decode_f_option PARAMS ((const char *));
173 static int decode_W_option PARAMS ((const char *));
174 static int decode_g_option PARAMS ((const char *));
175 static unsigned int independent_decode_option PARAMS ((int, char **));
177 static void print_version PARAMS ((FILE *, const char *));
178 static int print_single_switch PARAMS ((FILE *, int, int, const char *,
179 const char *, const char *,
180 const char *, const char *));
181 static void print_switch_values PARAMS ((FILE *, int, int, const char *,
182 const char *, const char *));
184 /* Length of line when printing switch values. */
185 #define MAX_LINE 75
187 /* Name of program invoked, sans directories. */
189 const char *progname;
191 /* Copy of arguments to main. */
192 int save_argc;
193 char **save_argv;
195 /* Name of current original source file (what was input to cpp).
196 This comes from each #-command in the actual input. */
198 const char *input_filename;
200 /* Name of top-level original source file (what was input to cpp).
201 This comes from the #-command at the beginning of the actual input.
202 If there isn't any there, then this is the cc1 input file name. */
204 const char *main_input_filename;
206 /* Current line number in real source file. */
208 int lineno;
210 /* Nonzero if it is unsafe to create any new pseudo registers. */
211 int no_new_pseudos;
213 /* Stack of currently pending input files. */
215 struct file_stack *input_file_stack;
217 /* Incremented on each change to input_file_stack. */
218 int input_file_stack_tick;
220 /* Name to use as base of names for dump output files. */
222 const char *dump_base_name;
224 /* Bit flags that specify the machine subtype we are compiling for.
225 Bits are tested using macros TARGET_... defined in the tm.h file
226 and set by `-m...' switches. Must be defined in rtlanal.c. */
228 extern int target_flags;
230 /* Describes a dump file. */
232 struct dump_file_info
234 /* The unique extension to apply, e.g. ".jump". */
235 const char *const extension;
237 /* The -d<c> character that enables this dump file. */
238 char const debug_switch;
240 /* True if there is a corresponding graph dump file. */
241 char const graph_dump_p;
243 /* True if the user selected this dump. */
244 char enabled;
246 /* True if the files have been initialized (ie truncated). */
247 char initialized;
250 /* Enumerate the extant dump files. */
252 enum dump_file_index
254 DFI_rtl,
255 DFI_sibling,
256 DFI_eh,
257 DFI_jump,
258 DFI_cse,
259 DFI_addressof,
260 DFI_ssa,
261 DFI_dce,
262 DFI_ussa,
263 DFI_gcse,
264 DFI_loop,
265 DFI_cse2,
266 DFI_cfg,
267 DFI_bp,
268 DFI_life,
269 DFI_combine,
270 DFI_ce,
271 DFI_regmove,
272 DFI_sched,
273 DFI_lreg,
274 DFI_greg,
275 DFI_postreload,
276 DFI_flow2,
277 DFI_peephole2,
278 DFI_rnreg,
279 DFI_ce2,
280 DFI_sched2,
281 DFI_bbro,
282 DFI_jump2,
283 DFI_mach,
284 DFI_dbr,
285 DFI_stack,
286 DFI_MAX
289 /* Describes all the dump files. Should be kept in order of the
290 pass and in sync with dump_file_index above.
292 Remaining -d letters:
294 " o q u "
295 " H K OPQ TUVW YZ"
298 struct dump_file_info dump_file[DFI_MAX] =
300 { "rtl", 'r', 0, 0, 0 },
301 { "sibling", 'i', 0, 0, 0 },
302 { "eh", 'h', 0, 0, 0 },
303 { "jump", 'j', 0, 0, 0 },
304 { "cse", 's', 0, 0, 0 },
305 { "addressof", 'F', 0, 0, 0 },
306 { "ssa", 'e', 1, 0, 0 },
307 { "dce", 'X', 1, 0, 0 },
308 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
309 { "gcse", 'G', 1, 0, 0 },
310 { "loop", 'L', 1, 0, 0 },
311 { "cse2", 't', 1, 0, 0 },
312 { "cfg", 'f', 1, 0, 0 },
313 { "bp", 'b', 1, 0, 0 },
314 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
315 { "combine", 'c', 1, 0, 0 },
316 { "ce", 'C', 1, 0, 0 },
317 { "regmove", 'N', 1, 0, 0 },
318 { "sched", 'S', 1, 0, 0 },
319 { "lreg", 'l', 1, 0, 0 },
320 { "greg", 'g', 1, 0, 0 },
321 { "postreload", 'o', 1, 0, 0 },
322 { "flow2", 'w', 1, 0, 0 },
323 { "peephole2", 'z', 1, 0, 0 },
324 { "rnreg", 'n', 1, 0, 0 },
325 { "ce2", 'E', 1, 0, 0 },
326 { "sched2", 'R', 1, 0, 0 },
327 { "bbro", 'B', 1, 0, 0 },
328 { "jump2", 'J', 1, 0, 0 },
329 { "mach", 'M', 1, 0, 0 },
330 { "dbr", 'd', 0, 0, 0 },
331 { "stack", 'k', 1, 0, 0 },
334 static int open_dump_file PARAMS ((enum dump_file_index, tree));
335 static void close_dump_file PARAMS ((enum dump_file_index,
336 void (*) (FILE *, rtx), rtx));
338 /* Other flags saying which kinds of debugging dump have been requested. */
340 int rtl_dump_and_exit;
341 int flag_print_asm_name;
342 static int flag_print_mem;
343 static int version_flag;
344 static char *filename;
345 enum graph_dump_types graph_dump_format;
347 /* Name for output file of assembly code, specified with -o. */
349 char *asm_file_name;
351 /* Value of the -G xx switch, and whether it was passed or not. */
352 int g_switch_value;
353 int g_switch_set;
355 /* Type(s) of debugging information we are producing (if any).
356 See flags.h for the definitions of the different possible
357 types of debugging information. */
358 enum debug_info_type write_symbols = NO_DEBUG;
360 /* Level of debugging information we are producing. See flags.h
361 for the definitions of the different possible levels. */
362 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
364 /* Nonzero means use GNU-only extensions in the generated symbolic
365 debugging information. */
366 /* Currently, this only has an effect when write_symbols is set to
367 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
368 int use_gnu_debug_info_extensions = 0;
370 /* Nonzero means do optimizations. -O.
371 Particular numeric values stand for particular amounts of optimization;
372 thus, -O2 stores 2 here. However, the optimizations beyond the basic
373 ones are not controlled directly by this variable. Instead, they are
374 controlled by individual `flag_...' variables that are defaulted
375 based on this variable. */
377 int optimize = 0;
379 /* Nonzero means optimize for size. -Os.
380 The only valid values are zero and non-zero. When optimize_size is
381 non-zero, optimize defaults to 2, but certain individual code
382 bloating optimizations are disabled. */
384 int optimize_size = 0;
386 /* Number of error messages and warning messages so far. */
388 int errorcount = 0;
389 int warningcount = 0;
390 int sorrycount = 0;
392 /* Nonzero if we should exit after parsing options. */
393 static int exit_after_options = 0;
395 /* The FUNCTION_DECL for the function currently being compiled,
396 or 0 if between functions. */
397 tree current_function_decl;
399 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
400 if none. */
401 tree current_function_func_begin_label;
403 /* Pointer to function to compute the name to use to print a declaration.
404 DECL is the declaration in question.
405 VERBOSITY determines what information will be printed:
406 0: DECL_NAME, demangled as necessary.
407 1: and scope information.
408 2: and any other information that might be interesting, such as function
409 parameter types in C++. */
411 const char *(*decl_printable_name) PARAMS ((tree, int));
413 /* Pointer to function to compute rtl for a language-specific tree code. */
415 typedef rtx (*lang_expand_expr_t)
416 PARAMS ((union tree_node *, rtx, enum machine_mode,
417 enum expand_modifier modifier));
419 lang_expand_expr_t lang_expand_expr = 0;
421 tree (*lang_expand_constant) PARAMS ((tree)) = 0;
423 /* Pointer to function to finish handling an incomplete decl at the
424 end of compilation. */
426 void (*incomplete_decl_finalize_hook) PARAMS ((tree)) = 0;
428 /* Nonzero if doing dwarf2 duplicate elimination. */
430 int flag_eliminate_dwarf2_dups = 0;
432 /* Nonzero if generating code to do profiling. */
434 int profile_flag = 0;
436 /* Nonzero if generating code to do profiling on a line-by-line basis. */
438 int profile_block_flag;
440 /* Nonzero if generating code to profile program flow graph arcs. */
442 int profile_arc_flag = 0;
444 /* Nonzero if generating info for gcov to calculate line test coverage. */
446 int flag_test_coverage = 0;
448 /* Nonzero indicates that branch taken probabilities should be calculated. */
450 int flag_branch_probabilities = 0;
452 /* Nonzero if basic blocks should be reordered. */
454 int flag_reorder_blocks = 0;
456 /* Nonzero if registers should be renamed. */
458 int flag_rename_registers = 0;
460 /* Nonzero for -pedantic switch: warn about anything
461 that standard spec forbids. */
463 int pedantic = 0;
465 /* Temporarily suppress certain warnings.
466 This is set while reading code from a system header file. */
468 int in_system_header = 0;
470 /* Don't print functions as they are compiled. -quiet. */
472 int quiet_flag = 0;
474 /* Print times taken by the various passes. -ftime-report. */
476 int time_report = 0;
478 /* Print memory still in use at end of compilation (which may have little
479 to do with peak memory consumption). -fmem-report. */
481 int mem_report = 0;
483 /* Non-zero means to collect statistics which might be expensive
484 and to print them when we are done. */
485 int flag_detailed_statistics = 0;
488 /* -f flags. */
490 /* Nonzero means `char' should be signed. */
492 int flag_signed_char;
494 /* Nonzero means give an enum type only as many bytes as it needs. */
496 int flag_short_enums;
498 /* Nonzero for -fcaller-saves: allocate values in regs that need to
499 be saved across function calls, if that produces overall better code.
500 Optional now, so people can test it. */
502 #ifdef DEFAULT_CALLER_SAVES
503 int flag_caller_saves = 1;
504 #else
505 int flag_caller_saves = 0;
506 #endif
508 /* Nonzero if structures and unions should be returned in memory.
510 This should only be defined if compatibility with another compiler or
511 with an ABI is needed, because it results in slower code. */
513 #ifndef DEFAULT_PCC_STRUCT_RETURN
514 #define DEFAULT_PCC_STRUCT_RETURN 1
515 #endif
517 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
519 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
521 /* Nonzero for -fforce-mem: load memory value into a register
522 before arithmetic on it. This makes better cse but slower compilation. */
524 int flag_force_mem = 0;
526 /* Nonzero for -fforce-addr: load memory address into a register before
527 reference to memory. This makes better cse but slower compilation. */
529 int flag_force_addr = 0;
531 /* Nonzero for -fdefer-pop: don't pop args after each function call;
532 instead save them up to pop many calls' args with one insns. */
534 int flag_defer_pop = 0;
536 /* Nonzero for -ffloat-store: don't allocate floats and doubles
537 in extended-precision registers. */
539 int flag_float_store = 0;
541 /* Nonzero for -fcse-follow-jumps:
542 have cse follow jumps to do a more extensive job. */
544 int flag_cse_follow_jumps;
546 /* Nonzero for -fcse-skip-blocks:
547 have cse follow a branch around a block. */
548 int flag_cse_skip_blocks;
550 /* Nonzero for -fexpensive-optimizations:
551 perform miscellaneous relatively-expensive optimizations. */
552 int flag_expensive_optimizations;
554 /* Nonzero for -fthread-jumps:
555 have jump optimize output of loop. */
557 int flag_thread_jumps;
559 /* Nonzero enables strength-reduction in loop.c. */
561 int flag_strength_reduce = 0;
563 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
564 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
565 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
566 unrolled. */
568 int flag_unroll_loops;
570 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
571 This is generally not a win. */
573 int flag_unroll_all_loops;
575 /* Nonzero forces all invariant computations in loops to be moved
576 outside the loop. */
578 int flag_move_all_movables = 0;
580 /* Nonzero forces all general induction variables in loops to be
581 strength reduced. */
583 int flag_reduce_all_givs = 0;
585 /* Nonzero to perform full register move optimization passes. This is the
586 default for -O2. */
588 int flag_regmove = 0;
590 /* Nonzero for -fwritable-strings:
591 store string constants in data segment and don't uniquize them. */
593 int flag_writable_strings = 0;
595 /* Nonzero means don't put addresses of constant functions in registers.
596 Used for compiling the Unix kernel, where strange substitutions are
597 done on the assembly output. */
599 int flag_no_function_cse = 0;
601 /* Nonzero for -fomit-frame-pointer:
602 don't make a frame pointer in simple functions that don't require one. */
604 int flag_omit_frame_pointer = 0;
606 /* Nonzero means place each function into its own section on those platforms
607 which support arbitrary section names and unlimited numbers of sections. */
609 int flag_function_sections = 0;
611 /* ... and similar for data. */
613 int flag_data_sections = 0;
615 /* Nonzero to inhibit use of define_optimization peephole opts. */
617 int flag_no_peephole = 0;
619 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
620 operations in the interest of optimization. For example it allows
621 GCC to assume arguments to sqrt are nonnegative numbers, allowing
622 faster code for sqrt to be generated. */
624 int flag_fast_math = 0;
626 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
628 int flag_optimize_sibling_calls = 0;
630 /* Nonzero means the front end generally wants `errno' maintained by math
631 operations, like built-in SQRT, unless overridden by flag_fast_math. */
633 int flag_errno_math = 1;
635 /* 0 means straightforward implementation of complex divide acceptable.
636 1 means wide ranges of inputs must work for complex divide.
637 2 means C99-like requirements for complex divide (not yet implemented). */
639 int flag_complex_divide_method = 0;
641 /* Nonzero means all references through pointers are volatile. */
643 int flag_volatile;
645 /* Nonzero means treat all global and extern variables as volatile. */
647 int flag_volatile_global;
649 /* Nonzero means treat all static variables as volatile. */
651 int flag_volatile_static;
653 /* Nonzero means just do syntax checking; don't output anything. */
655 int flag_syntax_only = 0;
657 /* Nonzero means perform global cse. */
659 static int flag_gcse;
661 /* Nonzero means to use global dataflow analysis to eliminate
662 useless null pointer tests. */
664 static int flag_delete_null_pointer_checks;
666 /* Nonzero means to rerun cse after loop optimization. This increases
667 compilation time about 20% and picks up a few more common expressions. */
669 static int flag_rerun_cse_after_loop;
671 /* Nonzero means to run loop optimizations twice. */
673 int flag_rerun_loop_opt;
675 /* Nonzero for -finline-functions: ok to inline functions that look like
676 good inline candidates. */
678 int flag_inline_functions;
680 /* Nonzero for -fkeep-inline-functions: even if we make a function
681 go inline everywhere, keep its definition around for debugging
682 purposes. */
684 int flag_keep_inline_functions;
686 /* Nonzero means that functions will not be inlined. */
688 int flag_no_inline;
690 /* Nonzero means that we should emit static const variables
691 regardless of whether or not optimization is turned on. */
693 int flag_keep_static_consts = 1;
695 /* Nonzero means we should be saving declaration info into a .X file. */
697 int flag_gen_aux_info = 0;
699 /* Specified name of aux-info file. */
701 static char *aux_info_file_name;
703 /* Nonzero means make the text shared if supported. */
705 int flag_shared_data;
707 /* Nonzero means schedule into delayed branch slots if supported. */
709 int flag_delayed_branch;
711 /* Nonzero if we are compiling pure (sharable) code.
712 Value is 1 if we are doing reasonable (i.e. simple
713 offset into offset table) pic. Value is 2 if we can
714 only perform register offsets. */
716 int flag_pic;
718 /* Nonzero means generate extra code for exception handling and enable
719 exception handling. */
721 int flag_exceptions;
723 /* Nonzero means generate frame unwind info table when supported. */
725 int flag_unwind_tables = 0;
727 /* Nonzero means don't place uninitialized global data in common storage
728 by default. */
730 int flag_no_common;
732 /* Nonzero means pretend it is OK to examine bits of target floats,
733 even if that isn't true. The resulting code will have incorrect constants,
734 but the same series of instructions that the native compiler would make. */
736 int flag_pretend_float;
738 /* Nonzero means change certain warnings into errors.
739 Usually these are warnings about failure to conform to some standard. */
741 int flag_pedantic_errors = 0;
743 /* flag_schedule_insns means schedule insns within basic blocks (before
744 local_alloc).
745 flag_schedule_insns_after_reload means schedule insns after
746 global_alloc. */
748 int flag_schedule_insns = 0;
749 int flag_schedule_insns_after_reload = 0;
751 /* The following flags have effect only for scheduling before register
752 allocation:
754 flag_schedule_interblock means schedule insns accross basic blocks.
755 flag_schedule_speculative means allow speculative motion of non-load insns.
756 flag_schedule_speculative_load means allow speculative motion of some
757 load insns.
758 flag_schedule_speculative_load_dangerous allows speculative motion of more
759 load insns. */
761 int flag_schedule_interblock = 1;
762 int flag_schedule_speculative = 1;
763 int flag_schedule_speculative_load = 0;
764 int flag_schedule_speculative_load_dangerous = 0;
766 int flag_single_precision_constant;
768 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
769 by a cheaper branch on a count register. */
770 int flag_branch_on_count_reg = 1;
772 /* -finhibit-size-directive inhibits output of .size for ELF.
773 This is used only for compiling crtstuff.c,
774 and it may be extended to other effects
775 needed for crtstuff.c on other systems. */
776 int flag_inhibit_size_directive = 0;
778 /* -fverbose-asm causes extra commentary information to be produced in
779 the generated assembly code (to make it more readable). This option
780 is generally only of use to those who actually need to read the
781 generated assembly code (perhaps while debugging the compiler itself).
782 -fno-verbose-asm, the default, causes the extra information
783 to be omitted and is useful when comparing two assembler files. */
785 int flag_verbose_asm = 0;
787 /* -dA causes debug commentary information to be produced in
788 the generated assembly code (to make it more readable). This option
789 is generally only of use to those who actually need to read the
790 generated assembly code (perhaps while debugging the compiler itself).
791 Currently, this switch is only used by dwarfout.c; however, it is intended
792 to be a catchall for printing debug information in the assembler file. */
794 int flag_debug_asm = 0;
796 /* -dP causes the rtl to be emitted as a comment in assembly. */
798 int flag_dump_rtl_in_asm = 0;
800 /* -fgnu-linker specifies use of the GNU linker for initializations.
801 (Or, more generally, a linker that handles initializations.)
802 -fno-gnu-linker says that collect2 will be used. */
803 #ifdef USE_COLLECT2
804 int flag_gnu_linker = 0;
805 #else
806 int flag_gnu_linker = 1;
807 #endif
809 /* Enable SSA. */
810 int flag_ssa = 0;
812 /* Enable dead code elimination. */
813 int flag_dce = 0;
815 /* Tag all structures with __attribute__(packed). */
816 int flag_pack_struct = 0;
818 /* Emit code to check for stack overflow; also may cause large objects
819 to be allocated dynamically. */
820 int flag_stack_check;
822 /* When non-NULL, indicates that whenever space is allocated on the
823 stack, the resulting stack pointer must not pass this
824 address---that is, for stacks that grow downward, the stack pointer
825 must always be greater than or equal to this address; for stacks
826 that grow upward, the stack pointer must be less than this address.
827 At present, the rtx may be either a REG or a SYMBOL_REF, although
828 the support provided depends on the backend. */
829 rtx stack_limit_rtx;
831 /* -fcheck-memory-usage causes extra code to be generated in order to check
832 memory accesses. This is used by a detector of bad memory accesses such
833 as Checker. */
834 int flag_check_memory_usage = 0;
836 /* -fprefix-function-name causes function name to be prefixed. This
837 can be used with -fcheck-memory-usage to isolate code compiled with
838 -fcheck-memory-usage. */
839 int flag_prefix_function_name = 0;
841 /* 0 if pointer arguments may alias each other. True in C.
842 1 if pointer arguments may not alias each other but may alias
843 global variables.
844 2 if pointer arguments may not alias each other and may not
845 alias global variables. True in Fortran.
846 This defaults to 0 for C. */
847 int flag_argument_noalias = 0;
849 /* Nonzero if we should do (language-dependent) alias analysis.
850 Typically, this analysis will assume that expressions of certain
851 types do not alias expressions of certain other types. Only used
852 if alias analysis (in general) is enabled. */
853 int flag_strict_aliasing = 0;
855 /* Instrument functions with calls at entry and exit, for profiling. */
856 int flag_instrument_function_entry_exit = 0;
858 /* Nonzero means ignore `#ident' directives. 0 means handle them.
859 On SVR4 targets, it also controls whether or not to emit a
860 string identifying the compiler. */
862 int flag_no_ident = 0;
864 /* This will perform a peephole pass before sched2. */
865 int flag_peephole2 = 0;
867 /* This will try to guess branch probabilities. */
868 int flag_guess_branch_prob = 0;
870 /* -fbounded-pointers causes gcc to compile pointers as composite
871 objects occupying three words: the pointer value, the base address
872 of the referent object, and the address immediately beyond the end
873 of the referent object. The base and extent allow us to perform
874 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
875 int flag_bounded_pointers = 0;
877 /* -fcheck-bounds causes gcc to generate array bounds checks.
878 For C, C++: defaults to value of flag_bounded_pointers.
879 For ObjC: defaults to off.
880 For Java: defaults to on.
881 For Fortran: defaults to off.
882 For CHILL: defaults to off. */
883 int flag_bounds_check = 0;
885 /* If one, renumber instruction UIDs to reduce the number of
886 unused UIDs if there are a lot of instructions. If greater than
887 one, unconditionally renumber instruction UIDs. */
888 int flag_renumber_insns = 1;
890 /* Values of the -falign-* flags: how much to align labels in code.
891 0 means `use default', 1 means `don't align'.
892 For each variable, there is an _log variant which is the power
893 of two not less than the variable, for .align output. */
895 int align_loops;
896 int align_loops_log;
897 int align_jumps;
898 int align_jumps_log;
899 int align_labels;
900 int align_labels_log;
901 int align_functions;
902 int align_functions_log;
904 /* Table of supported debugging formats. */
905 static struct
907 const char *arg;
908 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
909 constant expression, we use NO_DEBUG in its place. */
910 enum debug_info_type debug_type;
911 int use_extensions_p;
912 const char *description;
913 } *da,
914 debug_args[] =
916 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
917 "Generate default debug format output" },
918 { "gdb", NO_DEBUG, 1, "Generate default extended debug format output" },
919 #ifdef DBX_DEBUGGING_INFO
920 { "stabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
921 { "stabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
922 #endif
923 #ifdef DWARF_DEBUGGING_INFO
924 { "dwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
925 { "dwarf+", DWARF_DEBUG, 1,
926 "Generated extended DWARF-1 format debug output" },
927 #endif
928 #ifdef DWARF2_DEBUGGING_INFO
929 { "dwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
930 #endif
931 #ifdef XCOFF_DEBUGGING_INFO
932 { "xcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
933 { "xcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
934 #endif
935 #ifdef SDB_DEBUGGING_INFO
936 { "coff", SDB_DEBUG, 0, "Generate COFF format debug output" },
937 #endif
938 { 0, 0, 0, 0 }
941 typedef struct
943 const char *string;
944 int *variable;
945 int on_value;
946 const char *description;
948 lang_independent_options;
950 int flag_trapv = 0;
952 /* Add or remove a leading underscore from user symbols. */
953 int flag_leading_underscore = -1;
955 /* The user symbol prefix after having resolved same. */
956 const char *user_label_prefix;
958 static const param_info lang_independent_params[] = {
959 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
960 { OPTION, DEFAULT, HELP },
961 #include "params.def"
962 #undef DEFPARAM
963 { NULL, 0, NULL }
966 /* A default for same. */
967 #ifndef USER_LABEL_PREFIX
968 #define USER_LABEL_PREFIX ""
969 #endif
971 /* Table of language-independent -f options.
972 STRING is the option name. VARIABLE is the address of the variable.
973 ON_VALUE is the value to store in VARIABLE
974 if `-fSTRING' is seen as an option.
975 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
977 lang_independent_options f_options[] =
979 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
980 "Perform DWARF2 duplicate elimination"},
981 {"float-store", &flag_float_store, 1,
982 "Do not store floats in registers" },
983 {"volatile", &flag_volatile, 1,
984 "Consider all mem refs through pointers as volatile"},
985 {"volatile-global", &flag_volatile_global, 1,
986 "Consider all mem refs to global data to be volatile" },
987 {"volatile-static", &flag_volatile_static, 1,
988 "Consider all mem refs to static data to be volatile" },
989 {"defer-pop", &flag_defer_pop, 1,
990 "Defer popping functions args from stack until later" },
991 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
992 "When possible do not generate stack frames"},
993 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
994 "Optimize sibling and tail recursive calls" },
995 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
996 "When running CSE, follow jumps to their targets" },
997 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
998 "When running CSE, follow conditional jumps" },
999 {"expensive-optimizations", &flag_expensive_optimizations, 1,
1000 "Perform a number of minor, expensive optimisations" },
1001 {"thread-jumps", &flag_thread_jumps, 1,
1002 "Perform jump threading optimisations"},
1003 {"strength-reduce", &flag_strength_reduce, 1,
1004 "Perform strength reduction optimisations" },
1005 {"unroll-loops", &flag_unroll_loops, 1,
1006 "Perform loop unrolling when iteration count is known" },
1007 {"unroll-all-loops", &flag_unroll_all_loops, 1,
1008 "Perform loop unrolling for all loops" },
1009 {"move-all-movables", &flag_move_all_movables, 1,
1010 "Force all loop invariant computations out of loops" },
1011 {"reduce-all-givs", &flag_reduce_all_givs, 1,
1012 "Strength reduce all loop general induction variables" },
1013 {"writable-strings", &flag_writable_strings, 1,
1014 "Store strings in writable data section" },
1015 {"peephole", &flag_no_peephole, 0,
1016 "Enable machine specific peephole optimisations" },
1017 {"force-mem", &flag_force_mem, 1,
1018 "Copy memory operands into registers before using" },
1019 {"force-addr", &flag_force_addr, 1,
1020 "Copy memory address constants into regs before using" },
1021 {"function-cse", &flag_no_function_cse, 0,
1022 "Allow function addresses to be held in registers" },
1023 {"inline-functions", &flag_inline_functions, 1,
1024 "Integrate simple functions into their callers" },
1025 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1026 "Generate code for funcs even if they are fully inlined" },
1027 {"inline", &flag_no_inline, 0,
1028 "Pay attention to the 'inline' keyword"},
1029 {"keep-static-consts", &flag_keep_static_consts, 1,
1030 "Emit static const variables even if they are not used" },
1031 {"syntax-only", &flag_syntax_only, 1,
1032 "Check for syntax errors, then stop" },
1033 {"shared-data", &flag_shared_data, 1,
1034 "Mark data as shared rather than private" },
1035 {"caller-saves", &flag_caller_saves, 1,
1036 "Enable saving registers around function calls" },
1037 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1038 "Return 'short' aggregates in memory, not registers" },
1039 {"reg-struct-return", &flag_pcc_struct_return, 0,
1040 "Return 'short' aggregates in registers" },
1041 {"delayed-branch", &flag_delayed_branch, 1,
1042 "Attempt to fill delay slots of branch instructions" },
1043 {"gcse", &flag_gcse, 1,
1044 "Perform the global common subexpression elimination" },
1045 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1046 "Run CSE pass after loop optimisations"},
1047 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1048 "Run the loop optimiser twice"},
1049 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1050 "Delete useless null pointer checks" },
1051 {"pretend-float", &flag_pretend_float, 1,
1052 "Pretend that host and target use the same FP format"},
1053 {"schedule-insns", &flag_schedule_insns, 1,
1054 "Reschedule instructions before register allocation"},
1055 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1056 "Reschedule instructions after register allocation"},
1057 {"sched-interblock",&flag_schedule_interblock, 1,
1058 "Enable scheduling across basic blocks" },
1059 {"sched-spec",&flag_schedule_speculative, 1,
1060 "Allow speculative motion of non-loads" },
1061 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1062 "Allow speculative motion of some loads" },
1063 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1064 "Allow speculative motion of more loads" },
1065 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1066 "Replace add,compare,branch with branch on count reg"},
1067 {"pic", &flag_pic, 1,
1068 "Generate position independent code, if possible"},
1069 {"PIC", &flag_pic, 2, ""},
1070 {"exceptions", &flag_exceptions, 1,
1071 "Enable exception handling" },
1072 {"unwind-tables", &flag_unwind_tables, 1,
1073 "Just generate unwind tables for exception handling" },
1074 {"non-call-exceptions", &flag_non_call_exceptions, 1,
1075 "Support synchronous non-call exceptions" },
1076 {"profile-arcs", &profile_arc_flag, 1,
1077 "Insert arc based program profiling code" },
1078 {"test-coverage", &flag_test_coverage, 1,
1079 "Create data files needed by gcov" },
1080 {"branch-probabilities", &flag_branch_probabilities, 1,
1081 "Use profiling information for branch probabilities" },
1082 {"reorder-blocks", &flag_reorder_blocks, 1,
1083 "Reorder basic blocks to improve code placement" },
1084 {"rename-registers", &flag_rename_registers, 1,
1085 "Do the register renaming optimization pass"},
1086 {"fast-math", &flag_fast_math, 1,
1087 "Improve FP speed by violating ANSI & IEEE rules" },
1088 {"common", &flag_no_common, 0,
1089 "Do not put unitialised globals in the common section" },
1090 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1091 "Do not generate .size directives" },
1092 {"function-sections", &flag_function_sections, 1,
1093 "place each function into its own section" },
1094 {"data-sections", &flag_data_sections, 1,
1095 "place data items into their own section" },
1096 {"verbose-asm", &flag_verbose_asm, 1,
1097 "Add extra commentry to assembler output"},
1098 {"gnu-linker", &flag_gnu_linker, 1,
1099 "Output GNU ld formatted global initialisers"},
1100 {"regmove", &flag_regmove, 1,
1101 "Enables a register move optimisation"},
1102 {"optimize-register-move", &flag_regmove, 1,
1103 "Do the full regmove optimization pass"},
1104 {"pack-struct", &flag_pack_struct, 1,
1105 "Pack structure members together without holes" },
1106 {"stack-check", &flag_stack_check, 1,
1107 "Insert stack checking code into the program" },
1108 {"argument-alias", &flag_argument_noalias, 0,
1109 "Specify that arguments may alias each other & globals"},
1110 {"argument-noalias", &flag_argument_noalias, 1,
1111 "Assume arguments may alias globals but not each other"},
1112 {"argument-noalias-global", &flag_argument_noalias, 2,
1113 "Assume arguments do not alias each other or globals" },
1114 {"strict-aliasing", &flag_strict_aliasing, 1,
1115 "Assume strict aliasing rules apply" },
1116 {"align-loops", &align_loops, 0,
1117 "Align the start of loops" },
1118 {"align-jumps", &align_jumps, 0,
1119 "Align labels which are only reached by jumping" },
1120 {"align-labels", &align_labels, 0,
1121 "Align all labels" },
1122 {"align-functions", &align_functions, 0,
1123 "Align the start of functions" },
1124 {"check-memory-usage", &flag_check_memory_usage, 1,
1125 "Generate code to check every memory access" },
1126 {"prefix-function-name", &flag_prefix_function_name, 1,
1127 "Add a prefix to all function names" },
1128 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1129 "Suppress output of instruction numbers and line number notes in debugging dumps"},
1130 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1131 "Instrument function entry/exit with profiling calls"},
1132 {"ssa", &flag_ssa, 1,
1133 "Enable SSA optimizations" },
1134 {"dce", &flag_dce, 1,
1135 "Enable dead code elimination" },
1136 {"leading-underscore", &flag_leading_underscore, 1,
1137 "External symbols have a leading underscore" },
1138 {"ident", &flag_no_ident, 0,
1139 "Process #ident directives"},
1140 { "peephole2", &flag_peephole2, 1,
1141 "Enables an rtl peephole pass run before sched2" },
1142 { "guess-branch-probability", &flag_guess_branch_prob, 1,
1143 "Enables guessing of branch probabilities" },
1144 {"math-errno", &flag_errno_math, 1,
1145 "Set errno after built-in math functions"},
1146 {"bounded-pointers", &flag_bounded_pointers, 1,
1147 "Compile pointers as triples: value, base & end" },
1148 {"bounds-check", &flag_bounds_check, 1,
1149 "Generate code to check bounds before dereferencing pointers and arrays" },
1150 {"single-precision-constant", &flag_single_precision_constant, 1,
1151 "Convert floating point constant to single precision constant"},
1152 {"time-report", &time_report, 1,
1153 "Report time taken by each compiler pass at end of run"},
1154 {"mem-report", &mem_report, 1,
1155 "Report on permanent memory allocation at end of run"},
1156 { "trapv", &flag_trapv, 1,
1157 "Trap for signed overflow in addition / subtraction / multiplication." },
1160 /* Table of language-specific options. */
1162 static struct lang_opt
1164 const char *option;
1165 const char *description;
1167 documented_lang_options[] =
1169 /* In order not to overload the --help output, the convention
1170 used here is to only describe those options which are not
1171 enabled by default. */
1173 { "-ansi", "Compile just for ISO C89" },
1174 { "-fallow-single-precision",
1175 "Do not promote floats to double if using -traditional" },
1176 { "-std= ", "Determine language standard"},
1178 { "-fsigned-bitfields", "" },
1179 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1180 { "-fno-signed-bitfields", "" },
1181 { "-fno-unsigned-bitfields","" },
1182 { "-fsigned-char", "Make 'char' be signed by default"},
1183 { "-funsigned-char", "Make 'char' be unsigned by default"},
1184 { "-fno-signed-char", "" },
1185 { "-fno-unsigned-char", "" },
1187 { "-ftraditional", "" },
1188 { "-traditional", "Attempt to support traditional K&R style C"},
1189 { "-fnotraditional", "" },
1190 { "-fno-traditional", "" },
1192 { "-fasm", "" },
1193 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1194 { "-fbuiltin", "" },
1195 { "-fno-builtin", "Do not recognise any built in functions" },
1196 { "-fhosted", "Assume normal C execution environment" },
1197 { "-fno-hosted", "" },
1198 { "-ffreestanding",
1199 "Assume that standard libraries & main might not exist" },
1200 { "-fno-freestanding", "" },
1201 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1202 { "-fno-cond-mismatch", "" },
1203 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1204 { "-fno-dollars-in-identifiers", "" },
1205 { "-fpreprocessed", "" },
1206 { "-fno-preprocessed", "" },
1207 { "-fshort-double", "Use the same size for double as for float" },
1208 { "-fno-short-double", "" },
1209 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1210 { "-fno-short-enums", "" },
1211 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1212 { "-fno-short-wchar", "" },
1214 { "-Wall", "Enable most warning messages" },
1215 { "-Wbad-function-cast",
1216 "Warn about casting functions to incompatible types" },
1217 { "-Wno-bad-function-cast", "" },
1218 { "-Wno-missing-noreturn", "" },
1219 { "-Wmissing-format-attribute",
1220 "Warn about functions which might be candidates for format attributes" },
1221 { "-Wno-missing-format-attribute", "" },
1222 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1223 { "-Wno-cast-qual", "" },
1224 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1225 { "-Wno-char-subscripts", "" },
1226 { "-Wcomment", "Warn if nested comments are detected" },
1227 { "-Wno-comment", "" },
1228 { "-Wcomments", "Warn if nested comments are detected" },
1229 { "-Wno-comments", "" },
1230 { "-Wconversion", "Warn about possibly confusing type conversions" },
1231 { "-Wno-conversion", "" },
1232 { "-Wformat", "Warn about printf/scanf/strftime/strfmon format anomalies" },
1233 { "-Wno-format", "" },
1234 { "-Wformat-y2k", "" },
1235 { "-Wno-format-y2k",
1236 "Don't warn about strftime formats yielding 2 digit years" },
1237 { "-Wformat-extra-args", "" },
1238 { "-Wno-format-extra-args",
1239 "Don't warn about too many arguments to format functions" },
1240 { "-Wformat-nonliteral", "Warn about non-string-literal format strings" },
1241 { "-Wno-format-nonliteral", "" },
1242 { "-Wformat-security",
1243 "Warn about possible security problems with format functions" },
1244 { "-Wno-format-security", "" },
1245 { "-Wimplicit-function-declaration",
1246 "Warn about implicit function declarations" },
1247 { "-Wno-implicit-function-declaration", "" },
1248 { "-Werror-implicit-function-declaration", "" },
1249 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1250 { "-Wno-implicit-int", "" },
1251 { "-Wimplicit", "" },
1252 { "-Wno-implicit", "" },
1253 { "-Wimport", "Warn about the use of the #import directive" },
1254 { "-Wno-import", "" },
1255 { "-Wlong-long","" },
1256 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1257 { "-Wmain", "Warn about suspicious declarations of main" },
1258 { "-Wno-main", "" },
1259 { "-Wmissing-braces",
1260 "Warn about possibly missing braces around initialisers" },
1261 { "-Wno-missing-braces", "" },
1262 { "-Wmissing-declarations",
1263 "Warn about global funcs without previous declarations"},
1264 { "-Wno-missing-declarations", "" },
1265 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1266 { "-Wno-missing-prototypes", "" },
1267 { "-Wmultichar", "Warn about use of multicharacter literals"},
1268 { "-Wno-multichar", "" },
1269 { "-Wnested-externs", "Warn about externs not at file scope level" },
1270 { "-Wno-nested-externs", "" },
1271 { "-Wparentheses", "Warn about possible missing parentheses" },
1272 { "-Wno-parentheses", "" },
1273 { "-Wsequence-point",
1274 "Warn about possible violations of sequence point rules" },
1275 { "-Wno-sequence-point", "" },
1276 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1277 { "-Wno-pointer-arith", "" },
1278 { "-Wredundant-decls",
1279 "Warn about multiple declarations of the same object" },
1280 { "-Wno-redundant-decls", "" },
1281 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1282 { "-Wno-sign-compare", "" },
1283 { "-Wfloat-equal", "Warn about testing equality of floating point numbers" },
1284 { "-Wno-float-equal", "" },
1285 { "-Wunknown-pragmas", "Warn about unrecognized pragmas" },
1286 { "-Wno-unknown-pragmas", "" },
1287 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1288 { "-Wno-strict-prototypes", "" },
1289 { "-Wtraditional", "Warn about constructs whose meaning change in ISO C"},
1290 { "-Wno-traditional", "" },
1291 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1292 { "-Wno-trigraphs", "" },
1293 { "-Wundef", "" },
1294 { "-Wno-undef", "" },
1295 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1296 { "-Wno-write-strings", "" },
1298 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1300 #include "options.h"
1304 /* Here is a table, controlled by the tm.h file, listing each -m switch
1305 and which bits in `target_switches' it should set or clear.
1306 If VALUE is positive, it is bits to set.
1307 If VALUE is negative, -VALUE is bits to clear.
1308 (The sign bit is not used so there is no confusion.) */
1310 struct
1312 const char *name;
1313 int value;
1314 const char *description;
1316 target_switches [] = TARGET_SWITCHES;
1318 /* This table is similar, but allows the switch to have a value. */
1320 #ifdef TARGET_OPTIONS
1321 struct
1323 const char *prefix;
1324 const char **variable;
1325 const char *description;
1327 target_options [] = TARGET_OPTIONS;
1328 #endif
1330 /* Options controlling warnings. */
1332 /* Don't print warning messages. -w. */
1334 int inhibit_warnings = 0;
1336 /* Don't suppress warnings from system headers. -Wsystem-headers. */
1338 int warn_system_headers = 0;
1340 /* Print various extra warnings. -W. */
1342 int extra_warnings = 0;
1344 /* Treat warnings as errors. -Werror. */
1346 int warnings_are_errors = 0;
1348 /* Nonzero to warn about unused variables, functions et.al. */
1350 int warn_unused_function;
1351 int warn_unused_label;
1352 int warn_unused_parameter;
1353 int warn_unused_variable;
1354 int warn_unused_value;
1356 void
1357 set_Wunused (setting)
1358 int setting;
1360 warn_unused_function = setting;
1361 warn_unused_label = setting;
1362 /* Unused function parameter warnings are reported when either ``-W
1363 -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
1364 -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
1365 if (!setting)
1366 warn_unused_parameter = 0;
1367 else if (!warn_unused_parameter)
1368 warn_unused_parameter = -1;
1369 warn_unused_variable = setting;
1370 warn_unused_value = setting;
1373 /* Nonzero to warn about code which is never reached. */
1375 int warn_notreached;
1377 /* Nonzero to warn about variables used before they are initialized. */
1379 int warn_uninitialized;
1381 /* Nonzero means warn about all declarations which shadow others. */
1383 int warn_shadow;
1385 /* Warn if a switch on an enum fails to have a case for every enum value. */
1387 int warn_switch;
1389 /* Nonzero means warn about function definitions that default the return type
1390 or that use a null return and have a return-type other than void. */
1392 int warn_return_type;
1394 /* Nonzero means warn about pointer casts that increase the required
1395 alignment of the target type (and might therefore lead to a crash
1396 due to a misaligned access). */
1398 int warn_cast_align;
1400 /* Nonzero means warn about any identifiers that match in the first N
1401 characters. The value N is in `id_clash_len'. */
1403 int warn_id_clash;
1404 int id_clash_len;
1406 /* Nonzero means warn about any objects definitions whose size is larger
1407 than N bytes. Also want about function definitions whose returned
1408 values are larger than N bytes. The value N is in `larger_than_size'. */
1410 int warn_larger_than;
1411 HOST_WIDE_INT larger_than_size;
1413 /* Nonzero means warn if inline function is too large. */
1415 int warn_inline;
1417 /* Warn if a function returns an aggregate,
1418 since there are often incompatible calling conventions for doing this. */
1420 int warn_aggregate_return;
1422 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1424 int warn_packed;
1426 /* Warn when gcc pads a structure to an alignment boundary. */
1428 int warn_padded;
1430 /* Warn when an optimization pass is disabled. */
1432 int warn_disabled_optimization;
1434 /* Warn about functions which might be candidates for attribute noreturn. */
1436 int warn_missing_noreturn;
1438 /* Likewise for -W. */
1440 lang_independent_options W_options[] =
1442 {"unused-function", &warn_unused_function, 1, "Warn when a function is unused" },
1443 {"unused-label", &warn_unused_label, 1, "Warn when a label is unused" },
1444 {"unused-parameter", &warn_unused_parameter, 1, "Warn when a function parameter is unused" },
1445 {"unused-variable", &warn_unused_variable, 1, "Warn when a variable is unused" },
1446 {"unused-value", &warn_unused_value, 1, "Warn when an expression value is unused" },
1447 {"system-headers", &warn_system_headers, 1, "Do not suppress warnings from system headers"},
1448 {"error", &warnings_are_errors, 1, ""},
1449 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1450 {"switch", &warn_switch, 1,
1451 "Warn about enumerated switches missing a specific case" },
1452 {"aggregate-return", &warn_aggregate_return, 1,
1453 "Warn about returning structures, unions or arrays" },
1454 {"cast-align", &warn_cast_align, 1,
1455 "Warn about pointer casts which increase alignment" },
1456 {"unreachable-code", &warn_notreached, 1,
1457 "Warn about code that will never be executed" },
1458 {"uninitialized", &warn_uninitialized, 1,
1459 "Warn about unitialized automatic variables"},
1460 {"inline", &warn_inline, 1,
1461 "Warn when an inlined function cannot be inlined"},
1462 {"packed", &warn_packed, 1,
1463 "Warn when the packed attribute has no effect on struct layout"},
1464 {"padded", &warn_padded, 1,
1465 "Warn when padding is required to align struct members"},
1466 {"disabled-optimization", &warn_disabled_optimization, 1,
1467 "Warn when an optimization pass is disabled"},
1468 {"missing-noreturn", &warn_missing_noreturn, 1,
1469 "Warn about functions which might be candidates for attribute noreturn"}
1472 /* Output files for assembler code (real compiler output)
1473 and debugging dumps. */
1475 FILE *asm_out_file;
1476 FILE *aux_info_file;
1477 FILE *rtl_dump_file = NULL;
1479 /* Decode the string P as an integral parameter.
1480 If the string is indeed an integer return its numeric value else
1481 issue an Invalid Option error for the option PNAME and return DEFVAL.
1482 If PNAME is zero just return DEFVAL, do not call error. */
1485 read_integral_parameter (p, pname, defval)
1486 const char *p;
1487 const char *pname;
1488 const int defval;
1490 const char *endp = p;
1492 while (*endp)
1494 if (*endp >= '0' && *endp <= '9')
1495 endp++;
1496 else
1497 break;
1500 if (*endp != 0)
1502 if (pname != 0)
1503 error ("Invalid option `%s'", pname);
1504 return defval;
1507 return atoi (p);
1511 /* This is the default decl_printable_name function. */
1513 static const char *
1514 decl_name (decl, verbosity)
1515 tree decl;
1516 int verbosity ATTRIBUTE_UNUSED;
1518 return IDENTIFIER_POINTER (DECL_NAME (decl));
1522 /* This calls abort and is used to avoid problems when abort if a macro.
1523 It is used when we need to pass the address of abort. */
1525 void
1526 do_abort ()
1528 abort ();
1531 /* When `malloc.c' is compiled with `rcheck' defined,
1532 it calls this function to report clobberage. */
1534 void
1535 botch (s)
1536 const char *s ATTRIBUTE_UNUSED;
1538 abort ();
1541 /* Return the logarithm of X, base 2, considering X unsigned,
1542 if X is a power of 2. Otherwise, returns -1.
1544 This should be used via the `exact_log2' macro. */
1547 exact_log2_wide (x)
1548 register unsigned HOST_WIDE_INT x;
1550 register int log = 0;
1551 /* Test for 0 or a power of 2. */
1552 if (x == 0 || x != (x & -x))
1553 return -1;
1554 while ((x >>= 1) != 0)
1555 log++;
1556 return log;
1559 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1560 If X is 0, return -1.
1562 This should be used via the floor_log2 macro. */
1565 floor_log2_wide (x)
1566 register unsigned HOST_WIDE_INT x;
1568 register int log = -1;
1569 while (x != 0)
1570 log++,
1571 x >>= 1;
1572 return log;
1575 /* Return the approximate positive square root of a number N. This is for
1576 statistical reports, not code generation. */
1577 double
1578 approx_sqrt (x)
1579 double x;
1581 double s, d;
1583 if (x < 0)
1584 abort ();
1585 if (x == 0)
1586 return 0;
1588 s = x;
1591 d = (s * s - x) / (2 * s);
1592 s -= d;
1594 while (d > .0001);
1595 return s;
1598 static int float_handler_set;
1599 int float_handled;
1600 jmp_buf float_handler;
1602 /* Signals actually come here. */
1604 static void
1605 float_signal (signo)
1606 /* If this is missing, some compilers complain. */
1607 int signo ATTRIBUTE_UNUSED;
1609 if (float_handled == 0)
1610 crash_signal (signo);
1611 #if defined (USG) || defined (hpux)
1612 /* Re-enable the signal catcher. */
1613 signal (SIGFPE, float_signal);
1614 #endif
1615 float_handled = 0;
1616 signal (SIGFPE, float_signal);
1617 longjmp (float_handler, 1);
1620 /* Specify where to longjmp to when a floating arithmetic error happens.
1621 If HANDLER is 0, it means don't handle the errors any more. */
1623 void
1624 set_float_handler (handler)
1625 jmp_buf handler;
1627 float_handled = (handler != 0);
1628 if (handler)
1629 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1631 if (float_handled && ! float_handler_set)
1633 signal (SIGFPE, float_signal);
1634 float_handler_set = 1;
1638 /* This is a wrapper function for code which might elicit an
1639 arithmetic exception. That code should be passed in as a function
1640 pointer FN, and one argument DATA. DATA is usually a struct which
1641 contains the real input and output for function FN. This function
1642 returns 0 (failure) if longjmp was called (i.e. an exception
1643 occured.) It returns 1 (success) otherwise. */
1646 do_float_handler (fn, data)
1647 void (*fn) PARAMS ((PTR));
1648 PTR data;
1650 jmp_buf buf;
1652 if (setjmp (buf))
1654 /* We got here via longjmp () caused by an exception in function
1655 fn (). */
1656 set_float_handler (NULL);
1657 return 0;
1660 set_float_handler (buf);
1661 (*fn)(data);
1662 set_float_handler (NULL);
1663 return 1;
1666 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1667 error happens, pushing the previous specification into OLD_HANDLER.
1668 Return an indication of whether there was a previous handler in effect. */
1671 push_float_handler (handler, old_handler)
1672 jmp_buf handler, old_handler;
1674 int was_handled = float_handled;
1676 float_handled = 1;
1677 if (was_handled)
1678 memcpy ((char *) old_handler, (char *) float_handler,
1679 sizeof (float_handler));
1681 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
1682 return was_handled;
1685 /* Restore the previous specification of whether and where to longjmp to
1686 when a floating arithmetic error happens. */
1688 void
1689 pop_float_handler (handled, handler)
1690 int handled;
1691 jmp_buf handler;
1693 float_handled = handled;
1694 if (handled)
1695 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1698 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1699 into ICE messages, which is much more user friendly. */
1701 static void
1702 crash_signal (signo)
1703 int signo;
1705 internal_error ("Internal error: %s", strsignal (signo));
1708 /* Strip off a legitimate source ending from the input string NAME of
1709 length LEN. Rather than having to know the names used by all of
1710 our front ends, we strip off an ending of a period followed by
1711 up to five characters. (Java uses ".class".) */
1713 void
1714 strip_off_ending (name, len)
1715 char *name;
1716 int len;
1718 int i;
1719 for (i = 2; i < 6 && len > i; i++)
1721 if (name[len - i] == '.')
1723 name[len - i] = '\0';
1724 break;
1729 /* Given a file name X, return the nondirectory portion. */
1731 char *
1732 file_name_nondirectory (x)
1733 const char *x;
1735 char *tmp = (char *) strrchr (x, '/');
1736 if (DIR_SEPARATOR != '/' && ! tmp)
1737 tmp = (char *) strrchr (x, DIR_SEPARATOR);
1738 if (tmp)
1739 return (char *) (tmp + 1);
1740 else
1741 return (char *) x;
1744 /* Output a quoted string. */
1746 void
1747 output_quoted_string (asm_file, string)
1748 FILE *asm_file;
1749 const char *string;
1751 #ifdef OUTPUT_QUOTED_STRING
1752 OUTPUT_QUOTED_STRING (asm_file, string);
1753 #else
1754 char c;
1756 putc ('\"', asm_file);
1757 while ((c = *string++) != 0)
1759 if (c == '\"' || c == '\\')
1760 putc ('\\', asm_file);
1761 putc (c, asm_file);
1763 putc ('\"', asm_file);
1764 #endif
1767 /* Output a file name in the form wanted by System V. */
1769 void
1770 output_file_directive (asm_file, input_name)
1771 FILE *asm_file;
1772 const char *input_name;
1774 int len = strlen (input_name);
1775 const char *na = input_name + len;
1777 /* NA gets INPUT_NAME sans directory names. */
1778 while (na > input_name)
1780 if (IS_DIR_SEPARATOR (na[-1]))
1781 break;
1782 na--;
1785 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1786 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1787 #else
1788 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1789 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1790 #else
1791 fprintf (asm_file, "\t.file\t");
1792 output_quoted_string (asm_file, na);
1793 fputc ('\n', asm_file);
1794 #endif
1795 #endif
1798 /* Routine to open a dump file. Return true if the dump file is enabled. */
1800 static int
1801 open_dump_file (index, decl)
1802 enum dump_file_index index;
1803 tree decl;
1805 char *dump_name;
1806 const char *open_arg;
1807 char seq[16];
1809 if (! dump_file[index].enabled)
1810 return 0;
1812 timevar_push (TV_DUMP);
1813 if (rtl_dump_file != NULL)
1814 fclose (rtl_dump_file);
1816 sprintf (seq, ".%02d.", index);
1818 if (! dump_file[index].initialized)
1820 /* If we've not initialized the files, do so now. */
1821 if (graph_dump_format != no_graph
1822 && dump_file[index].graph_dump_p)
1824 dump_name = concat (seq, dump_file[index].extension, NULL);
1825 clean_graph_dump_file (dump_base_name, dump_name);
1826 free (dump_name);
1828 dump_file[index].initialized = 1;
1829 open_arg = "w";
1831 else
1832 open_arg = "a";
1834 dump_name = concat (dump_base_name, seq,
1835 dump_file[index].extension, NULL);
1837 rtl_dump_file = fopen (dump_name, open_arg);
1838 if (rtl_dump_file == NULL)
1839 fatal_io_error ("can't open %s", dump_name);
1841 free (dump_name);
1843 if (decl)
1844 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1845 decl_printable_name (decl, 2));
1847 timevar_pop (TV_DUMP);
1848 return 1;
1851 /* Routine to close a dump file. */
1853 static void
1854 close_dump_file (index, func, insns)
1855 enum dump_file_index index;
1856 void (*func) PARAMS ((FILE *, rtx));
1857 rtx insns;
1859 if (! rtl_dump_file)
1860 return;
1862 timevar_push (TV_DUMP);
1863 if (insns
1864 && graph_dump_format != no_graph
1865 && dump_file[index].graph_dump_p)
1867 char seq[16];
1868 char *suffix;
1870 sprintf (seq, ".%02d.", index);
1871 suffix = concat (seq, dump_file[index].extension, NULL);
1872 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1873 free (suffix);
1876 if (func && insns)
1877 func (rtl_dump_file, insns);
1879 fflush (rtl_dump_file);
1880 fclose (rtl_dump_file);
1882 rtl_dump_file = NULL;
1883 timevar_pop (TV_DUMP);
1886 /* Do any final processing required for the declarations in VEC, of
1887 which there are LEN. We write out inline functions and variables
1888 that have been deferred until this point, but which are required.
1889 Returns non-zero if anything was put out. */
1892 wrapup_global_declarations (vec, len)
1893 tree *vec;
1894 int len;
1896 tree decl;
1897 int i;
1898 int reconsider;
1899 int output_something = 0;
1901 for (i = 0; i < len; i++)
1903 decl = vec[i];
1905 /* We're not deferring this any longer. */
1906 DECL_DEFER_OUTPUT (decl) = 0;
1908 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
1909 && incomplete_decl_finalize_hook != 0)
1910 (*incomplete_decl_finalize_hook) (decl);
1913 /* Now emit any global variables or functions that we have been
1914 putting off. We need to loop in case one of the things emitted
1915 here references another one which comes earlier in the list. */
1918 reconsider = 0;
1919 for (i = 0; i < len; i++)
1921 decl = vec[i];
1923 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1924 continue;
1926 /* Don't write out static consts, unless we still need them.
1928 We also keep static consts if not optimizing (for debugging),
1929 unless the user specified -fno-keep-static-consts.
1930 ??? They might be better written into the debug information.
1931 This is possible when using DWARF.
1933 A language processor that wants static constants to be always
1934 written out (even if it is not used) is responsible for
1935 calling rest_of_decl_compilation itself. E.g. the C front-end
1936 calls rest_of_decl_compilation from finish_decl.
1937 One motivation for this is that is conventional in some
1938 environments to write things like:
1939 static const char rcsid[] = "... version string ...";
1940 intending to force the string to be in the executable.
1942 A language processor that would prefer to have unneeded
1943 static constants "optimized away" would just defer writing
1944 them out until here. E.g. C++ does this, because static
1945 constants are often defined in header files.
1947 ??? A tempting alternative (for both C and C++) would be
1948 to force a constant to be written if and only if it is
1949 defined in a main file, as opposed to an include file. */
1951 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1952 && (! TREE_READONLY (decl)
1953 || TREE_PUBLIC (decl)
1954 || (!optimize
1955 && flag_keep_static_consts
1956 && !DECL_ARTIFICIAL (decl))
1957 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1959 reconsider = 1;
1960 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1963 if (TREE_CODE (decl) == FUNCTION_DECL
1964 && DECL_INITIAL (decl) != 0
1965 && DECL_SAVED_INSNS (decl) != 0
1966 && (flag_keep_inline_functions
1967 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1968 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1970 reconsider = 1;
1971 output_inline_function (decl);
1975 if (reconsider)
1976 output_something = 1;
1978 while (reconsider);
1980 return output_something;
1983 /* Issue appropriate warnings for the global declarations in VEC (of
1984 which there are LEN). Output debugging information for them. */
1986 void
1987 check_global_declarations (vec, len)
1988 tree *vec;
1989 int len;
1991 tree decl;
1992 int i;
1994 for (i = 0; i < len; i++)
1996 decl = vec[i];
1998 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1999 && ! TREE_ASM_WRITTEN (decl))
2000 /* Cancel the RTL for this decl so that, if debugging info
2001 output for global variables is still to come,
2002 this one will be omitted. */
2003 SET_DECL_RTL (decl, NULL_RTX);
2005 /* Warn about any function
2006 declared static but not defined.
2007 We don't warn about variables,
2008 because many programs have static variables
2009 that exist only to get some text into the object file. */
2010 if (TREE_CODE (decl) == FUNCTION_DECL
2011 && (warn_unused_function
2012 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2013 && DECL_INITIAL (decl) == 0
2014 && DECL_EXTERNAL (decl)
2015 && ! DECL_ARTIFICIAL (decl)
2016 && ! TREE_PUBLIC (decl))
2018 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2019 pedwarn_with_decl (decl,
2020 "`%s' used but never defined");
2021 else
2022 warning_with_decl (decl,
2023 "`%s' declared `static' but never defined");
2024 /* This symbol is effectively an "extern" declaration now. */
2025 TREE_PUBLIC (decl) = 1;
2026 assemble_external (decl);
2029 /* Warn about static fns or vars defined but not used,
2030 but not about inline functions or static consts
2031 since defining those in header files is normal practice. */
2032 if (((warn_unused_function
2033 && TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2034 || (warn_unused_variable
2035 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2036 && ! DECL_IN_SYSTEM_HEADER (decl)
2037 && ! DECL_EXTERNAL (decl)
2038 && ! TREE_PUBLIC (decl)
2039 && ! TREE_USED (decl)
2040 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2041 /* The TREE_USED bit for file-scope decls
2042 is kept in the identifier, to handle multiple
2043 external decls in different scopes. */
2044 && ! TREE_USED (DECL_NAME (decl)))
2045 warning_with_decl (decl, "`%s' defined but not used");
2047 timevar_push (TV_SYMOUT);
2048 #ifdef SDB_DEBUGGING_INFO
2049 /* The COFF linker can move initialized global vars to the end.
2050 And that can screw up the symbol ordering.
2051 By putting the symbols in that order to begin with,
2052 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2053 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2054 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2055 && ! DECL_EXTERNAL (decl)
2056 && DECL_RTL (decl) != 0)
2057 sdbout_symbol (decl, 0);
2059 /* Output COFF information for non-global
2060 file-scope initialized variables. */
2061 if (write_symbols == SDB_DEBUG
2062 && TREE_CODE (decl) == VAR_DECL
2063 && DECL_INITIAL (decl)
2064 && ! DECL_EXTERNAL (decl)
2065 && DECL_RTL (decl) != 0
2066 && GET_CODE (DECL_RTL (decl)) == MEM)
2067 sdbout_toplevel_data (decl);
2068 #endif /* SDB_DEBUGGING_INFO */
2069 #ifdef DWARF_DEBUGGING_INFO
2070 /* Output DWARF information for file-scope tentative data object
2071 declarations, file-scope (extern) function declarations (which
2072 had no corresponding body) and file-scope tagged type declarations
2073 and definitions which have not yet been forced out. */
2075 if (write_symbols == DWARF_DEBUG
2076 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2077 dwarfout_file_scope_decl (decl, 1);
2078 #endif
2079 #ifdef DWARF2_DEBUGGING_INFO
2080 /* Output DWARF2 information for file-scope tentative data object
2081 declarations, file-scope (extern) function declarations (which
2082 had no corresponding body) and file-scope tagged type declarations
2083 and definitions which have not yet been forced out. */
2085 if (write_symbols == DWARF2_DEBUG
2086 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2087 dwarf2out_decl (decl);
2088 #endif
2089 timevar_pop (TV_SYMOUT);
2093 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2094 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2095 INPUT_FILENAME and LINENO accordingly. */
2097 void
2098 push_srcloc (file, line)
2099 const char *file;
2100 int line;
2102 struct file_stack *fs;
2104 if (input_file_stack)
2106 input_file_stack->name = input_filename;
2107 input_file_stack->line = lineno;
2110 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2111 fs->name = input_filename = file;
2112 fs->line = lineno = line;
2113 fs->indent_level = 0;
2114 fs->next = input_file_stack;
2115 input_file_stack = fs;
2116 input_file_stack_tick++;
2119 /* Pop the top entry off the stack of presently open source files.
2120 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2121 the stack. */
2123 void
2124 pop_srcloc ()
2126 struct file_stack *fs;
2128 fs = input_file_stack;
2129 input_file_stack = fs->next;
2130 free (fs);
2131 input_file_stack_tick++;
2132 /* The initial source file is never popped. */
2133 if (!input_file_stack)
2134 abort ();
2135 input_filename = input_file_stack->name;
2136 lineno = input_file_stack->line;
2139 /* Compile an entire file of output from cpp, named NAME.
2140 Write a file of assembly output and various debugging dumps. */
2142 static void
2143 compile_file (name)
2144 const char *name;
2146 tree globals;
2148 int name_specified = name != 0;
2150 if (dump_base_name == 0)
2151 dump_base_name = name ? name : "gccdump";
2153 if (! quiet_flag)
2154 time_report = 1;
2156 /* Start timing total execution time. */
2158 init_timevar ();
2159 timevar_start (TV_TOTAL);
2161 /* Initialize data in various passes. */
2163 init_obstacks ();
2164 name = init_parse (name);
2165 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2166 || debug_info_level == DINFO_LEVEL_VERBOSE
2167 || flag_test_coverage
2168 || warn_notreached);
2169 init_regs ();
2170 init_alias_once ();
2171 init_decl_processing ();
2172 init_eh ();
2173 init_optabs ();
2174 init_stmt ();
2175 init_loop ();
2176 init_reload ();
2177 init_function_once ();
2178 init_stor_layout_once ();
2179 init_varasm_once ();
2181 /* The following initialization functions need to generate rtl, so
2182 provide a dummy function context for them. */
2183 init_dummy_function_start ();
2184 init_expmed ();
2185 init_expr_once ();
2186 if (flag_caller_saves)
2187 init_caller_save ();
2188 expand_dummy_function_end ();
2190 /* If auxiliary info generation is desired, open the output file.
2191 This goes in the same directory as the source file--unlike
2192 all the other output files. */
2193 if (flag_gen_aux_info)
2195 aux_info_file = fopen (aux_info_file_name, "w");
2196 if (aux_info_file == 0)
2197 fatal_io_error ("can't open %s", aux_info_file_name);
2200 /* Open assembler code output file. Do this even if -fsyntax-only is on,
2201 because then the driver will have provided the name of a temporary
2202 file or bit bucket for us. */
2204 if (! name_specified && asm_file_name == 0)
2205 asm_out_file = stdout;
2206 else
2208 if (asm_file_name == 0)
2210 int len = strlen (dump_base_name);
2211 char *dumpname = (char *) xmalloc (len + 6);
2212 memcpy (dumpname, dump_base_name, len + 1);
2213 strip_off_ending (dumpname, len);
2214 strcat (dumpname, ".s");
2215 asm_file_name = dumpname;
2217 if (!strcmp (asm_file_name, "-"))
2218 asm_out_file = stdout;
2219 else
2220 asm_out_file = fopen (asm_file_name, "w");
2221 if (asm_out_file == 0)
2222 fatal_io_error ("can't open %s for writing", asm_file_name);
2225 #ifdef IO_BUFFER_SIZE
2226 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2227 _IOFBF, IO_BUFFER_SIZE);
2228 #endif
2230 if (name != 0)
2231 name = ggc_strdup (name);
2233 input_filename = name;
2235 /* Put an entry on the input file stack for the main input file. */
2236 push_srcloc (input_filename, 0);
2238 /* Perform language-specific initialization.
2239 This may set main_input_filename. */
2240 if (lang_hooks.init)
2241 (*lang_hooks.init) ();
2243 /* If the input doesn't start with a #line, use the input name
2244 as the official input file name. */
2245 if (main_input_filename == 0)
2246 main_input_filename = name;
2248 if (flag_syntax_only)
2250 write_symbols = NO_DEBUG;
2251 profile_flag = 0;
2252 profile_block_flag = 0;
2254 else
2256 ASM_FILE_START (asm_out_file);
2258 #ifdef ASM_COMMENT_START
2259 if (flag_verbose_asm)
2261 /* Print the list of options in effect. */
2262 print_version (asm_out_file, ASM_COMMENT_START);
2263 print_switch_values (asm_out_file, 0, MAX_LINE,
2264 ASM_COMMENT_START, " ", "\n");
2265 /* Add a blank line here so it appears in assembler output but not
2266 screen output. */
2267 fprintf (asm_out_file, "\n");
2269 #endif
2270 } /* ! flag_syntax_only */
2272 #ifndef ASM_OUTPUT_SECTION_NAME
2273 if (flag_function_sections)
2275 warning ("-ffunction-sections not supported for this target.");
2276 flag_function_sections = 0;
2278 if (flag_data_sections)
2280 warning ("-fdata-sections not supported for this target.");
2281 flag_data_sections = 0;
2283 #endif
2285 if (flag_function_sections
2286 && (profile_flag || profile_block_flag))
2288 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2289 flag_function_sections = 0;
2292 #ifndef OBJECT_FORMAT_ELF
2293 if (flag_function_sections && write_symbols != NO_DEBUG)
2294 warning ("-ffunction-sections may affect debugging on some targets.");
2295 #endif
2297 /* If dbx symbol table desired, initialize writing it
2298 and output the predefined types. */
2299 timevar_push (TV_SYMOUT);
2300 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2301 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2302 dbxout_init (asm_out_file, main_input_filename, getdecls ());
2303 #endif
2304 #ifdef SDB_DEBUGGING_INFO
2305 if (write_symbols == SDB_DEBUG)
2306 sdbout_init (asm_out_file, main_input_filename, getdecls ());
2307 #endif
2308 #ifdef DWARF_DEBUGGING_INFO
2309 if (write_symbols == DWARF_DEBUG)
2310 dwarfout_init (asm_out_file, main_input_filename);
2311 #endif
2312 #ifdef DWARF2_UNWIND_INFO
2313 if (dwarf2out_do_frame ())
2314 dwarf2out_frame_init ();
2315 #endif
2316 #ifdef DWARF2_DEBUGGING_INFO
2317 if (write_symbols == DWARF2_DEBUG)
2318 dwarf2out_init (asm_out_file, main_input_filename);
2319 #endif
2320 timevar_pop (TV_SYMOUT);
2322 /* Initialize yet another pass. */
2324 init_final (main_input_filename);
2325 init_branch_prob (dump_base_name);
2327 timevar_push (TV_PARSE);
2329 /* Call the parser, which parses the entire file
2330 (calling rest_of_compilation for each function). */
2332 if (yyparse () != 0)
2334 if (errorcount == 0)
2335 fnotice (stderr, "Errors detected in input file (your bison.simple is out of date)\n");
2337 /* In case there were missing closebraces,
2338 get us back to the global binding level. */
2339 while (! global_bindings_p ())
2340 poplevel (0, 0, 0);
2343 /* Compilation is now finished except for writing
2344 what's left of the symbol table output. */
2346 timevar_pop (TV_PARSE);
2348 if (flag_syntax_only)
2349 goto finish_syntax;
2351 globals = getdecls ();
2353 /* Really define vars that have had only a tentative definition.
2354 Really output inline functions that must actually be callable
2355 and have not been output so far. */
2358 int len = list_length (globals);
2359 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2360 int i;
2361 tree decl;
2363 /* Process the decls in reverse order--earliest first.
2364 Put them into VEC from back to front, then take out from front. */
2366 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2367 vec[len - i - 1] = decl;
2369 wrapup_global_declarations (vec, len);
2371 /* This must occur after the loop to output deferred functions. Else
2372 the profiler initializer would not be emitted if all the functions
2373 in this compilation unit were deferred.
2375 output_func_start_profiler can not cause any additional functions or
2376 data to need to be output, so it need not be in the deferred function
2377 loop above. */
2378 output_func_start_profiler ();
2380 check_global_declarations (vec, len);
2382 /* Clean up. */
2383 free (vec);
2386 /* Write out any pending weak symbol declarations. */
2388 weak_finish ();
2390 /* Do dbx symbols. */
2391 timevar_push (TV_SYMOUT);
2392 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2393 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2394 dbxout_finish (asm_out_file, main_input_filename);
2395 #endif
2397 #ifdef DWARF_DEBUGGING_INFO
2398 if (write_symbols == DWARF_DEBUG)
2399 dwarfout_finish ();
2400 #endif
2402 #ifdef DWARF2_UNWIND_INFO
2403 if (dwarf2out_do_frame ())
2404 dwarf2out_frame_finish ();
2405 #endif
2407 #ifdef DWARF2_DEBUGGING_INFO
2408 if (write_symbols == DWARF2_DEBUG)
2409 dwarf2out_finish ();
2410 #endif
2411 timevar_pop (TV_SYMOUT);
2413 /* Output some stuff at end of file if nec. */
2415 dw2_output_indirect_constants ();
2417 end_final (dump_base_name);
2419 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2421 timevar_push (TV_DUMP);
2422 open_dump_file (DFI_bp, NULL);
2424 end_branch_prob ();
2426 close_dump_file (DFI_bp, NULL, NULL_RTX);
2427 timevar_pop (TV_DUMP);
2430 #ifdef ASM_FILE_END
2431 ASM_FILE_END (asm_out_file);
2432 #endif
2434 /* Attach a special .ident directive to the end of the file to identify
2435 the version of GCC which compiled this code. The format of the .ident
2436 string is patterned after the ones produced by native SVR4 compilers. */
2437 #ifdef IDENT_ASM_OP
2438 if (!flag_no_ident)
2439 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2440 IDENT_ASM_OP, version_string);
2441 #endif
2443 /* Language-specific end of compilation actions. */
2444 finish_syntax:
2445 if (lang_hooks.finish)
2446 (*lang_hooks.finish) ();
2448 /* Close the dump files. */
2450 if (flag_gen_aux_info)
2452 fclose (aux_info_file);
2453 if (errorcount)
2454 unlink (aux_info_file_name);
2457 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2459 timevar_push (TV_DUMP);
2460 dump_combine_total_stats (rtl_dump_file);
2461 close_dump_file (DFI_combine, NULL, NULL_RTX);
2462 timevar_pop (TV_DUMP);
2465 /* Close non-debugging input and output files. Take special care to note
2466 whether fclose returns an error, since the pages might still be on the
2467 buffer chain while the file is open. */
2469 finish_parse ();
2471 if (ferror (asm_out_file) != 0)
2472 fatal_io_error ("error writing to %s", asm_file_name);
2473 if (fclose (asm_out_file) != 0)
2474 fatal_io_error ("error closing %s", asm_file_name);
2476 /* Do whatever is necessary to finish printing the graphs. */
2477 if (graph_dump_format != no_graph)
2479 int i;
2481 for (i = 0; i < (int) DFI_MAX; ++i)
2482 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
2484 char seq[16];
2485 char *suffix;
2487 sprintf (seq, ".%02d.", i);
2488 suffix = concat (seq, dump_file[i].extension, NULL);
2489 finish_graph_dump_file (dump_base_name, suffix);
2490 free (suffix);
2494 if (mem_report)
2496 ggc_print_statistics ();
2497 stringpool_statistics ();
2500 /* Free up memory for the benefit of leak detectors. */
2501 free_reg_info ();
2503 /* Stop timing total execution time. */
2504 timevar_stop (TV_TOTAL);
2506 /* Print the times. */
2508 timevar_print (stderr);
2511 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2512 and TYPE_DECL nodes.
2514 This does nothing for local (non-static) variables, unless the
2515 variable is a register variable with an ASMSPEC. In that case, or
2516 if the variable is not an automatice, it sets up the RTL and
2517 outputs any assembler code (label definition, storage allocation
2518 and initialization).
2520 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2521 the assembler symbol name to be used. TOP_LEVEL is nonzero
2522 if this declaration is not within a function. */
2524 void
2525 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2526 tree decl;
2527 const char *asmspec;
2528 int top_level;
2529 int at_end;
2531 /* Declarations of variables, and of functions defined elsewhere. */
2533 /* The most obvious approach, to put an #ifndef around where
2534 this macro is used, doesn't work since it's inside a macro call. */
2535 #ifndef ASM_FINISH_DECLARE_OBJECT
2536 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2537 #endif
2539 /* Forward declarations for nested functions are not "external",
2540 but we need to treat them as if they were. */
2541 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2542 || TREE_CODE (decl) == FUNCTION_DECL)
2544 timevar_push (TV_VARCONST);
2545 if (asmspec)
2546 make_decl_rtl (decl, asmspec);
2547 /* Initialized extern variable exists to be replaced
2548 with its value, or represents something that will be
2549 output in another file. */
2550 if (! (TREE_CODE (decl) == VAR_DECL
2551 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2552 && DECL_INITIAL (decl) != 0
2553 && DECL_INITIAL (decl) != error_mark_node))
2554 /* Don't output anything
2555 when a tentative file-scope definition is seen.
2556 But at end of compilation, do output code for them. */
2557 if (! (! at_end && top_level
2558 && (DECL_INITIAL (decl) == 0
2559 || DECL_INITIAL (decl) == error_mark_node)))
2560 assemble_variable (decl, top_level, at_end, 0);
2561 if (decl == last_assemble_variable_decl)
2563 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2564 top_level, at_end);
2566 timevar_pop (TV_VARCONST);
2568 else if (DECL_REGISTER (decl) && asmspec != 0)
2570 if (decode_reg_name (asmspec) >= 0)
2572 SET_DECL_RTL (decl, NULL_RTX);
2573 make_decl_rtl (decl, asmspec);
2575 else
2577 error ("invalid register name `%s' for register variable", asmspec);
2578 DECL_REGISTER (decl) = 0;
2579 if (!top_level)
2580 expand_decl (decl);
2583 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2584 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2585 && TREE_CODE (decl) == TYPE_DECL)
2587 timevar_push (TV_SYMOUT);
2588 dbxout_symbol (decl, 0);
2589 timevar_pop (TV_SYMOUT);
2591 #endif
2592 #ifdef SDB_DEBUGGING_INFO
2593 else if (write_symbols == SDB_DEBUG && top_level
2594 && TREE_CODE (decl) == TYPE_DECL)
2596 timevar_push (TV_SYMOUT);
2597 sdbout_symbol (decl, 0);
2598 timevar_pop (TV_SYMOUT);
2600 #endif
2603 /* Called after finishing a record, union or enumeral type. */
2605 void
2606 rest_of_type_compilation (type, toplev)
2607 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2608 tree type;
2609 int toplev;
2610 #else
2611 tree type ATTRIBUTE_UNUSED;
2612 int toplev ATTRIBUTE_UNUSED;
2613 #endif
2615 timevar_push (TV_SYMOUT);
2616 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2617 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2618 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2619 #endif
2620 #ifdef SDB_DEBUGGING_INFO
2621 if (write_symbols == SDB_DEBUG)
2622 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2623 #endif
2624 #ifdef DWARF2_DEBUGGING_INFO
2625 if (write_symbols == DWARF2_DEBUG && toplev)
2626 dwarf2out_decl (TYPE_STUB_DECL (type));
2627 #endif
2628 timevar_pop (TV_SYMOUT);
2631 /* DECL is an inline function, whose body is present, but which is not
2632 being output at this point. (We're putting that off until we need
2633 to do it.) If there are any actions that need to take place,
2634 including the emission of debugging information for the function,
2635 this is where they should go. This function may be called by
2636 language-dependent code for front-ends that do not even generate
2637 RTL for functions that don't need to be put out. */
2639 void
2640 note_deferral_of_defined_inline_function (decl)
2641 tree decl ATTRIBUTE_UNUSED;
2643 #ifdef DWARF_DEBUGGING_INFO
2644 /* Generate the DWARF info for the "abstract" instance of a function
2645 which we may later generate inlined and/or out-of-line instances
2646 of. */
2647 if (write_symbols == DWARF_DEBUG
2648 && (DECL_INLINE (decl) || DECL_ABSTRACT (decl))
2649 && ! DECL_ABSTRACT_ORIGIN (decl))
2651 /* The front-end may not have set CURRENT_FUNCTION_DECL, but the
2652 DWARF code expects it to be set in this case. Intuitively,
2653 DECL is the function we just finished defining, so setting
2654 CURRENT_FUNCTION_DECL is sensible. */
2655 tree saved_cfd = current_function_decl;
2656 int was_abstract = DECL_ABSTRACT (decl);
2657 current_function_decl = decl;
2659 /* Let the DWARF code do its work. */
2660 set_decl_abstract_flags (decl, 1);
2661 dwarfout_file_scope_decl (decl, 0);
2662 if (! was_abstract)
2663 set_decl_abstract_flags (decl, 0);
2665 /* Reset CURRENT_FUNCTION_DECL. */
2666 current_function_decl = saved_cfd;
2668 #endif
2671 /* FNDECL is an inline function which is about to be emitted out of line.
2672 Do any preparation, such as emitting abstract debug info for the inline
2673 before it gets mangled by optimization. */
2675 void
2676 note_outlining_of_inline_function (fndecl)
2677 tree fndecl ATTRIBUTE_UNUSED;
2679 #ifdef DWARF2_DEBUGGING_INFO
2680 /* The DWARF 2 backend tries to reduce debugging bloat by not emitting
2681 the abstract description of inline functions until something tries to
2682 reference them. Force it out now, before optimizations mangle the
2683 block tree. */
2684 if (write_symbols == DWARF2_DEBUG)
2685 dwarf2out_abstract_function (fndecl);
2686 #endif
2689 /* This is called from finish_function (within yyparse)
2690 after each top-level definition is parsed.
2691 It is supposed to compile that function or variable
2692 and output the assembler code for it.
2693 After we return, the tree storage is freed. */
2695 void
2696 rest_of_compilation (decl)
2697 tree decl;
2699 register rtx insns;
2700 int tem;
2701 int failure = 0;
2702 int rebuild_label_notes_after_reload;
2703 int register_life_up_to_date;
2705 timevar_push (TV_REST_OF_COMPILATION);
2707 /* Now that we're out of the frontend, we shouldn't have any more
2708 CONCATs anywhere. */
2709 generating_concat_p = 0;
2711 /* When processing delayed functions, prepare_function_start() won't
2712 have been run to re-initialize it. */
2713 cse_not_expected = ! optimize;
2715 /* First, make sure that NOTE_BLOCK is set correctly for each
2716 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2717 if (!cfun->x_whole_function_mode_p)
2718 identify_blocks ();
2720 /* Then remove any notes we don't need. That will make iterating
2721 over the instruction sequence faster, and allow the garbage
2722 collector to reclaim the memory used by the notes. */
2723 remove_unnecessary_notes ();
2725 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2726 tree in sensible shape. So, we just recalculate it here. */
2727 if (cfun->x_whole_function_mode_p)
2728 reorder_blocks ();
2730 init_flow ();
2732 /* If we are reconsidering an inline function
2733 at the end of compilation, skip the stuff for making it inline. */
2735 if (DECL_SAVED_INSNS (decl) == 0)
2737 int inlinable = 0;
2738 tree parent;
2739 const char *lose;
2741 /* If this is nested inside an inlined external function, pretend
2742 it was only declared. Since we cannot inline such functions,
2743 generating code for this one is not only not necessary but will
2744 confuse some debugging output writers. */
2745 for (parent = DECL_CONTEXT (current_function_decl);
2746 parent != NULL_TREE;
2747 parent = get_containing_scope (parent))
2748 if (TREE_CODE (parent) == FUNCTION_DECL
2749 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2751 DECL_INITIAL (decl) = 0;
2752 goto exit_rest_of_compilation;
2755 /* If requested, consider whether to make this function inline. */
2756 if ((DECL_INLINE (decl) && !flag_no_inline)
2757 || flag_inline_functions)
2759 timevar_push (TV_INTEGRATION);
2760 lose = function_cannot_inline_p (decl);
2761 timevar_pop (TV_INTEGRATION);
2762 if (lose || ! optimize)
2764 if (warn_inline && DECL_INLINE (decl))
2765 warning_with_decl (decl, lose);
2766 DECL_ABSTRACT_ORIGIN (decl) = 0;
2767 /* Don't really compile an extern inline function.
2768 If we can't make it inline, pretend
2769 it was only declared. */
2770 if (DECL_EXTERNAL (decl))
2772 DECL_INITIAL (decl) = 0;
2773 goto exit_rest_of_compilation;
2776 else
2777 /* ??? Note that this has the effect of making it look
2778 like "inline" was specified for a function if we choose
2779 to inline it. This isn't quite right, but it's
2780 probably not worth the trouble to fix. */
2781 inlinable = DECL_INLINE (decl) = 1;
2784 insns = get_insns ();
2786 /* Dump the rtl code if we are dumping rtl. */
2788 if (open_dump_file (DFI_rtl, decl))
2790 if (DECL_SAVED_INSNS (decl))
2791 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2792 close_dump_file (DFI_rtl, print_rtl, insns);
2795 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2796 sorts of eh initialization. Delay this until after the
2797 initial rtl dump so that we can see the original nesting. */
2798 convert_from_eh_region_ranges ();
2800 /* If function is inline, and we don't yet know whether to
2801 compile it by itself, defer decision till end of compilation.
2802 finish_compilation will call rest_of_compilation again
2803 for those functions that need to be output. Also defer those
2804 functions that we are supposed to defer. */
2806 if (inlinable
2807 || (DECL_INLINE (decl)
2808 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2809 && ! flag_keep_inline_functions)
2810 || DECL_EXTERNAL (decl))))
2811 DECL_DEFER_OUTPUT (decl) = 1;
2813 if (DECL_INLINE (decl))
2814 /* DWARF wants seperate debugging info for abstract and
2815 concrete instances of all inline functions, including those
2816 declared inline but not inlined, and those inlined even
2817 though they weren't declared inline. Conveniently, that's
2818 what DECL_INLINE means at this point. */
2819 note_deferral_of_defined_inline_function (decl);
2821 if (DECL_DEFER_OUTPUT (decl))
2823 /* If -Wreturn-type, we have to do a bit of compilation. We just
2824 want to call jump_optimize to figure out whether or not we can
2825 fall off the end of the function; we do the minimum amount of
2826 work necessary to make that safe. And, we set optimize to zero
2827 to keep jump_optimize from working too hard. */
2828 if (warn_return_type)
2830 int saved_optimize = optimize;
2832 optimize = 0;
2833 find_exception_handler_labels ();
2834 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2835 !JUMP_AFTER_REGSCAN);
2836 optimize = saved_optimize;
2839 current_function_nothrow = nothrow_function_p ();
2840 if (current_function_nothrow)
2841 /* Now we know that this can't throw; set the flag for the benefit
2842 of other functions later in this translation unit. */
2843 TREE_NOTHROW (current_function_decl) = 1;
2845 timevar_push (TV_INTEGRATION);
2846 save_for_inline (decl);
2847 timevar_pop (TV_INTEGRATION);
2848 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2849 goto exit_rest_of_compilation;
2852 /* If specified extern inline but we aren't inlining it, we are
2853 done. This goes for anything that gets here with DECL_EXTERNAL
2854 set, not just things with DECL_INLINE. */
2855 if (DECL_EXTERNAL (decl))
2856 goto exit_rest_of_compilation;
2859 init_EXPR_INSN_LIST_cache ();
2861 ggc_collect ();
2863 /* Initialize some variables used by the optimizers. */
2864 init_function_for_compilation ();
2866 if (! DECL_DEFER_OUTPUT (decl))
2867 TREE_ASM_WRITTEN (decl) = 1;
2869 /* Now that integrate will no longer see our rtl, we need not
2870 distinguish between the return value of this function and the
2871 return value of called functions. Also, we can remove all SETs
2872 of subregs of hard registers; they are only here because of
2873 integrate.*/
2874 rtx_equal_function_value_matters = 0;
2875 purge_hard_subreg_sets (get_insns ());
2877 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2878 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2879 goto exit_rest_of_compilation;
2881 /* We may have potential sibling or tail recursion sites. Select one
2882 (of possibly multiple) methods of performing the call. */
2883 if (flag_optimize_sibling_calls)
2885 timevar_push (TV_JUMP);
2886 open_dump_file (DFI_sibling, decl);
2888 optimize_sibling_and_tail_recursive_calls ();
2890 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2891 timevar_pop (TV_JUMP);
2894 /* Complete generation of exception handling code. */
2895 find_exception_handler_labels ();
2896 if (doing_eh (0))
2898 timevar_push (TV_JUMP);
2899 open_dump_file (DFI_eh, decl);
2901 finish_eh_generation ();
2903 close_dump_file (DFI_eh, print_rtl, get_insns ());
2904 timevar_pop (TV_JUMP);
2907 #ifdef FINALIZE_PIC
2908 /* If we are doing position-independent code generation, now
2909 is the time to output special prologues and epilogues.
2910 We do not want to do this earlier, because it just clutters
2911 up inline functions with meaningless insns. */
2912 if (flag_pic)
2913 FINALIZE_PIC;
2914 #endif
2916 insns = get_insns ();
2918 /* Copy any shared structure that should not be shared. */
2919 unshare_all_rtl (current_function_decl, insns);
2921 #ifdef SETJMP_VIA_SAVE_AREA
2922 /* This must be performed before virutal register instantiation. */
2923 if (current_function_calls_alloca)
2924 optimize_save_area_alloca (insns);
2925 #endif
2927 /* Instantiate all virtual registers. */
2928 instantiate_virtual_regs (current_function_decl, insns);
2930 open_dump_file (DFI_jump, decl);
2932 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2933 are initialized and to compute whether control can drop off the end
2934 of the function. */
2936 timevar_push (TV_JUMP);
2937 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2938 before jump optimization switches branch directions. */
2939 expected_value_to_br_prob ();
2941 reg_scan (insns, max_reg_num (), 0);
2942 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2943 JUMP_AFTER_REGSCAN);
2945 timevar_pop (TV_JUMP);
2947 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2948 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2950 close_dump_file (DFI_jump, print_rtl, insns);
2951 goto exit_rest_of_compilation;
2954 timevar_push (TV_JUMP);
2956 if (optimize > 0)
2958 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2959 cleanup_cfg ();
2961 /* ??? Run if-conversion before delete_null_pointer_checks,
2962 since the later does not preserve the CFG. This should
2963 be changed -- no since converting if's that are going to
2964 be deleted. */
2965 timevar_push (TV_IFCVT);
2966 if_convert (0);
2967 timevar_pop (TV_IFCVT);
2969 /* Try to identify useless null pointer tests and delete them. */
2970 if (flag_delete_null_pointer_checks)
2971 delete_null_pointer_checks (insns);
2974 /* Jump optimization, and the removal of NULL pointer checks, may
2975 have reduced the number of instructions substantially. CSE, and
2976 future passes, allocate arrays whose dimensions involve the
2977 maximum instruction UID, so if we can reduce the maximum UID
2978 we'll save big on memory. */
2979 renumber_insns (rtl_dump_file);
2980 timevar_pop (TV_JUMP);
2982 close_dump_file (DFI_jump, print_rtl, insns);
2984 ggc_collect ();
2986 /* Perform common subexpression elimination.
2987 Nonzero value from `cse_main' means that jumps were simplified
2988 and some code may now be unreachable, so do
2989 jump optimization again. */
2991 if (optimize > 0)
2993 open_dump_file (DFI_cse, decl);
2994 timevar_push (TV_CSE);
2996 reg_scan (insns, max_reg_num (), 1);
2998 if (flag_thread_jumps)
3000 timevar_push (TV_JUMP);
3001 thread_jumps (insns, max_reg_num (), 1);
3002 timevar_pop (TV_JUMP);
3005 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3007 /* If we are not running the second CSE pass, then we are no longer
3008 expecting CSE to be run. */
3009 cse_not_expected = !flag_rerun_cse_after_loop;
3011 if (tem || optimize > 1)
3013 timevar_push (TV_JUMP);
3014 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3015 !JUMP_AFTER_REGSCAN);
3016 timevar_pop (TV_JUMP);
3019 /* Run this after jump optmizations remove all the unreachable code
3020 so that unreachable code will not keep values live. */
3021 delete_trivially_dead_insns (insns, max_reg_num ());
3023 /* Try to identify useless null pointer tests and delete them. */
3024 if (flag_delete_null_pointer_checks)
3026 timevar_push (TV_JUMP);
3027 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3029 cleanup_cfg ();
3031 delete_null_pointer_checks (insns);
3032 timevar_pop (TV_JUMP);
3035 /* The second pass of jump optimization is likely to have
3036 removed a bunch more instructions. */
3037 renumber_insns (rtl_dump_file);
3039 timevar_pop (TV_CSE);
3040 close_dump_file (DFI_cse, print_rtl, insns);
3043 open_dump_file (DFI_addressof, decl);
3045 purge_addressof (insns);
3046 reg_scan (insns, max_reg_num (), 1);
3048 close_dump_file (DFI_addressof, print_rtl, insns);
3050 ggc_collect ();
3052 if (optimize > 0 && flag_ssa)
3054 /* Convert to SSA form. */
3056 timevar_push (TV_TO_SSA);
3057 open_dump_file (DFI_ssa, decl);
3059 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3060 cleanup_cfg ();
3061 convert_to_ssa ();
3063 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
3064 timevar_pop (TV_TO_SSA);
3066 /* The SSA implementation uses basic block numbers in its phi
3067 nodes. Thus, changing the control-flow graph or the basic
3068 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
3069 may cause problems. */
3071 if (flag_dce)
3073 /* Remove dead code. */
3075 timevar_push (TV_DEAD_CODE_ELIM);
3076 open_dump_file (DFI_dce, decl);
3078 insns = get_insns ();
3079 eliminate_dead_code();
3081 close_dump_file (DFI_dce, print_rtl_with_bb, insns);
3082 timevar_pop (TV_DEAD_CODE_ELIM);
3085 /* Convert from SSA form. */
3087 timevar_push (TV_FROM_SSA);
3088 open_dump_file (DFI_ussa, decl);
3090 convert_from_ssa ();
3091 /* New registers have been created. Rescan their usage. */
3092 reg_scan (insns, max_reg_num (), 1);
3093 /* Life analysis used in SSA adds log_links but these
3094 shouldn't be there until the flow stage, so clear
3095 them away. */
3096 clear_log_links (insns);
3098 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
3099 timevar_pop (TV_FROM_SSA);
3101 ggc_collect ();
3104 /* Perform global cse. */
3106 if (optimize > 0 && flag_gcse)
3108 timevar_push (TV_GCSE);
3109 open_dump_file (DFI_gcse, decl);
3111 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3112 cleanup_cfg ();
3113 tem = gcse_main (insns, rtl_dump_file);
3115 /* If gcse altered any jumps, rerun jump optimizations to clean
3116 things up. */
3117 if (tem)
3119 timevar_push (TV_JUMP);
3120 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3121 !JUMP_AFTER_REGSCAN);
3122 timevar_pop (TV_JUMP);
3125 close_dump_file (DFI_gcse, print_rtl, insns);
3126 timevar_pop (TV_GCSE);
3128 ggc_collect ();
3131 /* Move constant computations out of loops. */
3133 if (optimize > 0)
3135 timevar_push (TV_LOOP);
3136 open_dump_file (DFI_loop, decl);
3138 if (flag_rerun_loop_opt)
3140 /* We only want to perform unrolling once. */
3142 loop_optimize (insns, rtl_dump_file, 0);
3144 /* The first call to loop_optimize makes some instructions
3145 trivially dead. We delete those instructions now in the
3146 hope that doing so will make the heuristics in loop work
3147 better and possibly speed up compilation. */
3148 delete_trivially_dead_insns (insns, max_reg_num ());
3150 /* The regscan pass is currently necessary as the alias
3151 analysis code depends on this information. */
3152 reg_scan (insns, max_reg_num (), 1);
3154 loop_optimize (insns, rtl_dump_file,
3155 (flag_unroll_loops ? LOOP_UNROLL : 0) | LOOP_BCT);
3157 close_dump_file (DFI_loop, print_rtl, insns);
3158 timevar_pop (TV_LOOP);
3160 ggc_collect ();
3163 if (optimize > 0)
3165 timevar_push (TV_CSE2);
3166 open_dump_file (DFI_cse2, decl);
3168 if (flag_rerun_cse_after_loop)
3170 /* Running another jump optimization pass before the second
3171 cse pass sometimes simplifies the RTL enough to allow
3172 the second CSE pass to do a better job. Jump_optimize can change
3173 max_reg_num so we must rerun reg_scan afterwards.
3174 ??? Rework to not call reg_scan so often. */
3175 timevar_push (TV_JUMP);
3177 reg_scan (insns, max_reg_num (), 0);
3178 jump_optimize (insns, !JUMP_CROSS_JUMP,
3179 !JUMP_NOOP_MOVES, JUMP_AFTER_REGSCAN);
3181 timevar_push (TV_IFCVT);
3183 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3184 cleanup_cfg ();
3185 if_convert (0);
3187 timevar_pop(TV_IFCVT);
3189 timevar_pop (TV_JUMP);
3191 reg_scan (insns, max_reg_num (), 0);
3192 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3194 if (tem)
3196 timevar_push (TV_JUMP);
3197 jump_optimize (insns, !JUMP_CROSS_JUMP,
3198 !JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3199 timevar_pop (TV_JUMP);
3203 if (flag_thread_jumps)
3205 /* This pass of jump threading straightens out code
3206 that was kinked by loop optimization. */
3207 timevar_push (TV_JUMP);
3208 reg_scan (insns, max_reg_num (), 0);
3209 thread_jumps (insns, max_reg_num (), 0);
3210 timevar_pop (TV_JUMP);
3213 close_dump_file (DFI_cse2, print_rtl, insns);
3214 timevar_pop (TV_CSE2);
3216 ggc_collect ();
3219 cse_not_expected = 1;
3221 regclass_init ();
3223 /* Do control and data flow analysis; wrote some of the results to
3224 the dump file. */
3226 timevar_push (TV_FLOW);
3227 open_dump_file (DFI_cfg, decl);
3229 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3230 cleanup_cfg ();
3231 check_function_return_warnings ();
3233 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
3235 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3237 timevar_push (TV_BRANCH_PROB);
3238 open_dump_file (DFI_bp, decl);
3240 branch_prob ();
3242 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
3243 timevar_pop (TV_BRANCH_PROB);
3246 open_dump_file (DFI_life, decl);
3247 if (optimize)
3249 struct loops loops;
3251 /* Discover and record the loop depth at the head of each basic
3252 block. The loop infrastructure does the real job for us. */
3253 flow_loops_find (&loops, LOOP_TREE);
3255 /* Estimate using heuristics if no profiling info is available. */
3256 if (flag_guess_branch_prob)
3257 estimate_probability (&loops);
3259 if (rtl_dump_file)
3260 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
3262 flow_loops_free (&loops);
3264 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3265 mark_constant_function ();
3266 timevar_pop (TV_FLOW);
3268 register_life_up_to_date = 1;
3269 no_new_pseudos = 1;
3271 if (warn_uninitialized || extra_warnings)
3273 uninitialized_vars_warning (DECL_INITIAL (decl));
3274 if (extra_warnings)
3275 setjmp_args_warning ();
3278 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3280 ggc_collect ();
3282 /* If -opt, try combining insns through substitution. */
3284 if (optimize > 0)
3286 int rebuild_jump_labels_after_combine = 0;
3288 timevar_push (TV_COMBINE);
3289 open_dump_file (DFI_combine, decl);
3291 rebuild_jump_labels_after_combine
3292 = combine_instructions (insns, max_reg_num ());
3294 /* Combining insns may have turned an indirect jump into a
3295 direct jump. Rebuid the JUMP_LABEL fields of jumping
3296 instructions. */
3297 if (rebuild_jump_labels_after_combine)
3299 timevar_push (TV_JUMP);
3300 rebuild_jump_labels (insns);
3301 timevar_pop (TV_JUMP);
3303 timevar_push (TV_FLOW);
3304 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3305 cleanup_cfg ();
3307 /* Blimey. We've got to have the CFG up to date for the call to
3308 if_convert below. However, the random deletion of blocks
3309 without updating life info can wind up with Wierd Stuff in
3310 global_live_at_end. We then run sched1, which updates things
3311 properly, discovers the wierdness and aborts. */
3312 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
3313 PROP_DEATH_NOTES | PROP_KILL_DEAD_CODE
3314 | PROP_SCAN_DEAD_CODE);
3316 timevar_pop (TV_FLOW);
3319 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3320 timevar_pop (TV_COMBINE);
3322 ggc_collect ();
3325 /* Rerun if-conversion, as combine may have simplified things enough to
3326 now meet sequence length restrictions. */
3327 if (optimize > 0)
3329 timevar_push (TV_IFCVT);
3330 open_dump_file (DFI_ce, decl);
3332 no_new_pseudos = 0;
3333 if_convert (1);
3334 no_new_pseudos = 1;
3336 close_dump_file (DFI_ce, print_rtl_with_bb, insns);
3337 timevar_pop (TV_IFCVT);
3340 /* Register allocation pre-pass, to reduce number of moves
3341 necessary for two-address machines. */
3342 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3344 timevar_push (TV_REGMOVE);
3345 open_dump_file (DFI_regmove, decl);
3347 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3349 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3350 timevar_pop (TV_REGMOVE);
3352 ggc_collect ();
3355 /* Any of the several passes since flow1 will have munged register
3356 lifetime data a bit. */
3357 if (optimize > 0)
3358 register_life_up_to_date = 0;
3360 #ifdef OPTIMIZE_MODE_SWITCHING
3361 timevar_push (TV_GCSE);
3363 if (optimize_mode_switching (NULL_PTR))
3365 /* We did work, and so had to regenerate global life information.
3366 Take advantage of this and don't re-recompute register life
3367 information below. */
3368 register_life_up_to_date = 1;
3371 timevar_pop (TV_GCSE);
3372 #endif
3374 #ifdef INSN_SCHEDULING
3376 /* Print function header into sched dump now
3377 because doing the sched analysis makes some of the dump. */
3378 if (optimize > 0 && flag_schedule_insns)
3380 timevar_push (TV_SCHED);
3381 open_dump_file (DFI_sched, decl);
3383 /* Do control and data sched analysis,
3384 and write some of the results to dump file. */
3386 schedule_insns (rtl_dump_file);
3388 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3389 timevar_pop (TV_SCHED);
3391 ggc_collect ();
3393 /* Register lifetime information was updated as part of verifying
3394 the schedule. */
3395 register_life_up_to_date = 1;
3397 #endif
3399 /* Determine if the current function is a leaf before running reload
3400 since this can impact optimizations done by the prologue and
3401 epilogue thus changing register elimination offsets. */
3402 current_function_is_leaf = leaf_function_p ();
3404 timevar_push (TV_LOCAL_ALLOC);
3405 open_dump_file (DFI_lreg, decl);
3407 /* Allocate pseudo-regs that are used only within 1 basic block.
3409 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3410 jump optimizer after register allocation and reloading are finished. */
3412 if (! register_life_up_to_date)
3413 recompute_reg_usage (insns, ! optimize_size);
3414 regclass (insns, max_reg_num (), rtl_dump_file);
3415 rebuild_label_notes_after_reload = local_alloc ();
3417 timevar_pop (TV_LOCAL_ALLOC);
3419 if (dump_file[DFI_lreg].enabled)
3421 timevar_push (TV_DUMP);
3423 dump_flow_info (rtl_dump_file);
3424 dump_local_alloc (rtl_dump_file);
3426 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3427 timevar_pop (TV_DUMP);
3430 ggc_collect ();
3432 timevar_push (TV_GLOBAL_ALLOC);
3433 open_dump_file (DFI_greg, decl);
3435 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3436 pass fixing up any insns that are invalid. */
3438 if (optimize)
3439 failure = global_alloc (rtl_dump_file);
3440 else
3442 build_insn_chain (insns);
3443 failure = reload (insns, 0);
3446 timevar_pop (TV_GLOBAL_ALLOC);
3448 if (dump_file[DFI_greg].enabled)
3450 timevar_push (TV_DUMP);
3452 dump_global_regs (rtl_dump_file);
3454 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3455 timevar_pop (TV_DUMP);
3458 if (failure)
3459 goto exit_rest_of_compilation;
3461 ggc_collect ();
3463 open_dump_file (DFI_postreload, decl);
3465 /* Do a very simple CSE pass over just the hard registers. */
3466 if (optimize > 0)
3468 timevar_push (TV_RELOAD_CSE_REGS);
3469 reload_cse_regs (insns);
3470 timevar_pop (TV_RELOAD_CSE_REGS);
3473 /* If optimizing, then go ahead and split insns now since we are about
3474 to recompute flow information anyway. */
3475 if (optimize > 0)
3477 int old_labelnum = max_label_num ();
3479 split_all_insns (0);
3480 rebuild_label_notes_after_reload |= old_labelnum != max_label_num ();
3483 /* Register allocation and reloading may have turned an indirect jump into
3484 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3485 jumping instructions. */
3486 if (rebuild_label_notes_after_reload)
3488 timevar_push (TV_JUMP);
3490 rebuild_jump_labels (insns);
3492 timevar_pop (TV_JUMP);
3495 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3497 /* Re-create the death notes which were deleted during reload. */
3498 timevar_push (TV_FLOW2);
3499 open_dump_file (DFI_flow2, decl);
3501 jump_optimize (insns, !JUMP_CROSS_JUMP,
3502 JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3503 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3505 /* On some machines, the prologue and epilogue code, or parts thereof,
3506 can be represented as RTL. Doing so lets us schedule insns between
3507 it and the rest of the code and also allows delayed branch
3508 scheduling to operate in the epilogue. */
3509 thread_prologue_and_epilogue_insns (insns);
3511 if (optimize)
3513 cleanup_cfg ();
3514 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3516 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3517 even for machines with possibly nonzero RETURN_POPS_ARGS
3518 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3519 push instructions will have popping returns. */
3520 #ifndef PUSH_ROUNDING
3521 if (!ACCUMULATE_OUTGOING_ARGS)
3522 #endif
3523 combine_stack_adjustments ();
3525 ggc_collect ();
3528 flow2_completed = 1;
3530 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3531 timevar_pop (TV_FLOW2);
3533 #ifdef HAVE_peephole2
3534 if (optimize > 0 && flag_peephole2)
3536 timevar_push (TV_PEEPHOLE2);
3537 open_dump_file (DFI_peephole2, decl);
3539 peephole2_optimize (rtl_dump_file);
3541 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3542 timevar_pop (TV_PEEPHOLE2);
3544 #endif
3546 if (optimize > 0 && flag_rename_registers)
3548 timevar_push (TV_RENAME_REGISTERS);
3549 open_dump_file (DFI_rnreg, decl);
3551 regrename_optimize ();
3553 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3554 timevar_pop (TV_RENAME_REGISTERS);
3557 if (optimize > 0)
3559 timevar_push (TV_IFCVT2);
3560 open_dump_file (DFI_ce2, decl);
3562 if_convert (1);
3564 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3565 timevar_pop (TV_IFCVT2);
3568 #ifdef INSN_SCHEDULING
3569 if (optimize > 0 && flag_schedule_insns_after_reload)
3571 timevar_push (TV_SCHED2);
3572 open_dump_file (DFI_sched2, decl);
3574 /* Do control and data sched analysis again,
3575 and write some more of the results to dump file. */
3577 schedule_insns (rtl_dump_file);
3579 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3580 timevar_pop (TV_SCHED2);
3582 ggc_collect ();
3584 #endif
3586 #ifdef LEAF_REGISTERS
3587 current_function_uses_only_leaf_regs
3588 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3589 #endif
3591 if (optimize > 0 && flag_reorder_blocks)
3593 timevar_push (TV_REORDER_BLOCKS);
3594 open_dump_file (DFI_bbro, decl);
3596 reorder_basic_blocks ();
3598 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3599 timevar_pop (TV_REORDER_BLOCKS);
3602 /* One more attempt to remove jumps to .+1 left by dead-store elimination.
3603 Also do cross-jumping this time and delete no-op move insns. */
3605 if (optimize > 0)
3607 timevar_push (TV_JUMP);
3608 open_dump_file (DFI_jump2, decl);
3610 jump_optimize (insns, JUMP_CROSS_JUMP, JUMP_NOOP_MOVES,
3611 !JUMP_AFTER_REGSCAN);
3613 /* CFG no longer kept up to date. */
3615 close_dump_file (DFI_jump2, print_rtl, insns);
3616 timevar_pop (TV_JUMP);
3619 /* If a machine dependent reorganization is needed, call it. */
3620 #ifdef MACHINE_DEPENDENT_REORG
3621 open_dump_file (DFI_mach, decl);
3623 MACHINE_DEPENDENT_REORG (insns);
3625 close_dump_file (DFI_mach, print_rtl, insns);
3627 ggc_collect ();
3628 #endif
3630 /* If a scheduling pass for delayed branches is to be done,
3631 call the scheduling code. */
3633 #ifdef DELAY_SLOTS
3634 if (optimize > 0 && flag_delayed_branch)
3636 timevar_push (TV_DBR_SCHED);
3637 open_dump_file (DFI_dbr, decl);
3639 dbr_schedule (insns, rtl_dump_file);
3641 close_dump_file (DFI_dbr, print_rtl, insns);
3642 timevar_pop (TV_DBR_SCHED);
3644 ggc_collect ();
3646 #endif
3648 #ifndef STACK_REGS
3649 /* ??? Do this before shorten branches so that we aren't creating
3650 insns too late and fail sanity checks in final. */
3651 convert_to_eh_region_ranges ();
3652 #endif
3654 /* Shorten branches.
3656 Note this must run before reg-stack because of death note (ab)use
3657 in the ia32 backend. */
3658 timevar_push (TV_SHORTEN_BRANCH);
3659 shorten_branches (get_insns ());
3660 timevar_pop (TV_SHORTEN_BRANCH);
3662 #ifdef STACK_REGS
3663 timevar_push (TV_REG_STACK);
3664 open_dump_file (DFI_stack, decl);
3666 reg_to_stack (insns, rtl_dump_file);
3668 close_dump_file (DFI_stack, print_rtl, insns);
3669 timevar_pop (TV_REG_STACK);
3671 ggc_collect ();
3673 convert_to_eh_region_ranges ();
3674 #endif
3676 current_function_nothrow = nothrow_function_p ();
3677 if (current_function_nothrow)
3678 /* Now we know that this can't throw; set the flag for the benefit
3679 of other functions later in this translation unit. */
3680 TREE_NOTHROW (current_function_decl) = 1;
3682 /* Now turn the rtl into assembler code. */
3684 timevar_push (TV_FINAL);
3686 rtx x;
3687 const char *fnname;
3689 /* Get the function's name, as described by its RTL. This may be
3690 different from the DECL_NAME name used in the source file. */
3692 x = DECL_RTL (decl);
3693 if (GET_CODE (x) != MEM)
3694 abort ();
3695 x = XEXP (x, 0);
3696 if (GET_CODE (x) != SYMBOL_REF)
3697 abort ();
3698 fnname = XSTR (x, 0);
3700 assemble_start_function (decl, fnname);
3701 final_start_function (insns, asm_out_file, optimize);
3702 final (insns, asm_out_file, optimize, 0);
3703 final_end_function (insns, asm_out_file, optimize);
3705 #ifdef IA64_UNWIND_INFO
3706 /* ??? The IA-64 ".handlerdata" directive must be issued before
3707 the ".endp" directive that closes the procedure descriptor. */
3708 output_function_exception_table ();
3709 #endif
3711 assemble_end_function (decl, fnname);
3713 #ifndef IA64_UNWIND_INFO
3714 /* Otherwise, it feels unclean to switch sections in the middle. */
3715 output_function_exception_table ();
3716 #endif
3718 if (! quiet_flag)
3719 fflush (asm_out_file);
3721 /* Release all memory allocated by flow. */
3722 free_basic_block_vars (0);
3724 /* Release all memory held by regsets now. */
3725 regset_release_memory ();
3727 timevar_pop (TV_FINAL);
3729 ggc_collect ();
3731 /* Write DBX symbols if requested. */
3733 /* Note that for those inline functions where we don't initially
3734 know for certain that we will be generating an out-of-line copy,
3735 the first invocation of this routine (rest_of_compilation) will
3736 skip over this code by doing a `goto exit_rest_of_compilation;'.
3737 Later on, finish_compilation will call rest_of_compilation again
3738 for those inline functions that need to have out-of-line copies
3739 generated. During that call, we *will* be routed past here. */
3741 timevar_push (TV_SYMOUT);
3742 #ifdef DBX_DEBUGGING_INFO
3743 if (write_symbols == DBX_DEBUG)
3744 dbxout_function (decl);
3745 #endif
3747 #ifdef DWARF_DEBUGGING_INFO
3748 if (write_symbols == DWARF_DEBUG)
3749 dwarfout_file_scope_decl (decl, 0);
3750 #endif
3752 #ifdef DWARF2_DEBUGGING_INFO
3753 if (write_symbols == DWARF2_DEBUG)
3754 dwarf2out_decl (decl);
3755 #endif
3756 timevar_pop (TV_SYMOUT);
3758 exit_rest_of_compilation:
3760 /* In case the function was not output,
3761 don't leave any temporary anonymous types
3762 queued up for sdb output. */
3763 #ifdef SDB_DEBUGGING_INFO
3764 if (write_symbols == SDB_DEBUG)
3765 sdbout_types (NULL_TREE);
3766 #endif
3768 reload_completed = 0;
3769 flow2_completed = 0;
3770 no_new_pseudos = 0;
3772 timevar_push (TV_FINAL);
3774 /* Clear out the insn_length contents now that they are no
3775 longer valid. */
3776 init_insn_lengths ();
3778 /* Clear out the real_constant_chain before some of the rtx's
3779 it runs through become garbage. */
3780 clear_const_double_mem ();
3782 /* Show no temporary slots allocated. */
3783 init_temp_slots ();
3785 free_basic_block_vars (0);
3787 timevar_pop (TV_FINAL);
3789 /* Make sure volatile mem refs aren't considered valid operands for
3790 arithmetic insns. We must call this here if this is a nested inline
3791 function, since the above code leaves us in the init_recog state
3792 (from final.c), and the function context push/pop code does not
3793 save/restore volatile_ok.
3795 ??? Maybe it isn't necessary for expand_start_function to call this
3796 anymore if we do it here? */
3798 init_recog_no_volatile ();
3800 /* We're done with this function. Free up memory if we can. */
3801 free_after_parsing (cfun);
3802 if (! DECL_DEFER_OUTPUT (decl))
3803 free_after_compilation (cfun);
3804 cfun = 0;
3806 ggc_collect ();
3808 timevar_pop (TV_REST_OF_COMPILATION);
3811 static void
3812 display_help ()
3814 int undoc;
3815 unsigned long i;
3816 const char *lang;
3818 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3819 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3820 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3821 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3822 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3823 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"));
3825 for (i = ARRAY_SIZE (f_options); i--;)
3827 const char *description = f_options[i].description;
3829 if (description != NULL && * description != 0)
3830 printf (" -f%-21s %s\n",
3831 f_options[i].string, description);
3834 printf (_(" -O[number] Set optimisation level to [number]\n"));
3835 printf (_(" -Os Optimise for space rather than speed\n"));
3836 for (i = sizeof (compiler_params); i--;)
3838 const char *description = compiler_params[i].help;
3839 const int length = 21-strlen(compiler_params[i].option);
3841 if (description != NULL && * description != 0)
3842 printf (" --param %s=<value>%.*s%s\n",
3843 compiler_params[i].option,
3844 length > 0 ? length : 1, " ",
3845 description);
3847 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3848 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3849 printf (_(" -w Suppress warnings\n"));
3850 printf (_(" -W Enable extra warnings\n"));
3852 for (i = ARRAY_SIZE (W_options); i--;)
3854 const char *description = W_options[i].description;
3856 if (description != NULL && * description != 0)
3857 printf (" -W%-21s %s\n",
3858 W_options[i].string, description);
3861 printf (_(" -Wunused Enable unused warnings\n"));
3862 printf (_(" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n"));
3863 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3864 printf (_(" -p Enable function profiling\n"));
3865 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3866 printf (_(" -a Enable block profiling \n"));
3867 #endif
3868 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3869 printf (_(" -ax Enable jump profiling \n"));
3870 #endif
3871 printf (_(" -o <file> Place output into <file> \n"));
3872 printf (_("\
3873 -G <number> Put global and static data smaller than <number>\n\
3874 bytes into a special section (on some targets)\n"));
3876 for (i = ARRAY_SIZE (debug_args); i--;)
3878 if (debug_args[i].description != NULL)
3879 printf (" -g%-21s %s\n",
3880 debug_args[i].arg, debug_args[i].description);
3883 printf (_(" -aux-info <file> Emit declaration info into <file>.X\n"));
3884 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3885 printf (_(" -version Display the compiler's version\n"));
3886 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3887 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3888 #if defined INSN_SCHEDULING
3889 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3890 #endif
3891 printf (_(" --help Display this information\n"));
3893 undoc = 0;
3894 lang = "language";
3896 /* Display descriptions of language specific options.
3897 If there is no description, note that there is an undocumented option.
3898 If the description is empty, do not display anything. (This allows
3899 options to be deliberately undocumented, for whatever reason).
3900 If the option string is missing, then this is a marker, indicating
3901 that the description string is in fact the name of a language, whose
3902 language specific options are to follow. */
3904 if (ARRAY_SIZE (documented_lang_options) > 1)
3906 printf (_("\nLanguage specific options:\n"));
3908 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3910 const char *description = documented_lang_options[i].description;
3911 const char *option = documented_lang_options[i].option;
3913 if (description == NULL)
3915 undoc = 1;
3917 if (extra_warnings)
3918 printf (_(" %-23.23s [undocumented]\n"), option);
3920 else if (*description == 0)
3921 continue;
3922 else if (option == NULL)
3924 if (undoc)
3925 printf
3926 (_("\nThere are undocumented %s specific options as well.\n"),
3927 lang);
3928 undoc = 0;
3930 printf (_("\n Options for %s:\n"), description);
3932 lang = description;
3934 else
3935 printf (" %-23.23s %s\n", option, description);
3939 if (undoc)
3940 printf (_("\nThere are undocumented %s specific options as well.\n"),
3941 lang);
3943 display_target_options ();
3946 static void
3947 display_target_options ()
3949 int undoc,i;
3951 if (ARRAY_SIZE (target_switches) > 1
3952 #ifdef TARGET_OPTIONS
3953 || ARRAY_SIZE (target_options) > 1
3954 #endif
3957 int doc = 0;
3959 undoc = 0;
3961 printf (_("\nTarget specific options:\n"));
3963 for (i = ARRAY_SIZE (target_switches); i--;)
3965 const char *option = target_switches[i].name;
3966 const char *description = target_switches[i].description;
3968 if (option == NULL || *option == 0)
3969 continue;
3970 else if (description == NULL)
3972 undoc = 1;
3974 if (extra_warnings)
3975 printf (_(" -m%-23.23s [undocumented]\n"), option);
3977 else if (* description != 0)
3978 doc += printf (" -m%-23.23s %s\n", option, description);
3981 #ifdef TARGET_OPTIONS
3982 for (i = ARRAY_SIZE (target_options); i--;)
3984 const char *option = target_options[i].prefix;
3985 const char *description = target_options[i].description;
3987 if (option == NULL || *option == 0)
3988 continue;
3989 else if (description == NULL)
3991 undoc = 1;
3993 if (extra_warnings)
3994 printf (_(" -m%-23.23s [undocumented]\n"), option);
3996 else if (* description != 0)
3997 doc += printf (" -m%-23.23s %s\n", option, description);
3999 #endif
4000 if (undoc)
4002 if (doc)
4003 printf (_("\nThere are undocumented target specific options as well.\n"));
4004 else
4005 printf (_(" They exist, but they are not documented.\n"));
4010 /* Parse a -d... comand line switch. */
4012 static void
4013 decode_d_option (arg)
4014 const char *arg;
4016 int i, c, matched;
4018 while (*arg)
4019 switch (c = *arg++)
4021 case 'a':
4022 for (i = 0; i < (int) DFI_MAX; ++i)
4023 dump_file[i].enabled = 1;
4024 break;
4025 case 'A':
4026 flag_debug_asm = 1;
4027 break;
4028 case 'm':
4029 flag_print_mem = 1;
4030 break;
4031 case 'p':
4032 flag_print_asm_name = 1;
4033 break;
4034 case 'P':
4035 flag_dump_rtl_in_asm = 1;
4036 flag_print_asm_name = 1;
4037 break;
4038 case 'v':
4039 graph_dump_format = vcg;
4040 break;
4041 case 'x':
4042 rtl_dump_and_exit = 1;
4043 break;
4044 case 'y':
4045 set_yydebug (1);
4046 break;
4047 case 'D': /* These are handled by the preprocessor. */
4048 case 'I':
4049 break;
4051 default:
4052 matched = 0;
4053 for (i = 0; i < (int) DFI_MAX; ++i)
4054 if (c == dump_file[i].debug_switch)
4056 dump_file[i].enabled = 1;
4057 matched = 1;
4060 if (! matched)
4061 warning ("unrecognized gcc debugging option: %c", c);
4062 break;
4066 /* Parse a -f... comand line switch. ARG is the value after the -f.
4067 It is safe to access 'ARG - 2' to generate the full switch name.
4068 Return the number of strings consumed. */
4070 static int
4071 decode_f_option (arg)
4072 const char *arg;
4074 int j;
4075 const char *option_value = NULL;
4077 /* Search for the option in the table of binary f options. */
4078 for (j = ARRAY_SIZE (f_options); j--;)
4080 if (!strcmp (arg, f_options[j].string))
4082 *f_options[j].variable = f_options[j].on_value;
4083 return 1;
4086 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4087 && ! strcmp (arg + 3, f_options[j].string))
4089 *f_options[j].variable = ! f_options[j].on_value;
4090 return 1;
4094 if ((option_value = skip_leading_substring (arg, "inline-limit-"))
4095 || (option_value = skip_leading_substring (arg, "inline-limit=")))
4097 int val =
4098 read_integral_parameter (option_value, arg - 2,
4099 MAX_INLINE_INSNS);
4100 set_param_value ("max-inline-insns", val);
4102 #ifdef INSN_SCHEDULING
4103 else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
4104 fix_sched_param ("verbose", option_value);
4105 #endif
4106 else if ((option_value = skip_leading_substring (arg, "fixed-")))
4107 fix_register (option_value, 1, 1);
4108 else if ((option_value = skip_leading_substring (arg, "call-used-")))
4109 fix_register (option_value, 0, 1);
4110 else if ((option_value = skip_leading_substring (arg, "call-saved-")))
4111 fix_register (option_value, 0, 0);
4112 else if ((option_value = skip_leading_substring (arg, "align-loops=")))
4113 align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
4114 else if ((option_value = skip_leading_substring (arg, "align-functions=")))
4115 align_functions
4116 = read_integral_parameter (option_value, arg - 2, align_functions);
4117 else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
4118 align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
4119 else if ((option_value = skip_leading_substring (arg, "align-labels=")))
4120 align_labels
4121 = read_integral_parameter (option_value, arg - 2, align_labels);
4122 else if ((option_value
4123 = skip_leading_substring (arg, "stack-limit-register=")))
4125 int reg = decode_reg_name (option_value);
4126 if (reg < 0)
4127 error ("unrecognized register name `%s'", option_value);
4128 else
4129 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
4131 else if ((option_value
4132 = skip_leading_substring (arg, "stack-limit-symbol=")))
4134 const char *nm;
4135 nm = ggc_strdup (option_value);
4136 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
4138 else if ((option_value
4139 = skip_leading_substring (arg, "message-length=")))
4140 diagnostic_message_length_per_line =
4141 read_integral_parameter (option_value, arg - 2,
4142 diagnostic_message_length_per_line);
4143 else if ((option_value
4144 = skip_leading_substring (arg, "diagnostics-show-location=")))
4146 if (!strcmp (option_value, "once"))
4147 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
4148 else if (!strcmp (option_value, "every-line"))
4149 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE);
4150 else
4151 error ("Unrecognized option `%s'", arg - 2);
4153 else if (!strcmp (arg, "no-stack-limit"))
4154 stack_limit_rtx = NULL_RTX;
4155 else if (!strcmp (arg, "preprocessed"))
4156 /* Recognise this switch but do nothing. This prevents warnings
4157 about an unrecognized switch if cpplib has not been linked in. */
4159 else
4160 return 0;
4162 return 1;
4165 /* Parse a -W... comand line switch. ARG is the value after the -W.
4166 It is safe to access 'ARG - 2' to generate the full switch name.
4167 Return the number of strings consumed. */
4169 static int
4170 decode_W_option (arg)
4171 const char *arg;
4173 const char *option_value = NULL;
4174 int j;
4176 /* Search for the option in the table of binary W options. */
4178 for (j = ARRAY_SIZE (W_options); j--;)
4180 if (!strcmp (arg, W_options[j].string))
4182 *W_options[j].variable = W_options[j].on_value;
4183 return 1;
4186 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4187 && ! strcmp (arg + 3, W_options[j].string))
4189 *W_options[j].variable = ! W_options[j].on_value;
4190 return 1;
4194 if ((option_value = skip_leading_substring (arg, "id-clash-")))
4196 id_clash_len = read_integral_parameter (option_value, arg - 2, -1);
4198 if (id_clash_len != -1)
4199 warn_id_clash = 1;
4201 else if ((option_value = skip_leading_substring (arg, "larger-than-")))
4203 larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
4205 warn_larger_than = larger_than_size != -1;
4207 else if (!strcmp (arg, "unused"))
4209 set_Wunused (1);
4211 else if (!strcmp (arg, "no-unused"))
4213 set_Wunused (0);
4215 else
4216 return 0;
4218 return 1;
4221 /* Parse a -g... comand line switch. ARG is the value after the -g.
4222 It is safe to access 'ARG - 2' to generate the full switch name.
4223 Return the number of strings consumed. */
4225 static int
4226 decode_g_option (arg)
4227 const char *arg;
4229 unsigned level;
4230 /* A lot of code assumes write_symbols == NO_DEBUG if the
4231 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4232 of what debugging type has been selected). This records the
4233 selected type. It is an error to specify more than one
4234 debugging type. */
4235 static enum debug_info_type selected_debug_type = NO_DEBUG;
4236 /* Non-zero if debugging format has been explicitly set.
4237 -g and -ggdb don't explicitly set the debugging format so
4238 -gdwarf -g3 is equivalent to -gdwarf3. */
4239 static int type_explicitly_set_p = 0;
4240 /* Indexed by enum debug_info_type. */
4241 static const char *debug_type_names[] =
4243 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4246 /* The maximum admissible debug level value. */
4247 static const unsigned max_debug_level = 3;
4249 /* Look up ARG in the table. */
4250 for (da = debug_args; da->arg; da++)
4252 const int da_len = strlen (da->arg);
4254 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4256 enum debug_info_type type = da->debug_type;
4257 const char *p = arg + da_len;
4259 if (*p && (*p < '0' || *p > '9'))
4260 continue;
4262 /* A debug flag without a level defaults to level 2.
4263 Note we do not want to call read_integral_parameter
4264 for that case since it will call atoi which
4265 will return zero.
4267 ??? We may want to generalize the interface to
4268 read_integral_parameter to better handle this case
4269 if this case shows up often. */
4270 if (*p)
4271 level = read_integral_parameter (p, 0, max_debug_level + 1);
4272 else
4273 level = 2;
4275 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4277 error ("use -gdwarf -g%d for DWARF v1, level %d",
4278 level, level);
4279 if (level == 2)
4280 error ("use -gdwarf-2 for DWARF v2");
4283 if (level > max_debug_level)
4285 warning ("\
4286 ignoring option `%s' due to invalid debug level specification",
4287 arg - 2);
4288 level = debug_info_level;
4291 if (type == NO_DEBUG)
4293 type = PREFERRED_DEBUGGING_TYPE;
4295 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4297 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4298 type = DWARF2_DEBUG;
4299 #else
4300 #ifdef DBX_DEBUGGING_INFO
4301 type = DBX_DEBUG;
4302 #endif
4303 #endif
4307 if (type == NO_DEBUG)
4308 warning ("`%s': unknown or unsupported -g option", arg - 2);
4310 /* Does it conflict with an already selected type? */
4311 if (type_explicitly_set_p
4312 /* -g/-ggdb don't conflict with anything. */
4313 && da->debug_type != NO_DEBUG
4314 && type != selected_debug_type)
4315 warning ("`%s' ignored, conflicts with `-g%s'",
4316 arg - 2, debug_type_names[(int) selected_debug_type]);
4317 else
4319 /* If the format has already been set, -g/-ggdb
4320 only change the debug level. */
4321 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4322 /* Don't change debugging type. */
4324 else
4326 selected_debug_type = type;
4327 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4330 write_symbols = (level == 0
4331 ? NO_DEBUG
4332 : selected_debug_type);
4333 use_gnu_debug_info_extensions = da->use_extensions_p;
4334 debug_info_level = (enum debug_info_level) level;
4337 break;
4341 if (! da->arg)
4342 return 0;
4344 return 1;
4347 /* Decode the first argument in the argv as a language-independent option.
4348 Return the number of strings consumed. */
4350 static unsigned int
4351 independent_decode_option (argc, argv)
4352 int argc;
4353 char **argv;
4355 char *arg = argv[0];
4357 if (arg[0] != '-' || arg[1] == 0)
4359 if (arg[0] == '+')
4360 return 0;
4362 filename = arg;
4364 return 1;
4367 arg++;
4369 if (!strcmp (arg, "-help"))
4371 display_help ();
4372 exit_after_options = 1;
4375 if (!strcmp (arg, "-target-help"))
4377 display_target_options ();
4378 exit_after_options = 1;
4381 if (!strcmp (arg, "-version"))
4383 print_version (stderr, "");
4384 exit_after_options = 1;
4387 /* Handle '--param <name>=<value>'. */
4388 if (strcmp (arg, "-param") == 0)
4390 char *equal;
4392 if (argc == 1)
4394 error ("-param option missing argument");
4395 return 1;
4398 /* Get the '<name>=<value>' parameter. */
4399 arg = argv[1];
4400 /* Look for the `='. */
4401 equal = strchr (arg, '=');
4402 if (!equal)
4403 error ("invalid --param option: %s", arg);
4404 else
4406 int val;
4408 /* Zero out the `=' sign so that we get two separate strings. */
4409 *equal = '\0';
4410 /* Figure out what value is specified. */
4411 val = read_integral_parameter (equal + 1, NULL, INVALID_PARAM_VAL);
4412 if (val != INVALID_PARAM_VAL)
4413 set_param_value (arg, val);
4414 else
4415 error ("invalid parameter value `%s'", equal + 1);
4418 return 2;
4421 if (*arg == 'Y')
4422 arg++;
4424 switch (*arg)
4426 default:
4427 return 0;
4429 case 'O':
4430 /* Already been treated in main (). Do nothing. */
4431 break;
4433 case 'm':
4434 set_target_switch (arg + 1);
4435 break;
4437 case 'f':
4438 return decode_f_option (arg + 1);
4440 case 'g':
4441 return decode_g_option (arg + 1);
4443 case 'd':
4444 if (!strcmp (arg, "dumpbase"))
4446 if (argc == 1)
4447 return 0;
4449 dump_base_name = argv[1];
4450 return 2;
4452 else
4453 decode_d_option (arg + 1);
4454 break;
4456 case 'p':
4457 if (!strcmp (arg, "pedantic"))
4458 pedantic = 1;
4459 else if (!strcmp (arg, "pedantic-errors"))
4460 flag_pedantic_errors = pedantic = 1;
4461 else if (arg[1] == 0)
4462 profile_flag = 1;
4463 else
4464 return 0;
4465 break;
4467 case 'q':
4468 if (!strcmp (arg, "quiet"))
4469 quiet_flag = 1;
4470 else
4471 return 0;
4472 break;
4474 case 'v':
4475 if (!strcmp (arg, "version"))
4476 version_flag = 1;
4477 else
4478 return 0;
4479 break;
4481 case 'w':
4482 if (arg[1] == 0)
4483 inhibit_warnings = 1;
4484 else
4485 return 0;
4486 break;
4488 case 'W':
4489 if (arg[1] == 0)
4491 extra_warnings = 1;
4492 /* We save the value of warn_uninitialized, since if they put
4493 -Wuninitialized on the command line, we need to generate a
4494 warning about not using it without also specifying -O. */
4495 if (warn_uninitialized != 1)
4496 warn_uninitialized = 2;
4498 else
4499 return decode_W_option (arg + 1);
4500 break;
4502 case 'a':
4503 if (arg[1] == 0)
4505 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4506 warning ("`-a' option (basic block profile) not supported");
4507 #else
4508 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4509 #endif
4511 else if (!strcmp (arg, "ax"))
4513 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4514 warning ("`-ax' option (jump profiling) not supported");
4515 #else
4516 profile_block_flag = (!profile_block_flag
4517 || profile_block_flag == 2) ? 2 : 3;
4518 #endif
4520 else if (!strncmp (arg, "aux-info", 8))
4522 flag_gen_aux_info = 1;
4523 if (arg[8] == '\0')
4525 if (argc == 1)
4526 return 0;
4528 aux_info_file_name = argv[1];
4529 return 2;
4531 else
4532 aux_info_file_name = arg + 8;
4534 else
4535 return 0;
4536 break;
4538 case 'o':
4539 if (arg[1] == 0)
4541 if (argc == 1)
4542 return 0;
4544 asm_file_name = argv[1];
4545 return 2;
4547 return 0;
4549 case 'G':
4551 int g_switch_val;
4552 int return_val;
4554 if (arg[1] == 0)
4556 if (argc == 1)
4557 return 0;
4559 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4560 return_val = 2;
4562 else
4564 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4565 return_val = 1;
4568 if (g_switch_val == -1)
4569 return_val = 0;
4570 else
4572 g_switch_set = TRUE;
4573 g_switch_value = g_switch_val;
4576 return return_val;
4580 return 1;
4583 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4584 Exit code is 35 if can't open files, 34 if fatal error,
4585 33 if had nonfatal errors, else success. */
4587 extern int main PARAMS ((int, char **));
4590 main (argc, argv)
4591 int argc;
4592 char **argv;
4594 register int i;
4595 char *p;
4597 /* save in case md file wants to emit args as a comment. */
4598 save_argc = argc;
4599 save_argv = argv;
4601 p = argv[0] + strlen (argv[0]);
4602 while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
4603 --p;
4604 progname = p;
4606 xmalloc_set_program_name (progname);
4608 /* LC_CTYPE determines the character set used by the terminal so it has be set
4609 to output messages correctly. */
4611 #ifdef HAVE_LC_MESSAGES
4612 setlocale (LC_CTYPE, "");
4613 setlocale (LC_MESSAGES, "");
4614 #else
4615 setlocale (LC_ALL, "");
4616 #endif
4618 (void) bindtextdomain (PACKAGE, localedir);
4619 (void) textdomain (PACKAGE);
4621 /* Install handler for SIGFPE, which may be received while we do
4622 compile-time floating point arithmetic. */
4623 signal (SIGFPE, float_signal);
4625 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4626 #ifdef SIGSEGV
4627 signal (SIGSEGV, crash_signal);
4628 #endif
4629 #ifdef SIGILL
4630 signal (SIGILL, crash_signal);
4631 #endif
4632 #ifdef SIGBUS
4633 signal (SIGBUS, crash_signal);
4634 #endif
4635 #ifdef SIGABRT
4636 signal (SIGABRT, crash_signal);
4637 #endif
4638 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4639 signal (SIGIOT, crash_signal);
4640 #endif
4642 decl_printable_name = decl_name;
4643 lang_expand_expr = (lang_expand_expr_t) do_abort;
4645 /* Initialize whether `char' is signed. */
4646 flag_signed_char = DEFAULT_SIGNED_CHAR;
4647 #ifdef DEFAULT_SHORT_ENUMS
4648 /* Initialize how much space enums occupy, by default. */
4649 flag_short_enums = DEFAULT_SHORT_ENUMS;
4650 #endif
4652 /* Initialize the garbage-collector. */
4653 init_ggc ();
4654 init_stringpool ();
4655 ggc_add_rtx_root (&stack_limit_rtx, 1);
4656 ggc_add_tree_root (&current_function_decl, 1);
4657 ggc_add_tree_root (&current_function_func_begin_label, 1);
4659 /* Initialize the diagnostics reporting machinery. */
4660 initialize_diagnostics ();
4662 /* Register the language-independent parameters. */
4663 add_params (lang_independent_params, LAST_PARAM);
4665 /* Perform language-specific options intialization. */
4666 if (lang_hooks.init_options)
4667 (*lang_hooks.init_options) ();
4669 /* Scan to see what optimization level has been specified. That will
4670 determine the default value of many flags. */
4671 for (i = 1; i < argc; i++)
4673 if (!strcmp (argv[i], "-O"))
4675 optimize = 1;
4676 optimize_size = 0;
4678 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4680 /* Handle -Os, -O2, -O3, -O69, ... */
4681 char *p = &argv[i][2];
4683 if ((p[0] == 's') && (p[1] == 0))
4685 optimize_size = 1;
4687 /* Optimizing for size forces optimize to be 2. */
4688 optimize = 2;
4690 else
4692 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4693 if (optimize_val != -1)
4695 optimize = optimize_val;
4696 optimize_size = 0;
4702 if (optimize >= 1)
4704 flag_defer_pop = 1;
4705 flag_thread_jumps = 1;
4706 #ifdef DELAY_SLOTS
4707 flag_delayed_branch = 1;
4708 #endif
4709 #ifdef CAN_DEBUG_WITHOUT_FP
4710 flag_omit_frame_pointer = 1;
4711 #endif
4712 flag_guess_branch_prob = 1;
4715 if (optimize >= 2)
4717 flag_optimize_sibling_calls = 1;
4718 flag_cse_follow_jumps = 1;
4719 flag_cse_skip_blocks = 1;
4720 flag_gcse = 1;
4721 flag_expensive_optimizations = 1;
4722 flag_strength_reduce = 1;
4723 flag_rerun_cse_after_loop = 1;
4724 flag_rerun_loop_opt = 1;
4725 flag_caller_saves = 1;
4726 flag_force_mem = 1;
4727 flag_peephole2 = 1;
4728 #ifdef INSN_SCHEDULING
4729 flag_schedule_insns = 1;
4730 flag_schedule_insns_after_reload = 1;
4731 #endif
4732 flag_regmove = 1;
4733 flag_strict_aliasing = 1;
4734 flag_delete_null_pointer_checks = 1;
4735 flag_reorder_blocks = 1;
4738 if (optimize >= 3)
4740 flag_inline_functions = 1;
4741 flag_rename_registers = 1;
4744 if (optimize < 2 || optimize_size)
4746 align_loops = 1;
4747 align_jumps = 1;
4748 align_labels = 1;
4749 align_functions = 1;
4752 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4753 modify it. */
4754 target_flags = 0;
4755 set_target_switch ("");
4757 /* Unwind tables are always present in an ABI-conformant IA-64
4758 object file, so the default should be ON. */
4759 #ifdef IA64_UNWIND_INFO
4760 flag_unwind_tables = IA64_UNWIND_INFO;
4761 #endif
4763 #ifdef OPTIMIZATION_OPTIONS
4764 /* Allow default optimizations to be specified on a per-machine basis. */
4765 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4766 #endif
4768 /* Initialize register usage now so switches may override. */
4769 init_reg_sets ();
4771 /* Perform normal command line switch decoding. */
4772 for (i = 1; i < argc;)
4774 int lang_processed;
4775 int indep_processed;
4777 /* Give the language a chance to decode the option for itself. */
4778 lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
4780 if (lang_processed >= 0)
4781 /* Now see if the option also has a language independent meaning.
4782 Some options are both language specific and language independent,
4783 eg --help. */
4784 indep_processed = independent_decode_option (argc - i, argv + i);
4785 else
4787 lang_processed = -lang_processed;
4788 indep_processed = 0;
4791 if (lang_processed || indep_processed)
4792 i += MAX (lang_processed, indep_processed);
4793 else
4795 const char *option = NULL;
4796 const char *lang = NULL;
4797 unsigned int j;
4799 /* It is possible that the command line switch is not valid for the
4800 current language, but it is valid for another language. In order
4801 to be compatible with previous versions of the compiler (which
4802 did not issue an error message in this case) we check for this
4803 possibility here. If we do find a match, then if extra_warnings
4804 is set we generate a warning message, otherwise we will just
4805 ignore the option. */
4806 for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4808 option = documented_lang_options[j].option;
4810 if (option == NULL)
4811 lang = documented_lang_options[j].description;
4812 else if (! strncmp (argv[i], option, strlen (option)))
4813 break;
4816 if (j != ARRAY_SIZE (documented_lang_options))
4818 if (extra_warnings)
4820 warning ("Ignoring command line option '%s'", argv[i]);
4821 if (lang)
4822 warning
4823 ("(It is valid for %s but not the selected language)",
4824 lang);
4827 else if (argv[i][0] == '-' && argv[i][1] == 'g')
4828 warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
4829 else
4830 error ("Unrecognized option `%s'", argv[i]);
4832 i++;
4836 /* All command line options have been processed. */
4837 if (lang_hooks.post_options)
4838 (*lang_hooks.post_options) ();
4840 if (exit_after_options)
4841 exit (0);
4843 /* Reflect any language-specific diagnostic option setting. */
4844 reshape_diagnostic_buffer ();
4846 /* Checker uses the frame pointer. */
4847 if (flag_check_memory_usage)
4848 flag_omit_frame_pointer = 0;
4850 if (optimize == 0)
4852 /* Inlining does not work if not optimizing,
4853 so force it not to be done. */
4854 flag_no_inline = 1;
4855 warn_inline = 0;
4857 /* The c_decode_option function and decode_option hook set
4858 this to `2' if -Wall is used, so we can avoid giving out
4859 lots of errors for people who don't realize what -Wall does. */
4860 if (warn_uninitialized == 1)
4861 warning ("-Wuninitialized is not supported without -O");
4864 #ifdef OVERRIDE_OPTIONS
4865 /* Some machines may reject certain combinations of options. */
4866 OVERRIDE_OPTIONS;
4867 #endif
4869 /* Set up the align_*_log variables, defaulting them to 1 if they
4870 were still unset. */
4871 if (align_loops <= 0) align_loops = 1;
4872 align_loops_log = floor_log2 (align_loops * 2 - 1);
4873 if (align_jumps <= 0) align_jumps = 1;
4874 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4875 if (align_labels <= 0) align_labels = 1;
4876 align_labels_log = floor_log2 (align_labels * 2 - 1);
4877 if (align_functions <= 0) align_functions = 1;
4878 align_functions_log = floor_log2 (align_functions * 2 - 1);
4880 if (profile_block_flag == 3)
4882 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4883 profile_block_flag = 2;
4886 /* Unrolling all loops implies that standard loop unrolling must also
4887 be done. */
4888 if (flag_unroll_all_loops)
4889 flag_unroll_loops = 1;
4890 /* Loop unrolling requires that strength_reduction be on also. Silently
4891 turn on strength reduction here if it isn't already on. Also, the loop
4892 unrolling code assumes that cse will be run after loop, so that must
4893 be turned on also. */
4894 if (flag_unroll_loops)
4896 flag_strength_reduce = 1;
4897 flag_rerun_cse_after_loop = 1;
4900 /* Warn about options that are not supported on this machine. */
4901 #ifndef INSN_SCHEDULING
4902 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4903 warning ("instruction scheduling not supported on this target machine");
4904 #endif
4905 #ifndef DELAY_SLOTS
4906 if (flag_delayed_branch)
4907 warning ("this target machine does not have delayed branches");
4908 #endif
4910 /* Some operating systems do not allow profiling without a frame
4911 pointer. */
4912 if (!TARGET_ALLOWS_PROFILING_WITHOUT_FRAME_POINTER
4913 && profile_flag
4914 && flag_omit_frame_pointer)
4916 error ("profiling does not work without a frame pointer");
4917 flag_omit_frame_pointer = 0;
4920 user_label_prefix = USER_LABEL_PREFIX;
4921 if (flag_leading_underscore != -1)
4923 /* If the default prefix is more complicated than "" or "_",
4924 issue a warning and ignore this option. */
4925 if (user_label_prefix[0] == 0 ||
4926 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4928 user_label_prefix = flag_leading_underscore ? "_" : "";
4930 else
4931 warning ("-f%sleading-underscore not supported on this target machine",
4932 flag_leading_underscore ? "" : "no-");
4935 /* If we are in verbose mode, write out the version and maybe all the
4936 option flags in use. */
4937 if (version_flag)
4939 print_version (stderr, "");
4940 if (! quiet_flag)
4941 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4944 compile_file (filename);
4946 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
4947 if (flag_print_mem)
4949 char *lim = (char *) sbrk (0);
4951 fnotice (stderr, "Data size %ld.\n", (long) (lim - (char *) &environ));
4952 fflush (stderr);
4954 #ifndef __MSDOS__
4955 #ifdef USG
4956 system ("ps -l 1>&2");
4957 #else /* not USG */
4958 system ("ps v");
4959 #endif /* not USG */
4960 #endif
4962 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
4964 if (errorcount)
4965 return (FATAL_EXIT_CODE);
4966 if (sorrycount)
4967 return (FATAL_EXIT_CODE);
4968 return (SUCCESS_EXIT_CODE);
4971 /* Decode -m switches. */
4972 /* Decode the switch -mNAME. */
4974 static void
4975 set_target_switch (name)
4976 const char *name;
4978 register size_t j;
4979 int valid_target_option = 0;
4981 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4982 if (!strcmp (target_switches[j].name, name))
4984 if (target_switches[j].value < 0)
4985 target_flags &= ~-target_switches[j].value;
4986 else
4987 target_flags |= target_switches[j].value;
4988 valid_target_option = 1;
4991 #ifdef TARGET_OPTIONS
4992 if (!valid_target_option)
4993 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4995 int len = strlen (target_options[j].prefix);
4996 if (!strncmp (target_options[j].prefix, name, len))
4998 *target_options[j].variable = name + len;
4999 valid_target_option = 1;
5002 #endif
5004 if (!valid_target_option)
5005 error ("Invalid option `%s'", name);
5008 /* Print version information to FILE.
5009 Each line begins with INDENT (for the case where FILE is the
5010 assembler output file). */
5012 static void
5013 print_version (file, indent)
5014 FILE *file;
5015 const char *indent;
5017 #ifndef __VERSION__
5018 #define __VERSION__ "[?]"
5019 #endif
5020 fnotice (file,
5021 #ifdef __GNUC__
5022 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
5023 #else
5024 "%s%s%s version %s (%s) compiled by CC.\n"
5025 #endif
5026 , indent, *indent != 0 ? " " : "",
5027 language_string, version_string, TARGET_NAME,
5028 indent, __VERSION__);
5031 /* Print an option value and return the adjusted position in the line.
5032 ??? We don't handle error returns from fprintf (disk full); presumably
5033 other code will catch a disk full though. */
5035 static int
5036 print_single_switch (file, pos, max, indent, sep, term, type, name)
5037 FILE *file;
5038 int pos, max;
5039 const char *indent, *sep, *term, *type, *name;
5041 /* The ultrix fprintf returns 0 on success, so compute the result we want
5042 here since we need it for the following test. */
5043 int len = strlen (sep) + strlen (type) + strlen (name);
5045 if (pos != 0
5046 && pos + len > max)
5048 fprintf (file, "%s", term);
5049 pos = 0;
5051 if (pos == 0)
5053 fprintf (file, "%s", indent);
5054 pos = strlen (indent);
5056 fprintf (file, "%s%s%s", sep, type, name);
5057 pos += len;
5058 return pos;
5061 /* Print active target switches to FILE.
5062 POS is the current cursor position and MAX is the size of a "line".
5063 Each line begins with INDENT and ends with TERM.
5064 Each switch is separated from the next by SEP. */
5066 static void
5067 print_switch_values (file, pos, max, indent, sep, term)
5068 FILE *file;
5069 int pos, max;
5070 const char *indent, *sep, *term;
5072 size_t j;
5073 char **p;
5075 /* Print the options as passed. */
5077 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5078 _("options passed: "), "");
5080 for (p = &save_argv[1]; *p != NULL; p++)
5081 if (**p == '-')
5083 /* Ignore these. */
5084 if (strcmp (*p, "-o") == 0)
5086 if (p[1] != NULL)
5087 p++;
5088 continue;
5090 if (strcmp (*p, "-quiet") == 0)
5091 continue;
5092 if (strcmp (*p, "-version") == 0)
5093 continue;
5094 if ((*p)[1] == 'd')
5095 continue;
5097 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5099 if (pos > 0)
5100 fprintf (file, "%s", term);
5102 /* Print the -f and -m options that have been enabled.
5103 We don't handle language specific options but printing argv
5104 should suffice. */
5106 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5107 _("options enabled: "), "");
5109 for (j = 0; j < ARRAY_SIZE (f_options); j++)
5110 if (*f_options[j].variable == f_options[j].on_value)
5111 pos = print_single_switch (file, pos, max, indent, sep, term,
5112 "-f", f_options[j].string);
5114 /* Print target specific options. */
5116 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
5117 if (target_switches[j].name[0] != '\0'
5118 && target_switches[j].value > 0
5119 && ((target_switches[j].value & target_flags)
5120 == target_switches[j].value))
5122 pos = print_single_switch (file, pos, max, indent, sep, term,
5123 "-m", target_switches[j].name);
5126 #ifdef TARGET_OPTIONS
5127 for (j = 0; j < ARRAY_SIZE (target_options); j++)
5128 if (*target_options[j].variable != NULL)
5130 char prefix[256];
5131 sprintf (prefix, "-m%s", target_options[j].prefix);
5132 pos = print_single_switch (file, pos, max, indent, sep, term,
5133 prefix, *target_options[j].variable);
5135 #endif
5137 fprintf (file, "%s", term);
5140 /* Record the beginning of a new source file, named FILENAME. */
5142 void
5143 debug_start_source_file (filename)
5144 register const char *filename ATTRIBUTE_UNUSED;
5146 #ifdef DBX_DEBUGGING_INFO
5147 if (write_symbols == DBX_DEBUG)
5148 dbxout_start_new_source_file (filename);
5149 #endif
5150 #ifdef DWARF_DEBUGGING_INFO
5151 if (debug_info_level == DINFO_LEVEL_VERBOSE
5152 && write_symbols == DWARF_DEBUG)
5153 dwarfout_start_new_source_file (filename);
5154 #endif /* DWARF_DEBUGGING_INFO */
5155 #ifdef DWARF2_DEBUGGING_INFO
5156 if (write_symbols == DWARF2_DEBUG)
5157 dwarf2out_start_source_file (filename);
5158 #endif /* DWARF2_DEBUGGING_INFO */
5159 #ifdef SDB_DEBUGGING_INFO
5160 if (write_symbols == SDB_DEBUG)
5161 sdbout_start_new_source_file (filename);
5162 #endif
5165 /* Record the resumption of a source file. LINENO is the line number in
5166 the source file we are returning to. */
5168 void
5169 debug_end_source_file (lineno)
5170 register unsigned lineno ATTRIBUTE_UNUSED;
5172 #ifdef DBX_DEBUGGING_INFO
5173 if (write_symbols == DBX_DEBUG)
5174 dbxout_resume_previous_source_file ();
5175 #endif
5176 #ifdef DWARF_DEBUGGING_INFO
5177 if (debug_info_level == DINFO_LEVEL_VERBOSE
5178 && write_symbols == DWARF_DEBUG)
5179 dwarfout_resume_previous_source_file (lineno);
5180 #endif /* DWARF_DEBUGGING_INFO */
5181 #ifdef DWARF2_DEBUGGING_INFO
5182 if (write_symbols == DWARF2_DEBUG)
5183 dwarf2out_end_source_file ();
5184 #endif /* DWARF2_DEBUGGING_INFO */
5185 #ifdef SDB_DEBUGGING_INFO
5186 if (write_symbols == SDB_DEBUG)
5187 sdbout_resume_previous_source_file ();
5188 #endif
5191 /* Called from cb_define in c-lex.c. The `buffer' parameter contains
5192 the tail part of the directive line, i.e. the part which is past the
5193 initial whitespace, #, whitespace, directive-name, whitespace part. */
5195 void
5196 debug_define (lineno, buffer)
5197 register unsigned lineno ATTRIBUTE_UNUSED;
5198 register const char *buffer ATTRIBUTE_UNUSED;
5200 #ifdef DWARF_DEBUGGING_INFO
5201 if (write_symbols == DWARF_DEBUG)
5202 dwarfout_define (lineno, buffer);
5203 #endif /* DWARF_DEBUGGING_INFO */
5204 #ifdef DWARF2_DEBUGGING_INFO
5205 if (write_symbols == DWARF2_DEBUG)
5206 dwarf2out_define (lineno, buffer);
5207 #endif /* DWARF2_DEBUGGING_INFO */
5210 /* Called from cb_undef in c-lex.c. The `buffer' parameter contains
5211 the tail part of the directive line, i.e. the part which is past the
5212 initial whitespace, #, whitespace, directive-name, whitespace part. */
5214 void
5215 debug_undef (lineno, buffer)
5216 register unsigned lineno ATTRIBUTE_UNUSED;
5217 register const char *buffer ATTRIBUTE_UNUSED;
5219 #ifdef DWARF_DEBUGGING_INFO
5220 if (write_symbols == DWARF_DEBUG)
5221 dwarfout_undef (lineno, buffer);
5222 #endif /* DWARF_DEBUGGING_INFO */
5223 #ifdef DWARF2_DEBUGGING_INFO
5224 if (write_symbols == DWARF2_DEBUG)
5225 dwarf2out_undef (lineno, buffer);
5226 #endif /* DWARF2_DEBUGGING_INFO */
5229 /* Returns nonzero if it is appropriate not to emit any debugging
5230 information for BLOCK, because it doesn't contain any instructions.
5231 This may not be the case for blocks containing nested functions, since
5232 we may actually call such a function even though the BLOCK information
5233 is messed up. */
5236 debug_ignore_block (block)
5237 tree block ATTRIBUTE_UNUSED;
5239 /* Never delete the BLOCK for the outermost scope
5240 of the function; we can refer to names from
5241 that scope even if the block notes are messed up. */
5242 if (is_body_block (block))
5243 return 0;
5245 #ifdef DWARF2_DEBUGGING_INFO
5246 if (write_symbols == DWARF2_DEBUG)
5247 return dwarf2out_ignore_block (block);
5248 #endif
5250 return 1;