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>
45 #include "insn-attr.h"
46 #include "insn-codes.h"
47 #include "insn-config.h"
54 #include "basic-block.h"
57 #ifdef DWARF_DEBUGGING_INFO
61 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
62 #include "dwarf2out.h"
65 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
69 #ifdef SDB_DEBUGGING_INFO
73 #ifdef XCOFF_DEBUGGING_INFO
78 /* The extra parameters substantially improve the I/O performance. */
80 vms_fopen (fname, type)
84 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
85 fixed arguments, which matches ANSI's specification but not VAXCRTL's
86 pre-ANSI implementation. This hack circumvents the mismatch problem. */
87 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
90 return (*vmslib_fopen) (fname, type, "mbc=32",
91 "deq=64", "fop=tef", "shr=nil");
93 return (*vmslib_fopen) (fname, type, "mbc=32");
95 #define fopen vms_fopen
98 #ifndef DEFAULT_GDB_EXTENSIONS
99 #define DEFAULT_GDB_EXTENSIONS 1
102 /* If more than one debugging type is supported, you must define
103 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
105 This is one long line cause VAXC can't handle a \-newline. */
106 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
107 #ifndef PREFERRED_DEBUGGING_TYPE
108 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
109 #endif /* no PREFERRED_DEBUGGING_TYPE */
110 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
111 so the following code needn't care. */
112 #ifdef DBX_DEBUGGING_INFO
113 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
115 #ifdef SDB_DEBUGGING_INFO
116 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
118 #ifdef DWARF_DEBUGGING_INFO
119 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
121 #ifdef DWARF2_DEBUGGING_INFO
122 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
124 #ifdef XCOFF_DEBUGGING_INFO
125 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
127 #endif /* More than one debugger format enabled. */
129 /* If still not defined, must have been because no debugging formats
131 #ifndef PREFERRED_DEBUGGING_TYPE
132 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
135 #ifndef DIR_SEPARATOR
136 #define DIR_SEPARATOR '/'
139 extern int rtx_equal_function_value_matters;
141 #if ! (defined (VMS) || defined (OS2))
142 extern char **environ;
144 extern char *version_string, *language_string;
146 /* Carry information from ASM_DECLARE_OBJECT_NAME
147 to ASM_FINISH_DECLARE_OBJECT. */
149 extern int size_directive_output;
150 extern tree last_assemble_variable_decl;
152 extern char *init_parse PVPROTO((char *));
153 extern void finish_parse ();
154 extern void init_decl_processing ();
155 extern void init_obstacks ();
156 extern void init_tree_codes ();
157 extern void init_rtl ();
158 extern void init_regs ();
159 extern void init_optabs ();
160 extern void init_stmt ();
161 extern void init_reg_sets ();
162 extern void dump_flow_info ();
163 extern void dump_sched_info ();
164 extern void dump_local_alloc ();
165 extern void regset_release_memory ();
167 extern void print_rtl ();
168 extern void print_rtl_with_bb ();
170 void rest_of_decl_compilation ();
171 void error_with_file_and_line PVPROTO((const char *file,
172 int line, const char *s, ...));
173 void error_with_decl PVPROTO((tree decl, const char *s, ...));
174 void error_for_asm PVPROTO((rtx insn, const char *s, ...));
175 void notice PVPROTO((const char *s, ...));
176 void error PVPROTO((const char *s, ...));
177 void fatal PVPROTO((const char *s, ...));
178 void warning_with_file_and_line PVPROTO((const char *file,
179 int line, const char *s, ...));
180 void warning_with_decl PVPROTO((tree decl, const char *s, ...));
181 void warning PVPROTO((const char *s, ...));
182 void pedwarn PVPROTO((const char *s, ...));
183 void pedwarn_with_decl PVPROTO((tree decl, const char *s, ...));
184 void pedwarn_with_file_and_line PVPROTO((const char *file,
185 int line, const char *s, ...));
186 void sorry PVPROTO((const char *s, ...));
187 static void set_target_switch PROTO((const char *));
188 static char *decl_name PROTO((tree, int));
189 static void vmessage PROTO((const char *, const char *, va_list));
190 static void v_message_with_file_and_line PROTO((const char *, int, int,
191 const char *, va_list));
192 static void v_message_with_decl PROTO((tree, int, const char *, va_list));
193 static void file_and_line_for_asm PROTO((rtx, char **, int *));
194 static void v_error_with_file_and_line PROTO((const char *, int,
195 const char *, va_list));
196 static void v_error_with_decl PROTO((tree, const char *, va_list));
197 static void v_error_for_asm PROTO((rtx, const char *, va_list));
198 static void verror PROTO((const char *, va_list));
199 static void vfatal PROTO((const char *, va_list)) ATTRIBUTE_NORETURN;
200 static void v_warning_with_file_and_line PROTO ((const char *, int,
201 const char *, va_list));
202 static void v_warning_with_decl PROTO((tree, const char *, va_list));
203 static void v_warning_for_asm PROTO((rtx, const char *, va_list));
204 static void vwarning PROTO((const char *, va_list));
205 static void vpedwarn PROTO((const char *, va_list));
206 static void v_pedwarn_with_decl PROTO((tree, const char *, va_list));
207 static void v_pedwarn_with_file_and_line PROTO((const char *, int,
208 const char *, va_list));
209 static void vsorry PROTO((const char *, va_list));
210 static void float_signal PROTO((int)) ATTRIBUTE_NORETURN;
211 static void pipe_closed PROTO((int)) ATTRIBUTE_NORETURN;
212 #ifdef ASM_IDENTIFY_LANGUAGE
213 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
214 static void output_lang_identify PROTO((FILE *)) ATTRIBUTE_UNUSED;
216 static void open_dump_file PROTO((const char *, const char *));
217 static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
218 static void dump_rtl PROTO((const char *, tree, void (*) (FILE *, rtx), rtx));
219 static void clean_dump_file PROTO((const char *));
220 static void compile_file PROTO((char *));
221 static void display_help PROTO ((void));
223 static void print_version PROTO((FILE *, const char *));
224 static int print_single_switch PROTO((FILE *, int, int, const char *,
225 const char *, const char *,
226 const char *, const char *));
227 static void print_switch_values PROTO((FILE *, int, int, const char *,
228 const char *, const char *));
230 void print_rtl_graph_with_bb PROTO ((const char *, const char *, rtx));
231 void clean_graph_dump_file PROTO ((const char *, const char *));
232 void finish_graph_dump_file PROTO ((const char *, const char *));
233 /* Length of line when printing switch values. */
236 /* Name of program invoked, sans directories. */
240 /* Copy of arguments to main. */
244 /* Name of current original source file (what was input to cpp).
245 This comes from each #-command in the actual input. */
247 char *input_filename;
249 /* Name of top-level original source file (what was input to cpp).
250 This comes from the #-command at the beginning of the actual input.
251 If there isn't any there, then this is the cc1 input file name. */
253 char *main_input_filename;
255 /* Current line number in real source file. */
259 /* Nonzero if it is unsafe to create any new pseudo registers. */
262 /* Stack of currently pending input files. */
264 struct file_stack *input_file_stack;
266 /* Incremented on each change to input_file_stack. */
267 int input_file_stack_tick;
269 /* FUNCTION_DECL for function now being parsed or compiled. */
271 extern tree current_function_decl;
273 /* Name to use as base of names for dump output files. */
275 const char *dump_base_name;
277 /* Bit flags that specify the machine subtype we are compiling for.
278 Bits are tested using macros TARGET_... defined in the tm.h file
279 and set by `-m...' switches. Must be defined in rtlanal.c. */
281 extern int target_flags;
283 /* Flags saying which kinds of debugging dump have been requested. */
286 int rtl_dump_and_exit = 0;
287 int jump_opt_dump = 0;
288 int addressof_dump = 0;
293 int branch_prob_dump = 0;
295 int combine_dump = 0;
296 int regmove_dump = 0;
298 int local_reg_dump = 0;
299 int global_reg_dump = 0;
302 int jump2_opt_dump = 0;
304 int dbr_sched_dump = 0;
306 int flag_print_asm_name = 0;
308 int stack_reg_dump = 0;
310 #ifdef MACHINE_DEPENDENT_REORG
311 int mach_dep_reorg_dump = 0;
313 enum graph_dump_types graph_dump_format;
315 /* Name for output file of assembly code, specified with -o. */
319 /* Value of the -G xx switch, and whether it was passed or not. */
323 /* Type(s) of debugging information we are producing (if any).
324 See flags.h for the definitions of the different possible
325 types of debugging information. */
326 enum debug_info_type write_symbols = NO_DEBUG;
328 /* Level of debugging information we are producing. See flags.h
329 for the definitions of the different possible levels. */
330 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
332 /* Nonzero means use GNU-only extensions in the generated symbolic
333 debugging information. */
334 /* Currently, this only has an effect when write_symbols is set to
335 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
336 int use_gnu_debug_info_extensions = 0;
338 /* Nonzero means do optimizations. -O.
339 Particular numeric values stand for particular amounts of optimization;
340 thus, -O2 stores 2 here. However, the optimizations beyond the basic
341 ones are not controlled directly by this variable. Instead, they are
342 controlled by individual `flag_...' variables that are defaulted
343 based on this variable. */
347 /* Nonzero means optimize for size. -Os.
348 The only valid values are zero and non-zero. When optimize_size is
349 non-zero, optimize defaults to 2, but certain individual code
350 bloating optimizations are disabled. */
352 int optimize_size = 0;
354 /* Number of error messages and warning messages so far. */
357 int warningcount = 0;
360 /* Pointer to function to compute the name to use to print a declaration.
361 DECL is the declaration in question.
362 VERBOSITY determines what information will be printed:
363 0: DECL_NAME, demangled as necessary.
364 1: and scope information.
365 2: and any other information that might be interesting, such as function
366 parameter types in C++. */
368 char *(*decl_printable_name) PROTO ((tree, int));
370 /* Pointer to function to compute rtl for a language-specific tree code. */
372 typedef rtx (*lang_expand_expr_t)
373 PROTO ((union tree_node *, rtx, enum machine_mode,
374 enum expand_modifier modifier));
376 lang_expand_expr_t lang_expand_expr = 0;
378 /* Pointer to function to finish handling an incomplete decl at the
379 end of compilation. */
381 void (*incomplete_decl_finalize_hook) PROTO((tree)) = 0;
383 /* Nonzero if generating code to do profiling. */
385 int profile_flag = 0;
387 /* Nonzero if generating code to do profiling on a line-by-line basis. */
389 int profile_block_flag;
391 /* Nonzero if generating code to profile program flow graph arcs. */
393 int profile_arc_flag = 0;
395 /* Nonzero if generating info for gcov to calculate line test coverage. */
397 int flag_test_coverage = 0;
399 /* Nonzero indicates that branch taken probabilities should be calculated. */
401 int flag_branch_probabilities = 0;
403 /* Nonzero for -pedantic switch: warn about anything
404 that standard spec forbids. */
408 /* Temporarily suppress certain warnings.
409 This is set while reading code from a system header file. */
411 int in_system_header = 0;
413 /* Nonzero means do stupid register allocation.
414 Currently, this is 1 if `optimize' is 0. */
416 int obey_regdecls = 0;
418 /* Don't print functions as they are compiled and don't print
419 times taken by the various passes. -quiet. */
425 /* Nonzero means `char' should be signed. */
427 int flag_signed_char;
429 /* Nonzero means give an enum type only as many bytes as it needs. */
431 int flag_short_enums;
433 /* Nonzero for -fcaller-saves: allocate values in regs that need to
434 be saved across function calls, if that produces overall better code.
435 Optional now, so people can test it. */
437 #ifdef DEFAULT_CALLER_SAVES
438 int flag_caller_saves = 1;
440 int flag_caller_saves = 0;
443 /* Nonzero if structures and unions should be returned in memory.
445 This should only be defined if compatibility with another compiler or
446 with an ABI is needed, because it results in slower code. */
448 #ifndef DEFAULT_PCC_STRUCT_RETURN
449 #define DEFAULT_PCC_STRUCT_RETURN 1
452 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
454 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
456 /* Nonzero for -fforce-mem: load memory value into a register
457 before arithmetic on it. This makes better cse but slower compilation. */
459 int flag_force_mem = 0;
461 /* Nonzero for -fforce-addr: load memory address into a register before
462 reference to memory. This makes better cse but slower compilation. */
464 int flag_force_addr = 0;
466 /* Nonzero for -fdefer-pop: don't pop args after each function call;
467 instead save them up to pop many calls' args with one insns. */
469 int flag_defer_pop = 0;
471 /* Nonzero for -ffloat-store: don't allocate floats and doubles
472 in extended-precision registers. */
474 int flag_float_store = 0;
476 /* Nonzero for -fcse-follow-jumps:
477 have cse follow jumps to do a more extensive job. */
479 int flag_cse_follow_jumps;
481 /* Nonzero for -fcse-skip-blocks:
482 have cse follow a branch around a block. */
483 int flag_cse_skip_blocks;
485 /* Nonzero for -fexpensive-optimizations:
486 perform miscellaneous relatively-expensive optimizations. */
487 int flag_expensive_optimizations;
489 /* Nonzero for -fthread-jumps:
490 have jump optimize output of loop. */
492 int flag_thread_jumps;
494 /* Nonzero enables strength-reduction in loop.c. */
496 int flag_strength_reduce = 0;
498 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
499 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
500 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
503 int flag_unroll_loops;
505 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
506 This is generally not a win. */
508 int flag_unroll_all_loops;
510 /* Nonzero forces all invariant computations in loops to be moved
513 int flag_move_all_movables = 0;
515 /* Nonzero forces all general induction variables in loops to be
518 int flag_reduce_all_givs = 0;
520 /* Nonzero to perform full register move optimization passes. This is the
523 int flag_regmove = 0;
525 /* Nonzero for -fwritable-strings:
526 store string constants in data segment and don't uniquize them. */
528 int flag_writable_strings = 0;
530 /* Nonzero means don't put addresses of constant functions in registers.
531 Used for compiling the Unix kernel, where strange substitutions are
532 done on the assembly output. */
534 int flag_no_function_cse = 0;
536 /* Nonzero for -fomit-frame-pointer:
537 don't make a frame pointer in simple functions that don't require one. */
539 int flag_omit_frame_pointer = 0;
541 /* Nonzero means place each function into its own section on those platforms
542 which support arbitrary section names and unlimited numbers of sections. */
544 int flag_function_sections = 0;
546 /* ... and similar for data. */
548 int flag_data_sections = 0;
550 /* Nonzero to inhibit use of define_optimization peephole opts. */
552 int flag_no_peephole = 0;
554 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
555 operations in the interest of optimization. For example it allows
556 GCC to assume arguments to sqrt are nonnegative numbers, allowing
557 faster code for sqrt to be generated. */
559 int flag_fast_math = 0;
561 /* Nonzero means all references through pointers are volatile. */
565 /* Nonzero means treat all global and extern variables as volatile. */
567 int flag_volatile_global;
569 /* Nonzero means treat all static variables as volatile. */
571 int flag_volatile_static;
573 /* Nonzero means just do syntax checking; don't output anything. */
575 int flag_syntax_only = 0;
577 /* Nonzero means perform global cse. */
579 static int flag_gcse;
581 /* Nonzero means to rerun cse after loop optimization. This increases
582 compilation time about 20% and picks up a few more common expressions. */
584 static int flag_rerun_cse_after_loop;
586 /* Nonzero means to run loop optimizations twice. */
588 int flag_rerun_loop_opt;
590 /* Nonzero for -finline-functions: ok to inline functions that look like
591 good inline candidates. */
593 int flag_inline_functions;
595 /* Nonzero for -fkeep-inline-functions: even if we make a function
596 go inline everywhere, keep its definition around for debugging
599 int flag_keep_inline_functions;
601 /* Nonzero means that functions will not be inlined. */
605 /* Nonzero means that we should emit static const variables
606 regardless of whether or not optimization is turned on. */
608 int flag_keep_static_consts = 1;
610 /* Nonzero means we should be saving declaration info into a .X file. */
612 int flag_gen_aux_info = 0;
614 /* Specified name of aux-info file. */
616 static char *aux_info_file_name;
618 /* Nonzero means make the text shared if supported. */
620 int flag_shared_data;
622 /* Nonzero means schedule into delayed branch slots if supported. */
624 int flag_delayed_branch;
626 /* Nonzero if we are compiling pure (sharable) code.
627 Value is 1 if we are doing reasonable (i.e. simple
628 offset into offset table) pic. Value is 2 if we can
629 only perform register offsets. */
633 /* Nonzero means generate extra code for exception handling and enable
634 exception handling. */
638 /* Nonzero means use the new model for exception handling. Replaces
639 -DNEW_EH_MODEL as a compile option. */
641 int flag_new_exceptions = 0;
643 /* Nonzero means don't place uninitialized global data in common storage
648 /* Nonzero means pretend it is OK to examine bits of target floats,
649 even if that isn't true. The resulting code will have incorrect constants,
650 but the same series of instructions that the native compiler would make. */
652 int flag_pretend_float;
654 /* Nonzero means change certain warnings into errors.
655 Usually these are warnings about failure to conform to some standard. */
657 int flag_pedantic_errors = 0;
659 /* flag_schedule_insns means schedule insns within basic blocks (before
661 flag_schedule_insns_after_reload means schedule insns after
664 int flag_schedule_insns = 0;
665 int flag_schedule_insns_after_reload = 0;
668 /* The following flags have effect only for scheduling before register
671 flag_schedule_interblock means schedule insns accross basic blocks.
672 flag_schedule_speculative means allow speculative motion of non-load insns.
673 flag_schedule_speculative_load means allow speculative motion of some
675 flag_schedule_speculative_load_dangerous allows speculative motion of more
678 int flag_schedule_interblock = 1;
679 int flag_schedule_speculative = 1;
680 int flag_schedule_speculative_load = 0;
681 int flag_schedule_speculative_load_dangerous = 0;
684 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
685 by a cheaper branch, on a count register. */
686 int flag_branch_on_count_reg;
688 /* -finhibit-size-directive inhibits output of .size for ELF.
689 This is used only for compiling crtstuff.c,
690 and it may be extended to other effects
691 needed for crtstuff.c on other systems. */
692 int flag_inhibit_size_directive = 0;
694 /* -fverbose-asm causes extra 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 -fno-verbose-asm, the default, causes the extra information
699 to be omitted and is useful when comparing two assembler files. */
701 int flag_verbose_asm = 0;
703 /* -dA causes debug commentary information to be produced in
704 the generated assembly code (to make it more readable). This option
705 is generally only of use to those who actually need to read the
706 generated assembly code (perhaps while debugging the compiler itself).
707 Currently, this switch is only used by dwarfout.c; however, it is intended
708 to be a catchall for printing debug information in the assembler file. */
710 int flag_debug_asm = 0;
712 /* -fgnu-linker specifies use of the GNU linker for initializations.
713 (Or, more generally, a linker that handles initializations.)
714 -fno-gnu-linker says that collect2 will be used. */
716 int flag_gnu_linker = 0;
718 int flag_gnu_linker = 1;
721 /* Tag all structures with __attribute__(packed) */
722 int flag_pack_struct = 0;
724 /* Emit code to check for stack overflow; also may cause large objects
725 to be allocated dynamically. */
726 int flag_stack_check;
728 /* -fcheck-memory-usage causes extra code to be generated in order to check
729 memory accesses. This is used by a detector of bad memory accesses such
731 int flag_check_memory_usage = 0;
733 /* -fprefix-function-name causes function name to be prefixed. This
734 can be used with -fcheck-memory-usage to isolate code compiled with
735 -fcheck-memory-usage. */
736 int flag_prefix_function_name = 0;
738 /* 0 if pointer arguments may alias each other. True in C.
739 1 if pointer arguments may not alias each other but may alias
741 2 if pointer arguments may not alias each other and may not
742 alias global variables. True in Fortran.
743 This defaults to 0 for C. */
744 int flag_argument_noalias = 0;
746 /* Nonzero if we should do (language-dependent) alias analysis.
747 Typically, this analysis will assume that expressions of certain
748 types do not alias expressions of certain other types. Only used
749 if alias analysis (in general) is enabled. */
750 int flag_strict_aliasing = 0;
752 /* Instrument functions with calls at entry and exit, for profiling. */
753 int flag_instrument_function_entry_exit = 0;
755 /* Nonzero means ignore `#ident' directives. 0 means handle them.
756 On SVR4 targets, it also controls whether or not to emit a
757 string identifying the compiler. */
759 int flag_no_ident = 0;
761 /* Table of supported debugging formats. */
765 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
766 constant expression, we use NO_DEBUG in its place. */
767 enum debug_info_type debug_type;
768 int use_extensions_p;
769 const char * description;
773 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
774 "Generate default debug format output" },
775 { "ggdb", NO_DEBUG, 1, "Generate default extended debug format output" },
776 #ifdef DBX_DEBUGGING_INFO
777 { "gstabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
778 { "gstabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
780 #ifdef DWARF_DEBUGGING_INFO
781 { "gdwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
782 { "gdwarf+", DWARF_DEBUG, 1,
783 "Generated extended DWARF-1 format debug output" },
785 #ifdef DWARF2_DEBUGGING_INFO
786 { "gdwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
788 #ifdef XCOFF_DEBUGGING_INFO
789 { "gxcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
790 { "gxcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
792 #ifdef SDB_DEBUGGING_INFO
793 { "gcoff", SDB_DEBUG, 0, "Generate COFF format debug output" },
803 const char * description;
805 lang_independent_options;
807 /* Add or remove a leading underscore from user symbols. */
808 int flag_leading_underscore = -1;
810 /* The user symbol prefix after having resolved same. */
811 const char *user_label_prefix;
813 /* A default for same. */
814 #ifndef USER_LABEL_PREFIX
815 #define USER_LABEL_PREFIX ""
818 /* Table of language-independent -f options.
819 STRING is the option name. VARIABLE is the address of the variable.
820 ON_VALUE is the value to store in VARIABLE
821 if `-fSTRING' is seen as an option.
822 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
824 lang_independent_options f_options[] =
826 {"float-store", &flag_float_store, 1,
827 "Do not store floats in registers" },
828 {"volatile", &flag_volatile, 1,
829 "Consider all mem refs through pointers as volatile"},
830 {"volatile-global", &flag_volatile_global, 1,
831 "Consider all mem refs to global data to be volatile" },
832 {"volatile-static", &flag_volatile_static, 1,
833 "Consider all mem refs to static data to be volatile" },
834 {"defer-pop", &flag_defer_pop, 1,
835 "Defer popping functions args from stack until later" },
836 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
837 "When possible do not generate stack frames"},
838 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
839 "When running CSE, follow jumps to their targets" },
840 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
841 "When running CSE, follow conditional jumps" },
842 {"expensive-optimizations", &flag_expensive_optimizations, 1,
843 "Perform a number of minor, expensive optimisations" },
844 {"thread-jumps", &flag_thread_jumps, 1,
845 "Perform jump threading optimisations"},
846 {"strength-reduce", &flag_strength_reduce, 1,
847 "Perform strength reduction optimisations" },
848 {"unroll-loops", &flag_unroll_loops, 1,
849 "Perform loop unrolling when iteration count is known" },
850 {"unroll-all-loops", &flag_unroll_all_loops, 1,
851 "Perform loop unrolling for all loops" },
852 {"move-all-movables", &flag_move_all_movables, 1,
853 "Force all loop invariant computations out of loops" },
854 {"reduce-all-givs", &flag_reduce_all_givs, 1,
855 "Strength reduce all loop general induction variables" },
856 {"writable-strings", &flag_writable_strings, 1,
857 "Store strings in writable data section" },
858 {"peephole", &flag_no_peephole, 0,
859 "Enable machine specific peephole optimisations" },
860 {"force-mem", &flag_force_mem, 1,
861 "Copy memory operands into registers before using" },
862 {"force-addr", &flag_force_addr, 1,
863 "Copy memory address constants into regs before using" },
864 {"function-cse", &flag_no_function_cse, 0,
865 "Allow function addresses to be held in registers" },
866 {"inline-functions", &flag_inline_functions, 1,
867 "Integrate simple functions into their callers" },
868 {"keep-inline-functions", &flag_keep_inline_functions, 1,
869 "Generate code for funcs even if they are fully inlined" },
870 {"inline", &flag_no_inline, 0,
871 "Pay attention to the 'inline' keyword"},
872 {"keep-static-consts", &flag_keep_static_consts, 1,
873 "Emit static const variables even if they are not used" },
874 {"syntax-only", &flag_syntax_only, 1,
875 "Check for syntax errors, then stop" },
876 {"shared-data", &flag_shared_data, 1,
877 "Mark data as shared rather than private" },
878 {"caller-saves", &flag_caller_saves, 1,
879 "Enable saving registers around function calls" },
880 {"pcc-struct-return", &flag_pcc_struct_return, 1,
881 "Return 'short' aggregates in memory, not registers" },
882 {"reg-struct-return", &flag_pcc_struct_return, 0,
883 "Return 'short' aggregates in registers" },
884 {"delayed-branch", &flag_delayed_branch, 1,
885 "Attempt to fill delay slots of branch instructions" },
886 {"gcse", &flag_gcse, 1,
887 "Perform the global common subexpression elimination" },
888 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
889 "Run CSE pass after loop optimisations"},
890 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
891 "Run the loop optimiser twice"},
892 {"pretend-float", &flag_pretend_float, 1,
893 "Pretend that host and target use the same FP format"},
894 {"schedule-insns", &flag_schedule_insns, 1,
895 "Reschedule instructions to avoid pipeline stalls"},
896 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
897 "Run two passes of the instruction scheduler"},
899 {"sched-interblock",&flag_schedule_interblock, 1,
900 "Enable scheduling across basic blocks" },
901 {"sched-spec",&flag_schedule_speculative, 1,
902 "Allow speculative motion of non-loads" },
903 {"sched-spec-load",&flag_schedule_speculative_load, 1,
904 "Allow speculative motion of some loads" },
905 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
906 "Allow speculative motion of more loads" },
908 {"branch-count-reg",&flag_branch_on_count_reg, 1,
909 "Replace add,compare,branch with branch on count reg"},
910 {"pic", &flag_pic, 1,
911 "Generate position independent code, if possible"},
912 {"PIC", &flag_pic, 2, ""},
913 {"exceptions", &flag_exceptions, 1,
914 "Enable exception handling" },
915 {"new-exceptions", &flag_new_exceptions, 1,
916 "Use the new model for exception handling" },
917 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
918 "Use setjmp/longjmp to handle exceptions" },
919 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
920 "Support asynchronous exceptions" },
921 {"profile-arcs", &profile_arc_flag, 1,
922 "Insert arc based program profiling code" },
923 {"test-coverage", &flag_test_coverage, 1,
924 "Create data files needed by gcov" },
925 {"branch-probabilities", &flag_branch_probabilities, 1,
926 "Use profiling information for branch probabilities" },
927 {"fast-math", &flag_fast_math, 1,
928 "Improve FP speed by violating ANSI & IEEE rules" },
929 {"common", &flag_no_common, 0,
930 "Do not put unitialised globals in the common section" },
931 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
932 "Do not generate .size directives" },
933 {"function-sections", &flag_function_sections, 1,
934 "place each function into its own section" },
935 {"data-sections", &flag_data_sections, 1,
936 "place data items into their own section" },
937 {"verbose-asm", &flag_verbose_asm, 1,
938 "Add extra commentry to assembler output"},
939 {"gnu-linker", &flag_gnu_linker, 1,
940 "Output GNU ld formatted global initialisers"},
941 {"regmove", &flag_regmove, 1,
942 "Enables a register move optimisation"},
943 {"optimize-register-move", &flag_regmove, 1,
944 "Do the full regmove optimization pass"},
945 {"pack-struct", &flag_pack_struct, 1,
946 "Pack structure members together without holes" },
947 {"stack-check", &flag_stack_check, 1,
948 "Insert stack checking code into the program" },
949 {"argument-alias", &flag_argument_noalias, 0,
950 "Specify that arguments may alias each other & globals"},
951 {"argument-noalias", &flag_argument_noalias, 1,
952 "Assume arguments may alias globals but not each other"},
953 {"argument-noalias-global", &flag_argument_noalias, 2,
954 "Assume arguments do not alias each other or globals" },
955 {"strict-aliasing", &flag_strict_aliasing, 1,
956 "Assume strict aliasing rules apply" },
957 {"check-memory-usage", &flag_check_memory_usage, 1,
958 "Generate code to check every memory access" },
959 {"prefix-function-name", &flag_prefix_function_name, 1,
960 "Add a prefix to all function names" },
961 {"dump-unnumbered", &flag_dump_unnumbered, 1,
962 "Suppress output of instruction numbers and line number notes in debugging dumps"},
963 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
964 "Instrument function entry/exit with profiling calls"},
965 {"leading-underscore", &flag_leading_underscore, 1,
966 "External symbols have a leading underscore" },
967 {"ident", &flag_no_ident, 0,
968 "Process #ident directives"}
971 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
973 /* Table of language-specific options. */
975 static struct lang_opt
978 const char * description;
980 documented_lang_options[] =
982 /* In order not to overload the --help output, the convention
983 used here is to only describe those options which are not
984 enabled by default. */
986 { "-ansi", "Compile just for ANSI C" },
987 { "-fallow-single-precision",
988 "Do not promote floats to double if using -traditional" },
989 { "-std= ", "Determine language standard"},
991 { "-fsigned-bitfields", "" },
992 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
993 { "-fno-signed-bitfields", "" },
994 { "-fno-unsigned-bitfields","" },
995 { "-fsigned-char", "Make 'char' be signed by default"},
996 { "-funsigned-char", "Make 'char' be unsigned by default"},
997 { "-fno-signed-char", "" },
998 { "-fno-unsigned-char", "" },
1000 { "-ftraditional", "" },
1001 { "-traditional", "Attempt to support traditional K&R style C"},
1002 { "-fnotraditional", "" },
1003 { "-fno-traditional", "" },
1006 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1007 { "-fbuiltin", "" },
1008 { "-fno-builtin", "Do not recognise any built in functions" },
1009 { "-fhosted", "Assume normal C execution environment" },
1010 { "-fno-hosted", "" },
1012 "Assume that standard libraries & main might not exist" },
1013 { "-fno-freestanding", "" },
1014 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1015 { "-fno-cond-mismatch", "" },
1016 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1017 { "-fno-dollars-in-identifiers", "" },
1018 { "-fshort-double", "Use the same size for double as for float" },
1019 { "-fno-short-double", "" },
1020 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1021 { "-fno-short-enums", "" },
1023 { "-Wall", "Enable most warning messages" },
1024 { "-Wbad-function-cast",
1025 "Warn about casting functions to incompatible types" },
1026 { "-Wno-bad-function-cast", "" },
1027 { "-Wmissing-noreturn",
1028 "Warn about functions which might be candidates for attribute noreturn" },
1029 { "-Wno-missing-noreturn", "" },
1030 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1031 { "-Wno-cast-qual", "" },
1032 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1033 { "-Wno-char-subscripts", "" },
1034 { "-Wcomment", "Warn if nested comments are detected" },
1035 { "-Wno-comment", "" },
1036 { "-Wcomments", "Warn if nested comments are detected" },
1037 { "-Wno-comments", "" },
1038 { "-Wconversion", "Warn about possibly confusing type conversions" },
1039 { "-Wno-conversion", "" },
1040 { "-Wformat", "Warn about printf format anomalies" },
1041 { "-Wno-format", "" },
1042 { "-Wimplicit-function-declaration",
1043 "Warn about implicit function declarations" },
1044 { "-Wno-implicit-function-declaration", "" },
1045 { "-Werror-implicit-function-declaration", "" },
1046 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1047 { "-Wno-implicit-int", "" },
1048 { "-Wimplicit", "" },
1049 { "-Wno-implicit", "" },
1050 { "-Wimport", "Warn about the use of the #import directive" },
1051 { "-Wno-import", "" },
1052 { "-Wlong-long","" },
1053 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1054 { "-Wmain", "Warn about suspicious declarations of main" },
1055 { "-Wno-main", "" },
1056 { "-Wmissing-braces",
1057 "Warn about possibly missing braces around initialisers" },
1058 { "-Wno-missing-braces", "" },
1059 { "-Wmissing-declarations",
1060 "Warn about global funcs without previous declarations"},
1061 { "-Wno-missing-declarations", "" },
1062 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1063 { "-Wno-missing-prototypes", "" },
1064 { "-Wmultichar", "Warn about use of multicharacter literals"},
1065 { "-Wno-multichar", "" },
1066 { "-Wnested-externs", "Warn about externs not at file scope level" },
1067 { "-Wno-nested-externs", "" },
1068 { "-Wparentheses", "Warn about possible missing parentheses" },
1069 { "-Wno-parentheses", "" },
1070 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1071 { "-Wno-pointer-arith", "" },
1072 { "-Wredundant-decls",
1073 "Warn about multiple declarations of the same object" },
1074 { "-Wno-redundant-decls", "" },
1075 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1076 { "-Wno-sign-compare", "" },
1077 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1078 { "-Wno-unknown-pragmas", "" },
1079 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1080 { "-Wno-strict-prototypes", "" },
1081 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1082 { "-Wno-traditional", "" },
1083 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1084 { "-Wno-trigraphs", "" },
1086 { "-Wno-undef", "" },
1087 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1088 { "-Wno-write-strings", "" },
1090 /* These are for languages with USE_CPPLIB. */
1091 /* These options are already documented in cpplib.c */
1097 { "-MD", "Print dependencies to FILE.d" },
1098 { "-MMD", "Print dependencies to FILE.d" },
1099 { "-M", "Print dependencies to stdout" },
1100 { "-MM", "Print dependencies to stdout" },
1101 #endif /* USE_CPPLIB */
1104 { "-idirafter", "" },
1109 { "-iwithprefix", "" },
1110 { "-iwithprefixbefore", "" },
1112 { "-lang-c89", "" },
1113 { "-lang-c++", "" },
1115 { "-nostdinc", "" },
1116 { "-nostdinc++", "" },
1117 { "-trigraphs", "" },
1120 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1122 /* These are for obj c. */
1123 DEFINE_LANG_NAME ("Objective C")
1125 { "-lang-objc", "" },
1126 { "-gen-decls", "Dump decls to a .decl file" },
1127 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1128 { "-fno-gnu-runtime", "" },
1129 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1130 { "-fno-next-runtime", "" },
1131 { "-Wselector", "Warn if a selector has multiple methods" },
1132 { "-Wno-selector", "" },
1133 { "-Wprotocol", "" },
1134 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1135 { "-print-objc-runtime-info",
1136 "Generate C header of platform specific features" },
1138 #include "options.h"
1142 /* Here is a table, controlled by the tm.h file, listing each -m switch
1143 and which bits in `target_switches' it should set or clear.
1144 If VALUE is positive, it is bits to set.
1145 If VALUE is negative, -VALUE is bits to clear.
1146 (The sign bit is not used so there is no confusion.) */
1152 const char * description;
1154 target_switches [] = TARGET_SWITCHES;
1156 /* This table is similar, but allows the switch to have a value. */
1158 #ifdef TARGET_OPTIONS
1161 const char * prefix;
1162 const char ** variable;
1163 const char * description;
1165 target_options [] = TARGET_OPTIONS;
1168 /* Options controlling warnings */
1170 /* Don't print warning messages. -w. */
1172 int inhibit_warnings = 0;
1174 /* Print various extra warnings. -W. */
1176 int extra_warnings = 0;
1178 /* Treat warnings as errors. -Werror. */
1180 int warnings_are_errors = 0;
1182 /* Nonzero to warn about unused local variables. */
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 {"uninitialized", &warn_uninitialized, 1,
1245 "Warn about unitialized automatic variables"},
1246 {"inline", &warn_inline, 1,
1247 "Warn when an inlined function cannot be inlined"}
1250 /* Output files for assembler code (real compiler output)
1251 and debugging dumps. */
1254 FILE *aux_info_file;
1255 FILE *rtl_dump_file = NULL;
1257 /* Decode the string P as an integral parameter.
1258 If the string is indeed an integer return its numeric value else
1259 issue an Invalid Option error for the option PNAME and return DEFVAL.
1260 If PNAME is zero just return DEFVAL, do not call error. */
1263 read_integral_parameter (p, pname, defval)
1268 const char *endp = p;
1272 if (*endp >= '0' && *endp <= '9')
1281 error ("Invalid option `%s'", pname);
1289 /* Time accumulators, to count the total time spent in various passes. */
1293 int integration_time;
1299 int branch_prob_time;
1304 int local_alloc_time;
1305 int global_alloc_time;
1311 int shorten_branch_time;
1317 /* Return time used so far, in microseconds. */
1327 #else /* not BeOS */
1328 #if defined (_WIN32) && !defined (__CYGWIN__)
1332 return (clock() * 1000);
1333 #else /* not _WIN32 */
1339 tick = 1000000 / sysconf(_SC_CLK_TCK);
1341 return (tms.tms_utime + tms.tms_stime) * tick;
1347 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1348 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1351 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1353 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1357 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1362 struct rusage rusage;
1363 getrusage (0, &rusage);
1364 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1365 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1372 int proc_system_time;
1373 int child_user_time;
1374 int child_system_time;
1376 times ((void *) &vms_times);
1377 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1381 #endif /* _SC_CLK_TCK */
1383 #endif /* __BEOS__ */
1386 #define TIMEVAR(VAR, BODY) \
1387 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1390 print_time (str, total)
1395 "time in %s: %d.%06d\n",
1396 str, total / 1000000, total % 1000000);
1399 /* Count an error or warning. Return 1 if the message should be printed. */
1402 count_error (warningp)
1405 if (warningp && inhibit_warnings)
1408 if (warningp && !warnings_are_errors)
1412 static int warning_message = 0;
1414 if (warningp && !warning_message)
1416 notice ("%s: warnings being treated as errors\n", progname);
1417 warning_message = 1;
1425 /* Print a fatal error message. NAME is the text.
1426 Also include a system error message based on `errno'. */
1429 pfatal_with_name (name)
1432 fprintf (stderr, "%s: ", progname);
1434 exit (FATAL_EXIT_CODE);
1438 fatal_io_error (name)
1441 notice ("%s: %s: I/O error\n", progname, name);
1442 exit (FATAL_EXIT_CODE);
1445 /* Called to give a better error message for a bad insn rather than
1446 just calling abort(). */
1449 fatal_insn VPROTO((const char *msgid, rtx insn, ...))
1451 #ifndef ANSI_PROTOTYPES
1457 VA_START (ap, insn);
1459 #ifndef ANSI_PROTOTYPES
1460 msgid = va_arg (ap, const char *);
1461 insn = va_arg (ap, rtx);
1466 exit (FATAL_EXIT_CODE);
1469 /* Called to give a better error message when we don't have an insn to match
1470 what we are looking for or if the insn's constraints aren't satisfied,
1471 rather than just calling abort(). */
1474 fatal_insn_not_found (insn)
1477 if (INSN_CODE (insn) < 0)
1478 fatal_insn ("internal error--unrecognizable insn:", insn);
1480 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1483 /* This is the default decl_printable_name function. */
1486 decl_name (decl, verbosity)
1488 int verbosity ATTRIBUTE_UNUSED;
1490 return IDENTIFIER_POINTER (DECL_NAME (decl));
1493 static int need_error_newline;
1495 /* Function of last error message;
1496 more generally, function such that if next error message is in it
1497 then we don't have to mention the function name. */
1498 static tree last_error_function = NULL;
1500 /* Used to detect when input_file_stack has changed since last described. */
1501 static int last_error_tick;
1503 /* Called when the start of a function definition is parsed,
1504 this function prints on stderr the name of the function. */
1507 announce_function (decl)
1512 if (rtl_dump_and_exit)
1513 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1515 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1517 need_error_newline = 1;
1518 last_error_function = current_function_decl;
1522 /* The default function to print out name of current function that caused
1526 default_print_error_function (file)
1529 if (last_error_function != current_function_decl)
1532 fprintf (stderr, "%s: ", file);
1534 if (current_function_decl == NULL)
1535 notice ("At top level:\n");
1537 notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE
1538 ? "In method `%s':\n"
1539 : "In function `%s':\n"),
1540 (*decl_printable_name) (current_function_decl, 2));
1542 last_error_function = current_function_decl;
1546 /* Called by report_error_function to print out function name.
1547 * Default may be overridden by language front-ends. */
1549 void (*print_error_function) PROTO((const char *)) =
1550 default_print_error_function;
1552 /* Prints out, if necessary, the name of the current function
1553 that caused an error. Called from all error and warning functions.
1554 We ignore the FILE parameter, as it cannot be relied upon. */
1557 report_error_function (file)
1558 const char *file ATTRIBUTE_UNUSED;
1560 struct file_stack *p;
1562 if (need_error_newline)
1564 fprintf (stderr, "\n");
1565 need_error_newline = 0;
1568 if (input_file_stack && input_file_stack->next != 0
1569 && input_file_stack_tick != last_error_tick)
1571 for (p = input_file_stack->next; p; p = p->next)
1572 notice ((p == input_file_stack->next
1573 ? "In file included from %s:%d"
1574 : ",\n from %s:%d"),
1576 fprintf (stderr, ":\n");
1577 last_error_tick = input_file_stack_tick;
1580 (*print_error_function) (input_filename);
1583 /* Print a message. */
1586 vnotice (file, msgid, ap)
1591 vfprintf (file, _(msgid), ap);
1595 notice VPROTO((const char *msgid, ...))
1597 #ifndef ANSI_PROTOTYPES
1602 VA_START (ap, msgid);
1604 #ifndef ANSI_PROTOTYPES
1605 msgid = va_arg (ap, char *);
1608 vnotice (stderr, msgid, ap);
1613 fnotice VPROTO((FILE *file, const char *msgid, ...))
1615 #ifndef ANSI_PROTOTYPES
1621 VA_START (ap, msgid);
1623 #ifndef ANSI_PROTOTYPES
1624 file = va_arg (ap, FILE *);
1625 msgid = va_arg (ap, const char *);
1628 vnotice (file, msgid, ap);
1632 /* Report FILE and LINE (or program name), and optionally just WARN. */
1635 report_file_and_line (file, line, warn)
1641 fprintf (stderr, "%s:%d: ", file, line);
1643 fprintf (stderr, "%s: ", progname);
1646 notice ("warning: ");
1649 /* Print a message. */
1652 vmessage (prefix, msgid, ap)
1658 fprintf (stderr, "%s: ", prefix);
1660 vfprintf (stderr, msgid, ap);
1663 /* Print a message relevant to line LINE of file FILE. */
1666 v_message_with_file_and_line (file, line, warn, msgid, ap)
1673 report_file_and_line (file, line, warn);
1674 vnotice (stderr, msgid, ap);
1675 fputc ('\n', stderr);
1678 /* Print a message relevant to the given DECL. */
1681 v_message_with_decl (decl, warn, msgid, ap)
1689 report_file_and_line (DECL_SOURCE_FILE (decl),
1690 DECL_SOURCE_LINE (decl), warn);
1692 /* Do magic to get around lack of varargs support for insertion
1693 of arguments into existing list. We know that the decl is first;
1694 we ass_u_me that it will be printed with "%s". */
1696 for (p = _(msgid); *p; ++p)
1700 if (*(p + 1) == '%')
1702 else if (*(p + 1) != 's')
1709 if (p > _(msgid)) /* Print the left-hand substring. */
1711 char fmt[sizeof "%.255s"];
1712 long width = p - _(msgid);
1714 if (width > 255L) width = 255L; /* arbitrary */
1715 sprintf (fmt, "%%.%lds", width);
1716 fprintf (stderr, fmt, _(msgid));
1719 if (*p == '%') /* Print the name. */
1721 const char *n = (DECL_NAME (decl)
1722 ? (*decl_printable_name) (decl, 2)
1728 if (ISALPHA (*(p - 1) & 0xFF))
1733 if (*p) /* Print the rest of the message. */
1734 vmessage ((char *)NULL, p, ap);
1736 fputc ('\n', stderr);
1739 /* Figure file and line of the given INSN. */
1742 file_and_line_for_asm (insn, pfile, pline)
1747 rtx body = PATTERN (insn);
1750 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1751 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1752 asmop = SET_SRC (body);
1753 else if (GET_CODE (body) == ASM_OPERANDS)
1755 else if (GET_CODE (body) == PARALLEL
1756 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1757 asmop = SET_SRC (XVECEXP (body, 0, 0));
1758 else if (GET_CODE (body) == PARALLEL
1759 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1760 asmop = XVECEXP (body, 0, 0);
1766 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1767 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1771 *pfile = input_filename;
1776 /* Report an error at line LINE of file FILE. */
1779 v_error_with_file_and_line (file, line, msgid, ap)
1786 report_error_function (file);
1787 v_message_with_file_and_line (file, line, 0, msgid, ap);
1791 error_with_file_and_line VPROTO((const char *file, int line,
1792 const char *msgid, ...))
1794 #ifndef ANSI_PROTOTYPES
1801 VA_START (ap, msgid);
1803 #ifndef ANSI_PROTOTYPES
1804 file = va_arg (ap, const char *);
1805 line = va_arg (ap, int);
1806 msgid = va_arg (ap, const char *);
1809 v_error_with_file_and_line (file, line, msgid, ap);
1813 /* Report an error at the declaration DECL.
1814 MSGID is a format string which uses %s to substitute the declaration
1815 name; subsequent substitutions are a la printf. */
1818 v_error_with_decl (decl, msgid, ap)
1824 report_error_function (DECL_SOURCE_FILE (decl));
1825 v_message_with_decl (decl, 0, msgid, ap);
1829 error_with_decl VPROTO((tree decl, const char *msgid, ...))
1831 #ifndef ANSI_PROTOTYPES
1837 VA_START (ap, msgid);
1839 #ifndef ANSI_PROTOTYPES
1840 decl = va_arg (ap, tree);
1841 msgid = va_arg (ap, const char *);
1844 v_error_with_decl (decl, msgid, ap);
1848 /* Report an error at the line number of the insn INSN.
1849 This is used only when INSN is an `asm' with operands,
1850 and each ASM_OPERANDS records its own source file and line. */
1853 v_error_for_asm (insn, msgid, ap)
1862 file_and_line_for_asm (insn, &file, &line);
1863 report_error_function (file);
1864 v_message_with_file_and_line (file, line, 0, msgid, ap);
1868 error_for_asm VPROTO((rtx insn, const char *msgid, ...))
1870 #ifndef ANSI_PROTOTYPES
1876 VA_START (ap, msgid);
1878 #ifndef ANSI_PROTOTYPES
1879 insn = va_arg (ap, rtx);
1880 msgid = va_arg (ap, const char *);
1883 v_error_for_asm (insn, msgid, ap);
1887 /* Report an error at the current line number. */
1894 v_error_with_file_and_line (input_filename, lineno, msgid, ap);
1898 error VPROTO((const char *msgid, ...))
1900 #ifndef ANSI_PROTOTYPES
1905 VA_START (ap, msgid);
1907 #ifndef ANSI_PROTOTYPES
1908 msgid = va_arg (ap, const char *);
1915 /* Report a fatal error at the current line number. */
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 *);
1944 /* Report a warning at line LINE of file FILE. */
1947 v_warning_with_file_and_line (file, line, msgid, ap)
1953 if (count_error (1))
1955 report_error_function (file);
1956 v_message_with_file_and_line (file, line, 1, msgid, ap);
1961 warning_with_file_and_line VPROTO((const char *file, int line,
1962 const char *msgid, ...))
1964 #ifndef ANSI_PROTOTYPES
1971 VA_START (ap, msgid);
1973 #ifndef ANSI_PROTOTYPES
1974 file = va_arg (ap, const char *);
1975 line = va_arg (ap, int);
1976 msgid = va_arg (ap, const char *);
1979 v_warning_with_file_and_line (file, line, msgid, ap);
1983 /* Report a warning at the declaration DECL.
1984 MSGID is a format string which uses %s to substitute the declaration
1985 name; subsequent substitutions are a la printf. */
1988 v_warning_with_decl (decl, msgid, ap)
1993 if (count_error (1))
1995 report_error_function (DECL_SOURCE_FILE (decl));
1996 v_message_with_decl (decl, 1, msgid, ap);
2001 warning_with_decl VPROTO((tree decl, const char *msgid, ...))
2003 #ifndef ANSI_PROTOTYPES
2009 VA_START (ap, msgid);
2011 #ifndef ANSI_PROTOTYPES
2012 decl = va_arg (ap, tree);
2013 msgid = va_arg (ap, const char *);
2016 v_warning_with_decl (decl, msgid, ap);
2020 /* Report a warning at the line number of the insn INSN.
2021 This is used only when INSN is an `asm' with operands,
2022 and each ASM_OPERANDS records its own source file and line. */
2025 v_warning_for_asm (insn, msgid, ap)
2030 if (count_error (1))
2035 file_and_line_for_asm (insn, &file, &line);
2036 report_error_function (file);
2037 v_message_with_file_and_line (file, line, 1, msgid, ap);
2042 warning_for_asm VPROTO((rtx insn, const char *msgid, ...))
2044 #ifndef ANSI_PROTOTYPES
2050 VA_START (ap, msgid);
2052 #ifndef ANSI_PROTOTYPES
2053 insn = va_arg (ap, rtx);
2054 msgid = va_arg (ap, const char *);
2057 v_warning_for_asm (insn, msgid, ap);
2061 /* Report a warning at the current line number. */
2064 vwarning (msgid, ap)
2068 v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
2072 warning VPROTO((const char *msgid, ...))
2074 #ifndef ANSI_PROTOTYPES
2079 VA_START (ap, msgid);
2081 #ifndef ANSI_PROTOTYPES
2082 msgid = va_arg (ap, const char *);
2085 vwarning (msgid, ap);
2089 /* These functions issue either warnings or errors depending on
2090 -pedantic-errors. */
2093 vpedwarn (msgid, ap)
2097 if (flag_pedantic_errors)
2100 vwarning (msgid, ap);
2104 pedwarn VPROTO((const char *msgid, ...))
2106 #ifndef ANSI_PROTOTYPES
2111 VA_START (ap, msgid);
2113 #ifndef ANSI_PROTOTYPES
2114 msgid = va_arg (ap, const char *);
2117 vpedwarn (msgid, ap);
2122 v_pedwarn_with_decl (decl, msgid, ap)
2127 /* We don't want -pedantic-errors to cause the compilation to fail from
2128 "errors" in system header files. Sometimes fixincludes can't fix what's
2129 broken (eg: unsigned char bitfields - fixing it may change the alignment
2130 which will cause programs to mysteriously fail because the C library
2131 or kernel uses the original layout). There's no point in issuing a
2132 warning either, it's just unnecessary noise. */
2134 if (! DECL_IN_SYSTEM_HEADER (decl))
2136 if (flag_pedantic_errors)
2137 v_error_with_decl (decl, msgid, ap);
2139 v_warning_with_decl (decl, msgid, ap);
2144 pedwarn_with_decl VPROTO((tree decl, const char *msgid, ...))
2146 #ifndef ANSI_PROTOTYPES
2152 VA_START (ap, msgid);
2154 #ifndef ANSI_PROTOTYPES
2155 decl = va_arg (ap, tree);
2156 msgid = va_arg (ap, const char *);
2159 v_pedwarn_with_decl (decl, msgid, ap);
2164 v_pedwarn_with_file_and_line (file, line, msgid, ap)
2170 if (flag_pedantic_errors)
2171 v_error_with_file_and_line (file, line, msgid, ap);
2173 v_warning_with_file_and_line (file, line, msgid, ap);
2177 pedwarn_with_file_and_line VPROTO((const char *file, int line,
2178 const char *msgid, ...))
2180 #ifndef ANSI_PROTOTYPES
2187 VA_START (ap, msgid);
2189 #ifndef ANSI_PROTOTYPES
2190 file = va_arg (ap, const char *);
2191 line = va_arg (ap, int);
2192 msgid = va_arg (ap, const char *);
2195 v_pedwarn_with_file_and_line (file, line, msgid, ap);
2199 /* Apologize for not implementing some feature. */
2208 fprintf (stderr, "%s:%d: ", input_filename, lineno);
2210 fprintf (stderr, "%s: ", progname);
2211 notice ("sorry, not implemented: ");
2212 vnotice (stderr, msgid, ap);
2213 fputc ('\n', stderr);
2217 sorry VPROTO((const char *msgid, ...))
2219 #ifndef ANSI_PROTOTYPES
2224 VA_START (ap, msgid);
2226 #ifndef ANSI_PROTOTYPES
2227 msgid = va_arg (ap, const char *);
2234 /* Given a partial pathname as input, return another pathname that shares
2235 no elements with the pathname of __FILE__. This is used by abort() to
2236 print `Internal compiler error in expr.c' instead of `Internal compiler
2237 error in ../../egcs/gcc/expr.c'. */
2239 trim_filename (name)
2242 static const char *this_file = __FILE__;
2243 const char *p = name, *q = this_file;
2245 while (*p == *q && *p != 0 && *q != 0) p++, q++;
2246 while (p > name && p[-1] != DIR_SEPARATOR
2247 #ifdef DIR_SEPARATOR_2
2248 && p[-1] != DIR_SEPARATOR_2
2256 /* More 'friendly' abort that prints the line and file.
2257 config.h can #define abort fancy_abort if you like that sort of thing.
2259 I don't think this is actually a good idea.
2260 Other sorts of crashes will look a certain way.
2261 It is a good thing if crashes from calling abort look the same way.
2267 fatal ("internal gcc abort");
2270 /* This calls abort and is used to avoid problems when abort if a macro.
2271 It is used when we need to pass the address of abort. */
2279 /* When `malloc.c' is compiled with `rcheck' defined,
2280 it calls this function to report clobberage. */
2284 const char * s ATTRIBUTE_UNUSED;
2289 /* Same as `malloc' but report error if no memory available. */
2300 value = (PTR) malloc (size);
2302 fatal ("virtual memory exhausted");
2306 /* Same as `calloc' but report error if no memory available. */
2309 xcalloc (size1, size2)
2310 size_t size1, size2;
2314 if (size1 == 0 || size2 == 0)
2317 value = (PTR) calloc (size1, size2);
2319 fatal ("virtual memory exhausted");
2324 /* Same as `realloc' but report error if no memory available.
2325 Also handle null PTR even if the vendor realloc gets it wrong. */
2328 xrealloc (ptr, size)
2332 register PTR result;
2337 result = (ptr ? (PTR) realloc (ptr, size) : (PTR) malloc (size));
2340 fatal ("virtual memory exhausted");
2345 /* Same as `strdup' but report error if no memory available. */
2349 register const char *s;
2351 register char *result = (char *) malloc (strlen (s) + 1);
2354 fatal ("virtual memory exhausted");
2359 /* Return the logarithm of X, base 2, considering X unsigned,
2360 if X is a power of 2. Otherwise, returns -1.
2362 This should be used via the `exact_log2' macro. */
2366 register unsigned HOST_WIDE_INT x;
2368 register int log = 0;
2369 /* Test for 0 or a power of 2. */
2370 if (x == 0 || x != (x & -x))
2372 while ((x >>= 1) != 0)
2377 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2378 If X is 0, return -1.
2380 This should be used via the floor_log2 macro. */
2384 register unsigned HOST_WIDE_INT x;
2386 register int log = -1;
2393 static int float_handler_set;
2395 jmp_buf float_handler;
2397 /* Signals actually come here. */
2400 float_signal (signo)
2401 /* If this is missing, some compilers complain. */
2402 int signo ATTRIBUTE_UNUSED;
2404 if (float_handled == 0)
2406 #if defined (USG) || defined (hpux)
2407 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2410 signal (SIGFPE, float_signal);
2411 longjmp (float_handler, 1);
2414 /* Specify where to longjmp to when a floating arithmetic error happens.
2415 If HANDLER is 0, it means don't handle the errors any more. */
2418 set_float_handler (handler)
2421 float_handled = (handler != 0);
2423 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2425 if (float_handled && ! float_handler_set)
2427 signal (SIGFPE, float_signal);
2428 float_handler_set = 1;
2432 /* This is a wrapper function for code which might elicit an
2433 arithmetic exception. That code should be passed in as a function
2434 pointer FN, and one argument DATA. DATA is usually a struct which
2435 contains the real input and output for function FN. This function
2436 returns 0 (failure) if longjmp was called (i.e. an exception
2437 occured.) It returns 1 (success) otherwise. */
2440 do_float_handler (fn, data)
2441 void (*fn) PROTO ((PTR));
2448 /* We got here via longjmp() caused by an exception in function fn() */
2449 set_float_handler (NULL);
2453 set_float_handler (buf);
2455 set_float_handler (NULL);
2459 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2460 error happens, pushing the previous specification into OLD_HANDLER.
2461 Return an indication of whether there was a previous handler in effect. */
2464 push_float_handler (handler, old_handler)
2465 jmp_buf handler, old_handler;
2467 int was_handled = float_handled;
2471 memcpy ((char *) old_handler, (char *) float_handler,
2472 sizeof (float_handler));
2474 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
2478 /* Restore the previous specification of whether and where to longjmp to
2479 when a floating arithmetic error happens. */
2482 pop_float_handler (handled, handler)
2486 float_handled = handled;
2488 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2491 /* Handler for SIGPIPE. */
2495 /* If this is missing, some compilers complain. */
2496 int signo ATTRIBUTE_UNUSED;
2498 fatal ("output pipe has been closed");
2501 /* Strip off a legitimate source ending from the input string NAME of
2502 length LEN. Rather than having to know the names used by all of
2503 our front ends, we strip off an ending of a period followed by
2504 up to five characters. (Java uses ".class".) */
2507 strip_off_ending (name, len)
2512 for (i = 2; i < 6 && len > i; i++)
2514 if (name[len - i] == '.')
2516 name[len - i] = '\0';
2522 /* Output a quoted string. */
2525 output_quoted_string (asm_file, string)
2529 #ifdef OUTPUT_QUOTED_STRING
2530 OUTPUT_QUOTED_STRING (asm_file, string);
2534 putc ('\"', asm_file);
2535 while ((c = *string++) != 0)
2537 if (c == '\"' || c == '\\')
2538 putc ('\\', asm_file);
2541 putc ('\"', asm_file);
2545 /* Output a file name in the form wanted by System V. */
2548 output_file_directive (asm_file, input_name)
2550 const char *input_name;
2552 int len = strlen (input_name);
2553 const char *na = input_name + len;
2555 /* NA gets INPUT_NAME sans directory names. */
2556 while (na > input_name)
2560 #ifdef DIR_SEPARATOR
2561 if (na[-1] == DIR_SEPARATOR)
2567 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2568 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2570 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2571 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2573 fprintf (asm_file, "\t.file\t");
2574 output_quoted_string (asm_file, na);
2575 fputc ('\n', asm_file);
2580 #ifdef ASM_IDENTIFY_LANGUAGE
2581 /* Routine to build language identifier for object file. */
2583 output_lang_identify (asm_out_file)
2586 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2587 char *s = (char *) alloca (len);
2588 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2589 ASM_OUTPUT_LABEL (asm_out_file, s);
2593 /* Routine to open a dump file. */
2595 open_dump_file (suffix, function_name)
2597 const char *function_name;
2604 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2606 if (rtl_dump_file != NULL)
2607 fclose (rtl_dump_file);
2609 strcpy (dumpname, dump_base_name);
2610 strcat (dumpname, suffix);
2612 rtl_dump_file = fopen (dumpname, "a");
2614 if (rtl_dump_file == NULL)
2615 pfatal_with_name (dumpname);
2620 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2626 /* Routine to close a dump file. */
2628 close_dump_file (func, insns)
2629 void (*func) PROTO ((FILE *, rtx));
2636 func (rtl_dump_file, insns);
2638 fflush (rtl_dump_file);
2639 fclose (rtl_dump_file);
2641 rtl_dump_file = NULL;
2647 /* Routine to dump rtl into a file. */
2649 dump_rtl (suffix, decl, func, insns)
2652 void (*func) PROTO ((FILE *, rtx));
2655 open_dump_file (suffix, decl_printable_name (decl, 2));
2656 close_dump_file (func, insns);
2659 /* Routine to empty a dump file. */
2661 clean_dump_file (suffix)
2666 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2668 strcpy (dumpname, dump_base_name);
2669 strcat (dumpname, suffix);
2671 rtl_dump_file = fopen (dumpname, "w");
2673 if (rtl_dump_file == NULL)
2674 pfatal_with_name (dumpname);
2678 fclose (rtl_dump_file);
2679 rtl_dump_file = NULL;
2684 /* Do any final processing required for the declarations in VEC, of
2685 which there are LEN. We write out inline functions and variables
2686 that have been deferred until this point, but which are required.
2687 Returns non-zero if anything was put out. */
2689 wrapup_global_declarations (vec, len)
2696 int output_something = 0;
2698 for (i = 0; i < len; i++)
2702 /* We're not deferring this any longer. */
2703 DECL_DEFER_OUTPUT (decl) = 0;
2705 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2706 && incomplete_decl_finalize_hook != 0)
2707 (*incomplete_decl_finalize_hook) (decl);
2710 /* Now emit any global variables or functions that we have been
2711 putting off. We need to loop in case one of the things emitted
2712 here references another one which comes earlier in the list. */
2716 for (i = 0; i < len; i++)
2720 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2723 /* Don't write out static consts, unless we still need them.
2725 We also keep static consts if not optimizing (for debugging),
2726 unless the user specified -fno-keep-static-consts.
2727 ??? They might be better written into the debug information.
2728 This is possible when using DWARF.
2730 A language processor that wants static constants to be always
2731 written out (even if it is not used) is responsible for
2732 calling rest_of_decl_compilation itself. E.g. the C front-end
2733 calls rest_of_decl_compilation from finish_decl.
2734 One motivation for this is that is conventional in some
2735 environments to write things like:
2736 static const char rcsid[] = "... version string ...";
2737 intending to force the string to be in the executable.
2739 A language processor that would prefer to have unneeded
2740 static constants "optimized away" would just defer writing
2741 them out until here. E.g. C++ does this, because static
2742 constants are often defined in header files.
2744 ??? A tempting alternative (for both C and C++) would be
2745 to force a constant to be written if and only if it is
2746 defined in a main file, as opposed to an include file. */
2748 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2749 && (! TREE_READONLY (decl)
2750 || TREE_PUBLIC (decl)
2751 || (!optimize && flag_keep_static_consts)
2752 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2755 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2758 if (TREE_CODE (decl) == FUNCTION_DECL
2759 && DECL_INITIAL (decl) != 0
2760 && DECL_SAVED_INSNS (decl) != 0
2761 && (flag_keep_inline_functions
2762 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2763 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2766 temporary_allocation ();
2767 output_inline_function (decl);
2768 permanent_allocation (1);
2773 output_something = 1;
2777 return output_something;
2780 /* Issue appropriate warnings for the global declarations in VEC (of
2781 which there are LEN). Output debugging information for them. */
2783 check_global_declarations (vec, len)
2790 for (i = 0; i < len; i++)
2794 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2795 && ! TREE_ASM_WRITTEN (decl))
2796 /* Cancel the RTL for this decl so that, if debugging info
2797 output for global variables is still to come,
2798 this one will be omitted. */
2799 DECL_RTL (decl) = NULL;
2801 /* Warn about any function
2802 declared static but not defined.
2803 We don't warn about variables,
2804 because many programs have static variables
2805 that exist only to get some text into the object file. */
2806 if (TREE_CODE (decl) == FUNCTION_DECL
2808 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2809 && DECL_INITIAL (decl) == 0
2810 && DECL_EXTERNAL (decl)
2811 && ! DECL_ARTIFICIAL (decl)
2812 && ! TREE_PUBLIC (decl))
2814 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2815 pedwarn_with_decl (decl,
2816 "`%s' used but never defined");
2818 warning_with_decl (decl,
2819 "`%s' declared `static' but never defined");
2820 /* This symbol is effectively an "extern" declaration now. */
2821 TREE_PUBLIC (decl) = 1;
2822 assemble_external (decl);
2825 /* Warn about static fns or vars defined but not used,
2826 but not about inline functions or static consts
2827 since defining those in header files is normal practice. */
2829 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2830 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2831 && ! DECL_IN_SYSTEM_HEADER (decl)
2832 && ! DECL_EXTERNAL (decl)
2833 && ! TREE_PUBLIC (decl)
2834 && ! TREE_USED (decl)
2835 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2836 /* The TREE_USED bit for file-scope decls
2837 is kept in the identifier, to handle multiple
2838 external decls in different scopes. */
2839 && ! TREE_USED (DECL_NAME (decl)))
2840 warning_with_decl (decl, "`%s' defined but not used");
2842 #ifdef SDB_DEBUGGING_INFO
2843 /* The COFF linker can move initialized global vars to the end.
2844 And that can screw up the symbol ordering.
2845 By putting the symbols in that order to begin with,
2846 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2847 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2848 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2849 && ! DECL_EXTERNAL (decl)
2850 && DECL_RTL (decl) != 0)
2851 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2853 /* Output COFF information for non-global
2854 file-scope initialized variables. */
2855 if (write_symbols == SDB_DEBUG
2856 && TREE_CODE (decl) == VAR_DECL
2857 && DECL_INITIAL (decl)
2858 && ! DECL_EXTERNAL (decl)
2859 && DECL_RTL (decl) != 0
2860 && GET_CODE (DECL_RTL (decl)) == MEM)
2861 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2862 #endif /* SDB_DEBUGGING_INFO */
2863 #ifdef DWARF_DEBUGGING_INFO
2864 /* Output DWARF information for file-scope tentative data object
2865 declarations, file-scope (extern) function declarations (which
2866 had no corresponding body) and file-scope tagged type declarations
2867 and definitions which have not yet been forced out. */
2869 if (write_symbols == DWARF_DEBUG
2870 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2871 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2873 #ifdef DWARF2_DEBUGGING_INFO
2874 /* Output DWARF2 information for file-scope tentative data object
2875 declarations, file-scope (extern) function declarations (which
2876 had no corresponding body) and file-scope tagged type declarations
2877 and definitions which have not yet been forced out. */
2879 if (write_symbols == DWARF2_DEBUG
2880 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2881 TIMEVAR (symout_time, dwarf2out_decl (decl));
2886 /* Compile an entire file of output from cpp, named NAME.
2887 Write a file of assembly output and various debugging dumps. */
2896 int name_specified = name != 0;
2898 if (dump_base_name == 0)
2899 dump_base_name = name ? name : "gccdump";
2903 integration_time = 0;
2909 branch_prob_time = 0;
2914 local_alloc_time = 0;
2915 global_alloc_time = 0;
2921 shorten_branch_time = 0;
2927 /* Initialize data in various passes. */
2931 name = init_parse (name);
2933 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2934 || debug_info_level == DINFO_LEVEL_VERBOSE
2935 || flag_test_coverage);
2937 init_decl_processing ();
2946 if (flag_caller_saves)
2947 init_caller_save ();
2949 /* If auxiliary info generation is desired, open the output file.
2950 This goes in the same directory as the source file--unlike
2951 all the other output files. */
2952 if (flag_gen_aux_info)
2954 aux_info_file = fopen (aux_info_file_name, "w");
2955 if (aux_info_file == 0)
2956 pfatal_with_name (aux_info_file_name);
2959 /* Clear the dump files. */
2961 clean_dump_file (".rtl");
2964 clean_dump_file (".jump");
2965 if (graph_dump_format != no_graph)
2966 clean_graph_dump_file (dump_base_name, ".jump");
2970 clean_dump_file (".addressof");
2971 if (graph_dump_format != no_graph)
2972 clean_graph_dump_file (dump_base_name, ".addressof");
2976 clean_dump_file (".cse");
2977 if (graph_dump_format != no_graph)
2978 clean_graph_dump_file (dump_base_name, ".cse");
2982 clean_dump_file (".loop");
2983 if (graph_dump_format != no_graph)
2984 clean_graph_dump_file (dump_base_name, ".loop");
2988 clean_dump_file (".cse2");
2989 if (graph_dump_format != no_graph)
2990 clean_graph_dump_file (dump_base_name, ".cse2");
2992 if (branch_prob_dump)
2994 clean_dump_file (".bp");
2995 if (graph_dump_format != no_graph)
2996 clean_graph_dump_file (dump_base_name, ".bp");
3000 clean_dump_file (".flow");
3001 if (graph_dump_format != no_graph)
3002 clean_graph_dump_file (dump_base_name, ".flow");
3006 clean_dump_file (".combine");
3007 if (graph_dump_format != no_graph)
3008 clean_graph_dump_file (dump_base_name, ".combine");
3012 clean_dump_file (".regmove");
3013 if (graph_dump_format != no_graph)
3014 clean_graph_dump_file (dump_base_name, ".regmove");
3018 clean_dump_file (".sched");
3019 if (graph_dump_format != no_graph)
3020 clean_graph_dump_file (dump_base_name, ".sched");
3024 clean_dump_file (".lreg");
3025 if (graph_dump_format != no_graph)
3026 clean_graph_dump_file (dump_base_name, ".lreg");
3028 if (global_reg_dump)
3030 clean_dump_file (".greg");
3031 if (graph_dump_format != no_graph)
3032 clean_graph_dump_file (dump_base_name, ".greg");
3036 clean_dump_file (".flow2");
3037 if (graph_dump_format != no_graph)
3038 clean_graph_dump_file (dump_base_name, ".flow2");
3042 clean_dump_file (".sched2");
3043 if (graph_dump_format != no_graph)
3044 clean_graph_dump_file (dump_base_name, ".sched2");
3048 clean_dump_file (".jump2");
3049 if (graph_dump_format != no_graph)
3050 clean_graph_dump_file (dump_base_name, ".jump2");
3055 clean_dump_file (".dbr");
3056 if (graph_dump_format != no_graph)
3057 clean_graph_dump_file (dump_base_name, ".dbr");
3062 clean_dump_file (".gcse");
3063 if (graph_dump_format != no_graph)
3064 clean_graph_dump_file (dump_base_name, ".gcse");
3069 clean_dump_file (".stack");
3070 if (graph_dump_format != no_graph)
3071 clean_graph_dump_file (dump_base_name, ".stack");
3074 #ifdef MACHINE_DEPENDENT_REORG
3075 if (mach_dep_reorg_dump)
3077 clean_dump_file (".mach");
3078 if (graph_dump_format != no_graph)
3079 clean_graph_dump_file (dump_base_name, ".mach");
3083 /* Open assembler code output file. */
3085 if (flag_syntax_only)
3086 asm_out_file = NULL;
3089 if (! name_specified && asm_file_name == 0)
3090 asm_out_file = stdout;
3093 int len = strlen (dump_base_name);
3094 register char *dumpname = (char *) xmalloc (len + 6);
3095 strcpy (dumpname, dump_base_name);
3096 strip_off_ending (dumpname, len);
3097 strcat (dumpname, ".s");
3098 if (asm_file_name == 0)
3100 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
3101 strcpy (asm_file_name, dumpname);
3103 if (!strcmp (asm_file_name, "-"))
3104 asm_out_file = stdout;
3106 asm_out_file = fopen (asm_file_name, "w");
3107 if (asm_out_file == 0)
3108 pfatal_with_name (asm_file_name);
3111 #ifdef IO_BUFFER_SIZE
3112 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
3113 _IOFBF, IO_BUFFER_SIZE);
3117 input_filename = name;
3119 /* Put an entry on the input file stack for the main input file. */
3121 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
3122 input_file_stack->next = 0;
3123 input_file_stack->name = input_filename;
3125 /* Perform language-specific initialization.
3126 This may set main_input_filename. */
3129 /* If the input doesn't start with a #line, use the input name
3130 as the official input file name. */
3131 if (main_input_filename == 0)
3132 main_input_filename = name;
3134 if (flag_syntax_only)
3136 write_symbols = NO_DEBUG;
3138 profile_block_flag = 0;
3142 ASM_FILE_START (asm_out_file);
3144 #ifdef ASM_COMMENT_START
3145 if (flag_verbose_asm)
3147 /* Print the list of options in effect. */
3148 print_version (asm_out_file, ASM_COMMENT_START);
3149 print_switch_values (asm_out_file, 0, MAX_LINE,
3150 ASM_COMMENT_START, " ", "\n");
3151 /* Add a blank line here so it appears in assembler output but not
3153 fprintf (asm_out_file, "\n");
3157 /* Output something to inform GDB that this compilation was by GCC. */
3158 #ifndef ASM_IDENTIFY_GCC
3159 fprintf (asm_out_file, "gcc2_compiled.:\n");
3161 ASM_IDENTIFY_GCC (asm_out_file);
3164 /* Output something to identify which front-end produced this file. */
3165 #ifdef ASM_IDENTIFY_LANGUAGE
3166 ASM_IDENTIFY_LANGUAGE (asm_out_file);
3168 } /* ! flag_syntax_only */
3170 #ifndef ASM_OUTPUT_SECTION_NAME
3171 if (flag_function_sections)
3173 warning ("-ffunction-sections not supported for this target.");
3174 flag_function_sections = 0;
3176 if (flag_data_sections)
3178 warning ("-fdata-sections not supported for this target.");
3179 flag_data_sections = 0;
3183 if (flag_function_sections
3184 && (profile_flag || profile_block_flag))
3186 warning ("-ffunction-sections disabled; it makes profiling impossible.");
3187 flag_function_sections = 0;
3190 #ifndef OBJECT_FORMAT_ELF
3191 if (flag_function_sections && write_symbols != NO_DEBUG)
3192 warning ("-ffunction-sections may affect debugging on some targets.");
3195 /* ??? Note: There used to be a conditional here
3196 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
3197 This was to guarantee separation between gcc_compiled. and
3198 the first function, for the sake of dbx on Suns.
3199 However, having the extra zero here confused the Emacs
3200 code for unexec, and might confuse other programs too.
3201 Therefore, I took out that change.
3202 In future versions we should find another way to solve
3203 that dbx problem. -- rms, 23 May 93. */
3205 /* Don't let the first function fall at the same address
3206 as gcc_compiled., if profiling. */
3207 if (profile_flag || profile_block_flag)
3209 /* It's best if we can write a nop here since some
3210 assemblers don't tolerate zeros in the text section. */
3211 if (insn_template[CODE_FOR_nop] != 0)
3212 output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR);
3214 assemble_zeros (UNITS_PER_WORD);
3217 /* If dbx symbol table desired, initialize writing it
3218 and output the predefined types. */
3219 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3220 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3221 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
3224 #ifdef SDB_DEBUGGING_INFO
3225 if (write_symbols == SDB_DEBUG)
3226 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
3229 #ifdef DWARF_DEBUGGING_INFO
3230 if (write_symbols == DWARF_DEBUG)
3231 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
3233 #ifdef DWARF2_UNWIND_INFO
3234 if (dwarf2out_do_frame ())
3235 dwarf2out_frame_init ();
3237 #ifdef DWARF2_DEBUGGING_INFO
3238 if (write_symbols == DWARF2_DEBUG)
3239 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
3242 /* Initialize yet another pass. */
3244 init_final (main_input_filename);
3245 init_branch_prob (dump_base_name);
3247 start_time = get_run_time ();
3249 /* Call the parser, which parses the entire file
3250 (calling rest_of_compilation for each function). */
3252 if (yyparse () != 0)
3254 if (errorcount == 0)
3255 notice ("Errors detected in input file (your bison.simple is out of date)\n");
3257 /* In case there were missing closebraces,
3258 get us back to the global binding level. */
3259 while (! global_bindings_p ())
3263 /* Compilation is now finished except for writing
3264 what's left of the symbol table output. */
3266 parse_time += get_run_time () - start_time;
3268 parse_time -= integration_time;
3269 parse_time -= varconst_time;
3271 if (flag_syntax_only)
3274 globals = getdecls ();
3276 /* Really define vars that have had only a tentative definition.
3277 Really output inline functions that must actually be callable
3278 and have not been output so far. */
3281 int len = list_length (globals);
3282 tree *vec = (tree *) alloca (sizeof (tree) * len);
3286 /* Process the decls in reverse order--earliest first.
3287 Put them into VEC from back to front, then take out from front. */
3289 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
3290 vec[len - i - 1] = decl;
3292 wrapup_global_declarations (vec, len);
3294 /* This must occur after the loop to output deferred functions. Else
3295 the profiler initializer would not be emitted if all the functions
3296 in this compilation unit were deferred.
3298 output_func_start_profiler can not cause any additional functions or
3299 data to need to be output, so it need not be in the deferred function
3301 output_func_start_profiler ();
3303 /* Now that all possible functions have been output, we can dump
3304 the exception table. */
3306 output_exception_table ();
3308 check_global_declarations (vec, len);
3311 /* Write out any pending weak symbol declarations. */
3315 /* Do dbx symbols */
3316 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3317 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3318 TIMEVAR (symout_time,
3320 dbxout_finish (asm_out_file, main_input_filename);
3324 #ifdef DWARF_DEBUGGING_INFO
3325 if (write_symbols == DWARF_DEBUG)
3326 TIMEVAR (symout_time,
3332 #ifdef DWARF2_UNWIND_INFO
3333 if (dwarf2out_do_frame ())
3334 dwarf2out_frame_finish ();
3337 #ifdef DWARF2_DEBUGGING_INFO
3338 if (write_symbols == DWARF2_DEBUG)
3339 TIMEVAR (symout_time,
3341 dwarf2out_finish ();
3345 /* Output some stuff at end of file if nec. */
3347 end_final (dump_base_name);
3349 if (branch_prob_dump)
3350 open_dump_file (".bp", NULL);
3352 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
3354 if (branch_prob_dump)
3355 close_dump_file (NULL, NULL_RTX);
3358 ASM_FILE_END (asm_out_file);
3362 /* Language-specific end of compilation actions. */
3366 /* Close the dump files. */
3368 if (flag_gen_aux_info)
3370 fclose (aux_info_file);
3372 unlink (aux_info_file_name);
3377 open_dump_file (".combine", NULL);
3378 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
3379 close_dump_file (NULL, NULL_RTX);
3382 /* Close non-debugging input and output files. Take special care to note
3383 whether fclose returns an error, since the pages might still be on the
3384 buffer chain while the file is open. */
3388 if (! flag_syntax_only
3389 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
3390 fatal_io_error (asm_file_name);
3392 /* Do whatever is necessary to finish printing the graphs. */
3393 if (graph_dump_format != no_graph)
3396 finish_graph_dump_file (dump_base_name, ".jump");
3398 finish_graph_dump_file (dump_base_name, ".addressof");
3400 finish_graph_dump_file (dump_base_name, ".cse");
3402 finish_graph_dump_file (dump_base_name, ".loop");
3404 finish_graph_dump_file (dump_base_name, ".cse2");
3405 if (branch_prob_dump)
3406 finish_graph_dump_file (dump_base_name, ".bp");
3408 finish_graph_dump_file (dump_base_name, ".flow");
3410 finish_graph_dump_file (dump_base_name, ".combine");
3412 finish_graph_dump_file (dump_base_name, ".regmove");
3414 finish_graph_dump_file (dump_base_name, ".sched");
3416 finish_graph_dump_file (dump_base_name, ".lreg");
3417 if (global_reg_dump)
3418 finish_graph_dump_file (dump_base_name, ".greg");
3420 finish_graph_dump_file (dump_base_name, ".flow2");
3422 finish_graph_dump_file (dump_base_name, ".sched2");
3424 finish_graph_dump_file (dump_base_name, ".jump2");
3427 finish_graph_dump_file (dump_base_name, ".dbr");
3430 finish_graph_dump_file (dump_base_name, ".gcse");
3433 finish_graph_dump_file (dump_base_name, ".stack");
3435 #ifdef MACHINE_DEPENDENT_REORG
3436 if (mach_dep_reorg_dump)
3437 finish_graph_dump_file (dump_base_name, ".mach");
3441 /* Free up memory for the benefit of leak detectors. */
3444 /* Print the times. */
3448 fprintf (stderr,"\n");
3449 print_time ("parse", parse_time);
3451 print_time ("integration", integration_time);
3452 print_time ("jump", jump_time);
3453 print_time ("cse", cse_time);
3454 print_time ("gcse", gcse_time);
3455 print_time ("loop", loop_time);
3456 print_time ("cse2", cse2_time);
3457 print_time ("branch-prob", branch_prob_time);
3458 print_time ("flow", flow_time);
3459 print_time ("combine", combine_time);
3460 print_time ("regmove", regmove_time);
3461 print_time ("sched", sched_time);
3462 print_time ("local-alloc", local_alloc_time);
3463 print_time ("global-alloc", global_alloc_time);
3464 print_time ("flow2", flow2_time);
3465 print_time ("sched2", sched2_time);
3467 print_time ("dbranch", dbr_sched_time);
3469 print_time ("shorten-branch", shorten_branch_time);
3470 print_time ("stack-reg", stack_reg_time);
3471 print_time ("final", final_time);
3472 print_time ("varconst", varconst_time);
3473 print_time ("symout", symout_time);
3474 print_time ("dump", dump_time);
3478 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3479 and TYPE_DECL nodes.
3481 This does nothing for local (non-static) variables.
3482 Otherwise, it sets up the RTL and outputs any assembler code
3483 (label definition, storage allocation and initialization).
3485 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3486 the assembler symbol name to be used. TOP_LEVEL is nonzero
3487 if this declaration is not within a function. */
3490 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
3492 const char *asmspec;
3496 /* Declarations of variables, and of functions defined elsewhere. */
3498 /* The most obvious approach, to put an #ifndef around where
3499 this macro is used, doesn't work since it's inside a macro call. */
3500 #ifndef ASM_FINISH_DECLARE_OBJECT
3501 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3504 /* Forward declarations for nested functions are not "external",
3505 but we need to treat them as if they were. */
3506 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
3507 || TREE_CODE (decl) == FUNCTION_DECL)
3508 TIMEVAR (varconst_time,
3510 make_decl_rtl (decl, asmspec, top_level);
3511 /* Initialized extern variable exists to be replaced
3512 with its value, or represents something that will be
3513 output in another file. */
3514 if (! (TREE_CODE (decl) == VAR_DECL
3515 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
3516 && DECL_INITIAL (decl) != 0
3517 && DECL_INITIAL (decl) != error_mark_node))
3518 /* Don't output anything
3519 when a tentative file-scope definition is seen.
3520 But at end of compilation, do output code for them. */
3521 if (! (! at_end && top_level
3522 && (DECL_INITIAL (decl) == 0
3523 || DECL_INITIAL (decl) == error_mark_node)))
3524 assemble_variable (decl, top_level, at_end, 0);
3525 if (decl == last_assemble_variable_decl)
3527 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
3531 else if (DECL_REGISTER (decl) && asmspec != 0)
3533 if (decode_reg_name (asmspec) >= 0)
3535 DECL_RTL (decl) = 0;
3536 make_decl_rtl (decl, asmspec, top_level);
3539 error ("invalid register name `%s' for register variable", asmspec);
3541 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3542 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3543 && TREE_CODE (decl) == TYPE_DECL)
3544 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
3546 #ifdef SDB_DEBUGGING_INFO
3547 else if (write_symbols == SDB_DEBUG && top_level
3548 && TREE_CODE (decl) == TYPE_DECL)
3549 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
3553 /* Called after finishing a record, union or enumeral type. */
3556 rest_of_type_compilation (type, toplev)
3557 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3561 tree type ATTRIBUTE_UNUSED;
3562 int toplev ATTRIBUTE_UNUSED;
3565 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3566 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3567 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3569 #ifdef SDB_DEBUGGING_INFO
3570 if (write_symbols == SDB_DEBUG)
3571 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3575 /* This is called from finish_function (within yyparse)
3576 after each top-level definition is parsed.
3577 It is supposed to compile that function or variable
3578 and output the assembler code for it.
3579 After we return, the tree storage is freed. */
3582 rest_of_compilation (decl)
3586 int start_time = get_run_time ();
3588 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3589 to be restored after we finish compiling the function
3590 (for use when compiling inline calls to this function). */
3591 tree saved_block_tree = 0;
3592 /* Likewise, for DECL_ARGUMENTS. */
3593 tree saved_arguments = 0;
3595 int rebuild_label_notes_after_reload;
3597 /* If we are reconsidering an inline function
3598 at the end of compilation, skip the stuff for making it inline. */
3600 if (DECL_SAVED_INSNS (decl) == 0)
3605 /* If requested, consider whether to make this function inline. */
3606 if (DECL_INLINE (decl) || flag_inline_functions)
3607 TIMEVAR (integration_time,
3609 lose = function_cannot_inline_p (decl);
3610 if (lose || ! optimize)
3612 if (warn_inline && DECL_INLINE (decl))
3613 warning_with_decl (decl, lose);
3614 DECL_ABSTRACT_ORIGIN (decl) = 0;
3615 /* Don't really compile an extern inline function.
3616 If we can't make it inline, pretend
3617 it was only declared. */
3618 if (DECL_EXTERNAL (decl))
3620 DECL_INITIAL (decl) = 0;
3621 goto exit_rest_of_compilation;
3625 /* ??? Note that this has the effect of making it look
3626 like "inline" was specified for a function if we choose
3627 to inline it. This isn't quite right, but it's
3628 probably not worth the trouble to fix. */
3629 inlinable = DECL_INLINE (decl) = 1;
3632 insns = get_insns ();
3634 /* Dump the rtl code if we are dumping rtl. */
3638 open_dump_file (".rtl", decl_printable_name (decl, 2));
3640 if (DECL_SAVED_INSNS (decl))
3641 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3643 close_dump_file (print_rtl, insns);
3646 /* If we can, defer compiling inlines until EOF.
3647 save_for_inline_copying can be extremely expensive. */
3648 if (inlinable && ! decl_function_context (decl))
3649 DECL_DEFER_OUTPUT (decl) = 1;
3651 /* If function is inline, and we don't yet know whether to
3652 compile it by itself, defer decision till end of compilation.
3653 finish_compilation will call rest_of_compilation again
3654 for those functions that need to be output. Also defer those
3655 functions that we are supposed to defer. We cannot defer
3656 functions containing nested functions since the nested function
3657 data is in our non-saved obstack. We cannot defer nested
3658 functions for the same reason. */
3660 /* If this is a nested inline, remove ADDRESSOF now so we can
3661 finish compiling ourselves. Otherwise, wait until EOF.
3662 We have to do this because the purge_addressof transformation
3663 changes the DECL_RTL for many variables, which confuses integrate. */
3666 if (decl_function_context (decl))
3667 purge_addressof (insns);
3669 DECL_DEFER_OUTPUT (decl) = 1;
3672 if (! current_function_contains_functions
3673 && (DECL_DEFER_OUTPUT (decl)
3674 || (DECL_INLINE (decl)
3675 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3676 && ! flag_keep_inline_functions)
3677 || DECL_EXTERNAL (decl)))))
3679 DECL_DEFER_OUTPUT (decl) = 1;
3681 /* If -Wreturn-type, we have to do a bit of compilation.
3682 However, if we just fall through we will call
3683 save_for_inline_copying() which results in excessive
3684 memory use. Instead, we just want to call
3685 jump_optimize() to figure out whether or not we can fall
3686 off the end of the function; we do the minimum amount of
3687 work necessary to make that safe. And, we set optimize
3688 to zero to keep jump_optimize from working too hard. */
3689 if (warn_return_type)
3691 int saved_optimize = optimize;
3693 find_exception_handler_labels ();
3694 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3695 !JUMP_AFTER_REGSCAN);
3696 optimize = saved_optimize;
3699 #ifdef DWARF_DEBUGGING_INFO
3700 /* Generate the DWARF info for the "abstract" instance
3701 of a function which we may later generate inlined and/or
3702 out-of-line instances of. */
3703 if (write_symbols == DWARF_DEBUG)
3705 set_decl_abstract_flags (decl, 1);
3706 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3707 set_decl_abstract_flags (decl, 0);
3710 #ifdef DWARF2_DEBUGGING_INFO
3711 /* Generate the DWARF2 info for the "abstract" instance
3712 of a function which we may later generate inlined and/or
3713 out-of-line instances of. */
3714 if (write_symbols == DWARF2_DEBUG)
3716 set_decl_abstract_flags (decl, 1);
3717 TIMEVAR (symout_time, dwarf2out_decl (decl));
3718 set_decl_abstract_flags (decl, 0);
3721 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3722 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3723 goto exit_rest_of_compilation;
3726 /* If we have to compile the function now, save its rtl and subdecls
3727 so that its compilation will not affect what others get. */
3728 if (inlinable || DECL_DEFER_OUTPUT (decl))
3730 #ifdef DWARF_DEBUGGING_INFO
3731 /* Generate the DWARF info for the "abstract" instance of
3732 a function which we will generate an out-of-line instance
3733 of almost immediately (and which we may also later generate
3734 various inlined instances of). */
3735 if (write_symbols == DWARF_DEBUG)
3737 set_decl_abstract_flags (decl, 1);
3738 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3739 set_decl_abstract_flags (decl, 0);
3742 #ifdef DWARF2_DEBUGGING_INFO
3743 /* Generate the DWARF2 info for the "abstract" instance of
3744 a function which we will generate an out-of-line instance
3745 of almost immediately (and which we may also later generate
3746 various inlined instances of). */
3747 if (write_symbols == DWARF2_DEBUG)
3749 set_decl_abstract_flags (decl, 1);
3750 TIMEVAR (symout_time, dwarf2out_decl (decl));
3751 set_decl_abstract_flags (decl, 0);
3754 saved_block_tree = DECL_INITIAL (decl);
3755 saved_arguments = DECL_ARGUMENTS (decl);
3756 TIMEVAR (integration_time, save_for_inline_copying (decl));
3757 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3760 /* If specified extern inline but we aren't inlining it, we are
3761 done. This goes for anything that gets here with DECL_EXTERNAL
3762 set, not just things with DECL_INLINE. */
3763 if (DECL_EXTERNAL (decl))
3764 goto exit_rest_of_compilation;
3767 if (! DECL_DEFER_OUTPUT (decl))
3768 TREE_ASM_WRITTEN (decl) = 1;
3770 /* Now that integrate will no longer see our rtl, we need not distinguish
3771 between the return value of this function and the return value of called
3773 rtx_equal_function_value_matters = 0;
3775 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3776 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3778 goto exit_rest_of_compilation;
3781 /* Emit code to get eh context, if needed. */
3785 /* If we are doing position-independent code generation, now
3786 is the time to output special prologues and epilogues.
3787 We do not want to do this earlier, because it just clutters
3788 up inline functions with meaningless insns. */
3793 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3794 Note that that may have been done above, in save_for_inline_copying.
3795 The call to resume_temporary_allocation near the end of this function
3796 goes back to the usual state of affairs. This must be done after
3797 we've built up any unwinders for exception handling, and done
3798 the FINALIZE_PIC work, if necessary. */
3800 rtl_in_current_obstack ();
3802 insns = get_insns ();
3804 /* Copy any shared structure that should not be shared. */
3806 unshare_all_rtl (insns);
3808 #ifdef SETJMP_VIA_SAVE_AREA
3809 /* This must be performed before virutal register instantiation. */
3810 if (current_function_calls_alloca)
3811 optimize_save_area_alloca (insns);
3814 /* Instantiate all virtual registers. */
3816 instantiate_virtual_regs (current_function_decl, get_insns ());
3818 /* See if we have allocated stack slots that are not directly addressable.
3819 If so, scan all the insns and create explicit address computation
3820 for all references to such slots. */
3821 /* fixup_stack_slots (); */
3823 /* Find all the EH handlers. */
3824 find_exception_handler_labels ();
3826 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3827 are initialized and to compute whether control can drop off the end
3829 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3830 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3831 JUMP_AFTER_REGSCAN));
3833 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3834 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3835 goto exit_rest_of_compilation;
3837 /* Dump rtl code after jump, if we are doing that. */
3840 dump_rtl (".jump", decl, print_rtl, insns);
3842 /* Perform common subexpression elimination.
3843 Nonzero value from `cse_main' means that jumps were simplified
3844 and some code may now be unreachable, so do
3845 jump optimization again. */
3850 open_dump_file (".cse", decl_printable_name (decl, 2));
3852 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3854 if (flag_thread_jumps)
3855 /* Hacks by tiemann & kenner. */
3856 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3858 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3860 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3862 if (tem || optimize > 1)
3863 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3865 !JUMP_AFTER_REGSCAN));
3867 /* Dump rtl code after cse, if we are doing that. */
3871 close_dump_file (print_rtl, insns);
3872 if (graph_dump_format != no_graph)
3873 print_rtl_graph_with_bb (dump_base_name, ".cse", insns);
3877 purge_addressof (insns);
3878 reg_scan (insns, max_reg_num (), 1);
3882 dump_rtl (".addressof", decl, print_rtl, insns);
3883 if (graph_dump_format != no_graph)
3884 print_rtl_graph_with_bb (dump_base_name, ".addressof", insns);
3887 /* Perform global cse. */
3889 if (optimize > 0 && flag_gcse)
3892 open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl)));
3894 TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file));
3896 /* If gcse altered any jumps, rerun jump optimizations to clean
3900 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3902 !JUMP_AFTER_REGSCAN));
3907 close_dump_file (print_rtl, insns);
3908 if (graph_dump_format != no_graph)
3909 print_rtl_graph_with_bb (dump_base_name, ".gcse", insns);
3912 /* Move constant computations out of loops. */
3917 open_dump_file (".loop", decl_printable_name (decl, 2));
3922 if (flag_rerun_loop_opt)
3924 /* We only want to perform unrolling once. */
3926 loop_optimize (insns, rtl_dump_file, 0, 0);
3929 /* The first call to loop_optimize makes some instructions
3930 trivially dead. We delete those instructions now in the
3931 hope that doing so will make the heuristics in loop work
3932 better and possibly speed up compilation. */
3933 delete_trivially_dead_insns (insns, max_reg_num ());
3935 /* The regscan pass is currently necessary as the alias
3936 analysis code depends on this information. */
3937 reg_scan (insns, max_reg_num (), 1);
3939 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
3942 /* Dump rtl code after loop opt, if we are doing that. */
3946 close_dump_file (print_rtl, insns);
3947 if (graph_dump_format != no_graph)
3948 print_rtl_graph_with_bb (dump_base_name, ".loop", insns);
3955 open_dump_file (".cse2", decl_printable_name (decl, 2));
3957 if (flag_rerun_cse_after_loop)
3959 /* Running another jump optimization pass before the second
3960 cse pass sometimes simplifies the RTL enough to allow
3961 the second CSE pass to do a better job. Jump_optimize can change
3962 max_reg_num so we must rerun reg_scan afterwards.
3963 ??? Rework to not call reg_scan so often. */
3964 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3965 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3967 JUMP_AFTER_REGSCAN));
3969 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3970 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3973 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3975 !JUMP_AFTER_REGSCAN));
3978 if (flag_thread_jumps)
3980 /* This pass of jump threading straightens out code
3981 that was kinked by loop optimization. */
3982 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3983 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3986 /* Dump rtl code after cse, if we are doing that. */
3990 close_dump_file (print_rtl, insns);
3991 if (graph_dump_format != no_graph)
3992 print_rtl_graph_with_bb (dump_base_name, ".cse2", insns);
3996 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3998 if (branch_prob_dump)
3999 open_dump_file (".bp", decl_printable_name (decl, 2));
4004 branch_prob (insns, rtl_dump_file);
4007 if (branch_prob_dump)
4009 close_dump_file (print_rtl, insns);
4010 if (graph_dump_format != no_graph)
4011 print_rtl_graph_with_bb (dump_base_name, ".bp", insns);
4015 /* We are no longer anticipating cse in this function, at least. */
4017 cse_not_expected = 1;
4019 /* Now we choose between stupid (pcc-like) register allocation
4020 (if we got the -noreg switch and not -opt)
4021 and smart register allocation. */
4023 if (optimize > 0) /* Stupid allocation probably won't work */
4024 obey_regdecls = 0; /* if optimizations being done. */
4028 /* Print function header into flow dump now
4029 because doing the flow analysis makes some of the dump. */
4032 open_dump_file (".flow", decl_printable_name (decl, 2));
4038 regclass (insns, max_reg_num ());
4039 stupid_life_analysis (insns, max_reg_num (),
4045 /* Do control and data flow analysis,
4046 and write some of the results to dump file. */
4051 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4052 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4055 if (warn_uninitialized)
4057 uninitialized_vars_warning (DECL_INITIAL (decl));
4058 setjmp_args_warning ();
4062 /* Dump rtl after flow analysis. */
4066 close_dump_file (print_rtl_with_bb, insns);
4067 if (graph_dump_format != no_graph)
4068 print_rtl_graph_with_bb (dump_base_name, ".flow", insns);
4071 /* The first life analysis pass has finished. From now on we can not
4072 generate any new pseudos. */
4075 /* If -opt, try combining insns through substitution. */
4079 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
4081 /* Dump rtl code after insn combination. */
4085 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
4086 if (graph_dump_format != no_graph)
4087 print_rtl_graph_with_bb (dump_base_name, ".combine", insns);
4091 /* Register allocation pre-pass, to reduce number of moves
4092 necessary for two-address machines. */
4093 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
4096 open_dump_file (".regmove", decl_printable_name (decl, 2));
4098 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
4103 close_dump_file (print_rtl_with_bb, insns);
4104 if (graph_dump_format != no_graph)
4105 print_rtl_graph_with_bb (dump_base_name, ".regmove", insns);
4109 /* Print function header into sched dump now
4110 because doing the sched analysis makes some of the dump. */
4112 if (optimize > 0 && flag_schedule_insns)
4115 open_dump_file (".sched", decl_printable_name (decl, 2));
4117 /* Do control and data sched analysis,
4118 and write some of the results to dump file. */
4120 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
4122 /* Dump rtl after instruction scheduling. */
4126 close_dump_file (print_rtl_with_bb, insns);
4127 if (graph_dump_format != no_graph)
4128 print_rtl_graph_with_bb (dump_base_name, ".sched", insns);
4132 /* Determine if the current function is a leaf before running reload
4133 since this can impact optimizations done by the prologue and
4134 epilogue thus changing register elimination offsets. */
4135 current_function_is_leaf = leaf_function_p ();
4137 /* Unless we did stupid register allocation,
4138 allocate pseudo-regs that are used only within 1 basic block.
4140 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
4141 jump optimizer after register allocation and reloading are finished. */
4144 TIMEVAR (local_alloc_time,
4146 recompute_reg_usage (insns, ! optimize_size);
4147 regclass (insns, max_reg_num ());
4148 rebuild_label_notes_after_reload = local_alloc ();
4151 rebuild_label_notes_after_reload = 0;
4153 /* Dump rtl code after allocating regs within basic blocks. */
4157 open_dump_file (".lreg", decl_printable_name (decl, 2));
4159 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
4160 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
4162 close_dump_file (print_rtl_with_bb, insns);
4163 if (graph_dump_format != no_graph)
4164 print_rtl_graph_with_bb (dump_base_name, ".lreg", insns);
4167 if (global_reg_dump)
4168 open_dump_file (".greg", decl_printable_name (decl, 2));
4170 /* Unless we did stupid register allocation,
4171 allocate remaining pseudo-regs, then do the reload pass
4172 fixing up any insns that are invalid. */
4174 TIMEVAR (global_alloc_time,
4177 failure = global_alloc (rtl_dump_file);
4179 failure = reload (insns, 0, rtl_dump_file);
4184 goto exit_rest_of_compilation;
4186 /* Do a very simple CSE pass over just the hard registers. */
4188 reload_cse_regs (insns);
4190 /* Register allocation and reloading may have turned an indirect jump into
4191 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
4192 jumping instructions. */
4193 if (rebuild_label_notes_after_reload)
4194 TIMEVAR (jump_time, rebuild_jump_labels (insns));
4196 /* If optimizing and we are performing instruction scheduling after
4197 reload, then go ahead and split insns now since we are about to
4198 recompute flow information anyway.
4200 reload_cse_regs may expose more splitting opportunities, expecially
4201 for double-word operations. */
4202 if (optimize > 0 && flag_schedule_insns_after_reload)
4206 for (insn = insns; insn; insn = NEXT_INSN (insn))
4210 if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
4213 last = try_split (PATTERN (insn), insn, 1);
4217 PUT_CODE (insn, NOTE);
4218 NOTE_SOURCE_FILE (insn) = 0;
4219 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
4224 if (global_reg_dump)
4226 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
4227 close_dump_file (print_rtl_with_bb, insns);
4228 if (graph_dump_format != no_graph)
4229 print_rtl_graph_with_bb (dump_base_name, ".greg", insns);
4232 /* Re-create the death notes which were deleted during reload. */
4234 open_dump_file (".flow2", decl_printable_name (decl, 2));
4241 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4242 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4246 flow2_completed = 1;
4248 /* On some machines, the prologue and epilogue code, or parts thereof,
4249 can be represented as RTL. Doing so lets us schedule insns between
4250 it and the rest of the code and also allows delayed branch
4251 scheduling to operate in the epilogue. */
4253 thread_prologue_and_epilogue_insns (insns);
4257 close_dump_file (print_rtl_with_bb, insns);
4258 if (graph_dump_format != no_graph)
4259 print_rtl_graph_with_bb (dump_base_name, ".flow2", insns);
4262 if (optimize > 0 && flag_schedule_insns_after_reload)
4265 open_dump_file (".sched2", decl_printable_name (decl, 2));
4267 /* Do control and data sched analysis again,
4268 and write some more of the results to dump file. */
4270 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
4272 /* Dump rtl after post-reorder instruction scheduling. */
4276 close_dump_file (print_rtl_with_bb, insns);
4277 if (graph_dump_format != no_graph)
4278 print_rtl_graph_with_bb (dump_base_name, ".sched2", insns);
4282 #ifdef LEAF_REGISTERS
4283 current_function_uses_only_leaf_regs
4284 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
4287 /* One more attempt to remove jumps to .+1
4288 left by dead-store-elimination.
4289 Also do cross-jumping this time
4290 and delete no-op move insns. */
4294 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
4296 !JUMP_AFTER_REGSCAN));
4298 /* Dump rtl code after jump, if we are doing that. */
4302 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
4303 if (graph_dump_format != no_graph)
4304 print_rtl_graph_with_bb (dump_base_name, ".jump2", insns);
4308 /* If a machine dependent reorganization is needed, call it. */
4309 #ifdef MACHINE_DEPENDENT_REORG
4310 MACHINE_DEPENDENT_REORG (insns);
4312 if (mach_dep_reorg_dump)
4314 dump_rtl (".mach", decl, print_rtl_with_bb, insns);
4315 if (graph_dump_format != no_graph)
4316 print_rtl_graph_with_bb (dump_base_name, ".mach", insns);
4320 /* If a scheduling pass for delayed branches is to be done,
4321 call the scheduling code. */
4324 if (optimize > 0 && flag_delayed_branch)
4327 open_dump_file (".dbr", decl_printable_name (decl, 2));
4329 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
4333 close_dump_file (print_rtl_with_bb, insns);
4334 if (graph_dump_format != no_graph)
4335 print_rtl_graph_with_bb (dump_base_name, ".dbr", insns);
4340 /* Shorten branches. */
4341 TIMEVAR (shorten_branch_time,
4343 shorten_branches (get_insns ());
4348 open_dump_file (".stack", decl_printable_name (decl, 2));
4350 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
4354 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
4355 if (graph_dump_format != no_graph)
4356 print_rtl_graph_with_bb (dump_base_name, ".stack", insns);
4360 /* Now turn the rtl into assembler code. */
4362 TIMEVAR (final_time,
4367 /* Get the function's name, as described by its RTL.
4368 This may be different from the DECL_NAME name used
4369 in the source file. */
4371 x = DECL_RTL (decl);
4372 if (GET_CODE (x) != MEM)
4375 if (GET_CODE (x) != SYMBOL_REF)
4377 fnname = XSTR (x, 0);
4379 assemble_start_function (decl, fnname);
4380 final_start_function (insns, asm_out_file, optimize);
4381 final (insns, asm_out_file, optimize, 0);
4382 final_end_function (insns, asm_out_file, optimize);
4383 assemble_end_function (decl, fnname);
4385 fflush (asm_out_file);
4387 /* Release all memory allocated by flow. */
4388 free_basic_block_vars (0);
4390 /* Release all memory held by regsets now */
4391 regset_release_memory ();
4394 /* Write DBX symbols if requested */
4396 /* Note that for those inline functions where we don't initially
4397 know for certain that we will be generating an out-of-line copy,
4398 the first invocation of this routine (rest_of_compilation) will
4399 skip over this code by doing a `goto exit_rest_of_compilation;'.
4400 Later on, finish_compilation will call rest_of_compilation again
4401 for those inline functions that need to have out-of-line copies
4402 generated. During that call, we *will* be routed past here. */
4404 #ifdef DBX_DEBUGGING_INFO
4405 if (write_symbols == DBX_DEBUG)
4406 TIMEVAR (symout_time, dbxout_function (decl));
4409 #ifdef DWARF_DEBUGGING_INFO
4410 if (write_symbols == DWARF_DEBUG)
4411 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
4414 #ifdef DWARF2_DEBUGGING_INFO
4415 if (write_symbols == DWARF2_DEBUG)
4416 TIMEVAR (symout_time, dwarf2out_decl (decl));
4419 exit_rest_of_compilation:
4423 /* In case the function was not output,
4424 don't leave any temporary anonymous types
4425 queued up for sdb output. */
4426 #ifdef SDB_DEBUGGING_INFO
4427 if (write_symbols == SDB_DEBUG)
4428 sdbout_types (NULL_TREE);
4431 /* Put back the tree of subblocks and list of arguments
4432 from before we copied them.
4433 Code generation and the output of debugging info may have modified
4434 the copy, but the original is unchanged. */
4436 if (saved_block_tree != 0)
4438 DECL_INITIAL (decl) = saved_block_tree;
4439 DECL_ARGUMENTS (decl) = saved_arguments;
4440 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
4443 reload_completed = 0;
4444 flow2_completed = 0;
4447 TIMEVAR (final_time,
4449 /* Clear out the insn_length contents now that they are no
4451 init_insn_lengths ();
4453 /* Clear out the real_constant_chain before some of the rtx's
4454 it runs through become garbage. */
4455 clear_const_double_mem ();
4457 /* Cancel the effect of rtl_in_current_obstack. */
4458 resume_temporary_allocation ();
4460 /* Show no temporary slots allocated. */
4464 /* Make sure volatile mem refs aren't considered valid operands for
4465 arithmetic insns. We must call this here if this is a nested inline
4466 function, since the above code leaves us in the init_recog state
4467 (from final.c), and the function context push/pop code does not
4468 save/restore volatile_ok.
4470 ??? Maybe it isn't necessary for expand_start_function to call this
4471 anymore if we do it here? */
4473 init_recog_no_volatile ();
4475 /* The parsing time is all the time spent in yyparse
4476 *except* what is spent in this function. */
4478 parse_time -= get_run_time () - start_time;
4480 /* Reset global variables. */
4481 free_basic_block_vars (0);
4492 printf ("Usage: %s input [switches]\n", progname);
4493 printf ("Switches:\n");
4495 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
4496 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
4497 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4498 printf (" -finline-limit-<number> Limits the size of inlined functions to <number>\n");
4500 for (i = NUM_ELEM (f_options); i--;)
4502 const char * description = f_options[i].description;
4504 if (description != NULL && * description != 0)
4505 printf (" -f%-21s %s\n",
4506 f_options[i].string, description);
4509 printf (" -O[number] Set optimisation level to [number]\n");
4510 printf (" -Os Optimise for space rather than speed\n");
4511 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
4512 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
4513 printf (" -w Suppress warnings\n");
4514 printf (" -W Enable extra warnings\n");
4516 for (i = NUM_ELEM (W_options); i--;)
4518 const char * description = W_options[i].description;
4520 if (description != NULL && * description != 0)
4521 printf (" -W%-21s %s\n",
4522 W_options[i].string, description);
4525 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4526 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4527 printf (" -p Enable function profiling\n");
4528 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4529 printf (" -a Enable block profiling \n");
4531 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4532 printf (" -ax Enable jump profiling \n");
4534 printf (" -o <file> Place output into <file> \n");
4535 printf (" -G <number> Put global and static data smaller than <number>\n");
4536 printf (" bytes into a special section (on some targets)\n");
4538 for (i = NUM_ELEM (debug_args); i--;)
4540 if (debug_args[i].description != NULL)
4541 printf (" -%-22s %s\n", debug_args[i].arg, debug_args[i].description);
4544 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4545 printf (" -quiet Do not display functions compiled or elapsed time\n");
4546 printf (" -version Display the compiler's version\n");
4547 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4548 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4549 #if defined HAIFA || defined INSN_SCHEDULING
4550 printf (" -sched-verbose-<number> Set the verbosity level of the scheduler\n");
4552 printf (" --help Display this information\n");
4557 /* Display descriptions of language specific options.
4558 If there is no description, note that there is an undocumented option.
4559 If the description is empty, do not display anything. (This allows
4560 options to be deliberately undocumented, for whatever reason).
4561 If the option string is missing, then this is a marker, indicating
4562 that the description string is in fact the name of a language, whose
4563 language specific options are to follow. */
4565 if (NUM_ELEM (documented_lang_options) > 1)
4567 printf ("\nLanguage specific options:\n");
4569 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
4571 const char * description = documented_lang_options[i].description;
4572 const char * option = documented_lang_options[i].option;
4574 if (description == NULL)
4579 printf (" %-23.23s [undocumented]\n", option);
4581 else if (* description == 0)
4583 else if (option == NULL)
4587 ("\nThere are undocumented %s specific options as well.\n",
4591 printf ("\n Options for %s:\n", description);
4596 printf (" %-23.23s %s\n", option, description);
4601 printf ("\nThere are undocumented %s specific options as well.\n", lang);
4603 if (NUM_ELEM (target_switches) > 1
4604 #ifdef TARGET_OPTIONS
4605 || NUM_ELEM (target_options) > 1
4613 printf ("\nTarget specific options:\n");
4615 for (i = NUM_ELEM (target_switches); i--;)
4617 const char * option = target_switches[i].name;
4618 const char * description = target_switches[i].description;
4620 if (option == NULL || * option == 0)
4622 else if (description == NULL)
4627 printf (" -m%-21.21s [undocumented]\n", option);
4629 else if (* description != 0)
4630 doc += printf (" -m%-21.21s %s\n", option, description);
4633 #ifdef TARGET_OPTIONS
4634 for (i = NUM_ELEM (target_options); i--;)
4636 const char * option = target_options[i].prefix;
4637 const char * description = target_options[i].description;
4639 if (option == NULL || * option == 0)
4641 else if (description == NULL)
4646 printf (" -m%-21.21s [undocumented]\n", option);
4648 else if (* description != 0)
4649 doc += printf (" -m%-21.21s %s\n", option, description);
4655 printf ("\nThere are undocumented target specific options as well.\n");
4657 printf (" They exist, but they are not documented.\n");
4662 /* Compare the user specified 'option' with the language
4663 specific 'lang_option'. Return true if they match, or
4664 if 'option' is a viable prefix of 'lang_option'. */
4667 check_lang_option (option, lang_option)
4671 lang_independent_options * indep_options;
4676 /* Ignore NULL entries. */
4677 if (option == NULL || lang_option == NULL)
4680 if ((space = strchr (lang_option, ' ')) != NULL)
4681 len = space - lang_option;
4683 len = strlen (lang_option);
4685 /* If they do not match to the first n characters then fail. */
4686 if (strncmp (option, lang_option, len) != 0)
4689 /* Do not accept a lang option, if it matches a normal -f or -W
4690 option. Chill defines a -fpack, but we want to support
4693 /* An exact match is OK */
4694 if ((int) strlen (option) == len)
4697 /* If it is not an -f or -W option allow the match */
4698 if (option[0] != '-')
4703 case 'f': indep_options = f_options; break;
4704 case 'W': indep_options = W_options; break;
4708 /* The option is a -f or -W option.
4709 Skip past the prefix and search for the remainder in the
4710 appropriate table of options. */
4713 if (option[0] == 'n' && option[1] == 'o' && option[2] == '-')
4716 for (k = NUM_ELEM (indep_options); k--;)
4718 if (!strcmp (option, indep_options[k].string))
4720 /* The option matched a language independent option,
4721 do not allow the language specific match. */
4727 /* The option matches the start of the langauge specific option
4728 and it is not an exact match for a language independent option. */
4732 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4733 Exit code is 35 if can't open files, 34 if fatal error,
4734 33 if had nonfatal errors, else success. */
4743 int flag_print_mem = 0;
4744 int version_flag = 0;
4747 /* save in case md file wants to emit args as a comment. */
4751 p = argv[0] + strlen (argv[0]);
4752 while (p != argv[0] && p[-1] != '/'
4753 #ifdef DIR_SEPARATOR
4754 && p[-1] != DIR_SEPARATOR
4760 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
4761 /* Get rid of any avoidable limit on stack size. */
4765 /* Set the stack limit huge so that alloca does not fail. */
4766 getrlimit (RLIMIT_STACK, &rlim);
4767 rlim.rlim_cur = rlim.rlim_max;
4768 setrlimit (RLIMIT_STACK, &rlim);
4772 #ifdef HAVE_LC_MESSAGES
4773 setlocale (LC_MESSAGES, "");
4775 (void) bindtextdomain (PACKAGE, localedir);
4776 (void) textdomain (PACKAGE);
4778 signal (SIGFPE, float_signal);
4781 signal (SIGPIPE, pipe_closed);
4784 decl_printable_name = decl_name;
4785 lang_expand_expr = (lang_expand_expr_t) do_abort;
4787 /* Initialize whether `char' is signed. */
4788 flag_signed_char = DEFAULT_SIGNED_CHAR;
4789 #ifdef DEFAULT_SHORT_ENUMS
4790 /* Initialize how much space enums occupy, by default. */
4791 flag_short_enums = DEFAULT_SHORT_ENUMS;
4794 /* Perform language-specific options intialization. */
4795 lang_init_options ();
4797 /* Scan to see what optimization level has been specified. That will
4798 determine the default value of many flags. */
4799 for (i = 1; i < argc; i++)
4801 if (!strcmp (argv[i], "-O"))
4806 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4808 /* Handle -Os, -O2, -O3, -O69, ... */
4809 char *p = &argv[i][2];
4811 if ((p[0] == 's') && (p[1] == 0))
4815 /* Optimizing for size forces optimize to be 2. */
4820 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4821 if (optimize_val != -1)
4823 optimize = optimize_val;
4830 obey_regdecls = (optimize == 0);
4835 flag_thread_jumps = 1;
4837 flag_delayed_branch = 1;
4839 #ifdef CAN_DEBUG_WITHOUT_FP
4840 flag_omit_frame_pointer = 1;
4846 flag_cse_follow_jumps = 1;
4847 flag_cse_skip_blocks = 1;
4849 flag_expensive_optimizations = 1;
4850 flag_strength_reduce = 1;
4851 flag_rerun_cse_after_loop = 1;
4852 flag_rerun_loop_opt = 1;
4853 flag_caller_saves = 1;
4855 #ifdef INSN_SCHEDULING
4856 flag_schedule_insns = 1;
4857 flag_schedule_insns_after_reload = 1;
4860 flag_strict_aliasing = 1;
4865 flag_inline_functions = 1;
4868 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4871 set_target_switch ("");
4873 #ifdef OPTIMIZATION_OPTIONS
4874 /* Allow default optimizations to be specified on a per-machine basis. */
4875 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4878 /* Initialize register usage now so switches may override. */
4881 for (i = 1; i < argc; i++)
4885 /* If this is a language-specific option,
4886 decode it in a language-specific way. */
4887 for (j = NUM_ELEM (documented_lang_options); j--;)
4888 if (check_lang_option (argv[i], documented_lang_options[j].option))
4891 if (j != (size_t)-1)
4893 /* If the option is valid for *some* language,
4894 treat it as valid even if this language doesn't understand it. */
4895 int strings_processed = lang_decode_option (argc - i, argv + i);
4897 if (!strcmp (argv[i], "--help"))
4903 if (strings_processed != 0)
4904 i += strings_processed - 1;
4906 else if (argv[i][0] == '-' && argv[i][1] != 0)
4908 register char *str = argv[i] + 1;
4913 set_target_switch (&str[1]);
4914 else if (!strcmp (str, "dumpbase"))
4916 dump_base_name = argv[++i];
4918 else if (str[0] == 'd')
4920 register char *p = &str[1];
4925 branch_prob_dump = 1;
4932 global_reg_dump = 1;
4940 cse_dump = 1, cse2_dump = 1;
4947 #ifdef MACHINE_DEPENDENT_REORG
4948 mach_dep_reorg_dump = 1;
4955 branch_prob_dump = 1;
4972 global_reg_dump = 1;
4997 #ifdef MACHINE_DEPENDENT_REORG
4999 mach_dep_reorg_dump = 1;
5003 flag_print_asm_name = 1;
5024 graph_dump_format = vcg;
5033 rtl_dump_and_exit = 1;
5035 case 'D': /* these are handled by the preprocessor */
5039 warning ("unrecognised gcc debugging option: %c", p[-1]);
5043 else if (str[0] == 'f')
5045 register char *p = &str[1];
5048 /* Some kind of -f option.
5049 P's value is the option sans `-f'.
5050 Search for it in the table of options. */
5053 !found && j < sizeof (f_options) / sizeof (f_options[0]);
5056 if (!strcmp (p, f_options[j].string))
5058 *f_options[j].variable = f_options[j].on_value;
5059 /* A goto here would be cleaner,
5060 but breaks the vax pcc. */
5063 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
5064 && ! strcmp (p+3, f_options[j].string))
5066 *f_options[j].variable = ! f_options[j].on_value;
5073 else if (!strncmp (p, "inline-limit-", 13))
5075 read_integral_parameter (p + 13, p - 2, inline_max_insns);
5077 #ifdef INSN_SCHEDULING
5078 else if (!strncmp (p, "sched-verbose-",14))
5079 fix_sched_param("verbose",&p[14]);
5082 else if (!strncmp (p, "fixed-", 6))
5083 fix_register (&p[6], 1, 1);
5084 else if (!strncmp (p, "call-used-", 10))
5085 fix_register (&p[10], 0, 1);
5086 else if (!strncmp (p, "call-saved-", 11))
5087 fix_register (&p[11], 0, 0);
5089 error ("Invalid option `%s'", argv[i]);
5091 else if (str[0] == 'O')
5093 /* Already been treated above. Do nothing. */
5095 else if (!strcmp (str, "pedantic"))
5097 else if (!strcmp (str, "pedantic-errors"))
5098 flag_pedantic_errors = pedantic = 1;
5099 else if (!strcmp (str, "quiet"))
5101 else if (!strcmp (str, "version"))
5103 else if (!strcmp (str, "w"))
5104 inhibit_warnings = 1;
5105 else if (!strcmp (str, "W"))
5108 /* We save the value of warn_uninitialized, since if they put
5109 -Wuninitialized on the command line, we need to generate a
5110 warning about not using it without also specifying -O. */
5111 if (warn_uninitialized != 1)
5112 warn_uninitialized = 2;
5114 else if (str[0] == 'W')
5116 register char *p = &str[1];
5119 /* Some kind of -W option.
5120 P's value is the option sans `-W'.
5121 Search for it in the table of options. */
5124 !found && j < sizeof (W_options) / sizeof (W_options[0]);
5127 if (!strcmp (p, W_options[j].string))
5129 *W_options[j].variable = W_options[j].on_value;
5130 /* A goto here would be cleaner,
5131 but breaks the vax pcc. */
5134 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
5135 && ! strcmp (p+3, W_options[j].string))
5137 *W_options[j].variable = ! W_options[j].on_value;
5144 else if (!strncmp (p, "id-clash-", 9))
5146 const int id_clash_val
5147 = read_integral_parameter (p + 9, p - 2, -1);
5148 if (id_clash_val != -1)
5150 id_clash_len = id_clash_val;
5154 else if (!strncmp (p, "larger-than-", 12))
5156 const int larger_than_val
5157 = read_integral_parameter (p + 12, p - 2, -1);
5158 if (larger_than_val != -1)
5160 larger_than_size = larger_than_val;
5161 warn_larger_than = 1;
5165 error ("Invalid option `%s'", argv[i]);
5167 else if (!strcmp (str, "p"))
5171 else if (!strcmp (str, "a"))
5173 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5174 warning ("`-a' option (basic block profile) not supported");
5176 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
5179 else if (!strcmp (str, "ax"))
5181 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5182 warning ("`-ax' option (jump profiling) not supported");
5184 profile_block_flag = (!profile_block_flag
5185 || profile_block_flag == 2) ? 2 : 3;
5188 else if (str[0] == 'g')
5191 /* A lot of code assumes write_symbols == NO_DEBUG if the
5192 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
5193 of what debugging type has been selected). This records the
5194 selected type. It is an error to specify more than one
5196 static enum debug_info_type selected_debug_type = NO_DEBUG;
5197 /* Non-zero if debugging format has been explicitly set.
5198 -g and -ggdb don't explicitly set the debugging format so
5199 -gdwarf -g3 is equivalent to -gdwarf3. */
5200 static int type_explicitly_set_p = 0;
5201 /* Indexed by enum debug_info_type. */
5202 static const char *debug_type_names[] =
5204 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
5207 /* The maximum admissible debug level value. */
5208 static const unsigned max_debug_level = 3;
5210 /* Look up STR in the table. */
5211 for (da = debug_args; da->arg; da++)
5213 const int da_len = strlen (da->arg);
5215 if (! strncmp (str, da->arg, da_len))
5217 enum debug_info_type type = da->debug_type;
5218 const char *p = str + da_len;
5220 if (*p && (*p < '0' || *p > '9'))
5223 /* A debug flag without a level defaults to level 2.
5224 Note we do not want to call read_integral_parameter
5225 for that case since it will call atoi which
5228 ??? We may want to generalize the interface to
5229 read_integral_parameter to better handle this case
5230 if this case shows up often. */
5232 level = read_integral_parameter (p, 0,
5233 max_debug_level + 1);
5237 if (da_len > 1 && !strncmp (str, "gdwarf", da_len))
5239 error ("use -gdwarf -g%d for DWARF v1, level %d",
5242 error ("use -gdwarf-2 for DWARF v2");
5245 if (level > max_debug_level)
5247 warning ("ignoring option `%s' due to invalid debug level specification",
5249 level = debug_info_level;
5252 if (type == NO_DEBUG)
5254 type = PREFERRED_DEBUGGING_TYPE;
5255 if (da_len > 1 && strncmp (str, "ggdb", da_len) == 0)
5257 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
5258 type = DWARF2_DEBUG;
5260 #ifdef DBX_DEBUGGING_INFO
5267 if (type == NO_DEBUG)
5268 warning ("`-%s' not supported by this configuration of GCC",
5271 /* Does it conflict with an already selected type? */
5272 if (type_explicitly_set_p
5273 /* -g/-ggdb don't conflict with anything */
5274 && da->debug_type != NO_DEBUG
5275 && type != selected_debug_type)
5276 warning ("`-%s' ignored, conflicts with `-g%s'",
5277 str, debug_type_names[(int) selected_debug_type]);
5280 /* If the format has already been set, -g/-ggdb
5281 only change the debug level. */
5282 if (type_explicitly_set_p
5283 && da->debug_type == NO_DEBUG)
5284 ; /* don't change debugging type */
5287 selected_debug_type = type;
5288 type_explicitly_set_p = da->debug_type != NO_DEBUG;
5290 write_symbols = (level == 0
5292 : selected_debug_type);
5293 use_gnu_debug_info_extensions = da->use_extensions_p;
5294 debug_info_level = (enum debug_info_level) level;
5300 warning ("`-%s' not supported by this configuration of GCC",
5303 else if (!strcmp (str, "o"))
5305 asm_file_name = argv[++i];
5307 else if (str[0] == 'G')
5309 const int g_switch_val = (str[1] != '\0') ?
5310 read_integral_parameter(str + 1, 0, -1) :
5311 read_integral_parameter(argv[++i], 0, -1);
5313 if (g_switch_val != -1)
5315 g_switch_set = TRUE;
5316 g_switch_value = g_switch_val;
5320 error("Invalid option `-%s'",str);
5323 else if (!strncmp (str, "aux-info", 8))
5325 flag_gen_aux_info = 1;
5326 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
5328 else if (!strcmp (str, "-help"))
5334 error ("Invalid option `%s'", argv[i]);
5336 else if (argv[i][0] == '+')
5337 error ("Invalid option `%s'", argv[i]);
5342 /* Checker uses the frame pointer. */
5343 if (flag_check_memory_usage)
5344 flag_omit_frame_pointer = 0;
5348 /* Inlining does not work if not optimizing,
5349 so force it not to be done. */
5353 /* The c_decode_option and lang_decode_option functions set
5354 this to `2' if -Wall is used, so we can avoid giving out
5355 lots of errors for people who don't realize what -Wall does. */
5356 if (warn_uninitialized == 1)
5357 warning ("-Wuninitialized is not supported without -O");
5360 #ifdef OVERRIDE_OPTIONS
5361 /* Some machines may reject certain combinations of options. */
5365 if (exceptions_via_longjmp == 2)
5367 #ifdef DWARF2_UNWIND_INFO
5368 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
5370 exceptions_via_longjmp = 1;
5374 if (profile_block_flag == 3)
5376 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
5377 profile_block_flag = 2;
5380 /* Unrolling all loops implies that standard loop unrolling must also
5382 if (flag_unroll_all_loops)
5383 flag_unroll_loops = 1;
5384 /* Loop unrolling requires that strength_reduction be on also. Silently
5385 turn on strength reduction here if it isn't already on. Also, the loop
5386 unrolling code assumes that cse will be run after loop, so that must
5387 be turned on also. */
5388 if (flag_unroll_loops)
5390 flag_strength_reduce = 1;
5391 flag_rerun_cse_after_loop = 1;
5394 /* Warn about options that are not supported on this machine. */
5395 #ifndef INSN_SCHEDULING
5396 if (flag_schedule_insns || flag_schedule_insns_after_reload)
5397 warning ("instruction scheduling not supported on this target machine");
5400 if (flag_delayed_branch)
5401 warning ("this target machine does not have delayed branches");
5404 user_label_prefix = USER_LABEL_PREFIX;
5405 if (flag_leading_underscore != -1)
5407 /* If the default prefix is more complicated than "" or "_",
5408 issue a warning and ignore this option. */
5409 if (user_label_prefix[0] == 0 ||
5410 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5412 user_label_prefix = flag_leading_underscore ? "_" : "";
5415 warning ("-f%sleading-underscore not supported on this target machine",
5416 flag_leading_underscore ? "" : "no-");
5419 /* If we are in verbose mode, write out the version and maybe all the
5420 option flags in use. */
5423 print_version (stderr, "");
5425 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5428 compile_file (filename);
5430 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
5433 char *lim = (char *) sbrk (0);
5435 notice ("Data size %ld.\n", (long) (lim - (char *) &environ));
5440 system ("ps -l 1>&2");
5443 #endif /* not USG */
5446 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
5449 exit (FATAL_EXIT_CODE);
5451 exit (FATAL_EXIT_CODE);
5452 exit (SUCCESS_EXIT_CODE);
5456 /* Decode -m switches. */
5457 /* Decode the switch -mNAME. */
5460 set_target_switch (name)
5464 int valid_target_option = 0;
5466 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5467 if (!strcmp (target_switches[j].name, name))
5469 if (target_switches[j].value < 0)
5470 target_flags &= ~-target_switches[j].value;
5472 target_flags |= target_switches[j].value;
5473 valid_target_option = 1;
5476 #ifdef TARGET_OPTIONS
5477 if (!valid_target_option)
5478 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5480 int len = strlen (target_options[j].prefix);
5481 if (!strncmp (target_options[j].prefix, name, len))
5483 *target_options[j].variable = name + len;
5484 valid_target_option = 1;
5489 if (!valid_target_option)
5490 error ("Invalid option `%s'", name);
5493 /* Print version information to FILE.
5494 Each line begins with INDENT (for the case where FILE is the
5495 assembler output file). */
5498 print_version (file, indent)
5503 #define __VERSION__ "[?]"
5507 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
5509 "%s%s%s version %s (%s) compiled by CC.\n"
5511 , indent, *indent != 0 ? " " : "",
5512 language_string, version_string, TARGET_NAME, __VERSION__);
5515 /* Print an option value and return the adjusted position in the line.
5516 ??? We don't handle error returns from fprintf (disk full); presumably
5517 other code will catch a disk full though. */
5520 print_single_switch (file, pos, max, indent, sep, term, type, name)
5523 const char *indent, *sep, *term, *type, *name;
5525 /* The ultrix fprintf returns 0 on success, so compute the result we want
5526 here since we need it for the following test. */
5527 int len = strlen (sep) + strlen (type) + strlen (name);
5532 fprintf (file, "%s", term);
5537 fprintf (file, "%s", indent);
5538 pos = strlen (indent);
5540 fprintf (file, "%s%s%s", sep, type, name);
5545 /* Print active target switches to FILE.
5546 POS is the current cursor position and MAX is the size of a "line".
5547 Each line begins with INDENT and ends with TERM.
5548 Each switch is separated from the next by SEP. */
5551 print_switch_values (file, pos, max, indent, sep, term)
5554 const char *indent, *sep, *term;
5559 /* Print the options as passed. */
5561 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5562 _("options passed: "), "");
5564 for (p = &save_argv[1]; *p != NULL; p++)
5568 if (strcmp (*p, "-o") == 0)
5574 if (strcmp (*p, "-quiet") == 0)
5576 if (strcmp (*p, "-version") == 0)
5581 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5584 fprintf (file, "%s", term);
5586 /* Print the -f and -m options that have been enabled.
5587 We don't handle language specific options but printing argv
5590 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5591 _("options enabled: "), "");
5593 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
5594 if (*f_options[j].variable == f_options[j].on_value)
5595 pos = print_single_switch (file, pos, max, indent, sep, term,
5596 "-f", f_options[j].string);
5598 /* Print target specific options. */
5600 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5601 if (target_switches[j].name[0] != '\0'
5602 && target_switches[j].value > 0
5603 && ((target_switches[j].value & target_flags)
5604 == target_switches[j].value))
5606 pos = print_single_switch (file, pos, max, indent, sep, term,
5607 "-m", target_switches[j].name);
5610 #ifdef TARGET_OPTIONS
5611 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5612 if (*target_options[j].variable != NULL)
5615 sprintf (prefix, "-m%s", target_options[j].prefix);
5616 pos = print_single_switch (file, pos, max, indent, sep, term,
5617 prefix, *target_options[j].variable);
5621 fprintf (file, "%s", term);
5624 /* Record the beginning of a new source file, named FILENAME. */
5627 debug_start_source_file (filename)
5628 register char *filename ATTRIBUTE_UNUSED;
5630 #ifdef DBX_DEBUGGING_INFO
5631 if (write_symbols == DBX_DEBUG)
5632 dbxout_start_new_source_file (filename);
5634 #ifdef DWARF_DEBUGGING_INFO
5635 if (debug_info_level == DINFO_LEVEL_VERBOSE
5636 && write_symbols == DWARF_DEBUG)
5637 dwarfout_start_new_source_file (filename);
5638 #endif /* DWARF_DEBUGGING_INFO */
5639 #ifdef DWARF2_DEBUGGING_INFO
5640 if (debug_info_level == DINFO_LEVEL_VERBOSE
5641 && write_symbols == DWARF2_DEBUG)
5642 dwarf2out_start_source_file (filename);
5643 #endif /* DWARF2_DEBUGGING_INFO */
5644 #ifdef SDB_DEBUGGING_INFO
5645 if (write_symbols == SDB_DEBUG)
5646 sdbout_start_new_source_file (filename);
5650 /* Record the resumption of a source file. LINENO is the line number in
5651 the source file we are returning to. */
5654 debug_end_source_file (lineno)
5655 register unsigned lineno ATTRIBUTE_UNUSED;
5657 #ifdef DBX_DEBUGGING_INFO
5658 if (write_symbols == DBX_DEBUG)
5659 dbxout_resume_previous_source_file ();
5661 #ifdef DWARF_DEBUGGING_INFO
5662 if (debug_info_level == DINFO_LEVEL_VERBOSE
5663 && write_symbols == DWARF_DEBUG)
5664 dwarfout_resume_previous_source_file (lineno);
5665 #endif /* DWARF_DEBUGGING_INFO */
5666 #ifdef DWARF2_DEBUGGING_INFO
5667 if (debug_info_level == DINFO_LEVEL_VERBOSE
5668 && write_symbols == DWARF2_DEBUG)
5669 dwarf2out_end_source_file ();
5670 #endif /* DWARF2_DEBUGGING_INFO */
5671 #ifdef SDB_DEBUGGING_INFO
5672 if (write_symbols == SDB_DEBUG)
5673 sdbout_resume_previous_source_file ();
5677 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5678 the tail part of the directive line, i.e. the part which is past the
5679 initial whitespace, #, whitespace, directive-name, whitespace part. */
5682 debug_define (lineno, buffer)
5683 register unsigned lineno ATTRIBUTE_UNUSED;
5684 register char *buffer ATTRIBUTE_UNUSED;
5686 #ifdef DWARF_DEBUGGING_INFO
5687 if (debug_info_level == DINFO_LEVEL_VERBOSE
5688 && write_symbols == DWARF_DEBUG)
5689 dwarfout_define (lineno, buffer);
5690 #endif /* DWARF_DEBUGGING_INFO */
5691 #ifdef DWARF2_DEBUGGING_INFO
5692 if (debug_info_level == DINFO_LEVEL_VERBOSE
5693 && write_symbols == DWARF2_DEBUG)
5694 dwarf2out_define (lineno, buffer);
5695 #endif /* DWARF2_DEBUGGING_INFO */
5698 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5699 the tail part of the directive line, i.e. the part which is past the
5700 initial whitespace, #, whitespace, directive-name, whitespace part. */
5703 debug_undef (lineno, buffer)
5704 register unsigned lineno ATTRIBUTE_UNUSED;
5705 register char *buffer ATTRIBUTE_UNUSED;
5707 #ifdef DWARF_DEBUGGING_INFO
5708 if (debug_info_level == DINFO_LEVEL_VERBOSE
5709 && write_symbols == DWARF_DEBUG)
5710 dwarfout_undef (lineno, buffer);
5711 #endif /* DWARF_DEBUGGING_INFO */
5712 #ifdef DWARF2_DEBUGGING_INFO
5713 if (debug_info_level == DINFO_LEVEL_VERBOSE
5714 && write_symbols == DWARF2_DEBUG)
5715 dwarf2out_undef (lineno, buffer);
5716 #endif /* DWARF2_DEBUGGING_INFO */