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)
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 /* $FreeBSD: src/contrib/gcc/toplev.c,v 1.6.2.8 2002/07/03 17:56:20 ambrisko Exp $ */
24 /* This is the top level of cc1/c++.
25 It parses command args, opens files, invokes the various passes
26 in the proper order, and counts the time used by each.
27 Error messages and low-level interface to malloc also handled here. */
30 #undef FLOAT /* This is for hpux. They should change hpux. */
31 #undef FFS /* Some systems define this in param.h. */
36 #ifdef HAVE_SYS_RESOURCE_H
37 # include <sys/resource.h>
40 #ifdef HAVE_SYS_TIMES_H
41 # include <sys/times.h>
48 #include "insn-attr.h"
49 #include "insn-codes.h"
50 #include "insn-config.h"
57 #include "basic-block.h"
60 #ifdef DWARF_DEBUGGING_INFO
64 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
65 #include "dwarf2out.h"
68 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
72 #ifdef SDB_DEBUGGING_INFO
76 #ifdef XCOFF_DEBUGGING_INFO
81 /* The extra parameters substantially improve the I/O performance. */
83 vms_fopen (fname, type)
87 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
88 fixed arguments, which matches ANSI's specification but not VAXCRTL's
89 pre-ANSI implementation. This hack circumvents the mismatch problem. */
90 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
93 return (*vmslib_fopen) (fname, type, "mbc=32",
94 "deq=64", "fop=tef", "shr=nil");
96 return (*vmslib_fopen) (fname, type, "mbc=32");
98 #define fopen vms_fopen
101 #ifndef DEFAULT_GDB_EXTENSIONS
102 #define DEFAULT_GDB_EXTENSIONS 1
105 /* If more than one debugging type is supported, you must define
106 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
108 This is one long line cause VAXC can't handle a \-newline. */
109 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
110 #ifndef PREFERRED_DEBUGGING_TYPE
111 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
112 #endif /* no PREFERRED_DEBUGGING_TYPE */
113 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
114 so the following code needn't care. */
115 #ifdef DBX_DEBUGGING_INFO
116 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
118 #ifdef SDB_DEBUGGING_INFO
119 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
121 #ifdef DWARF_DEBUGGING_INFO
122 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
124 #ifdef DWARF2_DEBUGGING_INFO
125 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
127 #ifdef XCOFF_DEBUGGING_INFO
128 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
130 #endif /* More than one debugger format enabled. */
132 /* If still not defined, must have been because no debugging formats
134 #ifndef PREFERRED_DEBUGGING_TYPE
135 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
138 #ifndef DIR_SEPARATOR
139 #define DIR_SEPARATOR '/'
142 #if ! (defined (VMS) || defined (OS2))
143 extern char **environ;
145 extern char *version_string, *language_string;
147 /* Carry information from ASM_DECLARE_OBJECT_NAME
148 to ASM_FINISH_DECLARE_OBJECT. */
150 extern int size_directive_output;
151 extern tree last_assemble_variable_decl;
153 extern char *init_parse PVPROTO((char *));
154 extern void finish_parse ();
155 extern void init_decl_processing ();
156 extern void init_obstacks ();
157 extern void init_tree_codes ();
158 extern void init_rtl ();
159 extern void init_regs ();
160 extern void init_optabs ();
161 extern void init_stmt ();
162 extern void init_reg_sets ();
163 extern void dump_flow_info ();
164 extern void dump_sched_info ();
165 extern void dump_local_alloc ();
166 extern void regset_release_memory ();
168 extern void print_rtl ();
169 extern void print_rtl_with_bb ();
171 void rest_of_decl_compilation ();
172 void error_with_file_and_line PVPROTO((const char *file,
173 int line, const char *s, ...));
174 void error_with_decl PVPROTO((tree decl, const char *s, ...));
175 void error_for_asm PVPROTO((rtx insn, const char *s, ...));
176 void notice PVPROTO((const char *s, ...));
177 void error PVPROTO((const char *s, ...));
178 void fatal PVPROTO((const char *s, ...));
179 void warning_with_file_and_line PVPROTO((const char *file,
180 int line, const char *s, ...));
181 void warning_with_decl PVPROTO((tree decl, const char *s, ...));
182 void warning PVPROTO((const char *s, ...));
183 void pedwarn PVPROTO((const char *s, ...));
184 void pedwarn_with_decl PVPROTO((tree decl, const char *s, ...));
185 void pedwarn_with_file_and_line PVPROTO((const char *file,
186 int line, const char *s, ...));
187 void sorry PVPROTO((const char *s, ...));
188 static void set_target_switch PROTO((const char *));
189 static char *decl_name PROTO((tree, int));
190 static void vmessage PROTO((const char *, const char *, va_list));
191 static void v_message_with_file_and_line PROTO((const char *, int, int,
192 const char *, va_list));
193 static void v_message_with_decl PROTO((tree, int, const char *, va_list));
194 static void file_and_line_for_asm PROTO((rtx, char **, int *));
195 static void v_error_with_file_and_line PROTO((const char *, int,
196 const char *, va_list));
197 static void v_error_with_decl PROTO((tree, const char *, va_list));
198 static void v_error_for_asm PROTO((rtx, const char *, va_list));
199 static void verror PROTO((const char *, va_list));
200 static void vfatal PROTO((const char *, va_list)) ATTRIBUTE_NORETURN;
201 static void v_warning_with_file_and_line PROTO ((const char *, int,
202 const char *, va_list));
203 static void v_warning_with_decl PROTO((tree, const char *, va_list));
204 static void v_warning_for_asm PROTO((rtx, const char *, va_list));
205 static void vwarning PROTO((const char *, va_list));
206 static void vpedwarn PROTO((const char *, va_list));
207 static void v_pedwarn_with_decl PROTO((tree, const char *, va_list));
208 static void v_pedwarn_with_file_and_line PROTO((const char *, int,
209 const char *, va_list));
210 static void vsorry PROTO((const char *, va_list));
211 static void float_signal PROTO((int)) ATTRIBUTE_NORETURN;
212 static void pipe_closed PROTO((int)) ATTRIBUTE_NORETURN;
213 #ifdef ASM_IDENTIFY_LANGUAGE
214 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
215 static void output_lang_identify PROTO((FILE *)) ATTRIBUTE_UNUSED;
217 static void open_dump_file PROTO((const char *, const char *));
218 static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
219 static void dump_rtl PROTO((const char *, tree, void (*) (FILE *, rtx), rtx));
220 static void clean_dump_file PROTO((const char *));
221 static void compile_file PROTO((char *));
222 static void display_help PROTO ((void));
224 static void print_version PROTO((FILE *, const char *));
225 static int print_single_switch PROTO((FILE *, int, int, const char *,
226 const char *, const char *,
227 const char *, const char *));
228 static void print_switch_values PROTO((FILE *, int, int, const char *,
229 const char *, const char *));
231 void print_rtl_graph_with_bb PROTO ((const char *, const char *, rtx));
232 void clean_graph_dump_file PROTO ((const char *, const char *));
233 void finish_graph_dump_file PROTO ((const char *, const char *));
234 /* Length of line when printing switch values. */
237 /* Name of program invoked, sans directories. */
241 /* Copy of arguments to main. */
245 /* Name of current original source file (what was input to cpp).
246 This comes from each #-command in the actual input. */
248 char *input_filename;
250 /* Name of top-level original source file (what was input to cpp).
251 This comes from the #-command at the beginning of the actual input.
252 If there isn't any there, then this is the cc1 input file name. */
254 char *main_input_filename;
256 /* Current line number in real source file. */
260 /* Nonzero if it is unsafe to create any new pseudo registers. */
263 /* Stack of currently pending input files. */
265 struct file_stack *input_file_stack;
267 /* Incremented on each change to input_file_stack. */
268 int input_file_stack_tick;
270 /* FUNCTION_DECL for function now being parsed or compiled. */
272 extern tree current_function_decl;
274 /* Name to use as base of names for dump output files. */
276 const char *dump_base_name;
278 /* Bit flags that specify the machine subtype we are compiling for.
279 Bits are tested using macros TARGET_... defined in the tm.h file
280 and set by `-m...' switches. Must be defined in rtlanal.c. */
282 extern int target_flags;
284 /* Flags saying which kinds of debugging dump have been requested. */
287 int rtl_dump_and_exit = 0;
288 int jump_opt_dump = 0;
289 int addressof_dump = 0;
294 int branch_prob_dump = 0;
296 int combine_dump = 0;
297 int regmove_dump = 0;
299 int local_reg_dump = 0;
300 int global_reg_dump = 0;
303 int jump2_opt_dump = 0;
305 int dbr_sched_dump = 0;
307 int flag_print_asm_name = 0;
309 int stack_reg_dump = 0;
311 #ifdef MACHINE_DEPENDENT_REORG
312 int mach_dep_reorg_dump = 0;
314 enum graph_dump_types graph_dump_format;
316 /* Name for output file of assembly code, specified with -o. */
320 /* Value of the -G xx switch, and whether it was passed or not. */
324 /* Type(s) of debugging information we are producing (if any).
325 See flags.h for the definitions of the different possible
326 types of debugging information. */
327 enum debug_info_type write_symbols = NO_DEBUG;
329 /* Level of debugging information we are producing. See flags.h
330 for the definitions of the different possible levels. */
331 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
333 /* Nonzero means use GNU-only extensions in the generated symbolic
334 debugging information. */
335 /* Currently, this only has an effect when write_symbols is set to
336 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
337 int use_gnu_debug_info_extensions = 0;
339 /* Nonzero means do optimizations. -O.
340 Particular numeric values stand for particular amounts of optimization;
341 thus, -O2 stores 2 here. However, the optimizations beyond the basic
342 ones are not controlled directly by this variable. Instead, they are
343 controlled by individual `flag_...' variables that are defaulted
344 based on this variable. */
348 /* Nonzero means optimize for size. -Os.
349 The only valid values are zero and non-zero. When optimize_size is
350 non-zero, optimize defaults to 2, but certain individual code
351 bloating optimizations are disabled. */
353 int optimize_size = 0;
355 /* Number of error messages and warning messages so far. */
358 int warningcount = 0;
361 /* Pointer to function to compute the name to use to print a declaration.
362 DECL is the declaration in question.
363 VERBOSITY determines what information will be printed:
364 0: DECL_NAME, demangled as necessary.
365 1: and scope information.
366 2: and any other information that might be interesting, such as function
367 parameter types in C++. */
369 char *(*decl_printable_name) PROTO ((tree, int));
371 /* Pointer to function to compute rtl for a language-specific tree code. */
373 typedef rtx (*lang_expand_expr_t)
374 PROTO ((union tree_node *, rtx, enum machine_mode,
375 enum expand_modifier modifier));
377 lang_expand_expr_t lang_expand_expr = 0;
379 tree (*lang_expand_constant) PROTO((tree)) = 0;
381 /* Pointer to function to finish handling an incomplete decl at the
382 end of compilation. */
384 void (*incomplete_decl_finalize_hook) PROTO((tree)) = 0;
386 /* Nonzero if generating code to do profiling. */
388 int profile_flag = 0;
390 /* Nonzero if generating code to do profiling on a line-by-line basis. */
392 int profile_block_flag;
394 /* Nonzero if generating code to profile program flow graph arcs. */
396 int profile_arc_flag = 0;
398 /* Nonzero if generating info for gcov to calculate line test coverage. */
400 int flag_test_coverage = 0;
402 /* Nonzero indicates that branch taken probabilities should be calculated. */
404 int flag_branch_probabilities = 0;
406 /* Nonzero for -pedantic switch: warn about anything
407 that standard spec forbids. */
411 /* Temporarily suppress certain warnings.
412 This is set while reading code from a system header file. */
414 int in_system_header = 0;
416 /* Nonzero means do stupid register allocation.
417 Currently, this is 1 if `optimize' is 0. */
419 int obey_regdecls = 0;
421 /* Don't print functions as they are compiled and don't print
422 times taken by the various passes. -quiet. */
428 /* Nonzero means `char' should be signed. */
430 int flag_signed_char;
432 /* Nonzero means give an enum type only as many bytes as it needs. */
434 int flag_short_enums;
436 /* Nonzero for -fcaller-saves: allocate values in regs that need to
437 be saved across function calls, if that produces overall better code.
438 Optional now, so people can test it. */
440 #ifdef DEFAULT_CALLER_SAVES
441 int flag_caller_saves = 1;
443 int flag_caller_saves = 0;
446 /* Nonzero if structures and unions should be returned in memory.
448 This should only be defined if compatibility with another compiler or
449 with an ABI is needed, because it results in slower code. */
451 #ifndef DEFAULT_PCC_STRUCT_RETURN
452 #define DEFAULT_PCC_STRUCT_RETURN 1
455 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
457 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
459 /* Nonzero for -fforce-mem: load memory value into a register
460 before arithmetic on it. This makes better cse but slower compilation. */
462 int flag_force_mem = 0;
464 /* Nonzero for -fforce-addr: load memory address into a register before
465 reference to memory. This makes better cse but slower compilation. */
467 int flag_force_addr = 0;
469 /* Nonzero for -fdefer-pop: don't pop args after each function call;
470 instead save them up to pop many calls' args with one insns. */
472 int flag_defer_pop = 0;
474 /* Nonzero for -ffloat-store: don't allocate floats and doubles
475 in extended-precision registers. */
477 int flag_float_store = 0;
479 /* Nonzero for -fcse-follow-jumps:
480 have cse follow jumps to do a more extensive job. */
482 int flag_cse_follow_jumps;
484 /* Nonzero for -fcse-skip-blocks:
485 have cse follow a branch around a block. */
486 int flag_cse_skip_blocks;
488 /* Nonzero for -fexpensive-optimizations:
489 perform miscellaneous relatively-expensive optimizations. */
490 int flag_expensive_optimizations;
492 /* Nonzero for -fthread-jumps:
493 have jump optimize output of loop. */
495 int flag_thread_jumps;
497 /* Nonzero enables strength-reduction in loop.c. */
499 int flag_strength_reduce = 0;
501 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
502 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
503 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
506 int flag_unroll_loops;
508 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
509 This is generally not a win. */
511 int flag_unroll_all_loops;
513 /* Nonzero forces all invariant computations in loops to be moved
516 int flag_move_all_movables = 0;
518 /* Nonzero forces all general induction variables in loops to be
521 int flag_reduce_all_givs = 0;
523 /* Nonzero to perform full register move optimization passes. This is the
526 int flag_regmove = 0;
528 /* Nonzero for -fwritable-strings:
529 store string constants in data segment and don't uniquize them. */
531 int flag_writable_strings = 0;
533 /* Nonzero means don't put addresses of constant functions in registers.
534 Used for compiling the Unix kernel, where strange substitutions are
535 done on the assembly output. */
537 int flag_no_function_cse = 0;
539 /* Nonzero for -fomit-frame-pointer:
540 don't make a frame pointer in simple functions that don't require one. */
542 int flag_omit_frame_pointer = 0;
544 /* Nonzero means place each function into its own section on those platforms
545 which support arbitrary section names and unlimited numbers of sections. */
547 int flag_function_sections = 0;
549 /* ... and similar for data. */
551 int flag_data_sections = 0;
553 /* Nonzero to inhibit use of define_optimization peephole opts. */
555 int flag_no_peephole = 0;
557 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
558 operations in the interest of optimization. For example it allows
559 GCC to assume arguments to sqrt are nonnegative numbers, allowing
560 faster code for sqrt to be generated. */
562 int flag_fast_math = 0;
564 /* Nonzero means the front end generally wants `errno' maintained by math
565 operations, like built-in SQRT, unless overridden by flag_fast_math. */
567 int flag_errno_math = 1;
569 /* 0 means straightforward implementation of complex divide acceptable.
570 1 means wide ranges of inputs must work for complex divide.
571 2 means C9X-like requirements for complex divide (not yet implemented). */
573 int flag_complex_divide_method = 0;
575 /* Nonzero means all references through pointers are volatile. */
579 /* Nonzero means treat all global and extern variables as volatile. */
581 int flag_volatile_global;
583 /* Nonzero means treat all static variables as volatile. */
585 int flag_volatile_static;
587 /* Nonzero means just do syntax checking; don't output anything. */
589 int flag_syntax_only = 0;
591 /* Nonzero means perform global cse. */
593 static int flag_gcse;
595 /* Nonzero means to rerun cse after loop optimization. This increases
596 compilation time about 20% and picks up a few more common expressions. */
598 static int flag_rerun_cse_after_loop;
600 /* Nonzero means to run loop optimizations twice. */
602 int flag_rerun_loop_opt;
604 /* Nonzero for -finline-functions: ok to inline functions that look like
605 good inline candidates. */
607 int flag_inline_functions;
609 /* Nonzero for -fkeep-inline-functions: even if we make a function
610 go inline everywhere, keep its definition around for debugging
613 int flag_keep_inline_functions;
615 /* Nonzero means that functions will not be inlined. */
619 /* Nonzero means that we should emit static const variables
620 regardless of whether or not optimization is turned on. */
622 int flag_keep_static_consts = 1;
624 /* Nonzero means we should be saving declaration info into a .X file. */
626 int flag_gen_aux_info = 0;
628 /* Specified name of aux-info file. */
630 static char *aux_info_file_name;
632 /* Nonzero means make the text shared if supported. */
634 int flag_shared_data;
636 /* Nonzero means schedule into delayed branch slots if supported. */
638 int flag_delayed_branch;
640 /* Nonzero if we are compiling pure (sharable) code.
641 Value is 1 if we are doing reasonable (i.e. simple
642 offset into offset table) pic. Value is 2 if we can
643 only perform register offsets. */
647 /* Nonzero means generate extra code for exception handling and enable
648 exception handling. */
652 /* Nonzero means use the new model for exception handling. Replaces
653 -DNEW_EH_MODEL as a compile option. */
655 int flag_new_exceptions = 0;
657 /* Nonzero means don't place uninitialized global data in common storage
662 /* Nonzero means pretend it is OK to examine bits of target floats,
663 even if that isn't true. The resulting code will have incorrect constants,
664 but the same series of instructions that the native compiler would make. */
666 int flag_pretend_float;
668 /* Nonzero means change certain warnings into errors.
669 Usually these are warnings about failure to conform to some standard. */
671 int flag_pedantic_errors = 0;
673 /* flag_schedule_insns means schedule insns within basic blocks (before
675 flag_schedule_insns_after_reload means schedule insns after
678 int flag_schedule_insns = 0;
679 int flag_schedule_insns_after_reload = 0;
682 /* The following flags have effect only for scheduling before register
685 flag_schedule_interblock means schedule insns accross basic blocks.
686 flag_schedule_speculative means allow speculative motion of non-load insns.
687 flag_schedule_speculative_load means allow speculative motion of some
689 flag_schedule_speculative_load_dangerous allows speculative motion of more
692 int flag_schedule_interblock = 1;
693 int flag_schedule_speculative = 1;
694 int flag_schedule_speculative_load = 0;
695 int flag_schedule_speculative_load_dangerous = 0;
698 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
699 by a cheaper branch, on a count register. */
700 int flag_branch_on_count_reg;
702 /* -finhibit-size-directive inhibits output of .size for ELF.
703 This is used only for compiling crtstuff.c,
704 and it may be extended to other effects
705 needed for crtstuff.c on other systems. */
706 int flag_inhibit_size_directive = 0;
708 /* -fverbose-asm causes extra commentary information to be produced in
709 the generated assembly code (to make it more readable). This option
710 is generally only of use to those who actually need to read the
711 generated assembly code (perhaps while debugging the compiler itself).
712 -fno-verbose-asm, the default, causes the extra information
713 to be omitted and is useful when comparing two assembler files. */
715 int flag_verbose_asm = 0;
717 /* -dA causes debug commentary information to be produced in
718 the generated assembly code (to make it more readable). This option
719 is generally only of use to those who actually need to read the
720 generated assembly code (perhaps while debugging the compiler itself).
721 Currently, this switch is only used by dwarfout.c; however, it is intended
722 to be a catchall for printing debug information in the assembler file. */
724 int flag_debug_asm = 0;
726 /* -fgnu-linker specifies use of the GNU linker for initializations.
727 (Or, more generally, a linker that handles initializations.)
728 -fno-gnu-linker says that collect2 will be used. */
730 int flag_gnu_linker = 0;
732 int flag_gnu_linker = 1;
735 /* Tag all structures with __attribute__(packed) */
736 int flag_pack_struct = 0;
738 /* Nonzero means that -Wformat accepts certain system-dependent formats. */
739 int flag_format_extensions = 0;
741 /* Emit code to check for stack overflow; also may cause large objects
742 to be allocated dynamically. */
743 int flag_stack_check;
745 /* -fcheck-memory-usage causes extra code to be generated in order to check
746 memory accesses. This is used by a detector of bad memory accesses such
748 int flag_check_memory_usage = 0;
750 /* -fprefix-function-name causes function name to be prefixed. This
751 can be used with -fcheck-memory-usage to isolate code compiled with
752 -fcheck-memory-usage. */
753 int flag_prefix_function_name = 0;
755 /* 0 if pointer arguments may alias each other. True in C.
756 1 if pointer arguments may not alias each other but may alias
758 2 if pointer arguments may not alias each other and may not
759 alias global variables. True in Fortran.
760 This defaults to 0 for C. */
761 int flag_argument_noalias = 0;
763 /* Nonzero if we should do (language-dependent) alias analysis.
764 Typically, this analysis will assume that expressions of certain
765 types do not alias expressions of certain other types. Only used
766 if alias analysis (in general) is enabled. */
767 int flag_strict_aliasing = 0;
769 /* Instrument functions with calls at entry and exit, for profiling. */
770 int flag_instrument_function_entry_exit = 0;
772 /* Nonzero means ignore `#ident' directives. 0 means handle them.
773 On SVR4 targets, it also controls whether or not to emit a
774 string identifying the compiler. */
776 int flag_no_ident = 0;
778 /* Table of supported debugging formats. */
782 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
783 constant expression, we use NO_DEBUG in its place. */
784 enum debug_info_type debug_type;
785 int use_extensions_p;
786 const char * description;
790 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
791 "Generate default debug format output" },
792 { "ggdb", NO_DEBUG, 1, "Generate default extended debug format output" },
793 #ifdef DBX_DEBUGGING_INFO
794 { "gstabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
795 { "gstabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
797 #ifdef DWARF_DEBUGGING_INFO
798 { "gdwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
799 { "gdwarf+", DWARF_DEBUG, 1,
800 "Generated extended DWARF-1 format debug output" },
802 #ifdef DWARF2_DEBUGGING_INFO
803 { "gdwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
805 #ifdef XCOFF_DEBUGGING_INFO
806 { "gxcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
807 { "gxcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
809 #ifdef SDB_DEBUGGING_INFO
810 { "gcoff", SDB_DEBUG, 0, "Generate COFF format debug output" },
820 const char * description;
822 lang_independent_options;
824 /* Add or remove a leading underscore from user symbols. */
825 int flag_leading_underscore = -1;
827 /* The user symbol prefix after having resolved same. */
828 const char *user_label_prefix;
830 /* A default for same. */
831 #ifndef USER_LABEL_PREFIX
832 #define USER_LABEL_PREFIX ""
835 /* Table of language-independent -f options.
836 STRING is the option name. VARIABLE is the address of the variable.
837 ON_VALUE is the value to store in VARIABLE
838 if `-fSTRING' is seen as an option.
839 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
841 lang_independent_options f_options[] =
843 {"float-store", &flag_float_store, 1,
844 "Do not store floats in registers" },
845 {"volatile", &flag_volatile, 1,
846 "Consider all mem refs through pointers as volatile"},
847 {"volatile-global", &flag_volatile_global, 1,
848 "Consider all mem refs to global data to be volatile" },
849 {"volatile-static", &flag_volatile_static, 1,
850 "Consider all mem refs to static data to be volatile" },
851 {"defer-pop", &flag_defer_pop, 1,
852 "Defer popping functions args from stack until later" },
853 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
854 "When possible do not generate stack frames"},
855 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
856 "When running CSE, follow jumps to their targets" },
857 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
858 "When running CSE, follow conditional jumps" },
859 {"expensive-optimizations", &flag_expensive_optimizations, 1,
860 "Perform a number of minor, expensive optimisations" },
861 {"thread-jumps", &flag_thread_jumps, 1,
862 "Perform jump threading optimisations"},
863 {"strength-reduce", &flag_strength_reduce, 1,
864 "Perform strength reduction optimisations" },
865 {"unroll-loops", &flag_unroll_loops, 1,
866 "Perform loop unrolling when iteration count is known" },
867 {"unroll-all-loops", &flag_unroll_all_loops, 1,
868 "Perform loop unrolling for all loops" },
869 {"move-all-movables", &flag_move_all_movables, 1,
870 "Force all loop invariant computations out of loops" },
871 {"reduce-all-givs", &flag_reduce_all_givs, 1,
872 "Strength reduce all loop general induction variables" },
873 {"writable-strings", &flag_writable_strings, 1,
874 "Store strings in writable data section" },
875 {"peephole", &flag_no_peephole, 0,
876 "Enable machine specific peephole optimisations" },
877 {"force-mem", &flag_force_mem, 1,
878 "Copy memory operands into registers before using" },
879 {"force-addr", &flag_force_addr, 1,
880 "Copy memory address constants into regs before using" },
881 {"function-cse", &flag_no_function_cse, 0,
882 "Allow function addresses to be held in registers" },
883 {"inline-functions", &flag_inline_functions, 1,
884 "Integrate simple functions into their callers" },
885 {"keep-inline-functions", &flag_keep_inline_functions, 1,
886 "Generate code for funcs even if they are fully inlined" },
887 {"inline", &flag_no_inline, 0,
888 "Pay attention to the 'inline' keyword"},
889 {"keep-static-consts", &flag_keep_static_consts, 1,
890 "Emit static const variables even if they are not used" },
891 {"syntax-only", &flag_syntax_only, 1,
892 "Check for syntax errors, then stop" },
893 {"shared-data", &flag_shared_data, 1,
894 "Mark data as shared rather than private" },
895 {"caller-saves", &flag_caller_saves, 1,
896 "Enable saving registers around function calls" },
897 {"pcc-struct-return", &flag_pcc_struct_return, 1,
898 "Return 'short' aggregates in memory, not registers" },
899 {"reg-struct-return", &flag_pcc_struct_return, 0,
900 "Return 'short' aggregates in registers" },
901 {"delayed-branch", &flag_delayed_branch, 1,
902 "Attempt to fill delay slots of branch instructions" },
903 {"gcse", &flag_gcse, 1,
904 "Perform the global common subexpression elimination" },
905 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
906 "Run CSE pass after loop optimisations"},
907 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
908 "Run the loop optimiser twice"},
909 {"pretend-float", &flag_pretend_float, 1,
910 "Pretend that host and target use the same FP format"},
911 {"schedule-insns", &flag_schedule_insns, 1,
912 "Reschedule instructions to avoid pipeline stalls"},
913 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
914 "Run two passes of the instruction scheduler"},
916 {"sched-interblock",&flag_schedule_interblock, 1,
917 "Enable scheduling across basic blocks" },
918 {"sched-spec",&flag_schedule_speculative, 1,
919 "Allow speculative motion of non-loads" },
920 {"sched-spec-load",&flag_schedule_speculative_load, 1,
921 "Allow speculative motion of some loads" },
922 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
923 "Allow speculative motion of more loads" },
925 {"branch-count-reg",&flag_branch_on_count_reg, 1,
926 "Replace add,compare,branch with branch on count reg"},
927 {"pic", &flag_pic, 1,
928 "Generate position independent code, if possible"},
929 {"PIC", &flag_pic, 2, ""},
930 {"exceptions", &flag_exceptions, 1,
931 "Enable exception handling" },
932 {"new-exceptions", &flag_new_exceptions, 1,
933 "Use the new model for exception handling" },
934 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
935 "Use setjmp/longjmp to handle exceptions" },
936 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
937 "Support asynchronous exceptions" },
938 {"profile-arcs", &profile_arc_flag, 1,
939 "Insert arc based program profiling code" },
940 {"test-coverage", &flag_test_coverage, 1,
941 "Create data files needed by gcov" },
942 {"branch-probabilities", &flag_branch_probabilities, 1,
943 "Use profiling information for branch probabilities" },
944 {"fast-math", &flag_fast_math, 1,
945 "Improve FP speed by violating ANSI & IEEE rules" },
946 {"common", &flag_no_common, 0,
947 "Do not put unitialised globals in the common section" },
948 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
949 "Do not generate .size directives" },
950 {"function-sections", &flag_function_sections, 1,
951 "place each function into its own section" },
952 {"data-sections", &flag_data_sections, 1,
953 "place data items into their own section" },
954 {"verbose-asm", &flag_verbose_asm, 1,
955 "Add extra commentry to assembler output"},
956 {"gnu-linker", &flag_gnu_linker, 1,
957 "Output GNU ld formatted global initialisers"},
958 {"regmove", &flag_regmove, 1,
959 "Enables a register move optimisation"},
960 {"optimize-register-move", &flag_regmove, 1,
961 "Do the full regmove optimization pass"},
962 {"pack-struct", &flag_pack_struct, 1,
963 "Pack structure members together without holes" },
964 {"format-extensions", &flag_format_extensions, 1,
965 "-Wformat accepts certain FreeBSD system-dependent formats" },
966 {"stack-check", &flag_stack_check, 1,
967 "Insert stack checking code into the program" },
968 {"argument-alias", &flag_argument_noalias, 0,
969 "Specify that arguments may alias each other & globals"},
970 {"argument-noalias", &flag_argument_noalias, 1,
971 "Assume arguments may alias globals but not each other"},
972 {"argument-noalias-global", &flag_argument_noalias, 2,
973 "Assume arguments do not alias each other or globals" },
974 {"strict-aliasing", &flag_strict_aliasing, 1,
975 "Assume strict aliasing rules apply" },
976 {"check-memory-usage", &flag_check_memory_usage, 1,
977 "Generate code to check every memory access" },
978 {"prefix-function-name", &flag_prefix_function_name, 1,
979 "Add a prefix to all function names" },
980 {"dump-unnumbered", &flag_dump_unnumbered, 1,
981 "Suppress output of instruction numbers and line number notes in debugging dumps"},
982 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
983 "Instrument function entry/exit with profiling calls"},
984 {"leading-underscore", &flag_leading_underscore, 1,
985 "External symbols have a leading underscore" },
986 {"ident", &flag_no_ident, 0,
987 "Process #ident directives"}
990 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
992 /* Table of language-specific options. */
994 static struct lang_opt
997 const char * description;
999 documented_lang_options[] =
1001 /* In order not to overload the --help output, the convention
1002 used here is to only describe those options which are not
1003 enabled by default. */
1005 { "-ansi", "Compile just for ANSI C" },
1006 { "-fallow-single-precision",
1007 "Do not promote floats to double if using -traditional" },
1008 { "-std= ", "Determine language standard"},
1010 { "-fsigned-bitfields", "" },
1011 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1012 { "-fno-signed-bitfields", "" },
1013 { "-fno-unsigned-bitfields","" },
1014 { "-fsigned-char", "Make 'char' be signed by default"},
1015 { "-funsigned-char", "Make 'char' be unsigned by default"},
1016 { "-fno-signed-char", "" },
1017 { "-fno-unsigned-char", "" },
1019 { "-ftraditional", "" },
1020 { "-traditional", "Attempt to support traditional K&R style C"},
1021 { "-fnotraditional", "" },
1022 { "-fno-traditional", "" },
1025 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1026 { "-fbuiltin", "" },
1027 { "-fno-builtin", "Do not recognise any built in functions" },
1028 { "-fhosted", "Assume normal C execution environment" },
1029 { "-fno-hosted", "" },
1031 "Assume that standard libraries & main might not exist" },
1032 { "-fno-freestanding", "" },
1033 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1034 { "-fno-cond-mismatch", "" },
1035 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1036 { "-fno-dollars-in-identifiers", "" },
1037 { "-fshort-double", "Use the same size for double as for float" },
1038 { "-fno-short-double", "" },
1039 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1040 { "-fno-short-enums", "" },
1042 { "-Wall", "Enable most warning messages" },
1043 { "-Wbad-function-cast",
1044 "Warn about casting functions to incompatible types" },
1045 { "-Wno-bad-function-cast", "" },
1046 { "-Wmissing-noreturn",
1047 "Warn about functions which might be candidates for attribute noreturn" },
1048 { "-Wno-missing-noreturn", "" },
1049 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1050 { "-Wno-cast-qual", "" },
1051 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1052 { "-Wno-char-subscripts", "" },
1053 { "-Wcomment", "Warn if nested comments are detected" },
1054 { "-Wno-comment", "" },
1055 { "-Wcomments", "Warn if nested comments are detected" },
1056 { "-Wno-comments", "" },
1057 { "-Wconversion", "Warn about possibly confusing type conversions" },
1058 { "-Wno-conversion", "" },
1059 { "-Wformat", "Warn about printf format anomalies" },
1060 { "-Wnon-const-format", "Warn about printf-like format strings" },
1061 { "-Wno-format", "" },
1062 { "-Wno-format-extra-args", "" },
1063 { "-Wimplicit-function-declaration",
1064 "Warn about implicit function declarations" },
1065 { "-Wno-implicit-function-declaration", "" },
1066 { "-Werror-implicit-function-declaration", "" },
1067 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1068 { "-Wno-implicit-int", "" },
1069 { "-Wimplicit", "" },
1070 { "-Wno-implicit", "" },
1071 { "-Wimport", "Warn about the use of the #import directive" },
1072 { "-Wno-import", "" },
1073 { "-Wlong-long","" },
1074 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1075 { "-Wmain", "Warn about suspicious declarations of main" },
1076 { "-Wframe-size-<N>",
1077 "Warn if frame uses greater than <N> bytes." },
1078 { "-Warglist-size-<N>",
1079 "Warn if function argument list uses greater than <N> bytes." },
1080 { "-Wno-main", "" },
1081 { "-Wmissing-braces",
1082 "Warn about possibly missing braces around initialisers" },
1083 { "-Wno-missing-braces", "" },
1084 { "-Wmissing-declarations",
1085 "Warn about global funcs without previous declarations"},
1086 { "-Wno-missing-declarations", "" },
1087 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1088 { "-Wno-missing-prototypes", "" },
1089 { "-Wmultichar", "Warn about use of multicharacter literals"},
1090 { "-Wno-multichar", "" },
1091 { "-Wnested-externs", "Warn about externs not at file scope level" },
1092 { "-Wno-nested-externs", "" },
1093 { "-Wparentheses", "Warn about possible missing parentheses" },
1094 { "-Wno-parentheses", "" },
1095 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1096 { "-Wno-pointer-arith", "" },
1097 { "-Wredundant-decls",
1098 "Warn about multiple declarations of the same object" },
1099 { "-Wno-redundant-decls", "" },
1100 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1101 { "-Wno-sign-compare", "" },
1102 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1103 { "-Wno-unknown-pragmas", "" },
1104 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1105 { "-Wno-strict-prototypes", "" },
1106 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1107 { "-Wno-traditional", "" },
1108 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1109 { "-Wno-trigraphs", "" },
1111 { "-Wno-undef", "" },
1112 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1113 { "-Wno-write-strings", "" },
1115 /* These are for languages with USE_CPPLIB. */
1116 /* These options are already documented in cpplib.c */
1122 { "-MD", "Print dependencies to FILE.d" },
1123 { "-MMD", "Print dependencies to FILE.d" },
1124 { "-M", "Print dependencies to stdout" },
1125 { "-MM", "Print dependencies to stdout" },
1126 #endif /* USE_CPPLIB */
1129 { "-idirafter", "" },
1134 { "-iwithprefix", "" },
1135 { "-iwithprefixbefore", "" },
1137 { "-lang-c89", "" },
1138 { "-lang-c++", "" },
1140 { "-nostdinc", "" },
1141 { "-nostdinc++", "" },
1142 { "-trigraphs", "" },
1145 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1147 /* These are for obj c. */
1148 DEFINE_LANG_NAME ("Objective C")
1150 { "-lang-objc", "" },
1151 { "-gen-decls", "Dump decls to a .decl file" },
1152 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1153 { "-fno-gnu-runtime", "" },
1154 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1155 { "-fno-next-runtime", "" },
1156 { "-Wselector", "Warn if a selector has multiple methods" },
1157 { "-Wno-selector", "" },
1158 { "-Wprotocol", "" },
1159 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1160 { "-print-objc-runtime-info",
1161 "Generate C header of platform specific features" },
1163 #include "options.h"
1167 /* Here is a table, controlled by the tm.h file, listing each -m switch
1168 and which bits in `target_switches' it should set or clear.
1169 If VALUE is positive, it is bits to set.
1170 If VALUE is negative, -VALUE is bits to clear.
1171 (The sign bit is not used so there is no confusion.) */
1177 const char * description;
1179 target_switches [] = TARGET_SWITCHES;
1181 /* This table is similar, but allows the switch to have a value. */
1183 #ifdef TARGET_OPTIONS
1186 const char * prefix;
1187 const char ** variable;
1188 const char * description;
1190 target_options [] = TARGET_OPTIONS;
1193 /* Options controlling warnings */
1195 /* Don't print warning messages. -w. */
1197 int inhibit_warnings = 0;
1199 /* Print various extra warnings. -W. */
1201 int extra_warnings = 0;
1203 /* Treat warnings as errors. -Werror. */
1205 int warnings_are_errors = 0;
1207 /* Nonzero to warn about unused local variables. */
1211 /* Nonzero to warn about variables used before they are initialized. */
1213 int warn_uninitialized;
1215 /* Nonzero means warn about all declarations which shadow others. */
1219 /* Warn if a switch on an enum fails to have a case for every enum value. */
1223 /* Nonzero means warn about function definitions that default the return type
1224 or that use a null return and have a return-type other than void. */
1226 int warn_return_type;
1228 /* Nonzero means warn about pointer casts that increase the required
1229 alignment of the target type (and might therefore lead to a crash
1230 due to a misaligned access). */
1232 int warn_cast_align;
1234 /* Nonzero means warn if a frame is larger that N bytes. The value
1235 of N is warn_frame_size. */
1237 int warn_frame_size_flag = 0;
1238 int warn_frame_size;
1240 /* Nonzero means warn if a function call pushes more than N bytes
1241 onto the stack. The value of N is warn_arglist_size. */
1243 int warn_arglist_size_flag = 0;
1244 int warn_arglist_size;
1246 /* Nonzero means warn about any identifiers that match in the first N
1247 characters. The value N is in `id_clash_len'. */
1250 unsigned id_clash_len;
1252 /* Nonzero means warn about any objects definitions whose size is larger
1253 than N bytes. Also want about function definitions whose returned
1254 values are larger than N bytes. The value N is in `larger_than_size'. */
1256 int warn_larger_than;
1257 unsigned larger_than_size;
1259 /* Nonzero means warn if inline function is too large. */
1263 /* Warn if a function returns an aggregate,
1264 since there are often incompatible calling conventions for doing this. */
1266 int warn_aggregate_return;
1268 /* Likewise for -W. */
1270 lang_independent_options W_options[] =
1272 {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1273 {"error", &warnings_are_errors, 1, ""},
1274 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1275 {"switch", &warn_switch, 1,
1276 "Warn about enumerated switches missing a specific case" },
1277 {"aggregate-return", &warn_aggregate_return, 1,
1278 "Warn about returning structures, unions or arrays" },
1279 {"cast-align", &warn_cast_align, 1,
1280 "Warn about pointer casts which increase alignment" },
1281 {"uninitialized", &warn_uninitialized, 1,
1282 "Warn about unitialized automatic variables"},
1283 {"inline", &warn_inline, 1,
1284 "Warn when an inlined function cannot be inlined"}
1287 /* Output files for assembler code (real compiler output)
1288 and debugging dumps. */
1291 FILE *aux_info_file;
1292 FILE *rtl_dump_file = NULL;
1294 /* Decode the string P as an integral parameter.
1295 If the string is indeed an integer return its numeric value else
1296 issue an Invalid Option error for the option PNAME and return DEFVAL.
1297 If PNAME is zero just return DEFVAL, do not call error. */
1300 read_integral_parameter (p, pname, defval)
1305 const char *endp = p;
1309 if (*endp >= '0' && *endp <= '9')
1318 error ("Invalid option `%s'", pname);
1326 /* Time accumulators, to count the total time spent in various passes. */
1330 int integration_time;
1336 int branch_prob_time;
1341 int local_alloc_time;
1342 int global_alloc_time;
1348 int shorten_branch_time;
1354 /* Return time used so far, in microseconds. */
1364 #else /* not BeOS */
1365 #if defined (_WIN32) && !defined (__CYGWIN__)
1369 return (clock() * 1000);
1370 #else /* not _WIN32 */
1376 tick = 1000000 / sysconf(_SC_CLK_TCK);
1378 return (tms.tms_utime + tms.tms_stime) * tick;
1384 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1385 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1388 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1390 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1394 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1399 struct rusage rusage;
1400 getrusage (0, &rusage);
1401 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1402 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1409 int proc_system_time;
1410 int child_user_time;
1411 int child_system_time;
1413 times ((void *) &vms_times);
1414 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1418 #endif /* _SC_CLK_TCK */
1420 #endif /* __BEOS__ */
1423 #define TIMEVAR(VAR, BODY) \
1424 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1427 print_time (str, total)
1432 "time in %s: %d.%06d\n",
1433 str, total / 1000000, total % 1000000);
1436 /* Count an error or warning. Return 1 if the message should be printed. */
1439 count_error (warningp)
1442 if (warningp && inhibit_warnings)
1445 if (warningp && !warnings_are_errors)
1449 static int warning_message = 0;
1451 if (warningp && !warning_message)
1453 notice ("%s: warnings being treated as errors\n", progname);
1454 warning_message = 1;
1462 /* Print a fatal error message. NAME is the text.
1463 Also include a system error message based on `errno'. */
1466 pfatal_with_name (name)
1469 fprintf (stderr, "%s: ", progname);
1471 exit (FATAL_EXIT_CODE);
1475 fatal_io_error (name)
1478 notice ("%s: %s: I/O error\n", progname, name);
1479 exit (FATAL_EXIT_CODE);
1482 /* Called to give a better error message for a bad insn rather than
1483 just calling abort(). */
1486 fatal_insn VPROTO((const char *msgid, rtx insn, ...))
1488 #ifndef ANSI_PROTOTYPES
1494 VA_START (ap, insn);
1496 #ifndef ANSI_PROTOTYPES
1497 msgid = va_arg (ap, const char *);
1498 insn = va_arg (ap, rtx);
1503 exit (FATAL_EXIT_CODE);
1506 /* Called to give a better error message when we don't have an insn to match
1507 what we are looking for or if the insn's constraints aren't satisfied,
1508 rather than just calling abort(). */
1511 fatal_insn_not_found (insn)
1514 if (INSN_CODE (insn) < 0)
1515 fatal_insn ("internal error--unrecognizable insn:", insn);
1517 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1520 /* This is the default decl_printable_name function. */
1523 decl_name (decl, verbosity)
1525 int verbosity ATTRIBUTE_UNUSED;
1527 return IDENTIFIER_POINTER (DECL_NAME (decl));
1530 static int need_error_newline;
1532 /* Function of last error message;
1533 more generally, function such that if next error message is in it
1534 then we don't have to mention the function name. */
1535 static tree last_error_function = NULL;
1537 /* Used to detect when input_file_stack has changed since last described. */
1538 static int last_error_tick;
1540 /* Called when the start of a function definition is parsed,
1541 this function prints on stderr the name of the function. */
1544 announce_function (decl)
1549 if (rtl_dump_and_exit)
1550 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1552 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1554 need_error_newline = 1;
1555 last_error_function = current_function_decl;
1559 /* The default function to print out name of current function that caused
1563 default_print_error_function (file)
1566 if (last_error_function != current_function_decl)
1569 fprintf (stderr, "%s: ", file);
1571 if (current_function_decl == NULL)
1572 notice ("At top level:\n");
1574 notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE
1575 ? "In method `%s':\n"
1576 : "In function `%s':\n"),
1577 (*decl_printable_name) (current_function_decl, 2));
1579 last_error_function = current_function_decl;
1583 /* Called by report_error_function to print out function name.
1584 * Default may be overridden by language front-ends. */
1586 void (*print_error_function) PROTO((const char *)) =
1587 default_print_error_function;
1589 /* Prints out, if necessary, the name of the current function
1590 that caused an error. Called from all error and warning functions.
1591 We ignore the FILE parameter, as it cannot be relied upon. */
1594 report_error_function (file)
1595 const char *file ATTRIBUTE_UNUSED;
1597 struct file_stack *p;
1599 if (need_error_newline)
1601 fprintf (stderr, "\n");
1602 need_error_newline = 0;
1605 if (input_file_stack && input_file_stack->next != 0
1606 && input_file_stack_tick != last_error_tick)
1608 for (p = input_file_stack->next; p; p = p->next)
1609 notice ((p == input_file_stack->next
1610 ? "In file included from %s:%d"
1611 : ",\n from %s:%d"),
1613 fprintf (stderr, ":\n");
1614 last_error_tick = input_file_stack_tick;
1617 (*print_error_function) (input_filename);
1620 /* Print a message. */
1623 vnotice (file, msgid, ap)
1628 vfprintf (file, _(msgid), ap);
1632 notice VPROTO((const char *msgid, ...))
1634 #ifndef ANSI_PROTOTYPES
1639 VA_START (ap, msgid);
1641 #ifndef ANSI_PROTOTYPES
1642 msgid = va_arg (ap, char *);
1645 vnotice (stderr, msgid, ap);
1650 fnotice VPROTO((FILE *file, const char *msgid, ...))
1652 #ifndef ANSI_PROTOTYPES
1658 VA_START (ap, msgid);
1660 #ifndef ANSI_PROTOTYPES
1661 file = va_arg (ap, FILE *);
1662 msgid = va_arg (ap, const char *);
1665 vnotice (file, msgid, ap);
1669 /* Report FILE and LINE (or program name), and optionally just WARN. */
1672 report_file_and_line (file, line, warn)
1678 fprintf (stderr, "%s:%d: ", file, line);
1680 fprintf (stderr, "%s: ", progname);
1683 notice ("warning: ");
1686 /* Print a message. */
1689 vmessage (prefix, msgid, ap)
1695 fprintf (stderr, "%s: ", prefix);
1697 vfprintf (stderr, msgid, ap);
1700 /* Print a message relevant to line LINE of file FILE. */
1703 v_message_with_file_and_line (file, line, warn, msgid, ap)
1710 report_file_and_line (file, line, warn);
1711 vnotice (stderr, msgid, ap);
1712 fputc ('\n', stderr);
1715 /* Print a message relevant to the given DECL. */
1718 v_message_with_decl (decl, warn, msgid, ap)
1726 report_file_and_line (DECL_SOURCE_FILE (decl),
1727 DECL_SOURCE_LINE (decl), warn);
1729 /* Do magic to get around lack of varargs support for insertion
1730 of arguments into existing list. We know that the decl is first;
1731 we ass_u_me that it will be printed with "%s". */
1733 for (p = _(msgid); *p; ++p)
1737 if (*(p + 1) == '%')
1739 else if (*(p + 1) != 's')
1746 if (p > _(msgid)) /* Print the left-hand substring. */
1748 char fmt[sizeof "%.255s"];
1749 long width = p - _(msgid);
1751 if (width > 255L) width = 255L; /* arbitrary */
1752 sprintf (fmt, "%%.%lds", width);
1753 fprintf (stderr, fmt, _(msgid));
1756 if (*p == '%') /* Print the name. */
1758 const char *n = (DECL_NAME (decl)
1759 ? (*decl_printable_name) (decl, 2)
1765 if (ISALPHA (*(p - 1) & 0xFF))
1770 if (*p) /* Print the rest of the message. */
1771 vmessage ((char *)NULL, p, ap);
1773 fputc ('\n', stderr);
1776 /* Figure file and line of the given INSN. */
1779 file_and_line_for_asm (insn, pfile, pline)
1784 rtx body = PATTERN (insn);
1787 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1788 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1789 asmop = SET_SRC (body);
1790 else if (GET_CODE (body) == ASM_OPERANDS)
1792 else if (GET_CODE (body) == PARALLEL
1793 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1794 asmop = SET_SRC (XVECEXP (body, 0, 0));
1795 else if (GET_CODE (body) == PARALLEL
1796 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1797 asmop = XVECEXP (body, 0, 0);
1803 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1804 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1808 *pfile = input_filename;
1813 /* Report an error at line LINE of file FILE. */
1816 v_error_with_file_and_line (file, line, msgid, ap)
1823 report_error_function (file);
1824 v_message_with_file_and_line (file, line, 0, msgid, ap);
1828 error_with_file_and_line VPROTO((const char *file, int line,
1829 const char *msgid, ...))
1831 #ifndef ANSI_PROTOTYPES
1838 VA_START (ap, msgid);
1840 #ifndef ANSI_PROTOTYPES
1841 file = va_arg (ap, const char *);
1842 line = va_arg (ap, int);
1843 msgid = va_arg (ap, const char *);
1846 v_error_with_file_and_line (file, line, msgid, ap);
1850 /* Report an error at the declaration DECL.
1851 MSGID is a format string which uses %s to substitute the declaration
1852 name; subsequent substitutions are a la printf. */
1855 v_error_with_decl (decl, msgid, ap)
1861 report_error_function (DECL_SOURCE_FILE (decl));
1862 v_message_with_decl (decl, 0, msgid, ap);
1866 error_with_decl VPROTO((tree decl, const char *msgid, ...))
1868 #ifndef ANSI_PROTOTYPES
1874 VA_START (ap, msgid);
1876 #ifndef ANSI_PROTOTYPES
1877 decl = va_arg (ap, tree);
1878 msgid = va_arg (ap, const char *);
1881 v_error_with_decl (decl, msgid, ap);
1885 /* Report an error at the line number of the insn INSN.
1886 This is used only when INSN is an `asm' with operands,
1887 and each ASM_OPERANDS records its own source file and line. */
1890 v_error_for_asm (insn, msgid, ap)
1899 file_and_line_for_asm (insn, &file, &line);
1900 report_error_function (file);
1901 v_message_with_file_and_line (file, line, 0, msgid, ap);
1905 error_for_asm VPROTO((rtx insn, const char *msgid, ...))
1907 #ifndef ANSI_PROTOTYPES
1913 VA_START (ap, msgid);
1915 #ifndef ANSI_PROTOTYPES
1916 insn = va_arg (ap, rtx);
1917 msgid = va_arg (ap, const char *);
1920 v_error_for_asm (insn, msgid, ap);
1924 /* Report an error at the current line number. */
1931 v_error_with_file_and_line (input_filename, lineno, msgid, ap);
1935 error VPROTO((const char *msgid, ...))
1937 #ifndef ANSI_PROTOTYPES
1942 VA_START (ap, msgid);
1944 #ifndef ANSI_PROTOTYPES
1945 msgid = va_arg (ap, const char *);
1952 /* Report a fatal error at the current line number. */
1960 exit (FATAL_EXIT_CODE);
1964 fatal VPROTO((const char *msgid, ...))
1966 #ifndef ANSI_PROTOTYPES
1971 VA_START (ap, msgid);
1973 #ifndef ANSI_PROTOTYPES
1974 msgid = va_arg (ap, const char *);
1981 /* Report a warning at line LINE of file FILE. */
1984 v_warning_with_file_and_line (file, line, msgid, ap)
1990 if (count_error (1))
1992 report_error_function (file);
1993 v_message_with_file_and_line (file, line, 1, msgid, ap);
1998 warning_with_file_and_line VPROTO((const char *file, int line,
1999 const char *msgid, ...))
2001 #ifndef ANSI_PROTOTYPES
2008 VA_START (ap, msgid);
2010 #ifndef ANSI_PROTOTYPES
2011 file = va_arg (ap, const char *);
2012 line = va_arg (ap, int);
2013 msgid = va_arg (ap, const char *);
2016 v_warning_with_file_and_line (file, line, msgid, ap);
2020 /* Report a warning at the declaration DECL.
2021 MSGID is a format string which uses %s to substitute the declaration
2022 name; subsequent substitutions are a la printf. */
2025 v_warning_with_decl (decl, msgid, ap)
2030 if (count_error (1))
2032 report_error_function (DECL_SOURCE_FILE (decl));
2033 v_message_with_decl (decl, 1, msgid, ap);
2038 warning_with_decl VPROTO((tree decl, const char *msgid, ...))
2040 #ifndef ANSI_PROTOTYPES
2046 VA_START (ap, msgid);
2048 #ifndef ANSI_PROTOTYPES
2049 decl = va_arg (ap, tree);
2050 msgid = va_arg (ap, const char *);
2053 v_warning_with_decl (decl, msgid, ap);
2057 /* Report a warning at the line number of the insn INSN.
2058 This is used only when INSN is an `asm' with operands,
2059 and each ASM_OPERANDS records its own source file and line. */
2062 v_warning_for_asm (insn, msgid, ap)
2067 if (count_error (1))
2072 file_and_line_for_asm (insn, &file, &line);
2073 report_error_function (file);
2074 v_message_with_file_and_line (file, line, 1, msgid, ap);
2079 warning_for_asm VPROTO((rtx insn, const char *msgid, ...))
2081 #ifndef ANSI_PROTOTYPES
2087 VA_START (ap, msgid);
2089 #ifndef ANSI_PROTOTYPES
2090 insn = va_arg (ap, rtx);
2091 msgid = va_arg (ap, const char *);
2094 v_warning_for_asm (insn, msgid, ap);
2098 /* Report a warning at the current line number. */
2101 vwarning (msgid, ap)
2105 v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
2109 warning VPROTO((const char *msgid, ...))
2111 #ifndef ANSI_PROTOTYPES
2116 VA_START (ap, msgid);
2118 #ifndef ANSI_PROTOTYPES
2119 msgid = va_arg (ap, const char *);
2122 vwarning (msgid, ap);
2126 /* These functions issue either warnings or errors depending on
2127 -pedantic-errors. */
2130 vpedwarn (msgid, ap)
2134 if (flag_pedantic_errors)
2137 vwarning (msgid, ap);
2141 pedwarn VPROTO((const char *msgid, ...))
2143 #ifndef ANSI_PROTOTYPES
2148 VA_START (ap, msgid);
2150 #ifndef ANSI_PROTOTYPES
2151 msgid = va_arg (ap, const char *);
2154 vpedwarn (msgid, ap);
2159 v_pedwarn_with_decl (decl, msgid, ap)
2164 /* We don't want -pedantic-errors to cause the compilation to fail from
2165 "errors" in system header files. Sometimes fixincludes can't fix what's
2166 broken (eg: unsigned char bitfields - fixing it may change the alignment
2167 which will cause programs to mysteriously fail because the C library
2168 or kernel uses the original layout). There's no point in issuing a
2169 warning either, it's just unnecessary noise. */
2171 if (! DECL_IN_SYSTEM_HEADER (decl))
2173 if (flag_pedantic_errors)
2174 v_error_with_decl (decl, msgid, ap);
2176 v_warning_with_decl (decl, msgid, ap);
2181 pedwarn_with_decl VPROTO((tree decl, const char *msgid, ...))
2183 #ifndef ANSI_PROTOTYPES
2189 VA_START (ap, msgid);
2191 #ifndef ANSI_PROTOTYPES
2192 decl = va_arg (ap, tree);
2193 msgid = va_arg (ap, const char *);
2196 v_pedwarn_with_decl (decl, msgid, ap);
2201 v_pedwarn_with_file_and_line (file, line, msgid, ap)
2207 if (flag_pedantic_errors)
2208 v_error_with_file_and_line (file, line, msgid, ap);
2210 v_warning_with_file_and_line (file, line, msgid, ap);
2214 pedwarn_with_file_and_line VPROTO((const char *file, int line,
2215 const char *msgid, ...))
2217 #ifndef ANSI_PROTOTYPES
2224 VA_START (ap, msgid);
2226 #ifndef ANSI_PROTOTYPES
2227 file = va_arg (ap, const char *);
2228 line = va_arg (ap, int);
2229 msgid = va_arg (ap, const char *);
2232 v_pedwarn_with_file_and_line (file, line, msgid, ap);
2236 /* Apologize for not implementing some feature. */
2245 fprintf (stderr, "%s:%d: ", input_filename, lineno);
2247 fprintf (stderr, "%s: ", progname);
2248 notice ("sorry, not implemented: ");
2249 vnotice (stderr, msgid, ap);
2250 fputc ('\n', stderr);
2254 sorry VPROTO((const char *msgid, ...))
2256 #ifndef ANSI_PROTOTYPES
2261 VA_START (ap, msgid);
2263 #ifndef ANSI_PROTOTYPES
2264 msgid = va_arg (ap, const char *);
2271 /* Given a partial pathname as input, return another pathname that shares
2272 no elements with the pathname of __FILE__. This is used by abort() to
2273 print `Internal compiler error in expr.c' instead of `Internal compiler
2274 error in ../../egcs/gcc/expr.c'. */
2276 trim_filename (name)
2279 static const char *this_file = __FILE__;
2280 const char *p = name, *q = this_file;
2282 while (*p == *q && *p != 0 && *q != 0) p++, q++;
2283 while (p > name && p[-1] != DIR_SEPARATOR
2284 #ifdef DIR_SEPARATOR_2
2285 && p[-1] != DIR_SEPARATOR_2
2293 /* More 'friendly' abort that prints the line and file.
2294 config.h can #define abort fancy_abort if you like that sort of thing.
2296 I don't think this is actually a good idea.
2297 Other sorts of crashes will look a certain way.
2298 It is a good thing if crashes from calling abort look the same way.
2304 fatal ("internal gcc abort");
2307 /* This calls abort and is used to avoid problems when abort if a macro.
2308 It is used when we need to pass the address of abort. */
2316 /* When `malloc.c' is compiled with `rcheck' defined,
2317 it calls this function to report clobberage. */
2321 const char * s ATTRIBUTE_UNUSED;
2326 /* Same as `malloc' but report error if no memory available. */
2337 value = (PTR) malloc (size);
2339 fatal ("virtual memory exhausted");
2343 /* Same as `calloc' but report error if no memory available. */
2346 xcalloc (size1, size2)
2347 size_t size1, size2;
2351 if (size1 == 0 || size2 == 0)
2354 value = (PTR) calloc (size1, size2);
2356 fatal ("virtual memory exhausted");
2361 /* Same as `realloc' but report error if no memory available.
2362 Also handle null PTR even if the vendor realloc gets it wrong. */
2365 xrealloc (ptr, size)
2369 register PTR result;
2374 result = (ptr ? (PTR) realloc (ptr, size) : (PTR) malloc (size));
2377 fatal ("virtual memory exhausted");
2382 /* Same as `strdup' but report error if no memory available. */
2386 register const char *s;
2388 register char *result = (char *) malloc (strlen (s) + 1);
2391 fatal ("virtual memory exhausted");
2396 /* Return the logarithm of X, base 2, considering X unsigned,
2397 if X is a power of 2. Otherwise, returns -1.
2399 This should be used via the `exact_log2' macro. */
2403 register unsigned HOST_WIDE_INT x;
2405 register int log = 0;
2406 /* Test for 0 or a power of 2. */
2407 if (x == 0 || x != (x & -x))
2409 while ((x >>= 1) != 0)
2414 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2415 If X is 0, return -1.
2417 This should be used via the floor_log2 macro. */
2421 register unsigned HOST_WIDE_INT x;
2423 register int log = -1;
2430 static int float_handler_set;
2432 jmp_buf float_handler;
2434 /* Signals actually come here. */
2437 float_signal (signo)
2438 /* If this is missing, some compilers complain. */
2439 int signo ATTRIBUTE_UNUSED;
2441 if (float_handled == 0)
2443 #if defined (USG) || defined (hpux)
2444 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2447 signal (SIGFPE, float_signal);
2448 longjmp (float_handler, 1);
2451 /* Specify where to longjmp to when a floating arithmetic error happens.
2452 If HANDLER is 0, it means don't handle the errors any more. */
2455 set_float_handler (handler)
2458 float_handled = (handler != 0);
2460 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2462 if (float_handled && ! float_handler_set)
2464 signal (SIGFPE, float_signal);
2465 float_handler_set = 1;
2469 /* This is a wrapper function for code which might elicit an
2470 arithmetic exception. That code should be passed in as a function
2471 pointer FN, and one argument DATA. DATA is usually a struct which
2472 contains the real input and output for function FN. This function
2473 returns 0 (failure) if longjmp was called (i.e. an exception
2474 occured.) It returns 1 (success) otherwise. */
2477 do_float_handler (fn, data)
2478 void (*fn) PROTO ((PTR));
2485 /* We got here via longjmp() caused by an exception in function fn() */
2486 set_float_handler (NULL);
2490 set_float_handler (buf);
2492 set_float_handler (NULL);
2496 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2497 error happens, pushing the previous specification into OLD_HANDLER.
2498 Return an indication of whether there was a previous handler in effect. */
2501 push_float_handler (handler, old_handler)
2502 jmp_buf handler, old_handler;
2504 int was_handled = float_handled;
2508 memcpy ((char *) old_handler, (char *) float_handler,
2509 sizeof (float_handler));
2511 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
2515 /* Restore the previous specification of whether and where to longjmp to
2516 when a floating arithmetic error happens. */
2519 pop_float_handler (handled, handler)
2523 float_handled = handled;
2525 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2528 /* Handler for SIGPIPE. */
2532 /* If this is missing, some compilers complain. */
2533 int signo ATTRIBUTE_UNUSED;
2535 fatal ("output pipe has been closed");
2538 /* Strip off a legitimate source ending from the input string NAME of
2539 length LEN. Rather than having to know the names used by all of
2540 our front ends, we strip off an ending of a period followed by
2541 up to five characters. (Java uses ".class".) */
2544 strip_off_ending (name, len)
2549 for (i = 2; i < 6 && len > i; i++)
2551 if (name[len - i] == '.')
2553 name[len - i] = '\0';
2559 /* Output a quoted string. */
2562 output_quoted_string (asm_file, string)
2566 #ifdef OUTPUT_QUOTED_STRING
2567 OUTPUT_QUOTED_STRING (asm_file, string);
2571 putc ('\"', asm_file);
2572 while ((c = *string++) != 0)
2574 if (c == '\"' || c == '\\')
2575 putc ('\\', asm_file);
2578 putc ('\"', asm_file);
2582 /* Output a file name in the form wanted by System V. */
2585 output_file_directive (asm_file, input_name)
2587 const char *input_name;
2589 int len = strlen (input_name);
2590 const char *na = input_name + len;
2592 /* NA gets INPUT_NAME sans directory names. */
2593 while (na > input_name)
2597 #ifdef DIR_SEPARATOR
2598 if (na[-1] == DIR_SEPARATOR)
2604 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2605 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2607 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2608 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2610 fprintf (asm_file, "\t.file\t");
2611 output_quoted_string (asm_file, na);
2612 fputc ('\n', asm_file);
2617 #ifdef ASM_IDENTIFY_LANGUAGE
2618 /* Routine to build language identifier for object file. */
2620 output_lang_identify (asm_out_file)
2623 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2624 char *s = (char *) alloca (len);
2625 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2626 ASM_OUTPUT_LABEL (asm_out_file, s);
2630 /* Routine to open a dump file. */
2632 open_dump_file (suffix, function_name)
2634 const char *function_name;
2641 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2643 if (rtl_dump_file != NULL)
2644 fclose (rtl_dump_file);
2646 strcpy (dumpname, dump_base_name);
2647 strcat (dumpname, suffix);
2649 rtl_dump_file = fopen (dumpname, "a");
2651 if (rtl_dump_file == NULL)
2652 pfatal_with_name (dumpname);
2657 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2663 /* Routine to close a dump file. */
2665 close_dump_file (func, insns)
2666 void (*func) PROTO ((FILE *, rtx));
2673 func (rtl_dump_file, insns);
2675 fflush (rtl_dump_file);
2676 fclose (rtl_dump_file);
2678 rtl_dump_file = NULL;
2684 /* Routine to dump rtl into a file. */
2686 dump_rtl (suffix, decl, func, insns)
2689 void (*func) PROTO ((FILE *, rtx));
2692 open_dump_file (suffix, decl_printable_name (decl, 2));
2693 close_dump_file (func, insns);
2696 /* Routine to empty a dump file. */
2698 clean_dump_file (suffix)
2703 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2705 strcpy (dumpname, dump_base_name);
2706 strcat (dumpname, suffix);
2708 rtl_dump_file = fopen (dumpname, "w");
2710 if (rtl_dump_file == NULL)
2711 pfatal_with_name (dumpname);
2715 fclose (rtl_dump_file);
2716 rtl_dump_file = NULL;
2721 /* Do any final processing required for the declarations in VEC, of
2722 which there are LEN. We write out inline functions and variables
2723 that have been deferred until this point, but which are required.
2724 Returns non-zero if anything was put out. */
2726 wrapup_global_declarations (vec, len)
2733 int output_something = 0;
2735 for (i = 0; i < len; i++)
2739 /* We're not deferring this any longer. */
2740 DECL_DEFER_OUTPUT (decl) = 0;
2742 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2743 && incomplete_decl_finalize_hook != 0)
2744 (*incomplete_decl_finalize_hook) (decl);
2747 /* Now emit any global variables or functions that we have been
2748 putting off. We need to loop in case one of the things emitted
2749 here references another one which comes earlier in the list. */
2753 for (i = 0; i < len; i++)
2757 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2760 /* Don't write out static consts, unless we still need them.
2762 We also keep static consts if not optimizing (for debugging),
2763 unless the user specified -fno-keep-static-consts.
2764 ??? They might be better written into the debug information.
2765 This is possible when using DWARF.
2767 A language processor that wants static constants to be always
2768 written out (even if it is not used) is responsible for
2769 calling rest_of_decl_compilation itself. E.g. the C front-end
2770 calls rest_of_decl_compilation from finish_decl.
2771 One motivation for this is that is conventional in some
2772 environments to write things like:
2773 static const char rcsid[] = "... version string ...";
2774 intending to force the string to be in the executable.
2776 A language processor that would prefer to have unneeded
2777 static constants "optimized away" would just defer writing
2778 them out until here. E.g. C++ does this, because static
2779 constants are often defined in header files.
2781 ??? A tempting alternative (for both C and C++) would be
2782 to force a constant to be written if and only if it is
2783 defined in a main file, as opposed to an include file. */
2785 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2786 && (! TREE_READONLY (decl)
2787 || TREE_PUBLIC (decl)
2788 || (!optimize && flag_keep_static_consts)
2789 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2792 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2795 if (TREE_CODE (decl) == FUNCTION_DECL
2796 && DECL_INITIAL (decl) != 0
2797 && DECL_SAVED_INSNS (decl) != 0
2798 && (flag_keep_inline_functions
2799 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2800 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2803 temporary_allocation ();
2804 output_inline_function (decl);
2805 permanent_allocation (1);
2810 output_something = 1;
2814 return output_something;
2817 /* Issue appropriate warnings for the global declarations in VEC (of
2818 which there are LEN). Output debugging information for them. */
2820 check_global_declarations (vec, len)
2827 for (i = 0; i < len; i++)
2831 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2832 && ! TREE_ASM_WRITTEN (decl))
2833 /* Cancel the RTL for this decl so that, if debugging info
2834 output for global variables is still to come,
2835 this one will be omitted. */
2836 DECL_RTL (decl) = NULL;
2838 /* Warn about any function
2839 declared static but not defined.
2840 We don't warn about variables,
2841 because many programs have static variables
2842 that exist only to get some text into the object file. */
2843 if (TREE_CODE (decl) == FUNCTION_DECL
2845 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2846 && DECL_INITIAL (decl) == 0
2847 && DECL_EXTERNAL (decl)
2848 && ! DECL_ARTIFICIAL (decl)
2849 && ! TREE_PUBLIC (decl))
2851 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2852 pedwarn_with_decl (decl,
2853 "`%s' used but never defined");
2855 warning_with_decl (decl,
2856 "`%s' declared `static' but never defined");
2857 /* This symbol is effectively an "extern" declaration now. */
2858 TREE_PUBLIC (decl) = 1;
2859 assemble_external (decl);
2862 /* Warn about static fns or vars defined but not used,
2863 but not about inline functions or static consts
2864 since defining those in header files is normal practice. */
2866 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2867 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2868 && ! DECL_IN_SYSTEM_HEADER (decl)
2869 && ! DECL_EXTERNAL (decl)
2870 && ! TREE_PUBLIC (decl)
2871 && ! TREE_USED (decl)
2872 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2873 /* The TREE_USED bit for file-scope decls
2874 is kept in the identifier, to handle multiple
2875 external decls in different scopes. */
2876 && ! TREE_USED (DECL_NAME (decl)))
2877 warning_with_decl (decl, "`%s' defined but not used");
2879 #ifdef SDB_DEBUGGING_INFO
2880 /* The COFF linker can move initialized global vars to the end.
2881 And that can screw up the symbol ordering.
2882 By putting the symbols in that order to begin with,
2883 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2884 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2885 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2886 && ! DECL_EXTERNAL (decl)
2887 && DECL_RTL (decl) != 0)
2888 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2890 /* Output COFF information for non-global
2891 file-scope initialized variables. */
2892 if (write_symbols == SDB_DEBUG
2893 && TREE_CODE (decl) == VAR_DECL
2894 && DECL_INITIAL (decl)
2895 && ! DECL_EXTERNAL (decl)
2896 && DECL_RTL (decl) != 0
2897 && GET_CODE (DECL_RTL (decl)) == MEM)
2898 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2899 #endif /* SDB_DEBUGGING_INFO */
2900 #ifdef DWARF_DEBUGGING_INFO
2901 /* Output DWARF information for file-scope tentative data object
2902 declarations, file-scope (extern) function declarations (which
2903 had no corresponding body) and file-scope tagged type declarations
2904 and definitions which have not yet been forced out. */
2906 if (write_symbols == DWARF_DEBUG
2907 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2908 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2910 #ifdef DWARF2_DEBUGGING_INFO
2911 /* Output DWARF2 information for file-scope tentative data object
2912 declarations, file-scope (extern) function declarations (which
2913 had no corresponding body) and file-scope tagged type declarations
2914 and definitions which have not yet been forced out. */
2916 if (write_symbols == DWARF2_DEBUG
2917 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2918 TIMEVAR (symout_time, dwarf2out_decl (decl));
2923 /* Compile an entire file of output from cpp, named NAME.
2924 Write a file of assembly output and various debugging dumps. */
2933 int name_specified = name != 0;
2935 if (dump_base_name == 0)
2936 dump_base_name = name ? name : "gccdump";
2940 integration_time = 0;
2946 branch_prob_time = 0;
2951 local_alloc_time = 0;
2952 global_alloc_time = 0;
2958 shorten_branch_time = 0;
2964 /* Initialize data in various passes. */
2968 name = init_parse (name);
2970 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2971 || debug_info_level == DINFO_LEVEL_VERBOSE
2972 || flag_test_coverage);
2974 init_decl_processing ();
2983 if (flag_caller_saves)
2984 init_caller_save ();
2986 /* If auxiliary info generation is desired, open the output file.
2987 This goes in the same directory as the source file--unlike
2988 all the other output files. */
2989 if (flag_gen_aux_info)
2991 aux_info_file = fopen (aux_info_file_name, "w");
2992 if (aux_info_file == 0)
2993 pfatal_with_name (aux_info_file_name);
2996 /* Clear the dump files. */
2998 clean_dump_file (".rtl");
3001 clean_dump_file (".jump");
3002 if (graph_dump_format != no_graph)
3003 clean_graph_dump_file (dump_base_name, ".jump");
3007 clean_dump_file (".addressof");
3008 if (graph_dump_format != no_graph)
3009 clean_graph_dump_file (dump_base_name, ".addressof");
3013 clean_dump_file (".cse");
3014 if (graph_dump_format != no_graph)
3015 clean_graph_dump_file (dump_base_name, ".cse");
3019 clean_dump_file (".loop");
3020 if (graph_dump_format != no_graph)
3021 clean_graph_dump_file (dump_base_name, ".loop");
3025 clean_dump_file (".cse2");
3026 if (graph_dump_format != no_graph)
3027 clean_graph_dump_file (dump_base_name, ".cse2");
3029 if (branch_prob_dump)
3031 clean_dump_file (".bp");
3032 if (graph_dump_format != no_graph)
3033 clean_graph_dump_file (dump_base_name, ".bp");
3037 clean_dump_file (".flow");
3038 if (graph_dump_format != no_graph)
3039 clean_graph_dump_file (dump_base_name, ".flow");
3043 clean_dump_file (".combine");
3044 if (graph_dump_format != no_graph)
3045 clean_graph_dump_file (dump_base_name, ".combine");
3049 clean_dump_file (".regmove");
3050 if (graph_dump_format != no_graph)
3051 clean_graph_dump_file (dump_base_name, ".regmove");
3055 clean_dump_file (".sched");
3056 if (graph_dump_format != no_graph)
3057 clean_graph_dump_file (dump_base_name, ".sched");
3061 clean_dump_file (".lreg");
3062 if (graph_dump_format != no_graph)
3063 clean_graph_dump_file (dump_base_name, ".lreg");
3065 if (global_reg_dump)
3067 clean_dump_file (".greg");
3068 if (graph_dump_format != no_graph)
3069 clean_graph_dump_file (dump_base_name, ".greg");
3073 clean_dump_file (".flow2");
3074 if (graph_dump_format != no_graph)
3075 clean_graph_dump_file (dump_base_name, ".flow2");
3079 clean_dump_file (".sched2");
3080 if (graph_dump_format != no_graph)
3081 clean_graph_dump_file (dump_base_name, ".sched2");
3085 clean_dump_file (".jump2");
3086 if (graph_dump_format != no_graph)
3087 clean_graph_dump_file (dump_base_name, ".jump2");
3092 clean_dump_file (".dbr");
3093 if (graph_dump_format != no_graph)
3094 clean_graph_dump_file (dump_base_name, ".dbr");
3099 clean_dump_file (".gcse");
3100 if (graph_dump_format != no_graph)
3101 clean_graph_dump_file (dump_base_name, ".gcse");
3106 clean_dump_file (".stack");
3107 if (graph_dump_format != no_graph)
3108 clean_graph_dump_file (dump_base_name, ".stack");
3111 #ifdef MACHINE_DEPENDENT_REORG
3112 if (mach_dep_reorg_dump)
3114 clean_dump_file (".mach");
3115 if (graph_dump_format != no_graph)
3116 clean_graph_dump_file (dump_base_name, ".mach");
3120 /* Open assembler code output file. */
3122 if (flag_syntax_only)
3123 asm_out_file = NULL;
3126 if (! name_specified && asm_file_name == 0)
3127 asm_out_file = stdout;
3130 int len = strlen (dump_base_name);
3131 register char *dumpname = (char *) xmalloc (len + 6);
3132 strcpy (dumpname, dump_base_name);
3133 strip_off_ending (dumpname, len);
3134 strcat (dumpname, ".s");
3135 if (asm_file_name == 0)
3137 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
3138 strcpy (asm_file_name, dumpname);
3140 if (!strcmp (asm_file_name, "-"))
3141 asm_out_file = stdout;
3143 asm_out_file = fopen (asm_file_name, "w");
3144 if (asm_out_file == 0)
3145 pfatal_with_name (asm_file_name);
3148 #ifdef IO_BUFFER_SIZE
3149 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
3150 _IOFBF, IO_BUFFER_SIZE);
3154 input_filename = name;
3156 /* Put an entry on the input file stack for the main input file. */
3158 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
3159 input_file_stack->next = 0;
3160 input_file_stack->name = input_filename;
3162 /* Perform language-specific initialization.
3163 This may set main_input_filename. */
3166 /* If the input doesn't start with a #line, use the input name
3167 as the official input file name. */
3168 if (main_input_filename == 0)
3169 main_input_filename = name;
3171 if (flag_syntax_only)
3173 write_symbols = NO_DEBUG;
3175 profile_block_flag = 0;
3179 ASM_FILE_START (asm_out_file);
3181 #ifdef ASM_COMMENT_START
3182 if (flag_verbose_asm)
3184 /* Print the list of options in effect. */
3185 print_version (asm_out_file, ASM_COMMENT_START);
3186 print_switch_values (asm_out_file, 0, MAX_LINE,
3187 ASM_COMMENT_START, " ", "\n");
3188 /* Add a blank line here so it appears in assembler output but not
3190 fprintf (asm_out_file, "\n");
3194 /* Output something to inform GDB that this compilation was by GCC. */
3195 #ifndef ASM_IDENTIFY_GCC
3196 fprintf (asm_out_file, "gcc2_compiled.:\n");
3198 ASM_IDENTIFY_GCC (asm_out_file);
3201 /* Output something to identify which front-end produced this file. */
3202 #ifdef ASM_IDENTIFY_LANGUAGE
3203 ASM_IDENTIFY_LANGUAGE (asm_out_file);
3205 } /* ! flag_syntax_only */
3207 #ifndef ASM_OUTPUT_SECTION_NAME
3208 if (flag_function_sections)
3210 warning ("-ffunction-sections not supported for this target.");
3211 flag_function_sections = 0;
3213 if (flag_data_sections)
3215 warning ("-fdata-sections not supported for this target.");
3216 flag_data_sections = 0;
3220 if (flag_function_sections
3221 && (profile_flag || profile_block_flag))
3223 warning ("-ffunction-sections disabled; it makes profiling impossible.");
3224 flag_function_sections = 0;
3227 #ifndef OBJECT_FORMAT_ELF
3228 if (flag_function_sections && write_symbols != NO_DEBUG)
3229 warning ("-ffunction-sections may affect debugging on some targets.");
3232 /* ??? Note: There used to be a conditional here
3233 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
3234 This was to guarantee separation between gcc_compiled. and
3235 the first function, for the sake of dbx on Suns.
3236 However, having the extra zero here confused the Emacs
3237 code for unexec, and might confuse other programs too.
3238 Therefore, I took out that change.
3239 In future versions we should find another way to solve
3240 that dbx problem. -- rms, 23 May 93. */
3242 /* Don't let the first function fall at the same address
3243 as gcc_compiled., if profiling. */
3244 if (profile_flag || profile_block_flag)
3246 /* It's best if we can write a nop here since some
3247 assemblers don't tolerate zeros in the text section. */
3248 if (insn_template[CODE_FOR_nop] != 0)
3249 output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR);
3251 assemble_zeros (UNITS_PER_WORD);
3254 /* If dbx symbol table desired, initialize writing it
3255 and output the predefined types. */
3256 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3257 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3258 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
3261 #ifdef SDB_DEBUGGING_INFO
3262 if (write_symbols == SDB_DEBUG)
3263 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
3266 #ifdef DWARF_DEBUGGING_INFO
3267 if (write_symbols == DWARF_DEBUG)
3268 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
3270 #ifdef DWARF2_UNWIND_INFO
3271 if (dwarf2out_do_frame ())
3272 dwarf2out_frame_init ();
3274 #ifdef DWARF2_DEBUGGING_INFO
3275 if (write_symbols == DWARF2_DEBUG)
3276 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
3279 /* Initialize yet another pass. */
3281 init_final (main_input_filename);
3282 init_branch_prob (dump_base_name);
3284 start_time = get_run_time ();
3286 /* Call the parser, which parses the entire file
3287 (calling rest_of_compilation for each function). */
3289 if (yyparse () != 0)
3291 if (errorcount == 0)
3292 notice ("Errors detected in input file (your bison.simple is out of date)\n");
3294 /* In case there were missing closebraces,
3295 get us back to the global binding level. */
3296 while (! global_bindings_p ())
3300 /* Compilation is now finished except for writing
3301 what's left of the symbol table output. */
3303 parse_time += get_run_time () - start_time;
3305 parse_time -= integration_time;
3306 parse_time -= varconst_time;
3308 if (flag_syntax_only)
3311 globals = getdecls ();
3313 /* Really define vars that have had only a tentative definition.
3314 Really output inline functions that must actually be callable
3315 and have not been output so far. */
3318 int len = list_length (globals);
3319 tree *vec = (tree *) alloca (sizeof (tree) * len);
3323 /* Process the decls in reverse order--earliest first.
3324 Put them into VEC from back to front, then take out from front. */
3326 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
3327 vec[len - i - 1] = decl;
3329 wrapup_global_declarations (vec, len);
3331 /* This must occur after the loop to output deferred functions. Else
3332 the profiler initializer would not be emitted if all the functions
3333 in this compilation unit were deferred.
3335 output_func_start_profiler can not cause any additional functions or
3336 data to need to be output, so it need not be in the deferred function
3338 output_func_start_profiler ();
3340 /* Now that all possible functions have been output, we can dump
3341 the exception table. */
3343 output_exception_table ();
3345 check_global_declarations (vec, len);
3348 /* Write out any pending weak symbol declarations. */
3352 /* Do dbx symbols */
3353 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3354 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3355 TIMEVAR (symout_time,
3357 dbxout_finish (asm_out_file, main_input_filename);
3361 #ifdef DWARF_DEBUGGING_INFO
3362 if (write_symbols == DWARF_DEBUG)
3363 TIMEVAR (symout_time,
3369 #ifdef DWARF2_UNWIND_INFO
3370 if (dwarf2out_do_frame ())
3371 dwarf2out_frame_finish ();
3374 #ifdef DWARF2_DEBUGGING_INFO
3375 if (write_symbols == DWARF2_DEBUG)
3376 TIMEVAR (symout_time,
3378 dwarf2out_finish ();
3382 /* Output some stuff at end of file if nec. */
3384 end_final (dump_base_name);
3386 if (branch_prob_dump)
3387 open_dump_file (".bp", NULL);
3389 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
3391 if (branch_prob_dump)
3392 close_dump_file (NULL, NULL_RTX);
3395 ASM_FILE_END (asm_out_file);
3399 /* Language-specific end of compilation actions. */
3403 /* Close the dump files. */
3405 if (flag_gen_aux_info)
3407 fclose (aux_info_file);
3409 unlink (aux_info_file_name);
3414 open_dump_file (".combine", NULL);
3415 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
3416 close_dump_file (NULL, NULL_RTX);
3419 /* Close non-debugging input and output files. Take special care to note
3420 whether fclose returns an error, since the pages might still be on the
3421 buffer chain while the file is open. */
3425 if (! flag_syntax_only
3426 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
3427 fatal_io_error (asm_file_name);
3429 /* Do whatever is necessary to finish printing the graphs. */
3430 if (graph_dump_format != no_graph)
3433 finish_graph_dump_file (dump_base_name, ".jump");
3435 finish_graph_dump_file (dump_base_name, ".addressof");
3437 finish_graph_dump_file (dump_base_name, ".cse");
3439 finish_graph_dump_file (dump_base_name, ".loop");
3441 finish_graph_dump_file (dump_base_name, ".cse2");
3442 if (branch_prob_dump)
3443 finish_graph_dump_file (dump_base_name, ".bp");
3445 finish_graph_dump_file (dump_base_name, ".flow");
3447 finish_graph_dump_file (dump_base_name, ".combine");
3449 finish_graph_dump_file (dump_base_name, ".regmove");
3451 finish_graph_dump_file (dump_base_name, ".sched");
3453 finish_graph_dump_file (dump_base_name, ".lreg");
3454 if (global_reg_dump)
3455 finish_graph_dump_file (dump_base_name, ".greg");
3457 finish_graph_dump_file (dump_base_name, ".flow2");
3459 finish_graph_dump_file (dump_base_name, ".sched2");
3461 finish_graph_dump_file (dump_base_name, ".jump2");
3464 finish_graph_dump_file (dump_base_name, ".dbr");
3467 finish_graph_dump_file (dump_base_name, ".gcse");
3470 finish_graph_dump_file (dump_base_name, ".stack");
3472 #ifdef MACHINE_DEPENDENT_REORG
3473 if (mach_dep_reorg_dump)
3474 finish_graph_dump_file (dump_base_name, ".mach");
3478 /* Free up memory for the benefit of leak detectors. */
3481 /* Print the times. */
3485 fprintf (stderr,"\n");
3486 print_time ("parse", parse_time);
3488 print_time ("integration", integration_time);
3489 print_time ("jump", jump_time);
3490 print_time ("cse", cse_time);
3491 print_time ("gcse", gcse_time);
3492 print_time ("loop", loop_time);
3493 print_time ("cse2", cse2_time);
3494 print_time ("branch-prob", branch_prob_time);
3495 print_time ("flow", flow_time);
3496 print_time ("combine", combine_time);
3497 print_time ("regmove", regmove_time);
3498 print_time ("sched", sched_time);
3499 print_time ("local-alloc", local_alloc_time);
3500 print_time ("global-alloc", global_alloc_time);
3501 print_time ("flow2", flow2_time);
3502 print_time ("sched2", sched2_time);
3504 print_time ("dbranch", dbr_sched_time);
3506 print_time ("shorten-branch", shorten_branch_time);
3507 print_time ("stack-reg", stack_reg_time);
3508 print_time ("final", final_time);
3509 print_time ("varconst", varconst_time);
3510 print_time ("symout", symout_time);
3511 print_time ("dump", dump_time);
3515 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3516 and TYPE_DECL nodes.
3518 This does nothing for local (non-static) variables.
3519 Otherwise, it sets up the RTL and outputs any assembler code
3520 (label definition, storage allocation and initialization).
3522 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3523 the assembler symbol name to be used. TOP_LEVEL is nonzero
3524 if this declaration is not within a function. */
3527 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
3529 const char *asmspec;
3533 /* Declarations of variables, and of functions defined elsewhere. */
3535 /* The most obvious approach, to put an #ifndef around where
3536 this macro is used, doesn't work since it's inside a macro call. */
3537 #ifndef ASM_FINISH_DECLARE_OBJECT
3538 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3541 /* Forward declarations for nested functions are not "external",
3542 but we need to treat them as if they were. */
3543 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
3544 || TREE_CODE (decl) == FUNCTION_DECL)
3545 TIMEVAR (varconst_time,
3547 make_decl_rtl (decl, asmspec, top_level);
3548 /* Initialized extern variable exists to be replaced
3549 with its value, or represents something that will be
3550 output in another file. */
3551 if (! (TREE_CODE (decl) == VAR_DECL
3552 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
3553 && DECL_INITIAL (decl) != 0
3554 && DECL_INITIAL (decl) != error_mark_node))
3555 /* Don't output anything
3556 when a tentative file-scope definition is seen.
3557 But at end of compilation, do output code for them. */
3558 if (! (! at_end && top_level
3559 && (DECL_INITIAL (decl) == 0
3560 || DECL_INITIAL (decl) == error_mark_node)))
3561 assemble_variable (decl, top_level, at_end, 0);
3562 if (decl == last_assemble_variable_decl)
3564 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
3568 else if (DECL_REGISTER (decl) && asmspec != 0)
3570 if (decode_reg_name (asmspec) >= 0)
3572 DECL_RTL (decl) = 0;
3573 make_decl_rtl (decl, asmspec, top_level);
3576 error ("invalid register name `%s' for register variable", asmspec);
3578 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3579 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3580 && TREE_CODE (decl) == TYPE_DECL)
3581 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
3583 #ifdef SDB_DEBUGGING_INFO
3584 else if (write_symbols == SDB_DEBUG && top_level
3585 && TREE_CODE (decl) == TYPE_DECL)
3586 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
3590 /* Called after finishing a record, union or enumeral type. */
3593 rest_of_type_compilation (type, toplev)
3594 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3598 tree type ATTRIBUTE_UNUSED;
3599 int toplev ATTRIBUTE_UNUSED;
3602 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3603 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3604 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3606 #ifdef SDB_DEBUGGING_INFO
3607 if (write_symbols == SDB_DEBUG)
3608 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3612 /* This is called from finish_function (within yyparse)
3613 after each top-level definition is parsed.
3614 It is supposed to compile that function or variable
3615 and output the assembler code for it.
3616 After we return, the tree storage is freed. */
3619 rest_of_compilation (decl)
3623 int start_time = get_run_time ();
3625 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3626 to be restored after we finish compiling the function
3627 (for use when compiling inline calls to this function). */
3628 tree saved_block_tree = 0;
3629 /* Likewise, for DECL_ARGUMENTS. */
3630 tree saved_arguments = 0;
3632 int rebuild_label_notes_after_reload;
3634 /* If we are reconsidering an inline function
3635 at the end of compilation, skip the stuff for making it inline. */
3637 if (DECL_SAVED_INSNS (decl) == 0)
3642 /* If requested, consider whether to make this function inline. */
3643 if (DECL_INLINE (decl) || flag_inline_functions)
3644 TIMEVAR (integration_time,
3646 lose = function_cannot_inline_p (decl);
3647 if (lose || ! optimize)
3649 if (warn_inline && DECL_INLINE (decl))
3650 warning_with_decl (decl, lose);
3651 DECL_ABSTRACT_ORIGIN (decl) = 0;
3652 /* Don't really compile an extern inline function.
3653 If we can't make it inline, pretend
3654 it was only declared. */
3655 if (DECL_EXTERNAL (decl))
3657 DECL_INITIAL (decl) = 0;
3658 goto exit_rest_of_compilation;
3662 /* ??? Note that this has the effect of making it look
3663 like "inline" was specified for a function if we choose
3664 to inline it. This isn't quite right, but it's
3665 probably not worth the trouble to fix. */
3666 inlinable = DECL_INLINE (decl) = 1;
3669 insns = get_insns ();
3671 /* Dump the rtl code if we are dumping rtl. */
3675 open_dump_file (".rtl", decl_printable_name (decl, 2));
3677 if (DECL_SAVED_INSNS (decl))
3678 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3680 close_dump_file (print_rtl, insns);
3683 /* If we can, defer compiling inlines until EOF.
3684 save_for_inline_copying can be extremely expensive. */
3685 if (inlinable && ! decl_function_context (decl))
3686 DECL_DEFER_OUTPUT (decl) = 1;
3688 /* If function is inline, and we don't yet know whether to
3689 compile it by itself, defer decision till end of compilation.
3690 finish_compilation will call rest_of_compilation again
3691 for those functions that need to be output. Also defer those
3692 functions that we are supposed to defer. We cannot defer
3693 functions containing nested functions since the nested function
3694 data is in our non-saved obstack. We cannot defer nested
3695 functions for the same reason. */
3697 /* If this is a nested inline, remove ADDRESSOF now so we can
3698 finish compiling ourselves. Otherwise, wait until EOF.
3699 We have to do this because the purge_addressof transformation
3700 changes the DECL_RTL for many variables, which confuses integrate. */
3703 if (decl_function_context (decl))
3704 purge_addressof (insns);
3706 DECL_DEFER_OUTPUT (decl) = 1;
3709 if (! current_function_contains_functions
3710 && (DECL_DEFER_OUTPUT (decl)
3711 || (DECL_INLINE (decl)
3712 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3713 && ! flag_keep_inline_functions)
3714 || DECL_EXTERNAL (decl)))))
3716 DECL_DEFER_OUTPUT (decl) = 1;
3718 /* If -Wreturn-type, we have to do a bit of compilation.
3719 However, if we just fall through we will call
3720 save_for_inline_copying() which results in excessive
3721 memory use. Instead, we just want to call
3722 jump_optimize() to figure out whether or not we can fall
3723 off the end of the function; we do the minimum amount of
3724 work necessary to make that safe. And, we set optimize
3725 to zero to keep jump_optimize from working too hard. */
3726 if (warn_return_type)
3728 int saved_optimize = optimize;
3730 find_exception_handler_labels ();
3731 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3732 !JUMP_AFTER_REGSCAN);
3733 optimize = saved_optimize;
3736 #ifdef DWARF_DEBUGGING_INFO
3737 /* Generate the DWARF info for the "abstract" instance
3738 of a function which we may later generate inlined and/or
3739 out-of-line instances of. */
3740 if (write_symbols == DWARF_DEBUG)
3742 set_decl_abstract_flags (decl, 1);
3743 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3744 set_decl_abstract_flags (decl, 0);
3747 #ifdef DWARF2_DEBUGGING_INFO
3748 /* Generate the DWARF2 info for the "abstract" instance
3749 of a function which we may later generate inlined and/or
3750 out-of-line instances of. */
3751 if (write_symbols == DWARF2_DEBUG)
3753 set_decl_abstract_flags (decl, 1);
3754 TIMEVAR (symout_time, dwarf2out_decl (decl));
3755 set_decl_abstract_flags (decl, 0);
3758 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3759 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3760 goto exit_rest_of_compilation;
3763 /* If we have to compile the function now, save its rtl and subdecls
3764 so that its compilation will not affect what others get. */
3765 if (inlinable || DECL_DEFER_OUTPUT (decl))
3767 #ifdef DWARF_DEBUGGING_INFO
3768 /* Generate the DWARF info for the "abstract" instance of
3769 a function which we will generate an out-of-line instance
3770 of almost immediately (and which we may also later generate
3771 various inlined instances of). */
3772 if (write_symbols == DWARF_DEBUG)
3774 set_decl_abstract_flags (decl, 1);
3775 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3776 set_decl_abstract_flags (decl, 0);
3779 #ifdef DWARF2_DEBUGGING_INFO
3780 /* Generate the DWARF2 info for the "abstract" instance of
3781 a function which we will generate an out-of-line instance
3782 of almost immediately (and which we may also later generate
3783 various inlined instances of). */
3784 if (write_symbols == DWARF2_DEBUG)
3786 set_decl_abstract_flags (decl, 1);
3787 TIMEVAR (symout_time, dwarf2out_decl (decl));
3788 set_decl_abstract_flags (decl, 0);
3791 saved_block_tree = DECL_INITIAL (decl);
3792 saved_arguments = DECL_ARGUMENTS (decl);
3793 TIMEVAR (integration_time, save_for_inline_copying (decl));
3794 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3797 /* If specified extern inline but we aren't inlining it, we are
3798 done. This goes for anything that gets here with DECL_EXTERNAL
3799 set, not just things with DECL_INLINE. */
3800 if (DECL_EXTERNAL (decl))
3801 goto exit_rest_of_compilation;
3804 if (! DECL_DEFER_OUTPUT (decl))
3805 TREE_ASM_WRITTEN (decl) = 1;
3807 /* Now that integrate will no longer see our rtl, we need not distinguish
3808 between the return value of this function and the return value of called
3810 rtx_equal_function_value_matters = 0;
3812 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3813 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3815 goto exit_rest_of_compilation;
3818 /* Emit code to get eh context, if needed. */
3822 /* If we are doing position-independent code generation, now
3823 is the time to output special prologues and epilogues.
3824 We do not want to do this earlier, because it just clutters
3825 up inline functions with meaningless insns. */
3830 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3831 Note that that may have been done above, in save_for_inline_copying.
3832 The call to resume_temporary_allocation near the end of this function
3833 goes back to the usual state of affairs. This must be done after
3834 we've built up any unwinders for exception handling, and done
3835 the FINALIZE_PIC work, if necessary. */
3837 rtl_in_current_obstack ();
3839 insns = get_insns ();
3841 /* Copy any shared structure that should not be shared. */
3843 unshare_all_rtl (current_function_decl, insns);
3845 #ifdef SETJMP_VIA_SAVE_AREA
3846 /* This must be performed before virutal register instantiation. */
3847 if (current_function_calls_alloca)
3848 optimize_save_area_alloca (insns);
3851 /* Instantiate all virtual registers. */
3853 instantiate_virtual_regs (current_function_decl, get_insns ());
3855 /* See if we have allocated stack slots that are not directly addressable.
3856 If so, scan all the insns and create explicit address computation
3857 for all references to such slots. */
3858 /* fixup_stack_slots (); */
3860 /* Find all the EH handlers. */
3861 find_exception_handler_labels ();
3863 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3864 are initialized and to compute whether control can drop off the end
3866 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3867 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3868 JUMP_AFTER_REGSCAN));
3870 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3871 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3872 goto exit_rest_of_compilation;
3874 /* Dump rtl code after jump, if we are doing that. */
3877 dump_rtl (".jump", decl, print_rtl, insns);
3879 /* Perform common subexpression elimination.
3880 Nonzero value from `cse_main' means that jumps were simplified
3881 and some code may now be unreachable, so do
3882 jump optimization again. */
3887 open_dump_file (".cse", decl_printable_name (decl, 2));
3889 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3891 if (flag_thread_jumps)
3892 /* Hacks by tiemann & kenner. */
3893 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3895 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3897 if (tem || optimize > 1)
3898 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3900 !JUMP_AFTER_REGSCAN));
3902 /* Run this after jump optmizations remove all the unreachable code
3903 so that unreachable code will not keep values live. */
3904 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3906 /* Dump rtl code after cse, if we are doing that. */
3910 close_dump_file (print_rtl, insns);
3911 if (graph_dump_format != no_graph)
3912 print_rtl_graph_with_bb (dump_base_name, ".cse", insns);
3916 purge_addressof (insns);
3917 reg_scan (insns, max_reg_num (), 1);
3921 dump_rtl (".addressof", decl, print_rtl, insns);
3922 if (graph_dump_format != no_graph)
3923 print_rtl_graph_with_bb (dump_base_name, ".addressof", insns);
3926 /* Perform global cse. */
3928 if (optimize > 0 && flag_gcse)
3931 open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl)));
3933 TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file));
3935 /* If gcse altered any jumps, rerun jump optimizations to clean
3939 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3941 !JUMP_AFTER_REGSCAN));
3946 close_dump_file (print_rtl, insns);
3947 if (graph_dump_format != no_graph)
3948 print_rtl_graph_with_bb (dump_base_name, ".gcse", insns);
3951 /* Move constant computations out of loops. */
3956 open_dump_file (".loop", decl_printable_name (decl, 2));
3961 if (flag_rerun_loop_opt)
3963 /* We only want to perform unrolling once. */
3965 loop_optimize (insns, rtl_dump_file, 0, 0);
3968 /* The first call to loop_optimize makes some instructions
3969 trivially dead. We delete those instructions now in the
3970 hope that doing so will make the heuristics in loop work
3971 better and possibly speed up compilation. */
3972 delete_trivially_dead_insns (insns, max_reg_num ());
3974 /* The regscan pass is currently necessary as the alias
3975 analysis code depends on this information. */
3976 reg_scan (insns, max_reg_num (), 1);
3978 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
3981 /* Dump rtl code after loop opt, if we are doing that. */
3985 close_dump_file (print_rtl, insns);
3986 if (graph_dump_format != no_graph)
3987 print_rtl_graph_with_bb (dump_base_name, ".loop", insns);
3994 open_dump_file (".cse2", decl_printable_name (decl, 2));
3996 if (flag_rerun_cse_after_loop)
3998 /* Running another jump optimization pass before the second
3999 cse pass sometimes simplifies the RTL enough to allow
4000 the second CSE pass to do a better job. Jump_optimize can change
4001 max_reg_num so we must rerun reg_scan afterwards.
4002 ??? Rework to not call reg_scan so often. */
4003 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
4004 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
4006 JUMP_AFTER_REGSCAN));
4008 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
4009 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
4012 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
4014 !JUMP_AFTER_REGSCAN));
4017 if (flag_thread_jumps)
4019 /* This pass of jump threading straightens out code
4020 that was kinked by loop optimization. */
4021 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
4022 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
4025 /* Dump rtl code after cse, if we are doing that. */
4029 close_dump_file (print_rtl, insns);
4030 if (graph_dump_format != no_graph)
4031 print_rtl_graph_with_bb (dump_base_name, ".cse2", insns);
4035 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
4037 if (branch_prob_dump)
4038 open_dump_file (".bp", decl_printable_name (decl, 2));
4043 branch_prob (insns, rtl_dump_file);
4046 if (branch_prob_dump)
4048 close_dump_file (print_rtl, insns);
4049 if (graph_dump_format != no_graph)
4050 print_rtl_graph_with_bb (dump_base_name, ".bp", insns);
4054 /* We are no longer anticipating cse in this function, at least. */
4056 cse_not_expected = 1;
4058 /* Now we choose between stupid (pcc-like) register allocation
4059 (if we got the -noreg switch and not -opt)
4060 and smart register allocation. */
4062 if (optimize > 0) /* Stupid allocation probably won't work */
4063 obey_regdecls = 0; /* if optimizations being done. */
4067 /* Print function header into flow dump now
4068 because doing the flow analysis makes some of the dump. */
4071 open_dump_file (".flow", decl_printable_name (decl, 2));
4077 regclass (insns, max_reg_num ());
4078 stupid_life_analysis (insns, max_reg_num (),
4084 /* Do control and data flow analysis,
4085 and write some of the results to dump file. */
4090 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4091 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4094 if (warn_uninitialized)
4096 uninitialized_vars_warning (DECL_INITIAL (decl));
4097 setjmp_args_warning ();
4101 /* Dump rtl after flow analysis. */
4105 close_dump_file (print_rtl_with_bb, insns);
4106 if (graph_dump_format != no_graph)
4107 print_rtl_graph_with_bb (dump_base_name, ".flow", insns);
4110 /* The first life analysis pass has finished. From now on we can not
4111 generate any new pseudos. */
4114 /* If -opt, try combining insns through substitution. */
4118 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
4120 /* Dump rtl code after insn combination. */
4124 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
4125 if (graph_dump_format != no_graph)
4126 print_rtl_graph_with_bb (dump_base_name, ".combine", insns);
4130 /* Register allocation pre-pass, to reduce number of moves
4131 necessary for two-address machines. */
4132 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
4135 open_dump_file (".regmove", decl_printable_name (decl, 2));
4137 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
4142 close_dump_file (print_rtl_with_bb, insns);
4143 if (graph_dump_format != no_graph)
4144 print_rtl_graph_with_bb (dump_base_name, ".regmove", insns);
4148 /* Print function header into sched dump now
4149 because doing the sched analysis makes some of the dump. */
4151 if (optimize > 0 && flag_schedule_insns)
4154 open_dump_file (".sched", decl_printable_name (decl, 2));
4156 /* Do control and data sched analysis,
4157 and write some of the results to dump file. */
4159 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
4161 /* Dump rtl after instruction scheduling. */
4165 close_dump_file (print_rtl_with_bb, insns);
4166 if (graph_dump_format != no_graph)
4167 print_rtl_graph_with_bb (dump_base_name, ".sched", insns);
4171 /* Determine if the current function is a leaf before running reload
4172 since this can impact optimizations done by the prologue and
4173 epilogue thus changing register elimination offsets. */
4174 current_function_is_leaf = leaf_function_p ();
4176 /* Unless we did stupid register allocation,
4177 allocate pseudo-regs that are used only within 1 basic block.
4179 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
4180 jump optimizer after register allocation and reloading are finished. */
4183 TIMEVAR (local_alloc_time,
4185 recompute_reg_usage (insns, ! optimize_size);
4186 regclass (insns, max_reg_num ());
4187 rebuild_label_notes_after_reload = local_alloc ();
4190 rebuild_label_notes_after_reload = 0;
4192 /* Dump rtl code after allocating regs within basic blocks. */
4196 open_dump_file (".lreg", decl_printable_name (decl, 2));
4198 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
4199 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
4201 close_dump_file (print_rtl_with_bb, insns);
4202 if (graph_dump_format != no_graph)
4203 print_rtl_graph_with_bb (dump_base_name, ".lreg", insns);
4206 if (global_reg_dump)
4207 open_dump_file (".greg", decl_printable_name (decl, 2));
4209 /* Unless we did stupid register allocation,
4210 allocate remaining pseudo-regs, then do the reload pass
4211 fixing up any insns that are invalid. */
4213 TIMEVAR (global_alloc_time,
4216 failure = global_alloc (rtl_dump_file);
4218 failure = reload (insns, 0, rtl_dump_file);
4223 goto exit_rest_of_compilation;
4225 /* Do a very simple CSE pass over just the hard registers. */
4227 reload_cse_regs (insns);
4229 /* Register allocation and reloading may have turned an indirect jump into
4230 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
4231 jumping instructions. */
4232 if (rebuild_label_notes_after_reload)
4233 TIMEVAR (jump_time, rebuild_jump_labels (insns));
4235 /* If optimizing and we are performing instruction scheduling after
4236 reload, then go ahead and split insns now since we are about to
4237 recompute flow information anyway.
4239 reload_cse_regs may expose more splitting opportunities, expecially
4240 for double-word operations. */
4241 if (optimize > 0 && flag_schedule_insns_after_reload)
4245 for (insn = insns; insn; insn = NEXT_INSN (insn))
4249 if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
4252 last = try_split (PATTERN (insn), insn, 1);
4256 PUT_CODE (insn, NOTE);
4257 NOTE_SOURCE_FILE (insn) = 0;
4258 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
4263 if (global_reg_dump)
4265 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
4266 close_dump_file (print_rtl_with_bb, insns);
4267 if (graph_dump_format != no_graph)
4268 print_rtl_graph_with_bb (dump_base_name, ".greg", insns);
4271 /* Re-create the death notes which were deleted during reload. */
4273 open_dump_file (".flow2", decl_printable_name (decl, 2));
4280 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4281 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4285 flow2_completed = 1;
4287 /* On some machines, the prologue and epilogue code, or parts thereof,
4288 can be represented as RTL. Doing so lets us schedule insns between
4289 it and the rest of the code and also allows delayed branch
4290 scheduling to operate in the epilogue. */
4292 thread_prologue_and_epilogue_insns (insns);
4296 close_dump_file (print_rtl_with_bb, insns);
4297 if (graph_dump_format != no_graph)
4298 print_rtl_graph_with_bb (dump_base_name, ".flow2", insns);
4301 if (optimize > 0 && flag_schedule_insns_after_reload)
4304 open_dump_file (".sched2", decl_printable_name (decl, 2));
4306 /* Do control and data sched analysis again,
4307 and write some more of the results to dump file. */
4309 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
4311 /* Dump rtl after post-reorder instruction scheduling. */
4315 close_dump_file (print_rtl_with_bb, insns);
4316 if (graph_dump_format != no_graph)
4317 print_rtl_graph_with_bb (dump_base_name, ".sched2", insns);
4321 #ifdef LEAF_REGISTERS
4322 current_function_uses_only_leaf_regs
4323 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
4326 /* One more attempt to remove jumps to .+1
4327 left by dead-store-elimination.
4328 Also do cross-jumping this time
4329 and delete no-op move insns. */
4333 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
4335 !JUMP_AFTER_REGSCAN));
4337 /* Dump rtl code after jump, if we are doing that. */
4341 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
4342 if (graph_dump_format != no_graph)
4343 print_rtl_graph_with_bb (dump_base_name, ".jump2", insns);
4347 /* If a machine dependent reorganization is needed, call it. */
4348 #ifdef MACHINE_DEPENDENT_REORG
4349 MACHINE_DEPENDENT_REORG (insns);
4351 if (mach_dep_reorg_dump)
4353 dump_rtl (".mach", decl, print_rtl_with_bb, insns);
4354 if (graph_dump_format != no_graph)
4355 print_rtl_graph_with_bb (dump_base_name, ".mach", insns);
4359 /* If a scheduling pass for delayed branches is to be done,
4360 call the scheduling code. */
4363 if (optimize > 0 && flag_delayed_branch)
4366 open_dump_file (".dbr", decl_printable_name (decl, 2));
4368 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
4372 close_dump_file (print_rtl_with_bb, insns);
4373 if (graph_dump_format != no_graph)
4374 print_rtl_graph_with_bb (dump_base_name, ".dbr", insns);
4379 /* Shorten branches. */
4380 TIMEVAR (shorten_branch_time,
4382 shorten_branches (get_insns ());
4387 open_dump_file (".stack", decl_printable_name (decl, 2));
4389 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
4393 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
4394 if (graph_dump_format != no_graph)
4395 print_rtl_graph_with_bb (dump_base_name, ".stack", insns);
4399 if (warn_frame_size_flag)
4400 if (get_frame_size () > warn_frame_size)
4401 warning ("%d byte frame exceeds user specified limit (%d bytes)",
4402 get_frame_size (), warn_frame_size);
4404 /* Now turn the rtl into assembler code. */
4406 TIMEVAR (final_time,
4411 /* Get the function's name, as described by its RTL.
4412 This may be different from the DECL_NAME name used
4413 in the source file. */
4415 x = DECL_RTL (decl);
4416 if (GET_CODE (x) != MEM)
4419 if (GET_CODE (x) != SYMBOL_REF)
4421 fnname = XSTR (x, 0);
4423 assemble_start_function (decl, fnname);
4424 final_start_function (insns, asm_out_file, optimize);
4425 final (insns, asm_out_file, optimize, 0);
4426 final_end_function (insns, asm_out_file, optimize);
4427 assemble_end_function (decl, fnname);
4429 fflush (asm_out_file);
4431 /* Release all memory allocated by flow. */
4432 free_basic_block_vars (0);
4434 /* Release all memory held by regsets now */
4435 regset_release_memory ();
4438 /* Write DBX symbols if requested */
4440 /* Note that for those inline functions where we don't initially
4441 know for certain that we will be generating an out-of-line copy,
4442 the first invocation of this routine (rest_of_compilation) will
4443 skip over this code by doing a `goto exit_rest_of_compilation;'.
4444 Later on, finish_compilation will call rest_of_compilation again
4445 for those inline functions that need to have out-of-line copies
4446 generated. During that call, we *will* be routed past here. */
4448 #ifdef DBX_DEBUGGING_INFO
4449 if (write_symbols == DBX_DEBUG)
4450 TIMEVAR (symout_time, dbxout_function (decl));
4453 #ifdef DWARF_DEBUGGING_INFO
4454 if (write_symbols == DWARF_DEBUG)
4455 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
4458 #ifdef DWARF2_DEBUGGING_INFO
4459 if (write_symbols == DWARF2_DEBUG)
4460 TIMEVAR (symout_time, dwarf2out_decl (decl));
4463 exit_rest_of_compilation:
4467 /* In case the function was not output,
4468 don't leave any temporary anonymous types
4469 queued up for sdb output. */
4470 #ifdef SDB_DEBUGGING_INFO
4471 if (write_symbols == SDB_DEBUG)
4472 sdbout_types (NULL_TREE);
4475 /* Put back the tree of subblocks and list of arguments
4476 from before we copied them.
4477 Code generation and the output of debugging info may have modified
4478 the copy, but the original is unchanged. */
4480 if (saved_block_tree != 0)
4482 DECL_INITIAL (decl) = saved_block_tree;
4483 DECL_ARGUMENTS (decl) = saved_arguments;
4484 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
4487 reload_completed = 0;
4488 flow2_completed = 0;
4491 TIMEVAR (final_time,
4493 /* Clear out the insn_length contents now that they are no
4495 init_insn_lengths ();
4497 /* Clear out the real_constant_chain before some of the rtx's
4498 it runs through become garbage. */
4499 clear_const_double_mem ();
4501 /* Cancel the effect of rtl_in_current_obstack. */
4502 resume_temporary_allocation ();
4504 /* Show no temporary slots allocated. */
4508 /* Make sure volatile mem refs aren't considered valid operands for
4509 arithmetic insns. We must call this here if this is a nested inline
4510 function, since the above code leaves us in the init_recog state
4511 (from final.c), and the function context push/pop code does not
4512 save/restore volatile_ok.
4514 ??? Maybe it isn't necessary for expand_start_function to call this
4515 anymore if we do it here? */
4517 init_recog_no_volatile ();
4519 /* The parsing time is all the time spent in yyparse
4520 *except* what is spent in this function. */
4522 parse_time -= get_run_time () - start_time;
4524 /* Reset global variables. */
4525 free_basic_block_vars (0);
4536 printf ("Usage: %s input [switches]\n", progname);
4537 printf ("Switches:\n");
4539 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
4540 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
4541 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4542 printf (" -finline-limit-<number> Limits the size of inlined functions to <number>\n");
4544 for (i = NUM_ELEM (f_options); i--;)
4546 const char * description = f_options[i].description;
4548 if (description != NULL && * description != 0)
4549 printf (" -f%-21s %s\n",
4550 f_options[i].string, description);
4553 printf (" -O[number] Set optimisation level to [number]\n");
4554 printf (" -Os Optimise for space rather than speed\n");
4555 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
4556 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
4557 printf (" -w Suppress warnings\n");
4558 printf (" -W Enable extra warnings\n");
4560 for (i = NUM_ELEM (W_options); i--;)
4562 const char * description = W_options[i].description;
4564 if (description != NULL && * description != 0)
4565 printf (" -W%-21s %s\n",
4566 W_options[i].string, description);
4569 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4570 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4571 printf (" -p Enable function profiling\n");
4572 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4573 printf (" -a Enable block profiling \n");
4575 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4576 printf (" -ax Enable jump profiling \n");
4578 printf (" -o <file> Place output into <file> \n");
4579 printf (" -G <number> Put global and static data smaller than <number>\n");
4580 printf (" bytes into a special section (on some targets)\n");
4582 for (i = NUM_ELEM (debug_args); i--;)
4584 if (debug_args[i].description != NULL)
4585 printf (" -%-22s %s\n", debug_args[i].arg, debug_args[i].description);
4588 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4589 printf (" -quiet Do not display functions compiled or elapsed time\n");
4590 printf (" -version Display the compiler's version\n");
4591 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4592 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4593 #if defined HAIFA || defined INSN_SCHEDULING
4594 printf (" -sched-verbose-<number> Set the verbosity level of the scheduler\n");
4596 printf (" --help Display this information\n");
4601 /* Display descriptions of language specific options.
4602 If there is no description, note that there is an undocumented option.
4603 If the description is empty, do not display anything. (This allows
4604 options to be deliberately undocumented, for whatever reason).
4605 If the option string is missing, then this is a marker, indicating
4606 that the description string is in fact the name of a language, whose
4607 language specific options are to follow. */
4609 if (NUM_ELEM (documented_lang_options) > 1)
4611 printf ("\nLanguage specific options:\n");
4613 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
4615 const char * description = documented_lang_options[i].description;
4616 const char * option = documented_lang_options[i].option;
4618 if (description == NULL)
4623 printf (" %-23.23s [undocumented]\n", option);
4625 else if (* description == 0)
4627 else if (option == NULL)
4631 ("\nThere are undocumented %s specific options as well.\n",
4635 printf ("\n Options for %s:\n", description);
4640 printf (" %-23.23s %s\n", option, description);
4645 printf ("\nThere are undocumented %s specific options as well.\n", lang);
4647 if (NUM_ELEM (target_switches) > 1
4648 #ifdef TARGET_OPTIONS
4649 || NUM_ELEM (target_options) > 1
4657 printf ("\nTarget specific options:\n");
4659 for (i = NUM_ELEM (target_switches); i--;)
4661 const char * option = target_switches[i].name;
4662 const char * description = target_switches[i].description;
4664 if (option == NULL || * option == 0)
4666 else if (description == NULL)
4671 printf (" -m%-21.21s [undocumented]\n", option);
4673 else if (* description != 0)
4674 doc += printf (" -m%-21.21s %s\n", option, description);
4677 #ifdef TARGET_OPTIONS
4678 for (i = NUM_ELEM (target_options); i--;)
4680 const char * option = target_options[i].prefix;
4681 const char * description = target_options[i].description;
4683 if (option == NULL || * option == 0)
4685 else if (description == NULL)
4690 printf (" -m%-21.21s [undocumented]\n", option);
4692 else if (* description != 0)
4693 doc += printf (" -m%-21.21s %s\n", option, description);
4699 printf ("\nThere are undocumented target specific options as well.\n");
4701 printf (" They exist, but they are not documented.\n");
4706 /* Compare the user specified 'option' with the language
4707 specific 'lang_option'. Return true if they match, or
4708 if 'option' is a viable prefix of 'lang_option'. */
4711 check_lang_option (option, lang_option)
4715 lang_independent_options * indep_options;
4721 /* Ignore NULL entries. */
4722 if (option == NULL || lang_option == NULL)
4725 if ((space = strchr (lang_option, ' ')) != NULL)
4726 len = space - lang_option;
4727 else if ((space = strchr (lang_option, '<')) != NULL)
4728 len = space - lang_option;
4730 len = strlen (lang_option);
4732 /* If they do not match to the first n characters then fail. */
4733 if (strncmp (option, lang_option, len) != 0)
4736 /* Do not accept a lang option, if it matches a normal -f or -W
4737 option. Chill defines a -fpack, but we want to support
4740 /* An exact match is OK */
4741 if ((int) strlen (option) == len)
4744 /* If it is not an -f or -W option allow the match */
4745 if (option[0] != '-')
4751 indep_options = f_options;
4752 numopts = NUM_ELEM (f_options);
4755 indep_options = W_options;
4756 numopts = NUM_ELEM (W_options);
4761 /* The option is a -f or -W option.
4762 Skip past the prefix and search for the remainder in the
4763 appropriate table of options. */
4766 if (option[0] == 'n' && option[1] == 'o' && option[2] == '-')
4769 for (k = numopts; k--;)
4771 if (!strcmp (option, indep_options[k].string))
4773 /* The option matched a language independent option,
4774 do not allow the language specific match. */
4780 /* The option matches the start of the langauge specific option
4781 and it is not an exact match for a language independent option. */
4785 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4786 Exit code is 35 if can't open files, 34 if fatal error,
4787 33 if had nonfatal errors, else success. */
4796 int flag_print_mem = 0;
4797 int version_flag = 0;
4800 /* save in case md file wants to emit args as a comment. */
4804 p = argv[0] + strlen (argv[0]);
4805 while (p != argv[0] && p[-1] != '/'
4806 #ifdef DIR_SEPARATOR
4807 && p[-1] != DIR_SEPARATOR
4813 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
4814 /* Get rid of any avoidable limit on stack size. */
4818 /* Set the stack limit huge so that alloca does not fail. */
4819 getrlimit (RLIMIT_STACK, &rlim);
4820 rlim.rlim_cur = rlim.rlim_max;
4821 setrlimit (RLIMIT_STACK, &rlim);
4825 #ifdef HAVE_LC_MESSAGES
4826 setlocale (LC_MESSAGES, "");
4828 (void) bindtextdomain (PACKAGE, localedir);
4829 (void) textdomain (PACKAGE);
4831 signal (SIGFPE, float_signal);
4834 signal (SIGPIPE, pipe_closed);
4837 decl_printable_name = decl_name;
4838 lang_expand_expr = (lang_expand_expr_t) do_abort;
4840 /* Initialize whether `char' is signed. */
4841 flag_signed_char = DEFAULT_SIGNED_CHAR;
4842 #ifdef DEFAULT_SHORT_ENUMS
4843 /* Initialize how much space enums occupy, by default. */
4844 flag_short_enums = DEFAULT_SHORT_ENUMS;
4847 /* Perform language-specific options intialization. */
4848 lang_init_options ();
4850 /* Scan to see what optimization level has been specified. That will
4851 determine the default value of many flags. */
4852 for (i = 1; i < argc; i++)
4854 if (!strcmp (argv[i], "-O"))
4859 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4861 /* Handle -Os, -O2, -O3, -O69, ... */
4862 char *p = &argv[i][2];
4864 if ((p[0] == 's') && (p[1] == 0))
4868 /* Optimizing for size forces optimize to be 2. */
4873 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4874 if (optimize_val != -1)
4876 optimize = optimize_val;
4877 #ifdef FORCE_OPTIMIZATION_DOWNGRADE
4878 #warning FORCE_OPTIMIZATION_DOWNGRADE
4879 if (optimize > FORCE_OPTIMIZATION_DOWNGRADE)
4881 optimize = FORCE_OPTIMIZATION_DOWNGRADE;
4882 warning ("\n***\n***\t-O%d converted to \"-O%d\" due to optimizer bugs on this platform\n***",
4884 FORCE_OPTIMIZATION_DOWNGRADE);
4887 #endif /*FORCE_OPTIMIZATION_DOWNGRADE*/
4888 #if defined(__alpha__)
4891 warning ("\n***\n***\tThe -O%d flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM\n***",
4894 #endif /*__alpha__*/
4901 obey_regdecls = (optimize == 0);
4906 flag_thread_jumps = 1;
4908 flag_delayed_branch = 1;
4910 #ifdef CAN_DEBUG_WITHOUT_FP
4911 flag_omit_frame_pointer = 1;
4917 flag_cse_follow_jumps = 1;
4918 flag_cse_skip_blocks = 1;
4920 flag_expensive_optimizations = 1;
4921 flag_strength_reduce = 1;
4922 flag_rerun_cse_after_loop = 1;
4923 flag_rerun_loop_opt = 1;
4924 flag_caller_saves = 1;
4926 #ifdef INSN_SCHEDULING
4927 flag_schedule_insns = 1;
4928 flag_schedule_insns_after_reload = 1;
4935 flag_inline_functions = 1;
4938 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4941 set_target_switch ("");
4943 #ifdef OPTIMIZATION_OPTIONS
4944 /* Allow default optimizations to be specified on a per-machine basis. */
4945 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4948 /* Initialize register usage now so switches may override. */
4951 for (i = 1; i < argc; i++)
4955 /* If this is a language-specific option,
4956 decode it in a language-specific way. */
4957 for (j = NUM_ELEM (documented_lang_options); j--;)
4958 if (check_lang_option (argv[i], documented_lang_options[j].option))
4961 if (j != (size_t)-1)
4963 /* If the option is valid for *some* language,
4964 treat it as valid even if this language doesn't understand it. */
4965 int strings_processed = lang_decode_option (argc - i, argv + i);
4967 if (!strcmp (argv[i], "--help"))
4973 if (strings_processed != 0)
4974 i += strings_processed - 1;
4976 else if (argv[i][0] == '-' && argv[i][1] != 0)
4978 register char *str = argv[i] + 1;
4983 set_target_switch (&str[1]);
4984 else if (!strcmp (str, "dumpbase"))
4986 dump_base_name = argv[++i];
4988 else if (str[0] == 'd')
4990 register char *p = &str[1];
4995 branch_prob_dump = 1;
5002 global_reg_dump = 1;
5010 cse_dump = 1, cse2_dump = 1;
5017 #ifdef MACHINE_DEPENDENT_REORG
5018 mach_dep_reorg_dump = 1;
5025 branch_prob_dump = 1;
5042 global_reg_dump = 1;
5067 #ifdef MACHINE_DEPENDENT_REORG
5069 mach_dep_reorg_dump = 1;
5073 flag_print_asm_name = 1;
5094 graph_dump_format = vcg;
5103 rtl_dump_and_exit = 1;
5105 case 'D': /* these are handled by the preprocessor */
5109 warning ("unrecognised gcc debugging option: %c", p[-1]);
5113 else if (str[0] == 'f')
5115 register char *p = &str[1];
5118 /* Some kind of -f option.
5119 P's value is the option sans `-f'.
5120 Search for it in the table of options. */
5123 !found && j < sizeof (f_options) / sizeof (f_options[0]);
5126 if (!strcmp (p, f_options[j].string))
5128 *f_options[j].variable = f_options[j].on_value;
5129 /* A goto here would be cleaner,
5130 but breaks the vax pcc. */
5133 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
5134 && ! strcmp (p+3, f_options[j].string))
5136 *f_options[j].variable = ! f_options[j].on_value;
5143 else if (!strncmp (p, "inline-limit-", 13))
5145 read_integral_parameter (p + 13, p - 2, inline_max_insns);
5147 #ifdef INSN_SCHEDULING
5148 else if (!strncmp (p, "sched-verbose-",14))
5149 fix_sched_param("verbose",&p[14]);
5152 else if (!strncmp (p, "fixed-", 6))
5153 fix_register (&p[6], 1, 1);
5154 else if (!strncmp (p, "call-used-", 10))
5155 fix_register (&p[10], 0, 1);
5156 else if (!strncmp (p, "call-saved-", 11))
5157 fix_register (&p[11], 0, 0);
5159 error ("Invalid option `%s'", argv[i]);
5161 else if (str[0] == 'O')
5163 /* Already been treated above. Do nothing. */
5165 else if (!strcmp (str, "pedantic"))
5167 else if (!strcmp (str, "pedantic-errors"))
5168 flag_pedantic_errors = pedantic = 1;
5169 else if (!strcmp (str, "quiet"))
5171 else if (!strcmp (str, "version"))
5173 else if (!strcmp (str, "w"))
5174 inhibit_warnings = 1;
5175 else if (!strcmp (str, "W"))
5178 /* We save the value of warn_uninitialized, since if they put
5179 -Wuninitialized on the command line, we need to generate a
5180 warning about not using it without also specifying -O. */
5181 if (warn_uninitialized != 1)
5182 warn_uninitialized = 2;
5184 else if (str[0] == 'W')
5186 register char *p = &str[1];
5189 /* Some kind of -W option.
5190 P's value is the option sans `-W'.
5191 Search for it in the table of options. */
5194 !found && j < sizeof (W_options) / sizeof (W_options[0]);
5197 if (!strcmp (p, W_options[j].string))
5199 *W_options[j].variable = W_options[j].on_value;
5200 /* A goto here would be cleaner,
5201 but breaks the vax pcc. */
5204 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
5205 && ! strcmp (p+3, W_options[j].string))
5207 *W_options[j].variable = ! W_options[j].on_value;
5214 else if (!strncmp (p, "id-clash-", 9))
5216 const int id_clash_val
5217 = read_integral_parameter (p + 9, p - 2, -1);
5218 if (id_clash_val != -1)
5220 id_clash_len = id_clash_val;
5224 else if (!strncmp (p, "larger-than-", 12))
5226 const int larger_than_val
5227 = read_integral_parameter (p + 12, p - 2, -1);
5228 if (larger_than_val != -1)
5230 larger_than_size = larger_than_val;
5231 warn_larger_than = 1;
5235 error ("Invalid option `%s'", argv[i]);
5237 else if (!strcmp (str, "p"))
5241 else if (!strcmp (str, "a"))
5243 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5244 warning ("`-a' option (basic block profile) not supported");
5246 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
5249 else if (!strcmp (str, "ax"))
5251 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5252 warning ("`-ax' option (jump profiling) not supported");
5254 profile_block_flag = (!profile_block_flag
5255 || profile_block_flag == 2) ? 2 : 3;
5258 else if (str[0] == 'g')
5261 /* A lot of code assumes write_symbols == NO_DEBUG if the
5262 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
5263 of what debugging type has been selected). This records the
5264 selected type. It is an error to specify more than one
5266 static enum debug_info_type selected_debug_type = NO_DEBUG;
5267 /* Non-zero if debugging format has been explicitly set.
5268 -g and -ggdb don't explicitly set the debugging format so
5269 -gdwarf -g3 is equivalent to -gdwarf3. */
5270 static int type_explicitly_set_p = 0;
5271 /* Indexed by enum debug_info_type. */
5272 static const char *debug_type_names[] =
5274 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
5277 /* The maximum admissible debug level value. */
5278 static const unsigned max_debug_level = 3;
5280 /* Look up STR in the table. */
5281 for (da = debug_args; da->arg; da++)
5283 const int da_len = strlen (da->arg);
5285 if (! strncmp (str, da->arg, da_len))
5287 enum debug_info_type type = da->debug_type;
5288 const char *p = str + da_len;
5290 if (*p && (*p < '0' || *p > '9'))
5293 /* A debug flag without a level defaults to level 2.
5294 Note we do not want to call read_integral_parameter
5295 for that case since it will call atoi which
5298 ??? We may want to generalize the interface to
5299 read_integral_parameter to better handle this case
5300 if this case shows up often. */
5302 level = read_integral_parameter (p, 0,
5303 max_debug_level + 1);
5307 if (da_len > 1 && *p && !strncmp (str, "gdwarf", da_len))
5309 error ("use -gdwarf -g%d for DWARF v1, level %d",
5312 error ("use -gdwarf-2 for DWARF v2");
5315 if (level > max_debug_level)
5317 warning ("ignoring option `%s' due to invalid debug level specification",
5319 level = debug_info_level;
5322 if (type == NO_DEBUG)
5324 type = PREFERRED_DEBUGGING_TYPE;
5325 if (da_len > 1 && strncmp (str, "ggdb", da_len) == 0)
5327 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
5328 type = DWARF2_DEBUG;
5330 #ifdef DBX_DEBUGGING_INFO
5337 if (type == NO_DEBUG)
5338 warning ("`-%s' not supported by this configuration of GCC",
5341 /* Does it conflict with an already selected type? */
5342 if (type_explicitly_set_p
5343 /* -g/-ggdb don't conflict with anything */
5344 && da->debug_type != NO_DEBUG
5345 && type != selected_debug_type)
5346 warning ("`-%s' ignored, conflicts with `-g%s'",
5347 str, debug_type_names[(int) selected_debug_type]);
5350 /* If the format has already been set, -g/-ggdb
5351 only change the debug level. */
5352 if (type_explicitly_set_p
5353 && da->debug_type == NO_DEBUG)
5354 ; /* don't change debugging type */
5357 selected_debug_type = type;
5358 type_explicitly_set_p = da->debug_type != NO_DEBUG;
5360 write_symbols = (level == 0
5362 : selected_debug_type);
5363 use_gnu_debug_info_extensions = da->use_extensions_p;
5364 debug_info_level = (enum debug_info_level) level;
5370 warning ("`-%s' not supported by this configuration of GCC",
5373 else if (!strcmp (str, "o"))
5375 asm_file_name = argv[++i];
5377 else if (str[0] == 'G')
5379 const int g_switch_val = (str[1] != '\0') ?
5380 read_integral_parameter(str + 1, 0, -1) :
5381 read_integral_parameter(argv[++i], 0, -1);
5383 if (g_switch_val != -1)
5385 g_switch_set = TRUE;
5386 g_switch_value = g_switch_val;
5390 error("Invalid option `-%s'",str);
5393 else if (!strncmp (str, "aux-info", 8))
5395 flag_gen_aux_info = 1;
5396 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
5398 else if (!strcmp (str, "-help"))
5404 error ("Invalid option `%s'", argv[i]);
5406 else if (argv[i][0] == '+')
5407 error ("Invalid option `%s'", argv[i]);
5412 /* Checker uses the frame pointer. */
5413 if (flag_check_memory_usage)
5414 flag_omit_frame_pointer = 0;
5418 /* Inlining does not work if not optimizing,
5419 so force it not to be done. */
5423 /* The c_decode_option and lang_decode_option functions set
5424 this to `2' if -Wall is used, so we can avoid giving out
5425 lots of errors for people who don't realize what -Wall does. */
5426 if (warn_uninitialized == 1)
5427 warning ("-Wuninitialized is not supported without -O");
5430 #ifdef OVERRIDE_OPTIONS
5431 /* Some machines may reject certain combinations of options. */
5435 if (exceptions_via_longjmp == 2)
5437 #ifdef DWARF2_UNWIND_INFO
5438 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
5440 exceptions_via_longjmp = 1;
5444 if (profile_block_flag == 3)
5446 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
5447 profile_block_flag = 2;
5450 /* Unrolling all loops implies that standard loop unrolling must also
5452 if (flag_unroll_all_loops)
5453 flag_unroll_loops = 1;
5454 /* Loop unrolling requires that strength_reduction be on also. Silently
5455 turn on strength reduction here if it isn't already on. Also, the loop
5456 unrolling code assumes that cse will be run after loop, so that must
5457 be turned on also. */
5458 if (flag_unroll_loops)
5460 flag_strength_reduce = 1;
5461 flag_rerun_cse_after_loop = 1;
5464 /* Warn about options that are not supported on this machine. */
5465 #ifndef INSN_SCHEDULING
5466 if (flag_schedule_insns || flag_schedule_insns_after_reload)
5467 warning ("instruction scheduling not supported on this target machine");
5470 if (flag_delayed_branch)
5471 warning ("this target machine does not have delayed branches");
5474 user_label_prefix = USER_LABEL_PREFIX;
5475 if (flag_leading_underscore != -1)
5477 /* If the default prefix is more complicated than "" or "_",
5478 issue a warning and ignore this option. */
5479 if (user_label_prefix[0] == 0 ||
5480 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5482 user_label_prefix = flag_leading_underscore ? "_" : "";
5485 warning ("-f%sleading-underscore not supported on this target machine",
5486 flag_leading_underscore ? "" : "no-");
5489 /* If we are in verbose mode, write out the version and maybe all the
5490 option flags in use. */
5493 print_version (stderr, "");
5495 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5498 compile_file (filename);
5500 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
5503 char *lim = (char *) sbrk (0);
5505 notice ("Data size %ld.\n", (long) (lim - (char *) &environ));
5510 system ("ps -l 1>&2");
5513 #endif /* not USG */
5516 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
5519 exit (FATAL_EXIT_CODE);
5521 exit (FATAL_EXIT_CODE);
5522 exit (SUCCESS_EXIT_CODE);
5526 /* Decode -m switches. */
5527 /* Decode the switch -mNAME. */
5530 set_target_switch (name)
5534 int valid_target_option = 0;
5536 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5537 if (!strcmp (target_switches[j].name, name))
5539 if (target_switches[j].value < 0)
5540 target_flags &= ~-target_switches[j].value;
5542 target_flags |= target_switches[j].value;
5543 valid_target_option = 1;
5546 #ifdef TARGET_OPTIONS
5547 if (!valid_target_option)
5548 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5550 int len = strlen (target_options[j].prefix);
5551 if (!strncmp (target_options[j].prefix, name, len))
5553 *target_options[j].variable = name + len;
5554 valid_target_option = 1;
5559 if (!valid_target_option)
5560 error ("Invalid option `%s'", name);
5563 /* Print version information to FILE.
5564 Each line begins with INDENT (for the case where FILE is the
5565 assembler output file). */
5568 print_version (file, indent)
5573 #define __VERSION__ "[?]"
5577 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
5579 "%s%s%s version %s (%s) compiled by CC.\n"
5581 , indent, *indent != 0 ? " " : "",
5582 language_string, version_string, TARGET_NAME, __VERSION__);
5585 /* Print an option value and return the adjusted position in the line.
5586 ??? We don't handle error returns from fprintf (disk full); presumably
5587 other code will catch a disk full though. */
5590 print_single_switch (file, pos, max, indent, sep, term, type, name)
5593 const char *indent, *sep, *term, *type, *name;
5595 /* The ultrix fprintf returns 0 on success, so compute the result we want
5596 here since we need it for the following test. */
5597 int len = strlen (sep) + strlen (type) + strlen (name);
5602 fprintf (file, "%s", term);
5607 fprintf (file, "%s", indent);
5608 pos = strlen (indent);
5610 fprintf (file, "%s%s%s", sep, type, name);
5615 /* Print active target switches to FILE.
5616 POS is the current cursor position and MAX is the size of a "line".
5617 Each line begins with INDENT and ends with TERM.
5618 Each switch is separated from the next by SEP. */
5621 print_switch_values (file, pos, max, indent, sep, term)
5624 const char *indent, *sep, *term;
5629 /* Print the options as passed. */
5631 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5632 _("options passed: "), "");
5634 for (p = &save_argv[1]; *p != NULL; p++)
5638 if (strcmp (*p, "-o") == 0)
5644 if (strcmp (*p, "-quiet") == 0)
5646 if (strcmp (*p, "-version") == 0)
5651 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5654 fprintf (file, "%s", term);
5656 /* Print the -f and -m options that have been enabled.
5657 We don't handle language specific options but printing argv
5660 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5661 _("options enabled: "), "");
5663 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
5664 if (*f_options[j].variable == f_options[j].on_value)
5665 pos = print_single_switch (file, pos, max, indent, sep, term,
5666 "-f", f_options[j].string);
5668 /* Print target specific options. */
5670 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5671 if (target_switches[j].name[0] != '\0'
5672 && target_switches[j].value > 0
5673 && ((target_switches[j].value & target_flags)
5674 == target_switches[j].value))
5676 pos = print_single_switch (file, pos, max, indent, sep, term,
5677 "-m", target_switches[j].name);
5680 #ifdef TARGET_OPTIONS
5681 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5682 if (*target_options[j].variable != NULL)
5685 sprintf (prefix, "-m%s", target_options[j].prefix);
5686 pos = print_single_switch (file, pos, max, indent, sep, term,
5687 prefix, *target_options[j].variable);
5691 fprintf (file, "%s", term);
5694 /* Record the beginning of a new source file, named FILENAME. */
5697 debug_start_source_file (filename)
5698 register char *filename ATTRIBUTE_UNUSED;
5700 #ifdef DBX_DEBUGGING_INFO
5701 if (write_symbols == DBX_DEBUG)
5702 dbxout_start_new_source_file (filename);
5704 #ifdef DWARF_DEBUGGING_INFO
5705 if (debug_info_level == DINFO_LEVEL_VERBOSE
5706 && write_symbols == DWARF_DEBUG)
5707 dwarfout_start_new_source_file (filename);
5708 #endif /* DWARF_DEBUGGING_INFO */
5709 #ifdef DWARF2_DEBUGGING_INFO
5710 if (debug_info_level == DINFO_LEVEL_VERBOSE
5711 && write_symbols == DWARF2_DEBUG)
5712 dwarf2out_start_source_file (filename);
5713 #endif /* DWARF2_DEBUGGING_INFO */
5714 #ifdef SDB_DEBUGGING_INFO
5715 if (write_symbols == SDB_DEBUG)
5716 sdbout_start_new_source_file (filename);
5720 /* Record the resumption of a source file. LINENO is the line number in
5721 the source file we are returning to. */
5724 debug_end_source_file (lineno)
5725 register unsigned lineno ATTRIBUTE_UNUSED;
5727 #ifdef DBX_DEBUGGING_INFO
5728 if (write_symbols == DBX_DEBUG)
5729 dbxout_resume_previous_source_file ();
5731 #ifdef DWARF_DEBUGGING_INFO
5732 if (debug_info_level == DINFO_LEVEL_VERBOSE
5733 && write_symbols == DWARF_DEBUG)
5734 dwarfout_resume_previous_source_file (lineno);
5735 #endif /* DWARF_DEBUGGING_INFO */
5736 #ifdef DWARF2_DEBUGGING_INFO
5737 if (debug_info_level == DINFO_LEVEL_VERBOSE
5738 && write_symbols == DWARF2_DEBUG)
5739 dwarf2out_end_source_file ();
5740 #endif /* DWARF2_DEBUGGING_INFO */
5741 #ifdef SDB_DEBUGGING_INFO
5742 if (write_symbols == SDB_DEBUG)
5743 sdbout_resume_previous_source_file ();
5747 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5748 the tail part of the directive line, i.e. the part which is past the
5749 initial whitespace, #, whitespace, directive-name, whitespace part. */
5752 debug_define (lineno, buffer)
5753 register unsigned lineno ATTRIBUTE_UNUSED;
5754 register char *buffer ATTRIBUTE_UNUSED;
5756 #ifdef DWARF_DEBUGGING_INFO
5757 if (debug_info_level == DINFO_LEVEL_VERBOSE
5758 && write_symbols == DWARF_DEBUG)
5759 dwarfout_define (lineno, buffer);
5760 #endif /* DWARF_DEBUGGING_INFO */
5761 #ifdef DWARF2_DEBUGGING_INFO
5762 if (debug_info_level == DINFO_LEVEL_VERBOSE
5763 && write_symbols == DWARF2_DEBUG)
5764 dwarf2out_define (lineno, buffer);
5765 #endif /* DWARF2_DEBUGGING_INFO */
5768 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5769 the tail part of the directive line, i.e. the part which is past the
5770 initial whitespace, #, whitespace, directive-name, whitespace part. */
5773 debug_undef (lineno, buffer)
5774 register unsigned lineno ATTRIBUTE_UNUSED;
5775 register char *buffer ATTRIBUTE_UNUSED;
5777 #ifdef DWARF_DEBUGGING_INFO
5778 if (debug_info_level == DINFO_LEVEL_VERBOSE
5779 && write_symbols == DWARF_DEBUG)
5780 dwarfout_undef (lineno, buffer);
5781 #endif /* DWARF_DEBUGGING_INFO */
5782 #ifdef DWARF2_DEBUGGING_INFO
5783 if (debug_info_level == DINFO_LEVEL_VERBOSE
5784 && write_symbols == DWARF2_DEBUG)
5785 dwarf2out_undef (lineno, buffer);
5786 #endif /* DWARF2_DEBUGGING_INFO */