Bump dates.
[official-gcc.git] / gcc / toplev.c
blobd4b0fc605db281c83343e5ae4b1c0d9a1ab3d807
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-codes.h"
49 #include "insn-config.h"
50 #include "hard-reg-set.h"
51 #include "recog.h"
52 #include "output.h"
53 #include "except.h"
54 #include "function.h"
55 #include "toplev.h"
56 #include "expr.h"
57 #include "basic-block.h"
58 #include "intl.h"
59 #include "ggc.h"
60 #include "graph.h"
61 #include "loop.h"
62 #include "regs.h"
63 #include "timevar.h"
64 #include "diagnostic.h"
65 #include "ssa.h"
66 #include "params.h"
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_jump,
257 DFI_cse,
258 DFI_addressof,
259 DFI_ssa,
260 DFI_dce,
261 DFI_ussa,
262 DFI_gcse,
263 DFI_loop,
264 DFI_cse2,
265 DFI_cfg,
266 DFI_bp,
267 DFI_life,
268 DFI_combine,
269 DFI_ce,
270 DFI_regmove,
271 DFI_sched,
272 DFI_lreg,
273 DFI_greg,
274 DFI_postreload,
275 DFI_flow2,
276 DFI_peephole2,
277 DFI_rnreg,
278 DFI_ce2,
279 DFI_sched2,
280 DFI_bbro,
281 DFI_jump2,
282 DFI_mach,
283 DFI_dbr,
284 DFI_stack,
285 DFI_MAX
288 /* Describes all the dump files. Should be kept in order of the
289 pass and in sync with dump_file_index above.
291 Remaining -d letters:
293 " h o q u "
294 " H K OPQ TUVW YZ"
297 struct dump_file_info dump_file[DFI_MAX] =
299 { "rtl", 'r', 0, 0, 0 },
300 { "sibling", 'i', 0, 0, 0 },
301 { "jump", 'j', 0, 0, 0 },
302 { "cse", 's', 0, 0, 0 },
303 { "addressof", 'F', 0, 0, 0 },
304 { "ssa", 'e', 1, 0, 0 },
305 { "dce", 'X', 1, 0, 0 },
306 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
307 { "gcse", 'G', 1, 0, 0 },
308 { "loop", 'L', 1, 0, 0 },
309 { "cse2", 't', 1, 0, 0 },
310 { "cfg", 'f', 1, 0, 0 },
311 { "bp", 'b', 1, 0, 0 },
312 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
313 { "combine", 'c', 1, 0, 0 },
314 { "ce", 'C', 1, 0, 0 },
315 { "regmove", 'N', 1, 0, 0 },
316 { "sched", 'S', 1, 0, 0 },
317 { "lreg", 'l', 1, 0, 0 },
318 { "greg", 'g', 1, 0, 0 },
319 { "postreload", 'o', 1, 0, 0 },
320 { "flow2", 'w', 1, 0, 0 },
321 { "peephole2", 'z', 1, 0, 0 },
322 { "rnreg", 'n', 1, 0, 0 },
323 { "ce2", 'E', 1, 0, 0 },
324 { "sched2", 'R', 1, 0, 0 },
325 { "bbro", 'B', 1, 0, 0 },
326 { "jump2", 'J', 1, 0, 0 },
327 { "mach", 'M', 1, 0, 0 },
328 { "dbr", 'd', 0, 0, 0 },
329 { "stack", 'k', 1, 0, 0 },
332 static int open_dump_file PARAMS ((enum dump_file_index, tree));
333 static void close_dump_file PARAMS ((enum dump_file_index,
334 void (*) (FILE *, rtx), rtx));
336 /* Other flags saying which kinds of debugging dump have been requested. */
338 int rtl_dump_and_exit;
339 int flag_print_asm_name;
340 static int flag_print_mem;
341 static int version_flag;
342 static char *filename;
343 enum graph_dump_types graph_dump_format;
345 /* Name for output file of assembly code, specified with -o. */
347 char *asm_file_name;
349 /* Value of the -G xx switch, and whether it was passed or not. */
350 int g_switch_value;
351 int g_switch_set;
353 /* Type(s) of debugging information we are producing (if any).
354 See flags.h for the definitions of the different possible
355 types of debugging information. */
356 enum debug_info_type write_symbols = NO_DEBUG;
358 /* Level of debugging information we are producing. See flags.h
359 for the definitions of the different possible levels. */
360 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
362 /* Nonzero means use GNU-only extensions in the generated symbolic
363 debugging information. */
364 /* Currently, this only has an effect when write_symbols is set to
365 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
366 int use_gnu_debug_info_extensions = 0;
368 /* Nonzero means do optimizations. -O.
369 Particular numeric values stand for particular amounts of optimization;
370 thus, -O2 stores 2 here. However, the optimizations beyond the basic
371 ones are not controlled directly by this variable. Instead, they are
372 controlled by individual `flag_...' variables that are defaulted
373 based on this variable. */
375 int optimize = 0;
377 /* Nonzero means optimize for size. -Os.
378 The only valid values are zero and non-zero. When optimize_size is
379 non-zero, optimize defaults to 2, but certain individual code
380 bloating optimizations are disabled. */
382 int optimize_size = 0;
384 /* Number of error messages and warning messages so far. */
386 int errorcount = 0;
387 int warningcount = 0;
388 int sorrycount = 0;
390 /* Nonzero if we should exit after parsing options. */
391 static int exit_after_options = 0;
393 /* The FUNCTION_DECL for the function currently being compiled,
394 or 0 if between functions. */
395 tree current_function_decl;
397 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
398 if none. */
399 tree current_function_func_begin_label;
401 /* Pointer to function to compute the name to use to print a declaration.
402 DECL is the declaration in question.
403 VERBOSITY determines what information will be printed:
404 0: DECL_NAME, demangled as necessary.
405 1: and scope information.
406 2: and any other information that might be interesting, such as function
407 parameter types in C++. */
409 const char *(*decl_printable_name) PARAMS ((tree, int));
411 /* Pointer to function to compute rtl for a language-specific tree code. */
413 typedef rtx (*lang_expand_expr_t)
414 PARAMS ((union tree_node *, rtx, enum machine_mode,
415 enum expand_modifier modifier));
417 lang_expand_expr_t lang_expand_expr = 0;
419 tree (*lang_expand_constant) PARAMS ((tree)) = 0;
421 /* Pointer to function to finish handling an incomplete decl at the
422 end of compilation. */
424 void (*incomplete_decl_finalize_hook) PARAMS ((tree)) = 0;
426 /* Nonzero if doing dwarf2 duplicate elimination. */
428 int flag_eliminate_dwarf2_dups = 0;
430 /* Nonzero if generating code to do profiling. */
432 int profile_flag = 0;
434 /* Nonzero if generating code to do profiling on a line-by-line basis. */
436 int profile_block_flag;
438 /* Nonzero if generating code to profile program flow graph arcs. */
440 int profile_arc_flag = 0;
442 /* Nonzero if generating info for gcov to calculate line test coverage. */
444 int flag_test_coverage = 0;
446 /* Nonzero indicates that branch taken probabilities should be calculated. */
448 int flag_branch_probabilities = 0;
450 /* Nonzero if basic blocks should be reordered. */
452 int flag_reorder_blocks = 0;
454 /* Nonzero if registers should be renamed. */
456 int flag_rename_registers = 0;
458 /* Nonzero for -pedantic switch: warn about anything
459 that standard spec forbids. */
461 int pedantic = 0;
463 /* Temporarily suppress certain warnings.
464 This is set while reading code from a system header file. */
466 int in_system_header = 0;
468 /* Don't print functions as they are compiled. -quiet. */
470 int quiet_flag = 0;
472 /* Print times taken by the various passes. -ftime-report. */
474 int time_report = 0;
476 /* Print memory still in use at end of compilation (which may have little
477 to do with peak memory consumption). -fmem-report. */
479 int mem_report = 0;
481 /* Non-zero means to collect statistics which might be expensive
482 and to print them when we are done. */
483 int flag_detailed_statistics = 0;
486 /* -f flags. */
488 /* Nonzero means `char' should be signed. */
490 int flag_signed_char;
492 /* Nonzero means give an enum type only as many bytes as it needs. */
494 int flag_short_enums;
496 /* Nonzero for -fcaller-saves: allocate values in regs that need to
497 be saved across function calls, if that produces overall better code.
498 Optional now, so people can test it. */
500 #ifdef DEFAULT_CALLER_SAVES
501 int flag_caller_saves = 1;
502 #else
503 int flag_caller_saves = 0;
504 #endif
506 /* Nonzero if structures and unions should be returned in memory.
508 This should only be defined if compatibility with another compiler or
509 with an ABI is needed, because it results in slower code. */
511 #ifndef DEFAULT_PCC_STRUCT_RETURN
512 #define DEFAULT_PCC_STRUCT_RETURN 1
513 #endif
515 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
517 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
519 /* Nonzero for -fforce-mem: load memory value into a register
520 before arithmetic on it. This makes better cse but slower compilation. */
522 int flag_force_mem = 0;
524 /* Nonzero for -fforce-addr: load memory address into a register before
525 reference to memory. This makes better cse but slower compilation. */
527 int flag_force_addr = 0;
529 /* Nonzero for -fdefer-pop: don't pop args after each function call;
530 instead save them up to pop many calls' args with one insns. */
532 int flag_defer_pop = 0;
534 /* Nonzero for -ffloat-store: don't allocate floats and doubles
535 in extended-precision registers. */
537 int flag_float_store = 0;
539 /* Nonzero for -fcse-follow-jumps:
540 have cse follow jumps to do a more extensive job. */
542 int flag_cse_follow_jumps;
544 /* Nonzero for -fcse-skip-blocks:
545 have cse follow a branch around a block. */
546 int flag_cse_skip_blocks;
548 /* Nonzero for -fexpensive-optimizations:
549 perform miscellaneous relatively-expensive optimizations. */
550 int flag_expensive_optimizations;
552 /* Nonzero for -fthread-jumps:
553 have jump optimize output of loop. */
555 int flag_thread_jumps;
557 /* Nonzero enables strength-reduction in loop.c. */
559 int flag_strength_reduce = 0;
561 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
562 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
563 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
564 unrolled. */
566 int flag_unroll_loops;
568 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
569 This is generally not a win. */
571 int flag_unroll_all_loops;
573 /* Nonzero forces all invariant computations in loops to be moved
574 outside the loop. */
576 int flag_move_all_movables = 0;
578 /* Nonzero forces all general induction variables in loops to be
579 strength reduced. */
581 int flag_reduce_all_givs = 0;
583 /* Nonzero to perform full register move optimization passes. This is the
584 default for -O2. */
586 int flag_regmove = 0;
588 /* Nonzero for -fwritable-strings:
589 store string constants in data segment and don't uniquize them. */
591 int flag_writable_strings = 0;
593 /* Nonzero means don't put addresses of constant functions in registers.
594 Used for compiling the Unix kernel, where strange substitutions are
595 done on the assembly output. */
597 int flag_no_function_cse = 0;
599 /* Nonzero for -fomit-frame-pointer:
600 don't make a frame pointer in simple functions that don't require one. */
602 int flag_omit_frame_pointer = 0;
604 /* Nonzero means place each function into its own section on those platforms
605 which support arbitrary section names and unlimited numbers of sections. */
607 int flag_function_sections = 0;
609 /* ... and similar for data. */
611 int flag_data_sections = 0;
613 /* Nonzero to inhibit use of define_optimization peephole opts. */
615 int flag_no_peephole = 0;
617 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
618 operations in the interest of optimization. For example it allows
619 GCC to assume arguments to sqrt are nonnegative numbers, allowing
620 faster code for sqrt to be generated. */
622 int flag_fast_math = 0;
624 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
626 int flag_optimize_sibling_calls = 0;
628 /* Nonzero means the front end generally wants `errno' maintained by math
629 operations, like built-in SQRT, unless overridden by flag_fast_math. */
631 int flag_errno_math = 1;
633 /* 0 means straightforward implementation of complex divide acceptable.
634 1 means wide ranges of inputs must work for complex divide.
635 2 means C99-like requirements for complex divide (not yet implemented). */
637 int flag_complex_divide_method = 0;
639 /* Nonzero means all references through pointers are volatile. */
641 int flag_volatile;
643 /* Nonzero means treat all global and extern variables as volatile. */
645 int flag_volatile_global;
647 /* Nonzero means treat all static variables as volatile. */
649 int flag_volatile_static;
651 /* Nonzero means just do syntax checking; don't output anything. */
653 int flag_syntax_only = 0;
655 /* Nonzero means perform global cse. */
657 static int flag_gcse;
659 /* Nonzero means to use global dataflow analysis to eliminate
660 useless null pointer tests. */
662 static int flag_delete_null_pointer_checks;
664 /* Nonzero means to rerun cse after loop optimization. This increases
665 compilation time about 20% and picks up a few more common expressions. */
667 static int flag_rerun_cse_after_loop;
669 /* Nonzero means to run loop optimizations twice. */
671 int flag_rerun_loop_opt;
673 /* Nonzero for -finline-functions: ok to inline functions that look like
674 good inline candidates. */
676 int flag_inline_functions;
678 /* Nonzero for -fkeep-inline-functions: even if we make a function
679 go inline everywhere, keep its definition around for debugging
680 purposes. */
682 int flag_keep_inline_functions;
684 /* Nonzero means that functions will not be inlined. */
686 int flag_no_inline;
688 /* Nonzero means that we should emit static const variables
689 regardless of whether or not optimization is turned on. */
691 int flag_keep_static_consts = 1;
693 /* Nonzero means we should be saving declaration info into a .X file. */
695 int flag_gen_aux_info = 0;
697 /* Specified name of aux-info file. */
699 static char *aux_info_file_name;
701 /* Nonzero means make the text shared if supported. */
703 int flag_shared_data;
705 /* Nonzero means schedule into delayed branch slots if supported. */
707 int flag_delayed_branch;
709 /* Nonzero if we are compiling pure (sharable) code.
710 Value is 1 if we are doing reasonable (i.e. simple
711 offset into offset table) pic. Value is 2 if we can
712 only perform register offsets. */
714 int flag_pic;
716 /* Nonzero means generate extra code for exception handling and enable
717 exception handling. */
719 int flag_exceptions;
721 /* Nonzero means use the new model for exception handling. Replaces
722 -DNEW_EH_MODEL as a compile option. */
724 int flag_new_exceptions = 1;
726 /* Nonzero means generate frame unwind info table when supported. */
728 int flag_unwind_tables = 0;
730 /* Nonzero means don't place uninitialized global data in common storage
731 by default. */
733 int flag_no_common;
735 /* Nonzero means pretend it is OK to examine bits of target floats,
736 even if that isn't true. The resulting code will have incorrect constants,
737 but the same series of instructions that the native compiler would make. */
739 int flag_pretend_float;
741 /* Nonzero means change certain warnings into errors.
742 Usually these are warnings about failure to conform to some standard. */
744 int flag_pedantic_errors = 0;
746 /* flag_schedule_insns means schedule insns within basic blocks (before
747 local_alloc).
748 flag_schedule_insns_after_reload means schedule insns after
749 global_alloc. */
751 int flag_schedule_insns = 0;
752 int flag_schedule_insns_after_reload = 0;
754 /* The following flags have effect only for scheduling before register
755 allocation:
757 flag_schedule_interblock means schedule insns accross basic blocks.
758 flag_schedule_speculative means allow speculative motion of non-load insns.
759 flag_schedule_speculative_load means allow speculative motion of some
760 load insns.
761 flag_schedule_speculative_load_dangerous allows speculative motion of more
762 load insns. */
764 int flag_schedule_interblock = 1;
765 int flag_schedule_speculative = 1;
766 int flag_schedule_speculative_load = 0;
767 int flag_schedule_speculative_load_dangerous = 0;
769 int flag_single_precision_constant;
771 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
772 by a cheaper branch on a count register. */
773 int flag_branch_on_count_reg = 1;
775 /* -finhibit-size-directive inhibits output of .size for ELF.
776 This is used only for compiling crtstuff.c,
777 and it may be extended to other effects
778 needed for crtstuff.c on other systems. */
779 int flag_inhibit_size_directive = 0;
781 /* -fverbose-asm causes extra commentary information to be produced in
782 the generated assembly code (to make it more readable). This option
783 is generally only of use to those who actually need to read the
784 generated assembly code (perhaps while debugging the compiler itself).
785 -fno-verbose-asm, the default, causes the extra information
786 to be omitted and is useful when comparing two assembler files. */
788 int flag_verbose_asm = 0;
790 /* -dA causes debug commentary information to be produced in
791 the generated assembly code (to make it more readable). This option
792 is generally only of use to those who actually need to read the
793 generated assembly code (perhaps while debugging the compiler itself).
794 Currently, this switch is only used by dwarfout.c; however, it is intended
795 to be a catchall for printing debug information in the assembler file. */
797 int flag_debug_asm = 0;
799 /* -dP causes the rtl to be emitted as a comment in assembly. */
801 int flag_dump_rtl_in_asm = 0;
803 /* -fgnu-linker specifies use of the GNU linker for initializations.
804 (Or, more generally, a linker that handles initializations.)
805 -fno-gnu-linker says that collect2 will be used. */
806 #ifdef USE_COLLECT2
807 int flag_gnu_linker = 0;
808 #else
809 int flag_gnu_linker = 1;
810 #endif
812 /* Enable SSA. */
813 int flag_ssa = 0;
815 /* Enable dead code elimination. */
816 int flag_dce = 0;
818 /* Tag all structures with __attribute__(packed). */
819 int flag_pack_struct = 0;
821 /* Emit code to check for stack overflow; also may cause large objects
822 to be allocated dynamically. */
823 int flag_stack_check;
825 /* When non-NULL, indicates that whenever space is allocated on the
826 stack, the resulting stack pointer must not pass this
827 address---that is, for stacks that grow downward, the stack pointer
828 must always be greater than or equal to this address; for stacks
829 that grow upward, the stack pointer must be less than this address.
830 At present, the rtx may be either a REG or a SYMBOL_REF, although
831 the support provided depends on the backend. */
832 rtx stack_limit_rtx;
834 /* -fcheck-memory-usage causes extra code to be generated in order to check
835 memory accesses. This is used by a detector of bad memory accesses such
836 as Checker. */
837 int flag_check_memory_usage = 0;
839 /* -fprefix-function-name causes function name to be prefixed. This
840 can be used with -fcheck-memory-usage to isolate code compiled with
841 -fcheck-memory-usage. */
842 int flag_prefix_function_name = 0;
844 /* 0 if pointer arguments may alias each other. True in C.
845 1 if pointer arguments may not alias each other but may alias
846 global variables.
847 2 if pointer arguments may not alias each other and may not
848 alias global variables. True in Fortran.
849 This defaults to 0 for C. */
850 int flag_argument_noalias = 0;
852 /* Nonzero if we should do (language-dependent) alias analysis.
853 Typically, this analysis will assume that expressions of certain
854 types do not alias expressions of certain other types. Only used
855 if alias analysis (in general) is enabled. */
856 int flag_strict_aliasing = 0;
858 /* Instrument functions with calls at entry and exit, for profiling. */
859 int flag_instrument_function_entry_exit = 0;
861 /* Nonzero means ignore `#ident' directives. 0 means handle them.
862 On SVR4 targets, it also controls whether or not to emit a
863 string identifying the compiler. */
865 int flag_no_ident = 0;
867 /* This will perform a peephole pass before sched2. */
868 int flag_peephole2 = 0;
870 /* This will try to guess branch probabilities. */
871 int flag_guess_branch_prob = 0;
873 /* -fbounded-pointers causes gcc to compile pointers as composite
874 objects occupying three words: the pointer value, the base address
875 of the referent object, and the address immediately beyond the end
876 of the referent object. The base and extent allow us to perform
877 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
878 int flag_bounded_pointers = 0;
880 /* -fcheck-bounds causes gcc to generate array bounds checks.
881 For C, C++: defaults to value of flag_bounded_pointers.
882 For ObjC: defaults to off.
883 For Java: defaults to on.
884 For Fortran: defaults to off.
885 For CHILL: defaults to off. */
886 int flag_bounds_check = 0;
888 /* If one, renumber instruction UIDs to reduce the number of
889 unused UIDs if there are a lot of instructions. If greater than
890 one, unconditionally renumber instruction UIDs. */
891 int flag_renumber_insns = 1;
893 /* Values of the -falign-* flags: how much to align labels in code.
894 0 means `use default', 1 means `don't align'.
895 For each variable, there is an _log variant which is the power
896 of two not less than the variable, for .align output. */
898 int align_loops;
899 int align_loops_log;
900 int align_jumps;
901 int align_jumps_log;
902 int align_labels;
903 int align_labels_log;
904 int align_functions;
905 int align_functions_log;
907 /* Table of supported debugging formats. */
908 static struct
910 const char *arg;
911 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
912 constant expression, we use NO_DEBUG in its place. */
913 enum debug_info_type debug_type;
914 int use_extensions_p;
915 const char *description;
916 } *da,
917 debug_args[] =
919 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
920 "Generate default debug format output" },
921 { "gdb", NO_DEBUG, 1, "Generate default extended debug format output" },
922 #ifdef DBX_DEBUGGING_INFO
923 { "stabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
924 { "stabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
925 #endif
926 #ifdef DWARF_DEBUGGING_INFO
927 { "dwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
928 { "dwarf+", DWARF_DEBUG, 1,
929 "Generated extended DWARF-1 format debug output" },
930 #endif
931 #ifdef DWARF2_DEBUGGING_INFO
932 { "dwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
933 #endif
934 #ifdef XCOFF_DEBUGGING_INFO
935 { "xcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
936 { "xcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
937 #endif
938 #ifdef SDB_DEBUGGING_INFO
939 { "coff", SDB_DEBUG, 0, "Generate COFF format debug output" },
940 #endif
941 { 0, 0, 0, 0 }
944 typedef struct
946 const char *string;
947 int *variable;
948 int on_value;
949 const char *description;
951 lang_independent_options;
953 int flag_trapv = 0;
955 /* Add or remove a leading underscore from user symbols. */
956 int flag_leading_underscore = -1;
958 /* The user symbol prefix after having resolved same. */
959 const char *user_label_prefix;
961 static const param_info lang_independent_params[] = {
962 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
963 { OPTION, DEFAULT },
964 #include "params.def"
965 #undef DEFPARAM
966 { NULL, 0 }
969 /* A default for same. */
970 #ifndef USER_LABEL_PREFIX
971 #define USER_LABEL_PREFIX ""
972 #endif
974 /* Table of language-independent -f options.
975 STRING is the option name. VARIABLE is the address of the variable.
976 ON_VALUE is the value to store in VARIABLE
977 if `-fSTRING' is seen as an option.
978 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
980 lang_independent_options f_options[] =
982 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
983 "Perform DWARF2 duplicate elimination"},
984 {"float-store", &flag_float_store, 1,
985 "Do not store floats in registers" },
986 {"volatile", &flag_volatile, 1,
987 "Consider all mem refs through pointers as volatile"},
988 {"volatile-global", &flag_volatile_global, 1,
989 "Consider all mem refs to global data to be volatile" },
990 {"volatile-static", &flag_volatile_static, 1,
991 "Consider all mem refs to static data to be volatile" },
992 {"defer-pop", &flag_defer_pop, 1,
993 "Defer popping functions args from stack until later" },
994 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
995 "When possible do not generate stack frames"},
996 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
997 "Optimize sibling and tail recursive calls" },
998 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
999 "When running CSE, follow jumps to their targets" },
1000 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
1001 "When running CSE, follow conditional jumps" },
1002 {"expensive-optimizations", &flag_expensive_optimizations, 1,
1003 "Perform a number of minor, expensive optimisations" },
1004 {"thread-jumps", &flag_thread_jumps, 1,
1005 "Perform jump threading optimisations"},
1006 {"strength-reduce", &flag_strength_reduce, 1,
1007 "Perform strength reduction optimisations" },
1008 {"unroll-loops", &flag_unroll_loops, 1,
1009 "Perform loop unrolling when iteration count is known" },
1010 {"unroll-all-loops", &flag_unroll_all_loops, 1,
1011 "Perform loop unrolling for all loops" },
1012 {"move-all-movables", &flag_move_all_movables, 1,
1013 "Force all loop invariant computations out of loops" },
1014 {"reduce-all-givs", &flag_reduce_all_givs, 1,
1015 "Strength reduce all loop general induction variables" },
1016 {"writable-strings", &flag_writable_strings, 1,
1017 "Store strings in writable data section" },
1018 {"peephole", &flag_no_peephole, 0,
1019 "Enable machine specific peephole optimisations" },
1020 {"force-mem", &flag_force_mem, 1,
1021 "Copy memory operands into registers before using" },
1022 {"force-addr", &flag_force_addr, 1,
1023 "Copy memory address constants into regs before using" },
1024 {"function-cse", &flag_no_function_cse, 0,
1025 "Allow function addresses to be held in registers" },
1026 {"inline-functions", &flag_inline_functions, 1,
1027 "Integrate simple functions into their callers" },
1028 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1029 "Generate code for funcs even if they are fully inlined" },
1030 {"inline", &flag_no_inline, 0,
1031 "Pay attention to the 'inline' keyword"},
1032 {"keep-static-consts", &flag_keep_static_consts, 1,
1033 "Emit static const variables even if they are not used" },
1034 {"syntax-only", &flag_syntax_only, 1,
1035 "Check for syntax errors, then stop" },
1036 {"shared-data", &flag_shared_data, 1,
1037 "Mark data as shared rather than private" },
1038 {"caller-saves", &flag_caller_saves, 1,
1039 "Enable saving registers around function calls" },
1040 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1041 "Return 'short' aggregates in memory, not registers" },
1042 {"reg-struct-return", &flag_pcc_struct_return, 0,
1043 "Return 'short' aggregates in registers" },
1044 {"delayed-branch", &flag_delayed_branch, 1,
1045 "Attempt to fill delay slots of branch instructions" },
1046 {"gcse", &flag_gcse, 1,
1047 "Perform the global common subexpression elimination" },
1048 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1049 "Run CSE pass after loop optimisations"},
1050 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1051 "Run the loop optimiser twice"},
1052 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1053 "Delete useless null pointer checks" },
1054 {"pretend-float", &flag_pretend_float, 1,
1055 "Pretend that host and target use the same FP format"},
1056 {"schedule-insns", &flag_schedule_insns, 1,
1057 "Reschedule instructions before register allocation"},
1058 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1059 "Reschedule instructions after register allocation"},
1060 {"sched-interblock",&flag_schedule_interblock, 1,
1061 "Enable scheduling across basic blocks" },
1062 {"sched-spec",&flag_schedule_speculative, 1,
1063 "Allow speculative motion of non-loads" },
1064 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1065 "Allow speculative motion of some loads" },
1066 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1067 "Allow speculative motion of more loads" },
1068 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1069 "Replace add,compare,branch with branch on count reg"},
1070 {"pic", &flag_pic, 1,
1071 "Generate position independent code, if possible"},
1072 {"PIC", &flag_pic, 2, ""},
1073 {"exceptions", &flag_exceptions, 1,
1074 "Enable exception handling" },
1075 {"new-exceptions", &flag_new_exceptions, 1,
1076 "Use the new model for exception handling" },
1077 {"unwind-tables", &flag_unwind_tables, 1,
1078 "Just generate unwind tables for exception handling" },
1079 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
1080 "Use setjmp/longjmp to handle exceptions" },
1081 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
1082 "Support asynchronous exceptions" },
1083 {"profile-arcs", &profile_arc_flag, 1,
1084 "Insert arc based program profiling code" },
1085 {"test-coverage", &flag_test_coverage, 1,
1086 "Create data files needed by gcov" },
1087 {"branch-probabilities", &flag_branch_probabilities, 1,
1088 "Use profiling information for branch probabilities" },
1089 {"reorder-blocks", &flag_reorder_blocks, 1,
1090 "Reorder basic blocks to improve code placement" },
1091 {"rename-registers", &flag_rename_registers, 1,
1092 "Do the register renaming optimization pass"},
1093 {"fast-math", &flag_fast_math, 1,
1094 "Improve FP speed by violating ANSI & IEEE rules" },
1095 {"common", &flag_no_common, 0,
1096 "Do not put unitialised globals in the common section" },
1097 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1098 "Do not generate .size directives" },
1099 {"function-sections", &flag_function_sections, 1,
1100 "place each function into its own section" },
1101 {"data-sections", &flag_data_sections, 1,
1102 "place data items into their own section" },
1103 {"verbose-asm", &flag_verbose_asm, 1,
1104 "Add extra commentry to assembler output"},
1105 {"gnu-linker", &flag_gnu_linker, 1,
1106 "Output GNU ld formatted global initialisers"},
1107 {"regmove", &flag_regmove, 1,
1108 "Enables a register move optimisation"},
1109 {"optimize-register-move", &flag_regmove, 1,
1110 "Do the full regmove optimization pass"},
1111 {"pack-struct", &flag_pack_struct, 1,
1112 "Pack structure members together without holes" },
1113 {"stack-check", &flag_stack_check, 1,
1114 "Insert stack checking code into the program" },
1115 {"argument-alias", &flag_argument_noalias, 0,
1116 "Specify that arguments may alias each other & globals"},
1117 {"argument-noalias", &flag_argument_noalias, 1,
1118 "Assume arguments may alias globals but not each other"},
1119 {"argument-noalias-global", &flag_argument_noalias, 2,
1120 "Assume arguments do not alias each other or globals" },
1121 {"strict-aliasing", &flag_strict_aliasing, 1,
1122 "Assume strict aliasing rules apply" },
1123 {"align-loops", &align_loops, 0,
1124 "Align the start of loops" },
1125 {"align-jumps", &align_jumps, 0,
1126 "Align labels which are only reached by jumping" },
1127 {"align-labels", &align_labels, 0,
1128 "Align all labels" },
1129 {"align-functions", &align_functions, 0,
1130 "Align the start of functions" },
1131 {"check-memory-usage", &flag_check_memory_usage, 1,
1132 "Generate code to check every memory access" },
1133 {"prefix-function-name", &flag_prefix_function_name, 1,
1134 "Add a prefix to all function names" },
1135 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1136 "Suppress output of instruction numbers and line number notes in debugging dumps"},
1137 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1138 "Instrument function entry/exit with profiling calls"},
1139 {"ssa", &flag_ssa, 1,
1140 "Enable SSA optimizations" },
1141 {"dce", &flag_dce, 1,
1142 "Enable dead code elimination" },
1143 {"leading-underscore", &flag_leading_underscore, 1,
1144 "External symbols have a leading underscore" },
1145 {"ident", &flag_no_ident, 0,
1146 "Process #ident directives"},
1147 { "peephole2", &flag_peephole2, 1,
1148 "Enables an rtl peephole pass run before sched2" },
1149 { "guess-branch-probability", &flag_guess_branch_prob, 1,
1150 "Enables guessing of branch probabilities" },
1151 {"math-errno", &flag_errno_math, 1,
1152 "Set errno after built-in math functions"},
1153 {"bounded-pointers", &flag_bounded_pointers, 1,
1154 "Compile pointers as triples: value, base & end" },
1155 {"bounds-check", &flag_bounds_check, 1,
1156 "Generate code to check bounds before dereferencing pointers and arrays" },
1157 {"single-precision-constant", &flag_single_precision_constant, 1,
1158 "Convert floating point constant to single precision constant"},
1159 {"time-report", &time_report, 1,
1160 "Report time taken by each compiler pass at end of run"},
1161 {"mem-report", &mem_report, 1,
1162 "Report on permanent memory allocation at end of run"},
1163 { "trapv", &flag_trapv, 1,
1164 "Trap for signed overflow in addition / subtraction / multiplication." },
1167 /* Table of language-specific options. */
1169 static struct lang_opt
1171 const char *option;
1172 const char *description;
1174 documented_lang_options[] =
1176 /* In order not to overload the --help output, the convention
1177 used here is to only describe those options which are not
1178 enabled by default. */
1180 { "-ansi", "Compile just for ISO C89" },
1181 { "-fallow-single-precision",
1182 "Do not promote floats to double if using -traditional" },
1183 { "-std= ", "Determine language standard"},
1185 { "-fsigned-bitfields", "" },
1186 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1187 { "-fno-signed-bitfields", "" },
1188 { "-fno-unsigned-bitfields","" },
1189 { "-fsigned-char", "Make 'char' be signed by default"},
1190 { "-funsigned-char", "Make 'char' be unsigned by default"},
1191 { "-fno-signed-char", "" },
1192 { "-fno-unsigned-char", "" },
1194 { "-ftraditional", "" },
1195 { "-traditional", "Attempt to support traditional K&R style C"},
1196 { "-fnotraditional", "" },
1197 { "-fno-traditional", "" },
1199 { "-fasm", "" },
1200 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1201 { "-fbuiltin", "" },
1202 { "-fno-builtin", "Do not recognise any built in functions" },
1203 { "-fhosted", "Assume normal C execution environment" },
1204 { "-fno-hosted", "" },
1205 { "-ffreestanding",
1206 "Assume that standard libraries & main might not exist" },
1207 { "-fno-freestanding", "" },
1208 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1209 { "-fno-cond-mismatch", "" },
1210 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1211 { "-fno-dollars-in-identifiers", "" },
1212 { "-fpreprocessed", "" },
1213 { "-fno-preprocessed", "" },
1214 { "-fshort-double", "Use the same size for double as for float" },
1215 { "-fno-short-double", "" },
1216 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1217 { "-fno-short-enums", "" },
1218 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1219 { "-fno-short-wchar", "" },
1221 { "-Wall", "Enable most warning messages" },
1222 { "-Wbad-function-cast",
1223 "Warn about casting functions to incompatible types" },
1224 { "-Wno-bad-function-cast", "" },
1225 { "-Wno-missing-noreturn", "" },
1226 { "-Wmissing-format-attribute",
1227 "Warn about functions which might be candidates for format attributes" },
1228 { "-Wno-missing-format-attribute", "" },
1229 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1230 { "-Wno-cast-qual", "" },
1231 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1232 { "-Wno-char-subscripts", "" },
1233 { "-Wcomment", "Warn if nested comments are detected" },
1234 { "-Wno-comment", "" },
1235 { "-Wcomments", "Warn if nested comments are detected" },
1236 { "-Wno-comments", "" },
1237 { "-Wconversion", "Warn about possibly confusing type conversions" },
1238 { "-Wno-conversion", "" },
1239 { "-Wformat", "Warn about printf/scanf/strftime/strfmon format anomalies" },
1240 { "-Wno-format", "" },
1241 { "-Wformat-y2k", "" },
1242 { "-Wno-format-y2k",
1243 "Don't warn about strftime formats yielding 2 digit years" },
1244 { "-Wformat-extra-args", "" },
1245 { "-Wno-format-extra-args",
1246 "Don't warn about too many arguments to format functions" },
1247 { "-Wformat-nonliteral", "Warn about non-string-literal format strings" },
1248 { "-Wno-format-nonliteral", "" },
1249 { "-Wformat-security",
1250 "Warn about possible security problems with format functions" },
1251 { "-Wno-format-security", "" },
1252 { "-Wimplicit-function-declaration",
1253 "Warn about implicit function declarations" },
1254 { "-Wno-implicit-function-declaration", "" },
1255 { "-Werror-implicit-function-declaration", "" },
1256 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1257 { "-Wno-implicit-int", "" },
1258 { "-Wimplicit", "" },
1259 { "-Wno-implicit", "" },
1260 { "-Wimport", "Warn about the use of the #import directive" },
1261 { "-Wno-import", "" },
1262 { "-Wlong-long","" },
1263 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1264 { "-Wmain", "Warn about suspicious declarations of main" },
1265 { "-Wno-main", "" },
1266 { "-Wmissing-braces",
1267 "Warn about possibly missing braces around initialisers" },
1268 { "-Wno-missing-braces", "" },
1269 { "-Wmissing-declarations",
1270 "Warn about global funcs without previous declarations"},
1271 { "-Wno-missing-declarations", "" },
1272 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1273 { "-Wno-missing-prototypes", "" },
1274 { "-Wmultichar", "Warn about use of multicharacter literals"},
1275 { "-Wno-multichar", "" },
1276 { "-Wnested-externs", "Warn about externs not at file scope level" },
1277 { "-Wno-nested-externs", "" },
1278 { "-Wparentheses", "Warn about possible missing parentheses" },
1279 { "-Wno-parentheses", "" },
1280 { "-Wsequence-point",
1281 "Warn about possible violations of sequence point rules" },
1282 { "-Wno-sequence-point", "" },
1283 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1284 { "-Wno-pointer-arith", "" },
1285 { "-Wredundant-decls",
1286 "Warn about multiple declarations of the same object" },
1287 { "-Wno-redundant-decls", "" },
1288 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1289 { "-Wno-sign-compare", "" },
1290 { "-Wfloat-equal", "Warn about testing equality of floating point numbers" },
1291 { "-Wno-float-equal", "" },
1292 { "-Wunknown-pragmas", "Warn about unrecognized pragmas" },
1293 { "-Wno-unknown-pragmas", "" },
1294 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1295 { "-Wno-strict-prototypes", "" },
1296 { "-Wtraditional", "Warn about constructs whose meaning change in ISO C"},
1297 { "-Wno-traditional", "" },
1298 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1299 { "-Wno-trigraphs", "" },
1300 { "-Wundef", "" },
1301 { "-Wno-undef", "" },
1302 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1303 { "-Wno-write-strings", "" },
1305 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1307 #include "options.h"
1311 /* Here is a table, controlled by the tm.h file, listing each -m switch
1312 and which bits in `target_switches' it should set or clear.
1313 If VALUE is positive, it is bits to set.
1314 If VALUE is negative, -VALUE is bits to clear.
1315 (The sign bit is not used so there is no confusion.) */
1317 struct
1319 const char *name;
1320 int value;
1321 const char *description;
1323 target_switches [] = TARGET_SWITCHES;
1325 /* This table is similar, but allows the switch to have a value. */
1327 #ifdef TARGET_OPTIONS
1328 struct
1330 const char *prefix;
1331 const char **variable;
1332 const char *description;
1334 target_options [] = TARGET_OPTIONS;
1335 #endif
1337 /* Options controlling warnings. */
1339 /* Don't print warning messages. -w. */
1341 int inhibit_warnings = 0;
1343 /* Don't suppress warnings from system headers. -Wsystem-headers. */
1345 int warn_system_headers = 0;
1347 /* Print various extra warnings. -W. */
1349 int extra_warnings = 0;
1351 /* Treat warnings as errors. -Werror. */
1353 int warnings_are_errors = 0;
1355 /* Nonzero to warn about unused variables, functions et.al. */
1357 int warn_unused_function;
1358 int warn_unused_label;
1359 int warn_unused_parameter;
1360 int warn_unused_variable;
1361 int warn_unused_value;
1363 void
1364 set_Wunused (setting)
1365 int setting;
1367 warn_unused_function = setting;
1368 warn_unused_label = setting;
1369 /* Unused function parameter warnings are reported when either ``-W
1370 -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
1371 -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
1372 if (!setting)
1373 warn_unused_parameter = 0;
1374 else if (!warn_unused_parameter)
1375 warn_unused_parameter = -1;
1376 warn_unused_variable = setting;
1377 warn_unused_value = setting;
1380 /* Nonzero to warn about code which is never reached. */
1382 int warn_notreached;
1384 /* Nonzero to warn about variables used before they are initialized. */
1386 int warn_uninitialized;
1388 /* Nonzero means warn about all declarations which shadow others. */
1390 int warn_shadow;
1392 /* Warn if a switch on an enum fails to have a case for every enum value. */
1394 int warn_switch;
1396 /* Nonzero means warn about function definitions that default the return type
1397 or that use a null return and have a return-type other than void. */
1399 int warn_return_type;
1401 /* Nonzero means warn about pointer casts that increase the required
1402 alignment of the target type (and might therefore lead to a crash
1403 due to a misaligned access). */
1405 int warn_cast_align;
1407 /* Nonzero means warn about any identifiers that match in the first N
1408 characters. The value N is in `id_clash_len'. */
1410 int warn_id_clash;
1411 int id_clash_len;
1413 /* Nonzero means warn about any objects definitions whose size is larger
1414 than N bytes. Also want about function definitions whose returned
1415 values are larger than N bytes. The value N is in `larger_than_size'. */
1417 int warn_larger_than;
1418 HOST_WIDE_INT larger_than_size;
1420 /* Nonzero means warn if inline function is too large. */
1422 int warn_inline;
1424 /* Warn if a function returns an aggregate,
1425 since there are often incompatible calling conventions for doing this. */
1427 int warn_aggregate_return;
1429 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1431 int warn_packed;
1433 /* Warn when gcc pads a structure to an alignment boundary. */
1435 int warn_padded;
1437 /* Warn when an optimization pass is disabled. */
1439 int warn_disabled_optimization;
1441 /* Warn about functions which might be candidates for attribute noreturn. */
1443 int warn_missing_noreturn;
1445 /* Likewise for -W. */
1447 lang_independent_options W_options[] =
1449 {"unused-function", &warn_unused_function, 1, "Warn when a function is unused" },
1450 {"unused-label", &warn_unused_label, 1, "Warn when a label is unused" },
1451 {"unused-parameter", &warn_unused_parameter, 1, "Warn when a function parameter is unused" },
1452 {"unused-variable", &warn_unused_variable, 1, "Warn when a variable is unused" },
1453 {"unused-value", &warn_unused_value, 1, "Warn when an expression value is unused" },
1454 {"system-headers", &warn_system_headers, 1, "Do not suppress warnings from system headers"},
1455 {"error", &warnings_are_errors, 1, ""},
1456 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1457 {"switch", &warn_switch, 1,
1458 "Warn about enumerated switches missing a specific case" },
1459 {"aggregate-return", &warn_aggregate_return, 1,
1460 "Warn about returning structures, unions or arrays" },
1461 {"cast-align", &warn_cast_align, 1,
1462 "Warn about pointer casts which increase alignment" },
1463 {"unreachable-code", &warn_notreached, 1,
1464 "Warn about code that will never be executed" },
1465 {"uninitialized", &warn_uninitialized, 1,
1466 "Warn about unitialized automatic variables"},
1467 {"inline", &warn_inline, 1,
1468 "Warn when an inlined function cannot be inlined"},
1469 {"packed", &warn_packed, 1,
1470 "Warn when the packed attribute has no effect on struct layout"},
1471 {"padded", &warn_padded, 1,
1472 "Warn when padding is required to align struct members"},
1473 {"disabled-optimization", &warn_disabled_optimization, 1,
1474 "Warn when an optimization pass is disabled"},
1475 {"missing-noreturn", &warn_missing_noreturn, 1,
1476 "Warn about functions which might be candidates for attribute noreturn"}
1479 /* Output files for assembler code (real compiler output)
1480 and debugging dumps. */
1482 FILE *asm_out_file;
1483 FILE *aux_info_file;
1484 FILE *rtl_dump_file = NULL;
1486 /* Decode the string P as an integral parameter.
1487 If the string is indeed an integer return its numeric value else
1488 issue an Invalid Option error for the option PNAME and return DEFVAL.
1489 If PNAME is zero just return DEFVAL, do not call error. */
1492 read_integral_parameter (p, pname, defval)
1493 const char *p;
1494 const char *pname;
1495 const int defval;
1497 const char *endp = p;
1499 while (*endp)
1501 if (*endp >= '0' && *endp <= '9')
1502 endp++;
1503 else
1504 break;
1507 if (*endp != 0)
1509 if (pname != 0)
1510 error ("Invalid option `%s'", pname);
1511 return defval;
1514 return atoi (p);
1518 /* This is the default decl_printable_name function. */
1520 static const char *
1521 decl_name (decl, verbosity)
1522 tree decl;
1523 int verbosity ATTRIBUTE_UNUSED;
1525 return IDENTIFIER_POINTER (DECL_NAME (decl));
1529 /* This calls abort and is used to avoid problems when abort if a macro.
1530 It is used when we need to pass the address of abort. */
1532 void
1533 do_abort ()
1535 abort ();
1538 /* When `malloc.c' is compiled with `rcheck' defined,
1539 it calls this function to report clobberage. */
1541 void
1542 botch (s)
1543 const char *s ATTRIBUTE_UNUSED;
1545 abort ();
1548 /* Return the logarithm of X, base 2, considering X unsigned,
1549 if X is a power of 2. Otherwise, returns -1.
1551 This should be used via the `exact_log2' macro. */
1554 exact_log2_wide (x)
1555 register unsigned HOST_WIDE_INT x;
1557 register int log = 0;
1558 /* Test for 0 or a power of 2. */
1559 if (x == 0 || x != (x & -x))
1560 return -1;
1561 while ((x >>= 1) != 0)
1562 log++;
1563 return log;
1566 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1567 If X is 0, return -1.
1569 This should be used via the floor_log2 macro. */
1572 floor_log2_wide (x)
1573 register unsigned HOST_WIDE_INT x;
1575 register int log = -1;
1576 while (x != 0)
1577 log++,
1578 x >>= 1;
1579 return log;
1582 /* Return the approximate positive square root of a number N. This is for
1583 statistical reports, not code generation. */
1584 double
1585 approx_sqrt (x)
1586 double x;
1588 double s, d;
1590 if (x < 0)
1591 abort ();
1592 if (x == 0)
1593 return 0;
1595 s = x;
1598 d = (s * s - x) / (2 * s);
1599 s -= d;
1601 while (d > .0001);
1602 return s;
1605 static int float_handler_set;
1606 int float_handled;
1607 jmp_buf float_handler;
1609 /* Signals actually come here. */
1611 static void
1612 float_signal (signo)
1613 /* If this is missing, some compilers complain. */
1614 int signo ATTRIBUTE_UNUSED;
1616 if (float_handled == 0)
1617 crash_signal (signo);
1618 #if defined (USG) || defined (hpux)
1619 /* Re-enable the signal catcher. */
1620 signal (SIGFPE, float_signal);
1621 #endif
1622 float_handled = 0;
1623 signal (SIGFPE, float_signal);
1624 longjmp (float_handler, 1);
1627 /* Specify where to longjmp to when a floating arithmetic error happens.
1628 If HANDLER is 0, it means don't handle the errors any more. */
1630 void
1631 set_float_handler (handler)
1632 jmp_buf handler;
1634 float_handled = (handler != 0);
1635 if (handler)
1636 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1638 if (float_handled && ! float_handler_set)
1640 signal (SIGFPE, float_signal);
1641 float_handler_set = 1;
1645 /* This is a wrapper function for code which might elicit an
1646 arithmetic exception. That code should be passed in as a function
1647 pointer FN, and one argument DATA. DATA is usually a struct which
1648 contains the real input and output for function FN. This function
1649 returns 0 (failure) if longjmp was called (i.e. an exception
1650 occured.) It returns 1 (success) otherwise. */
1653 do_float_handler (fn, data)
1654 void (*fn) PARAMS ((PTR));
1655 PTR data;
1657 jmp_buf buf;
1659 if (setjmp (buf))
1661 /* We got here via longjmp () caused by an exception in function
1662 fn (). */
1663 set_float_handler (NULL);
1664 return 0;
1667 set_float_handler (buf);
1668 (*fn)(data);
1669 set_float_handler (NULL);
1670 return 1;
1673 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1674 error happens, pushing the previous specification into OLD_HANDLER.
1675 Return an indication of whether there was a previous handler in effect. */
1678 push_float_handler (handler, old_handler)
1679 jmp_buf handler, old_handler;
1681 int was_handled = float_handled;
1683 float_handled = 1;
1684 if (was_handled)
1685 memcpy ((char *) old_handler, (char *) float_handler,
1686 sizeof (float_handler));
1688 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
1689 return was_handled;
1692 /* Restore the previous specification of whether and where to longjmp to
1693 when a floating arithmetic error happens. */
1695 void
1696 pop_float_handler (handled, handler)
1697 int handled;
1698 jmp_buf handler;
1700 float_handled = handled;
1701 if (handled)
1702 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1705 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1706 into ICE messages, which is much more user friendly. */
1708 static void
1709 crash_signal (signo)
1710 int signo;
1712 internal_error ("Internal error: %s", strsignal (signo));
1715 /* Strip off a legitimate source ending from the input string NAME of
1716 length LEN. Rather than having to know the names used by all of
1717 our front ends, we strip off an ending of a period followed by
1718 up to five characters. (Java uses ".class".) */
1720 void
1721 strip_off_ending (name, len)
1722 char *name;
1723 int len;
1725 int i;
1726 for (i = 2; i < 6 && len > i; i++)
1728 if (name[len - i] == '.')
1730 name[len - i] = '\0';
1731 break;
1736 /* Given a file name X, return the nondirectory portion. */
1738 char *
1739 file_name_nondirectory (x)
1740 const char *x;
1742 char *tmp = (char *) strrchr (x, '/');
1743 if (DIR_SEPARATOR != '/' && ! tmp)
1744 tmp = (char *) strrchr (x, DIR_SEPARATOR);
1745 if (tmp)
1746 return (char *) (tmp + 1);
1747 else
1748 return (char *) x;
1751 /* Output a quoted string. */
1753 void
1754 output_quoted_string (asm_file, string)
1755 FILE *asm_file;
1756 const char *string;
1758 #ifdef OUTPUT_QUOTED_STRING
1759 OUTPUT_QUOTED_STRING (asm_file, string);
1760 #else
1761 char c;
1763 putc ('\"', asm_file);
1764 while ((c = *string++) != 0)
1766 if (c == '\"' || c == '\\')
1767 putc ('\\', asm_file);
1768 putc (c, asm_file);
1770 putc ('\"', asm_file);
1771 #endif
1774 /* Output a file name in the form wanted by System V. */
1776 void
1777 output_file_directive (asm_file, input_name)
1778 FILE *asm_file;
1779 const char *input_name;
1781 int len = strlen (input_name);
1782 const char *na = input_name + len;
1784 /* NA gets INPUT_NAME sans directory names. */
1785 while (na > input_name)
1787 if (IS_DIR_SEPARATOR (na[-1]))
1788 break;
1789 na--;
1792 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1793 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1794 #else
1795 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1796 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1797 #else
1798 fprintf (asm_file, "\t.file\t");
1799 output_quoted_string (asm_file, na);
1800 fputc ('\n', asm_file);
1801 #endif
1802 #endif
1805 /* Routine to open a dump file. Return true if the dump file is enabled. */
1807 static int
1808 open_dump_file (index, decl)
1809 enum dump_file_index index;
1810 tree decl;
1812 char *dump_name;
1813 const char *open_arg;
1814 char seq[16];
1816 if (! dump_file[index].enabled)
1817 return 0;
1819 timevar_push (TV_DUMP);
1820 if (rtl_dump_file != NULL)
1821 fclose (rtl_dump_file);
1823 sprintf (seq, ".%02d.", index);
1825 if (! dump_file[index].initialized)
1827 /* If we've not initialized the files, do so now. */
1828 if (graph_dump_format != no_graph
1829 && dump_file[index].graph_dump_p)
1831 dump_name = concat (seq, dump_file[index].extension, NULL);
1832 clean_graph_dump_file (dump_base_name, dump_name);
1833 free (dump_name);
1835 dump_file[index].initialized = 1;
1836 open_arg = "w";
1838 else
1839 open_arg = "a";
1841 dump_name = concat (dump_base_name, seq,
1842 dump_file[index].extension, NULL);
1844 rtl_dump_file = fopen (dump_name, open_arg);
1845 if (rtl_dump_file == NULL)
1846 fatal_io_error ("can't open %s", dump_name);
1848 free (dump_name);
1850 if (decl)
1851 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1852 decl_printable_name (decl, 2));
1854 timevar_pop (TV_DUMP);
1855 return 1;
1858 /* Routine to close a dump file. */
1860 static void
1861 close_dump_file (index, func, insns)
1862 enum dump_file_index index;
1863 void (*func) PARAMS ((FILE *, rtx));
1864 rtx insns;
1866 if (! rtl_dump_file)
1867 return;
1869 timevar_push (TV_DUMP);
1870 if (insns
1871 && graph_dump_format != no_graph
1872 && dump_file[index].graph_dump_p)
1874 char seq[16];
1875 char *suffix;
1877 sprintf (seq, ".%02d.", index);
1878 suffix = concat (seq, dump_file[index].extension, NULL);
1879 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1880 free (suffix);
1883 if (func && insns)
1884 func (rtl_dump_file, insns);
1886 fflush (rtl_dump_file);
1887 fclose (rtl_dump_file);
1889 rtl_dump_file = NULL;
1890 timevar_pop (TV_DUMP);
1893 /* Do any final processing required for the declarations in VEC, of
1894 which there are LEN. We write out inline functions and variables
1895 that have been deferred until this point, but which are required.
1896 Returns non-zero if anything was put out. */
1899 wrapup_global_declarations (vec, len)
1900 tree *vec;
1901 int len;
1903 tree decl;
1904 int i;
1905 int reconsider;
1906 int output_something = 0;
1908 for (i = 0; i < len; i++)
1910 decl = vec[i];
1912 /* We're not deferring this any longer. */
1913 DECL_DEFER_OUTPUT (decl) = 0;
1915 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
1916 && incomplete_decl_finalize_hook != 0)
1917 (*incomplete_decl_finalize_hook) (decl);
1920 /* Now emit any global variables or functions that we have been
1921 putting off. We need to loop in case one of the things emitted
1922 here references another one which comes earlier in the list. */
1925 reconsider = 0;
1926 for (i = 0; i < len; i++)
1928 decl = vec[i];
1930 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1931 continue;
1933 /* Don't write out static consts, unless we still need them.
1935 We also keep static consts if not optimizing (for debugging),
1936 unless the user specified -fno-keep-static-consts.
1937 ??? They might be better written into the debug information.
1938 This is possible when using DWARF.
1940 A language processor that wants static constants to be always
1941 written out (even if it is not used) is responsible for
1942 calling rest_of_decl_compilation itself. E.g. the C front-end
1943 calls rest_of_decl_compilation from finish_decl.
1944 One motivation for this is that is conventional in some
1945 environments to write things like:
1946 static const char rcsid[] = "... version string ...";
1947 intending to force the string to be in the executable.
1949 A language processor that would prefer to have unneeded
1950 static constants "optimized away" would just defer writing
1951 them out until here. E.g. C++ does this, because static
1952 constants are often defined in header files.
1954 ??? A tempting alternative (for both C and C++) would be
1955 to force a constant to be written if and only if it is
1956 defined in a main file, as opposed to an include file. */
1958 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1959 && (! TREE_READONLY (decl)
1960 || TREE_PUBLIC (decl)
1961 || (!optimize
1962 && flag_keep_static_consts
1963 && !DECL_ARTIFICIAL (decl))
1964 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1966 reconsider = 1;
1967 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1970 if (TREE_CODE (decl) == FUNCTION_DECL
1971 && DECL_INITIAL (decl) != 0
1972 && DECL_SAVED_INSNS (decl) != 0
1973 && (flag_keep_inline_functions
1974 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1975 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1977 reconsider = 1;
1978 output_inline_function (decl);
1982 if (reconsider)
1983 output_something = 1;
1985 while (reconsider);
1987 return output_something;
1990 /* Issue appropriate warnings for the global declarations in VEC (of
1991 which there are LEN). Output debugging information for them. */
1993 void
1994 check_global_declarations (vec, len)
1995 tree *vec;
1996 int len;
1998 tree decl;
1999 int i;
2001 for (i = 0; i < len; i++)
2003 decl = vec[i];
2005 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2006 && ! TREE_ASM_WRITTEN (decl))
2007 /* Cancel the RTL for this decl so that, if debugging info
2008 output for global variables is still to come,
2009 this one will be omitted. */
2010 SET_DECL_RTL (decl, NULL_RTX);
2012 /* Warn about any function
2013 declared static but not defined.
2014 We don't warn about variables,
2015 because many programs have static variables
2016 that exist only to get some text into the object file. */
2017 if (TREE_CODE (decl) == FUNCTION_DECL
2018 && (warn_unused_function
2019 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2020 && DECL_INITIAL (decl) == 0
2021 && DECL_EXTERNAL (decl)
2022 && ! DECL_ARTIFICIAL (decl)
2023 && ! TREE_PUBLIC (decl))
2025 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2026 pedwarn_with_decl (decl,
2027 "`%s' used but never defined");
2028 else
2029 warning_with_decl (decl,
2030 "`%s' declared `static' but never defined");
2031 /* This symbol is effectively an "extern" declaration now. */
2032 TREE_PUBLIC (decl) = 1;
2033 assemble_external (decl);
2036 /* Warn about static fns or vars defined but not used,
2037 but not about inline functions or static consts
2038 since defining those in header files is normal practice. */
2039 if (((warn_unused_function
2040 && TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2041 || (warn_unused_variable
2042 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2043 && ! DECL_IN_SYSTEM_HEADER (decl)
2044 && ! DECL_EXTERNAL (decl)
2045 && ! TREE_PUBLIC (decl)
2046 && ! TREE_USED (decl)
2047 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2048 /* The TREE_USED bit for file-scope decls
2049 is kept in the identifier, to handle multiple
2050 external decls in different scopes. */
2051 && ! TREE_USED (DECL_NAME (decl)))
2052 warning_with_decl (decl, "`%s' defined but not used");
2054 timevar_push (TV_SYMOUT);
2055 #ifdef SDB_DEBUGGING_INFO
2056 /* The COFF linker can move initialized global vars to the end.
2057 And that can screw up the symbol ordering.
2058 By putting the symbols in that order to begin with,
2059 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2060 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2061 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2062 && ! DECL_EXTERNAL (decl)
2063 && DECL_RTL (decl) != 0)
2064 sdbout_symbol (decl, 0);
2066 /* Output COFF information for non-global
2067 file-scope initialized variables. */
2068 if (write_symbols == SDB_DEBUG
2069 && TREE_CODE (decl) == VAR_DECL
2070 && DECL_INITIAL (decl)
2071 && ! DECL_EXTERNAL (decl)
2072 && DECL_RTL (decl) != 0
2073 && GET_CODE (DECL_RTL (decl)) == MEM)
2074 sdbout_toplevel_data (decl);
2075 #endif /* SDB_DEBUGGING_INFO */
2076 #ifdef DWARF_DEBUGGING_INFO
2077 /* Output DWARF information for file-scope tentative data object
2078 declarations, file-scope (extern) function declarations (which
2079 had no corresponding body) and file-scope tagged type declarations
2080 and definitions which have not yet been forced out. */
2082 if (write_symbols == DWARF_DEBUG
2083 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2084 dwarfout_file_scope_decl (decl, 1);
2085 #endif
2086 #ifdef DWARF2_DEBUGGING_INFO
2087 /* Output DWARF2 information for file-scope tentative data object
2088 declarations, file-scope (extern) function declarations (which
2089 had no corresponding body) and file-scope tagged type declarations
2090 and definitions which have not yet been forced out. */
2092 if (write_symbols == DWARF2_DEBUG
2093 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2094 dwarf2out_decl (decl);
2095 #endif
2096 timevar_pop (TV_SYMOUT);
2100 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2101 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2102 INPUT_FILENAME and LINENO accordingly. */
2104 void
2105 push_srcloc (file, line)
2106 const char *file;
2107 int line;
2109 struct file_stack *fs;
2111 if (input_file_stack)
2113 input_file_stack->name = input_filename;
2114 input_file_stack->line = lineno;
2117 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2118 fs->name = input_filename = file;
2119 fs->line = lineno = line;
2120 fs->indent_level = 0;
2121 fs->next = input_file_stack;
2122 input_file_stack = fs;
2123 input_file_stack_tick++;
2126 /* Pop the top entry off the stack of presently open source files.
2127 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2128 the stack. */
2130 void
2131 pop_srcloc ()
2133 struct file_stack *fs;
2135 fs = input_file_stack;
2136 input_file_stack = fs->next;
2137 free (fs);
2138 input_file_stack_tick++;
2139 /* The initial source file is never popped. */
2140 if (!input_file_stack)
2141 abort ();
2142 input_filename = input_file_stack->name;
2143 lineno = input_file_stack->line;
2146 /* Compile an entire file of output from cpp, named NAME.
2147 Write a file of assembly output and various debugging dumps. */
2149 static void
2150 compile_file (name)
2151 const char *name;
2153 tree globals;
2155 int name_specified = name != 0;
2157 if (dump_base_name == 0)
2158 dump_base_name = name ? name : "gccdump";
2160 if (! quiet_flag)
2161 time_report = 1;
2163 /* Start timing total execution time. */
2165 init_timevar ();
2166 timevar_start (TV_TOTAL);
2168 /* Initialize data in various passes. */
2170 init_obstacks ();
2171 name = init_parse (name);
2172 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2173 || debug_info_level == DINFO_LEVEL_VERBOSE
2174 || flag_test_coverage
2175 || warn_notreached);
2176 init_regs ();
2177 init_alias_once ();
2178 init_decl_processing ();
2179 init_optabs ();
2180 init_stmt ();
2181 init_eh ();
2182 init_loop ();
2183 init_reload ();
2184 init_function_once ();
2185 init_stor_layout_once ();
2186 init_varasm_once ();
2188 /* The following initialization functions need to generate rtl, so
2189 provide a dummy function context for them. */
2190 init_dummy_function_start ();
2191 init_expmed ();
2192 init_expr_once ();
2193 if (flag_caller_saves)
2194 init_caller_save ();
2195 expand_dummy_function_end ();
2197 /* If auxiliary info generation is desired, open the output file.
2198 This goes in the same directory as the source file--unlike
2199 all the other output files. */
2200 if (flag_gen_aux_info)
2202 aux_info_file = fopen (aux_info_file_name, "w");
2203 if (aux_info_file == 0)
2204 fatal_io_error ("can't open %s", aux_info_file_name);
2207 /* Open assembler code output file. Do this even if -fsyntax-only is on,
2208 because then the driver will have provided the name of a temporary
2209 file or bit bucket for us. */
2211 if (! name_specified && asm_file_name == 0)
2212 asm_out_file = stdout;
2213 else
2215 if (asm_file_name == 0)
2217 int len = strlen (dump_base_name);
2218 char *dumpname = (char *) xmalloc (len + 6);
2219 memcpy (dumpname, dump_base_name, len + 1);
2220 strip_off_ending (dumpname, len);
2221 strcat (dumpname, ".s");
2222 asm_file_name = dumpname;
2224 if (!strcmp (asm_file_name, "-"))
2225 asm_out_file = stdout;
2226 else
2227 asm_out_file = fopen (asm_file_name, "w");
2228 if (asm_out_file == 0)
2229 fatal_io_error ("can't open %s for writing", asm_file_name);
2232 #ifdef IO_BUFFER_SIZE
2233 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2234 _IOFBF, IO_BUFFER_SIZE);
2235 #endif
2237 if (name != 0)
2238 name = ggc_strdup (name);
2240 input_filename = name;
2242 /* Put an entry on the input file stack for the main input file. */
2243 push_srcloc (input_filename, 0);
2245 /* Perform language-specific initialization.
2246 This may set main_input_filename. */
2247 if (lang_hooks.init)
2248 (*lang_hooks.init) ();
2250 /* If the input doesn't start with a #line, use the input name
2251 as the official input file name. */
2252 if (main_input_filename == 0)
2253 main_input_filename = name;
2255 if (flag_syntax_only)
2257 write_symbols = NO_DEBUG;
2258 profile_flag = 0;
2259 profile_block_flag = 0;
2261 else
2263 ASM_FILE_START (asm_out_file);
2265 #ifdef ASM_COMMENT_START
2266 if (flag_verbose_asm)
2268 /* Print the list of options in effect. */
2269 print_version (asm_out_file, ASM_COMMENT_START);
2270 print_switch_values (asm_out_file, 0, MAX_LINE,
2271 ASM_COMMENT_START, " ", "\n");
2272 /* Add a blank line here so it appears in assembler output but not
2273 screen output. */
2274 fprintf (asm_out_file, "\n");
2276 #endif
2277 } /* ! flag_syntax_only */
2279 #ifndef ASM_OUTPUT_SECTION_NAME
2280 if (flag_function_sections)
2282 warning ("-ffunction-sections not supported for this target.");
2283 flag_function_sections = 0;
2285 if (flag_data_sections)
2287 warning ("-fdata-sections not supported for this target.");
2288 flag_data_sections = 0;
2290 #endif
2292 if (flag_function_sections
2293 && (profile_flag || profile_block_flag))
2295 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2296 flag_function_sections = 0;
2299 #ifndef OBJECT_FORMAT_ELF
2300 if (flag_function_sections && write_symbols != NO_DEBUG)
2301 warning ("-ffunction-sections may affect debugging on some targets.");
2302 #endif
2304 /* If dbx symbol table desired, initialize writing it
2305 and output the predefined types. */
2306 timevar_push (TV_SYMOUT);
2307 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2308 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2309 dbxout_init (asm_out_file, main_input_filename, getdecls ());
2310 #endif
2311 #ifdef SDB_DEBUGGING_INFO
2312 if (write_symbols == SDB_DEBUG)
2313 sdbout_init (asm_out_file, main_input_filename, getdecls ());
2314 #endif
2315 #ifdef DWARF_DEBUGGING_INFO
2316 if (write_symbols == DWARF_DEBUG)
2317 dwarfout_init (asm_out_file, main_input_filename);
2318 #endif
2319 #ifdef DWARF2_UNWIND_INFO
2320 if (dwarf2out_do_frame ())
2321 dwarf2out_frame_init ();
2322 #endif
2323 #ifdef DWARF2_DEBUGGING_INFO
2324 if (write_symbols == DWARF2_DEBUG)
2325 dwarf2out_init (asm_out_file, main_input_filename);
2326 #endif
2327 timevar_pop (TV_SYMOUT);
2329 /* Initialize yet another pass. */
2331 init_final (main_input_filename);
2332 init_branch_prob (dump_base_name);
2334 timevar_push (TV_PARSE);
2336 /* Call the parser, which parses the entire file
2337 (calling rest_of_compilation for each function). */
2339 if (yyparse () != 0)
2341 if (errorcount == 0)
2342 fnotice (stderr, "Errors detected in input file (your bison.simple is out of date)\n");
2344 /* In case there were missing closebraces,
2345 get us back to the global binding level. */
2346 while (! global_bindings_p ())
2347 poplevel (0, 0, 0);
2350 /* Compilation is now finished except for writing
2351 what's left of the symbol table output. */
2353 timevar_pop (TV_PARSE);
2355 if (flag_syntax_only)
2356 goto finish_syntax;
2358 globals = getdecls ();
2360 /* Really define vars that have had only a tentative definition.
2361 Really output inline functions that must actually be callable
2362 and have not been output so far. */
2365 int len = list_length (globals);
2366 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2367 int i;
2368 tree decl;
2370 /* Process the decls in reverse order--earliest first.
2371 Put them into VEC from back to front, then take out from front. */
2373 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2374 vec[len - i - 1] = decl;
2376 wrapup_global_declarations (vec, len);
2378 /* This must occur after the loop to output deferred functions. Else
2379 the profiler initializer would not be emitted if all the functions
2380 in this compilation unit were deferred.
2382 output_func_start_profiler can not cause any additional functions or
2383 data to need to be output, so it need not be in the deferred function
2384 loop above. */
2385 output_func_start_profiler ();
2387 /* Now that all possible functions have been output, we can dump
2388 the exception table. */
2390 #ifndef IA64_UNWIND_INFO
2391 output_exception_table ();
2392 #endif
2393 free_exception_table ();
2395 check_global_declarations (vec, len);
2397 /* Clean up. */
2398 free (vec);
2401 /* Write out any pending weak symbol declarations. */
2403 weak_finish ();
2405 /* Do dbx symbols. */
2406 timevar_push (TV_SYMOUT);
2407 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2408 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2409 dbxout_finish (asm_out_file, main_input_filename);
2410 #endif
2412 #ifdef DWARF_DEBUGGING_INFO
2413 if (write_symbols == DWARF_DEBUG)
2414 dwarfout_finish ();
2415 #endif
2417 #ifdef DWARF2_UNWIND_INFO
2418 if (dwarf2out_do_frame ())
2419 dwarf2out_frame_finish ();
2420 #endif
2422 #ifdef DWARF2_DEBUGGING_INFO
2423 if (write_symbols == DWARF2_DEBUG)
2424 dwarf2out_finish ();
2425 #endif
2426 timevar_pop (TV_SYMOUT);
2428 /* Output some stuff at end of file if nec. */
2430 end_final (dump_base_name);
2432 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2434 timevar_push (TV_DUMP);
2435 open_dump_file (DFI_bp, NULL);
2437 end_branch_prob ();
2439 close_dump_file (DFI_bp, NULL, NULL_RTX);
2440 timevar_pop (TV_DUMP);
2443 #ifdef ASM_FILE_END
2444 ASM_FILE_END (asm_out_file);
2445 #endif
2447 /* Attach a special .ident directive to the end of the file to identify
2448 the version of GCC which compiled this code. The format of the .ident
2449 string is patterned after the ones produced by native SVR4 compilers. */
2450 #ifdef IDENT_ASM_OP
2451 if (!flag_no_ident)
2452 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2453 IDENT_ASM_OP, version_string);
2454 #endif
2456 /* Language-specific end of compilation actions. */
2457 finish_syntax:
2458 if (lang_hooks.finish)
2459 (*lang_hooks.finish) ();
2461 /* Close the dump files. */
2463 if (flag_gen_aux_info)
2465 fclose (aux_info_file);
2466 if (errorcount)
2467 unlink (aux_info_file_name);
2470 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2472 timevar_push (TV_DUMP);
2473 dump_combine_total_stats (rtl_dump_file);
2474 close_dump_file (DFI_combine, NULL, NULL_RTX);
2475 timevar_pop (TV_DUMP);
2478 /* Close non-debugging input and output files. Take special care to note
2479 whether fclose returns an error, since the pages might still be on the
2480 buffer chain while the file is open. */
2482 finish_parse ();
2484 if (ferror (asm_out_file) != 0)
2485 fatal_io_error ("error writing to %s", asm_file_name);
2486 if (fclose (asm_out_file) != 0)
2487 fatal_io_error ("error closing %s", asm_file_name);
2489 /* Do whatever is necessary to finish printing the graphs. */
2490 if (graph_dump_format != no_graph)
2492 int i;
2494 for (i = 0; i < (int) DFI_MAX; ++i)
2495 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
2497 char seq[16];
2498 char *suffix;
2500 sprintf (seq, ".%02d.", i);
2501 suffix = concat (seq, dump_file[i].extension, NULL);
2502 finish_graph_dump_file (dump_base_name, suffix);
2503 free (suffix);
2507 if (mem_report)
2509 ggc_print_statistics ();
2510 stringpool_statistics ();
2513 /* Free up memory for the benefit of leak detectors. */
2514 free_reg_info ();
2516 /* Stop timing total execution time. */
2517 timevar_stop (TV_TOTAL);
2519 /* Print the times. */
2521 timevar_print (stderr);
2524 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2525 and TYPE_DECL nodes.
2527 This does nothing for local (non-static) variables, unless the
2528 variable is a register variable with an ASMSPEC. In that case, or
2529 if the variable is not an automatice, it sets up the RTL and
2530 outputs any assembler code (label definition, storage allocation
2531 and initialization).
2533 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2534 the assembler symbol name to be used. TOP_LEVEL is nonzero
2535 if this declaration is not within a function. */
2537 void
2538 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2539 tree decl;
2540 const char *asmspec;
2541 int top_level;
2542 int at_end;
2544 /* Declarations of variables, and of functions defined elsewhere. */
2546 /* The most obvious approach, to put an #ifndef around where
2547 this macro is used, doesn't work since it's inside a macro call. */
2548 #ifndef ASM_FINISH_DECLARE_OBJECT
2549 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2550 #endif
2552 /* Forward declarations for nested functions are not "external",
2553 but we need to treat them as if they were. */
2554 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2555 || TREE_CODE (decl) == FUNCTION_DECL)
2557 timevar_push (TV_VARCONST);
2558 if (asmspec)
2559 make_decl_rtl (decl, asmspec);
2560 /* Initialized extern variable exists to be replaced
2561 with its value, or represents something that will be
2562 output in another file. */
2563 if (! (TREE_CODE (decl) == VAR_DECL
2564 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2565 && DECL_INITIAL (decl) != 0
2566 && DECL_INITIAL (decl) != error_mark_node))
2567 /* Don't output anything
2568 when a tentative file-scope definition is seen.
2569 But at end of compilation, do output code for them. */
2570 if (! (! at_end && top_level
2571 && (DECL_INITIAL (decl) == 0
2572 || DECL_INITIAL (decl) == error_mark_node)))
2573 assemble_variable (decl, top_level, at_end, 0);
2574 if (decl == last_assemble_variable_decl)
2576 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2577 top_level, at_end);
2579 timevar_pop (TV_VARCONST);
2581 else if (DECL_REGISTER (decl) && asmspec != 0)
2583 if (decode_reg_name (asmspec) >= 0)
2585 SET_DECL_RTL (decl, NULL_RTX);
2586 make_decl_rtl (decl, asmspec);
2588 else
2590 error ("invalid register name `%s' for register variable", asmspec);
2591 DECL_REGISTER (decl) = 0;
2592 if (!top_level)
2593 expand_decl (decl);
2596 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2597 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2598 && TREE_CODE (decl) == TYPE_DECL)
2600 timevar_push (TV_SYMOUT);
2601 dbxout_symbol (decl, 0);
2602 timevar_pop (TV_SYMOUT);
2604 #endif
2605 #ifdef SDB_DEBUGGING_INFO
2606 else if (write_symbols == SDB_DEBUG && top_level
2607 && TREE_CODE (decl) == TYPE_DECL)
2609 timevar_push (TV_SYMOUT);
2610 sdbout_symbol (decl, 0);
2611 timevar_pop (TV_SYMOUT);
2613 #endif
2616 /* Called after finishing a record, union or enumeral type. */
2618 void
2619 rest_of_type_compilation (type, toplev)
2620 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2621 tree type;
2622 int toplev;
2623 #else
2624 tree type ATTRIBUTE_UNUSED;
2625 int toplev ATTRIBUTE_UNUSED;
2626 #endif
2628 timevar_push (TV_SYMOUT);
2629 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2630 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2631 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2632 #endif
2633 #ifdef SDB_DEBUGGING_INFO
2634 if (write_symbols == SDB_DEBUG)
2635 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2636 #endif
2637 #ifdef DWARF2_DEBUGGING_INFO
2638 if (write_symbols == DWARF2_DEBUG && toplev)
2639 dwarf2out_decl (TYPE_STUB_DECL (type));
2640 #endif
2641 timevar_pop (TV_SYMOUT);
2644 /* DECL is an inline function, whose body is present, but which is not
2645 being output at this point. (We're putting that off until we need
2646 to do it.) If there are any actions that need to take place,
2647 including the emission of debugging information for the function,
2648 this is where they should go. This function may be called by
2649 language-dependent code for front-ends that do not even generate
2650 RTL for functions that don't need to be put out. */
2652 void
2653 note_deferral_of_defined_inline_function (decl)
2654 tree decl ATTRIBUTE_UNUSED;
2656 #ifdef DWARF_DEBUGGING_INFO
2657 /* Generate the DWARF info for the "abstract" instance of a function
2658 which we may later generate inlined and/or out-of-line instances
2659 of. */
2660 if (write_symbols == DWARF_DEBUG
2661 && (DECL_INLINE (decl) || DECL_ABSTRACT (decl))
2662 && ! DECL_ABSTRACT_ORIGIN (decl))
2664 /* The front-end may not have set CURRENT_FUNCTION_DECL, but the
2665 DWARF code expects it to be set in this case. Intuitively,
2666 DECL is the function we just finished defining, so setting
2667 CURRENT_FUNCTION_DECL is sensible. */
2668 tree saved_cfd = current_function_decl;
2669 int was_abstract = DECL_ABSTRACT (decl);
2670 current_function_decl = decl;
2672 /* Let the DWARF code do its work. */
2673 set_decl_abstract_flags (decl, 1);
2674 dwarfout_file_scope_decl (decl, 0);
2675 if (! was_abstract)
2676 set_decl_abstract_flags (decl, 0);
2678 /* Reset CURRENT_FUNCTION_DECL. */
2679 current_function_decl = saved_cfd;
2681 #endif
2684 /* FNDECL is an inline function which is about to be emitted out of line.
2685 Do any preparation, such as emitting abstract debug info for the inline
2686 before it gets mangled by optimization. */
2688 void
2689 note_outlining_of_inline_function (fndecl)
2690 tree fndecl;
2692 #ifdef DWARF2_DEBUGGING_INFO
2693 /* The DWARF 2 backend tries to reduce debugging bloat by not emitting
2694 the abstract description of inline functions until something tries to
2695 reference them. Force it out now, before optimizations mangle the
2696 block tree. */
2697 if (write_symbols == DWARF2_DEBUG)
2698 dwarf2out_abstract_function (fndecl);
2699 #endif
2702 /* This is called from finish_function (within yyparse)
2703 after each top-level definition is parsed.
2704 It is supposed to compile that function or variable
2705 and output the assembler code for it.
2706 After we return, the tree storage is freed. */
2708 void
2709 rest_of_compilation (decl)
2710 tree decl;
2712 register rtx insns;
2713 int tem;
2714 int failure = 0;
2715 int rebuild_label_notes_after_reload;
2716 int register_life_up_to_date;
2718 timevar_push (TV_REST_OF_COMPILATION);
2720 /* Now that we're out of the frontend, we shouldn't have any more
2721 CONCATs anywhere. */
2722 generating_concat_p = 0;
2724 /* When processing delayed functions, prepare_function_start() won't
2725 have been run to re-initialize it. */
2726 cse_not_expected = ! optimize;
2728 /* First, make sure that NOTE_BLOCK is set correctly for each
2729 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2730 if (!cfun->x_whole_function_mode_p)
2731 identify_blocks ();
2733 /* Then remove any notes we don't need. That will make iterating
2734 over the instruction sequence faster, and allow the garbage
2735 collector to reclaim the memory used by the notes. */
2736 remove_unnecessary_notes ();
2738 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2739 tree in sensible shape. So, we just recalculate it here. */
2740 if (cfun->x_whole_function_mode_p)
2741 reorder_blocks ();
2743 init_flow ();
2745 /* If we are reconsidering an inline function
2746 at the end of compilation, skip the stuff for making it inline. */
2748 if (DECL_SAVED_INSNS (decl) == 0)
2750 int inlinable = 0;
2751 tree parent;
2752 const char *lose;
2754 /* If this is nested inside an inlined external function, pretend
2755 it was only declared. Since we cannot inline such functions,
2756 generating code for this one is not only not necessary but will
2757 confuse some debugging output writers. */
2758 for (parent = DECL_CONTEXT (current_function_decl);
2759 parent != NULL_TREE;
2760 parent = get_containing_scope (parent))
2761 if (TREE_CODE (parent) == FUNCTION_DECL
2762 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2764 DECL_INITIAL (decl) = 0;
2765 goto exit_rest_of_compilation;
2768 /* If requested, consider whether to make this function inline. */
2769 if ((DECL_INLINE (decl) && !flag_no_inline)
2770 || flag_inline_functions)
2772 timevar_push (TV_INTEGRATION);
2773 lose = function_cannot_inline_p (decl);
2774 timevar_pop (TV_INTEGRATION);
2775 if (lose || ! optimize)
2777 if (warn_inline && DECL_INLINE (decl))
2778 warning_with_decl (decl, lose);
2779 DECL_ABSTRACT_ORIGIN (decl) = 0;
2780 /* Don't really compile an extern inline function.
2781 If we can't make it inline, pretend
2782 it was only declared. */
2783 if (DECL_EXTERNAL (decl))
2785 DECL_INITIAL (decl) = 0;
2786 goto exit_rest_of_compilation;
2789 else
2790 /* ??? Note that this has the effect of making it look
2791 like "inline" was specified for a function if we choose
2792 to inline it. This isn't quite right, but it's
2793 probably not worth the trouble to fix. */
2794 inlinable = DECL_INLINE (decl) = 1;
2797 insns = get_insns ();
2799 /* Dump the rtl code if we are dumping rtl. */
2801 if (open_dump_file (DFI_rtl, decl))
2803 if (DECL_SAVED_INSNS (decl))
2804 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2805 close_dump_file (DFI_rtl, print_rtl, insns);
2808 /* If function is inline, and we don't yet know whether to
2809 compile it by itself, defer decision till end of compilation.
2810 finish_compilation will call rest_of_compilation again
2811 for those functions that need to be output. Also defer those
2812 functions that we are supposed to defer. */
2814 if (inlinable
2815 || (DECL_INLINE (decl)
2816 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2817 && ! flag_keep_inline_functions)
2818 || DECL_EXTERNAL (decl))))
2819 DECL_DEFER_OUTPUT (decl) = 1;
2821 if (DECL_INLINE (decl))
2822 /* DWARF wants seperate debugging info for abstract and
2823 concrete instances of all inline functions, including those
2824 declared inline but not inlined, and those inlined even
2825 though they weren't declared inline. Conveniently, that's
2826 what DECL_INLINE means at this point. */
2827 note_deferral_of_defined_inline_function (decl);
2829 if (DECL_DEFER_OUTPUT (decl))
2831 /* If -Wreturn-type, we have to do a bit of compilation. We just
2832 want to call jump_optimize to figure out whether or not we can
2833 fall off the end of the function; we do the minimum amount of
2834 work necessary to make that safe. And, we set optimize to zero
2835 to keep jump_optimize from working too hard. */
2836 if (warn_return_type)
2838 int saved_optimize = optimize;
2840 optimize = 0;
2841 find_exception_handler_labels ();
2842 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2843 !JUMP_AFTER_REGSCAN);
2844 optimize = saved_optimize;
2847 current_function_nothrow = nothrow_function_p ();
2848 if (current_function_nothrow)
2849 /* Now we know that this can't throw; set the flag for the benefit
2850 of other functions later in this translation unit. */
2851 TREE_NOTHROW (current_function_decl) = 1;
2853 timevar_push (TV_INTEGRATION);
2854 save_for_inline (decl);
2855 timevar_pop (TV_INTEGRATION);
2856 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2857 goto exit_rest_of_compilation;
2860 /* If specified extern inline but we aren't inlining it, we are
2861 done. This goes for anything that gets here with DECL_EXTERNAL
2862 set, not just things with DECL_INLINE. */
2863 if (DECL_EXTERNAL (decl))
2864 goto exit_rest_of_compilation;
2867 init_EXPR_INSN_LIST_cache ();
2869 ggc_collect ();
2871 /* Initialize some variables used by the optimizers. */
2872 init_function_for_compilation ();
2874 if (! DECL_DEFER_OUTPUT (decl))
2875 TREE_ASM_WRITTEN (decl) = 1;
2877 /* Now that integrate will no longer see our rtl, we need not
2878 distinguish between the return value of this function and the
2879 return value of called functions. Also, we can remove all SETs
2880 of subregs of hard registers; they are only here because of
2881 integrate.*/
2882 rtx_equal_function_value_matters = 0;
2883 purge_hard_subreg_sets (get_insns ());
2885 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2886 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2887 goto exit_rest_of_compilation;
2889 /* Emit code to get eh context, if needed. */
2890 emit_eh_context ();
2892 /* We may have potential sibling or tail recursion sites. Select one
2893 (of possibly multiple) methods of performing the call. */
2894 if (flag_optimize_sibling_calls)
2896 timevar_push (TV_JUMP);
2897 open_dump_file (DFI_sibling, decl);
2899 optimize_sibling_and_tail_recursive_calls ();
2901 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2902 timevar_pop (TV_JUMP);
2905 #ifdef FINALIZE_PIC
2906 /* If we are doing position-independent code generation, now
2907 is the time to output special prologues and epilogues.
2908 We do not want to do this earlier, because it just clutters
2909 up inline functions with meaningless insns. */
2910 if (flag_pic)
2911 FINALIZE_PIC;
2912 #endif
2914 insns = get_insns ();
2916 /* Copy any shared structure that should not be shared. */
2917 unshare_all_rtl (current_function_decl, insns);
2919 #ifdef SETJMP_VIA_SAVE_AREA
2920 /* This must be performed before virutal register instantiation. */
2921 if (current_function_calls_alloca)
2922 optimize_save_area_alloca (insns);
2923 #endif
2925 /* Instantiate all virtual registers. */
2926 instantiate_virtual_regs (current_function_decl, insns);
2928 /* Find all the EH handlers. */
2929 find_exception_handler_labels ();
2931 open_dump_file (DFI_jump, decl);
2933 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2934 are initialized and to compute whether control can drop off the end
2935 of the function. */
2937 timevar_push (TV_JUMP);
2938 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2939 before jump optimization switches branch directions. */
2940 expected_value_to_br_prob ();
2942 reg_scan (insns, max_reg_num (), 0);
2943 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2944 JUMP_AFTER_REGSCAN);
2946 timevar_pop (TV_JUMP);
2948 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2949 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2951 close_dump_file (DFI_jump, print_rtl, insns);
2952 goto exit_rest_of_compilation;
2955 timevar_push (TV_JUMP);
2957 if (optimize > 0)
2959 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2960 cleanup_cfg (insns);
2962 /* ??? Run if-conversion before delete_null_pointer_checks,
2963 since the later does not preserve the CFG. This should
2964 be changed -- no since converting if's that are going to
2965 be deleted. */
2966 timevar_push (TV_IFCVT);
2967 if_convert (0);
2968 timevar_pop (TV_IFCVT);
2970 /* Try to identify useless null pointer tests and delete them. */
2971 if (flag_delete_null_pointer_checks)
2972 delete_null_pointer_checks (insns);
2975 /* Jump optimization, and the removal of NULL pointer checks, may
2976 have reduced the number of instructions substantially. CSE, and
2977 future passes, allocate arrays whose dimensions involve the
2978 maximum instruction UID, so if we can reduce the maximum UID
2979 we'll save big on memory. */
2980 renumber_insns (rtl_dump_file);
2981 timevar_pop (TV_JUMP);
2983 close_dump_file (DFI_jump, print_rtl, insns);
2985 ggc_collect ();
2987 /* Perform common subexpression elimination.
2988 Nonzero value from `cse_main' means that jumps were simplified
2989 and some code may now be unreachable, so do
2990 jump optimization again. */
2992 if (optimize > 0)
2994 open_dump_file (DFI_cse, decl);
2995 timevar_push (TV_CSE);
2997 reg_scan (insns, max_reg_num (), 1);
2999 if (flag_thread_jumps)
3001 timevar_push (TV_JUMP);
3002 thread_jumps (insns, max_reg_num (), 1);
3003 timevar_pop (TV_JUMP);
3006 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3008 /* If we are not running the second CSE pass, then we are no longer
3009 expecting CSE to be run. */
3010 cse_not_expected = !flag_rerun_cse_after_loop;
3012 if (tem || optimize > 1)
3014 timevar_push (TV_JUMP);
3015 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3016 !JUMP_AFTER_REGSCAN);
3017 timevar_pop (TV_JUMP);
3020 /* Run this after jump optmizations remove all the unreachable code
3021 so that unreachable code will not keep values live. */
3022 delete_trivially_dead_insns (insns, max_reg_num ());
3024 /* Try to identify useless null pointer tests and delete them. */
3025 if (flag_delete_null_pointer_checks)
3027 timevar_push (TV_JUMP);
3028 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3030 cleanup_cfg (insns);
3032 delete_null_pointer_checks (insns);
3033 timevar_pop (TV_JUMP);
3036 /* The second pass of jump optimization is likely to have
3037 removed a bunch more instructions. */
3038 renumber_insns (rtl_dump_file);
3040 timevar_pop (TV_CSE);
3041 close_dump_file (DFI_cse, print_rtl, insns);
3044 open_dump_file (DFI_addressof, decl);
3046 purge_addressof (insns);
3047 reg_scan (insns, max_reg_num (), 1);
3049 close_dump_file (DFI_addressof, print_rtl, insns);
3051 ggc_collect ();
3053 if (optimize > 0 && flag_ssa)
3055 /* Convert to SSA form. */
3057 timevar_push (TV_TO_SSA);
3058 open_dump_file (DFI_ssa, decl);
3060 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3061 cleanup_cfg (insns);
3062 convert_to_ssa ();
3064 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
3065 timevar_pop (TV_TO_SSA);
3067 /* The SSA implementation uses basic block numbers in its phi
3068 nodes. Thus, changing the control-flow graph or the basic
3069 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
3070 may cause problems. */
3072 if (flag_dce)
3074 /* Remove dead code. */
3076 timevar_push (TV_DEAD_CODE_ELIM);
3077 open_dump_file (DFI_dce, decl);
3079 insns = get_insns ();
3080 eliminate_dead_code();
3082 close_dump_file (DFI_dce, print_rtl_with_bb, insns);
3083 timevar_pop (TV_DEAD_CODE_ELIM);
3086 /* Convert from SSA form. */
3088 timevar_push (TV_FROM_SSA);
3089 open_dump_file (DFI_ussa, decl);
3091 convert_from_ssa ();
3092 /* New registers have been created. Rescan their usage. */
3093 reg_scan (insns, max_reg_num (), 1);
3094 /* Life analysis used in SSA adds log_links but these
3095 shouldn't be there until the flow stage, so clear
3096 them away. */
3097 clear_log_links (insns);
3099 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
3100 timevar_pop (TV_FROM_SSA);
3102 ggc_collect ();
3105 /* Perform global cse. */
3107 if (optimize > 0 && flag_gcse)
3109 timevar_push (TV_GCSE);
3110 open_dump_file (DFI_gcse, decl);
3112 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3113 cleanup_cfg (insns);
3114 tem = gcse_main (insns, rtl_dump_file);
3116 /* If gcse altered any jumps, rerun jump optimizations to clean
3117 things up. */
3118 if (tem)
3120 timevar_push (TV_JUMP);
3121 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3122 !JUMP_AFTER_REGSCAN);
3123 timevar_pop (TV_JUMP);
3126 close_dump_file (DFI_gcse, print_rtl, insns);
3127 timevar_pop (TV_GCSE);
3129 ggc_collect ();
3132 /* Move constant computations out of loops. */
3134 if (optimize > 0)
3136 timevar_push (TV_LOOP);
3137 open_dump_file (DFI_loop, decl);
3139 if (flag_rerun_loop_opt)
3141 /* We only want to perform unrolling once. */
3143 loop_optimize (insns, rtl_dump_file, 0);
3145 /* The first call to loop_optimize makes some instructions
3146 trivially dead. We delete those instructions now in the
3147 hope that doing so will make the heuristics in loop work
3148 better and possibly speed up compilation. */
3149 delete_trivially_dead_insns (insns, max_reg_num ());
3151 /* The regscan pass is currently necessary as the alias
3152 analysis code depends on this information. */
3153 reg_scan (insns, max_reg_num (), 1);
3155 loop_optimize (insns, rtl_dump_file,
3156 (flag_unroll_loops ? LOOP_UNROLL : 0) | LOOP_BCT);
3158 close_dump_file (DFI_loop, print_rtl, insns);
3159 timevar_pop (TV_LOOP);
3161 ggc_collect ();
3164 if (optimize > 0)
3166 timevar_push (TV_CSE2);
3167 open_dump_file (DFI_cse2, decl);
3169 if (flag_rerun_cse_after_loop)
3171 /* Running another jump optimization pass before the second
3172 cse pass sometimes simplifies the RTL enough to allow
3173 the second CSE pass to do a better job. Jump_optimize can change
3174 max_reg_num so we must rerun reg_scan afterwards.
3175 ??? Rework to not call reg_scan so often. */
3176 timevar_push (TV_JUMP);
3178 reg_scan (insns, max_reg_num (), 0);
3179 jump_optimize (insns, !JUMP_CROSS_JUMP,
3180 !JUMP_NOOP_MOVES, JUMP_AFTER_REGSCAN);
3182 timevar_push (TV_IFCVT);
3184 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3185 cleanup_cfg (insns);
3186 if_convert (0);
3188 timevar_pop(TV_IFCVT);
3190 timevar_pop (TV_JUMP);
3192 reg_scan (insns, max_reg_num (), 0);
3193 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3195 if (tem)
3197 timevar_push (TV_JUMP);
3198 jump_optimize (insns, !JUMP_CROSS_JUMP,
3199 !JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3200 timevar_pop (TV_JUMP);
3204 if (flag_thread_jumps)
3206 /* This pass of jump threading straightens out code
3207 that was kinked by loop optimization. */
3208 timevar_push (TV_JUMP);
3209 reg_scan (insns, max_reg_num (), 0);
3210 thread_jumps (insns, max_reg_num (), 0);
3211 timevar_pop (TV_JUMP);
3214 close_dump_file (DFI_cse2, print_rtl, insns);
3215 timevar_pop (TV_CSE2);
3217 ggc_collect ();
3220 cse_not_expected = 1;
3222 regclass_init ();
3224 /* Do control and data flow analysis; wrote some of the results to
3225 the dump file. */
3227 timevar_push (TV_FLOW);
3228 open_dump_file (DFI_cfg, decl);
3230 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3231 cleanup_cfg (insns);
3232 check_function_return_warnings ();
3234 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
3236 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3238 timevar_push (TV_BRANCH_PROB);
3239 open_dump_file (DFI_bp, decl);
3241 branch_prob ();
3243 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
3244 timevar_pop (TV_BRANCH_PROB);
3247 open_dump_file (DFI_life, decl);
3248 if (optimize)
3250 struct loops loops;
3252 /* Discover and record the loop depth at the head of each basic
3253 block. The loop infrastructure does the real job for us. */
3254 flow_loops_find (&loops, LOOP_TREE);
3256 /* Estimate using heuristics if no profiling info is available. */
3257 if (flag_guess_branch_prob)
3258 estimate_probability (&loops);
3260 if (rtl_dump_file)
3261 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
3263 flow_loops_free (&loops);
3265 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3266 mark_constant_function ();
3267 timevar_pop (TV_FLOW);
3269 register_life_up_to_date = 1;
3270 no_new_pseudos = 1;
3272 if (warn_uninitialized || extra_warnings)
3274 uninitialized_vars_warning (DECL_INITIAL (decl));
3275 if (extra_warnings)
3276 setjmp_args_warning ();
3279 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3281 ggc_collect ();
3283 /* If -opt, try combining insns through substitution. */
3285 if (optimize > 0)
3287 int rebuild_jump_labels_after_combine = 0;
3289 timevar_push (TV_COMBINE);
3290 open_dump_file (DFI_combine, decl);
3292 rebuild_jump_labels_after_combine
3293 = combine_instructions (insns, max_reg_num ());
3295 /* Combining insns may have turned an indirect jump into a
3296 direct jump. Rebuid the JUMP_LABEL fields of jumping
3297 instructions. */
3298 if (rebuild_jump_labels_after_combine)
3300 timevar_push (TV_JUMP);
3301 rebuild_jump_labels (insns);
3302 timevar_pop (TV_JUMP);
3304 timevar_push (TV_FLOW);
3305 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3306 cleanup_cfg (insns);
3308 /* Blimey. We've got to have the CFG up to date for the call to
3309 if_convert below. However, the random deletion of blocks
3310 without updating life info can wind up with Wierd Stuff in
3311 global_live_at_end. We then run sched1, which updates things
3312 properly, discovers the wierdness and aborts. */
3313 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
3314 PROP_DEATH_NOTES | PROP_KILL_DEAD_CODE
3315 | PROP_SCAN_DEAD_CODE);
3317 timevar_pop (TV_FLOW);
3320 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3321 timevar_pop (TV_COMBINE);
3323 ggc_collect ();
3326 /* Rerun if-conversion, as combine may have simplified things enough to
3327 now meet sequence length restrictions. */
3328 if (optimize > 0)
3330 timevar_push (TV_IFCVT);
3331 open_dump_file (DFI_ce, decl);
3333 no_new_pseudos = 0;
3334 if_convert (1);
3335 no_new_pseudos = 1;
3337 close_dump_file (DFI_ce, print_rtl_with_bb, insns);
3338 timevar_pop (TV_IFCVT);
3341 /* Register allocation pre-pass, to reduce number of moves
3342 necessary for two-address machines. */
3343 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3345 timevar_push (TV_REGMOVE);
3346 open_dump_file (DFI_regmove, decl);
3348 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3350 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3351 timevar_pop (TV_REGMOVE);
3353 ggc_collect ();
3356 /* Any of the several passes since flow1 will have munged register
3357 lifetime data a bit. */
3358 if (optimize > 0)
3359 register_life_up_to_date = 0;
3361 #ifdef OPTIMIZE_MODE_SWITCHING
3362 timevar_push (TV_GCSE);
3364 if (optimize_mode_switching (NULL_PTR))
3366 /* We did work, and so had to regenerate global life information.
3367 Take advantage of this and don't re-recompute register life
3368 information below. */
3369 register_life_up_to_date = 1;
3372 timevar_pop (TV_GCSE);
3373 #endif
3375 #ifdef INSN_SCHEDULING
3377 /* Print function header into sched dump now
3378 because doing the sched analysis makes some of the dump. */
3379 if (optimize > 0 && flag_schedule_insns)
3381 timevar_push (TV_SCHED);
3382 open_dump_file (DFI_sched, decl);
3384 /* Do control and data sched analysis,
3385 and write some of the results to dump file. */
3387 schedule_insns (rtl_dump_file);
3389 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3390 timevar_pop (TV_SCHED);
3392 ggc_collect ();
3394 /* Register lifetime information was updated as part of verifying
3395 the schedule. */
3396 register_life_up_to_date = 1;
3398 #endif
3400 /* Determine if the current function is a leaf before running reload
3401 since this can impact optimizations done by the prologue and
3402 epilogue thus changing register elimination offsets. */
3403 current_function_is_leaf = leaf_function_p ();
3405 timevar_push (TV_LOCAL_ALLOC);
3406 open_dump_file (DFI_lreg, decl);
3408 /* Allocate pseudo-regs that are used only within 1 basic block.
3410 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3411 jump optimizer after register allocation and reloading are finished. */
3413 if (! register_life_up_to_date)
3414 recompute_reg_usage (insns, ! optimize_size);
3415 regclass (insns, max_reg_num (), rtl_dump_file);
3416 rebuild_label_notes_after_reload = local_alloc ();
3418 timevar_pop (TV_LOCAL_ALLOC);
3420 if (dump_file[DFI_lreg].enabled)
3422 timevar_push (TV_DUMP);
3424 dump_flow_info (rtl_dump_file);
3425 dump_local_alloc (rtl_dump_file);
3427 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3428 timevar_pop (TV_DUMP);
3431 ggc_collect ();
3433 timevar_push (TV_GLOBAL_ALLOC);
3434 open_dump_file (DFI_greg, decl);
3436 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3437 pass fixing up any insns that are invalid. */
3439 if (optimize)
3440 failure = global_alloc (rtl_dump_file);
3441 else
3443 build_insn_chain (insns);
3444 failure = reload (insns, 0);
3447 timevar_pop (TV_GLOBAL_ALLOC);
3449 if (dump_file[DFI_greg].enabled)
3451 timevar_push (TV_DUMP);
3453 dump_global_regs (rtl_dump_file);
3455 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3456 timevar_pop (TV_DUMP);
3459 if (failure)
3460 goto exit_rest_of_compilation;
3462 ggc_collect ();
3464 open_dump_file (DFI_postreload, decl);
3466 /* Do a very simple CSE pass over just the hard registers. */
3467 if (optimize > 0)
3469 timevar_push (TV_RELOAD_CSE_REGS);
3470 reload_cse_regs (insns);
3471 timevar_pop (TV_RELOAD_CSE_REGS);
3474 /* If optimizing, then go ahead and split insns now since we are about
3475 to recompute flow information anyway. */
3476 if (optimize > 0)
3478 int old_labelnum = max_label_num ();
3480 split_all_insns (0);
3481 rebuild_label_notes_after_reload |= old_labelnum != max_label_num ();
3484 /* Register allocation and reloading may have turned an indirect jump into
3485 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3486 jumping instructions. */
3487 if (rebuild_label_notes_after_reload)
3489 timevar_push (TV_JUMP);
3491 rebuild_jump_labels (insns);
3493 timevar_pop (TV_JUMP);
3496 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3498 /* Re-create the death notes which were deleted during reload. */
3499 timevar_push (TV_FLOW2);
3500 open_dump_file (DFI_flow2, decl);
3502 jump_optimize (insns, !JUMP_CROSS_JUMP,
3503 JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3504 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3506 /* On some machines, the prologue and epilogue code, or parts thereof,
3507 can be represented as RTL. Doing so lets us schedule insns between
3508 it and the rest of the code and also allows delayed branch
3509 scheduling to operate in the epilogue. */
3510 thread_prologue_and_epilogue_insns (insns);
3512 if (optimize)
3514 cleanup_cfg (insns);
3515 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3517 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3518 even for machines with possibly nonzero RETURN_POPS_ARGS
3519 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3520 push instructions will have popping returns. */
3521 #ifndef PUSH_ROUNDING
3522 if (!ACCUMULATE_OUTGOING_ARGS)
3523 #endif
3524 combine_stack_adjustments ();
3526 ggc_collect ();
3529 flow2_completed = 1;
3531 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3532 timevar_pop (TV_FLOW2);
3534 #ifdef HAVE_peephole2
3535 if (optimize > 0 && flag_peephole2)
3537 timevar_push (TV_PEEPHOLE2);
3538 open_dump_file (DFI_peephole2, decl);
3540 peephole2_optimize (rtl_dump_file);
3542 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3543 timevar_pop (TV_PEEPHOLE2);
3545 #endif
3547 if (optimize > 0 && flag_rename_registers)
3549 timevar_push (TV_RENAME_REGISTERS);
3550 open_dump_file (DFI_rnreg, decl);
3552 regrename_optimize ();
3554 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3555 timevar_pop (TV_RENAME_REGISTERS);
3558 if (optimize > 0)
3560 timevar_push (TV_IFCVT2);
3561 open_dump_file (DFI_ce2, decl);
3563 if_convert (1);
3565 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3566 timevar_pop (TV_IFCVT2);
3569 #ifdef INSN_SCHEDULING
3570 if (optimize > 0 && flag_schedule_insns_after_reload)
3572 timevar_push (TV_SCHED2);
3573 open_dump_file (DFI_sched2, decl);
3575 /* Do control and data sched analysis again,
3576 and write some more of the results to dump file. */
3578 schedule_insns (rtl_dump_file);
3580 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3581 timevar_pop (TV_SCHED2);
3583 ggc_collect ();
3585 #endif
3587 #ifdef LEAF_REGISTERS
3588 current_function_uses_only_leaf_regs
3589 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3590 #endif
3592 if (optimize > 0 && flag_reorder_blocks)
3594 timevar_push (TV_REORDER_BLOCKS);
3595 open_dump_file (DFI_bbro, decl);
3597 reorder_basic_blocks ();
3599 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3600 timevar_pop (TV_REORDER_BLOCKS);
3603 /* One more attempt to remove jumps to .+1 left by dead-store elimination.
3604 Also do cross-jumping this time and delete no-op move insns. */
3606 if (optimize > 0)
3608 timevar_push (TV_JUMP);
3609 open_dump_file (DFI_jump2, decl);
3611 jump_optimize (insns, JUMP_CROSS_JUMP, JUMP_NOOP_MOVES,
3612 !JUMP_AFTER_REGSCAN);
3614 /* CFG no longer kept up to date. */
3616 close_dump_file (DFI_jump2, print_rtl, insns);
3617 timevar_pop (TV_JUMP);
3620 /* If a machine dependent reorganization is needed, call it. */
3621 #ifdef MACHINE_DEPENDENT_REORG
3622 open_dump_file (DFI_mach, decl);
3624 MACHINE_DEPENDENT_REORG (insns);
3626 close_dump_file (DFI_mach, print_rtl, insns);
3628 ggc_collect ();
3629 #endif
3631 /* If a scheduling pass for delayed branches is to be done,
3632 call the scheduling code. */
3634 #ifdef DELAY_SLOTS
3635 if (optimize > 0 && flag_delayed_branch)
3637 timevar_push (TV_DBR_SCHED);
3638 open_dump_file (DFI_dbr, decl);
3640 dbr_schedule (insns, rtl_dump_file);
3642 close_dump_file (DFI_dbr, print_rtl, insns);
3643 timevar_pop (TV_DBR_SCHED);
3645 ggc_collect ();
3647 #endif
3649 /* Shorten branches.
3651 Note this must run before reg-stack because of death note (ab)use
3652 in the ia32 backend. */
3653 timevar_push (TV_SHORTEN_BRANCH);
3654 shorten_branches (get_insns ());
3655 timevar_pop (TV_SHORTEN_BRANCH);
3657 #ifdef STACK_REGS
3658 timevar_push (TV_REG_STACK);
3659 open_dump_file (DFI_stack, decl);
3661 reg_to_stack (insns, rtl_dump_file);
3663 close_dump_file (DFI_stack, print_rtl, insns);
3664 timevar_pop (TV_REG_STACK);
3666 ggc_collect ();
3667 #endif
3669 current_function_nothrow = nothrow_function_p ();
3670 if (current_function_nothrow)
3671 /* Now we know that this can't throw; set the flag for the benefit
3672 of other functions later in this translation unit. */
3673 TREE_NOTHROW (current_function_decl) = 1;
3675 /* Now turn the rtl into assembler code. */
3677 timevar_push (TV_FINAL);
3679 rtx x;
3680 const char *fnname;
3682 /* Get the function's name, as described by its RTL. This may be
3683 different from the DECL_NAME name used in the source file. */
3685 x = DECL_RTL (decl);
3686 if (GET_CODE (x) != MEM)
3687 abort ();
3688 x = XEXP (x, 0);
3689 if (GET_CODE (x) != SYMBOL_REF)
3690 abort ();
3691 fnname = XSTR (x, 0);
3693 assemble_start_function (decl, fnname);
3694 final_start_function (insns, asm_out_file, optimize);
3695 final (insns, asm_out_file, optimize, 0);
3696 final_end_function (insns, asm_out_file, optimize);
3697 assemble_end_function (decl, fnname);
3698 if (! quiet_flag)
3699 fflush (asm_out_file);
3701 /* Release all memory allocated by flow. */
3702 free_basic_block_vars (0);
3704 /* Release all memory held by regsets now. */
3705 regset_release_memory ();
3707 timevar_pop (TV_FINAL);
3709 ggc_collect ();
3711 /* Write DBX symbols if requested. */
3713 /* Note that for those inline functions where we don't initially
3714 know for certain that we will be generating an out-of-line copy,
3715 the first invocation of this routine (rest_of_compilation) will
3716 skip over this code by doing a `goto exit_rest_of_compilation;'.
3717 Later on, finish_compilation will call rest_of_compilation again
3718 for those inline functions that need to have out-of-line copies
3719 generated. During that call, we *will* be routed past here. */
3721 timevar_push (TV_SYMOUT);
3722 #ifdef DBX_DEBUGGING_INFO
3723 if (write_symbols == DBX_DEBUG)
3724 dbxout_function (decl);
3725 #endif
3727 #ifdef DWARF_DEBUGGING_INFO
3728 if (write_symbols == DWARF_DEBUG)
3729 dwarfout_file_scope_decl (decl, 0);
3730 #endif
3732 #ifdef DWARF2_DEBUGGING_INFO
3733 if (write_symbols == DWARF2_DEBUG)
3734 dwarf2out_decl (decl);
3735 #endif
3736 timevar_pop (TV_SYMOUT);
3738 exit_rest_of_compilation:
3740 /* In case the function was not output,
3741 don't leave any temporary anonymous types
3742 queued up for sdb output. */
3743 #ifdef SDB_DEBUGGING_INFO
3744 if (write_symbols == SDB_DEBUG)
3745 sdbout_types (NULL_TREE);
3746 #endif
3748 reload_completed = 0;
3749 flow2_completed = 0;
3750 no_new_pseudos = 0;
3752 timevar_push (TV_FINAL);
3754 /* Clear out the insn_length contents now that they are no
3755 longer valid. */
3756 init_insn_lengths ();
3758 /* Clear out the real_constant_chain before some of the rtx's
3759 it runs through become garbage. */
3760 clear_const_double_mem ();
3762 /* Show no temporary slots allocated. */
3763 init_temp_slots ();
3765 free_basic_block_vars (0);
3767 timevar_pop (TV_FINAL);
3769 /* Make sure volatile mem refs aren't considered valid operands for
3770 arithmetic insns. We must call this here if this is a nested inline
3771 function, since the above code leaves us in the init_recog state
3772 (from final.c), and the function context push/pop code does not
3773 save/restore volatile_ok.
3775 ??? Maybe it isn't necessary for expand_start_function to call this
3776 anymore if we do it here? */
3778 init_recog_no_volatile ();
3780 /* We're done with this function. Free up memory if we can. */
3781 free_after_parsing (cfun);
3782 if (! DECL_DEFER_OUTPUT (decl))
3783 free_after_compilation (cfun);
3784 cfun = 0;
3786 ggc_collect ();
3788 timevar_pop (TV_REST_OF_COMPILATION);
3791 static void
3792 display_help ()
3794 int undoc;
3795 unsigned long i;
3796 const char *lang;
3798 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3799 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3800 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3801 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3802 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3803 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"));
3805 for (i = ARRAY_SIZE (f_options); i--;)
3807 const char *description = f_options[i].description;
3809 if (description != NULL && * description != 0)
3810 printf (" -f%-21s %s\n",
3811 f_options[i].string, description);
3814 printf (_(" -O[number] Set optimisation level to [number]\n"));
3815 printf (_(" -Os Optimise for space rather than speed\n"));
3816 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3817 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3818 printf (_(" -w Suppress warnings\n"));
3819 printf (_(" -W Enable extra warnings\n"));
3821 for (i = ARRAY_SIZE (W_options); i--;)
3823 const char *description = W_options[i].description;
3825 if (description != NULL && * description != 0)
3826 printf (" -W%-21s %s\n",
3827 W_options[i].string, description);
3830 printf (_(" -Wunused Enable unused warnings\n"));
3831 printf (_(" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n"));
3832 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3833 printf (_(" -p Enable function profiling\n"));
3834 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3835 printf (_(" -a Enable block profiling \n"));
3836 #endif
3837 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3838 printf (_(" -ax Enable jump profiling \n"));
3839 #endif
3840 printf (_(" -o <file> Place output into <file> \n"));
3841 printf (_("\
3842 -G <number> Put global and static data smaller than <number>\n\
3843 bytes into a special section (on some targets)\n"));
3845 for (i = ARRAY_SIZE (debug_args); i--;)
3847 if (debug_args[i].description != NULL)
3848 printf (" -g%-21s %s\n",
3849 debug_args[i].arg, debug_args[i].description);
3852 printf (_(" -aux-info <file> Emit declaration info into <file>.X\n"));
3853 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3854 printf (_(" -version Display the compiler's version\n"));
3855 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3856 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3857 #if defined INSN_SCHEDULING
3858 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3859 #endif
3860 printf (_(" --help Display this information\n"));
3862 undoc = 0;
3863 lang = "language";
3865 /* Display descriptions of language specific options.
3866 If there is no description, note that there is an undocumented option.
3867 If the description is empty, do not display anything. (This allows
3868 options to be deliberately undocumented, for whatever reason).
3869 If the option string is missing, then this is a marker, indicating
3870 that the description string is in fact the name of a language, whose
3871 language specific options are to follow. */
3873 if (ARRAY_SIZE (documented_lang_options) > 1)
3875 printf (_("\nLanguage specific options:\n"));
3877 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3879 const char *description = documented_lang_options[i].description;
3880 const char *option = documented_lang_options[i].option;
3882 if (description == NULL)
3884 undoc = 1;
3886 if (extra_warnings)
3887 printf (_(" %-23.23s [undocumented]\n"), option);
3889 else if (*description == 0)
3890 continue;
3891 else if (option == NULL)
3893 if (undoc)
3894 printf
3895 (_("\nThere are undocumented %s specific options as well.\n"),
3896 lang);
3897 undoc = 0;
3899 printf (_("\n Options for %s:\n"), description);
3901 lang = description;
3903 else
3904 printf (" %-23.23s %s\n", option, description);
3908 if (undoc)
3909 printf (_("\nThere are undocumented %s specific options as well.\n"),
3910 lang);
3912 display_target_options ();
3915 static void
3916 display_target_options ()
3918 int undoc,i;
3920 if (ARRAY_SIZE (target_switches) > 1
3921 #ifdef TARGET_OPTIONS
3922 || ARRAY_SIZE (target_options) > 1
3923 #endif
3926 int doc = 0;
3928 undoc = 0;
3930 printf (_("\nTarget specific options:\n"));
3932 for (i = ARRAY_SIZE (target_switches); i--;)
3934 const char *option = target_switches[i].name;
3935 const char *description = target_switches[i].description;
3937 if (option == NULL || *option == 0)
3938 continue;
3939 else if (description == NULL)
3941 undoc = 1;
3943 if (extra_warnings)
3944 printf (_(" -m%-23.23s [undocumented]\n"), option);
3946 else if (* description != 0)
3947 doc += printf (" -m%-23.23s %s\n", option, description);
3950 #ifdef TARGET_OPTIONS
3951 for (i = ARRAY_SIZE (target_options); i--;)
3953 const char *option = target_options[i].prefix;
3954 const char *description = target_options[i].description;
3956 if (option == NULL || *option == 0)
3957 continue;
3958 else if (description == NULL)
3960 undoc = 1;
3962 if (extra_warnings)
3963 printf (_(" -m%-23.23s [undocumented]\n"), option);
3965 else if (* description != 0)
3966 doc += printf (" -m%-23.23s %s\n", option, description);
3968 #endif
3969 if (undoc)
3971 if (doc)
3972 printf (_("\nThere are undocumented target specific options as well.\n"));
3973 else
3974 printf (_(" They exist, but they are not documented.\n"));
3979 /* Parse a -d... comand line switch. */
3981 static void
3982 decode_d_option (arg)
3983 const char *arg;
3985 int i, c, matched;
3987 while (*arg)
3988 switch (c = *arg++)
3990 case 'a':
3991 for (i = 0; i < (int) DFI_MAX; ++i)
3992 dump_file[i].enabled = 1;
3993 break;
3994 case 'A':
3995 flag_debug_asm = 1;
3996 break;
3997 case 'm':
3998 flag_print_mem = 1;
3999 break;
4000 case 'p':
4001 flag_print_asm_name = 1;
4002 break;
4003 case 'P':
4004 flag_dump_rtl_in_asm = 1;
4005 flag_print_asm_name = 1;
4006 break;
4007 case 'v':
4008 graph_dump_format = vcg;
4009 break;
4010 case 'x':
4011 rtl_dump_and_exit = 1;
4012 break;
4013 case 'y':
4014 set_yydebug (1);
4015 break;
4016 case 'D': /* These are handled by the preprocessor. */
4017 case 'I':
4018 break;
4020 default:
4021 matched = 0;
4022 for (i = 0; i < (int) DFI_MAX; ++i)
4023 if (c == dump_file[i].debug_switch)
4025 dump_file[i].enabled = 1;
4026 matched = 1;
4029 if (! matched)
4030 warning ("unrecognized gcc debugging option: %c", c);
4031 break;
4035 /* Parse a -f... comand line switch. ARG is the value after the -f.
4036 It is safe to access 'ARG - 2' to generate the full switch name.
4037 Return the number of strings consumed. */
4039 static int
4040 decode_f_option (arg)
4041 const char *arg;
4043 int j;
4044 const char *option_value = NULL;
4046 /* Search for the option in the table of binary f options. */
4047 for (j = ARRAY_SIZE (f_options); j--;)
4049 if (!strcmp (arg, f_options[j].string))
4051 *f_options[j].variable = f_options[j].on_value;
4052 return 1;
4055 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4056 && ! strcmp (arg + 3, f_options[j].string))
4058 *f_options[j].variable = ! f_options[j].on_value;
4059 return 1;
4063 if ((option_value = skip_leading_substring (arg, "inline-limit-"))
4064 || (option_value = skip_leading_substring (arg, "inline-limit=")))
4066 int val =
4067 read_integral_parameter (option_value, arg - 2,
4068 MAX_INLINE_INSNS);
4069 set_param_value ("max-inline-insns", val);
4071 #ifdef INSN_SCHEDULING
4072 else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
4073 fix_sched_param ("verbose", option_value);
4074 #endif
4075 else if ((option_value = skip_leading_substring (arg, "fixed-")))
4076 fix_register (option_value, 1, 1);
4077 else if ((option_value = skip_leading_substring (arg, "call-used-")))
4078 fix_register (option_value, 0, 1);
4079 else if ((option_value = skip_leading_substring (arg, "call-saved-")))
4080 fix_register (option_value, 0, 0);
4081 else if ((option_value = skip_leading_substring (arg, "align-loops=")))
4082 align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
4083 else if ((option_value = skip_leading_substring (arg, "align-functions=")))
4084 align_functions
4085 = read_integral_parameter (option_value, arg - 2, align_functions);
4086 else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
4087 align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
4088 else if ((option_value = skip_leading_substring (arg, "align-labels=")))
4089 align_labels
4090 = read_integral_parameter (option_value, arg - 2, align_labels);
4091 else if ((option_value
4092 = skip_leading_substring (arg, "stack-limit-register=")))
4094 int reg = decode_reg_name (option_value);
4095 if (reg < 0)
4096 error ("unrecognized register name `%s'", option_value);
4097 else
4098 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
4100 else if ((option_value
4101 = skip_leading_substring (arg, "stack-limit-symbol=")))
4103 const char *nm;
4104 nm = ggc_strdup (option_value);
4105 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
4107 else if ((option_value
4108 = skip_leading_substring (arg, "message-length=")))
4109 diagnostic_message_length_per_line =
4110 read_integral_parameter (option_value, arg - 2,
4111 diagnostic_message_length_per_line);
4112 else if ((option_value
4113 = skip_leading_substring (arg, "diagnostics-show-location=")))
4115 if (!strcmp (option_value, "once"))
4116 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
4117 else if (!strcmp (option_value, "every-line"))
4118 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE);
4119 else
4120 error ("Unrecognized option `%s'", arg - 2);
4122 else if (!strcmp (arg, "no-stack-limit"))
4123 stack_limit_rtx = NULL_RTX;
4124 else if (!strcmp (arg, "preprocessed"))
4125 /* Recognise this switch but do nothing. This prevents warnings
4126 about an unrecognized switch if cpplib has not been linked in. */
4128 else
4129 return 0;
4131 return 1;
4134 /* Parse a -W... comand line switch. ARG is the value after the -W.
4135 It is safe to access 'ARG - 2' to generate the full switch name.
4136 Return the number of strings consumed. */
4138 static int
4139 decode_W_option (arg)
4140 const char *arg;
4142 const char *option_value = NULL;
4143 int j;
4145 /* Search for the option in the table of binary W options. */
4147 for (j = ARRAY_SIZE (W_options); j--;)
4149 if (!strcmp (arg, W_options[j].string))
4151 *W_options[j].variable = W_options[j].on_value;
4152 return 1;
4155 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4156 && ! strcmp (arg + 3, W_options[j].string))
4158 *W_options[j].variable = ! W_options[j].on_value;
4159 return 1;
4163 if ((option_value = skip_leading_substring (arg, "id-clash-")))
4165 id_clash_len = read_integral_parameter (option_value, arg - 2, -1);
4167 if (id_clash_len != -1)
4168 warn_id_clash = 1;
4170 else if ((option_value = skip_leading_substring (arg, "larger-than-")))
4172 larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
4174 warn_larger_than = larger_than_size != -1;
4176 else if (!strcmp (arg, "unused"))
4178 set_Wunused (1);
4180 else if (!strcmp (arg, "no-unused"))
4182 set_Wunused (0);
4184 else
4185 return 0;
4187 return 1;
4190 /* Parse a -g... comand line switch. ARG is the value after the -g.
4191 It is safe to access 'ARG - 2' to generate the full switch name.
4192 Return the number of strings consumed. */
4194 static int
4195 decode_g_option (arg)
4196 const char *arg;
4198 unsigned level;
4199 /* A lot of code assumes write_symbols == NO_DEBUG if the
4200 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4201 of what debugging type has been selected). This records the
4202 selected type. It is an error to specify more than one
4203 debugging type. */
4204 static enum debug_info_type selected_debug_type = NO_DEBUG;
4205 /* Non-zero if debugging format has been explicitly set.
4206 -g and -ggdb don't explicitly set the debugging format so
4207 -gdwarf -g3 is equivalent to -gdwarf3. */
4208 static int type_explicitly_set_p = 0;
4209 /* Indexed by enum debug_info_type. */
4210 static const char *debug_type_names[] =
4212 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4215 /* The maximum admissible debug level value. */
4216 static const unsigned max_debug_level = 3;
4218 /* Look up ARG in the table. */
4219 for (da = debug_args; da->arg; da++)
4221 const int da_len = strlen (da->arg);
4223 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4225 enum debug_info_type type = da->debug_type;
4226 const char *p = arg + da_len;
4228 if (*p && (*p < '0' || *p > '9'))
4229 continue;
4231 /* A debug flag without a level defaults to level 2.
4232 Note we do not want to call read_integral_parameter
4233 for that case since it will call atoi which
4234 will return zero.
4236 ??? We may want to generalize the interface to
4237 read_integral_parameter to better handle this case
4238 if this case shows up often. */
4239 if (*p)
4240 level = read_integral_parameter (p, 0, max_debug_level + 1);
4241 else
4242 level = 2;
4244 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4246 error ("use -gdwarf -g%d for DWARF v1, level %d",
4247 level, level);
4248 if (level == 2)
4249 error ("use -gdwarf-2 for DWARF v2");
4252 if (level > max_debug_level)
4254 warning ("\
4255 ignoring option `%s' due to invalid debug level specification",
4256 arg - 2);
4257 level = debug_info_level;
4260 if (type == NO_DEBUG)
4262 type = PREFERRED_DEBUGGING_TYPE;
4264 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4266 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4267 type = DWARF2_DEBUG;
4268 #else
4269 #ifdef DBX_DEBUGGING_INFO
4270 type = DBX_DEBUG;
4271 #endif
4272 #endif
4276 if (type == NO_DEBUG)
4277 warning ("`%s': unknown or unsupported -g option", arg - 2);
4279 /* Does it conflict with an already selected type? */
4280 if (type_explicitly_set_p
4281 /* -g/-ggdb don't conflict with anything. */
4282 && da->debug_type != NO_DEBUG
4283 && type != selected_debug_type)
4284 warning ("`%s' ignored, conflicts with `-g%s'",
4285 arg - 2, debug_type_names[(int) selected_debug_type]);
4286 else
4288 /* If the format has already been set, -g/-ggdb
4289 only change the debug level. */
4290 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4291 /* Don't change debugging type. */
4293 else
4295 selected_debug_type = type;
4296 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4299 write_symbols = (level == 0
4300 ? NO_DEBUG
4301 : selected_debug_type);
4302 use_gnu_debug_info_extensions = da->use_extensions_p;
4303 debug_info_level = (enum debug_info_level) level;
4306 break;
4310 if (! da->arg)
4311 return 0;
4313 return 1;
4316 /* Decode the first argument in the argv as a language-independent option.
4317 Return the number of strings consumed. */
4319 static unsigned int
4320 independent_decode_option (argc, argv)
4321 int argc;
4322 char **argv;
4324 char *arg = argv[0];
4326 if (arg[0] != '-' || arg[1] == 0)
4328 if (arg[0] == '+')
4329 return 0;
4331 filename = arg;
4333 return 1;
4336 arg++;
4338 if (!strcmp (arg, "-help"))
4340 display_help ();
4341 exit_after_options = 1;
4344 if (!strcmp (arg, "-target-help"))
4346 display_target_options ();
4347 exit_after_options = 1;
4350 if (!strcmp (arg, "-version"))
4352 print_version (stderr, "");
4353 exit_after_options = 1;
4356 /* Handle '--param <name>=<value>'. */
4357 if (strcmp (arg, "-param") == 0)
4359 char *equal;
4361 if (argc == 1)
4363 error ("-param option missing argument");
4364 return 1;
4367 /* Get the '<name>=<value' parameter. */
4368 arg = argv[1];
4369 /* Look for the `='. */
4370 equal = strchr (arg, '=');
4371 if (!equal)
4372 error ("invalid --param option: %s", arg);
4373 else
4375 int val;
4377 /* Zero out the `=' sign so that we get two separate strings. */
4378 *equal = '\0';
4379 /* Figure out what value is specified. */
4380 val = read_integral_parameter (equal + 1, NULL, INVALID_PARAM_VAL);
4381 if (val != INVALID_PARAM_VAL)
4382 set_param_value (arg, val);
4383 else
4384 error ("invalid parameter value `%s'", equal + 1);
4387 return 2;
4390 if (*arg == 'Y')
4391 arg++;
4393 switch (*arg)
4395 default:
4396 return 0;
4398 case 'O':
4399 /* Already been treated in main (). Do nothing. */
4400 break;
4402 case 'm':
4403 set_target_switch (arg + 1);
4404 break;
4406 case 'f':
4407 return decode_f_option (arg + 1);
4409 case 'g':
4410 return decode_g_option (arg + 1);
4412 case 'd':
4413 if (!strcmp (arg, "dumpbase"))
4415 if (argc == 1)
4416 return 0;
4418 dump_base_name = argv[1];
4419 return 2;
4421 else
4422 decode_d_option (arg + 1);
4423 break;
4425 case 'p':
4426 if (!strcmp (arg, "pedantic"))
4427 pedantic = 1;
4428 else if (!strcmp (arg, "pedantic-errors"))
4429 flag_pedantic_errors = pedantic = 1;
4430 else if (arg[1] == 0)
4431 profile_flag = 1;
4432 else
4433 return 0;
4434 break;
4436 case 'q':
4437 if (!strcmp (arg, "quiet"))
4438 quiet_flag = 1;
4439 else
4440 return 0;
4441 break;
4443 case 'v':
4444 if (!strcmp (arg, "version"))
4445 version_flag = 1;
4446 else
4447 return 0;
4448 break;
4450 case 'w':
4451 if (arg[1] == 0)
4452 inhibit_warnings = 1;
4453 else
4454 return 0;
4455 break;
4457 case 'W':
4458 if (arg[1] == 0)
4460 extra_warnings = 1;
4461 /* We save the value of warn_uninitialized, since if they put
4462 -Wuninitialized on the command line, we need to generate a
4463 warning about not using it without also specifying -O. */
4464 if (warn_uninitialized != 1)
4465 warn_uninitialized = 2;
4467 else
4468 return decode_W_option (arg + 1);
4469 break;
4471 case 'a':
4472 if (arg[1] == 0)
4474 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4475 warning ("`-a' option (basic block profile) not supported");
4476 #else
4477 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4478 #endif
4480 else if (!strcmp (arg, "ax"))
4482 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4483 warning ("`-ax' option (jump profiling) not supported");
4484 #else
4485 profile_block_flag = (!profile_block_flag
4486 || profile_block_flag == 2) ? 2 : 3;
4487 #endif
4489 else if (!strncmp (arg, "aux-info", 8))
4491 flag_gen_aux_info = 1;
4492 if (arg[8] == '\0')
4494 if (argc == 1)
4495 return 0;
4497 aux_info_file_name = argv[1];
4498 return 2;
4500 else
4501 aux_info_file_name = arg + 8;
4503 else
4504 return 0;
4505 break;
4507 case 'o':
4508 if (arg[1] == 0)
4510 if (argc == 1)
4511 return 0;
4513 asm_file_name = argv[1];
4514 return 2;
4516 return 0;
4518 case 'G':
4520 int g_switch_val;
4521 int return_val;
4523 if (arg[1] == 0)
4525 if (argc == 1)
4526 return 0;
4528 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4529 return_val = 2;
4531 else
4533 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4534 return_val = 1;
4537 if (g_switch_val == -1)
4538 return_val = 0;
4539 else
4541 g_switch_set = TRUE;
4542 g_switch_value = g_switch_val;
4545 return return_val;
4549 return 1;
4552 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4553 Exit code is 35 if can't open files, 34 if fatal error,
4554 33 if had nonfatal errors, else success. */
4556 extern int main PARAMS ((int, char **));
4559 main (argc, argv)
4560 int argc;
4561 char **argv;
4563 register int i;
4564 char *p;
4566 /* save in case md file wants to emit args as a comment. */
4567 save_argc = argc;
4568 save_argv = argv;
4570 p = argv[0] + strlen (argv[0]);
4571 while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
4572 --p;
4573 progname = p;
4575 xmalloc_set_program_name (progname);
4577 /* LC_CTYPE determines the character set used by the terminal so it has be set
4578 to output messages correctly. */
4580 #ifdef HAVE_LC_MESSAGES
4581 setlocale (LC_CTYPE, "");
4582 setlocale (LC_MESSAGES, "");
4583 #else
4584 setlocale (LC_ALL, "");
4585 #endif
4587 (void) bindtextdomain (PACKAGE, localedir);
4588 (void) textdomain (PACKAGE);
4590 /* Install handler for SIGFPE, which may be received while we do
4591 compile-time floating point arithmetic. */
4592 signal (SIGFPE, float_signal);
4594 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4595 #ifdef SIGSEGV
4596 signal (SIGSEGV, crash_signal);
4597 #endif
4598 #ifdef SIGILL
4599 signal (SIGILL, crash_signal);
4600 #endif
4601 #ifdef SIGBUS
4602 signal (SIGBUS, crash_signal);
4603 #endif
4604 #ifdef SIGABRT
4605 signal (SIGABRT, crash_signal);
4606 #endif
4607 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4608 signal (SIGIOT, crash_signal);
4609 #endif
4611 decl_printable_name = decl_name;
4612 lang_expand_expr = (lang_expand_expr_t) do_abort;
4614 /* Initialize whether `char' is signed. */
4615 flag_signed_char = DEFAULT_SIGNED_CHAR;
4616 #ifdef DEFAULT_SHORT_ENUMS
4617 /* Initialize how much space enums occupy, by default. */
4618 flag_short_enums = DEFAULT_SHORT_ENUMS;
4619 #endif
4621 /* Initialize the garbage-collector. */
4622 init_ggc ();
4623 init_stringpool ();
4624 ggc_add_rtx_root (&stack_limit_rtx, 1);
4625 ggc_add_tree_root (&current_function_decl, 1);
4626 ggc_add_tree_root (&current_function_func_begin_label, 1);
4628 /* Initialize the diagnostics reporting machinery. */
4629 initialize_diagnostics ();
4631 /* Register the language-independent parameters. */
4632 add_params (lang_independent_params, LAST_PARAM);
4634 /* Perform language-specific options intialization. */
4635 if (lang_hooks.init_options)
4636 (*lang_hooks.init_options) ();
4638 /* Scan to see what optimization level has been specified. That will
4639 determine the default value of many flags. */
4640 for (i = 1; i < argc; i++)
4642 if (!strcmp (argv[i], "-O"))
4644 optimize = 1;
4645 optimize_size = 0;
4647 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4649 /* Handle -Os, -O2, -O3, -O69, ... */
4650 char *p = &argv[i][2];
4652 if ((p[0] == 's') && (p[1] == 0))
4654 optimize_size = 1;
4656 /* Optimizing for size forces optimize to be 2. */
4657 optimize = 2;
4659 else
4661 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4662 if (optimize_val != -1)
4664 optimize = optimize_val;
4665 optimize_size = 0;
4671 if (optimize >= 1)
4673 flag_defer_pop = 1;
4674 flag_thread_jumps = 1;
4675 #ifdef DELAY_SLOTS
4676 flag_delayed_branch = 1;
4677 #endif
4678 #ifdef CAN_DEBUG_WITHOUT_FP
4679 flag_omit_frame_pointer = 1;
4680 #endif
4681 flag_guess_branch_prob = 1;
4684 if (optimize >= 2)
4686 flag_optimize_sibling_calls = 1;
4687 flag_cse_follow_jumps = 1;
4688 flag_cse_skip_blocks = 1;
4689 flag_gcse = 1;
4690 flag_expensive_optimizations = 1;
4691 flag_strength_reduce = 1;
4692 flag_rerun_cse_after_loop = 1;
4693 flag_rerun_loop_opt = 1;
4694 flag_caller_saves = 1;
4695 flag_force_mem = 1;
4696 flag_peephole2 = 1;
4697 #ifdef INSN_SCHEDULING
4698 flag_schedule_insns = 1;
4699 flag_schedule_insns_after_reload = 1;
4700 #endif
4701 flag_regmove = 1;
4702 flag_strict_aliasing = 1;
4703 flag_delete_null_pointer_checks = 1;
4704 flag_reorder_blocks = 1;
4707 if (optimize >= 3)
4709 flag_inline_functions = 1;
4710 flag_rename_registers = 1;
4713 if (optimize < 2 || optimize_size)
4715 align_loops = 1;
4716 align_jumps = 1;
4717 align_labels = 1;
4718 align_functions = 1;
4721 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4722 modify it. */
4723 target_flags = 0;
4724 set_target_switch ("");
4726 /* Unwind tables are always present in an ABI-conformant IA-64
4727 object file, so the default should be ON. */
4728 #ifdef IA64_UNWIND_INFO
4729 flag_unwind_tables = IA64_UNWIND_INFO;
4730 #endif
4732 #ifdef OPTIMIZATION_OPTIONS
4733 /* Allow default optimizations to be specified on a per-machine basis. */
4734 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4735 #endif
4737 /* Initialize register usage now so switches may override. */
4738 init_reg_sets ();
4740 /* Perform normal command line switch decoding. */
4741 for (i = 1; i < argc;)
4743 unsigned int lang_processed;
4744 unsigned int indep_processed;
4746 /* Give the language a chance to decode the option for itself. */
4747 lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
4749 /* Now see if the option also has a language independent meaning.
4750 Some options are both language specific and language independent,
4751 eg --help. */
4752 indep_processed = independent_decode_option (argc - i, argv + i);
4754 if (lang_processed || indep_processed)
4755 i += MAX (lang_processed, indep_processed);
4756 else
4758 const char *option = NULL;
4759 const char *lang = NULL;
4760 unsigned int j;
4762 /* It is possible that the command line switch is not valid for the
4763 current language, but it is valid for another language. In order
4764 to be compatible with previous versions of the compiler (which
4765 did not issue an error message in this case) we check for this
4766 possibility here. If we do find a match, then if extra_warnings
4767 is set we generate a warning message, otherwise we will just
4768 ignore the option. */
4769 for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4771 option = documented_lang_options[j].option;
4773 if (option == NULL)
4774 lang = documented_lang_options[j].description;
4775 else if (! strncmp (argv[i], option, strlen (option)))
4776 break;
4779 if (j != ARRAY_SIZE (documented_lang_options))
4781 if (extra_warnings)
4783 warning ("Ignoring command line option '%s'", argv[i]);
4784 if (lang)
4785 warning
4786 ("(It is valid for %s but not the selected language)",
4787 lang);
4790 else if (argv[i][0] == '-' && argv[i][1] == 'g')
4791 warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
4792 else
4793 error ("Unrecognized option `%s'", argv[i]);
4795 i++;
4799 /* All command line options have been processed. */
4800 if (lang_hooks.post_options)
4801 (*lang_hooks.post_options) ();
4803 if (exit_after_options)
4804 exit (0);
4806 /* Reflect any language-specific diagnostic option setting. */
4807 reshape_diagnostic_buffer ();
4809 /* Checker uses the frame pointer. */
4810 if (flag_check_memory_usage)
4811 flag_omit_frame_pointer = 0;
4813 if (optimize == 0)
4815 /* Inlining does not work if not optimizing,
4816 so force it not to be done. */
4817 flag_no_inline = 1;
4818 warn_inline = 0;
4820 /* The c_decode_option function and decode_option hook set
4821 this to `2' if -Wall is used, so we can avoid giving out
4822 lots of errors for people who don't realize what -Wall does. */
4823 if (warn_uninitialized == 1)
4824 warning ("-Wuninitialized is not supported without -O");
4827 #ifdef OVERRIDE_OPTIONS
4828 /* Some machines may reject certain combinations of options. */
4829 OVERRIDE_OPTIONS;
4830 #endif
4832 if (exceptions_via_longjmp == 2)
4834 #ifdef DWARF2_UNWIND_INFO
4835 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4836 #else
4837 #ifdef IA64_UNWIND_INFO
4838 exceptions_via_longjmp = ! IA64_UNWIND_INFO;
4839 #else
4840 exceptions_via_longjmp = 1;
4841 #endif
4842 #endif
4845 /* Since each function gets its own handler data, we can't support the
4846 new model currently, since it depend on a specific rethrow label
4847 which is declared at the front of the table, and we can only
4848 have one such symbol in a file. */
4849 #ifdef IA64_UNWIND_INFO
4850 flag_new_exceptions = 0;
4851 #endif
4853 /* Set up the align_*_log variables, defaulting them to 1 if they
4854 were still unset. */
4855 if (align_loops <= 0) align_loops = 1;
4856 align_loops_log = floor_log2 (align_loops * 2 - 1);
4857 if (align_jumps <= 0) align_jumps = 1;
4858 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4859 if (align_labels <= 0) align_labels = 1;
4860 align_labels_log = floor_log2 (align_labels * 2 - 1);
4861 if (align_functions <= 0) align_functions = 1;
4862 align_functions_log = floor_log2 (align_functions * 2 - 1);
4864 if (profile_block_flag == 3)
4866 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4867 profile_block_flag = 2;
4870 /* Unrolling all loops implies that standard loop unrolling must also
4871 be done. */
4872 if (flag_unroll_all_loops)
4873 flag_unroll_loops = 1;
4874 /* Loop unrolling requires that strength_reduction be on also. Silently
4875 turn on strength reduction here if it isn't already on. Also, the loop
4876 unrolling code assumes that cse will be run after loop, so that must
4877 be turned on also. */
4878 if (flag_unroll_loops)
4880 flag_strength_reduce = 1;
4881 flag_rerun_cse_after_loop = 1;
4884 /* Warn about options that are not supported on this machine. */
4885 #ifndef INSN_SCHEDULING
4886 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4887 warning ("instruction scheduling not supported on this target machine");
4888 #endif
4889 #ifndef DELAY_SLOTS
4890 if (flag_delayed_branch)
4891 warning ("this target machine does not have delayed branches");
4892 #endif
4894 user_label_prefix = USER_LABEL_PREFIX;
4895 if (flag_leading_underscore != -1)
4897 /* If the default prefix is more complicated than "" or "_",
4898 issue a warning and ignore this option. */
4899 if (user_label_prefix[0] == 0 ||
4900 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4902 user_label_prefix = flag_leading_underscore ? "_" : "";
4904 else
4905 warning ("-f%sleading-underscore not supported on this target machine",
4906 flag_leading_underscore ? "" : "no-");
4909 /* If we are in verbose mode, write out the version and maybe all the
4910 option flags in use. */
4911 if (version_flag)
4913 print_version (stderr, "");
4914 if (! quiet_flag)
4915 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4918 compile_file (filename);
4920 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
4921 if (flag_print_mem)
4923 char *lim = (char *) sbrk (0);
4925 fnotice (stderr, "Data size %ld.\n", (long) (lim - (char *) &environ));
4926 fflush (stderr);
4928 #ifndef __MSDOS__
4929 #ifdef USG
4930 system ("ps -l 1>&2");
4931 #else /* not USG */
4932 system ("ps v");
4933 #endif /* not USG */
4934 #endif
4936 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
4938 if (errorcount)
4939 return (FATAL_EXIT_CODE);
4940 if (sorrycount)
4941 return (FATAL_EXIT_CODE);
4942 return (SUCCESS_EXIT_CODE);
4945 /* Decode -m switches. */
4946 /* Decode the switch -mNAME. */
4948 static void
4949 set_target_switch (name)
4950 const char *name;
4952 register size_t j;
4953 int valid_target_option = 0;
4955 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4956 if (!strcmp (target_switches[j].name, name))
4958 if (target_switches[j].value < 0)
4959 target_flags &= ~-target_switches[j].value;
4960 else
4961 target_flags |= target_switches[j].value;
4962 valid_target_option = 1;
4965 #ifdef TARGET_OPTIONS
4966 if (!valid_target_option)
4967 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4969 int len = strlen (target_options[j].prefix);
4970 if (!strncmp (target_options[j].prefix, name, len))
4972 *target_options[j].variable = name + len;
4973 valid_target_option = 1;
4976 #endif
4978 if (!valid_target_option)
4979 error ("Invalid option `%s'", name);
4982 /* Print version information to FILE.
4983 Each line begins with INDENT (for the case where FILE is the
4984 assembler output file). */
4986 static void
4987 print_version (file, indent)
4988 FILE *file;
4989 const char *indent;
4991 #ifndef __VERSION__
4992 #define __VERSION__ "[?]"
4993 #endif
4994 fnotice (file,
4995 #ifdef __GNUC__
4996 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
4997 #else
4998 "%s%s%s version %s (%s) compiled by CC.\n"
4999 #endif
5000 , indent, *indent != 0 ? " " : "",
5001 language_string, version_string, TARGET_NAME,
5002 indent, __VERSION__);
5005 /* Print an option value and return the adjusted position in the line.
5006 ??? We don't handle error returns from fprintf (disk full); presumably
5007 other code will catch a disk full though. */
5009 static int
5010 print_single_switch (file, pos, max, indent, sep, term, type, name)
5011 FILE *file;
5012 int pos, max;
5013 const char *indent, *sep, *term, *type, *name;
5015 /* The ultrix fprintf returns 0 on success, so compute the result we want
5016 here since we need it for the following test. */
5017 int len = strlen (sep) + strlen (type) + strlen (name);
5019 if (pos != 0
5020 && pos + len > max)
5022 fprintf (file, "%s", term);
5023 pos = 0;
5025 if (pos == 0)
5027 fprintf (file, "%s", indent);
5028 pos = strlen (indent);
5030 fprintf (file, "%s%s%s", sep, type, name);
5031 pos += len;
5032 return pos;
5035 /* Print active target switches to FILE.
5036 POS is the current cursor position and MAX is the size of a "line".
5037 Each line begins with INDENT and ends with TERM.
5038 Each switch is separated from the next by SEP. */
5040 static void
5041 print_switch_values (file, pos, max, indent, sep, term)
5042 FILE *file;
5043 int pos, max;
5044 const char *indent, *sep, *term;
5046 size_t j;
5047 char **p;
5049 /* Print the options as passed. */
5051 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5052 _("options passed: "), "");
5054 for (p = &save_argv[1]; *p != NULL; p++)
5055 if (**p == '-')
5057 /* Ignore these. */
5058 if (strcmp (*p, "-o") == 0)
5060 if (p[1] != NULL)
5061 p++;
5062 continue;
5064 if (strcmp (*p, "-quiet") == 0)
5065 continue;
5066 if (strcmp (*p, "-version") == 0)
5067 continue;
5068 if ((*p)[1] == 'd')
5069 continue;
5071 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5073 if (pos > 0)
5074 fprintf (file, "%s", term);
5076 /* Print the -f and -m options that have been enabled.
5077 We don't handle language specific options but printing argv
5078 should suffice. */
5080 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5081 _("options enabled: "), "");
5083 for (j = 0; j < ARRAY_SIZE (f_options); j++)
5084 if (*f_options[j].variable == f_options[j].on_value)
5085 pos = print_single_switch (file, pos, max, indent, sep, term,
5086 "-f", f_options[j].string);
5088 /* Print target specific options. */
5090 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
5091 if (target_switches[j].name[0] != '\0'
5092 && target_switches[j].value > 0
5093 && ((target_switches[j].value & target_flags)
5094 == target_switches[j].value))
5096 pos = print_single_switch (file, pos, max, indent, sep, term,
5097 "-m", target_switches[j].name);
5100 #ifdef TARGET_OPTIONS
5101 for (j = 0; j < ARRAY_SIZE (target_options); j++)
5102 if (*target_options[j].variable != NULL)
5104 char prefix[256];
5105 sprintf (prefix, "-m%s", target_options[j].prefix);
5106 pos = print_single_switch (file, pos, max, indent, sep, term,
5107 prefix, *target_options[j].variable);
5109 #endif
5111 fprintf (file, "%s", term);
5114 /* Record the beginning of a new source file, named FILENAME. */
5116 void
5117 debug_start_source_file (filename)
5118 register const char *filename ATTRIBUTE_UNUSED;
5120 #ifdef DBX_DEBUGGING_INFO
5121 if (write_symbols == DBX_DEBUG)
5122 dbxout_start_new_source_file (filename);
5123 #endif
5124 #ifdef DWARF_DEBUGGING_INFO
5125 if (debug_info_level == DINFO_LEVEL_VERBOSE
5126 && write_symbols == DWARF_DEBUG)
5127 dwarfout_start_new_source_file (filename);
5128 #endif /* DWARF_DEBUGGING_INFO */
5129 #ifdef DWARF2_DEBUGGING_INFO
5130 if (write_symbols == DWARF2_DEBUG)
5131 dwarf2out_start_source_file (filename);
5132 #endif /* DWARF2_DEBUGGING_INFO */
5133 #ifdef SDB_DEBUGGING_INFO
5134 if (write_symbols == SDB_DEBUG)
5135 sdbout_start_new_source_file (filename);
5136 #endif
5139 /* Record the resumption of a source file. LINENO is the line number in
5140 the source file we are returning to. */
5142 void
5143 debug_end_source_file (lineno)
5144 register unsigned lineno ATTRIBUTE_UNUSED;
5146 #ifdef DBX_DEBUGGING_INFO
5147 if (write_symbols == DBX_DEBUG)
5148 dbxout_resume_previous_source_file ();
5149 #endif
5150 #ifdef DWARF_DEBUGGING_INFO
5151 if (debug_info_level == DINFO_LEVEL_VERBOSE
5152 && write_symbols == DWARF_DEBUG)
5153 dwarfout_resume_previous_source_file (lineno);
5154 #endif /* DWARF_DEBUGGING_INFO */
5155 #ifdef DWARF2_DEBUGGING_INFO
5156 if (write_symbols == DWARF2_DEBUG)
5157 dwarf2out_end_source_file ();
5158 #endif /* DWARF2_DEBUGGING_INFO */
5159 #ifdef SDB_DEBUGGING_INFO
5160 if (write_symbols == SDB_DEBUG)
5161 sdbout_resume_previous_source_file ();
5162 #endif
5165 /* Called from cb_define in c-lex.c. The `buffer' parameter contains
5166 the tail part of the directive line, i.e. the part which is past the
5167 initial whitespace, #, whitespace, directive-name, whitespace part. */
5169 void
5170 debug_define (lineno, buffer)
5171 register unsigned lineno ATTRIBUTE_UNUSED;
5172 register const char *buffer ATTRIBUTE_UNUSED;
5174 #ifdef DWARF_DEBUGGING_INFO
5175 if (write_symbols == DWARF_DEBUG)
5176 dwarfout_define (lineno, buffer);
5177 #endif /* DWARF_DEBUGGING_INFO */
5178 #ifdef DWARF2_DEBUGGING_INFO
5179 if (write_symbols == DWARF2_DEBUG)
5180 dwarf2out_define (lineno, buffer);
5181 #endif /* DWARF2_DEBUGGING_INFO */
5184 /* Called from cb_undef in c-lex.c. The `buffer' parameter contains
5185 the tail part of the directive line, i.e. the part which is past the
5186 initial whitespace, #, whitespace, directive-name, whitespace part. */
5188 void
5189 debug_undef (lineno, buffer)
5190 register unsigned lineno ATTRIBUTE_UNUSED;
5191 register const char *buffer ATTRIBUTE_UNUSED;
5193 #ifdef DWARF_DEBUGGING_INFO
5194 if (write_symbols == DWARF_DEBUG)
5195 dwarfout_undef (lineno, buffer);
5196 #endif /* DWARF_DEBUGGING_INFO */
5197 #ifdef DWARF2_DEBUGGING_INFO
5198 if (write_symbols == DWARF2_DEBUG)
5199 dwarf2out_undef (lineno, buffer);
5200 #endif /* DWARF2_DEBUGGING_INFO */
5203 /* Returns nonzero if it is appropriate not to emit any debugging
5204 information for BLOCK, because it doesn't contain any instructions.
5205 This may not be the case for blocks containing nested functions, since
5206 we may actually call such a function even though the BLOCK information
5207 is messed up. */
5210 debug_ignore_block (block)
5211 tree block ATTRIBUTE_UNUSED;
5213 /* Never delete the BLOCK for the outermost scope
5214 of the function; we can refer to names from
5215 that scope even if the block notes are messed up. */
5216 if (is_body_block (block))
5217 return 0;
5219 #ifdef DWARF2_DEBUGGING_INFO
5220 if (write_symbols == DWARF2_DEBUG)
5221 return dwarf2out_ignore_block (block);
5222 #endif
5224 return 1;