1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This is the top level of cc1/c++.
22 It parses command args, opens files, invokes the various passes
23 in the proper order, and counts the time used by each.
24 Error messages and low-level interface to malloc also handled here. */
27 #undef FLOAT /* This is for hpux. They should change hpux. */
28 #undef FFS /* Some systems define this in param.h. */
33 #ifdef HAVE_SYS_RESOURCE_H
34 # include <sys/resource.h>
37 #ifdef HAVE_SYS_TIMES_H
38 # include <sys/times.h>
46 #include "insn-attr.h"
47 #include "insn-codes.h"
48 #include "insn-config.h"
56 #include "basic-block.h"
61 #ifdef DWARF_DEBUGGING_INFO
65 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
66 #include "dwarf2out.h"
69 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
73 #ifdef SDB_DEBUGGING_INFO
77 #ifdef XCOFF_DEBUGGING_INFO
82 /* The extra parameters substantially improve the I/O performance. */
84 vms_fopen (fname, type)
88 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
89 fixed arguments, which matches ANSI's specification but not VAXCRTL's
90 pre-ANSI implementation. This hack circumvents the mismatch problem. */
91 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
94 return (*vmslib_fopen) (fname, type, "mbc=32",
95 "deq=64", "fop=tef", "shr=nil");
97 return (*vmslib_fopen) (fname, type, "mbc=32");
99 #define fopen vms_fopen
102 #ifndef DEFAULT_GDB_EXTENSIONS
103 #define DEFAULT_GDB_EXTENSIONS 1
106 /* If more than one debugging type is supported, you must define
107 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
109 This is one long line cause VAXC can't handle a \-newline. */
110 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
111 #ifndef PREFERRED_DEBUGGING_TYPE
112 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
113 #endif /* no PREFERRED_DEBUGGING_TYPE */
114 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
115 so the following code needn't care. */
116 #ifdef DBX_DEBUGGING_INFO
117 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
119 #ifdef SDB_DEBUGGING_INFO
120 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
122 #ifdef DWARF_DEBUGGING_INFO
123 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
125 #ifdef DWARF2_DEBUGGING_INFO
126 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
128 #ifdef XCOFF_DEBUGGING_INFO
129 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
131 #endif /* More than one debugger format enabled. */
133 /* If still not defined, must have been because no debugging formats
135 #ifndef PREFERRED_DEBUGGING_TYPE
136 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
139 #ifndef DIR_SEPARATOR
140 #define DIR_SEPARATOR '/'
143 #if ! (defined (VMS) || defined (OS2))
144 extern char **environ;
146 extern char *version_string;
148 /* Carry information from ASM_DECLARE_OBJECT_NAME
149 to ASM_FINISH_DECLARE_OBJECT. */
151 extern int size_directive_output;
152 extern tree last_assemble_variable_decl;
154 static void notice PVPROTO((const char *s, ...)) ATTRIBUTE_PRINTF_1;
155 static void set_target_switch PROTO((const char *));
156 static const char *decl_name PROTO((tree, int));
157 static void vmessage PROTO((const char *, const char *, va_list));
158 static void v_message_with_file_and_line PROTO((const char *, int, int,
159 const char *, va_list));
160 static void v_message_with_decl PROTO((tree, int, const char *, va_list));
161 static void file_and_line_for_asm PROTO((rtx, char **, int *));
162 static void v_error_with_file_and_line PROTO((const char *, int,
163 const char *, va_list));
164 static void v_error_with_decl PROTO((tree, const char *, va_list));
165 static void v_error_for_asm PROTO((rtx, const char *, va_list));
166 static void verror PROTO((const char *, va_list));
167 static void vfatal PROTO((const char *, va_list)) ATTRIBUTE_NORETURN;
168 static void v_warning_with_file_and_line PROTO ((const char *, int,
169 const char *, va_list));
170 static void v_warning_with_decl PROTO((tree, const char *, va_list));
171 static void v_warning_for_asm PROTO((rtx, const char *, va_list));
172 static void vwarning PROTO((const char *, va_list));
173 static void vpedwarn PROTO((const char *, va_list));
174 static void v_pedwarn_with_decl PROTO((tree, const char *, va_list));
175 static void v_pedwarn_with_file_and_line PROTO((const char *, int,
176 const char *, va_list));
177 static void vsorry PROTO((const char *, va_list));
178 extern void set_fatal_function PROTO((void (*)(const char *, va_list)));
179 static void float_signal PROTO((int)) ATTRIBUTE_NORETURN;
180 static void pipe_closed PROTO((int)) ATTRIBUTE_NORETURN;
181 #ifdef ASM_IDENTIFY_LANGUAGE
182 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
183 static void output_lang_identify PROTO((FILE *)) ATTRIBUTE_UNUSED;
185 static void open_dump_file PROTO((const char *, const char *));
186 static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
187 static void dump_rtl PROTO((const char *, tree, void (*) (FILE *, rtx), rtx));
188 static void clean_dump_file PROTO((const char *));
189 static void compile_file PROTO((char *));
190 static void display_help PROTO ((void));
191 static void report_file_and_line PROTO ((const char *, int, int));
192 static void vnotice PROTO ((FILE *, const char *, va_list));
193 static void mark_file_stack PROTO ((void *));
195 static void decode_d_option PROTO ((const char *));
196 static int decode_f_option PROTO ((const char *));
197 static int decode_W_option PROTO ((const char *));
198 static int decode_g_option PROTO ((const char *));
199 static unsigned independent_decode_option PROTO ((int, char **, unsigned));
201 static void print_version PROTO((FILE *, const char *));
202 static int print_single_switch PROTO((FILE *, int, int, const char *,
203 const char *, const char *,
204 const char *, const char *));
205 static void print_switch_values PROTO((FILE *, int, int, const char *,
206 const char *, const char *));
208 /* Length of line when printing switch values. */
211 /* Name of program invoked, sans directories. */
213 const char *progname;
215 /* Copy of arguments to main. */
219 /* Name of current original source file (what was input to cpp).
220 This comes from each #-command in the actual input. */
222 char *input_filename;
224 /* Name of top-level original source file (what was input to cpp).
225 This comes from the #-command at the beginning of the actual input.
226 If there isn't any there, then this is the cc1 input file name. */
228 char *main_input_filename;
230 /* Current line number in real source file. */
234 /* Nonzero if it is unsafe to create any new pseudo registers. */
237 /* Stack of currently pending input files. */
239 struct file_stack *input_file_stack;
241 /* Incremented on each change to input_file_stack. */
242 int input_file_stack_tick;
244 /* Name to use as base of names for dump output files. */
246 const char *dump_base_name;
248 /* Bit flags that specify the machine subtype we are compiling for.
249 Bits are tested using macros TARGET_... defined in the tm.h file
250 and set by `-m...' switches. Must be defined in rtlanal.c. */
252 extern int target_flags;
254 /* Flags saying which kinds of debugging dump have been requested. */
257 int rtl_dump_and_exit = 0;
258 int jump_opt_dump = 0;
259 int addressof_dump = 0;
264 int branch_prob_dump = 0;
266 int combine_dump = 0;
267 int regmove_dump = 0;
269 int local_reg_dump = 0;
270 int global_reg_dump = 0;
272 int peephole2_dump = 0;
274 int jump2_opt_dump = 0;
276 int dbr_sched_dump = 0;
278 int flag_print_asm_name = 0;
280 int stack_reg_dump = 0;
282 #ifdef MACHINE_DEPENDENT_REORG
283 int mach_dep_reorg_dump = 0;
285 static int flag_print_mem = 0;
286 static int version_flag = 0;
287 static char * filename = 0;
288 enum graph_dump_types graph_dump_format;
290 /* Name for output file of assembly code, specified with -o. */
294 /* Value of the -G xx switch, and whether it was passed or not. */
298 /* Type(s) of debugging information we are producing (if any).
299 See flags.h for the definitions of the different possible
300 types of debugging information. */
301 enum debug_info_type write_symbols = NO_DEBUG;
303 /* Level of debugging information we are producing. See flags.h
304 for the definitions of the different possible levels. */
305 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
307 /* Nonzero means use GNU-only extensions in the generated symbolic
308 debugging information. */
309 /* Currently, this only has an effect when write_symbols is set to
310 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
311 int use_gnu_debug_info_extensions = 0;
313 /* Nonzero means do optimizations. -O.
314 Particular numeric values stand for particular amounts of optimization;
315 thus, -O2 stores 2 here. However, the optimizations beyond the basic
316 ones are not controlled directly by this variable. Instead, they are
317 controlled by individual `flag_...' variables that are defaulted
318 based on this variable. */
322 /* Nonzero means optimize for size. -Os.
323 The only valid values are zero and non-zero. When optimize_size is
324 non-zero, optimize defaults to 2, but certain individual code
325 bloating optimizations are disabled. */
327 int optimize_size = 0;
329 /* Number of error messages and warning messages so far. */
332 int warningcount = 0;
335 /* Pointer to function to compute the name to use to print a declaration.
336 DECL is the declaration in question.
337 VERBOSITY determines what information will be printed:
338 0: DECL_NAME, demangled as necessary.
339 1: and scope information.
340 2: and any other information that might be interesting, such as function
341 parameter types in C++. */
343 const char *(*decl_printable_name) PROTO ((tree, int));
345 /* Pointer to function to compute rtl for a language-specific tree code. */
347 typedef rtx (*lang_expand_expr_t)
348 PROTO ((union tree_node *, rtx, enum machine_mode,
349 enum expand_modifier modifier));
351 lang_expand_expr_t lang_expand_expr = 0;
353 tree (*lang_expand_constant) PROTO((tree)) = 0;
355 /* Pointer to function to finish handling an incomplete decl at the
356 end of compilation. */
358 void (*incomplete_decl_finalize_hook) PROTO((tree)) = 0;
360 /* Nonzero if generating code to do profiling. */
362 int profile_flag = 0;
364 /* Nonzero if generating code to do profiling on a line-by-line basis. */
366 int profile_block_flag;
368 /* Nonzero if generating code to profile program flow graph arcs. */
370 int profile_arc_flag = 0;
372 /* Nonzero if generating info for gcov to calculate line test coverage. */
374 int flag_test_coverage = 0;
376 /* Nonzero indicates that branch taken probabilities should be calculated. */
378 int flag_branch_probabilities = 0;
380 /* Nonzero for -pedantic switch: warn about anything
381 that standard spec forbids. */
385 /* Temporarily suppress certain warnings.
386 This is set while reading code from a system header file. */
388 int in_system_header = 0;
390 /* Nonzero means do stupid register allocation.
391 Currently, this is 1 if `optimize' is 0. */
393 int obey_regdecls = 0;
395 /* Don't print functions as they are compiled and don't print
396 times taken by the various passes. -quiet. */
402 /* Nonzero means `char' should be signed. */
404 int flag_signed_char;
406 /* Nonzero means give an enum type only as many bytes as it needs. */
408 int flag_short_enums;
410 /* Nonzero for -fcaller-saves: allocate values in regs that need to
411 be saved across function calls, if that produces overall better code.
412 Optional now, so people can test it. */
414 #ifdef DEFAULT_CALLER_SAVES
415 int flag_caller_saves = 1;
417 int flag_caller_saves = 0;
420 /* Nonzero if structures and unions should be returned in memory.
422 This should only be defined if compatibility with another compiler or
423 with an ABI is needed, because it results in slower code. */
425 #ifndef DEFAULT_PCC_STRUCT_RETURN
426 #define DEFAULT_PCC_STRUCT_RETURN 1
429 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
431 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
433 /* Nonzero for -fforce-mem: load memory value into a register
434 before arithmetic on it. This makes better cse but slower compilation. */
436 int flag_force_mem = 0;
438 /* Nonzero for -fforce-addr: load memory address into a register before
439 reference to memory. This makes better cse but slower compilation. */
441 int flag_force_addr = 0;
443 /* Nonzero for -fdefer-pop: don't pop args after each function call;
444 instead save them up to pop many calls' args with one insns. */
446 int flag_defer_pop = 0;
448 /* Nonzero for -ffloat-store: don't allocate floats and doubles
449 in extended-precision registers. */
451 int flag_float_store = 0;
453 /* Nonzero for -fcse-follow-jumps:
454 have cse follow jumps to do a more extensive job. */
456 int flag_cse_follow_jumps;
458 /* Nonzero for -fcse-skip-blocks:
459 have cse follow a branch around a block. */
460 int flag_cse_skip_blocks;
462 /* Nonzero for -fexpensive-optimizations:
463 perform miscellaneous relatively-expensive optimizations. */
464 int flag_expensive_optimizations;
466 /* Nonzero for -fthread-jumps:
467 have jump optimize output of loop. */
469 int flag_thread_jumps;
471 /* Nonzero enables strength-reduction in loop.c. */
473 int flag_strength_reduce = 0;
475 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
476 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
477 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
480 int flag_unroll_loops;
482 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
483 This is generally not a win. */
485 int flag_unroll_all_loops;
487 /* Nonzero forces all invariant computations in loops to be moved
490 int flag_move_all_movables = 0;
492 /* Nonzero forces all general induction variables in loops to be
495 int flag_reduce_all_givs = 0;
497 /* Nonzero to perform full register move optimization passes. This is the
500 int flag_regmove = 0;
502 /* Nonzero for -fwritable-strings:
503 store string constants in data segment and don't uniquize them. */
505 int flag_writable_strings = 0;
507 /* Nonzero means don't put addresses of constant functions in registers.
508 Used for compiling the Unix kernel, where strange substitutions are
509 done on the assembly output. */
511 int flag_no_function_cse = 0;
513 /* Nonzero for -fomit-frame-pointer:
514 don't make a frame pointer in simple functions that don't require one. */
516 int flag_omit_frame_pointer = 0;
518 /* Nonzero means place each function into its own section on those platforms
519 which support arbitrary section names and unlimited numbers of sections. */
521 int flag_function_sections = 0;
523 /* ... and similar for data. */
525 int flag_data_sections = 0;
527 /* Nonzero to inhibit use of define_optimization peephole opts. */
529 int flag_no_peephole = 0;
531 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
532 operations in the interest of optimization. For example it allows
533 GCC to assume arguments to sqrt are nonnegative numbers, allowing
534 faster code for sqrt to be generated. */
536 int flag_fast_math = 0;
538 /* Nonzero means the front end generally wants `errno' maintained by math
539 operations, like built-in SQRT, unless overridden by flag_fast_math. */
541 int flag_errno_math = 1;
543 /* 0 means straightforward implementation of complex divide acceptable.
544 1 means wide ranges of inputs must work for complex divide.
545 2 means C9X-like requirements for complex divide (not yet implemented). */
547 int flag_complex_divide_method = 0;
549 /* Nonzero means all references through pointers are volatile. */
553 /* Nonzero means treat all global and extern variables as volatile. */
555 int flag_volatile_global;
557 /* Nonzero means treat all static variables as volatile. */
559 int flag_volatile_static;
561 /* Nonzero means just do syntax checking; don't output anything. */
563 int flag_syntax_only = 0;
565 /* Nonzero means perform global cse. */
567 static int flag_gcse;
569 /* Nonzero means to use global dataflow analysis to eliminate
570 useless null pointer tests. */
572 static int flag_delete_null_pointer_checks;
574 /* Nonzero means to rerun cse after loop optimization. This increases
575 compilation time about 20% and picks up a few more common expressions. */
577 static int flag_rerun_cse_after_loop;
579 /* Nonzero means to run loop optimizations twice. */
581 int flag_rerun_loop_opt;
583 /* Nonzero for -finline-functions: ok to inline functions that look like
584 good inline candidates. */
586 int flag_inline_functions;
588 /* Nonzero for -fkeep-inline-functions: even if we make a function
589 go inline everywhere, keep its definition around for debugging
592 int flag_keep_inline_functions;
594 /* Nonzero means that functions will not be inlined. */
598 /* Nonzero means that we should emit static const variables
599 regardless of whether or not optimization is turned on. */
601 int flag_keep_static_consts = 1;
603 /* Nonzero means we should be saving declaration info into a .X file. */
605 int flag_gen_aux_info = 0;
607 /* Specified name of aux-info file. */
609 static char *aux_info_file_name;
611 /* Nonzero means make the text shared if supported. */
613 int flag_shared_data;
615 /* Nonzero means schedule into delayed branch slots if supported. */
617 int flag_delayed_branch;
619 /* Nonzero if we are compiling pure (sharable) code.
620 Value is 1 if we are doing reasonable (i.e. simple
621 offset into offset table) pic. Value is 2 if we can
622 only perform register offsets. */
626 /* Nonzero means generate extra code for exception handling and enable
627 exception handling. */
631 /* Nonzero means use the new model for exception handling. Replaces
632 -DNEW_EH_MODEL as a compile option. */
634 int flag_new_exceptions = 1;
636 /* Nonzero means don't place uninitialized global data in common storage
641 /* Nonzero means pretend it is OK to examine bits of target floats,
642 even if that isn't true. The resulting code will have incorrect constants,
643 but the same series of instructions that the native compiler would make. */
645 int flag_pretend_float;
647 /* Nonzero means change certain warnings into errors.
648 Usually these are warnings about failure to conform to some standard. */
650 int flag_pedantic_errors = 0;
652 /* flag_schedule_insns means schedule insns within basic blocks (before
654 flag_schedule_insns_after_reload means schedule insns after
657 int flag_schedule_insns = 0;
658 int flag_schedule_insns_after_reload = 0;
660 /* The following flags have effect only for scheduling before register
663 flag_schedule_interblock means schedule insns accross basic blocks.
664 flag_schedule_speculative means allow speculative motion of non-load insns.
665 flag_schedule_speculative_load means allow speculative motion of some
667 flag_schedule_speculative_load_dangerous allows speculative motion of more
670 int flag_schedule_interblock = 1;
671 int flag_schedule_speculative = 1;
672 int flag_schedule_speculative_load = 0;
673 int flag_schedule_speculative_load_dangerous = 0;
675 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
676 by a cheaper branch, on a count register. */
677 int flag_branch_on_count_reg;
679 /* -finhibit-size-directive inhibits output of .size for ELF.
680 This is used only for compiling crtstuff.c,
681 and it may be extended to other effects
682 needed for crtstuff.c on other systems. */
683 int flag_inhibit_size_directive = 0;
685 /* -fverbose-asm causes extra commentary information to be produced in
686 the generated assembly code (to make it more readable). This option
687 is generally only of use to those who actually need to read the
688 generated assembly code (perhaps while debugging the compiler itself).
689 -fno-verbose-asm, the default, causes the extra information
690 to be omitted and is useful when comparing two assembler files. */
692 int flag_verbose_asm = 0;
694 /* -dA causes debug commentary information to be produced in
695 the generated assembly code (to make it more readable). This option
696 is generally only of use to those who actually need to read the
697 generated assembly code (perhaps while debugging the compiler itself).
698 Currently, this switch is only used by dwarfout.c; however, it is intended
699 to be a catchall for printing debug information in the assembler file. */
701 int flag_debug_asm = 0;
703 /* -fgnu-linker specifies use of the GNU linker for initializations.
704 (Or, more generally, a linker that handles initializations.)
705 -fno-gnu-linker says that collect2 will be used. */
707 int flag_gnu_linker = 0;
709 int flag_gnu_linker = 1;
712 /* Tag all structures with __attribute__(packed) */
713 int flag_pack_struct = 0;
715 /* Emit code to check for stack overflow; also may cause large objects
716 to be allocated dynamically. */
717 int flag_stack_check;
719 /* -fcheck-memory-usage causes extra code to be generated in order to check
720 memory accesses. This is used by a detector of bad memory accesses such
722 int flag_check_memory_usage = 0;
724 /* -fprefix-function-name causes function name to be prefixed. This
725 can be used with -fcheck-memory-usage to isolate code compiled with
726 -fcheck-memory-usage. */
727 int flag_prefix_function_name = 0;
729 /* 0 if pointer arguments may alias each other. True in C.
730 1 if pointer arguments may not alias each other but may alias
732 2 if pointer arguments may not alias each other and may not
733 alias global variables. True in Fortran.
734 This defaults to 0 for C. */
735 int flag_argument_noalias = 0;
737 /* Nonzero if we should do (language-dependent) alias analysis.
738 Typically, this analysis will assume that expressions of certain
739 types do not alias expressions of certain other types. Only used
740 if alias analysis (in general) is enabled. */
741 int flag_strict_aliasing = 0;
743 /* Instrument functions with calls at entry and exit, for profiling. */
744 int flag_instrument_function_entry_exit = 0;
746 /* Nonzero means ignore `#ident' directives. 0 means handle them.
747 On SVR4 targets, it also controls whether or not to emit a
748 string identifying the compiler. */
750 int flag_no_ident = 0;
752 /* This will perform a peephole pass before sched2. */
753 int flag_peephole2 = 0;
755 /* Values of the -falign-* flags: how much to align labels in code.
756 0 means `use default', 1 means `don't align'.
757 For each variable, there is an _log variant which is the power
758 of two not less than the variable, for .align output. */
765 int align_labels_log;
767 int align_functions_log;
769 /* Table of supported debugging formats. */
773 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
774 constant expression, we use NO_DEBUG in its place. */
775 enum debug_info_type debug_type;
776 int use_extensions_p;
777 const char * description;
781 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
782 "Generate default debug format output" },
783 { "gdb", NO_DEBUG, 1, "Generate default extended debug format output" },
784 #ifdef DBX_DEBUGGING_INFO
785 { "stabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
786 { "stabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
788 #ifdef DWARF_DEBUGGING_INFO
789 { "dwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
790 { "dwarf+", DWARF_DEBUG, 1,
791 "Generated extended DWARF-1 format debug output" },
793 #ifdef DWARF2_DEBUGGING_INFO
794 { "dwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
796 #ifdef XCOFF_DEBUGGING_INFO
797 { "xcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
798 { "xcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
800 #ifdef SDB_DEBUGGING_INFO
801 { "coff", SDB_DEBUG, 0, "Generate COFF format debug output" },
811 const char * description;
813 lang_independent_options;
815 /* Add or remove a leading underscore from user symbols. */
816 int flag_leading_underscore = -1;
818 /* The user symbol prefix after having resolved same. */
819 const char *user_label_prefix;
821 /* A default for same. */
822 #ifndef USER_LABEL_PREFIX
823 #define USER_LABEL_PREFIX ""
826 /* Table of language-independent -f options.
827 STRING is the option name. VARIABLE is the address of the variable.
828 ON_VALUE is the value to store in VARIABLE
829 if `-fSTRING' is seen as an option.
830 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
832 lang_independent_options f_options[] =
834 {"float-store", &flag_float_store, 1,
835 "Do not store floats in registers" },
836 {"volatile", &flag_volatile, 1,
837 "Consider all mem refs through pointers as volatile"},
838 {"volatile-global", &flag_volatile_global, 1,
839 "Consider all mem refs to global data to be volatile" },
840 {"volatile-static", &flag_volatile_static, 1,
841 "Consider all mem refs to static data to be volatile" },
842 {"defer-pop", &flag_defer_pop, 1,
843 "Defer popping functions args from stack until later" },
844 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
845 "When possible do not generate stack frames"},
846 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
847 "When running CSE, follow jumps to their targets" },
848 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
849 "When running CSE, follow conditional jumps" },
850 {"expensive-optimizations", &flag_expensive_optimizations, 1,
851 "Perform a number of minor, expensive optimisations" },
852 {"thread-jumps", &flag_thread_jumps, 1,
853 "Perform jump threading optimisations"},
854 {"strength-reduce", &flag_strength_reduce, 1,
855 "Perform strength reduction optimisations" },
856 {"unroll-loops", &flag_unroll_loops, 1,
857 "Perform loop unrolling when iteration count is known" },
858 {"unroll-all-loops", &flag_unroll_all_loops, 1,
859 "Perform loop unrolling for all loops" },
860 {"move-all-movables", &flag_move_all_movables, 1,
861 "Force all loop invariant computations out of loops" },
862 {"reduce-all-givs", &flag_reduce_all_givs, 1,
863 "Strength reduce all loop general induction variables" },
864 {"writable-strings", &flag_writable_strings, 1,
865 "Store strings in writable data section" },
866 {"peephole", &flag_no_peephole, 0,
867 "Enable machine specific peephole optimisations" },
868 {"force-mem", &flag_force_mem, 1,
869 "Copy memory operands into registers before using" },
870 {"force-addr", &flag_force_addr, 1,
871 "Copy memory address constants into regs before using" },
872 {"function-cse", &flag_no_function_cse, 0,
873 "Allow function addresses to be held in registers" },
874 {"inline-functions", &flag_inline_functions, 1,
875 "Integrate simple functions into their callers" },
876 {"keep-inline-functions", &flag_keep_inline_functions, 1,
877 "Generate code for funcs even if they are fully inlined" },
878 {"inline", &flag_no_inline, 0,
879 "Pay attention to the 'inline' keyword"},
880 {"keep-static-consts", &flag_keep_static_consts, 1,
881 "Emit static const variables even if they are not used" },
882 {"syntax-only", &flag_syntax_only, 1,
883 "Check for syntax errors, then stop" },
884 {"shared-data", &flag_shared_data, 1,
885 "Mark data as shared rather than private" },
886 {"caller-saves", &flag_caller_saves, 1,
887 "Enable saving registers around function calls" },
888 {"pcc-struct-return", &flag_pcc_struct_return, 1,
889 "Return 'short' aggregates in memory, not registers" },
890 {"reg-struct-return", &flag_pcc_struct_return, 0,
891 "Return 'short' aggregates in registers" },
892 {"delayed-branch", &flag_delayed_branch, 1,
893 "Attempt to fill delay slots of branch instructions" },
894 {"gcse", &flag_gcse, 1,
895 "Perform the global common subexpression elimination" },
896 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
897 "Run CSE pass after loop optimisations"},
898 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
899 "Run the loop optimiser twice"},
900 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
901 "Delete useless null pointer checks" },
902 {"pretend-float", &flag_pretend_float, 1,
903 "Pretend that host and target use the same FP format"},
904 {"schedule-insns", &flag_schedule_insns, 1,
905 "Reschedule instructions to avoid pipeline stalls"},
906 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
907 "Run two passes of the instruction scheduler"},
908 {"sched-interblock",&flag_schedule_interblock, 1,
909 "Enable scheduling across basic blocks" },
910 {"sched-spec",&flag_schedule_speculative, 1,
911 "Allow speculative motion of non-loads" },
912 {"sched-spec-load",&flag_schedule_speculative_load, 1,
913 "Allow speculative motion of some loads" },
914 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
915 "Allow speculative motion of more loads" },
916 {"branch-count-reg",&flag_branch_on_count_reg, 1,
917 "Replace add,compare,branch with branch on count reg"},
918 {"pic", &flag_pic, 1,
919 "Generate position independent code, if possible"},
920 {"PIC", &flag_pic, 2, ""},
921 {"exceptions", &flag_exceptions, 1,
922 "Enable exception handling" },
923 {"new-exceptions", &flag_new_exceptions, 1,
924 "Use the new model for exception handling" },
925 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
926 "Use setjmp/longjmp to handle exceptions" },
927 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
928 "Support asynchronous exceptions" },
929 {"profile-arcs", &profile_arc_flag, 1,
930 "Insert arc based program profiling code" },
931 {"test-coverage", &flag_test_coverage, 1,
932 "Create data files needed by gcov" },
933 {"branch-probabilities", &flag_branch_probabilities, 1,
934 "Use profiling information for branch probabilities" },
935 {"fast-math", &flag_fast_math, 1,
936 "Improve FP speed by violating ANSI & IEEE rules" },
937 {"common", &flag_no_common, 0,
938 "Do not put unitialised globals in the common section" },
939 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
940 "Do not generate .size directives" },
941 {"function-sections", &flag_function_sections, 1,
942 "place each function into its own section" },
943 {"data-sections", &flag_data_sections, 1,
944 "place data items into their own section" },
945 {"verbose-asm", &flag_verbose_asm, 1,
946 "Add extra commentry to assembler output"},
947 {"gnu-linker", &flag_gnu_linker, 1,
948 "Output GNU ld formatted global initialisers"},
949 {"regmove", &flag_regmove, 1,
950 "Enables a register move optimisation"},
951 {"optimize-register-move", &flag_regmove, 1,
952 "Do the full regmove optimization pass"},
953 {"pack-struct", &flag_pack_struct, 1,
954 "Pack structure members together without holes" },
955 {"stack-check", &flag_stack_check, 1,
956 "Insert stack checking code into the program" },
957 {"argument-alias", &flag_argument_noalias, 0,
958 "Specify that arguments may alias each other & globals"},
959 {"argument-noalias", &flag_argument_noalias, 1,
960 "Assume arguments may alias globals but not each other"},
961 {"argument-noalias-global", &flag_argument_noalias, 2,
962 "Assume arguments do not alias each other or globals" },
963 {"strict-aliasing", &flag_strict_aliasing, 1,
964 "Assume strict aliasing rules apply" },
965 {"align-loops", &align_loops, 0,
966 "Align the start of loops" },
967 {"align-jumps", &align_jumps, 0,
968 "Align labels which are only reached by jumping" },
969 {"align-labels", &align_labels, 0,
970 "Align all labels" },
971 {"align-functions", &align_functions, 0,
972 "Align the start of functions" },
973 {"check-memory-usage", &flag_check_memory_usage, 1,
974 "Generate code to check every memory access" },
975 {"prefix-function-name", &flag_prefix_function_name, 1,
976 "Add a prefix to all function names" },
977 {"dump-unnumbered", &flag_dump_unnumbered, 1,
978 "Suppress output of instruction numbers and line number notes in debugging dumps"},
979 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
980 "Instrument function entry/exit with profiling calls"},
981 {"leading-underscore", &flag_leading_underscore, 1,
982 "External symbols have a leading underscore" },
983 {"ident", &flag_no_ident, 0,
984 "Process #ident directives"},
985 { "peephole2", &flag_peephole2, 1,
986 "Enables an rtl peephole pass run before sched2" },
987 {"math-errno", &flag_errno_math, 1,
988 "Set errno after built-in math functions"}
991 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
993 /* Table of language-specific options. */
995 static struct lang_opt
998 const char * description;
1000 documented_lang_options[] =
1002 /* In order not to overload the --help output, the convention
1003 used here is to only describe those options which are not
1004 enabled by default. */
1006 { "-ansi", "Compile just for ANSI C" },
1007 { "-fallow-single-precision",
1008 "Do not promote floats to double if using -traditional" },
1009 { "-std= ", "Determine language standard"},
1011 { "-fsigned-bitfields", "" },
1012 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1013 { "-fno-signed-bitfields", "" },
1014 { "-fno-unsigned-bitfields","" },
1015 { "-fsigned-char", "Make 'char' be signed by default"},
1016 { "-funsigned-char", "Make 'char' be unsigned by default"},
1017 { "-fno-signed-char", "" },
1018 { "-fno-unsigned-char", "" },
1020 { "-ftraditional", "" },
1021 { "-traditional", "Attempt to support traditional K&R style C"},
1022 { "-fnotraditional", "" },
1023 { "-fno-traditional", "" },
1026 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1027 { "-fbuiltin", "" },
1028 { "-fno-builtin", "Do not recognise any built in functions" },
1029 { "-fhosted", "Assume normal C execution environment" },
1030 { "-fno-hosted", "" },
1032 "Assume that standard libraries & main might not exist" },
1033 { "-fno-freestanding", "" },
1034 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1035 { "-fno-cond-mismatch", "" },
1036 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1037 { "-fno-dollars-in-identifiers", "" },
1038 { "-fpreprocessed", "" },
1039 { "-fno-preprocessed", "" },
1040 { "-fshort-double", "Use the same size for double as for float" },
1041 { "-fno-short-double", "" },
1042 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1043 { "-fno-short-enums", "" },
1044 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1045 { "-fno-short-wchar", "" },
1047 { "-Wall", "Enable most warning messages" },
1048 { "-Wbad-function-cast",
1049 "Warn about casting functions to incompatible types" },
1050 { "-Wno-bad-function-cast", "" },
1051 { "-Wmissing-noreturn",
1052 "Warn about functions which might be candidates for attribute noreturn" },
1053 { "-Wno-missing-noreturn", "" },
1054 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1055 { "-Wno-cast-qual", "" },
1056 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1057 { "-Wno-char-subscripts", "" },
1058 { "-Wcomment", "Warn if nested comments are detected" },
1059 { "-Wno-comment", "" },
1060 { "-Wcomments", "Warn if nested comments are detected" },
1061 { "-Wno-comments", "" },
1062 { "-Wconversion", "Warn about possibly confusing type conversions" },
1063 { "-Wno-conversion", "" },
1064 { "-Wformat", "Warn about printf format anomalies" },
1065 { "-Wno-format", "" },
1066 { "-Wimplicit-function-declaration",
1067 "Warn about implicit function declarations" },
1068 { "-Wno-implicit-function-declaration", "" },
1069 { "-Werror-implicit-function-declaration", "" },
1070 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1071 { "-Wno-implicit-int", "" },
1072 { "-Wimplicit", "" },
1073 { "-Wno-implicit", "" },
1074 { "-Wimport", "Warn about the use of the #import directive" },
1075 { "-Wno-import", "" },
1076 { "-Wlong-long","" },
1077 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1078 { "-Wmain", "Warn about suspicious declarations of main" },
1079 { "-Wno-main", "" },
1080 { "-Wmissing-braces",
1081 "Warn about possibly missing braces around initialisers" },
1082 { "-Wno-missing-braces", "" },
1083 { "-Wmissing-declarations",
1084 "Warn about global funcs without previous declarations"},
1085 { "-Wno-missing-declarations", "" },
1086 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1087 { "-Wno-missing-prototypes", "" },
1088 { "-Wmultichar", "Warn about use of multicharacter literals"},
1089 { "-Wno-multichar", "" },
1090 { "-Wnested-externs", "Warn about externs not at file scope level" },
1091 { "-Wno-nested-externs", "" },
1092 { "-Wparentheses", "Warn about possible missing parentheses" },
1093 { "-Wno-parentheses", "" },
1094 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1095 { "-Wno-pointer-arith", "" },
1096 { "-Wredundant-decls",
1097 "Warn about multiple declarations of the same object" },
1098 { "-Wno-redundant-decls", "" },
1099 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1100 { "-Wno-sign-compare", "" },
1101 { "-Wfloat-equal", "Warn about testing equality of floating point numbers" },
1102 { "-Wno-float-equal", "" },
1103 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1104 { "-Wno-unknown-pragmas", "" },
1105 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1106 { "-Wno-strict-prototypes", "" },
1107 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1108 { "-Wno-traditional", "" },
1109 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1110 { "-Wno-trigraphs", "" },
1112 { "-Wno-undef", "" },
1113 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1114 { "-Wno-write-strings", "" },
1116 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1118 /* These are for Objective C. */
1119 DEFINE_LANG_NAME ("Objective C")
1121 { "-lang-objc", "" },
1122 { "-gen-decls", "Dump decls to a .decl file" },
1123 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1124 { "-fno-gnu-runtime", "" },
1125 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1126 { "-fno-next-runtime", "" },
1127 { "-Wselector", "Warn if a selector has multiple methods" },
1128 { "-Wno-selector", "" },
1129 { "-Wprotocol", "" },
1130 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1131 { "-print-objc-runtime-info",
1132 "Generate C header of platform specific features" },
1134 #include "options.h"
1138 /* Here is a table, controlled by the tm.h file, listing each -m switch
1139 and which bits in `target_switches' it should set or clear.
1140 If VALUE is positive, it is bits to set.
1141 If VALUE is negative, -VALUE is bits to clear.
1142 (The sign bit is not used so there is no confusion.) */
1148 const char * description;
1150 target_switches [] = TARGET_SWITCHES;
1152 /* This table is similar, but allows the switch to have a value. */
1154 #ifdef TARGET_OPTIONS
1157 const char * prefix;
1158 const char ** variable;
1159 const char * description;
1161 target_options [] = TARGET_OPTIONS;
1164 /* Options controlling warnings */
1166 /* Don't print warning messages. -w. */
1168 int inhibit_warnings = 0;
1170 /* Print various extra warnings. -W. */
1172 int extra_warnings = 0;
1174 /* Treat warnings as errors. -Werror. */
1176 int warnings_are_errors = 0;
1178 /* Nonzero to warn about unused local variables. */
1182 /* Nonzero to warn about code which is never reached. */
1184 int warn_notreached;
1186 /* Nonzero to warn about variables used before they are initialized. */
1188 int warn_uninitialized;
1190 /* Nonzero means warn about all declarations which shadow others. */
1194 /* Warn if a switch on an enum fails to have a case for every enum value. */
1198 /* Nonzero means warn about function definitions that default the return type
1199 or that use a null return and have a return-type other than void. */
1201 int warn_return_type;
1203 /* Nonzero means warn about pointer casts that increase the required
1204 alignment of the target type (and might therefore lead to a crash
1205 due to a misaligned access). */
1207 int warn_cast_align;
1209 /* Nonzero means warn about any identifiers that match in the first N
1210 characters. The value N is in `id_clash_len'. */
1213 unsigned id_clash_len;
1215 /* Nonzero means warn about any objects definitions whose size is larger
1216 than N bytes. Also want about function definitions whose returned
1217 values are larger than N bytes. The value N is in `larger_than_size'. */
1219 int warn_larger_than;
1220 unsigned larger_than_size;
1222 /* Nonzero means warn if inline function is too large. */
1226 /* Warn if a function returns an aggregate,
1227 since there are often incompatible calling conventions for doing this. */
1229 int warn_aggregate_return;
1231 /* Likewise for -W. */
1233 lang_independent_options W_options[] =
1235 {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1236 {"error", &warnings_are_errors, 1, ""},
1237 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1238 {"switch", &warn_switch, 1,
1239 "Warn about enumerated switches missing a specific case" },
1240 {"aggregate-return", &warn_aggregate_return, 1,
1241 "Warn about returning structures, unions or arrays" },
1242 {"cast-align", &warn_cast_align, 1,
1243 "Warn about pointer casts which increase alignment" },
1244 {"unreachable-code", &warn_notreached, 1,
1245 "Warn about code that will never be executed" },
1246 {"uninitialized", &warn_uninitialized, 1,
1247 "Warn about unitialized automatic variables"},
1248 {"inline", &warn_inline, 1,
1249 "Warn when an inlined function cannot be inlined"}
1252 /* Output files for assembler code (real compiler output)
1253 and debugging dumps. */
1256 FILE *aux_info_file;
1257 FILE *rtl_dump_file = NULL;
1259 /* Decode the string P as an integral parameter.
1260 If the string is indeed an integer return its numeric value else
1261 issue an Invalid Option error for the option PNAME and return DEFVAL.
1262 If PNAME is zero just return DEFVAL, do not call error. */
1265 read_integral_parameter (p, pname, defval)
1270 const char *endp = p;
1274 if (*endp >= '0' && *endp <= '9')
1283 error ("Invalid option `%s'", pname);
1291 /* Time accumulators, to count the total time spent in various passes. */
1295 int integration_time;
1301 int branch_prob_time;
1306 int local_alloc_time;
1307 int global_alloc_time;
1312 int shorten_branch_time;
1320 /* Return time used so far, in microseconds. */
1330 #else /* not BeOS */
1331 #if defined (_WIN32) && !defined (__CYGWIN__)
1335 return (clock() * 1000);
1336 #else /* not _WIN32 */
1342 tick = 1000000 / sysconf(_SC_CLK_TCK);
1344 return (tms.tms_utime + tms.tms_stime) * tick;
1350 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1351 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1354 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1356 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1360 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1365 struct rusage rusage;
1366 getrusage (0, &rusage);
1367 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1368 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1375 int proc_system_time;
1376 int child_user_time;
1377 int child_system_time;
1379 times ((void *) &vms_times);
1380 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1384 #endif /* _SC_CLK_TCK */
1386 #endif /* __BEOS__ */
1389 #define TIMEVAR(VAR, BODY) \
1390 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1393 print_time (str, total)
1398 "time in %s: %d.%06d (%.0f%%)\n",
1399 str, total / 1000000, total % 1000000,
1400 (double)total / (double)all_time * 100.0);
1403 /* Count an error or warning. Return 1 if the message should be printed. */
1406 count_error (warningp)
1409 if (warningp && inhibit_warnings)
1412 if (warningp && !warnings_are_errors)
1416 static int warning_message = 0;
1418 if (warningp && !warning_message)
1420 notice ("%s: warnings being treated as errors\n", progname);
1421 warning_message = 1;
1429 /* Print a fatal error message. NAME is the text.
1430 Also include a system error message based on `errno'. */
1433 pfatal_with_name (name)
1436 fprintf (stderr, "%s: ", progname);
1438 exit (FATAL_EXIT_CODE);
1442 fatal_io_error (name)
1445 notice ("%s: %s: I/O error\n", progname, name);
1446 exit (FATAL_EXIT_CODE);
1449 /* This is the default decl_printable_name function. */
1452 decl_name (decl, verbosity)
1454 int verbosity ATTRIBUTE_UNUSED;
1456 return IDENTIFIER_POINTER (DECL_NAME (decl));
1459 /* Mark P for GC. Also mark main_input_filename and input_filename. */
1464 struct file_stack *stack = *(struct file_stack **)p;
1466 /* We're only called for input_file_stack, so we can mark the current
1467 input_filename here as well. */
1468 ggc_mark_string (main_input_filename);
1469 ggc_mark_string (input_filename);
1473 ggc_mark_string (stack->name);
1474 stack = stack->next;
1478 static int need_error_newline;
1480 /* Function of last error message;
1481 more generally, function such that if next error message is in it
1482 then we don't have to mention the function name. */
1483 static tree last_error_function = NULL;
1485 /* Used to detect when input_file_stack has changed since last described. */
1486 static int last_error_tick;
1488 /* Called when the start of a function definition is parsed,
1489 this function prints on stderr the name of the function. */
1492 announce_function (decl)
1497 if (rtl_dump_and_exit)
1498 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1500 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1502 need_error_newline = 1;
1503 last_error_function = current_function_decl;
1507 /* The default function to print out name of current function that caused
1511 default_print_error_function (file)
1514 if (last_error_function != current_function_decl)
1517 fprintf (stderr, "%s: ", file);
1519 if (current_function_decl == NULL)
1520 notice ("At top level:\n");
1522 notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE
1523 ? "In method `%s':\n"
1524 : "In function `%s':\n"),
1525 (*decl_printable_name) (current_function_decl, 2));
1527 last_error_function = current_function_decl;
1531 /* Called by report_error_function to print out function name.
1532 * Default may be overridden by language front-ends. */
1534 void (*print_error_function) PROTO((const char *)) =
1535 default_print_error_function;
1537 /* Prints out, if necessary, the name of the current function
1538 that caused an error. Called from all error and warning functions.
1539 We ignore the FILE parameter, as it cannot be relied upon. */
1542 report_error_function (file)
1543 const char *file ATTRIBUTE_UNUSED;
1545 struct file_stack *p;
1547 if (need_error_newline)
1549 fprintf (stderr, "\n");
1550 need_error_newline = 0;
1553 if (input_file_stack && input_file_stack->next != 0
1554 && input_file_stack_tick != last_error_tick)
1556 for (p = input_file_stack->next; p; p = p->next)
1557 notice ((p == input_file_stack->next
1558 ? "In file included from %s:%d"
1559 : ",\n from %s:%d"),
1561 fprintf (stderr, ":\n");
1562 last_error_tick = input_file_stack_tick;
1565 (*print_error_function) (input_filename);
1568 /* Print a message. */
1571 vnotice (file, msgid, ap)
1576 vfprintf (file, _(msgid), ap);
1580 notice VPROTO((const char *msgid, ...))
1582 #ifndef ANSI_PROTOTYPES
1587 VA_START (ap, msgid);
1589 #ifndef ANSI_PROTOTYPES
1590 msgid = va_arg (ap, char *);
1593 vnotice (stderr, msgid, ap);
1598 fnotice VPROTO((FILE *file, const char *msgid, ...))
1600 #ifndef ANSI_PROTOTYPES
1606 VA_START (ap, msgid);
1608 #ifndef ANSI_PROTOTYPES
1609 file = va_arg (ap, FILE *);
1610 msgid = va_arg (ap, const char *);
1613 vnotice (file, msgid, ap);
1617 /* Report FILE and LINE (or program name), and optionally just WARN. */
1620 report_file_and_line (file, line, warn)
1626 fprintf (stderr, "%s:%d: ", file, line);
1628 fprintf (stderr, "%s: ", progname);
1631 notice ("warning: ");
1634 /* Print a message. */
1637 vmessage (prefix, msgid, ap)
1643 fprintf (stderr, "%s: ", prefix);
1645 vfprintf (stderr, msgid, ap);
1648 /* Print a message relevant to line LINE of file FILE. */
1651 v_message_with_file_and_line (file, line, warn, msgid, ap)
1658 report_file_and_line (file, line, warn);
1659 vnotice (stderr, msgid, ap);
1660 fputc ('\n', stderr);
1663 /* Print a message relevant to the given DECL. */
1666 v_message_with_decl (decl, warn, msgid, ap)
1674 report_file_and_line (DECL_SOURCE_FILE (decl),
1675 DECL_SOURCE_LINE (decl), warn);
1677 /* Do magic to get around lack of varargs support for insertion
1678 of arguments into existing list. We know that the decl is first;
1679 we ass_u_me that it will be printed with "%s". */
1681 for (p = _(msgid); *p; ++p)
1685 if (*(p + 1) == '%')
1687 else if (*(p + 1) != 's')
1694 if (p > _(msgid)) /* Print the left-hand substring. */
1696 char fmt[sizeof "%.255s"];
1697 long width = p - _(msgid);
1699 if (width > 255L) width = 255L; /* arbitrary */
1700 sprintf (fmt, "%%.%lds", width);
1701 fprintf (stderr, fmt, _(msgid));
1704 if (*p == '%') /* Print the name. */
1706 const char *n = (DECL_NAME (decl)
1707 ? (*decl_printable_name) (decl, 2)
1713 if (ISALPHA (*(p - 1) & 0xFF))
1718 if (*p) /* Print the rest of the message. */
1719 vmessage ((char *)NULL, p, ap);
1721 fputc ('\n', stderr);
1724 /* Figure file and line of the given INSN. */
1727 file_and_line_for_asm (insn, pfile, pline)
1732 rtx body = PATTERN (insn);
1735 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1736 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1737 asmop = SET_SRC (body);
1738 else if (GET_CODE (body) == ASM_OPERANDS)
1740 else if (GET_CODE (body) == PARALLEL
1741 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1742 asmop = SET_SRC (XVECEXP (body, 0, 0));
1743 else if (GET_CODE (body) == PARALLEL
1744 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1745 asmop = XVECEXP (body, 0, 0);
1751 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1752 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1756 *pfile = input_filename;
1761 /* Report an error at line LINE of file FILE. */
1764 v_error_with_file_and_line (file, line, msgid, ap)
1771 report_error_function (file);
1772 v_message_with_file_and_line (file, line, 0, msgid, ap);
1776 error_with_file_and_line VPROTO((const char *file, int line,
1777 const char *msgid, ...))
1779 #ifndef ANSI_PROTOTYPES
1786 VA_START (ap, msgid);
1788 #ifndef ANSI_PROTOTYPES
1789 file = va_arg (ap, const char *);
1790 line = va_arg (ap, int);
1791 msgid = va_arg (ap, const char *);
1794 v_error_with_file_and_line (file, line, msgid, ap);
1798 /* Report an error at the declaration DECL.
1799 MSGID is a format string which uses %s to substitute the declaration
1800 name; subsequent substitutions are a la printf. */
1803 v_error_with_decl (decl, msgid, ap)
1809 report_error_function (DECL_SOURCE_FILE (decl));
1810 v_message_with_decl (decl, 0, msgid, ap);
1814 error_with_decl VPROTO((tree decl, const char *msgid, ...))
1816 #ifndef ANSI_PROTOTYPES
1822 VA_START (ap, msgid);
1824 #ifndef ANSI_PROTOTYPES
1825 decl = va_arg (ap, tree);
1826 msgid = va_arg (ap, const char *);
1829 v_error_with_decl (decl, msgid, ap);
1833 /* Report an error at the line number of the insn INSN.
1834 This is used only when INSN is an `asm' with operands,
1835 and each ASM_OPERANDS records its own source file and line. */
1838 v_error_for_asm (insn, msgid, ap)
1847 file_and_line_for_asm (insn, &file, &line);
1848 report_error_function (file);
1849 v_message_with_file_and_line (file, line, 0, msgid, ap);
1853 error_for_asm VPROTO((rtx insn, const char *msgid, ...))
1855 #ifndef ANSI_PROTOTYPES
1861 VA_START (ap, msgid);
1863 #ifndef ANSI_PROTOTYPES
1864 insn = va_arg (ap, rtx);
1865 msgid = va_arg (ap, const char *);
1868 v_error_for_asm (insn, msgid, ap);
1872 /* Report an error at the current line number. */
1879 v_error_with_file_and_line (input_filename, lineno, msgid, ap);
1883 error VPROTO((const char *msgid, ...))
1885 #ifndef ANSI_PROTOTYPES
1890 VA_START (ap, msgid);
1892 #ifndef ANSI_PROTOTYPES
1893 msgid = va_arg (ap, const char *);
1900 /* Report a fatal error at the current line number. Allow a front end to
1901 intercept the message. */
1903 static void (*fatal_function) PROTO ((const char *, va_list));
1905 /* Set the function to call when a fatal error occurs. */
1908 set_fatal_function (f)
1909 void (*f) PROTO ((const char *, va_list));
1919 if (fatal_function != 0)
1920 (*fatal_function) (_(msgid), ap);
1923 exit (FATAL_EXIT_CODE);
1927 fatal VPROTO((const char *msgid, ...))
1929 #ifndef ANSI_PROTOTYPES
1934 VA_START (ap, msgid);
1936 #ifndef ANSI_PROTOTYPES
1937 msgid = va_arg (ap, const char *);
1945 _fatal_insn (msgid, insn, file, line, function)
1950 const char *function;
1954 fancy_abort (file, line, function);
1958 _fatal_insn_not_found (insn, file, line, function)
1962 const char *function;
1964 if (INSN_CODE (insn) < 0)
1965 _fatal_insn ("Unrecognizable insn:", insn, file, line, function);
1967 _fatal_insn ("Insn does not satisfy its constraints:",
1968 insn, file, line, function);
1971 /* Report a warning at line LINE of file FILE. */
1974 v_warning_with_file_and_line (file, line, msgid, ap)
1980 if (count_error (1))
1982 report_error_function (file);
1983 v_message_with_file_and_line (file, line, 1, msgid, ap);
1988 warning_with_file_and_line VPROTO((const char *file, int line,
1989 const char *msgid, ...))
1991 #ifndef ANSI_PROTOTYPES
1998 VA_START (ap, msgid);
2000 #ifndef ANSI_PROTOTYPES
2001 file = va_arg (ap, const char *);
2002 line = va_arg (ap, int);
2003 msgid = va_arg (ap, const char *);
2006 v_warning_with_file_and_line (file, line, msgid, ap);
2010 /* Report a warning at the declaration DECL.
2011 MSGID is a format string which uses %s to substitute the declaration
2012 name; subsequent substitutions are a la printf. */
2015 v_warning_with_decl (decl, msgid, ap)
2020 if (count_error (1))
2022 report_error_function (DECL_SOURCE_FILE (decl));
2023 v_message_with_decl (decl, 1, msgid, ap);
2028 warning_with_decl VPROTO((tree decl, const char *msgid, ...))
2030 #ifndef ANSI_PROTOTYPES
2036 VA_START (ap, msgid);
2038 #ifndef ANSI_PROTOTYPES
2039 decl = va_arg (ap, tree);
2040 msgid = va_arg (ap, const char *);
2043 v_warning_with_decl (decl, msgid, ap);
2047 /* Report a warning at the line number of the insn INSN.
2048 This is used only when INSN is an `asm' with operands,
2049 and each ASM_OPERANDS records its own source file and line. */
2052 v_warning_for_asm (insn, msgid, ap)
2057 if (count_error (1))
2062 file_and_line_for_asm (insn, &file, &line);
2063 report_error_function (file);
2064 v_message_with_file_and_line (file, line, 1, msgid, ap);
2069 warning_for_asm VPROTO((rtx insn, const char *msgid, ...))
2071 #ifndef ANSI_PROTOTYPES
2077 VA_START (ap, msgid);
2079 #ifndef ANSI_PROTOTYPES
2080 insn = va_arg (ap, rtx);
2081 msgid = va_arg (ap, const char *);
2084 v_warning_for_asm (insn, msgid, ap);
2088 /* Report a warning at the current line number. */
2091 vwarning (msgid, ap)
2095 v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
2099 warning VPROTO((const char *msgid, ...))
2101 #ifndef ANSI_PROTOTYPES
2106 VA_START (ap, msgid);
2108 #ifndef ANSI_PROTOTYPES
2109 msgid = va_arg (ap, const char *);
2112 vwarning (msgid, ap);
2116 /* These functions issue either warnings or errors depending on
2117 -pedantic-errors. */
2120 vpedwarn (msgid, ap)
2124 if (flag_pedantic_errors)
2127 vwarning (msgid, ap);
2131 pedwarn VPROTO((const char *msgid, ...))
2133 #ifndef ANSI_PROTOTYPES
2138 VA_START (ap, msgid);
2140 #ifndef ANSI_PROTOTYPES
2141 msgid = va_arg (ap, const char *);
2144 vpedwarn (msgid, ap);
2149 v_pedwarn_with_decl (decl, msgid, ap)
2154 /* We don't want -pedantic-errors to cause the compilation to fail from
2155 "errors" in system header files. Sometimes fixincludes can't fix what's
2156 broken (eg: unsigned char bitfields - fixing it may change the alignment
2157 which will cause programs to mysteriously fail because the C library
2158 or kernel uses the original layout). There's no point in issuing a
2159 warning either, it's just unnecessary noise. */
2161 if (! DECL_IN_SYSTEM_HEADER (decl))
2163 if (flag_pedantic_errors)
2164 v_error_with_decl (decl, msgid, ap);
2166 v_warning_with_decl (decl, msgid, ap);
2171 pedwarn_with_decl VPROTO((tree decl, const char *msgid, ...))
2173 #ifndef ANSI_PROTOTYPES
2179 VA_START (ap, msgid);
2181 #ifndef ANSI_PROTOTYPES
2182 decl = va_arg (ap, tree);
2183 msgid = va_arg (ap, const char *);
2186 v_pedwarn_with_decl (decl, msgid, ap);
2191 v_pedwarn_with_file_and_line (file, line, msgid, ap)
2197 if (flag_pedantic_errors)
2198 v_error_with_file_and_line (file, line, msgid, ap);
2200 v_warning_with_file_and_line (file, line, msgid, ap);
2204 pedwarn_with_file_and_line VPROTO((const char *file, int line,
2205 const char *msgid, ...))
2207 #ifndef ANSI_PROTOTYPES
2214 VA_START (ap, msgid);
2216 #ifndef ANSI_PROTOTYPES
2217 file = va_arg (ap, const char *);
2218 line = va_arg (ap, int);
2219 msgid = va_arg (ap, const char *);
2222 v_pedwarn_with_file_and_line (file, line, msgid, ap);
2226 /* Apologize for not implementing some feature. */
2235 fprintf (stderr, "%s:%d: ", input_filename, lineno);
2237 fprintf (stderr, "%s: ", progname);
2238 notice ("sorry, not implemented: ");
2239 vnotice (stderr, msgid, ap);
2240 fputc ('\n', stderr);
2244 sorry VPROTO((const char *msgid, ...))
2246 #ifndef ANSI_PROTOTYPES
2251 VA_START (ap, msgid);
2253 #ifndef ANSI_PROTOTYPES
2254 msgid = va_arg (ap, const char *);
2262 /* This calls abort and is used to avoid problems when abort if a macro.
2263 It is used when we need to pass the address of abort. */
2271 /* When `malloc.c' is compiled with `rcheck' defined,
2272 it calls this function to report clobberage. */
2276 const char * s ATTRIBUTE_UNUSED;
2281 /* Return the logarithm of X, base 2, considering X unsigned,
2282 if X is a power of 2. Otherwise, returns -1.
2284 This should be used via the `exact_log2' macro. */
2288 register unsigned HOST_WIDE_INT x;
2290 register int log = 0;
2291 /* Test for 0 or a power of 2. */
2292 if (x == 0 || x != (x & -x))
2294 while ((x >>= 1) != 0)
2299 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2300 If X is 0, return -1.
2302 This should be used via the floor_log2 macro. */
2306 register unsigned HOST_WIDE_INT x;
2308 register int log = -1;
2315 static int float_handler_set;
2317 jmp_buf float_handler;
2319 /* Signals actually come here. */
2322 float_signal (signo)
2323 /* If this is missing, some compilers complain. */
2324 int signo ATTRIBUTE_UNUSED;
2326 if (float_handled == 0)
2328 #if defined (USG) || defined (hpux)
2329 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2332 signal (SIGFPE, float_signal);
2333 longjmp (float_handler, 1);
2336 /* Specify where to longjmp to when a floating arithmetic error happens.
2337 If HANDLER is 0, it means don't handle the errors any more. */
2340 set_float_handler (handler)
2343 float_handled = (handler != 0);
2345 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2347 if (float_handled && ! float_handler_set)
2349 signal (SIGFPE, float_signal);
2350 float_handler_set = 1;
2354 /* This is a wrapper function for code which might elicit an
2355 arithmetic exception. That code should be passed in as a function
2356 pointer FN, and one argument DATA. DATA is usually a struct which
2357 contains the real input and output for function FN. This function
2358 returns 0 (failure) if longjmp was called (i.e. an exception
2359 occured.) It returns 1 (success) otherwise. */
2362 do_float_handler (fn, data)
2363 void (*fn) PROTO ((PTR));
2370 /* We got here via longjmp() caused by an exception in function fn() */
2371 set_float_handler (NULL);
2375 set_float_handler (buf);
2377 set_float_handler (NULL);
2381 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2382 error happens, pushing the previous specification into OLD_HANDLER.
2383 Return an indication of whether there was a previous handler in effect. */
2386 push_float_handler (handler, old_handler)
2387 jmp_buf handler, old_handler;
2389 int was_handled = float_handled;
2393 memcpy ((char *) old_handler, (char *) float_handler,
2394 sizeof (float_handler));
2396 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
2400 /* Restore the previous specification of whether and where to longjmp to
2401 when a floating arithmetic error happens. */
2404 pop_float_handler (handled, handler)
2408 float_handled = handled;
2410 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2413 /* Handler for SIGPIPE. */
2417 /* If this is missing, some compilers complain. */
2418 int signo ATTRIBUTE_UNUSED;
2420 fatal ("output pipe has been closed");
2423 /* Strip off a legitimate source ending from the input string NAME of
2424 length LEN. Rather than having to know the names used by all of
2425 our front ends, we strip off an ending of a period followed by
2426 up to five characters. (Java uses ".class".) */
2429 strip_off_ending (name, len)
2434 for (i = 2; i < 6 && len > i; i++)
2436 if (name[len - i] == '.')
2438 name[len - i] = '\0';
2444 /* Output a quoted string. */
2447 output_quoted_string (asm_file, string)
2451 #ifdef OUTPUT_QUOTED_STRING
2452 OUTPUT_QUOTED_STRING (asm_file, string);
2456 putc ('\"', asm_file);
2457 while ((c = *string++) != 0)
2459 if (c == '\"' || c == '\\')
2460 putc ('\\', asm_file);
2463 putc ('\"', asm_file);
2467 /* Output a file name in the form wanted by System V. */
2470 output_file_directive (asm_file, input_name)
2472 const char *input_name;
2474 int len = strlen (input_name);
2475 const char *na = input_name + len;
2477 /* NA gets INPUT_NAME sans directory names. */
2478 while (na > input_name)
2482 #ifdef DIR_SEPARATOR
2483 if (na[-1] == DIR_SEPARATOR)
2489 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2490 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2492 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2493 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2495 fprintf (asm_file, "\t.file\t");
2496 output_quoted_string (asm_file, na);
2497 fputc ('\n', asm_file);
2502 #ifdef ASM_IDENTIFY_LANGUAGE
2503 /* Routine to build language identifier for object file. */
2505 output_lang_identify (asm_out_file)
2508 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2509 char *s = (char *) alloca (len);
2510 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2511 ASM_OUTPUT_LABEL (asm_out_file, s);
2515 /* Routine to open a dump file. */
2517 open_dump_file (suffix, function_name)
2519 const char *function_name;
2526 dumpname = concat (dump_base_name, suffix, NULL);
2528 if (rtl_dump_file != NULL)
2529 fclose (rtl_dump_file);
2531 rtl_dump_file = fopen (dumpname, "a");
2533 if (rtl_dump_file == NULL)
2534 pfatal_with_name (dumpname);
2539 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2545 /* Routine to close a dump file. */
2547 close_dump_file (func, insns)
2548 void (*func) PROTO ((FILE *, rtx));
2555 func (rtl_dump_file, insns);
2557 fflush (rtl_dump_file);
2558 fclose (rtl_dump_file);
2560 rtl_dump_file = NULL;
2566 /* Routine to dump rtl into a file. */
2568 dump_rtl (suffix, decl, func, insns)
2571 void (*func) PROTO ((FILE *, rtx));
2574 open_dump_file (suffix, decl_printable_name (decl, 2));
2575 close_dump_file (func, insns);
2578 /* Routine to empty a dump file. */
2580 clean_dump_file (suffix)
2583 char * const dumpname = concat (dump_base_name, suffix, NULL);
2585 rtl_dump_file = fopen (dumpname, "w");
2587 if (rtl_dump_file == NULL)
2588 pfatal_with_name (dumpname);
2592 fclose (rtl_dump_file);
2593 rtl_dump_file = NULL;
2598 /* Do any final processing required for the declarations in VEC, of
2599 which there are LEN. We write out inline functions and variables
2600 that have been deferred until this point, but which are required.
2601 Returns non-zero if anything was put out. */
2603 wrapup_global_declarations (vec, len)
2610 int output_something = 0;
2612 for (i = 0; i < len; i++)
2616 /* We're not deferring this any longer. */
2617 DECL_DEFER_OUTPUT (decl) = 0;
2619 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2620 && incomplete_decl_finalize_hook != 0)
2621 (*incomplete_decl_finalize_hook) (decl);
2624 /* Now emit any global variables or functions that we have been
2625 putting off. We need to loop in case one of the things emitted
2626 here references another one which comes earlier in the list. */
2630 for (i = 0; i < len; i++)
2634 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2637 /* Don't write out static consts, unless we still need them.
2639 We also keep static consts if not optimizing (for debugging),
2640 unless the user specified -fno-keep-static-consts.
2641 ??? They might be better written into the debug information.
2642 This is possible when using DWARF.
2644 A language processor that wants static constants to be always
2645 written out (even if it is not used) is responsible for
2646 calling rest_of_decl_compilation itself. E.g. the C front-end
2647 calls rest_of_decl_compilation from finish_decl.
2648 One motivation for this is that is conventional in some
2649 environments to write things like:
2650 static const char rcsid[] = "... version string ...";
2651 intending to force the string to be in the executable.
2653 A language processor that would prefer to have unneeded
2654 static constants "optimized away" would just defer writing
2655 them out until here. E.g. C++ does this, because static
2656 constants are often defined in header files.
2658 ??? A tempting alternative (for both C and C++) would be
2659 to force a constant to be written if and only if it is
2660 defined in a main file, as opposed to an include file. */
2662 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2663 && (! TREE_READONLY (decl)
2664 || TREE_PUBLIC (decl)
2665 || (!optimize && flag_keep_static_consts)
2666 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2669 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2672 if (TREE_CODE (decl) == FUNCTION_DECL
2673 && DECL_INITIAL (decl) != 0
2674 && DECL_SAVED_INSNS (decl) != 0
2675 && (flag_keep_inline_functions
2676 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2677 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2680 temporary_allocation ();
2681 output_inline_function (decl);
2682 permanent_allocation (1);
2687 output_something = 1;
2691 return output_something;
2694 /* Issue appropriate warnings for the global declarations in VEC (of
2695 which there are LEN). Output debugging information for them. */
2697 check_global_declarations (vec, len)
2704 for (i = 0; i < len; i++)
2708 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2709 && ! TREE_ASM_WRITTEN (decl))
2710 /* Cancel the RTL for this decl so that, if debugging info
2711 output for global variables is still to come,
2712 this one will be omitted. */
2713 DECL_RTL (decl) = NULL;
2715 /* Warn about any function
2716 declared static but not defined.
2717 We don't warn about variables,
2718 because many programs have static variables
2719 that exist only to get some text into the object file. */
2720 if (TREE_CODE (decl) == FUNCTION_DECL
2722 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2723 && DECL_INITIAL (decl) == 0
2724 && DECL_EXTERNAL (decl)
2725 && ! DECL_ARTIFICIAL (decl)
2726 && ! TREE_PUBLIC (decl))
2728 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2729 pedwarn_with_decl (decl,
2730 "`%s' used but never defined");
2732 warning_with_decl (decl,
2733 "`%s' declared `static' but never defined");
2734 /* This symbol is effectively an "extern" declaration now. */
2735 TREE_PUBLIC (decl) = 1;
2736 assemble_external (decl);
2739 /* Warn about static fns or vars defined but not used,
2740 but not about inline functions or static consts
2741 since defining those in header files is normal practice. */
2743 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2744 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2745 && ! DECL_IN_SYSTEM_HEADER (decl)
2746 && ! DECL_EXTERNAL (decl)
2747 && ! TREE_PUBLIC (decl)
2748 && ! TREE_USED (decl)
2749 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2750 /* The TREE_USED bit for file-scope decls
2751 is kept in the identifier, to handle multiple
2752 external decls in different scopes. */
2753 && ! TREE_USED (DECL_NAME (decl)))
2754 warning_with_decl (decl, "`%s' defined but not used");
2756 #ifdef SDB_DEBUGGING_INFO
2757 /* The COFF linker can move initialized global vars to the end.
2758 And that can screw up the symbol ordering.
2759 By putting the symbols in that order to begin with,
2760 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2761 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2762 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2763 && ! DECL_EXTERNAL (decl)
2764 && DECL_RTL (decl) != 0)
2765 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2767 /* Output COFF information for non-global
2768 file-scope initialized variables. */
2769 if (write_symbols == SDB_DEBUG
2770 && TREE_CODE (decl) == VAR_DECL
2771 && DECL_INITIAL (decl)
2772 && ! DECL_EXTERNAL (decl)
2773 && DECL_RTL (decl) != 0
2774 && GET_CODE (DECL_RTL (decl)) == MEM)
2775 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2776 #endif /* SDB_DEBUGGING_INFO */
2777 #ifdef DWARF_DEBUGGING_INFO
2778 /* Output DWARF information for file-scope tentative data object
2779 declarations, file-scope (extern) function declarations (which
2780 had no corresponding body) and file-scope tagged type declarations
2781 and definitions which have not yet been forced out. */
2783 if (write_symbols == DWARF_DEBUG
2784 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2785 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2787 #ifdef DWARF2_DEBUGGING_INFO
2788 /* Output DWARF2 information for file-scope tentative data object
2789 declarations, file-scope (extern) function declarations (which
2790 had no corresponding body) and file-scope tagged type declarations
2791 and definitions which have not yet been forced out. */
2793 if (write_symbols == DWARF2_DEBUG
2794 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2795 TIMEVAR (symout_time, dwarf2out_decl (decl));
2800 /* Compile an entire file of output from cpp, named NAME.
2801 Write a file of assembly output and various debugging dumps. */
2810 int name_specified = name != 0;
2812 if (dump_base_name == 0)
2813 dump_base_name = name ? name : "gccdump";
2817 integration_time = 0;
2823 branch_prob_time = 0;
2828 local_alloc_time = 0;
2829 global_alloc_time = 0;
2834 shorten_branch_time = 0;
2840 /* Initialize data in various passes. */
2844 name = init_parse (name);
2845 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2846 || debug_info_level == DINFO_LEVEL_VERBOSE
2847 || flag_test_coverage
2848 || warn_notreached);
2850 init_decl_processing ();
2857 init_function_once ();
2858 init_stor_layout_once ();
2859 init_varasm_once ();
2861 /* The following initialization functions need to generate rtl, so
2862 provide a dummy function context for them. */
2863 init_dummy_function_start ();
2866 if (flag_caller_saves)
2867 init_caller_save ();
2868 expand_dummy_function_end ();
2870 /* If auxiliary info generation is desired, open the output file.
2871 This goes in the same directory as the source file--unlike
2872 all the other output files. */
2873 if (flag_gen_aux_info)
2875 aux_info_file = fopen (aux_info_file_name, "w");
2876 if (aux_info_file == 0)
2877 pfatal_with_name (aux_info_file_name);
2880 /* Clear the dump files. */
2882 clean_dump_file (".00.rtl");
2885 clean_dump_file (".01.jump");
2886 if (graph_dump_format != no_graph)
2887 clean_graph_dump_file (dump_base_name, ".01.jump");
2891 clean_dump_file (".02.cse");
2892 if (graph_dump_format != no_graph)
2893 clean_graph_dump_file (dump_base_name, ".02.cse");
2897 clean_dump_file (".03.addressof");
2898 if (graph_dump_format != no_graph)
2899 clean_graph_dump_file (dump_base_name, ".03.addressof");
2903 clean_dump_file (".04.gcse");
2904 if (graph_dump_format != no_graph)
2905 clean_graph_dump_file (dump_base_name, ".04.gcse");
2909 clean_dump_file (".05.loop");
2910 if (graph_dump_format != no_graph)
2911 clean_graph_dump_file (dump_base_name, ".05.loop");
2915 clean_dump_file (".06.cse2");
2916 if (graph_dump_format != no_graph)
2917 clean_graph_dump_file (dump_base_name, ".06.cse2");
2919 if (branch_prob_dump)
2921 clean_dump_file (".07.bp");
2922 if (graph_dump_format != no_graph)
2923 clean_graph_dump_file (dump_base_name, ".07.bp");
2927 clean_dump_file (".08.flow");
2928 if (graph_dump_format != no_graph)
2929 clean_graph_dump_file (dump_base_name, ".08.flow");
2933 clean_dump_file (".09.combine");
2934 if (graph_dump_format != no_graph)
2935 clean_graph_dump_file (dump_base_name, ".09.combine");
2939 clean_dump_file (".10.regmove");
2940 if (graph_dump_format != no_graph)
2941 clean_graph_dump_file (dump_base_name, ".10.regmove");
2943 #ifdef INSN_SCHEDULING
2946 clean_dump_file (".11.sched");
2947 if (graph_dump_format != no_graph)
2948 clean_graph_dump_file (dump_base_name, ".11.sched");
2953 clean_dump_file (".12.lreg");
2954 if (graph_dump_format != no_graph)
2955 clean_graph_dump_file (dump_base_name, ".12.lreg");
2957 if (global_reg_dump)
2959 clean_dump_file (".13.greg");
2960 if (graph_dump_format != no_graph)
2961 clean_graph_dump_file (dump_base_name, ".13.greg");
2965 clean_dump_file (".14.flow2");
2966 if (graph_dump_format != no_graph)
2967 clean_graph_dump_file (dump_base_name, ".14.flow2");
2969 #ifdef HAVE_peephole2
2972 clean_dump_file (".15.peephole2");
2973 if (graph_dump_format != no_graph)
2974 clean_graph_dump_file (dump_base_name, ".15.peephole2");
2977 #ifdef INSN_SCHEDULING
2980 clean_dump_file (".16.sched2");
2981 if (graph_dump_format != no_graph)
2982 clean_graph_dump_file (dump_base_name, ".16.sched2");
2987 clean_dump_file (".17.jump2");
2988 if (graph_dump_format != no_graph)
2989 clean_graph_dump_file (dump_base_name, ".17.jump2");
2991 #ifdef MACHINE_DEPENDENT_REORG
2992 if (mach_dep_reorg_dump)
2994 clean_dump_file (".18.mach");
2995 if (graph_dump_format != no_graph)
2996 clean_graph_dump_file (dump_base_name, ".18.mach");
3002 clean_dump_file (".19.dbr");
3003 if (graph_dump_format != no_graph)
3004 clean_graph_dump_file (dump_base_name, ".19.dbr");
3010 clean_dump_file (".20.stack");
3011 if (graph_dump_format != no_graph)
3012 clean_graph_dump_file (dump_base_name, ".20.stack");
3016 /* Open assembler code output file. */
3018 if (flag_syntax_only)
3019 asm_out_file = NULL;
3022 if (! name_specified && asm_file_name == 0)
3023 asm_out_file = stdout;
3026 int len = strlen (dump_base_name);
3027 register char *dumpname = (char *) xmalloc (len + 6);
3028 strcpy (dumpname, dump_base_name);
3029 strip_off_ending (dumpname, len);
3030 strcat (dumpname, ".s");
3031 if (asm_file_name == 0)
3032 asm_file_name = xstrdup (dumpname);
3033 if (!strcmp (asm_file_name, "-"))
3034 asm_out_file = stdout;
3036 asm_out_file = fopen (asm_file_name, "w");
3037 if (asm_out_file == 0)
3038 pfatal_with_name (asm_file_name);
3041 #ifdef IO_BUFFER_SIZE
3042 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
3043 _IOFBF, IO_BUFFER_SIZE);
3048 name = ggc_alloc_string (name, strlen (name));
3049 input_filename = name;
3051 /* Put an entry on the input file stack for the main input file. */
3053 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
3054 input_file_stack->next = 0;
3055 input_file_stack->name = input_filename;
3057 /* Perform language-specific initialization.
3058 This may set main_input_filename. */
3061 /* If the input doesn't start with a #line, use the input name
3062 as the official input file name. */
3063 if (main_input_filename == 0)
3064 main_input_filename = name;
3066 if (flag_syntax_only)
3068 write_symbols = NO_DEBUG;
3070 profile_block_flag = 0;
3074 ASM_FILE_START (asm_out_file);
3076 #ifdef ASM_COMMENT_START
3077 if (flag_verbose_asm)
3079 /* Print the list of options in effect. */
3080 print_version (asm_out_file, ASM_COMMENT_START);
3081 print_switch_values (asm_out_file, 0, MAX_LINE,
3082 ASM_COMMENT_START, " ", "\n");
3083 /* Add a blank line here so it appears in assembler output but not
3085 fprintf (asm_out_file, "\n");
3089 /* Output something to inform GDB that this compilation was by GCC. */
3090 #ifndef ASM_IDENTIFY_GCC
3091 fprintf (asm_out_file, "gcc2_compiled.:\n");
3093 ASM_IDENTIFY_GCC (asm_out_file);
3096 /* Output something to identify which front-end produced this file. */
3097 #ifdef ASM_IDENTIFY_LANGUAGE
3098 ASM_IDENTIFY_LANGUAGE (asm_out_file);
3100 } /* ! flag_syntax_only */
3102 #ifndef ASM_OUTPUT_SECTION_NAME
3103 if (flag_function_sections)
3105 warning ("-ffunction-sections not supported for this target.");
3106 flag_function_sections = 0;
3108 if (flag_data_sections)
3110 warning ("-fdata-sections not supported for this target.");
3111 flag_data_sections = 0;
3115 if (flag_function_sections
3116 && (profile_flag || profile_block_flag))
3118 warning ("-ffunction-sections disabled; it makes profiling impossible.");
3119 flag_function_sections = 0;
3122 #ifndef OBJECT_FORMAT_ELF
3123 if (flag_function_sections && write_symbols != NO_DEBUG)
3124 warning ("-ffunction-sections may affect debugging on some targets.");
3127 /* ??? Note: There used to be a conditional here
3128 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
3129 This was to guarantee separation between gcc_compiled. and
3130 the first function, for the sake of dbx on Suns.
3131 However, having the extra zero here confused the Emacs
3132 code for unexec, and might confuse other programs too.
3133 Therefore, I took out that change.
3134 In future versions we should find another way to solve
3135 that dbx problem. -- rms, 23 May 93. */
3137 /* Don't let the first function fall at the same address
3138 as gcc_compiled., if profiling. */
3139 if (profile_flag || profile_block_flag)
3141 /* It's best if we can write a nop here since some
3142 assemblers don't tolerate zeros in the text section. */
3143 output_asm_insn (get_insn_template (CODE_FOR_nop, NULL), NULL_PTR);
3146 /* If dbx symbol table desired, initialize writing it
3147 and output the predefined types. */
3148 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3149 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3150 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
3153 #ifdef SDB_DEBUGGING_INFO
3154 if (write_symbols == SDB_DEBUG)
3155 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
3158 #ifdef DWARF_DEBUGGING_INFO
3159 if (write_symbols == DWARF_DEBUG)
3160 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
3162 #ifdef DWARF2_UNWIND_INFO
3163 if (dwarf2out_do_frame ())
3164 dwarf2out_frame_init ();
3166 #ifdef DWARF2_DEBUGGING_INFO
3167 if (write_symbols == DWARF2_DEBUG)
3168 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
3171 /* Initialize yet another pass. */
3173 init_final (main_input_filename);
3174 init_branch_prob (dump_base_name);
3176 start_time = get_run_time ();
3178 /* Call the parser, which parses the entire file
3179 (calling rest_of_compilation for each function). */
3181 if (yyparse () != 0)
3183 if (errorcount == 0)
3184 notice ("Errors detected in input file (your bison.simple is out of date)\n");
3186 /* In case there were missing closebraces,
3187 get us back to the global binding level. */
3188 while (! global_bindings_p ())
3192 /* Compilation is now finished except for writing
3193 what's left of the symbol table output. */
3195 parse_time += get_run_time () - start_time;
3197 parse_time -= integration_time;
3198 parse_time -= varconst_time;
3200 if (flag_syntax_only)
3203 globals = getdecls ();
3205 /* Really define vars that have had only a tentative definition.
3206 Really output inline functions that must actually be callable
3207 and have not been output so far. */
3210 int len = list_length (globals);
3211 tree *vec = (tree *) alloca (sizeof (tree) * len);
3215 /* Process the decls in reverse order--earliest first.
3216 Put them into VEC from back to front, then take out from front. */
3218 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
3219 vec[len - i - 1] = decl;
3221 wrapup_global_declarations (vec, len);
3223 /* This must occur after the loop to output deferred functions. Else
3224 the profiler initializer would not be emitted if all the functions
3225 in this compilation unit were deferred.
3227 output_func_start_profiler can not cause any additional functions or
3228 data to need to be output, so it need not be in the deferred function
3230 output_func_start_profiler ();
3232 /* Now that all possible functions have been output, we can dump
3233 the exception table. */
3235 output_exception_table ();
3237 check_global_declarations (vec, len);
3240 /* Write out any pending weak symbol declarations. */
3244 /* Do dbx symbols */
3245 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3246 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3247 TIMEVAR (symout_time,
3249 dbxout_finish (asm_out_file, main_input_filename);
3253 #ifdef DWARF_DEBUGGING_INFO
3254 if (write_symbols == DWARF_DEBUG)
3255 TIMEVAR (symout_time,
3261 #ifdef DWARF2_UNWIND_INFO
3262 if (dwarf2out_do_frame ())
3263 dwarf2out_frame_finish ();
3266 #ifdef DWARF2_DEBUGGING_INFO
3267 if (write_symbols == DWARF2_DEBUG)
3268 TIMEVAR (symout_time,
3270 dwarf2out_finish ();
3274 /* Output some stuff at end of file if nec. */
3276 end_final (dump_base_name);
3278 if (branch_prob_dump)
3279 open_dump_file (".07.bp", NULL);
3281 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
3283 if (branch_prob_dump)
3284 close_dump_file (NULL, NULL_RTX);
3287 ASM_FILE_END (asm_out_file);
3291 /* Language-specific end of compilation actions. */
3295 /* Close the dump files. */
3297 if (flag_gen_aux_info)
3299 fclose (aux_info_file);
3301 unlink (aux_info_file_name);
3306 open_dump_file (".09.combine", NULL);
3307 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
3308 close_dump_file (NULL, NULL_RTX);
3311 /* Close non-debugging input and output files. Take special care to note
3312 whether fclose returns an error, since the pages might still be on the
3313 buffer chain while the file is open. */
3317 if (! flag_syntax_only
3318 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
3319 fatal_io_error (asm_file_name);
3321 /* Do whatever is necessary to finish printing the graphs. */
3322 if (graph_dump_format != no_graph)
3325 finish_graph_dump_file (dump_base_name, ".01.jump");
3327 finish_graph_dump_file (dump_base_name, ".02.cse");
3329 finish_graph_dump_file (dump_base_name, ".03.addressof");
3331 finish_graph_dump_file (dump_base_name, ".04.gcse");
3333 finish_graph_dump_file (dump_base_name, ".05.loop");
3335 finish_graph_dump_file (dump_base_name, ".06.cse2");
3336 if (branch_prob_dump)
3337 finish_graph_dump_file (dump_base_name, ".07.bp");
3339 finish_graph_dump_file (dump_base_name, ".08.flow");
3341 finish_graph_dump_file (dump_base_name, ".09.combine");
3343 finish_graph_dump_file (dump_base_name, ".10.regmove");
3344 #ifdef INSN_SCHEDULING
3346 finish_graph_dump_file (dump_base_name, ".11.sched");
3349 finish_graph_dump_file (dump_base_name, ".12.lreg");
3350 if (global_reg_dump)
3351 finish_graph_dump_file (dump_base_name, ".13.greg");
3353 finish_graph_dump_file (dump_base_name, ".14.flow2");
3354 #ifdef HAVE_peephole2
3356 finish_graph_dump_file (dump_base_name, ".15.peephole2");
3358 #ifdef INSN_SCHEDULING
3360 finish_graph_dump_file (dump_base_name, ".16.sched2");
3363 finish_graph_dump_file (dump_base_name, ".17.jump2");
3364 #ifdef MACHINE_DEPENDENT_REORG
3365 if (mach_dep_reorg_dump)
3366 finish_graph_dump_file (dump_base_name, ".18.mach");
3370 finish_graph_dump_file (dump_base_name, ".19.dbr");
3374 finish_graph_dump_file (dump_base_name, ".20.stack");
3378 /* Free up memory for the benefit of leak detectors. */
3381 /* Print the times. */
3385 all_time = get_run_time ();
3387 fprintf (stderr,"\n");
3389 print_time ("parse", parse_time);
3390 print_time ("integration", integration_time);
3391 print_time ("jump", jump_time);
3392 print_time ("cse", cse_time);
3393 print_time ("gcse", gcse_time);
3394 print_time ("loop", loop_time);
3395 print_time ("cse2", cse2_time);
3396 print_time ("branch-prob", branch_prob_time);
3397 print_time ("flow", flow_time);
3398 print_time ("combine", combine_time);
3399 print_time ("regmove", regmove_time);
3400 #ifdef INSN_SCHEDULING
3401 print_time ("sched", sched_time);
3403 print_time ("local-alloc", local_alloc_time);
3404 print_time ("global-alloc", global_alloc_time);
3405 print_time ("flow2", flow2_time);
3406 #ifdef HAVE_peephole2
3407 print_time ("peephole2", peephole2_time);
3409 #ifdef INSN_SCHEDULING
3410 print_time ("sched2", sched2_time);
3413 print_time ("dbranch", dbr_sched_time);
3415 print_time ("shorten-branch", shorten_branch_time);
3417 print_time ("stack-reg", stack_reg_time);
3419 print_time ("final", final_time);
3420 print_time ("varconst", varconst_time);
3421 print_time ("symout", symout_time);
3422 print_time ("dump", dump_time);
3424 print_time ("gc", gc_time);
3428 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3429 and TYPE_DECL nodes.
3431 This does nothing for local (non-static) variables, unless the
3432 variable is a register variable with an ASMSPEC. In that case, or
3433 if the variable is not an automatice, it sets up the RTL and
3434 outputs any assembler code (label definition, storage allocation
3435 and initialization).
3437 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3438 the assembler symbol name to be used. TOP_LEVEL is nonzero
3439 if this declaration is not within a function. */
3442 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
3444 const char *asmspec;
3448 /* Declarations of variables, and of functions defined elsewhere. */
3450 /* The most obvious approach, to put an #ifndef around where
3451 this macro is used, doesn't work since it's inside a macro call. */
3452 #ifndef ASM_FINISH_DECLARE_OBJECT
3453 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3456 /* Forward declarations for nested functions are not "external",
3457 but we need to treat them as if they were. */
3458 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
3459 || TREE_CODE (decl) == FUNCTION_DECL)
3460 TIMEVAR (varconst_time,
3462 make_decl_rtl (decl, asmspec, top_level);
3463 /* Initialized extern variable exists to be replaced
3464 with its value, or represents something that will be
3465 output in another file. */
3466 if (! (TREE_CODE (decl) == VAR_DECL
3467 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
3468 && DECL_INITIAL (decl) != 0
3469 && DECL_INITIAL (decl) != error_mark_node))
3470 /* Don't output anything
3471 when a tentative file-scope definition is seen.
3472 But at end of compilation, do output code for them. */
3473 if (! (! at_end && top_level
3474 && (DECL_INITIAL (decl) == 0
3475 || DECL_INITIAL (decl) == error_mark_node)))
3476 assemble_variable (decl, top_level, at_end, 0);
3477 if (decl == last_assemble_variable_decl)
3479 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
3483 else if (DECL_REGISTER (decl) && asmspec != 0)
3485 if (decode_reg_name (asmspec) >= 0)
3487 DECL_RTL (decl) = 0;
3488 make_decl_rtl (decl, asmspec, top_level);
3491 error ("invalid register name `%s' for register variable", asmspec);
3493 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3494 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3495 && TREE_CODE (decl) == TYPE_DECL)
3496 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
3498 #ifdef SDB_DEBUGGING_INFO
3499 else if (write_symbols == SDB_DEBUG && top_level
3500 && TREE_CODE (decl) == TYPE_DECL)
3501 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
3505 /* Called after finishing a record, union or enumeral type. */
3508 rest_of_type_compilation (type, toplev)
3509 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3513 tree type ATTRIBUTE_UNUSED;
3514 int toplev ATTRIBUTE_UNUSED;
3517 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3518 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3519 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3521 #ifdef SDB_DEBUGGING_INFO
3522 if (write_symbols == SDB_DEBUG)
3523 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3527 /* This is called from finish_function (within yyparse)
3528 after each top-level definition is parsed.
3529 It is supposed to compile that function or variable
3530 and output the assembler code for it.
3531 After we return, the tree storage is freed. */
3534 rest_of_compilation (decl)
3538 int start_time = get_run_time ();
3540 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3541 to be restored after we finish compiling the function
3542 (for use when compiling inline calls to this function). */
3543 tree saved_block_tree = 0;
3544 /* Likewise, for DECL_ARGUMENTS. */
3545 tree saved_arguments = 0;
3547 int rebuild_label_notes_after_reload;
3549 /* If we are reconsidering an inline function
3550 at the end of compilation, skip the stuff for making it inline. */
3552 if (DECL_SAVED_INSNS (decl) == 0)
3557 /* If requested, consider whether to make this function inline. */
3558 if (DECL_INLINE (decl) || flag_inline_functions)
3559 TIMEVAR (integration_time,
3561 lose = function_cannot_inline_p (decl);
3562 if (lose || ! optimize)
3564 if (warn_inline && DECL_INLINE (decl))
3565 warning_with_decl (decl, lose);
3566 DECL_ABSTRACT_ORIGIN (decl) = 0;
3567 /* Don't really compile an extern inline function.
3568 If we can't make it inline, pretend
3569 it was only declared. */
3570 if (DECL_EXTERNAL (decl))
3572 DECL_INITIAL (decl) = 0;
3573 goto exit_rest_of_compilation;
3577 /* ??? Note that this has the effect of making it look
3578 like "inline" was specified for a function if we choose
3579 to inline it. This isn't quite right, but it's
3580 probably not worth the trouble to fix. */
3581 inlinable = DECL_INLINE (decl) = 1;
3584 insns = get_insns ();
3586 /* Dump the rtl code if we are dumping rtl. */
3590 open_dump_file (".00.rtl", decl_printable_name (decl, 2));
3592 if (DECL_SAVED_INSNS (decl))
3593 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3595 close_dump_file (print_rtl, insns);
3598 /* If function is inline, and we don't yet know whether to
3599 compile it by itself, defer decision till end of compilation.
3600 finish_compilation will call rest_of_compilation again
3601 for those functions that need to be output. Also defer those
3602 functions that we are supposed to defer. */
3605 DECL_DEFER_OUTPUT (decl) = 1;
3607 if (DECL_DEFER_OUTPUT (decl)
3608 || (DECL_INLINE (decl)
3609 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3610 && ! flag_keep_inline_functions)
3611 || DECL_EXTERNAL (decl))))
3613 DECL_DEFER_OUTPUT (decl) = 1;
3615 /* If -Wreturn-type, we have to do a bit of compilation.
3616 However, if we just fall through we will call
3617 save_for_inline_copying() which results in excessive
3618 memory use. Instead, we just want to call
3619 jump_optimize() to figure out whether or not we can fall
3620 off the end of the function; we do the minimum amount of
3621 work necessary to make that safe. And, we set optimize
3622 to zero to keep jump_optimize from working too hard. */
3623 if (warn_return_type)
3625 int saved_optimize = optimize;
3627 find_exception_handler_labels ();
3628 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3629 !JUMP_AFTER_REGSCAN);
3630 optimize = saved_optimize;
3633 #ifdef DWARF_DEBUGGING_INFO
3634 /* Generate the DWARF info for the "abstract" instance
3635 of a function which we may later generate inlined and/or
3636 out-of-line instances of. */
3637 if (write_symbols == DWARF_DEBUG)
3639 set_decl_abstract_flags (decl, 1);
3640 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3641 set_decl_abstract_flags (decl, 0);
3644 #ifdef DWARF2_DEBUGGING_INFO
3645 /* Generate the DWARF2 info for the "abstract" instance
3646 of a function which we may later generate inlined and/or
3647 out-of-line instances of. */
3648 if (write_symbols == DWARF2_DEBUG)
3650 set_decl_abstract_flags (decl, 1);
3651 TIMEVAR (symout_time, dwarf2out_decl (decl));
3652 set_decl_abstract_flags (decl, 0);
3655 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3656 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
3657 goto exit_rest_of_compilation;
3660 /* If specified extern inline but we aren't inlining it, we are
3661 done. This goes for anything that gets here with DECL_EXTERNAL
3662 set, not just things with DECL_INLINE. */
3663 if (DECL_EXTERNAL (decl))
3664 goto exit_rest_of_compilation;
3667 /* Initialize some variables used by the optimizers. */
3668 init_function_for_compilation ();
3670 if (! DECL_DEFER_OUTPUT (decl))
3671 TREE_ASM_WRITTEN (decl) = 1;
3673 /* Now that integrate will no longer see our rtl, we need not distinguish
3674 between the return value of this function and the return value of called
3676 rtx_equal_function_value_matters = 0;
3678 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3679 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3681 goto exit_rest_of_compilation;
3684 /* Emit code to get eh context, if needed. */
3688 /* If we are doing position-independent code generation, now
3689 is the time to output special prologues and epilogues.
3690 We do not want to do this earlier, because it just clutters
3691 up inline functions with meaningless insns. */
3696 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3697 Note that that may have been done above, in save_for_inline_copying.
3698 The call to resume_temporary_allocation near the end of this function
3699 goes back to the usual state of affairs. This must be done after
3700 we've built up any unwinders for exception handling, and done
3701 the FINALIZE_PIC work, if necessary. */
3703 rtl_in_current_obstack ();
3705 insns = get_insns ();
3707 /* Copy any shared structure that should not be shared. */
3709 unshare_all_rtl (insns);
3711 init_EXPR_INSN_LIST_cache ();
3713 #ifdef SETJMP_VIA_SAVE_AREA
3714 /* This must be performed before virutal register instantiation. */
3715 if (current_function_calls_alloca)
3716 optimize_save_area_alloca (insns);
3719 /* Instantiate all virtual registers. */
3721 instantiate_virtual_regs (current_function_decl, get_insns ());
3723 /* See if we have allocated stack slots that are not directly addressable.
3724 If so, scan all the insns and create explicit address computation
3725 for all references to such slots. */
3726 /* fixup_stack_slots (); */
3728 /* Find all the EH handlers. */
3729 find_exception_handler_labels ();
3731 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3732 are initialized and to compute whether control can drop off the end
3734 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3735 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3736 JUMP_AFTER_REGSCAN));
3738 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3739 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3740 goto exit_rest_of_compilation;
3742 /* Try to identify useless null pointer tests and delete them. */
3743 if (flag_delete_null_pointer_checks)
3744 TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
3746 /* Dump rtl code after jump, if we are doing that. */
3748 dump_rtl (".01.jump", decl, print_rtl, insns);
3753 /* Perform common subexpression elimination.
3754 Nonzero value from `cse_main' means that jumps were simplified
3755 and some code may now be unreachable, so do
3756 jump optimization again. */
3761 open_dump_file (".02.cse", decl_printable_name (decl, 2));
3763 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3765 if (flag_thread_jumps)
3766 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3768 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3770 /* If we are not running the second CSE pass, then we are no longer
3771 expecting CSE to be run. */
3772 cse_not_expected = !flag_rerun_cse_after_loop;
3774 if (tem || optimize > 1)
3775 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3777 !JUMP_AFTER_REGSCAN));
3779 /* Run this after jump optmizations remove all the unreachable code
3780 so that unreachable code will not keep values live. */
3781 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3783 /* Try to identify useless null pointer tests and delete them. */
3784 if (flag_delete_null_pointer_checks)
3785 TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
3787 /* Dump rtl code after cse, if we are doing that. */
3791 close_dump_file (print_rtl, insns);
3792 if (graph_dump_format != no_graph)
3793 print_rtl_graph_with_bb (dump_base_name, ".02.cse", insns);
3797 purge_addressof (insns);
3798 reg_scan (insns, max_reg_num (), 1);
3802 dump_rtl (".03.addressof", decl, print_rtl, insns);
3803 if (graph_dump_format != no_graph)
3804 print_rtl_graph_with_bb (dump_base_name, ".03.addressof", insns);
3810 /* Perform global cse. */
3812 if (optimize > 0 && flag_gcse)
3815 open_dump_file (".04.gcse", decl_printable_name (decl, 2));
3817 TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file));
3819 /* If gcse altered any jumps, rerun jump optimizations to clean
3823 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3825 !JUMP_AFTER_REGSCAN));
3830 close_dump_file (print_rtl, insns);
3831 if (graph_dump_format != no_graph)
3832 print_rtl_graph_with_bb (dump_base_name, ".04.gcse", insns);
3838 /* Move constant computations out of loops. */
3843 open_dump_file (".05.loop", decl_printable_name (decl, 2));
3848 if (flag_rerun_loop_opt)
3850 /* We only want to perform unrolling once. */
3852 loop_optimize (insns, rtl_dump_file, 0, 0);
3855 /* The first call to loop_optimize makes some instructions
3856 trivially dead. We delete those instructions now in the
3857 hope that doing so will make the heuristics in loop work
3858 better and possibly speed up compilation. */
3859 delete_trivially_dead_insns (insns, max_reg_num ());
3861 /* The regscan pass is currently necessary as the alias
3862 analysis code depends on this information. */
3863 reg_scan (insns, max_reg_num (), 1);
3865 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
3868 /* Dump rtl code after loop opt, if we are doing that. */
3872 close_dump_file (print_rtl, insns);
3873 if (graph_dump_format != no_graph)
3874 print_rtl_graph_with_bb (dump_base_name, ".05.loop", insns);
3881 /* ??? Well, nearly. If HAVE_conditional_arithmetic, jump_optimize
3882 has put off all if-conversion until "after CSE". If we put this
3883 off any longer we may miss out doing if-conversion entirely. */
3884 cse_not_expected = 1;
3889 open_dump_file (".06.cse2", decl_printable_name (decl, 2));
3891 if (flag_rerun_cse_after_loop)
3893 /* Running another jump optimization pass before the second
3894 cse pass sometimes simplifies the RTL enough to allow
3895 the second CSE pass to do a better job. Jump_optimize can change
3896 max_reg_num so we must rerun reg_scan afterwards.
3897 ??? Rework to not call reg_scan so often. */
3898 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3899 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3901 JUMP_AFTER_REGSCAN));
3903 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3904 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3907 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3909 !JUMP_AFTER_REGSCAN));
3912 if (flag_thread_jumps)
3914 /* This pass of jump threading straightens out code
3915 that was kinked by loop optimization. */
3916 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3917 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3920 /* Dump rtl code after cse, if we are doing that. */
3924 close_dump_file (print_rtl, insns);
3925 if (graph_dump_format != no_graph)
3926 print_rtl_graph_with_bb (dump_base_name, ".06.cse2", insns);
3933 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3935 if (branch_prob_dump)
3936 open_dump_file (".07.bp", decl_printable_name (decl, 2));
3941 branch_prob (insns, rtl_dump_file);
3944 if (branch_prob_dump)
3946 close_dump_file (print_rtl, insns);
3947 if (graph_dump_format != no_graph)
3948 print_rtl_graph_with_bb (dump_base_name, ".07.bp", insns);
3955 /* Now we choose between stupid (pcc-like) register allocation
3956 (if we got the -noreg switch and not -opt)
3957 and smart register allocation. */
3959 if (optimize > 0) /* Stupid allocation probably won't work */
3960 obey_regdecls = 0; /* if optimizations being done. */
3964 /* Print function header into flow dump now
3965 because doing the flow analysis makes some of the dump. */
3968 open_dump_file (".08.flow", decl_printable_name (decl, 2));
3974 regclass (insns, max_reg_num ());
3975 stupid_life_analysis (insns, max_reg_num (),
3981 /* Do control and data flow analysis,
3982 and write some of the results to dump file. */
3987 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
3988 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
3991 if (warn_uninitialized)
3993 uninitialized_vars_warning (DECL_INITIAL (decl));
3994 setjmp_args_warning ();
3998 /* Dump rtl after flow analysis. */
4002 close_dump_file (print_rtl_with_bb, insns);
4003 if (graph_dump_format != no_graph)
4004 print_rtl_graph_with_bb (dump_base_name, ".08.flow", insns);
4010 /* The first life analysis pass has finished. From now on we can not
4011 generate any new pseudos. */
4014 /* If -opt, try combining insns through substitution. */
4018 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
4020 /* Dump rtl code after insn combination. */
4024 dump_rtl (".09.combine", decl, print_rtl_with_bb, insns);
4025 if (graph_dump_format != no_graph)
4026 print_rtl_graph_with_bb (dump_base_name, ".09.combine", insns);
4033 /* Register allocation pre-pass, to reduce number of moves
4034 necessary for two-address machines. */
4035 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
4038 open_dump_file (".10.regmove", decl_printable_name (decl, 2));
4040 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
4045 close_dump_file (print_rtl_with_bb, insns);
4046 if (graph_dump_format != no_graph)
4047 print_rtl_graph_with_bb (dump_base_name, ".10.regmove", insns);
4054 /* Print function header into sched dump now
4055 because doing the sched analysis makes some of the dump. */
4057 #ifdef INSN_SCHEDULING
4058 if (optimize > 0 && flag_schedule_insns)
4061 open_dump_file (".11.sched", decl_printable_name (decl, 2));
4063 /* Do control and data sched analysis,
4064 and write some of the results to dump file. */
4066 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
4068 /* Dump rtl after instruction scheduling. */
4072 close_dump_file (print_rtl_with_bb, insns);
4073 if (graph_dump_format != no_graph)
4074 print_rtl_graph_with_bb (dump_base_name, ".11.sched", insns);
4082 /* Determine if the current function is a leaf before running reload
4083 since this can impact optimizations done by the prologue and
4084 epilogue thus changing register elimination offsets. */
4085 current_function_is_leaf = leaf_function_p ();
4087 /* Unless we did stupid register allocation,
4088 allocate pseudo-regs that are used only within 1 basic block.
4090 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
4091 jump optimizer after register allocation and reloading are finished. */
4094 TIMEVAR (local_alloc_time,
4096 recompute_reg_usage (insns, ! optimize_size);
4097 regclass (insns, max_reg_num ());
4098 rebuild_label_notes_after_reload = local_alloc ();
4101 rebuild_label_notes_after_reload = 0;
4103 /* Dump rtl code after allocating regs within basic blocks. */
4107 open_dump_file (".12.lreg", decl_printable_name (decl, 2));
4109 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
4110 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
4112 close_dump_file (print_rtl_with_bb, insns);
4113 if (graph_dump_format != no_graph)
4114 print_rtl_graph_with_bb (dump_base_name, ".12.lreg", insns);
4120 if (global_reg_dump)
4121 open_dump_file (".13.greg", decl_printable_name (decl, 2));
4123 /* Unless we did stupid register allocation,
4124 allocate remaining pseudo-regs, then do the reload pass
4125 fixing up any insns that are invalid. */
4127 TIMEVAR (global_alloc_time,
4130 failure = global_alloc (rtl_dump_file);
4132 failure = reload (insns, 0, rtl_dump_file);
4137 goto exit_rest_of_compilation;
4142 /* Do a very simple CSE pass over just the hard registers. */
4144 reload_cse_regs (insns);
4146 /* Register allocation and reloading may have turned an indirect jump into
4147 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
4148 jumping instructions. */
4149 if (rebuild_label_notes_after_reload)
4150 TIMEVAR (jump_time, rebuild_jump_labels (insns));
4152 /* On some machines, the prologue and epilogue code, or parts thereof,
4153 can be represented as RTL. Doing so lets us schedule insns between
4154 it and the rest of the code and also allows delayed branch
4155 scheduling to operate in the epilogue. */
4157 thread_prologue_and_epilogue_insns (insns);
4159 /* If optimizing and we are performing instruction scheduling after
4160 reload, then go ahead and split insns now since we are about to
4161 recompute flow information anyway.
4163 reload_cse_regs may expose more splitting opportunities, expecially
4164 for double-word operations. */
4165 if (optimize > 0 && flag_schedule_insns_after_reload)
4166 split_all_insns (0);
4168 if (global_reg_dump)
4170 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
4171 close_dump_file (print_rtl_with_bb, insns);
4172 if (graph_dump_format != no_graph)
4173 print_rtl_graph_with_bb (dump_base_name, ".13.greg", insns);
4176 /* Re-create the death notes which were deleted during reload. */
4178 open_dump_file (".14.flow2", decl_printable_name (decl, 2));
4185 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4186 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4193 flow2_completed = 1;
4197 close_dump_file (print_rtl_with_bb, insns);
4198 if (graph_dump_format != no_graph)
4199 print_rtl_graph_with_bb (dump_base_name, ".14.flow2", insns);
4202 #ifdef HAVE_peephole2
4203 if (optimize > 0 && flag_peephole2)
4206 open_dump_file (".15.peephole2", decl_printable_name (decl, 2));
4208 TIMEVAR (peephole2_time, peephole2_optimize (rtl_dump_file));
4212 close_dump_file (print_rtl_with_bb, insns);
4213 if (graph_dump_format != no_graph)
4214 print_rtl_graph_with_bb (dump_base_name, ".15.peephole2", insns);
4219 #ifdef INSN_SCHEDULING
4220 if (optimize > 0 && flag_schedule_insns_after_reload)
4223 open_dump_file (".16.sched2", decl_printable_name (decl, 2));
4225 /* Do control and data sched analysis again,
4226 and write some more of the results to dump file. */
4228 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
4230 /* Dump rtl after post-reorder instruction scheduling. */
4234 close_dump_file (print_rtl_with_bb, insns);
4235 if (graph_dump_format != no_graph)
4236 print_rtl_graph_with_bb (dump_base_name, ".16.sched2", insns);
4244 #ifdef LEAF_REGISTERS
4245 current_function_uses_only_leaf_regs
4246 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
4249 /* One more attempt to remove jumps to .+1
4250 left by dead-store-elimination.
4251 Also do cross-jumping this time
4252 and delete no-op move insns. */
4256 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
4258 !JUMP_AFTER_REGSCAN));
4260 /* Dump rtl code after jump, if we are doing that. */
4264 dump_rtl (".17.jump2", decl, print_rtl_with_bb, insns);
4265 if (graph_dump_format != no_graph)
4266 print_rtl_graph_with_bb (dump_base_name, ".17.jump2", insns);
4270 /* If a machine dependent reorganization is needed, call it. */
4271 #ifdef MACHINE_DEPENDENT_REORG
4272 if (mach_dep_reorg_dump)
4273 open_dump_file (".18.mach", decl_printable_name (decl, 2));
4275 MACHINE_DEPENDENT_REORG (insns);
4277 if (mach_dep_reorg_dump)
4279 close_dump_file (print_rtl_with_bb, insns);
4280 if (graph_dump_format != no_graph)
4281 print_rtl_graph_with_bb (dump_base_name, ".18.mach", insns);
4288 /* If a scheduling pass for delayed branches is to be done,
4289 call the scheduling code. */
4292 if (optimize > 0 && flag_delayed_branch)
4295 open_dump_file (".19.dbr", decl_printable_name (decl, 2));
4297 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
4301 close_dump_file (print_rtl_with_bb, insns);
4302 if (graph_dump_format != no_graph)
4303 print_rtl_graph_with_bb (dump_base_name, ".19.dbr", insns);
4311 /* Shorten branches. */
4312 TIMEVAR (shorten_branch_time,
4314 shorten_branches (get_insns ());
4319 open_dump_file (".20.stack", decl_printable_name (decl, 2));
4321 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
4325 close_dump_file (print_rtl_with_bb, insns);
4326 if (graph_dump_format != no_graph)
4327 print_rtl_graph_with_bb (dump_base_name, ".20.stack", insns);
4334 /* Now turn the rtl into assembler code. */
4336 TIMEVAR (final_time,
4341 /* Get the function's name, as described by its RTL.
4342 This may be different from the DECL_NAME name used
4343 in the source file. */
4345 x = DECL_RTL (decl);
4346 if (GET_CODE (x) != MEM)
4349 if (GET_CODE (x) != SYMBOL_REF)
4351 fnname = XSTR (x, 0);
4353 assemble_start_function (decl, fnname);
4354 final_start_function (insns, asm_out_file, optimize);
4355 final (insns, asm_out_file, optimize, 0);
4356 final_end_function (insns, asm_out_file, optimize);
4357 assemble_end_function (decl, fnname);
4359 fflush (asm_out_file);
4361 /* Release all memory allocated by flow. */
4362 free_basic_block_vars (0);
4364 /* Release all memory held by regsets now */
4365 regset_release_memory ();
4371 /* Write DBX symbols if requested */
4373 /* Note that for those inline functions where we don't initially
4374 know for certain that we will be generating an out-of-line copy,
4375 the first invocation of this routine (rest_of_compilation) will
4376 skip over this code by doing a `goto exit_rest_of_compilation;'.
4377 Later on, finish_compilation will call rest_of_compilation again
4378 for those inline functions that need to have out-of-line copies
4379 generated. During that call, we *will* be routed past here. */
4381 #ifdef DBX_DEBUGGING_INFO
4382 if (write_symbols == DBX_DEBUG)
4383 TIMEVAR (symout_time, dbxout_function (decl));
4386 #ifdef DWARF_DEBUGGING_INFO
4387 if (write_symbols == DWARF_DEBUG)
4388 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
4391 #ifdef DWARF2_DEBUGGING_INFO
4392 if (write_symbols == DWARF2_DEBUG)
4393 TIMEVAR (symout_time, dwarf2out_decl (decl));
4396 exit_rest_of_compilation:
4400 /* In case the function was not output,
4401 don't leave any temporary anonymous types
4402 queued up for sdb output. */
4403 #ifdef SDB_DEBUGGING_INFO
4404 if (write_symbols == SDB_DEBUG)
4405 sdbout_types (NULL_TREE);
4408 /* Put back the tree of subblocks and list of arguments
4409 from before we copied them.
4410 Code generation and the output of debugging info may have modified
4411 the copy, but the original is unchanged. */
4413 if (saved_block_tree != 0)
4415 DECL_INITIAL (decl) = saved_block_tree;
4416 DECL_ARGUMENTS (decl) = saved_arguments;
4417 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
4420 reload_completed = 0;
4421 flow2_completed = 0;
4424 TIMEVAR (final_time,
4426 /* Clear out the insn_length contents now that they are no
4428 init_insn_lengths ();
4430 /* Clear out the real_constant_chain before some of the rtx's
4431 it runs through become garbage. */
4432 clear_const_double_mem ();
4434 /* Cancel the effect of rtl_in_current_obstack. */
4435 resume_temporary_allocation ();
4437 /* Show no temporary slots allocated. */
4440 free_basic_block_vars (0);
4443 /* Make sure volatile mem refs aren't considered valid operands for
4444 arithmetic insns. We must call this here if this is a nested inline
4445 function, since the above code leaves us in the init_recog state
4446 (from final.c), and the function context push/pop code does not
4447 save/restore volatile_ok.
4449 ??? Maybe it isn't necessary for expand_start_function to call this
4450 anymore if we do it here? */
4452 init_recog_no_volatile ();
4454 /* We're done with this function. Free up memory if we can. */
4455 free_after_parsing (current_function);
4456 if (! DECL_DEFER_OUTPUT (decl))
4457 free_after_compilation (current_function);
4458 current_function = 0;
4463 /* The parsing time is all the time spent in yyparse
4464 *except* what is spent in this function. */
4466 parse_time -= get_run_time () - start_time;
4477 printf ("Usage: %s input [switches]\n", progname);
4478 printf ("Switches:\n");
4480 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
4481 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
4482 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4483 printf (" -finline-limit=<number> Limits the size of inlined functions to <number>\n");
4485 for (i = NUM_ELEM (f_options); i--;)
4487 const char * description = f_options[i].description;
4489 if (description != NULL && * description != 0)
4490 printf (" -f%-21s %s\n",
4491 f_options[i].string, description);
4494 printf (" -O[number] Set optimisation level to [number]\n");
4495 printf (" -Os Optimise for space rather than speed\n");
4496 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
4497 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
4498 printf (" -w Suppress warnings\n");
4499 printf (" -W Enable extra warnings\n");
4501 for (i = NUM_ELEM (W_options); i--;)
4503 const char * description = W_options[i].description;
4505 if (description != NULL && * description != 0)
4506 printf (" -W%-21s %s\n",
4507 W_options[i].string, description);
4510 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4511 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4512 printf (" -p Enable function profiling\n");
4513 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4514 printf (" -a Enable block profiling \n");
4516 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4517 printf (" -ax Enable jump profiling \n");
4519 printf (" -o <file> Place output into <file> \n");
4520 printf (" -G <number> Put global and static data smaller than <number>\n");
4521 printf (" bytes into a special section (on some targets)\n");
4523 for (i = NUM_ELEM (debug_args); i--;)
4525 if (debug_args[i].description != NULL)
4526 printf (" -g%-21s %s\n", debug_args[i].arg, debug_args[i].description);
4529 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4530 printf (" -quiet Do not display functions compiled or elapsed time\n");
4531 printf (" -version Display the compiler's version\n");
4532 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4533 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4534 #if defined INSN_SCHEDULING
4535 printf (" -sched-verbose=<number> Set the verbosity level of the scheduler\n");
4537 printf (" --help Display this information\n");
4542 /* Display descriptions of language specific options.
4543 If there is no description, note that there is an undocumented option.
4544 If the description is empty, do not display anything. (This allows
4545 options to be deliberately undocumented, for whatever reason).
4546 If the option string is missing, then this is a marker, indicating
4547 that the description string is in fact the name of a language, whose
4548 language specific options are to follow. */
4550 if (NUM_ELEM (documented_lang_options) > 1)
4552 printf ("\nLanguage specific options:\n");
4554 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
4556 const char * description = documented_lang_options[i].description;
4557 const char * option = documented_lang_options[i].option;
4559 if (description == NULL)
4564 printf (" %-23.23s [undocumented]\n", option);
4566 else if (* description == 0)
4568 else if (option == NULL)
4572 ("\nThere are undocumented %s specific options as well.\n",
4576 printf ("\n Options for %s:\n", description);
4581 printf (" %-23.23s %s\n", option, description);
4586 printf ("\nThere are undocumented %s specific options as well.\n", lang);
4588 if (NUM_ELEM (target_switches) > 1
4589 #ifdef TARGET_OPTIONS
4590 || NUM_ELEM (target_options) > 1
4598 printf ("\nTarget specific options:\n");
4600 for (i = NUM_ELEM (target_switches); i--;)
4602 const char * option = target_switches[i].name;
4603 const char * description = target_switches[i].description;
4605 if (option == NULL || * option == 0)
4607 else if (description == NULL)
4612 printf (" -m%-21.21s [undocumented]\n", option);
4614 else if (* description != 0)
4615 doc += printf (" -m%-21.21s %s\n", option, description);
4618 #ifdef TARGET_OPTIONS
4619 for (i = NUM_ELEM (target_options); i--;)
4621 const char * option = target_options[i].prefix;
4622 const char * description = target_options[i].description;
4624 if (option == NULL || * option == 0)
4626 else if (description == NULL)
4631 printf (" -m%-21.21s [undocumented]\n", option);
4633 else if (* description != 0)
4634 doc += printf (" -m%-21.21s %s\n", option, description);
4640 printf ("\nThere are undocumented target specific options as well.\n");
4642 printf (" They exist, but they are not documented.\n");
4647 /* Parse a -d... comand line switch. */
4650 decode_d_option (arg)
4657 branch_prob_dump = 1;
4664 global_reg_dump = 1;
4680 #ifdef MACHINE_DEPENDENT_REORG
4681 mach_dep_reorg_dump = 1;
4689 branch_prob_dump = 1;
4706 global_reg_dump = 1;
4731 #ifdef MACHINE_DEPENDENT_REORG
4733 mach_dep_reorg_dump = 1;
4737 flag_print_asm_name = 1;
4758 graph_dump_format = vcg;
4764 rtl_dump_and_exit = 1;
4772 case 'D': /* These are handled by the preprocessor. */
4776 warning ("unrecognised gcc debugging option: %c", arg[-1]);
4781 /* Parse a -f... comand line switch. ARG is the value after the -f.
4782 It is safe to access 'ARG - 2' to generate the full switch name.
4783 Return the number of strings consumed. */
4786 decode_f_option (arg)
4791 /* Search for the option in the table of binary f options. */
4792 for (j = sizeof (f_options) / sizeof (f_options[0]); j--;)
4794 if (!strcmp (arg, f_options[j].string))
4796 *f_options[j].variable = f_options[j].on_value;
4800 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4801 && ! strcmp (arg + 3, f_options[j].string))
4803 *f_options[j].variable = ! f_options[j].on_value;
4808 if (!strncmp (arg, "inline-limit-", 13)
4809 || !strncmp (arg, "inline-limit=", 13))
4811 read_integral_parameter (arg + 13, arg - 2, inline_max_insns);
4812 #ifdef INSN_SCHEDULING
4813 else if (!strncmp (arg, "sched-verbose=", 14))
4814 fix_sched_param ("verbose", (char *)(arg + 14));
4816 else if (!strncmp (arg, "fixed-", 6))
4817 fix_register ((char *)(arg + 6), 1, 1);
4818 else if (!strncmp (arg, "call-used-", 10))
4819 fix_register ((char *)(arg + 10), 0, 1);
4820 else if (!strncmp (arg, "call-saved-", 11))
4821 fix_register ((char *)(arg + 11), 0, 0);
4822 else if (!strncmp (arg, "align-loops=", 12))
4823 align_loops = read_integral_parameter (arg + 12, arg - 2, align_loops);
4824 else if (!strncmp (arg, "align-functions=", 16))
4826 read_integral_parameter (arg + 16, arg - 2, align_functions);
4827 else if (!strncmp (arg, "align-jumps=", 12))
4828 align_jumps = read_integral_parameter (arg + 12, arg - 2, align_jumps);
4829 else if (!strncmp (arg, "align-labels=", 13))
4830 align_labels = read_integral_parameter (arg + 13, arg - 2, align_labels);
4831 else if (!strcmp (arg, "preprocessed"))
4832 /* Recognise this switch but do nothing. This prevents warnings
4833 about an unrecognised switch if cpplib has not been linked in. */
4841 /* Parse a -W... comand line switch. ARG is the value after the -W.
4842 It is safe to access 'ARG - 2' to generate the full switch name.
4843 Return the number of strings consumed. */
4845 decode_W_option (arg)
4850 /* Search for the option in the table of binary W options. */
4852 for (j = sizeof (W_options) / sizeof (W_options[0]); j--;)
4854 if (!strcmp (arg, W_options[j].string))
4856 *W_options[j].variable = W_options[j].on_value;
4860 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4861 && ! strcmp (arg + 3, W_options[j].string))
4863 *W_options[j].variable = ! W_options[j].on_value;
4868 if (!strncmp (arg, "id-clash-", 9))
4870 const int id_clash_val = read_integral_parameter (arg + 9, arg - 2, -1);
4872 if (id_clash_val != -1)
4874 id_clash_len = id_clash_val;
4878 else if (!strncmp (arg, "larger-than-", 12))
4880 const int larger_than_val =
4881 read_integral_parameter (arg + 12, arg - 2, -1);
4882 if (larger_than_val != -1)
4884 larger_than_size = larger_than_val;
4885 warn_larger_than = 1;
4894 /* Parse a -g... comand line switch. ARG is the value after the -g.
4895 It is safe to access 'ARG - 2' to generate the full switch name.
4896 Return the number of strings consumed. */
4898 decode_g_option (arg)
4902 /* A lot of code assumes write_symbols == NO_DEBUG if the
4903 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4904 of what debugging type has been selected). This records the
4905 selected type. It is an error to specify more than one
4907 static enum debug_info_type selected_debug_type = NO_DEBUG;
4908 /* Non-zero if debugging format has been explicitly set.
4909 -g and -ggdb don't explicitly set the debugging format so
4910 -gdwarf -g3 is equivalent to -gdwarf3. */
4911 static int type_explicitly_set_p = 0;
4912 /* Indexed by enum debug_info_type. */
4913 static const char * debug_type_names[] =
4915 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4918 /* The maximum admissible debug level value. */
4919 static const unsigned max_debug_level = 3;
4921 /* Look up ARG in the table. */
4922 for (da = debug_args; da->arg; da++)
4924 const int da_len = strlen (da->arg);
4926 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4928 enum debug_info_type type = da->debug_type;
4929 const char * p = arg + da_len;
4931 if (*p && (*p < '0' || *p > '9'))
4934 /* A debug flag without a level defaults to level 2.
4935 Note we do not want to call read_integral_parameter
4936 for that case since it will call atoi which
4939 ??? We may want to generalize the interface to
4940 read_integral_parameter to better handle this case
4941 if this case shows up often. */
4943 level = read_integral_parameter (p, 0, max_debug_level + 1);
4947 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4949 error ("use -gdwarf -g%d for DWARF v1, level %d",
4952 error ("use -gdwarf-2 for DWARF v2");
4955 if (level > max_debug_level)
4958 ignoring option `%s' due to invalid debug level specification",
4960 level = debug_info_level;
4963 if (type == NO_DEBUG)
4965 type = PREFERRED_DEBUGGING_TYPE;
4967 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4969 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4970 type = DWARF2_DEBUG;
4972 #ifdef DBX_DEBUGGING_INFO
4979 if (type == NO_DEBUG)
4980 warning ("`%s' not supported by this configuration of GCC",
4983 /* Does it conflict with an already selected type? */
4984 if (type_explicitly_set_p
4985 /* -g/-ggdb don't conflict with anything */
4986 && da->debug_type != NO_DEBUG
4987 && type != selected_debug_type)
4988 warning ("`%s' ignored, conflicts with `-g%s'",
4989 arg - 2, debug_type_names[(int) selected_debug_type]);
4992 /* If the format has already been set, -g/-ggdb
4993 only change the debug level. */
4994 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4995 ; /* don't change debugging type */
4998 selected_debug_type = type;
4999 type_explicitly_set_p = da->debug_type != NO_DEBUG;
5002 write_symbols = (level == 0
5004 : selected_debug_type);
5005 use_gnu_debug_info_extensions = da->use_extensions_p;
5006 debug_info_level = (enum debug_info_level) level;
5014 warning ("`%s' not supported by this configuration of GCC", arg - 2);
5019 /* Decode the first argument in the argv as a language-independent option.
5020 Return the number of strings consumed. 'strings_processed' is the
5021 number of strings that have already been decoded in a language
5022 specific fashion before this function was invoked. */
5025 independent_decode_option (argc, argv, strings_processed)
5028 unsigned strings_processed ATTRIBUTE_UNUSED;
5030 char * arg = argv[0];
5032 if (arg[0] != '-' || arg[1] == 0)
5044 if (!strcmp (arg, "-help"))
5059 /* Already been treated in main (). Do nothing. */
5063 set_target_switch (arg + 1);
5067 return decode_f_option (arg + 1);
5070 return decode_g_option (arg + 1);
5073 if (!strcmp (arg, "dumpbase"))
5078 dump_base_name = argv[1];
5082 decode_d_option (arg + 1);
5086 if (!strcmp (arg, "pedantic"))
5088 else if (!strcmp (arg, "pedantic-errors"))
5089 flag_pedantic_errors = pedantic = 1;
5090 else if (arg[1] == 0)
5097 if (!strcmp (arg, "quiet"))
5104 if (!strcmp (arg, "version"))
5112 inhibit_warnings = 1;
5121 /* We save the value of warn_uninitialized, since if they put
5122 -Wuninitialized on the command line, we need to generate a
5123 warning about not using it without also specifying -O. */
5124 if (warn_uninitialized != 1)
5125 warn_uninitialized = 2;
5128 return decode_W_option (arg + 1);
5134 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5135 warning ("`-a' option (basic block profile) not supported");
5137 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
5140 else if (!strcmp (arg, "ax"))
5142 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5143 warning ("`-ax' option (jump profiling) not supported");
5145 profile_block_flag = (!profile_block_flag
5146 || profile_block_flag == 2) ? 2 : 3;
5149 else if (!strncmp (arg, "aux-info", 8))
5151 flag_gen_aux_info = 1;
5157 aux_info_file_name = argv[1];
5161 aux_info_file_name = arg + 8;
5173 asm_file_name = argv[1];
5188 g_switch_val = read_integral_parameter (argv[1], 0, -1);
5193 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
5197 if (g_switch_val == -1)
5201 g_switch_set = TRUE;
5202 g_switch_value = g_switch_val;
5212 /* Entry point of cc1/c++. Decode command args, then call compile_file.
5213 Exit code is 35 if can't open files, 34 if fatal error,
5214 33 if had nonfatal errors, else success. */
5216 extern int main PROTO ((int, char **));
5226 /* save in case md file wants to emit args as a comment. */
5230 p = argv[0] + strlen (argv[0]);
5231 while (p != argv[0] && p[-1] != '/'
5232 #ifdef DIR_SEPARATOR
5233 && p[-1] != DIR_SEPARATOR
5239 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
5240 /* Get rid of any avoidable limit on stack size. */
5244 /* Set the stack limit huge so that alloca does not fail. */
5245 getrlimit (RLIMIT_STACK, &rlim);
5246 rlim.rlim_cur = rlim.rlim_max;
5247 setrlimit (RLIMIT_STACK, &rlim);
5251 #ifdef HAVE_LC_MESSAGES
5252 setlocale (LC_MESSAGES, "");
5254 (void) bindtextdomain (PACKAGE, localedir);
5255 (void) textdomain (PACKAGE);
5257 signal (SIGFPE, float_signal);
5260 signal (SIGPIPE, pipe_closed);
5263 decl_printable_name = decl_name;
5264 lang_expand_expr = (lang_expand_expr_t) do_abort;
5266 /* Initialize whether `char' is signed. */
5267 flag_signed_char = DEFAULT_SIGNED_CHAR;
5268 #ifdef DEFAULT_SHORT_ENUMS
5269 /* Initialize how much space enums occupy, by default. */
5270 flag_short_enums = DEFAULT_SHORT_ENUMS;
5273 /* Initialize the garbage-collector. */
5275 ggc_add_root (&input_file_stack, 1, sizeof input_file_stack,
5278 /* Perform language-specific options intialization. */
5279 lang_init_options ();
5281 /* Scan to see what optimization level has been specified. That will
5282 determine the default value of many flags. */
5283 for (i = 1; i < argc; i++)
5285 if (!strcmp (argv[i], "-O"))
5290 else if (argv[i][0] == '-' && argv[i][1] == 'O')
5292 /* Handle -Os, -O2, -O3, -O69, ... */
5293 char *p = &argv[i][2];
5295 if ((p[0] == 's') && (p[1] == 0))
5299 /* Optimizing for size forces optimize to be 2. */
5304 const int optimize_val = read_integral_parameter (p, p - 2, -1);
5305 if (optimize_val != -1)
5307 optimize = optimize_val;
5314 obey_regdecls = (optimize == 0);
5319 flag_thread_jumps = 1;
5321 flag_delayed_branch = 1;
5323 #ifdef CAN_DEBUG_WITHOUT_FP
5324 flag_omit_frame_pointer = 1;
5330 flag_cse_follow_jumps = 1;
5331 flag_cse_skip_blocks = 1;
5333 flag_expensive_optimizations = 1;
5334 flag_strength_reduce = 1;
5335 flag_rerun_cse_after_loop = 1;
5336 flag_rerun_loop_opt = 1;
5337 flag_caller_saves = 1;
5340 #ifdef INSN_SCHEDULING
5341 flag_schedule_insns = 1;
5342 flag_schedule_insns_after_reload = 1;
5345 flag_strict_aliasing = 1;
5346 flag_delete_null_pointer_checks = 1;
5351 flag_inline_functions = 1;
5354 if (optimize < 2 || optimize_size)
5359 align_functions = 1;
5362 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
5365 set_target_switch ("");
5367 #ifdef OPTIMIZATION_OPTIONS
5368 /* Allow default optimizations to be specified on a per-machine basis. */
5369 OPTIMIZATION_OPTIONS (optimize, optimize_size);
5372 /* Initialize register usage now so switches may override. */
5375 /* Perform normal command line switch decoding. */
5376 for (i = 1; i < argc;)
5378 unsigned lang_processed;
5379 unsigned indep_processed;
5381 /* Give the language a chance to decode the option for itself. */
5382 lang_processed = lang_decode_option (argc - i, argv + i);
5384 /* Now see if the option also has a language independent meaning.
5385 Some options are both language specific and language independent,
5386 eg --help. It is possible that there might be options that should
5387 only be decoded in a language independent way if the were not
5388 decoded in a langauge specific way, which is why 'lang_processed'
5390 indep_processed = independent_decode_option (argc - i, argv + i,
5393 if (lang_processed || indep_processed)
5394 i += (lang_processed > indep_processed
5395 ? lang_processed : indep_processed);
5397 /* This option applies to some other language; ignore it. */
5401 /* Checker uses the frame pointer. */
5402 if (flag_check_memory_usage)
5403 flag_omit_frame_pointer = 0;
5407 /* Inlining does not work if not optimizing,
5408 so force it not to be done. */
5412 /* The c_decode_option and lang_decode_option functions set
5413 this to `2' if -Wall is used, so we can avoid giving out
5414 lots of errors for people who don't realize what -Wall does. */
5415 if (warn_uninitialized == 1)
5416 warning ("-Wuninitialized is not supported without -O");
5419 #ifdef OVERRIDE_OPTIONS
5420 /* Some machines may reject certain combinations of options. */
5424 if (exceptions_via_longjmp == 2)
5426 #ifdef DWARF2_UNWIND_INFO
5427 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
5429 exceptions_via_longjmp = 1;
5433 /* Set up the align_*_log variables, defaulting them to 1 if they
5434 were still unset. */
5435 if (align_loops <= 0) align_loops = 1;
5436 align_loops_log = floor_log2 (align_loops*2-1);
5437 if (align_jumps <= 0) align_jumps = 1;
5438 align_jumps_log = floor_log2 (align_jumps*2-1);
5439 if (align_labels <= 0) align_labels = 1;
5440 align_labels_log = floor_log2 (align_labels*2-1);
5441 if (align_functions <= 0) align_functions = 1;
5442 align_functions_log = floor_log2 (align_functions*2-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 return (FATAL_EXIT_CODE);
5521 return (FATAL_EXIT_CODE);
5522 return (SUCCESS_EXIT_CODE);
5525 /* Decode -m switches. */
5526 /* Decode the switch -mNAME. */
5529 set_target_switch (name)
5533 int valid_target_option = 0;
5535 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5536 if (!strcmp (target_switches[j].name, name))
5538 if (target_switches[j].value < 0)
5539 target_flags &= ~-target_switches[j].value;
5541 target_flags |= target_switches[j].value;
5542 valid_target_option = 1;
5545 #ifdef TARGET_OPTIONS
5546 if (!valid_target_option)
5547 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5549 int len = strlen (target_options[j].prefix);
5550 if (!strncmp (target_options[j].prefix, name, len))
5552 *target_options[j].variable = name + len;
5553 valid_target_option = 1;
5558 if (!valid_target_option)
5559 error ("Invalid option `%s'", name);
5562 /* Print version information to FILE.
5563 Each line begins with INDENT (for the case where FILE is the
5564 assembler output file). */
5567 print_version (file, indent)
5572 #define __VERSION__ "[?]"
5576 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
5578 "%s%s%s version %s (%s) compiled by CC.\n"
5580 , indent, *indent != 0 ? " " : "",
5581 language_string, version_string, TARGET_NAME, __VERSION__);
5584 /* Print an option value and return the adjusted position in the line.
5585 ??? We don't handle error returns from fprintf (disk full); presumably
5586 other code will catch a disk full though. */
5589 print_single_switch (file, pos, max, indent, sep, term, type, name)
5592 const char *indent, *sep, *term, *type, *name;
5594 /* The ultrix fprintf returns 0 on success, so compute the result we want
5595 here since we need it for the following test. */
5596 int len = strlen (sep) + strlen (type) + strlen (name);
5601 fprintf (file, "%s", term);
5606 fprintf (file, "%s", indent);
5607 pos = strlen (indent);
5609 fprintf (file, "%s%s%s", sep, type, name);
5614 /* Print active target switches to FILE.
5615 POS is the current cursor position and MAX is the size of a "line".
5616 Each line begins with INDENT and ends with TERM.
5617 Each switch is separated from the next by SEP. */
5620 print_switch_values (file, pos, max, indent, sep, term)
5623 const char *indent, *sep, *term;
5628 /* Print the options as passed. */
5630 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5631 _("options passed: "), "");
5633 for (p = &save_argv[1]; *p != NULL; p++)
5637 if (strcmp (*p, "-o") == 0)
5643 if (strcmp (*p, "-quiet") == 0)
5645 if (strcmp (*p, "-version") == 0)
5650 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5653 fprintf (file, "%s", term);
5655 /* Print the -f and -m options that have been enabled.
5656 We don't handle language specific options but printing argv
5659 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5660 _("options enabled: "), "");
5662 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
5663 if (*f_options[j].variable == f_options[j].on_value)
5664 pos = print_single_switch (file, pos, max, indent, sep, term,
5665 "-f", f_options[j].string);
5667 /* Print target specific options. */
5669 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5670 if (target_switches[j].name[0] != '\0'
5671 && target_switches[j].value > 0
5672 && ((target_switches[j].value & target_flags)
5673 == target_switches[j].value))
5675 pos = print_single_switch (file, pos, max, indent, sep, term,
5676 "-m", target_switches[j].name);
5679 #ifdef TARGET_OPTIONS
5680 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5681 if (*target_options[j].variable != NULL)
5684 sprintf (prefix, "-m%s", target_options[j].prefix);
5685 pos = print_single_switch (file, pos, max, indent, sep, term,
5686 prefix, *target_options[j].variable);
5690 fprintf (file, "%s", term);
5693 /* Record the beginning of a new source file, named FILENAME. */
5696 debug_start_source_file (filename)
5697 register char *filename ATTRIBUTE_UNUSED;
5699 #ifdef DBX_DEBUGGING_INFO
5700 if (write_symbols == DBX_DEBUG)
5701 dbxout_start_new_source_file (filename);
5703 #ifdef DWARF_DEBUGGING_INFO
5704 if (debug_info_level == DINFO_LEVEL_VERBOSE
5705 && write_symbols == DWARF_DEBUG)
5706 dwarfout_start_new_source_file (filename);
5707 #endif /* DWARF_DEBUGGING_INFO */
5708 #ifdef DWARF2_DEBUGGING_INFO
5709 if (debug_info_level == DINFO_LEVEL_VERBOSE
5710 && write_symbols == DWARF2_DEBUG)
5711 dwarf2out_start_source_file (filename);
5712 #endif /* DWARF2_DEBUGGING_INFO */
5713 #ifdef SDB_DEBUGGING_INFO
5714 if (write_symbols == SDB_DEBUG)
5715 sdbout_start_new_source_file (filename);
5719 /* Record the resumption of a source file. LINENO is the line number in
5720 the source file we are returning to. */
5723 debug_end_source_file (lineno)
5724 register unsigned lineno ATTRIBUTE_UNUSED;
5726 #ifdef DBX_DEBUGGING_INFO
5727 if (write_symbols == DBX_DEBUG)
5728 dbxout_resume_previous_source_file ();
5730 #ifdef DWARF_DEBUGGING_INFO
5731 if (debug_info_level == DINFO_LEVEL_VERBOSE
5732 && write_symbols == DWARF_DEBUG)
5733 dwarfout_resume_previous_source_file (lineno);
5734 #endif /* DWARF_DEBUGGING_INFO */
5735 #ifdef DWARF2_DEBUGGING_INFO
5736 if (debug_info_level == DINFO_LEVEL_VERBOSE
5737 && write_symbols == DWARF2_DEBUG)
5738 dwarf2out_end_source_file ();
5739 #endif /* DWARF2_DEBUGGING_INFO */
5740 #ifdef SDB_DEBUGGING_INFO
5741 if (write_symbols == SDB_DEBUG)
5742 sdbout_resume_previous_source_file ();
5746 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5747 the tail part of the directive line, i.e. the part which is past the
5748 initial whitespace, #, whitespace, directive-name, whitespace part. */
5751 debug_define (lineno, buffer)
5752 register unsigned lineno ATTRIBUTE_UNUSED;
5753 register char *buffer ATTRIBUTE_UNUSED;
5755 #ifdef DWARF_DEBUGGING_INFO
5756 if (debug_info_level == DINFO_LEVEL_VERBOSE
5757 && write_symbols == DWARF_DEBUG)
5758 dwarfout_define (lineno, buffer);
5759 #endif /* DWARF_DEBUGGING_INFO */
5760 #ifdef DWARF2_DEBUGGING_INFO
5761 if (debug_info_level == DINFO_LEVEL_VERBOSE
5762 && write_symbols == DWARF2_DEBUG)
5763 dwarf2out_define (lineno, buffer);
5764 #endif /* DWARF2_DEBUGGING_INFO */
5767 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5768 the tail part of the directive line, i.e. the part which is past the
5769 initial whitespace, #, whitespace, directive-name, whitespace part. */
5772 debug_undef (lineno, buffer)
5773 register unsigned lineno ATTRIBUTE_UNUSED;
5774 register char *buffer ATTRIBUTE_UNUSED;
5776 #ifdef DWARF_DEBUGGING_INFO
5777 if (debug_info_level == DINFO_LEVEL_VERBOSE
5778 && write_symbols == DWARF_DEBUG)
5779 dwarfout_undef (lineno, buffer);
5780 #endif /* DWARF_DEBUGGING_INFO */
5781 #ifdef DWARF2_DEBUGGING_INFO
5782 if (debug_info_level == DINFO_LEVEL_VERBOSE
5783 && write_symbols == DWARF2_DEBUG)
5784 dwarf2out_undef (lineno, buffer);
5785 #endif /* DWARF2_DEBUGGING_INFO */