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"
55 #include "basic-block.h"
58 #ifdef DWARF_DEBUGGING_INFO
62 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
63 #include "dwarf2out.h"
66 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
70 #ifdef SDB_DEBUGGING_INFO
74 #ifdef XCOFF_DEBUGGING_INFO
79 /* The extra parameters substantially improve the I/O performance. */
81 vms_fopen (fname
, type
)
85 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
86 fixed arguments, which matches ANSI's specification but not VAXCRTL's
87 pre-ANSI implementation. This hack circumvents the mismatch problem. */
88 FILE *(*vmslib_fopen
)() = (FILE *(*)()) fopen
;
91 return (*vmslib_fopen
) (fname
, type
, "mbc=32",
92 "deq=64", "fop=tef", "shr=nil");
94 return (*vmslib_fopen
) (fname
, type
, "mbc=32");
96 #define fopen vms_fopen
99 #ifndef DEFAULT_GDB_EXTENSIONS
100 #define DEFAULT_GDB_EXTENSIONS 1
103 /* If more than one debugging type is supported, you must define
104 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
106 This is one long line cause VAXC can't handle a \-newline. */
107 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
108 #ifndef PREFERRED_DEBUGGING_TYPE
109 You Lose
! You must define PREFERRED_DEBUGGING_TYPE
!
110 #endif /* no PREFERRED_DEBUGGING_TYPE */
111 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
112 so the following code needn't care. */
113 #ifdef DBX_DEBUGGING_INFO
114 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
116 #ifdef SDB_DEBUGGING_INFO
117 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
119 #ifdef DWARF_DEBUGGING_INFO
120 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
122 #ifdef DWARF2_DEBUGGING_INFO
123 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
125 #ifdef XCOFF_DEBUGGING_INFO
126 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
128 #endif /* More than one debugger format enabled. */
130 /* If still not defined, must have been because no debugging formats
132 #ifndef PREFERRED_DEBUGGING_TYPE
133 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
136 #ifndef DIR_SEPARATOR
137 #define DIR_SEPARATOR '/'
140 #if ! (defined (VMS) || defined (OS2))
141 extern char **environ
;
143 extern char *version_string
;
145 /* Carry information from ASM_DECLARE_OBJECT_NAME
146 to ASM_FINISH_DECLARE_OBJECT. */
148 extern int size_directive_output
;
149 extern tree last_assemble_variable_decl
;
151 extern void init_decl_processing ();
152 extern void init_obstacks ();
153 extern void init_tree_codes ();
154 extern void init_regs ();
155 extern void init_optabs ();
156 extern void init_stmt ();
157 extern void init_reg_sets ();
158 extern void dump_flow_info ();
159 extern void dump_sched_info ();
160 extern void dump_local_alloc ();
161 extern void regset_release_memory ();
163 extern void print_rtl ();
164 extern void print_rtl_with_bb ();
166 void rest_of_decl_compilation ();
167 void error_with_file_and_line
PVPROTO((const char *file
,
168 int line
, const char *s
, ...));
169 void error_with_decl
PVPROTO((tree decl
, const char *s
, ...));
170 void error_for_asm
PVPROTO((rtx insn
, const char *s
, ...));
171 void notice
PVPROTO((const char *s
, ...));
172 void error
PVPROTO((const char *s
, ...));
173 void fatal
PVPROTO((const char *s
, ...));
174 void warning_with_file_and_line
PVPROTO((const char *file
,
175 int line
, const char *s
, ...));
176 void warning_with_decl
PVPROTO((tree decl
, const char *s
, ...));
177 void warning
PVPROTO((const char *s
, ...));
178 void pedwarn
PVPROTO((const char *s
, ...));
179 void pedwarn_with_decl
PVPROTO((tree decl
, const char *s
, ...));
180 void pedwarn_with_file_and_line
PVPROTO((const char *file
,
181 int line
, const char *s
, ...));
182 void sorry
PVPROTO((const char *s
, ...));
183 static void set_target_switch
PROTO((const char *));
184 static const char *decl_name
PROTO((tree
, int));
185 static void vmessage
PROTO((const char *, const char *, va_list));
186 static void v_message_with_file_and_line
PROTO((const char *, int, int,
187 const char *, va_list));
188 static void v_message_with_decl
PROTO((tree
, int, const char *, va_list));
189 static void file_and_line_for_asm
PROTO((rtx
, char **, int *));
190 static void v_error_with_file_and_line
PROTO((const char *, int,
191 const char *, va_list));
192 static void v_error_with_decl
PROTO((tree
, const char *, va_list));
193 static void v_error_for_asm
PROTO((rtx
, const char *, va_list));
194 static void verror
PROTO((const char *, va_list));
195 static void vfatal
PROTO((const char *, va_list)) ATTRIBUTE_NORETURN
;
196 static void v_warning_with_file_and_line
PROTO ((const char *, int,
197 const char *, va_list));
198 static void v_warning_with_decl
PROTO((tree
, const char *, va_list));
199 static void v_warning_for_asm
PROTO((rtx
, const char *, va_list));
200 static void vwarning
PROTO((const char *, va_list));
201 static void vpedwarn
PROTO((const char *, va_list));
202 static void v_pedwarn_with_decl
PROTO((tree
, const char *, va_list));
203 static void v_pedwarn_with_file_and_line
PROTO((const char *, int,
204 const char *, va_list));
205 static void vsorry
PROTO((const char *, va_list));
206 static void float_signal
PROTO((int)) ATTRIBUTE_NORETURN
;
207 static void pipe_closed
PROTO((int)) ATTRIBUTE_NORETURN
;
208 #ifdef ASM_IDENTIFY_LANGUAGE
209 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
210 static void output_lang_identify
PROTO((FILE *)) ATTRIBUTE_UNUSED
;
212 static void open_dump_file
PROTO((const char *, const char *));
213 static void close_dump_file
PROTO((void (*) (FILE *, rtx
), rtx
));
214 static void dump_rtl
PROTO((const char *, tree
, void (*) (FILE *, rtx
), rtx
));
215 static void clean_dump_file
PROTO((const char *));
216 static void compile_file
PROTO((char *));
217 static void display_help
PROTO ((void));
219 static void print_version
PROTO((FILE *, const char *));
220 static int print_single_switch
PROTO((FILE *, int, int, const char *,
221 const char *, const char *,
222 const char *, const char *));
223 static void print_switch_values
PROTO((FILE *, int, int, const char *,
224 const char *, const char *));
226 void print_rtl_graph_with_bb
PROTO ((const char *, const char *, rtx
));
227 void clean_graph_dump_file
PROTO ((const char *, const char *));
228 void finish_graph_dump_file
PROTO ((const char *, const char *));
229 /* Length of line when printing switch values. */
232 /* Name of program invoked, sans directories. */
236 /* Copy of arguments to main. */
240 /* Name of current original source file (what was input to cpp).
241 This comes from each #-command in the actual input. */
243 char *input_filename
;
245 /* Name of top-level original source file (what was input to cpp).
246 This comes from the #-command at the beginning of the actual input.
247 If there isn't any there, then this is the cc1 input file name. */
249 char *main_input_filename
;
251 /* Current line number in real source file. */
255 /* Nonzero if it is unsafe to create any new pseudo registers. */
258 /* Stack of currently pending input files. */
260 struct file_stack
*input_file_stack
;
262 /* Incremented on each change to input_file_stack. */
263 int input_file_stack_tick
;
265 /* Name to use as base of names for dump output files. */
267 const char *dump_base_name
;
269 /* Bit flags that specify the machine subtype we are compiling for.
270 Bits are tested using macros TARGET_... defined in the tm.h file
271 and set by `-m...' switches. Must be defined in rtlanal.c. */
273 extern int target_flags
;
275 /* Flags saying which kinds of debugging dump have been requested. */
278 int rtl_dump_and_exit
= 0;
279 int jump_opt_dump
= 0;
280 int addressof_dump
= 0;
285 int branch_prob_dump
= 0;
287 int combine_dump
= 0;
288 int regmove_dump
= 0;
290 int local_reg_dump
= 0;
291 int global_reg_dump
= 0;
293 int peephole2_dump
= 0;
295 int jump2_opt_dump
= 0;
297 int dbr_sched_dump
= 0;
299 int flag_print_asm_name
= 0;
301 int stack_reg_dump
= 0;
303 #ifdef MACHINE_DEPENDENT_REORG
304 int mach_dep_reorg_dump
= 0;
306 enum graph_dump_types graph_dump_format
;
308 /* Name for output file of assembly code, specified with -o. */
312 /* Value of the -G xx switch, and whether it was passed or not. */
316 /* Type(s) of debugging information we are producing (if any).
317 See flags.h for the definitions of the different possible
318 types of debugging information. */
319 enum debug_info_type write_symbols
= NO_DEBUG
;
321 /* Level of debugging information we are producing. See flags.h
322 for the definitions of the different possible levels. */
323 enum debug_info_level debug_info_level
= DINFO_LEVEL_NONE
;
325 /* Nonzero means use GNU-only extensions in the generated symbolic
326 debugging information. */
327 /* Currently, this only has an effect when write_symbols is set to
328 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
329 int use_gnu_debug_info_extensions
= 0;
331 /* Nonzero means do optimizations. -O.
332 Particular numeric values stand for particular amounts of optimization;
333 thus, -O2 stores 2 here. However, the optimizations beyond the basic
334 ones are not controlled directly by this variable. Instead, they are
335 controlled by individual `flag_...' variables that are defaulted
336 based on this variable. */
340 /* Nonzero means optimize for size. -Os.
341 The only valid values are zero and non-zero. When optimize_size is
342 non-zero, optimize defaults to 2, but certain individual code
343 bloating optimizations are disabled. */
345 int optimize_size
= 0;
347 /* Number of error messages and warning messages so far. */
350 int warningcount
= 0;
353 /* Pointer to function to compute the name to use to print a declaration.
354 DECL is the declaration in question.
355 VERBOSITY determines what information will be printed:
356 0: DECL_NAME, demangled as necessary.
357 1: and scope information.
358 2: and any other information that might be interesting, such as function
359 parameter types in C++. */
361 const char *(*decl_printable_name
) PROTO ((tree
, int));
363 /* Pointer to function to compute rtl for a language-specific tree code. */
365 typedef rtx (*lang_expand_expr_t
)
366 PROTO ((union tree_node
*, rtx
, enum machine_mode
,
367 enum expand_modifier modifier
));
369 lang_expand_expr_t lang_expand_expr
= 0;
371 tree (*lang_expand_constant
) PROTO((tree
)) = 0;
373 /* Pointer to function to finish handling an incomplete decl at the
374 end of compilation. */
376 void (*incomplete_decl_finalize_hook
) PROTO((tree
)) = 0;
378 /* Nonzero if generating code to do profiling. */
380 int profile_flag
= 0;
382 /* Nonzero if generating code to do profiling on a line-by-line basis. */
384 int profile_block_flag
;
386 /* Nonzero if generating code to profile program flow graph arcs. */
388 int profile_arc_flag
= 0;
390 /* Nonzero if generating info for gcov to calculate line test coverage. */
392 int flag_test_coverage
= 0;
394 /* Nonzero indicates that branch taken probabilities should be calculated. */
396 int flag_branch_probabilities
= 0;
398 /* Nonzero for -pedantic switch: warn about anything
399 that standard spec forbids. */
403 /* Temporarily suppress certain warnings.
404 This is set while reading code from a system header file. */
406 int in_system_header
= 0;
408 /* Nonzero means do stupid register allocation.
409 Currently, this is 1 if `optimize' is 0. */
411 int obey_regdecls
= 0;
413 /* Don't print functions as they are compiled and don't print
414 times taken by the various passes. -quiet. */
420 /* Nonzero means `char' should be signed. */
422 int flag_signed_char
;
424 /* Nonzero means give an enum type only as many bytes as it needs. */
426 int flag_short_enums
;
428 /* Nonzero for -fcaller-saves: allocate values in regs that need to
429 be saved across function calls, if that produces overall better code.
430 Optional now, so people can test it. */
432 #ifdef DEFAULT_CALLER_SAVES
433 int flag_caller_saves
= 1;
435 int flag_caller_saves
= 0;
438 /* Nonzero if structures and unions should be returned in memory.
440 This should only be defined if compatibility with another compiler or
441 with an ABI is needed, because it results in slower code. */
443 #ifndef DEFAULT_PCC_STRUCT_RETURN
444 #define DEFAULT_PCC_STRUCT_RETURN 1
447 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
449 int flag_pcc_struct_return
= DEFAULT_PCC_STRUCT_RETURN
;
451 /* Nonzero for -fforce-mem: load memory value into a register
452 before arithmetic on it. This makes better cse but slower compilation. */
454 int flag_force_mem
= 0;
456 /* Nonzero for -fforce-addr: load memory address into a register before
457 reference to memory. This makes better cse but slower compilation. */
459 int flag_force_addr
= 0;
461 /* Nonzero for -fdefer-pop: don't pop args after each function call;
462 instead save them up to pop many calls' args with one insns. */
464 int flag_defer_pop
= 0;
466 /* Nonzero for -ffloat-store: don't allocate floats and doubles
467 in extended-precision registers. */
469 int flag_float_store
= 0;
471 /* Nonzero for -fcse-follow-jumps:
472 have cse follow jumps to do a more extensive job. */
474 int flag_cse_follow_jumps
;
476 /* Nonzero for -fcse-skip-blocks:
477 have cse follow a branch around a block. */
478 int flag_cse_skip_blocks
;
480 /* Nonzero for -fexpensive-optimizations:
481 perform miscellaneous relatively-expensive optimizations. */
482 int flag_expensive_optimizations
;
484 /* Nonzero for -fthread-jumps:
485 have jump optimize output of loop. */
487 int flag_thread_jumps
;
489 /* Nonzero enables strength-reduction in loop.c. */
491 int flag_strength_reduce
= 0;
493 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
494 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
495 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
498 int flag_unroll_loops
;
500 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
501 This is generally not a win. */
503 int flag_unroll_all_loops
;
505 /* Nonzero forces all invariant computations in loops to be moved
508 int flag_move_all_movables
= 0;
510 /* Nonzero forces all general induction variables in loops to be
513 int flag_reduce_all_givs
= 0;
515 /* Nonzero to perform full register move optimization passes. This is the
518 int flag_regmove
= 0;
520 /* Nonzero for -fwritable-strings:
521 store string constants in data segment and don't uniquize them. */
523 int flag_writable_strings
= 0;
525 /* Nonzero means don't put addresses of constant functions in registers.
526 Used for compiling the Unix kernel, where strange substitutions are
527 done on the assembly output. */
529 int flag_no_function_cse
= 0;
531 /* Nonzero for -fomit-frame-pointer:
532 don't make a frame pointer in simple functions that don't require one. */
534 int flag_omit_frame_pointer
= 0;
536 /* Nonzero means place each function into its own section on those platforms
537 which support arbitrary section names and unlimited numbers of sections. */
539 int flag_function_sections
= 0;
541 /* ... and similar for data. */
543 int flag_data_sections
= 0;
545 /* Nonzero to inhibit use of define_optimization peephole opts. */
547 int flag_no_peephole
= 0;
549 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
550 operations in the interest of optimization. For example it allows
551 GCC to assume arguments to sqrt are nonnegative numbers, allowing
552 faster code for sqrt to be generated. */
554 int flag_fast_math
= 0;
556 /* Nonzero means the front end generally wants `errno' maintained by math
557 operations, like built-in SQRT, unless overridden by flag_fast_math. */
559 int flag_errno_math
= 1;
561 /* 0 means straightforward implementation of complex divide acceptable.
562 1 means wide ranges of inputs must work for complex divide.
563 2 means C9X-like requirements for complex divide (not yet implemented). */
565 int flag_complex_divide_method
= 0;
567 /* Nonzero means all references through pointers are volatile. */
571 /* Nonzero means treat all global and extern variables as volatile. */
573 int flag_volatile_global
;
575 /* Nonzero means treat all static variables as volatile. */
577 int flag_volatile_static
;
579 /* Nonzero means just do syntax checking; don't output anything. */
581 int flag_syntax_only
= 0;
583 /* Nonzero means perform global cse. */
585 static int flag_gcse
;
587 /* Nonzero means to rerun cse after loop optimization. This increases
588 compilation time about 20% and picks up a few more common expressions. */
590 static int flag_rerun_cse_after_loop
;
592 /* Nonzero means to run loop optimizations twice. */
594 int flag_rerun_loop_opt
;
596 /* Nonzero for -finline-functions: ok to inline functions that look like
597 good inline candidates. */
599 int flag_inline_functions
;
601 /* Nonzero for -fkeep-inline-functions: even if we make a function
602 go inline everywhere, keep its definition around for debugging
605 int flag_keep_inline_functions
;
607 /* Nonzero means that functions will not be inlined. */
611 /* Nonzero means that we should emit static const variables
612 regardless of whether or not optimization is turned on. */
614 int flag_keep_static_consts
= 1;
616 /* Nonzero means we should be saving declaration info into a .X file. */
618 int flag_gen_aux_info
= 0;
620 /* Specified name of aux-info file. */
622 static char *aux_info_file_name
;
624 /* Nonzero means make the text shared if supported. */
626 int flag_shared_data
;
628 /* Nonzero means schedule into delayed branch slots if supported. */
630 int flag_delayed_branch
;
632 /* Nonzero if we are compiling pure (sharable) code.
633 Value is 1 if we are doing reasonable (i.e. simple
634 offset into offset table) pic. Value is 2 if we can
635 only perform register offsets. */
639 /* Nonzero means generate extra code for exception handling and enable
640 exception handling. */
644 /* Nonzero means use the new model for exception handling. Replaces
645 -DNEW_EH_MODEL as a compile option. */
647 int flag_new_exceptions
= 1;
649 /* Nonzero means don't place uninitialized global data in common storage
654 /* Nonzero means pretend it is OK to examine bits of target floats,
655 even if that isn't true. The resulting code will have incorrect constants,
656 but the same series of instructions that the native compiler would make. */
658 int flag_pretend_float
;
660 /* Nonzero means change certain warnings into errors.
661 Usually these are warnings about failure to conform to some standard. */
663 int flag_pedantic_errors
= 0;
665 /* flag_schedule_insns means schedule insns within basic blocks (before
667 flag_schedule_insns_after_reload means schedule insns after
670 int flag_schedule_insns
= 0;
671 int flag_schedule_insns_after_reload
= 0;
673 /* The following flags have effect only for scheduling before register
676 flag_schedule_interblock means schedule insns accross basic blocks.
677 flag_schedule_speculative means allow speculative motion of non-load insns.
678 flag_schedule_speculative_load means allow speculative motion of some
680 flag_schedule_speculative_load_dangerous allows speculative motion of more
683 int flag_schedule_interblock
= 1;
684 int flag_schedule_speculative
= 1;
685 int flag_schedule_speculative_load
= 0;
686 int flag_schedule_speculative_load_dangerous
= 0;
688 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
689 by a cheaper branch, on a count register. */
690 int flag_branch_on_count_reg
;
692 /* -finhibit-size-directive inhibits output of .size for ELF.
693 This is used only for compiling crtstuff.c,
694 and it may be extended to other effects
695 needed for crtstuff.c on other systems. */
696 int flag_inhibit_size_directive
= 0;
698 /* -fverbose-asm causes extra commentary information to be produced in
699 the generated assembly code (to make it more readable). This option
700 is generally only of use to those who actually need to read the
701 generated assembly code (perhaps while debugging the compiler itself).
702 -fno-verbose-asm, the default, causes the extra information
703 to be omitted and is useful when comparing two assembler files. */
705 int flag_verbose_asm
= 0;
707 /* -dA causes debug commentary information to be produced in
708 the generated assembly code (to make it more readable). This option
709 is generally only of use to those who actually need to read the
710 generated assembly code (perhaps while debugging the compiler itself).
711 Currently, this switch is only used by dwarfout.c; however, it is intended
712 to be a catchall for printing debug information in the assembler file. */
714 int flag_debug_asm
= 0;
716 /* -fgnu-linker specifies use of the GNU linker for initializations.
717 (Or, more generally, a linker that handles initializations.)
718 -fno-gnu-linker says that collect2 will be used. */
720 int flag_gnu_linker
= 0;
722 int flag_gnu_linker
= 1;
725 /* Tag all structures with __attribute__(packed) */
726 int flag_pack_struct
= 0;
728 /* Emit code to check for stack overflow; also may cause large objects
729 to be allocated dynamically. */
730 int flag_stack_check
;
732 /* -fcheck-memory-usage causes extra code to be generated in order to check
733 memory accesses. This is used by a detector of bad memory accesses such
735 int flag_check_memory_usage
= 0;
737 /* -fprefix-function-name causes function name to be prefixed. This
738 can be used with -fcheck-memory-usage to isolate code compiled with
739 -fcheck-memory-usage. */
740 int flag_prefix_function_name
= 0;
742 /* 0 if pointer arguments may alias each other. True in C.
743 1 if pointer arguments may not alias each other but may alias
745 2 if pointer arguments may not alias each other and may not
746 alias global variables. True in Fortran.
747 This defaults to 0 for C. */
748 int flag_argument_noalias
= 0;
750 /* Nonzero if we should do (language-dependent) alias analysis.
751 Typically, this analysis will assume that expressions of certain
752 types do not alias expressions of certain other types. Only used
753 if alias analysis (in general) is enabled. */
754 int flag_strict_aliasing
= 0;
756 /* Instrument functions with calls at entry and exit, for profiling. */
757 int flag_instrument_function_entry_exit
= 0;
759 /* Nonzero means ignore `#ident' directives. 0 means handle them.
760 On SVR4 targets, it also controls whether or not to emit a
761 string identifying the compiler. */
763 int flag_no_ident
= 0;
765 /* This will perform a peephole pass before sched2. */
766 int flag_peephole2
= 0;
768 /* Values of the -falign-* flags: how much to align labels in code.
769 0 means `use default', 1 means `don't align'.
770 For each variable, there is an _log variant which is the power
771 of two not less than the variable, for .align output. */
778 int align_labels_log
;
780 int align_functions_log
;
782 /* Table of supported debugging formats. */
786 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
787 constant expression, we use NO_DEBUG in its place. */
788 enum debug_info_type debug_type
;
789 int use_extensions_p
;
790 const char * description
;
794 { "g", NO_DEBUG
, DEFAULT_GDB_EXTENSIONS
,
795 "Generate default debug format output" },
796 { "ggdb", NO_DEBUG
, 1, "Generate default extended debug format output" },
797 #ifdef DBX_DEBUGGING_INFO
798 { "gstabs", DBX_DEBUG
, 0, "Generate STABS format debug output" },
799 { "gstabs+", DBX_DEBUG
, 1, "Generate extended STABS format debug output" },
801 #ifdef DWARF_DEBUGGING_INFO
802 { "gdwarf", DWARF_DEBUG
, 0, "Generate DWARF-1 format debug output"},
803 { "gdwarf+", DWARF_DEBUG
, 1,
804 "Generated extended DWARF-1 format debug output" },
806 #ifdef DWARF2_DEBUGGING_INFO
807 { "gdwarf-2", DWARF2_DEBUG
, 0, "Enable DWARF-2 debug output" },
809 #ifdef XCOFF_DEBUGGING_INFO
810 { "gxcoff", XCOFF_DEBUG
, 0, "Generate XCOFF format debug output" },
811 { "gxcoff+", XCOFF_DEBUG
, 1, "Generate extended XCOFF format debug output" },
813 #ifdef SDB_DEBUGGING_INFO
814 { "gcoff", SDB_DEBUG
, 0, "Generate COFF format debug output" },
824 const char * description
;
826 lang_independent_options
;
828 /* Add or remove a leading underscore from user symbols. */
829 int flag_leading_underscore
= -1;
831 /* The user symbol prefix after having resolved same. */
832 const char *user_label_prefix
;
834 /* A default for same. */
835 #ifndef USER_LABEL_PREFIX
836 #define USER_LABEL_PREFIX ""
839 /* Table of language-independent -f options.
840 STRING is the option name. VARIABLE is the address of the variable.
841 ON_VALUE is the value to store in VARIABLE
842 if `-fSTRING' is seen as an option.
843 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
845 lang_independent_options f_options
[] =
847 {"float-store", &flag_float_store
, 1,
848 "Do not store floats in registers" },
849 {"volatile", &flag_volatile
, 1,
850 "Consider all mem refs through pointers as volatile"},
851 {"volatile-global", &flag_volatile_global
, 1,
852 "Consider all mem refs to global data to be volatile" },
853 {"volatile-static", &flag_volatile_static
, 1,
854 "Consider all mem refs to static data to be volatile" },
855 {"defer-pop", &flag_defer_pop
, 1,
856 "Defer popping functions args from stack until later" },
857 {"omit-frame-pointer", &flag_omit_frame_pointer
, 1,
858 "When possible do not generate stack frames"},
859 {"cse-follow-jumps", &flag_cse_follow_jumps
, 1,
860 "When running CSE, follow jumps to their targets" },
861 {"cse-skip-blocks", &flag_cse_skip_blocks
, 1,
862 "When running CSE, follow conditional jumps" },
863 {"expensive-optimizations", &flag_expensive_optimizations
, 1,
864 "Perform a number of minor, expensive optimisations" },
865 {"thread-jumps", &flag_thread_jumps
, 1,
866 "Perform jump threading optimisations"},
867 {"strength-reduce", &flag_strength_reduce
, 1,
868 "Perform strength reduction optimisations" },
869 {"unroll-loops", &flag_unroll_loops
, 1,
870 "Perform loop unrolling when iteration count is known" },
871 {"unroll-all-loops", &flag_unroll_all_loops
, 1,
872 "Perform loop unrolling for all loops" },
873 {"move-all-movables", &flag_move_all_movables
, 1,
874 "Force all loop invariant computations out of loops" },
875 {"reduce-all-givs", &flag_reduce_all_givs
, 1,
876 "Strength reduce all loop general induction variables" },
877 {"writable-strings", &flag_writable_strings
, 1,
878 "Store strings in writable data section" },
879 {"peephole", &flag_no_peephole
, 0,
880 "Enable machine specific peephole optimisations" },
881 {"force-mem", &flag_force_mem
, 1,
882 "Copy memory operands into registers before using" },
883 {"force-addr", &flag_force_addr
, 1,
884 "Copy memory address constants into regs before using" },
885 {"function-cse", &flag_no_function_cse
, 0,
886 "Allow function addresses to be held in registers" },
887 {"inline-functions", &flag_inline_functions
, 1,
888 "Integrate simple functions into their callers" },
889 {"keep-inline-functions", &flag_keep_inline_functions
, 1,
890 "Generate code for funcs even if they are fully inlined" },
891 {"inline", &flag_no_inline
, 0,
892 "Pay attention to the 'inline' keyword"},
893 {"keep-static-consts", &flag_keep_static_consts
, 1,
894 "Emit static const variables even if they are not used" },
895 {"syntax-only", &flag_syntax_only
, 1,
896 "Check for syntax errors, then stop" },
897 {"shared-data", &flag_shared_data
, 1,
898 "Mark data as shared rather than private" },
899 {"caller-saves", &flag_caller_saves
, 1,
900 "Enable saving registers around function calls" },
901 {"pcc-struct-return", &flag_pcc_struct_return
, 1,
902 "Return 'short' aggregates in memory, not registers" },
903 {"reg-struct-return", &flag_pcc_struct_return
, 0,
904 "Return 'short' aggregates in registers" },
905 {"delayed-branch", &flag_delayed_branch
, 1,
906 "Attempt to fill delay slots of branch instructions" },
907 {"gcse", &flag_gcse
, 1,
908 "Perform the global common subexpression elimination" },
909 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop
, 1,
910 "Run CSE pass after loop optimisations"},
911 {"rerun-loop-opt", &flag_rerun_loop_opt
, 1,
912 "Run the loop optimiser twice"},
913 {"pretend-float", &flag_pretend_float
, 1,
914 "Pretend that host and target use the same FP format"},
915 {"schedule-insns", &flag_schedule_insns
, 1,
916 "Reschedule instructions to avoid pipeline stalls"},
917 {"schedule-insns2", &flag_schedule_insns_after_reload
, 1,
918 "Run two passes of the instruction scheduler"},
919 {"sched-interblock",&flag_schedule_interblock
, 1,
920 "Enable scheduling across basic blocks" },
921 {"sched-spec",&flag_schedule_speculative
, 1,
922 "Allow speculative motion of non-loads" },
923 {"sched-spec-load",&flag_schedule_speculative_load
, 1,
924 "Allow speculative motion of some loads" },
925 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous
, 1,
926 "Allow speculative motion of more loads" },
927 {"branch-count-reg",&flag_branch_on_count_reg
, 1,
928 "Replace add,compare,branch with branch on count reg"},
929 {"pic", &flag_pic
, 1,
930 "Generate position independent code, if possible"},
931 {"PIC", &flag_pic
, 2, ""},
932 {"exceptions", &flag_exceptions
, 1,
933 "Enable exception handling" },
934 {"new-exceptions", &flag_new_exceptions
, 1,
935 "Use the new model for exception handling" },
936 {"sjlj-exceptions", &exceptions_via_longjmp
, 1,
937 "Use setjmp/longjmp to handle exceptions" },
938 {"asynchronous-exceptions", &asynchronous_exceptions
, 1,
939 "Support asynchronous exceptions" },
940 {"profile-arcs", &profile_arc_flag
, 1,
941 "Insert arc based program profiling code" },
942 {"test-coverage", &flag_test_coverage
, 1,
943 "Create data files needed by gcov" },
944 {"branch-probabilities", &flag_branch_probabilities
, 1,
945 "Use profiling information for branch probabilities" },
946 {"fast-math", &flag_fast_math
, 1,
947 "Improve FP speed by violating ANSI & IEEE rules" },
948 {"common", &flag_no_common
, 0,
949 "Do not put unitialised globals in the common section" },
950 {"inhibit-size-directive", &flag_inhibit_size_directive
, 1,
951 "Do not generate .size directives" },
952 {"function-sections", &flag_function_sections
, 1,
953 "place each function into its own section" },
954 {"data-sections", &flag_data_sections
, 1,
955 "place data items into their own section" },
956 {"verbose-asm", &flag_verbose_asm
, 1,
957 "Add extra commentry to assembler output"},
958 {"gnu-linker", &flag_gnu_linker
, 1,
959 "Output GNU ld formatted global initialisers"},
960 {"regmove", &flag_regmove
, 1,
961 "Enables a register move optimisation"},
962 {"optimize-register-move", &flag_regmove
, 1,
963 "Do the full regmove optimization pass"},
964 {"pack-struct", &flag_pack_struct
, 1,
965 "Pack structure members together without holes" },
966 {"stack-check", &flag_stack_check
, 1,
967 "Insert stack checking code into the program" },
968 {"argument-alias", &flag_argument_noalias
, 0,
969 "Specify that arguments may alias each other & globals"},
970 {"argument-noalias", &flag_argument_noalias
, 1,
971 "Assume arguments may alias globals but not each other"},
972 {"argument-noalias-global", &flag_argument_noalias
, 2,
973 "Assume arguments do not alias each other or globals" },
974 {"strict-aliasing", &flag_strict_aliasing
, 1,
975 "Assume strict aliasing rules apply" },
976 {"align-loops", &align_loops
, 0,
977 "Align the start of loops" },
978 {"align-jumps", &align_jumps
, 0,
979 "Align labels which are only reached by jumping" },
980 {"align-labels", &align_labels
, 0,
981 "Align all labels" },
982 {"align-functions", &align_functions
, 0,
983 "Align the start of functions" },
984 {"check-memory-usage", &flag_check_memory_usage
, 1,
985 "Generate code to check every memory access" },
986 {"prefix-function-name", &flag_prefix_function_name
, 1,
987 "Add a prefix to all function names" },
988 {"dump-unnumbered", &flag_dump_unnumbered
, 1,
989 "Suppress output of instruction numbers and line number notes in debugging dumps"},
990 {"instrument-functions", &flag_instrument_function_entry_exit
, 1,
991 "Instrument function entry/exit with profiling calls"},
992 {"leading-underscore", &flag_leading_underscore
, 1,
993 "External symbols have a leading underscore" },
994 {"ident", &flag_no_ident
, 0,
995 "Process #ident directives"},
996 { "peephole2", &flag_peephole2
, 1,
997 "Enables an rtl peephole pass run before sched2" }
1000 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
1002 /* Table of language-specific options. */
1004 static struct lang_opt
1006 const char * option
;
1007 const char * description
;
1009 documented_lang_options
[] =
1011 /* In order not to overload the --help output, the convention
1012 used here is to only describe those options which are not
1013 enabled by default. */
1015 { "-ansi", "Compile just for ANSI C" },
1016 { "-fallow-single-precision",
1017 "Do not promote floats to double if using -traditional" },
1018 { "-std= ", "Determine language standard"},
1020 { "-fsigned-bitfields", "" },
1021 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1022 { "-fno-signed-bitfields", "" },
1023 { "-fno-unsigned-bitfields","" },
1024 { "-fsigned-char", "Make 'char' be signed by default"},
1025 { "-funsigned-char", "Make 'char' be unsigned by default"},
1026 { "-fno-signed-char", "" },
1027 { "-fno-unsigned-char", "" },
1029 { "-ftraditional", "" },
1030 { "-traditional", "Attempt to support traditional K&R style C"},
1031 { "-fnotraditional", "" },
1032 { "-fno-traditional", "" },
1035 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1036 { "-fbuiltin", "" },
1037 { "-fno-builtin", "Do not recognise any built in functions" },
1038 { "-fhosted", "Assume normal C execution environment" },
1039 { "-fno-hosted", "" },
1041 "Assume that standard libraries & main might not exist" },
1042 { "-fno-freestanding", "" },
1043 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1044 { "-fno-cond-mismatch", "" },
1045 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1046 { "-fno-dollars-in-identifiers", "" },
1047 { "-fpreprocessed", "" },
1048 { "-fno-preprocessed", "" },
1049 { "-fshort-double", "Use the same size for double as for float" },
1050 { "-fno-short-double", "" },
1051 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1052 { "-fno-short-enums", "" },
1054 { "-Wall", "Enable most warning messages" },
1055 { "-Wbad-function-cast",
1056 "Warn about casting functions to incompatible types" },
1057 { "-Wno-bad-function-cast", "" },
1058 { "-Wmissing-noreturn",
1059 "Warn about functions which might be candidates for attribute noreturn" },
1060 { "-Wno-missing-noreturn", "" },
1061 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1062 { "-Wno-cast-qual", "" },
1063 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1064 { "-Wno-char-subscripts", "" },
1065 { "-Wcomment", "Warn if nested comments are detected" },
1066 { "-Wno-comment", "" },
1067 { "-Wcomments", "Warn if nested comments are detected" },
1068 { "-Wno-comments", "" },
1069 { "-Wconversion", "Warn about possibly confusing type conversions" },
1070 { "-Wno-conversion", "" },
1071 { "-Wformat", "Warn about printf format anomalies" },
1072 { "-Wno-format", "" },
1073 { "-Wimplicit-function-declaration",
1074 "Warn about implicit function declarations" },
1075 { "-Wno-implicit-function-declaration", "" },
1076 { "-Werror-implicit-function-declaration", "" },
1077 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1078 { "-Wno-implicit-int", "" },
1079 { "-Wimplicit", "" },
1080 { "-Wno-implicit", "" },
1081 { "-Wimport", "Warn about the use of the #import directive" },
1082 { "-Wno-import", "" },
1083 { "-Wlong-long","" },
1084 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1085 { "-Wmain", "Warn about suspicious declarations of main" },
1086 { "-Wno-main", "" },
1087 { "-Wmissing-braces",
1088 "Warn about possibly missing braces around initialisers" },
1089 { "-Wno-missing-braces", "" },
1090 { "-Wmissing-declarations",
1091 "Warn about global funcs without previous declarations"},
1092 { "-Wno-missing-declarations", "" },
1093 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1094 { "-Wno-missing-prototypes", "" },
1095 { "-Wmultichar", "Warn about use of multicharacter literals"},
1096 { "-Wno-multichar", "" },
1097 { "-Wnested-externs", "Warn about externs not at file scope level" },
1098 { "-Wno-nested-externs", "" },
1099 { "-Wparentheses", "Warn about possible missing parentheses" },
1100 { "-Wno-parentheses", "" },
1101 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1102 { "-Wno-pointer-arith", "" },
1103 { "-Wredundant-decls",
1104 "Warn about multiple declarations of the same object" },
1105 { "-Wno-redundant-decls", "" },
1106 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1107 { "-Wno-sign-compare", "" },
1108 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1109 { "-Wno-unknown-pragmas", "" },
1110 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1111 { "-Wno-strict-prototypes", "" },
1112 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1113 { "-Wno-traditional", "" },
1114 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1115 { "-Wno-trigraphs", "" },
1117 { "-Wno-undef", "" },
1118 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1119 { "-Wno-write-strings", "" },
1121 /* These are for languages with USE_CPPLIB. */
1122 /* These options are already documented in cpplib.c */
1128 { "-MD", "Print dependencies to FILE.d" },
1129 { "-MMD", "Print dependencies to FILE.d" },
1130 { "-M", "Print dependencies to stdout" },
1131 { "-MM", "Print dependencies to stdout" },
1132 #endif /* USE_CPPLIB */
1135 { "-idirafter", "" },
1140 { "-iwithprefix", "" },
1141 { "-iwithprefixbefore", "" },
1143 { "-lang-c89", "" },
1144 { "-lang-c++", "" },
1146 { "-nostdinc", "" },
1147 { "-nostdinc++", "" },
1148 { "-trigraphs", "" },
1151 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1153 /* These are for obj c. */
1154 DEFINE_LANG_NAME ("Objective C")
1156 { "-lang-objc", "" },
1157 { "-gen-decls", "Dump decls to a .decl file" },
1158 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1159 { "-fno-gnu-runtime", "" },
1160 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1161 { "-fno-next-runtime", "" },
1162 { "-Wselector", "Warn if a selector has multiple methods" },
1163 { "-Wno-selector", "" },
1164 { "-Wprotocol", "" },
1165 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1166 { "-print-objc-runtime-info",
1167 "Generate C header of platform specific features" },
1169 #include "options.h"
1173 /* Here is a table, controlled by the tm.h file, listing each -m switch
1174 and which bits in `target_switches' it should set or clear.
1175 If VALUE is positive, it is bits to set.
1176 If VALUE is negative, -VALUE is bits to clear.
1177 (The sign bit is not used so there is no confusion.) */
1183 const char * description
;
1185 target_switches
[] = TARGET_SWITCHES
;
1187 /* This table is similar, but allows the switch to have a value. */
1189 #ifdef TARGET_OPTIONS
1192 const char * prefix
;
1193 const char ** variable
;
1194 const char * description
;
1196 target_options
[] = TARGET_OPTIONS
;
1199 /* Options controlling warnings */
1201 /* Don't print warning messages. -w. */
1203 int inhibit_warnings
= 0;
1205 /* Print various extra warnings. -W. */
1207 int extra_warnings
= 0;
1209 /* Treat warnings as errors. -Werror. */
1211 int warnings_are_errors
= 0;
1213 /* Nonzero to warn about unused local variables. */
1217 /* Nonzero to warn about code which is never reached. */
1219 int warn_notreached
;
1221 /* Nonzero to warn about variables used before they are initialized. */
1223 int warn_uninitialized
;
1225 /* Nonzero means warn about all declarations which shadow others. */
1229 /* Warn if a switch on an enum fails to have a case for every enum value. */
1233 /* Nonzero means warn about function definitions that default the return type
1234 or that use a null return and have a return-type other than void. */
1236 int warn_return_type
;
1238 /* Nonzero means warn about pointer casts that increase the required
1239 alignment of the target type (and might therefore lead to a crash
1240 due to a misaligned access). */
1242 int warn_cast_align
;
1244 /* Nonzero means warn about any identifiers that match in the first N
1245 characters. The value N is in `id_clash_len'. */
1248 unsigned id_clash_len
;
1250 /* Nonzero means warn about any objects definitions whose size is larger
1251 than N bytes. Also want about function definitions whose returned
1252 values are larger than N bytes. The value N is in `larger_than_size'. */
1254 int warn_larger_than
;
1255 unsigned larger_than_size
;
1257 /* Nonzero means warn if inline function is too large. */
1261 /* Warn if a function returns an aggregate,
1262 since there are often incompatible calling conventions for doing this. */
1264 int warn_aggregate_return
;
1266 /* Likewise for -W. */
1268 lang_independent_options W_options
[] =
1270 {"unused", &warn_unused
, 1, "Warn when a variable is unused" },
1271 {"error", &warnings_are_errors
, 1, ""},
1272 {"shadow", &warn_shadow
, 1, "Warn when one local variable shadows another" },
1273 {"switch", &warn_switch
, 1,
1274 "Warn about enumerated switches missing a specific case" },
1275 {"aggregate-return", &warn_aggregate_return
, 1,
1276 "Warn about returning structures, unions or arrays" },
1277 {"cast-align", &warn_cast_align
, 1,
1278 "Warn about pointer casts which increase alignment" },
1279 {"unreachable-code", &warn_notreached
, 1,
1280 "Warn about code that will never be executed" },
1281 {"uninitialized", &warn_uninitialized
, 1,
1282 "Warn about unitialized automatic variables"},
1283 {"inline", &warn_inline
, 1,
1284 "Warn when an inlined function cannot be inlined"}
1287 /* Output files for assembler code (real compiler output)
1288 and debugging dumps. */
1291 FILE *aux_info_file
;
1292 FILE *rtl_dump_file
= NULL
;
1294 /* Decode the string P as an integral parameter.
1295 If the string is indeed an integer return its numeric value else
1296 issue an Invalid Option error for the option PNAME and return DEFVAL.
1297 If PNAME is zero just return DEFVAL, do not call error. */
1300 read_integral_parameter (p
, pname
, defval
)
1305 const char *endp
= p
;
1309 if (*endp
>= '0' && *endp
<= '9')
1318 error ("Invalid option `%s'", pname
);
1326 /* Time accumulators, to count the total time spent in various passes. */
1330 int integration_time
;
1336 int branch_prob_time
;
1341 int local_alloc_time
;
1342 int global_alloc_time
;
1348 int shorten_branch_time
;
1354 /* Return time used so far, in microseconds. */
1364 #else /* not BeOS */
1365 #if defined (_WIN32) && !defined (__CYGWIN__)
1369 return (clock() * 1000);
1370 #else /* not _WIN32 */
1376 tick
= 1000000 / sysconf(_SC_CLK_TCK
);
1378 return (tms
.tms_utime
+ tms
.tms_stime
) * tick
;
1384 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1385 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1388 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1390 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1394 return (tms
.tms_utime
+ tms
.tms_stime
) * (1000000 / TICKS_PER_SECOND
);
1399 struct rusage rusage
;
1400 getrusage (0, &rusage
);
1401 return (rusage
.ru_utime
.tv_sec
* 1000000 + rusage
.ru_utime
.tv_usec
1402 + rusage
.ru_stime
.tv_sec
* 1000000 + rusage
.ru_stime
.tv_usec
);
1409 int proc_system_time
;
1410 int child_user_time
;
1411 int child_system_time
;
1413 times ((void *) &vms_times
);
1414 return (vms_times
.proc_user_time
+ vms_times
.proc_system_time
) * 10000;
1418 #endif /* _SC_CLK_TCK */
1420 #endif /* __BEOS__ */
1423 #define TIMEVAR(VAR, BODY) \
1424 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1427 print_time (str
, total
)
1432 "time in %s: %d.%06d\n",
1433 str
, total
/ 1000000, total
% 1000000);
1436 /* Count an error or warning. Return 1 if the message should be printed. */
1439 count_error (warningp
)
1442 if (warningp
&& inhibit_warnings
)
1445 if (warningp
&& !warnings_are_errors
)
1449 static int warning_message
= 0;
1451 if (warningp
&& !warning_message
)
1453 notice ("%s: warnings being treated as errors\n", progname
);
1454 warning_message
= 1;
1462 /* Print a fatal error message. NAME is the text.
1463 Also include a system error message based on `errno'. */
1466 pfatal_with_name (name
)
1469 fprintf (stderr
, "%s: ", progname
);
1471 exit (FATAL_EXIT_CODE
);
1475 fatal_io_error (name
)
1478 notice ("%s: %s: I/O error\n", progname
, name
);
1479 exit (FATAL_EXIT_CODE
);
1482 /* This is the default decl_printable_name function. */
1485 decl_name (decl
, verbosity
)
1487 int verbosity ATTRIBUTE_UNUSED
;
1489 return IDENTIFIER_POINTER (DECL_NAME (decl
));
1492 static int need_error_newline
;
1494 /* Function of last error message;
1495 more generally, function such that if next error message is in it
1496 then we don't have to mention the function name. */
1497 static tree last_error_function
= NULL
;
1499 /* Used to detect when input_file_stack has changed since last described. */
1500 static int last_error_tick
;
1502 /* Called when the start of a function definition is parsed,
1503 this function prints on stderr the name of the function. */
1506 announce_function (decl
)
1511 if (rtl_dump_and_exit
)
1512 fprintf (stderr
, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl
)));
1514 fprintf (stderr
, " %s", (*decl_printable_name
) (decl
, 2));
1516 need_error_newline
= 1;
1517 last_error_function
= current_function_decl
;
1521 /* The default function to print out name of current function that caused
1525 default_print_error_function (file
)
1528 if (last_error_function
!= current_function_decl
)
1531 fprintf (stderr
, "%s: ", file
);
1533 if (current_function_decl
== NULL
)
1534 notice ("At top level:\n");
1536 notice ((TREE_CODE (TREE_TYPE (current_function_decl
)) == METHOD_TYPE
1537 ? "In method `%s':\n"
1538 : "In function `%s':\n"),
1539 (*decl_printable_name
) (current_function_decl
, 2));
1541 last_error_function
= current_function_decl
;
1545 /* Called by report_error_function to print out function name.
1546 * Default may be overridden by language front-ends. */
1548 void (*print_error_function
) PROTO((const char *)) =
1549 default_print_error_function
;
1551 /* Prints out, if necessary, the name of the current function
1552 that caused an error. Called from all error and warning functions.
1553 We ignore the FILE parameter, as it cannot be relied upon. */
1556 report_error_function (file
)
1557 const char *file ATTRIBUTE_UNUSED
;
1559 struct file_stack
*p
;
1561 if (need_error_newline
)
1563 fprintf (stderr
, "\n");
1564 need_error_newline
= 0;
1567 if (input_file_stack
&& input_file_stack
->next
!= 0
1568 && input_file_stack_tick
!= last_error_tick
)
1570 for (p
= input_file_stack
->next
; p
; p
= p
->next
)
1571 notice ((p
== input_file_stack
->next
1572 ? "In file included from %s:%d"
1573 : ",\n from %s:%d"),
1575 fprintf (stderr
, ":\n");
1576 last_error_tick
= input_file_stack_tick
;
1579 (*print_error_function
) (input_filename
);
1582 /* Print a message. */
1585 vnotice (file
, msgid
, ap
)
1590 vfprintf (file
, _(msgid
), ap
);
1594 notice
VPROTO((const char *msgid
, ...))
1596 #ifndef ANSI_PROTOTYPES
1601 VA_START (ap
, msgid
);
1603 #ifndef ANSI_PROTOTYPES
1604 msgid
= va_arg (ap
, char *);
1607 vnotice (stderr
, msgid
, ap
);
1612 fnotice
VPROTO((FILE *file
, const char *msgid
, ...))
1614 #ifndef ANSI_PROTOTYPES
1620 VA_START (ap
, msgid
);
1622 #ifndef ANSI_PROTOTYPES
1623 file
= va_arg (ap
, FILE *);
1624 msgid
= va_arg (ap
, const char *);
1627 vnotice (file
, msgid
, ap
);
1631 /* Report FILE and LINE (or program name), and optionally just WARN. */
1634 report_file_and_line (file
, line
, warn
)
1640 fprintf (stderr
, "%s:%d: ", file
, line
);
1642 fprintf (stderr
, "%s: ", progname
);
1645 notice ("warning: ");
1648 /* Print a message. */
1651 vmessage (prefix
, msgid
, ap
)
1657 fprintf (stderr
, "%s: ", prefix
);
1659 vfprintf (stderr
, msgid
, ap
);
1662 /* Print a message relevant to line LINE of file FILE. */
1665 v_message_with_file_and_line (file
, line
, warn
, msgid
, ap
)
1672 report_file_and_line (file
, line
, warn
);
1673 vnotice (stderr
, msgid
, ap
);
1674 fputc ('\n', stderr
);
1677 /* Print a message relevant to the given DECL. */
1680 v_message_with_decl (decl
, warn
, msgid
, ap
)
1688 report_file_and_line (DECL_SOURCE_FILE (decl
),
1689 DECL_SOURCE_LINE (decl
), warn
);
1691 /* Do magic to get around lack of varargs support for insertion
1692 of arguments into existing list. We know that the decl is first;
1693 we ass_u_me that it will be printed with "%s". */
1695 for (p
= _(msgid
); *p
; ++p
)
1699 if (*(p
+ 1) == '%')
1701 else if (*(p
+ 1) != 's')
1708 if (p
> _(msgid
)) /* Print the left-hand substring. */
1710 char fmt
[sizeof "%.255s"];
1711 long width
= p
- _(msgid
);
1713 if (width
> 255L) width
= 255L; /* arbitrary */
1714 sprintf (fmt
, "%%.%lds", width
);
1715 fprintf (stderr
, fmt
, _(msgid
));
1718 if (*p
== '%') /* Print the name. */
1720 const char *n
= (DECL_NAME (decl
)
1721 ? (*decl_printable_name
) (decl
, 2)
1727 if (ISALPHA (*(p
- 1) & 0xFF))
1732 if (*p
) /* Print the rest of the message. */
1733 vmessage ((char *)NULL
, p
, ap
);
1735 fputc ('\n', stderr
);
1738 /* Figure file and line of the given INSN. */
1741 file_and_line_for_asm (insn
, pfile
, pline
)
1746 rtx body
= PATTERN (insn
);
1749 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1750 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
1751 asmop
= SET_SRC (body
);
1752 else if (GET_CODE (body
) == ASM_OPERANDS
)
1754 else if (GET_CODE (body
) == PARALLEL
1755 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
)
1756 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
1757 else if (GET_CODE (body
) == PARALLEL
1758 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
1759 asmop
= XVECEXP (body
, 0, 0);
1765 *pfile
= ASM_OPERANDS_SOURCE_FILE (asmop
);
1766 *pline
= ASM_OPERANDS_SOURCE_LINE (asmop
);
1770 *pfile
= input_filename
;
1775 /* Report an error at line LINE of file FILE. */
1778 v_error_with_file_and_line (file
, line
, msgid
, ap
)
1785 report_error_function (file
);
1786 v_message_with_file_and_line (file
, line
, 0, msgid
, ap
);
1790 error_with_file_and_line
VPROTO((const char *file
, int line
,
1791 const char *msgid
, ...))
1793 #ifndef ANSI_PROTOTYPES
1800 VA_START (ap
, msgid
);
1802 #ifndef ANSI_PROTOTYPES
1803 file
= va_arg (ap
, const char *);
1804 line
= va_arg (ap
, int);
1805 msgid
= va_arg (ap
, const char *);
1808 v_error_with_file_and_line (file
, line
, msgid
, ap
);
1812 /* Report an error at the declaration DECL.
1813 MSGID is a format string which uses %s to substitute the declaration
1814 name; subsequent substitutions are a la printf. */
1817 v_error_with_decl (decl
, msgid
, ap
)
1823 report_error_function (DECL_SOURCE_FILE (decl
));
1824 v_message_with_decl (decl
, 0, msgid
, ap
);
1828 error_with_decl
VPROTO((tree decl
, const char *msgid
, ...))
1830 #ifndef ANSI_PROTOTYPES
1836 VA_START (ap
, msgid
);
1838 #ifndef ANSI_PROTOTYPES
1839 decl
= va_arg (ap
, tree
);
1840 msgid
= va_arg (ap
, const char *);
1843 v_error_with_decl (decl
, msgid
, ap
);
1847 /* Report an error at the line number of the insn INSN.
1848 This is used only when INSN is an `asm' with operands,
1849 and each ASM_OPERANDS records its own source file and line. */
1852 v_error_for_asm (insn
, msgid
, ap
)
1861 file_and_line_for_asm (insn
, &file
, &line
);
1862 report_error_function (file
);
1863 v_message_with_file_and_line (file
, line
, 0, msgid
, ap
);
1867 error_for_asm
VPROTO((rtx insn
, const char *msgid
, ...))
1869 #ifndef ANSI_PROTOTYPES
1875 VA_START (ap
, msgid
);
1877 #ifndef ANSI_PROTOTYPES
1878 insn
= va_arg (ap
, rtx
);
1879 msgid
= va_arg (ap
, const char *);
1882 v_error_for_asm (insn
, msgid
, ap
);
1886 /* Report an error at the current line number. */
1893 v_error_with_file_and_line (input_filename
, lineno
, msgid
, ap
);
1897 error
VPROTO((const char *msgid
, ...))
1899 #ifndef ANSI_PROTOTYPES
1904 VA_START (ap
, msgid
);
1906 #ifndef ANSI_PROTOTYPES
1907 msgid
= va_arg (ap
, const char *);
1914 /* Report a fatal error at the current line number. */
1922 exit (FATAL_EXIT_CODE
);
1926 fatal
VPROTO((const char *msgid
, ...))
1928 #ifndef ANSI_PROTOTYPES
1933 VA_START (ap
, msgid
);
1935 #ifndef ANSI_PROTOTYPES
1936 msgid
= va_arg (ap
, const char *);
1944 _fatal_insn (msgid
, insn
, file
, line
, function
)
1949 const char *function
;
1953 fancy_abort (file
, line
, function
);
1957 _fatal_insn_not_found (insn
, file
, line
, function
)
1961 const char *function
;
1963 if (INSN_CODE (insn
) < 0)
1964 _fatal_insn ("Unrecognizable insn:", insn
, file
, line
, function
);
1966 _fatal_insn ("Insn does not satisfy its constraints:",
1967 insn
, file
, line
, function
);
1970 /* Report a warning at line LINE of file FILE. */
1973 v_warning_with_file_and_line (file
, line
, msgid
, ap
)
1979 if (count_error (1))
1981 report_error_function (file
);
1982 v_message_with_file_and_line (file
, line
, 1, msgid
, ap
);
1987 warning_with_file_and_line
VPROTO((const char *file
, int line
,
1988 const char *msgid
, ...))
1990 #ifndef ANSI_PROTOTYPES
1997 VA_START (ap
, msgid
);
1999 #ifndef ANSI_PROTOTYPES
2000 file
= va_arg (ap
, const char *);
2001 line
= va_arg (ap
, int);
2002 msgid
= va_arg (ap
, const char *);
2005 v_warning_with_file_and_line (file
, line
, msgid
, ap
);
2009 /* Report a warning at the declaration DECL.
2010 MSGID is a format string which uses %s to substitute the declaration
2011 name; subsequent substitutions are a la printf. */
2014 v_warning_with_decl (decl
, msgid
, ap
)
2019 if (count_error (1))
2021 report_error_function (DECL_SOURCE_FILE (decl
));
2022 v_message_with_decl (decl
, 1, msgid
, ap
);
2027 warning_with_decl
VPROTO((tree decl
, const char *msgid
, ...))
2029 #ifndef ANSI_PROTOTYPES
2035 VA_START (ap
, msgid
);
2037 #ifndef ANSI_PROTOTYPES
2038 decl
= va_arg (ap
, tree
);
2039 msgid
= va_arg (ap
, const char *);
2042 v_warning_with_decl (decl
, msgid
, ap
);
2046 /* Report a warning at the line number of the insn INSN.
2047 This is used only when INSN is an `asm' with operands,
2048 and each ASM_OPERANDS records its own source file and line. */
2051 v_warning_for_asm (insn
, msgid
, ap
)
2056 if (count_error (1))
2061 file_and_line_for_asm (insn
, &file
, &line
);
2062 report_error_function (file
);
2063 v_message_with_file_and_line (file
, line
, 1, msgid
, ap
);
2068 warning_for_asm
VPROTO((rtx insn
, const char *msgid
, ...))
2070 #ifndef ANSI_PROTOTYPES
2076 VA_START (ap
, msgid
);
2078 #ifndef ANSI_PROTOTYPES
2079 insn
= va_arg (ap
, rtx
);
2080 msgid
= va_arg (ap
, const char *);
2083 v_warning_for_asm (insn
, msgid
, ap
);
2087 /* Report a warning at the current line number. */
2090 vwarning (msgid
, ap
)
2094 v_warning_with_file_and_line (input_filename
, lineno
, msgid
, ap
);
2098 warning
VPROTO((const char *msgid
, ...))
2100 #ifndef ANSI_PROTOTYPES
2105 VA_START (ap
, msgid
);
2107 #ifndef ANSI_PROTOTYPES
2108 msgid
= va_arg (ap
, const char *);
2111 vwarning (msgid
, ap
);
2115 /* These functions issue either warnings or errors depending on
2116 -pedantic-errors. */
2119 vpedwarn (msgid
, ap
)
2123 if (flag_pedantic_errors
)
2126 vwarning (msgid
, ap
);
2130 pedwarn
VPROTO((const char *msgid
, ...))
2132 #ifndef ANSI_PROTOTYPES
2137 VA_START (ap
, msgid
);
2139 #ifndef ANSI_PROTOTYPES
2140 msgid
= va_arg (ap
, const char *);
2143 vpedwarn (msgid
, ap
);
2148 v_pedwarn_with_decl (decl
, msgid
, ap
)
2153 /* We don't want -pedantic-errors to cause the compilation to fail from
2154 "errors" in system header files. Sometimes fixincludes can't fix what's
2155 broken (eg: unsigned char bitfields - fixing it may change the alignment
2156 which will cause programs to mysteriously fail because the C library
2157 or kernel uses the original layout). There's no point in issuing a
2158 warning either, it's just unnecessary noise. */
2160 if (! DECL_IN_SYSTEM_HEADER (decl
))
2162 if (flag_pedantic_errors
)
2163 v_error_with_decl (decl
, msgid
, ap
);
2165 v_warning_with_decl (decl
, msgid
, ap
);
2170 pedwarn_with_decl
VPROTO((tree decl
, const char *msgid
, ...))
2172 #ifndef ANSI_PROTOTYPES
2178 VA_START (ap
, msgid
);
2180 #ifndef ANSI_PROTOTYPES
2181 decl
= va_arg (ap
, tree
);
2182 msgid
= va_arg (ap
, const char *);
2185 v_pedwarn_with_decl (decl
, msgid
, ap
);
2190 v_pedwarn_with_file_and_line (file
, line
, msgid
, ap
)
2196 if (flag_pedantic_errors
)
2197 v_error_with_file_and_line (file
, line
, msgid
, ap
);
2199 v_warning_with_file_and_line (file
, line
, msgid
, ap
);
2203 pedwarn_with_file_and_line
VPROTO((const char *file
, int line
,
2204 const char *msgid
, ...))
2206 #ifndef ANSI_PROTOTYPES
2213 VA_START (ap
, msgid
);
2215 #ifndef ANSI_PROTOTYPES
2216 file
= va_arg (ap
, const char *);
2217 line
= va_arg (ap
, int);
2218 msgid
= va_arg (ap
, const char *);
2221 v_pedwarn_with_file_and_line (file
, line
, msgid
, ap
);
2225 /* Apologize for not implementing some feature. */
2234 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
2236 fprintf (stderr
, "%s: ", progname
);
2237 notice ("sorry, not implemented: ");
2238 vnotice (stderr
, msgid
, ap
);
2239 fputc ('\n', stderr
);
2243 sorry
VPROTO((const char *msgid
, ...))
2245 #ifndef ANSI_PROTOTYPES
2250 VA_START (ap
, msgid
);
2252 #ifndef ANSI_PROTOTYPES
2253 msgid
= va_arg (ap
, const char *);
2261 /* This calls abort and is used to avoid problems when abort if a macro.
2262 It is used when we need to pass the address of abort. */
2270 /* When `malloc.c' is compiled with `rcheck' defined,
2271 it calls this function to report clobberage. */
2275 const char * s ATTRIBUTE_UNUSED
;
2280 /* Same as `malloc' but report error if no memory available. */
2291 value
= (PTR
) malloc (size
);
2293 fatal ("virtual memory exhausted");
2297 /* Same as `calloc' but report error if no memory available. */
2300 xcalloc (size1
, size2
)
2301 size_t size1
, size2
;
2305 if (size1
== 0 || size2
== 0)
2308 value
= (PTR
) calloc (size1
, size2
);
2310 fatal ("virtual memory exhausted");
2315 /* Same as `realloc' but report error if no memory available.
2316 Also handle null PTR even if the vendor realloc gets it wrong. */
2319 xrealloc (ptr
, size
)
2323 register PTR result
;
2328 result
= (ptr
? (PTR
) realloc (ptr
, size
) : (PTR
) malloc (size
));
2331 fatal ("virtual memory exhausted");
2336 /* Same as `strdup' but report error if no memory available. */
2340 register const char *s
;
2342 register char *result
= (char *) malloc (strlen (s
) + 1);
2345 fatal ("virtual memory exhausted");
2350 /* Return the logarithm of X, base 2, considering X unsigned,
2351 if X is a power of 2. Otherwise, returns -1.
2353 This should be used via the `exact_log2' macro. */
2357 register unsigned HOST_WIDE_INT x
;
2359 register int log
= 0;
2360 /* Test for 0 or a power of 2. */
2361 if (x
== 0 || x
!= (x
& -x
))
2363 while ((x
>>= 1) != 0)
2368 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2369 If X is 0, return -1.
2371 This should be used via the floor_log2 macro. */
2375 register unsigned HOST_WIDE_INT x
;
2377 register int log
= -1;
2384 static int float_handler_set
;
2386 jmp_buf float_handler
;
2388 /* Signals actually come here. */
2391 float_signal (signo
)
2392 /* If this is missing, some compilers complain. */
2393 int signo ATTRIBUTE_UNUSED
;
2395 if (float_handled
== 0)
2397 #if defined (USG) || defined (hpux)
2398 signal (SIGFPE
, float_signal
); /* re-enable the signal catcher */
2401 signal (SIGFPE
, float_signal
);
2402 longjmp (float_handler
, 1);
2405 /* Specify where to longjmp to when a floating arithmetic error happens.
2406 If HANDLER is 0, it means don't handle the errors any more. */
2409 set_float_handler (handler
)
2412 float_handled
= (handler
!= 0);
2414 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
2416 if (float_handled
&& ! float_handler_set
)
2418 signal (SIGFPE
, float_signal
);
2419 float_handler_set
= 1;
2423 /* This is a wrapper function for code which might elicit an
2424 arithmetic exception. That code should be passed in as a function
2425 pointer FN, and one argument DATA. DATA is usually a struct which
2426 contains the real input and output for function FN. This function
2427 returns 0 (failure) if longjmp was called (i.e. an exception
2428 occured.) It returns 1 (success) otherwise. */
2431 do_float_handler (fn
, data
)
2432 void (*fn
) PROTO ((PTR
));
2439 /* We got here via longjmp() caused by an exception in function fn() */
2440 set_float_handler (NULL
);
2444 set_float_handler (buf
);
2446 set_float_handler (NULL
);
2450 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2451 error happens, pushing the previous specification into OLD_HANDLER.
2452 Return an indication of whether there was a previous handler in effect. */
2455 push_float_handler (handler
, old_handler
)
2456 jmp_buf handler
, old_handler
;
2458 int was_handled
= float_handled
;
2462 memcpy ((char *) old_handler
, (char *) float_handler
,
2463 sizeof (float_handler
));
2465 memcpy ((char *) float_handler
, (char *) handler
, sizeof (float_handler
));
2469 /* Restore the previous specification of whether and where to longjmp to
2470 when a floating arithmetic error happens. */
2473 pop_float_handler (handled
, handler
)
2477 float_handled
= handled
;
2479 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
2482 /* Handler for SIGPIPE. */
2486 /* If this is missing, some compilers complain. */
2487 int signo ATTRIBUTE_UNUSED
;
2489 fatal ("output pipe has been closed");
2492 /* Strip off a legitimate source ending from the input string NAME of
2493 length LEN. Rather than having to know the names used by all of
2494 our front ends, we strip off an ending of a period followed by
2495 up to five characters. (Java uses ".class".) */
2498 strip_off_ending (name
, len
)
2503 for (i
= 2; i
< 6 && len
> i
; i
++)
2505 if (name
[len
- i
] == '.')
2507 name
[len
- i
] = '\0';
2513 /* Output a quoted string. */
2516 output_quoted_string (asm_file
, string
)
2520 #ifdef OUTPUT_QUOTED_STRING
2521 OUTPUT_QUOTED_STRING (asm_file
, string
);
2525 putc ('\"', asm_file
);
2526 while ((c
= *string
++) != 0)
2528 if (c
== '\"' || c
== '\\')
2529 putc ('\\', asm_file
);
2532 putc ('\"', asm_file
);
2536 /* Output a file name in the form wanted by System V. */
2539 output_file_directive (asm_file
, input_name
)
2541 const char *input_name
;
2543 int len
= strlen (input_name
);
2544 const char *na
= input_name
+ len
;
2546 /* NA gets INPUT_NAME sans directory names. */
2547 while (na
> input_name
)
2551 #ifdef DIR_SEPARATOR
2552 if (na
[-1] == DIR_SEPARATOR
)
2558 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2559 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file
, na
);
2561 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2562 ASM_OUTPUT_SOURCE_FILENAME (asm_file
, na
);
2564 fprintf (asm_file
, "\t.file\t");
2565 output_quoted_string (asm_file
, na
);
2566 fputc ('\n', asm_file
);
2571 #ifdef ASM_IDENTIFY_LANGUAGE
2572 /* Routine to build language identifier for object file. */
2574 output_lang_identify (asm_out_file
)
2577 int len
= strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2578 char *s
= (char *) alloca (len
);
2579 sprintf (s
, "__gnu_compiled_%s", lang_identify ());
2580 ASM_OUTPUT_LABEL (asm_out_file
, s
);
2584 /* Routine to open a dump file. */
2586 open_dump_file (suffix
, function_name
)
2588 const char *function_name
;
2595 dumpname
= (char *) xmalloc (strlen (dump_base_name
) + strlen (suffix
) + 1);
2597 if (rtl_dump_file
!= NULL
)
2598 fclose (rtl_dump_file
);
2600 strcpy (dumpname
, dump_base_name
);
2601 strcat (dumpname
, suffix
);
2603 rtl_dump_file
= fopen (dumpname
, "a");
2605 if (rtl_dump_file
== NULL
)
2606 pfatal_with_name (dumpname
);
2611 fprintf (rtl_dump_file
, "\n;; Function %s\n\n", function_name
);
2617 /* Routine to close a dump file. */
2619 close_dump_file (func
, insns
)
2620 void (*func
) PROTO ((FILE *, rtx
));
2627 func (rtl_dump_file
, insns
);
2629 fflush (rtl_dump_file
);
2630 fclose (rtl_dump_file
);
2632 rtl_dump_file
= NULL
;
2638 /* Routine to dump rtl into a file. */
2640 dump_rtl (suffix
, decl
, func
, insns
)
2643 void (*func
) PROTO ((FILE *, rtx
));
2646 open_dump_file (suffix
, decl_printable_name (decl
, 2));
2647 close_dump_file (func
, insns
);
2650 /* Routine to empty a dump file. */
2652 clean_dump_file (suffix
)
2657 dumpname
= (char *) xmalloc (strlen (dump_base_name
) + strlen (suffix
) + 1);
2659 strcpy (dumpname
, dump_base_name
);
2660 strcat (dumpname
, suffix
);
2662 rtl_dump_file
= fopen (dumpname
, "w");
2664 if (rtl_dump_file
== NULL
)
2665 pfatal_with_name (dumpname
);
2669 fclose (rtl_dump_file
);
2670 rtl_dump_file
= NULL
;
2675 /* Do any final processing required for the declarations in VEC, of
2676 which there are LEN. We write out inline functions and variables
2677 that have been deferred until this point, but which are required.
2678 Returns non-zero if anything was put out. */
2680 wrapup_global_declarations (vec
, len
)
2687 int output_something
= 0;
2689 for (i
= 0; i
< len
; i
++)
2693 /* We're not deferring this any longer. */
2694 DECL_DEFER_OUTPUT (decl
) = 0;
2696 if (TREE_CODE (decl
) == VAR_DECL
&& DECL_SIZE (decl
) == 0
2697 && incomplete_decl_finalize_hook
!= 0)
2698 (*incomplete_decl_finalize_hook
) (decl
);
2701 /* Now emit any global variables or functions that we have been
2702 putting off. We need to loop in case one of the things emitted
2703 here references another one which comes earlier in the list. */
2707 for (i
= 0; i
< len
; i
++)
2711 if (TREE_ASM_WRITTEN (decl
) || DECL_EXTERNAL (decl
))
2714 /* Don't write out static consts, unless we still need them.
2716 We also keep static consts if not optimizing (for debugging),
2717 unless the user specified -fno-keep-static-consts.
2718 ??? They might be better written into the debug information.
2719 This is possible when using DWARF.
2721 A language processor that wants static constants to be always
2722 written out (even if it is not used) is responsible for
2723 calling rest_of_decl_compilation itself. E.g. the C front-end
2724 calls rest_of_decl_compilation from finish_decl.
2725 One motivation for this is that is conventional in some
2726 environments to write things like:
2727 static const char rcsid[] = "... version string ...";
2728 intending to force the string to be in the executable.
2730 A language processor that would prefer to have unneeded
2731 static constants "optimized away" would just defer writing
2732 them out until here. E.g. C++ does this, because static
2733 constants are often defined in header files.
2735 ??? A tempting alternative (for both C and C++) would be
2736 to force a constant to be written if and only if it is
2737 defined in a main file, as opposed to an include file. */
2739 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
2740 && (! TREE_READONLY (decl
)
2741 || TREE_PUBLIC (decl
)
2742 || (!optimize
&& flag_keep_static_consts
)
2743 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
2746 rest_of_decl_compilation (decl
, NULL_PTR
, 1, 1);
2749 if (TREE_CODE (decl
) == FUNCTION_DECL
2750 && DECL_INITIAL (decl
) != 0
2751 && DECL_SAVED_INSNS (decl
) != 0
2752 && (flag_keep_inline_functions
2753 || (TREE_PUBLIC (decl
) && !DECL_COMDAT (decl
))
2754 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
2757 temporary_allocation ();
2758 output_inline_function (decl
);
2759 permanent_allocation (1);
2764 output_something
= 1;
2768 return output_something
;
2771 /* Issue appropriate warnings for the global declarations in VEC (of
2772 which there are LEN). Output debugging information for them. */
2774 check_global_declarations (vec
, len
)
2781 for (i
= 0; i
< len
; i
++)
2785 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
2786 && ! TREE_ASM_WRITTEN (decl
))
2787 /* Cancel the RTL for this decl so that, if debugging info
2788 output for global variables is still to come,
2789 this one will be omitted. */
2790 DECL_RTL (decl
) = NULL
;
2792 /* Warn about any function
2793 declared static but not defined.
2794 We don't warn about variables,
2795 because many programs have static variables
2796 that exist only to get some text into the object file. */
2797 if (TREE_CODE (decl
) == FUNCTION_DECL
2799 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
2800 && DECL_INITIAL (decl
) == 0
2801 && DECL_EXTERNAL (decl
)
2802 && ! DECL_ARTIFICIAL (decl
)
2803 && ! TREE_PUBLIC (decl
))
2805 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
2806 pedwarn_with_decl (decl
,
2807 "`%s' used but never defined");
2809 warning_with_decl (decl
,
2810 "`%s' declared `static' but never defined");
2811 /* This symbol is effectively an "extern" declaration now. */
2812 TREE_PUBLIC (decl
) = 1;
2813 assemble_external (decl
);
2816 /* Warn about static fns or vars defined but not used,
2817 but not about inline functions or static consts
2818 since defining those in header files is normal practice. */
2820 && ((TREE_CODE (decl
) == FUNCTION_DECL
&& ! DECL_INLINE (decl
))
2821 || (TREE_CODE (decl
) == VAR_DECL
&& ! TREE_READONLY (decl
)))
2822 && ! DECL_IN_SYSTEM_HEADER (decl
)
2823 && ! DECL_EXTERNAL (decl
)
2824 && ! TREE_PUBLIC (decl
)
2825 && ! TREE_USED (decl
)
2826 && (TREE_CODE (decl
) == FUNCTION_DECL
|| ! DECL_REGISTER (decl
))
2827 /* The TREE_USED bit for file-scope decls
2828 is kept in the identifier, to handle multiple
2829 external decls in different scopes. */
2830 && ! TREE_USED (DECL_NAME (decl
)))
2831 warning_with_decl (decl
, "`%s' defined but not used");
2833 #ifdef SDB_DEBUGGING_INFO
2834 /* The COFF linker can move initialized global vars to the end.
2835 And that can screw up the symbol ordering.
2836 By putting the symbols in that order to begin with,
2837 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2838 if (write_symbols
== SDB_DEBUG
&& TREE_CODE (decl
) == VAR_DECL
2839 && TREE_PUBLIC (decl
) && DECL_INITIAL (decl
)
2840 && ! DECL_EXTERNAL (decl
)
2841 && DECL_RTL (decl
) != 0)
2842 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
2844 /* Output COFF information for non-global
2845 file-scope initialized variables. */
2846 if (write_symbols
== SDB_DEBUG
2847 && TREE_CODE (decl
) == VAR_DECL
2848 && DECL_INITIAL (decl
)
2849 && ! DECL_EXTERNAL (decl
)
2850 && DECL_RTL (decl
) != 0
2851 && GET_CODE (DECL_RTL (decl
)) == MEM
)
2852 TIMEVAR (symout_time
, sdbout_toplevel_data (decl
));
2853 #endif /* SDB_DEBUGGING_INFO */
2854 #ifdef DWARF_DEBUGGING_INFO
2855 /* Output DWARF information for file-scope tentative data object
2856 declarations, file-scope (extern) function declarations (which
2857 had no corresponding body) and file-scope tagged type declarations
2858 and definitions which have not yet been forced out. */
2860 if (write_symbols
== DWARF_DEBUG
2861 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
2862 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 1));
2864 #ifdef DWARF2_DEBUGGING_INFO
2865 /* Output DWARF2 information for file-scope tentative data object
2866 declarations, file-scope (extern) function declarations (which
2867 had no corresponding body) and file-scope tagged type declarations
2868 and definitions which have not yet been forced out. */
2870 if (write_symbols
== DWARF2_DEBUG
2871 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
2872 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
2877 /* Compile an entire file of output from cpp, named NAME.
2878 Write a file of assembly output and various debugging dumps. */
2887 int name_specified
= name
!= 0;
2889 if (dump_base_name
== 0)
2890 dump_base_name
= name
? name
: "gccdump";
2894 integration_time
= 0;
2900 branch_prob_time
= 0;
2905 local_alloc_time
= 0;
2906 global_alloc_time
= 0;
2912 shorten_branch_time
= 0;
2918 /* Initialize data in various passes. */
2922 name
= init_parse (name
);
2923 init_emit_once (debug_info_level
== DINFO_LEVEL_NORMAL
2924 || debug_info_level
== DINFO_LEVEL_VERBOSE
2925 || flag_test_coverage
2926 || warn_notreached
);
2928 init_decl_processing ();
2935 /* The following initialization functions need to generate rtl, so
2936 provide a dummy function context for them. */
2937 init_dummy_function_start ();
2940 if (flag_caller_saves
)
2941 init_caller_save ();
2942 expand_dummy_function_end ();
2944 /* If auxiliary info generation is desired, open the output file.
2945 This goes in the same directory as the source file--unlike
2946 all the other output files. */
2947 if (flag_gen_aux_info
)
2949 aux_info_file
= fopen (aux_info_file_name
, "w");
2950 if (aux_info_file
== 0)
2951 pfatal_with_name (aux_info_file_name
);
2954 /* Clear the dump files. */
2956 clean_dump_file (".rtl");
2959 clean_dump_file (".jump");
2960 if (graph_dump_format
!= no_graph
)
2961 clean_graph_dump_file (dump_base_name
, ".jump");
2965 clean_dump_file (".addressof");
2966 if (graph_dump_format
!= no_graph
)
2967 clean_graph_dump_file (dump_base_name
, ".addressof");
2971 clean_dump_file (".cse");
2972 if (graph_dump_format
!= no_graph
)
2973 clean_graph_dump_file (dump_base_name
, ".cse");
2977 clean_dump_file (".loop");
2978 if (graph_dump_format
!= no_graph
)
2979 clean_graph_dump_file (dump_base_name
, ".loop");
2983 clean_dump_file (".cse2");
2984 if (graph_dump_format
!= no_graph
)
2985 clean_graph_dump_file (dump_base_name
, ".cse2");
2987 if (branch_prob_dump
)
2989 clean_dump_file (".bp");
2990 if (graph_dump_format
!= no_graph
)
2991 clean_graph_dump_file (dump_base_name
, ".bp");
2995 clean_dump_file (".flow");
2996 if (graph_dump_format
!= no_graph
)
2997 clean_graph_dump_file (dump_base_name
, ".flow");
3001 clean_dump_file (".combine");
3002 if (graph_dump_format
!= no_graph
)
3003 clean_graph_dump_file (dump_base_name
, ".combine");
3007 clean_dump_file (".regmove");
3008 if (graph_dump_format
!= no_graph
)
3009 clean_graph_dump_file (dump_base_name
, ".regmove");
3013 clean_dump_file (".sched");
3014 if (graph_dump_format
!= no_graph
)
3015 clean_graph_dump_file (dump_base_name
, ".sched");
3019 clean_dump_file (".lreg");
3020 if (graph_dump_format
!= no_graph
)
3021 clean_graph_dump_file (dump_base_name
, ".lreg");
3023 if (global_reg_dump
)
3025 clean_dump_file (".greg");
3026 if (graph_dump_format
!= no_graph
)
3027 clean_graph_dump_file (dump_base_name
, ".greg");
3031 clean_dump_file (".flow2");
3032 if (graph_dump_format
!= no_graph
)
3033 clean_graph_dump_file (dump_base_name
, ".flow2");
3037 clean_dump_file (".peephole2");
3038 if (graph_dump_format
!= no_graph
)
3039 clean_graph_dump_file (dump_base_name
, ".peephole2");
3043 clean_dump_file (".sched2");
3044 if (graph_dump_format
!= no_graph
)
3045 clean_graph_dump_file (dump_base_name
, ".sched2");
3049 clean_dump_file (".jump2");
3050 if (graph_dump_format
!= no_graph
)
3051 clean_graph_dump_file (dump_base_name
, ".jump2");
3056 clean_dump_file (".dbr");
3057 if (graph_dump_format
!= no_graph
)
3058 clean_graph_dump_file (dump_base_name
, ".dbr");
3063 clean_dump_file (".gcse");
3064 if (graph_dump_format
!= no_graph
)
3065 clean_graph_dump_file (dump_base_name
, ".gcse");
3070 clean_dump_file (".stack");
3071 if (graph_dump_format
!= no_graph
)
3072 clean_graph_dump_file (dump_base_name
, ".stack");
3075 #ifdef MACHINE_DEPENDENT_REORG
3076 if (mach_dep_reorg_dump
)
3078 clean_dump_file (".mach");
3079 if (graph_dump_format
!= no_graph
)
3080 clean_graph_dump_file (dump_base_name
, ".mach");
3084 /* Open assembler code output file. */
3086 if (flag_syntax_only
)
3087 asm_out_file
= NULL
;
3090 if (! name_specified
&& asm_file_name
== 0)
3091 asm_out_file
= stdout
;
3094 int len
= strlen (dump_base_name
);
3095 register char *dumpname
= (char *) xmalloc (len
+ 6);
3096 strcpy (dumpname
, dump_base_name
);
3097 strip_off_ending (dumpname
, len
);
3098 strcat (dumpname
, ".s");
3099 if (asm_file_name
== 0)
3101 asm_file_name
= (char *) xmalloc (strlen (dumpname
) + 1);
3102 strcpy (asm_file_name
, dumpname
);
3104 if (!strcmp (asm_file_name
, "-"))
3105 asm_out_file
= stdout
;
3107 asm_out_file
= fopen (asm_file_name
, "w");
3108 if (asm_out_file
== 0)
3109 pfatal_with_name (asm_file_name
);
3112 #ifdef IO_BUFFER_SIZE
3113 setvbuf (asm_out_file
, (char *) xmalloc (IO_BUFFER_SIZE
),
3114 _IOFBF
, IO_BUFFER_SIZE
);
3118 input_filename
= name
;
3120 /* Put an entry on the input file stack for the main input file. */
3122 = (struct file_stack
*) xmalloc (sizeof (struct file_stack
));
3123 input_file_stack
->next
= 0;
3124 input_file_stack
->name
= input_filename
;
3126 /* Perform language-specific initialization.
3127 This may set main_input_filename. */
3130 /* If the input doesn't start with a #line, use the input name
3131 as the official input file name. */
3132 if (main_input_filename
== 0)
3133 main_input_filename
= name
;
3135 if (flag_syntax_only
)
3137 write_symbols
= NO_DEBUG
;
3139 profile_block_flag
= 0;
3143 ASM_FILE_START (asm_out_file
);
3145 #ifdef ASM_COMMENT_START
3146 if (flag_verbose_asm
)
3148 /* Print the list of options in effect. */
3149 print_version (asm_out_file
, ASM_COMMENT_START
);
3150 print_switch_values (asm_out_file
, 0, MAX_LINE
,
3151 ASM_COMMENT_START
, " ", "\n");
3152 /* Add a blank line here so it appears in assembler output but not
3154 fprintf (asm_out_file
, "\n");
3158 /* Output something to inform GDB that this compilation was by GCC. */
3159 #ifndef ASM_IDENTIFY_GCC
3160 fprintf (asm_out_file
, "gcc2_compiled.:\n");
3162 ASM_IDENTIFY_GCC (asm_out_file
);
3165 /* Output something to identify which front-end produced this file. */
3166 #ifdef ASM_IDENTIFY_LANGUAGE
3167 ASM_IDENTIFY_LANGUAGE (asm_out_file
);
3169 } /* ! flag_syntax_only */
3171 #ifndef ASM_OUTPUT_SECTION_NAME
3172 if (flag_function_sections
)
3174 warning ("-ffunction-sections not supported for this target.");
3175 flag_function_sections
= 0;
3177 if (flag_data_sections
)
3179 warning ("-fdata-sections not supported for this target.");
3180 flag_data_sections
= 0;
3184 if (flag_function_sections
3185 && (profile_flag
|| profile_block_flag
))
3187 warning ("-ffunction-sections disabled; it makes profiling impossible.");
3188 flag_function_sections
= 0;
3191 #ifndef OBJECT_FORMAT_ELF
3192 if (flag_function_sections
&& write_symbols
!= NO_DEBUG
)
3193 warning ("-ffunction-sections may affect debugging on some targets.");
3196 /* ??? Note: There used to be a conditional here
3197 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
3198 This was to guarantee separation between gcc_compiled. and
3199 the first function, for the sake of dbx on Suns.
3200 However, having the extra zero here confused the Emacs
3201 code for unexec, and might confuse other programs too.
3202 Therefore, I took out that change.
3203 In future versions we should find another way to solve
3204 that dbx problem. -- rms, 23 May 93. */
3206 /* Don't let the first function fall at the same address
3207 as gcc_compiled., if profiling. */
3208 if (profile_flag
|| profile_block_flag
)
3210 /* It's best if we can write a nop here since some
3211 assemblers don't tolerate zeros in the text section. */
3212 if (insn_template
[CODE_FOR_nop
] != 0)
3213 output_asm_insn (insn_template
[CODE_FOR_nop
], NULL_PTR
);
3215 assemble_zeros (UNITS_PER_WORD
);
3218 /* If dbx symbol table desired, initialize writing it
3219 and output the predefined types. */
3220 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3221 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3222 TIMEVAR (symout_time
, dbxout_init (asm_out_file
, main_input_filename
,
3225 #ifdef SDB_DEBUGGING_INFO
3226 if (write_symbols
== SDB_DEBUG
)
3227 TIMEVAR (symout_time
, sdbout_init (asm_out_file
, main_input_filename
,
3230 #ifdef DWARF_DEBUGGING_INFO
3231 if (write_symbols
== DWARF_DEBUG
)
3232 TIMEVAR (symout_time
, dwarfout_init (asm_out_file
, main_input_filename
));
3234 #ifdef DWARF2_UNWIND_INFO
3235 if (dwarf2out_do_frame ())
3236 dwarf2out_frame_init ();
3238 #ifdef DWARF2_DEBUGGING_INFO
3239 if (write_symbols
== DWARF2_DEBUG
)
3240 TIMEVAR (symout_time
, dwarf2out_init (asm_out_file
, main_input_filename
));
3243 /* Initialize yet another pass. */
3245 init_final (main_input_filename
);
3246 init_branch_prob (dump_base_name
);
3248 start_time
= get_run_time ();
3250 /* Call the parser, which parses the entire file
3251 (calling rest_of_compilation for each function). */
3253 if (yyparse () != 0)
3255 if (errorcount
== 0)
3256 notice ("Errors detected in input file (your bison.simple is out of date)\n");
3258 /* In case there were missing closebraces,
3259 get us back to the global binding level. */
3260 while (! global_bindings_p ())
3264 /* Compilation is now finished except for writing
3265 what's left of the symbol table output. */
3267 parse_time
+= get_run_time () - start_time
;
3269 parse_time
-= integration_time
;
3270 parse_time
-= varconst_time
;
3272 if (flag_syntax_only
)
3275 globals
= getdecls ();
3277 /* Really define vars that have had only a tentative definition.
3278 Really output inline functions that must actually be callable
3279 and have not been output so far. */
3282 int len
= list_length (globals
);
3283 tree
*vec
= (tree
*) alloca (sizeof (tree
) * len
);
3287 /* Process the decls in reverse order--earliest first.
3288 Put them into VEC from back to front, then take out from front. */
3290 for (i
= 0, decl
= globals
; i
< len
; i
++, decl
= TREE_CHAIN (decl
))
3291 vec
[len
- i
- 1] = decl
;
3293 wrapup_global_declarations (vec
, len
);
3295 /* This must occur after the loop to output deferred functions. Else
3296 the profiler initializer would not be emitted if all the functions
3297 in this compilation unit were deferred.
3299 output_func_start_profiler can not cause any additional functions or
3300 data to need to be output, so it need not be in the deferred function
3302 output_func_start_profiler ();
3304 /* Now that all possible functions have been output, we can dump
3305 the exception table. */
3307 output_exception_table ();
3309 check_global_declarations (vec
, len
);
3312 /* Write out any pending weak symbol declarations. */
3316 /* Do dbx symbols */
3317 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3318 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3319 TIMEVAR (symout_time
,
3321 dbxout_finish (asm_out_file
, main_input_filename
);
3325 #ifdef DWARF_DEBUGGING_INFO
3326 if (write_symbols
== DWARF_DEBUG
)
3327 TIMEVAR (symout_time
,
3333 #ifdef DWARF2_UNWIND_INFO
3334 if (dwarf2out_do_frame ())
3335 dwarf2out_frame_finish ();
3338 #ifdef DWARF2_DEBUGGING_INFO
3339 if (write_symbols
== DWARF2_DEBUG
)
3340 TIMEVAR (symout_time
,
3342 dwarf2out_finish ();
3346 /* Output some stuff at end of file if nec. */
3348 end_final (dump_base_name
);
3350 if (branch_prob_dump
)
3351 open_dump_file (".bp", NULL
);
3353 TIMEVAR (dump_time
, end_branch_prob (rtl_dump_file
));
3355 if (branch_prob_dump
)
3356 close_dump_file (NULL
, NULL_RTX
);
3359 ASM_FILE_END (asm_out_file
);
3363 /* Language-specific end of compilation actions. */
3367 /* Close the dump files. */
3369 if (flag_gen_aux_info
)
3371 fclose (aux_info_file
);
3373 unlink (aux_info_file_name
);
3378 open_dump_file (".combine", NULL
);
3379 TIMEVAR (dump_time
, dump_combine_total_stats (rtl_dump_file
));
3380 close_dump_file (NULL
, NULL_RTX
);
3383 /* Close non-debugging input and output files. Take special care to note
3384 whether fclose returns an error, since the pages might still be on the
3385 buffer chain while the file is open. */
3389 if (! flag_syntax_only
3390 && (ferror (asm_out_file
) != 0 || fclose (asm_out_file
) != 0))
3391 fatal_io_error (asm_file_name
);
3393 /* Do whatever is necessary to finish printing the graphs. */
3394 if (graph_dump_format
!= no_graph
)
3397 finish_graph_dump_file (dump_base_name
, ".jump");
3399 finish_graph_dump_file (dump_base_name
, ".addressof");
3401 finish_graph_dump_file (dump_base_name
, ".cse");
3403 finish_graph_dump_file (dump_base_name
, ".loop");
3405 finish_graph_dump_file (dump_base_name
, ".cse2");
3406 if (branch_prob_dump
)
3407 finish_graph_dump_file (dump_base_name
, ".bp");
3409 finish_graph_dump_file (dump_base_name
, ".flow");
3411 finish_graph_dump_file (dump_base_name
, ".combine");
3413 finish_graph_dump_file (dump_base_name
, ".regmove");
3415 finish_graph_dump_file (dump_base_name
, ".sched");
3417 finish_graph_dump_file (dump_base_name
, ".lreg");
3418 if (global_reg_dump
)
3419 finish_graph_dump_file (dump_base_name
, ".greg");
3421 finish_graph_dump_file (dump_base_name
, ".flow2");
3423 finish_graph_dump_file (dump_base_name
, ".sched2");
3425 finish_graph_dump_file (dump_base_name
, ".jump2");
3428 finish_graph_dump_file (dump_base_name
, ".dbr");
3431 finish_graph_dump_file (dump_base_name
, ".gcse");
3434 finish_graph_dump_file (dump_base_name
, ".stack");
3436 #ifdef MACHINE_DEPENDENT_REORG
3437 if (mach_dep_reorg_dump
)
3438 finish_graph_dump_file (dump_base_name
, ".mach");
3442 /* Free up memory for the benefit of leak detectors. */
3445 /* Print the times. */
3449 fprintf (stderr
,"\n");
3450 print_time ("parse", parse_time
);
3452 print_time ("integration", integration_time
);
3453 print_time ("jump", jump_time
);
3454 print_time ("cse", cse_time
);
3455 print_time ("gcse", gcse_time
);
3456 print_time ("loop", loop_time
);
3457 print_time ("cse2", cse2_time
);
3458 print_time ("branch-prob", branch_prob_time
);
3459 print_time ("flow", flow_time
);
3460 print_time ("combine", combine_time
);
3461 print_time ("regmove", regmove_time
);
3462 print_time ("sched", sched_time
);
3463 print_time ("local-alloc", local_alloc_time
);
3464 print_time ("global-alloc", global_alloc_time
);
3465 print_time ("flow2", flow2_time
);
3466 print_time ("sched2", sched2_time
);
3468 print_time ("dbranch", dbr_sched_time
);
3470 print_time ("shorten-branch", shorten_branch_time
);
3471 print_time ("stack-reg", stack_reg_time
);
3472 print_time ("final", final_time
);
3473 print_time ("varconst", varconst_time
);
3474 print_time ("symout", symout_time
);
3475 print_time ("dump", dump_time
);
3479 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3480 and TYPE_DECL nodes.
3482 This does nothing for local (non-static) variables.
3483 Otherwise, it sets up the RTL and outputs any assembler code
3484 (label definition, storage allocation and initialization).
3486 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3487 the assembler symbol name to be used. TOP_LEVEL is nonzero
3488 if this declaration is not within a function. */
3491 rest_of_decl_compilation (decl
, asmspec
, top_level
, at_end
)
3493 const char *asmspec
;
3497 /* Declarations of variables, and of functions defined elsewhere. */
3499 /* The most obvious approach, to put an #ifndef around where
3500 this macro is used, doesn't work since it's inside a macro call. */
3501 #ifndef ASM_FINISH_DECLARE_OBJECT
3502 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3505 /* Forward declarations for nested functions are not "external",
3506 but we need to treat them as if they were. */
3507 if (TREE_STATIC (decl
) || DECL_EXTERNAL (decl
)
3508 || TREE_CODE (decl
) == FUNCTION_DECL
)
3509 TIMEVAR (varconst_time
,
3511 make_decl_rtl (decl
, asmspec
, top_level
);
3512 /* Initialized extern variable exists to be replaced
3513 with its value, or represents something that will be
3514 output in another file. */
3515 if (! (TREE_CODE (decl
) == VAR_DECL
3516 && DECL_EXTERNAL (decl
) && TREE_READONLY (decl
)
3517 && DECL_INITIAL (decl
) != 0
3518 && DECL_INITIAL (decl
) != error_mark_node
))
3519 /* Don't output anything
3520 when a tentative file-scope definition is seen.
3521 But at end of compilation, do output code for them. */
3522 if (! (! at_end
&& top_level
3523 && (DECL_INITIAL (decl
) == 0
3524 || DECL_INITIAL (decl
) == error_mark_node
)))
3525 assemble_variable (decl
, top_level
, at_end
, 0);
3526 if (decl
== last_assemble_variable_decl
)
3528 ASM_FINISH_DECLARE_OBJECT (asm_out_file
, decl
,
3532 else if (DECL_REGISTER (decl
) && asmspec
!= 0)
3534 if (decode_reg_name (asmspec
) >= 0)
3536 DECL_RTL (decl
) = 0;
3537 make_decl_rtl (decl
, asmspec
, top_level
);
3540 error ("invalid register name `%s' for register variable", asmspec
);
3542 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3543 else if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3544 && TREE_CODE (decl
) == TYPE_DECL
)
3545 TIMEVAR (symout_time
, dbxout_symbol (decl
, 0));
3547 #ifdef SDB_DEBUGGING_INFO
3548 else if (write_symbols
== SDB_DEBUG
&& top_level
3549 && TREE_CODE (decl
) == TYPE_DECL
)
3550 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
3554 /* Called after finishing a record, union or enumeral type. */
3557 rest_of_type_compilation (type
, toplev
)
3558 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3562 tree type ATTRIBUTE_UNUSED
;
3563 int toplev ATTRIBUTE_UNUSED
;
3566 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3567 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3568 TIMEVAR (symout_time
, dbxout_symbol (TYPE_STUB_DECL (type
), !toplev
));
3570 #ifdef SDB_DEBUGGING_INFO
3571 if (write_symbols
== SDB_DEBUG
)
3572 TIMEVAR (symout_time
, sdbout_symbol (TYPE_STUB_DECL (type
), !toplev
));
3576 /* This is called from finish_function (within yyparse)
3577 after each top-level definition is parsed.
3578 It is supposed to compile that function or variable
3579 and output the assembler code for it.
3580 After we return, the tree storage is freed. */
3583 rest_of_compilation (decl
)
3587 int start_time
= get_run_time ();
3589 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3590 to be restored after we finish compiling the function
3591 (for use when compiling inline calls to this function). */
3592 tree saved_block_tree
= 0;
3593 /* Likewise, for DECL_ARGUMENTS. */
3594 tree saved_arguments
= 0;
3596 int rebuild_label_notes_after_reload
;
3598 /* If we are reconsidering an inline function
3599 at the end of compilation, skip the stuff for making it inline. */
3601 if (DECL_SAVED_INSNS (decl
) == 0)
3606 /* If requested, consider whether to make this function inline. */
3607 if (DECL_INLINE (decl
) || flag_inline_functions
)
3608 TIMEVAR (integration_time
,
3610 lose
= function_cannot_inline_p (decl
);
3611 if (lose
|| ! optimize
)
3613 if (warn_inline
&& DECL_INLINE (decl
))
3614 warning_with_decl (decl
, lose
);
3615 DECL_ABSTRACT_ORIGIN (decl
) = 0;
3616 /* Don't really compile an extern inline function.
3617 If we can't make it inline, pretend
3618 it was only declared. */
3619 if (DECL_EXTERNAL (decl
))
3621 DECL_INITIAL (decl
) = 0;
3622 goto exit_rest_of_compilation
;
3626 /* ??? Note that this has the effect of making it look
3627 like "inline" was specified for a function if we choose
3628 to inline it. This isn't quite right, but it's
3629 probably not worth the trouble to fix. */
3630 inlinable
= DECL_INLINE (decl
) = 1;
3633 insns
= get_insns ();
3635 /* Dump the rtl code if we are dumping rtl. */
3639 open_dump_file (".rtl", decl_printable_name (decl
, 2));
3641 if (DECL_SAVED_INSNS (decl
))
3642 fprintf (rtl_dump_file
, ";; (integrable)\n\n");
3644 close_dump_file (print_rtl
, insns
);
3647 /* If function is inline, and we don't yet know whether to
3648 compile it by itself, defer decision till end of compilation.
3649 finish_compilation will call rest_of_compilation again
3650 for those functions that need to be output. Also defer those
3651 functions that we are supposed to defer. We cannot defer
3652 functions containing nested functions since the nested function
3653 data is in our non-saved obstack. We cannot defer nested
3654 functions for the same reason. */
3656 /* If this is a nested inline, remove ADDRESSOF now so we can
3657 finish compiling ourselves. Otherwise, wait until EOF.
3658 We have to do this because the purge_addressof transformation
3659 changes the DECL_RTL for many variables, which confuses integrate.
3660 Also, save_for_inline_copying can be very expensive. */
3663 if (decl_function_context (decl
))
3664 purge_addressof (insns
);
3666 DECL_DEFER_OUTPUT (decl
) = 1;
3669 if (! current_function_contains_functions
3670 && (DECL_DEFER_OUTPUT (decl
)
3671 || (DECL_INLINE (decl
)
3672 && ((! TREE_PUBLIC (decl
) && ! TREE_ADDRESSABLE (decl
)
3673 && ! flag_keep_inline_functions
)
3674 || DECL_EXTERNAL (decl
)))))
3676 DECL_DEFER_OUTPUT (decl
) = 1;
3678 /* If -Wreturn-type, we have to do a bit of compilation.
3679 However, if we just fall through we will call
3680 save_for_inline_copying() which results in excessive
3681 memory use. Instead, we just want to call
3682 jump_optimize() to figure out whether or not we can fall
3683 off the end of the function; we do the minimum amount of
3684 work necessary to make that safe. And, we set optimize
3685 to zero to keep jump_optimize from working too hard. */
3686 if (warn_return_type
)
3688 int saved_optimize
= optimize
;
3690 find_exception_handler_labels ();
3691 jump_optimize (get_insns(), !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
3692 !JUMP_AFTER_REGSCAN
);
3693 optimize
= saved_optimize
;
3696 #ifdef DWARF_DEBUGGING_INFO
3697 /* Generate the DWARF info for the "abstract" instance
3698 of a function which we may later generate inlined and/or
3699 out-of-line instances of. */
3700 if (write_symbols
== DWARF_DEBUG
)
3702 set_decl_abstract_flags (decl
, 1);
3703 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
3704 set_decl_abstract_flags (decl
, 0);
3707 #ifdef DWARF2_DEBUGGING_INFO
3708 /* Generate the DWARF2 info for the "abstract" instance
3709 of a function which we may later generate inlined and/or
3710 out-of-line instances of. */
3711 if (write_symbols
== DWARF2_DEBUG
)
3713 set_decl_abstract_flags (decl
, 1);
3714 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
3715 set_decl_abstract_flags (decl
, 0);
3718 TIMEVAR (integration_time
, save_for_inline_nocopy (decl
));
3719 DECL_SAVED_INSNS (decl
)->inlinable
= inlinable
;
3720 goto exit_rest_of_compilation
;
3723 /* If we have to compile the function now, save its rtl and subdecls
3724 so that its compilation will not affect what others get. */
3725 if (inlinable
|| DECL_DEFER_OUTPUT (decl
))
3727 #ifdef DWARF_DEBUGGING_INFO
3728 /* Generate the DWARF info for the "abstract" instance of
3729 a function which we will generate an out-of-line instance
3730 of almost immediately (and which we may also later generate
3731 various inlined instances of). */
3732 if (write_symbols
== DWARF_DEBUG
)
3734 set_decl_abstract_flags (decl
, 1);
3735 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
3736 set_decl_abstract_flags (decl
, 0);
3739 #ifdef DWARF2_DEBUGGING_INFO
3740 /* Generate the DWARF2 info for the "abstract" instance of
3741 a function which we will generate an out-of-line instance
3742 of almost immediately (and which we may also later generate
3743 various inlined instances of). */
3744 if (write_symbols
== DWARF2_DEBUG
)
3746 set_decl_abstract_flags (decl
, 1);
3747 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
3748 set_decl_abstract_flags (decl
, 0);
3751 saved_block_tree
= DECL_INITIAL (decl
);
3752 saved_arguments
= DECL_ARGUMENTS (decl
);
3753 TIMEVAR (integration_time
, save_for_inline_copying (decl
));
3754 DECL_SAVED_INSNS (decl
)->inlinable
= inlinable
;
3757 /* If specified extern inline but we aren't inlining it, we are
3758 done. This goes for anything that gets here with DECL_EXTERNAL
3759 set, not just things with DECL_INLINE. */
3760 if (DECL_EXTERNAL (decl
))
3761 goto exit_rest_of_compilation
;
3764 /* Initialize some variables used by the optimizers. */
3765 init_function_for_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 init_EXPR_INSN_LIST_cache ();
3810 #ifdef SETJMP_VIA_SAVE_AREA
3811 /* This must be performed before virutal register instantiation. */
3812 if (current_function_calls_alloca
)
3813 optimize_save_area_alloca (insns
);
3816 /* Instantiate all virtual registers. */
3818 instantiate_virtual_regs (current_function_decl
, get_insns ());
3820 /* See if we have allocated stack slots that are not directly addressable.
3821 If so, scan all the insns and create explicit address computation
3822 for all references to such slots. */
3823 /* fixup_stack_slots (); */
3825 /* Find all the EH handlers. */
3826 find_exception_handler_labels ();
3828 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3829 are initialized and to compute whether control can drop off the end
3831 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3832 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
3833 JUMP_AFTER_REGSCAN
));
3835 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3836 if (rtl_dump_and_exit
|| flag_syntax_only
|| DECL_DEFER_OUTPUT (decl
))
3837 goto exit_rest_of_compilation
;
3839 /* Dump rtl code after jump, if we are doing that. */
3841 dump_rtl (".jump", decl
, print_rtl
, insns
);
3843 /* Perform common subexpression elimination.
3844 Nonzero value from `cse_main' means that jumps were simplified
3845 and some code may now be unreachable, so do
3846 jump optimization again. */
3851 open_dump_file (".cse", decl_printable_name (decl
, 2));
3853 TIMEVAR (cse_time
, reg_scan (insns
, max_reg_num (), 1));
3855 if (flag_thread_jumps
)
3856 /* Hacks by tiemann & kenner. */
3857 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 1));
3859 TIMEVAR (cse_time
, tem
= cse_main (insns
, max_reg_num (),
3861 TIMEVAR (cse_time
, delete_trivially_dead_insns (insns
, max_reg_num ()));
3863 if (tem
|| optimize
> 1)
3864 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3866 !JUMP_AFTER_REGSCAN
));
3868 /* Dump rtl code after cse, if we are doing that. */
3872 close_dump_file (print_rtl
, insns
);
3873 if (graph_dump_format
!= no_graph
)
3874 print_rtl_graph_with_bb (dump_base_name
, ".cse", insns
);
3878 purge_addressof (insns
);
3879 reg_scan (insns
, max_reg_num (), 1);
3883 dump_rtl (".addressof", decl
, print_rtl
, insns
);
3884 if (graph_dump_format
!= no_graph
)
3885 print_rtl_graph_with_bb (dump_base_name
, ".addressof", insns
);
3888 /* Perform global cse. */
3890 if (optimize
> 0 && flag_gcse
)
3893 open_dump_file (".gcse", decl_printable_name (decl
, 2));
3895 TIMEVAR (gcse_time
, tem
= gcse_main (insns
, rtl_dump_file
));
3897 /* If gcse altered any jumps, rerun jump optimizations to clean
3901 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3903 !JUMP_AFTER_REGSCAN
));
3908 close_dump_file (print_rtl
, insns
);
3909 if (graph_dump_format
!= no_graph
)
3910 print_rtl_graph_with_bb (dump_base_name
, ".gcse", insns
);
3913 /* Move constant computations out of loops. */
3918 open_dump_file (".loop", decl_printable_name (decl
, 2));
3923 if (flag_rerun_loop_opt
)
3925 /* We only want to perform unrolling once. */
3927 loop_optimize (insns
, rtl_dump_file
, 0, 0);
3930 /* The first call to loop_optimize makes some instructions
3931 trivially dead. We delete those instructions now in the
3932 hope that doing so will make the heuristics in loop work
3933 better and possibly speed up compilation. */
3934 delete_trivially_dead_insns (insns
, max_reg_num ());
3936 /* The regscan pass is currently necessary as the alias
3937 analysis code depends on this information. */
3938 reg_scan (insns
, max_reg_num (), 1);
3940 loop_optimize (insns
, rtl_dump_file
, flag_unroll_loops
, 1);
3943 /* Dump rtl code after loop opt, if we are doing that. */
3947 close_dump_file (print_rtl
, insns
);
3948 if (graph_dump_format
!= no_graph
)
3949 print_rtl_graph_with_bb (dump_base_name
, ".loop", insns
);
3956 open_dump_file (".cse2", decl_printable_name (decl
, 2));
3958 if (flag_rerun_cse_after_loop
)
3960 /* Running another jump optimization pass before the second
3961 cse pass sometimes simplifies the RTL enough to allow
3962 the second CSE pass to do a better job. Jump_optimize can change
3963 max_reg_num so we must rerun reg_scan afterwards.
3964 ??? Rework to not call reg_scan so often. */
3965 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3966 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3968 JUMP_AFTER_REGSCAN
));
3970 TIMEVAR (cse2_time
, reg_scan (insns
, max_reg_num (), 0));
3971 TIMEVAR (cse2_time
, tem
= cse_main (insns
, max_reg_num (),
3974 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3976 !JUMP_AFTER_REGSCAN
));
3979 if (flag_thread_jumps
)
3981 /* This pass of jump threading straightens out code
3982 that was kinked by loop optimization. */
3983 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3984 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 0));
3987 /* Dump rtl code after cse, if we are doing that. */
3991 close_dump_file (print_rtl
, insns
);
3992 if (graph_dump_format
!= no_graph
)
3993 print_rtl_graph_with_bb (dump_base_name
, ".cse2", insns
);
3997 if (profile_arc_flag
|| flag_test_coverage
|| flag_branch_probabilities
)
3999 if (branch_prob_dump
)
4000 open_dump_file (".bp", decl_printable_name (decl
, 2));
4005 branch_prob (insns
, rtl_dump_file
);
4008 if (branch_prob_dump
)
4010 close_dump_file (print_rtl
, insns
);
4011 if (graph_dump_format
!= no_graph
)
4012 print_rtl_graph_with_bb (dump_base_name
, ".bp", insns
);
4016 /* We are no longer anticipating cse in this function, at least. */
4018 cse_not_expected
= 1;
4020 /* Now we choose between stupid (pcc-like) register allocation
4021 (if we got the -noreg switch and not -opt)
4022 and smart register allocation. */
4024 if (optimize
> 0) /* Stupid allocation probably won't work */
4025 obey_regdecls
= 0; /* if optimizations being done. */
4029 /* Print function header into flow dump now
4030 because doing the flow analysis makes some of the dump. */
4033 open_dump_file (".flow", decl_printable_name (decl
, 2));
4039 regclass (insns
, max_reg_num ());
4040 stupid_life_analysis (insns
, max_reg_num (),
4046 /* Do control and data flow analysis,
4047 and write some of the results to dump file. */
4052 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
, 1);
4053 life_analysis (insns
, max_reg_num (), rtl_dump_file
, 1);
4056 if (warn_uninitialized
)
4058 uninitialized_vars_warning (DECL_INITIAL (decl
));
4059 setjmp_args_warning ();
4063 /* Dump rtl after flow analysis. */
4067 close_dump_file (print_rtl_with_bb
, insns
);
4068 if (graph_dump_format
!= no_graph
)
4069 print_rtl_graph_with_bb (dump_base_name
, ".flow", insns
);
4072 /* The first life analysis pass has finished. From now on we can not
4073 generate any new pseudos. */
4076 /* If -opt, try combining insns through substitution. */
4080 TIMEVAR (combine_time
, combine_instructions (insns
, max_reg_num ()));
4082 /* Dump rtl code after insn combination. */
4086 dump_rtl (".combine", decl
, print_rtl_with_bb
, insns
);
4087 if (graph_dump_format
!= no_graph
)
4088 print_rtl_graph_with_bb (dump_base_name
, ".combine", insns
);
4092 /* Register allocation pre-pass, to reduce number of moves
4093 necessary for two-address machines. */
4094 if (optimize
> 0 && (flag_regmove
|| flag_expensive_optimizations
))
4097 open_dump_file (".regmove", decl_printable_name (decl
, 2));
4099 TIMEVAR (regmove_time
, regmove_optimize (insns
, max_reg_num (),
4104 close_dump_file (print_rtl_with_bb
, insns
);
4105 if (graph_dump_format
!= no_graph
)
4106 print_rtl_graph_with_bb (dump_base_name
, ".regmove", insns
);
4110 /* Print function header into sched dump now
4111 because doing the sched analysis makes some of the dump. */
4113 if (optimize
> 0 && flag_schedule_insns
)
4116 open_dump_file (".sched", decl_printable_name (decl
, 2));
4118 /* Do control and data sched analysis,
4119 and write some of the results to dump file. */
4121 TIMEVAR (sched_time
, schedule_insns (rtl_dump_file
));
4123 /* Dump rtl after instruction scheduling. */
4127 close_dump_file (print_rtl_with_bb
, insns
);
4128 if (graph_dump_format
!= no_graph
)
4129 print_rtl_graph_with_bb (dump_base_name
, ".sched", insns
);
4133 /* Determine if the current function is a leaf before running reload
4134 since this can impact optimizations done by the prologue and
4135 epilogue thus changing register elimination offsets. */
4136 current_function_is_leaf
= leaf_function_p ();
4138 /* Unless we did stupid register allocation,
4139 allocate pseudo-regs that are used only within 1 basic block.
4141 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
4142 jump optimizer after register allocation and reloading are finished. */
4145 TIMEVAR (local_alloc_time
,
4147 recompute_reg_usage (insns
, ! optimize_size
);
4148 regclass (insns
, max_reg_num ());
4149 rebuild_label_notes_after_reload
= local_alloc ();
4152 rebuild_label_notes_after_reload
= 0;
4154 /* Dump rtl code after allocating regs within basic blocks. */
4158 open_dump_file (".lreg", decl_printable_name (decl
, 2));
4160 TIMEVAR (dump_time
, dump_flow_info (rtl_dump_file
));
4161 TIMEVAR (dump_time
, dump_local_alloc (rtl_dump_file
));
4163 close_dump_file (print_rtl_with_bb
, insns
);
4164 if (graph_dump_format
!= no_graph
)
4165 print_rtl_graph_with_bb (dump_base_name
, ".lreg", insns
);
4168 if (global_reg_dump
)
4169 open_dump_file (".greg", decl_printable_name (decl
, 2));
4171 /* Unless we did stupid register allocation,
4172 allocate remaining pseudo-regs, then do the reload pass
4173 fixing up any insns that are invalid. */
4175 TIMEVAR (global_alloc_time
,
4178 failure
= global_alloc (rtl_dump_file
);
4180 failure
= reload (insns
, 0, rtl_dump_file
);
4185 goto exit_rest_of_compilation
;
4187 /* Do a very simple CSE pass over just the hard registers. */
4189 reload_cse_regs (insns
);
4191 /* Register allocation and reloading may have turned an indirect jump into
4192 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
4193 jumping instructions. */
4194 if (rebuild_label_notes_after_reload
)
4195 TIMEVAR (jump_time
, rebuild_jump_labels (insns
));
4197 /* If optimizing and we are performing instruction scheduling after
4198 reload, then go ahead and split insns now since we are about to
4199 recompute flow information anyway.
4201 reload_cse_regs may expose more splitting opportunities, expecially
4202 for double-word operations. */
4203 if (optimize
> 0 && flag_schedule_insns_after_reload
)
4207 for (insn
= insns
; insn
; insn
= NEXT_INSN (insn
))
4211 if (GET_RTX_CLASS (GET_CODE (insn
)) != 'i')
4214 last
= try_split (PATTERN (insn
), insn
, 1);
4218 PUT_CODE (insn
, NOTE
);
4219 NOTE_SOURCE_FILE (insn
) = 0;
4220 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
4225 if (global_reg_dump
)
4227 TIMEVAR (dump_time
, dump_global_regs (rtl_dump_file
));
4228 close_dump_file (print_rtl_with_bb
, insns
);
4229 if (graph_dump_format
!= no_graph
)
4230 print_rtl_graph_with_bb (dump_base_name
, ".greg", insns
);
4233 /* Re-create the death notes which were deleted during reload. */
4235 open_dump_file (".flow2", decl_printable_name (decl
, 2));
4242 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
, 1);
4243 life_analysis (insns
, max_reg_num (), rtl_dump_file
, 1);
4247 flow2_completed
= 1;
4249 /* On some machines, the prologue and epilogue code, or parts thereof,
4250 can be represented as RTL. Doing so lets us schedule insns between
4251 it and the rest of the code and also allows delayed branch
4252 scheduling to operate in the epilogue. */
4254 thread_prologue_and_epilogue_insns (insns
);
4258 close_dump_file (print_rtl_with_bb
, insns
);
4259 if (graph_dump_format
!= no_graph
)
4260 print_rtl_graph_with_bb (dump_base_name
, ".flow2", insns
);
4263 #ifdef HAVE_peephole2
4264 if (optimize
> 0 && flag_peephole2
)
4267 open_dump_file (".peephole2", decl_printable_name (decl
, 2));
4269 peephole2_optimize (rtl_dump_file
);
4273 close_dump_file (print_rtl_with_bb
, insns
);
4274 if (graph_dump_format
!= no_graph
)
4275 print_rtl_graph_with_bb (dump_base_name
, ".peephole2", insns
);
4280 if (optimize
> 0 && flag_schedule_insns_after_reload
)
4283 open_dump_file (".sched2", decl_printable_name (decl
, 2));
4285 /* Do control and data sched analysis again,
4286 and write some more of the results to dump file. */
4288 TIMEVAR (sched2_time
, schedule_insns (rtl_dump_file
));
4290 /* Dump rtl after post-reorder instruction scheduling. */
4294 close_dump_file (print_rtl_with_bb
, insns
);
4295 if (graph_dump_format
!= no_graph
)
4296 print_rtl_graph_with_bb (dump_base_name
, ".sched2", insns
);
4300 #ifdef LEAF_REGISTERS
4301 current_function_uses_only_leaf_regs
4302 = optimize
> 0 && only_leaf_regs_used () && leaf_function_p ();
4305 /* One more attempt to remove jumps to .+1
4306 left by dead-store-elimination.
4307 Also do cross-jumping this time
4308 and delete no-op move insns. */
4312 TIMEVAR (jump_time
, jump_optimize (insns
, JUMP_CROSS_JUMP
,
4314 !JUMP_AFTER_REGSCAN
));
4316 /* Dump rtl code after jump, if we are doing that. */
4320 dump_rtl (".jump2", decl
, print_rtl_with_bb
, insns
);
4321 if (graph_dump_format
!= no_graph
)
4322 print_rtl_graph_with_bb (dump_base_name
, ".jump2", insns
);
4326 /* If a machine dependent reorganization is needed, call it. */
4327 #ifdef MACHINE_DEPENDENT_REORG
4328 if (mach_dep_reorg_dump
)
4329 open_dump_file (".mach", decl_printable_name (decl
, 2));
4331 MACHINE_DEPENDENT_REORG (insns
);
4333 if (mach_dep_reorg_dump
)
4335 close_dump_file (print_rtl_with_bb
, insns
);
4336 if (graph_dump_format
!= no_graph
)
4337 print_rtl_graph_with_bb (dump_base_name
, ".mach", insns
);
4341 /* If a scheduling pass for delayed branches is to be done,
4342 call the scheduling code. */
4345 if (optimize
> 0 && flag_delayed_branch
)
4348 open_dump_file (".dbr", decl_printable_name (decl
, 2));
4350 TIMEVAR (dbr_sched_time
, dbr_schedule (insns
, rtl_dump_file
));
4354 close_dump_file (print_rtl_with_bb
, insns
);
4355 if (graph_dump_format
!= no_graph
)
4356 print_rtl_graph_with_bb (dump_base_name
, ".dbr", insns
);
4361 /* Shorten branches. */
4362 TIMEVAR (shorten_branch_time
,
4364 shorten_branches (get_insns ());
4369 open_dump_file (".stack", decl_printable_name (decl
, 2));
4371 TIMEVAR (stack_reg_time
, reg_to_stack (insns
, rtl_dump_file
));
4375 dump_rtl (".stack", decl
, print_rtl_with_bb
, insns
);
4376 if (graph_dump_format
!= no_graph
)
4377 print_rtl_graph_with_bb (dump_base_name
, ".stack", insns
);
4381 /* Now turn the rtl into assembler code. */
4383 TIMEVAR (final_time
,
4388 /* Get the function's name, as described by its RTL.
4389 This may be different from the DECL_NAME name used
4390 in the source file. */
4392 x
= DECL_RTL (decl
);
4393 if (GET_CODE (x
) != MEM
)
4396 if (GET_CODE (x
) != SYMBOL_REF
)
4398 fnname
= XSTR (x
, 0);
4400 assemble_start_function (decl
, fnname
);
4401 final_start_function (insns
, asm_out_file
, optimize
);
4402 final (insns
, asm_out_file
, optimize
, 0);
4403 final_end_function (insns
, asm_out_file
, optimize
);
4404 assemble_end_function (decl
, fnname
);
4406 fflush (asm_out_file
);
4408 /* Release all memory allocated by flow. */
4409 free_basic_block_vars (0);
4411 /* Release all memory held by regsets now */
4412 regset_release_memory ();
4415 /* Write DBX symbols if requested */
4417 /* Note that for those inline functions where we don't initially
4418 know for certain that we will be generating an out-of-line copy,
4419 the first invocation of this routine (rest_of_compilation) will
4420 skip over this code by doing a `goto exit_rest_of_compilation;'.
4421 Later on, finish_compilation will call rest_of_compilation again
4422 for those inline functions that need to have out-of-line copies
4423 generated. During that call, we *will* be routed past here. */
4425 #ifdef DBX_DEBUGGING_INFO
4426 if (write_symbols
== DBX_DEBUG
)
4427 TIMEVAR (symout_time
, dbxout_function (decl
));
4430 #ifdef DWARF_DEBUGGING_INFO
4431 if (write_symbols
== DWARF_DEBUG
)
4432 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
4435 #ifdef DWARF2_DEBUGGING_INFO
4436 if (write_symbols
== DWARF2_DEBUG
)
4437 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
4440 exit_rest_of_compilation
:
4444 /* In case the function was not output,
4445 don't leave any temporary anonymous types
4446 queued up for sdb output. */
4447 #ifdef SDB_DEBUGGING_INFO
4448 if (write_symbols
== SDB_DEBUG
)
4449 sdbout_types (NULL_TREE
);
4452 /* Put back the tree of subblocks and list of arguments
4453 from before we copied them.
4454 Code generation and the output of debugging info may have modified
4455 the copy, but the original is unchanged. */
4457 if (saved_block_tree
!= 0)
4459 DECL_INITIAL (decl
) = saved_block_tree
;
4460 DECL_ARGUMENTS (decl
) = saved_arguments
;
4461 DECL_ABSTRACT_ORIGIN (decl
) = NULL_TREE
;
4464 reload_completed
= 0;
4465 flow2_completed
= 0;
4468 TIMEVAR (final_time
,
4470 /* Clear out the insn_length contents now that they are no
4472 init_insn_lengths ();
4474 /* Clear out the real_constant_chain before some of the rtx's
4475 it runs through become garbage. */
4476 clear_const_double_mem ();
4478 /* Cancel the effect of rtl_in_current_obstack. */
4479 resume_temporary_allocation ();
4481 /* Show no temporary slots allocated. */
4485 /* Make sure volatile mem refs aren't considered valid operands for
4486 arithmetic insns. We must call this here if this is a nested inline
4487 function, since the above code leaves us in the init_recog state
4488 (from final.c), and the function context push/pop code does not
4489 save/restore volatile_ok.
4491 ??? Maybe it isn't necessary for expand_start_function to call this
4492 anymore if we do it here? */
4494 init_recog_no_volatile ();
4496 /* The parsing time is all the time spent in yyparse
4497 *except* what is spent in this function. */
4499 parse_time
-= get_run_time () - start_time
;
4501 /* Reset global variables. */
4502 free_basic_block_vars (0);
4513 printf ("Usage: %s input [switches]\n", progname
);
4514 printf ("Switches:\n");
4516 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
4517 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
4518 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4519 printf (" -finline-limit=<number> Limits the size of inlined functions to <number>\n");
4521 for (i
= NUM_ELEM (f_options
); i
--;)
4523 const char * description
= f_options
[i
].description
;
4525 if (description
!= NULL
&& * description
!= 0)
4526 printf (" -f%-21s %s\n",
4527 f_options
[i
].string
, description
);
4530 printf (" -O[number] Set optimisation level to [number]\n");
4531 printf (" -Os Optimise for space rather than speed\n");
4532 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
4533 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
4534 printf (" -w Suppress warnings\n");
4535 printf (" -W Enable extra warnings\n");
4537 for (i
= NUM_ELEM (W_options
); i
--;)
4539 const char * description
= W_options
[i
].description
;
4541 if (description
!= NULL
&& * description
!= 0)
4542 printf (" -W%-21s %s\n",
4543 W_options
[i
].string
, description
);
4546 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4547 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4548 printf (" -p Enable function profiling\n");
4549 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4550 printf (" -a Enable block profiling \n");
4552 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4553 printf (" -ax Enable jump profiling \n");
4555 printf (" -o <file> Place output into <file> \n");
4556 printf (" -G <number> Put global and static data smaller than <number>\n");
4557 printf (" bytes into a special section (on some targets)\n");
4559 for (i
= NUM_ELEM (debug_args
); i
--;)
4561 if (debug_args
[i
].description
!= NULL
)
4562 printf (" -%-22s %s\n", debug_args
[i
].arg
, debug_args
[i
].description
);
4565 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4566 printf (" -quiet Do not display functions compiled or elapsed time\n");
4567 printf (" -version Display the compiler's version\n");
4568 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4569 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4570 #if defined INSN_SCHEDULING
4571 printf (" -sched-verbose=<number> Set the verbosity level of the scheduler\n");
4573 printf (" --help Display this information\n");
4578 /* Display descriptions of language specific options.
4579 If there is no description, note that there is an undocumented option.
4580 If the description is empty, do not display anything. (This allows
4581 options to be deliberately undocumented, for whatever reason).
4582 If the option string is missing, then this is a marker, indicating
4583 that the description string is in fact the name of a language, whose
4584 language specific options are to follow. */
4586 if (NUM_ELEM (documented_lang_options
) > 1)
4588 printf ("\nLanguage specific options:\n");
4590 for (i
= 0; i
< NUM_ELEM (documented_lang_options
); i
++)
4592 const char * description
= documented_lang_options
[i
].description
;
4593 const char * option
= documented_lang_options
[i
].option
;
4595 if (description
== NULL
)
4600 printf (" %-23.23s [undocumented]\n", option
);
4602 else if (* description
== 0)
4604 else if (option
== NULL
)
4608 ("\nThere are undocumented %s specific options as well.\n",
4612 printf ("\n Options for %s:\n", description
);
4617 printf (" %-23.23s %s\n", option
, description
);
4622 printf ("\nThere are undocumented %s specific options as well.\n", lang
);
4624 if (NUM_ELEM (target_switches
) > 1
4625 #ifdef TARGET_OPTIONS
4626 || NUM_ELEM (target_options
) > 1
4634 printf ("\nTarget specific options:\n");
4636 for (i
= NUM_ELEM (target_switches
); i
--;)
4638 const char * option
= target_switches
[i
].name
;
4639 const char * description
= target_switches
[i
].description
;
4641 if (option
== NULL
|| * option
== 0)
4643 else if (description
== NULL
)
4648 printf (" -m%-21.21s [undocumented]\n", option
);
4650 else if (* description
!= 0)
4651 doc
+= printf (" -m%-21.21s %s\n", option
, description
);
4654 #ifdef TARGET_OPTIONS
4655 for (i
= NUM_ELEM (target_options
); i
--;)
4657 const char * option
= target_options
[i
].prefix
;
4658 const char * description
= target_options
[i
].description
;
4660 if (option
== NULL
|| * option
== 0)
4662 else if (description
== NULL
)
4667 printf (" -m%-21.21s [undocumented]\n", option
);
4669 else if (* description
!= 0)
4670 doc
+= printf (" -m%-21.21s %s\n", option
, description
);
4676 printf ("\nThere are undocumented target specific options as well.\n");
4678 printf (" They exist, but they are not documented.\n");
4683 /* Compare the user specified 'option' with the language
4684 specific 'lang_option'. Return true if they match, or
4685 if 'option' is a viable prefix of 'lang_option'. */
4688 check_lang_option (option
, lang_option
)
4692 lang_independent_options
* indep_options
;
4697 /* Ignore NULL entries. */
4698 if (option
== NULL
|| lang_option
== NULL
)
4701 if ((space
= strchr (lang_option
, ' ')) != NULL
)
4702 len
= space
- lang_option
;
4704 len
= strlen (lang_option
);
4706 /* If they do not match to the first n characters then fail. */
4707 if (strncmp (option
, lang_option
, len
) != 0)
4710 /* Do not accept a lang option, if it matches a normal -f or -W
4711 option. Chill defines a -fpack, but we want to support
4714 /* An exact match is OK */
4715 if ((int) strlen (option
) == len
)
4718 /* If it is not an -f or -W option allow the match */
4719 if (option
[0] != '-')
4724 case 'f': indep_options
= f_options
; break;
4725 case 'W': indep_options
= W_options
; break;
4729 /* The option is a -f or -W option.
4730 Skip past the prefix and search for the remainder in the
4731 appropriate table of options. */
4734 if (option
[0] == 'n' && option
[1] == 'o' && option
[2] == '-')
4737 for (k
= NUM_ELEM (indep_options
); k
--;)
4739 if (!strcmp (option
, indep_options
[k
].string
))
4741 /* The option matched a language independent option,
4742 do not allow the language specific match. */
4748 /* The option matches the start of the langauge specific option
4749 and it is not an exact match for a language independent option. */
4753 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4754 Exit code is 35 if can't open files, 34 if fatal error,
4755 33 if had nonfatal errors, else success. */
4764 int flag_print_mem
= 0;
4765 int version_flag
= 0;
4768 /* save in case md file wants to emit args as a comment. */
4772 p
= argv
[0] + strlen (argv
[0]);
4773 while (p
!= argv
[0] && p
[-1] != '/'
4774 #ifdef DIR_SEPARATOR
4775 && p
[-1] != DIR_SEPARATOR
4781 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
4782 /* Get rid of any avoidable limit on stack size. */
4786 /* Set the stack limit huge so that alloca does not fail. */
4787 getrlimit (RLIMIT_STACK
, &rlim
);
4788 rlim
.rlim_cur
= rlim
.rlim_max
;
4789 setrlimit (RLIMIT_STACK
, &rlim
);
4793 #ifdef HAVE_LC_MESSAGES
4794 setlocale (LC_MESSAGES
, "");
4796 (void) bindtextdomain (PACKAGE
, localedir
);
4797 (void) textdomain (PACKAGE
);
4799 signal (SIGFPE
, float_signal
);
4802 signal (SIGPIPE
, pipe_closed
);
4805 decl_printable_name
= decl_name
;
4806 lang_expand_expr
= (lang_expand_expr_t
) do_abort
;
4808 /* Initialize whether `char' is signed. */
4809 flag_signed_char
= DEFAULT_SIGNED_CHAR
;
4810 #ifdef DEFAULT_SHORT_ENUMS
4811 /* Initialize how much space enums occupy, by default. */
4812 flag_short_enums
= DEFAULT_SHORT_ENUMS
;
4815 /* Perform language-specific options intialization. */
4816 lang_init_options ();
4818 /* Scan to see what optimization level has been specified. That will
4819 determine the default value of many flags. */
4820 for (i
= 1; i
< argc
; i
++)
4822 if (!strcmp (argv
[i
], "-O"))
4827 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'O')
4829 /* Handle -Os, -O2, -O3, -O69, ... */
4830 char *p
= &argv
[i
][2];
4832 if ((p
[0] == 's') && (p
[1] == 0))
4836 /* Optimizing for size forces optimize to be 2. */
4841 const int optimize_val
= read_integral_parameter (p
, p
- 2, -1);
4842 if (optimize_val
!= -1)
4844 optimize
= optimize_val
;
4851 obey_regdecls
= (optimize
== 0);
4856 flag_thread_jumps
= 1;
4858 flag_delayed_branch
= 1;
4860 #ifdef CAN_DEBUG_WITHOUT_FP
4861 flag_omit_frame_pointer
= 1;
4867 flag_cse_follow_jumps
= 1;
4868 flag_cse_skip_blocks
= 1;
4870 flag_expensive_optimizations
= 1;
4871 flag_strength_reduce
= 1;
4872 flag_rerun_cse_after_loop
= 1;
4873 flag_rerun_loop_opt
= 1;
4874 flag_caller_saves
= 1;
4877 #ifdef INSN_SCHEDULING
4878 flag_schedule_insns
= 1;
4879 flag_schedule_insns_after_reload
= 1;
4882 flag_strict_aliasing
= 1;
4887 flag_inline_functions
= 1;
4890 if (optimize
< 2 || optimize_size
)
4895 align_functions
= 1;
4898 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4901 set_target_switch ("");
4903 #ifdef OPTIMIZATION_OPTIONS
4904 /* Allow default optimizations to be specified on a per-machine basis. */
4905 OPTIMIZATION_OPTIONS (optimize
, optimize_size
);
4908 /* Initialize register usage now so switches may override. */
4911 for (i
= 1; i
< argc
; i
++)
4915 /* If this is a language-specific option,
4916 decode it in a language-specific way. */
4917 for (j
= NUM_ELEM (documented_lang_options
); j
--;)
4918 if (check_lang_option (argv
[i
], documented_lang_options
[j
].option
))
4921 if (j
!= (size_t)-1)
4923 /* If the option is valid for *some* language,
4924 treat it as valid even if this language doesn't understand it. */
4925 int strings_processed
= lang_decode_option (argc
- i
, argv
+ i
);
4927 if (!strcmp (argv
[i
], "--help"))
4933 if (strings_processed
!= 0)
4934 i
+= strings_processed
- 1;
4936 else if (argv
[i
][0] == '-' && argv
[i
][1] != 0)
4938 register char *str
= argv
[i
] + 1;
4943 set_target_switch (&str
[1]);
4944 else if (!strcmp (str
, "dumpbase"))
4946 dump_base_name
= argv
[++i
];
4948 else if (str
[0] == 'd')
4950 register char *p
= &str
[1];
4955 branch_prob_dump
= 1;
4962 global_reg_dump
= 1;
4970 cse_dump
= 1, cse2_dump
= 1;
4977 #ifdef MACHINE_DEPENDENT_REORG
4978 mach_dep_reorg_dump
= 1;
4986 branch_prob_dump
= 1;
5003 global_reg_dump
= 1;
5028 #ifdef MACHINE_DEPENDENT_REORG
5030 mach_dep_reorg_dump
= 1;
5034 flag_print_asm_name
= 1;
5055 graph_dump_format
= vcg
;
5061 rtl_dump_and_exit
= 1;
5069 case 'D': /* these are handled by the preprocessor */
5073 warning ("unrecognised gcc debugging option: %c", p
[-1]);
5077 else if (str
[0] == 'f')
5079 register char *p
= &str
[1];
5082 /* Some kind of -f option.
5083 P's value is the option sans `-f'.
5084 Search for it in the table of options. */
5087 !found
&& j
< sizeof (f_options
) / sizeof (f_options
[0]);
5090 if (!strcmp (p
, f_options
[j
].string
))
5092 *f_options
[j
].variable
= f_options
[j
].on_value
;
5093 /* A goto here would be cleaner,
5094 but breaks the vax pcc. */
5097 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
5098 && ! strcmp (p
+3, f_options
[j
].string
))
5100 *f_options
[j
].variable
= ! f_options
[j
].on_value
;
5107 else if (!strncmp (p
, "inline-limit-", 13)
5108 || !strncmp (p
, "inline-limit=", 13))
5110 read_integral_parameter (p
+ 13, p
- 2, inline_max_insns
);
5111 #ifdef INSN_SCHEDULING
5112 else if (!strncmp (p
, "sched-verbose=",14))
5113 fix_sched_param("verbose",&p
[14]);
5115 else if (!strncmp (p
, "fixed-", 6))
5116 fix_register (&p
[6], 1, 1);
5117 else if (!strncmp (p
, "call-used-", 10))
5118 fix_register (&p
[10], 0, 1);
5119 else if (!strncmp (p
, "call-saved-", 11))
5120 fix_register (&p
[11], 0, 0);
5121 else if (!strncmp (p
, "align-loops=", 12))
5122 align_loops
= read_integral_parameter (p
+ 12, p
- 2,
5124 else if (!strncmp (p
, "align-functions=", 16))
5125 align_functions
= read_integral_parameter (p
+ 16, p
- 2,
5127 else if (!strncmp (p
, "align-jumps=", 12))
5128 align_jumps
= read_integral_parameter (p
+ 12, p
- 2,
5130 else if (!strncmp (p
, "align-labels=", 13))
5131 align_labels
= read_integral_parameter (p
+ 13, p
- 2,
5134 error ("Invalid option `%s'", argv
[i
]);
5136 else if (str
[0] == 'O')
5138 /* Already been treated above. Do nothing. */
5140 else if (!strcmp (str
, "pedantic"))
5142 else if (!strcmp (str
, "pedantic-errors"))
5143 flag_pedantic_errors
= pedantic
= 1;
5144 else if (!strcmp (str
, "quiet"))
5146 else if (!strcmp (str
, "version"))
5148 else if (!strcmp (str
, "w"))
5149 inhibit_warnings
= 1;
5150 else if (!strcmp (str
, "W"))
5153 /* We save the value of warn_uninitialized, since if they put
5154 -Wuninitialized on the command line, we need to generate a
5155 warning about not using it without also specifying -O. */
5156 if (warn_uninitialized
!= 1)
5157 warn_uninitialized
= 2;
5159 else if (str
[0] == 'W')
5161 register char *p
= &str
[1];
5164 /* Some kind of -W option.
5165 P's value is the option sans `-W'.
5166 Search for it in the table of options. */
5169 !found
&& j
< sizeof (W_options
) / sizeof (W_options
[0]);
5172 if (!strcmp (p
, W_options
[j
].string
))
5174 *W_options
[j
].variable
= W_options
[j
].on_value
;
5175 /* A goto here would be cleaner,
5176 but breaks the vax pcc. */
5179 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
5180 && ! strcmp (p
+3, W_options
[j
].string
))
5182 *W_options
[j
].variable
= ! W_options
[j
].on_value
;
5189 else if (!strncmp (p
, "id-clash-", 9))
5191 const int id_clash_val
5192 = read_integral_parameter (p
+ 9, p
- 2, -1);
5193 if (id_clash_val
!= -1)
5195 id_clash_len
= id_clash_val
;
5199 else if (!strncmp (p
, "larger-than-", 12))
5201 const int larger_than_val
5202 = read_integral_parameter (p
+ 12, p
- 2, -1);
5203 if (larger_than_val
!= -1)
5205 larger_than_size
= larger_than_val
;
5206 warn_larger_than
= 1;
5210 error ("Invalid option `%s'", argv
[i
]);
5212 else if (!strcmp (str
, "p"))
5216 else if (!strcmp (str
, "a"))
5218 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5219 warning ("`-a' option (basic block profile) not supported");
5221 profile_block_flag
= (profile_block_flag
< 2) ? 1 : 3;
5224 else if (!strcmp (str
, "ax"))
5226 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5227 warning ("`-ax' option (jump profiling) not supported");
5229 profile_block_flag
= (!profile_block_flag
5230 || profile_block_flag
== 2) ? 2 : 3;
5233 else if (str
[0] == 'g')
5236 /* A lot of code assumes write_symbols == NO_DEBUG if the
5237 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
5238 of what debugging type has been selected). This records the
5239 selected type. It is an error to specify more than one
5241 static enum debug_info_type selected_debug_type
= NO_DEBUG
;
5242 /* Non-zero if debugging format has been explicitly set.
5243 -g and -ggdb don't explicitly set the debugging format so
5244 -gdwarf -g3 is equivalent to -gdwarf3. */
5245 static int type_explicitly_set_p
= 0;
5246 /* Indexed by enum debug_info_type. */
5247 static const char *debug_type_names
[] =
5249 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
5252 /* The maximum admissible debug level value. */
5253 static const unsigned max_debug_level
= 3;
5255 /* Look up STR in the table. */
5256 for (da
= debug_args
; da
->arg
; da
++)
5258 const int da_len
= strlen (da
->arg
);
5260 if (! strncmp (str
, da
->arg
, da_len
))
5262 enum debug_info_type type
= da
->debug_type
;
5263 const char *p
= str
+ da_len
;
5265 if (*p
&& (*p
< '0' || *p
> '9'))
5268 /* A debug flag without a level defaults to level 2.
5269 Note we do not want to call read_integral_parameter
5270 for that case since it will call atoi which
5273 ??? We may want to generalize the interface to
5274 read_integral_parameter to better handle this case
5275 if this case shows up often. */
5277 level
= read_integral_parameter (p
, 0,
5278 max_debug_level
+ 1);
5282 if (da_len
> 1 && *p
&& !strncmp (str
, "gdwarf", da_len
))
5284 error ("use -gdwarf -g%d for DWARF v1, level %d",
5287 error ("use -gdwarf-2 for DWARF v2");
5290 if (level
> max_debug_level
)
5292 warning ("ignoring option `%s' due to invalid debug level specification",
5294 level
= debug_info_level
;
5297 if (type
== NO_DEBUG
)
5299 type
= PREFERRED_DEBUGGING_TYPE
;
5300 if (da_len
> 1 && strncmp (str
, "ggdb", da_len
) == 0)
5302 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
5303 type
= DWARF2_DEBUG
;
5305 #ifdef DBX_DEBUGGING_INFO
5312 if (type
== NO_DEBUG
)
5313 warning ("`-%s' not supported by this configuration of GCC",
5316 /* Does it conflict with an already selected type? */
5317 if (type_explicitly_set_p
5318 /* -g/-ggdb don't conflict with anything */
5319 && da
->debug_type
!= NO_DEBUG
5320 && type
!= selected_debug_type
)
5321 warning ("`-%s' ignored, conflicts with `-g%s'",
5322 str
, debug_type_names
[(int) selected_debug_type
]);
5325 /* If the format has already been set, -g/-ggdb
5326 only change the debug level. */
5327 if (type_explicitly_set_p
5328 && da
->debug_type
== NO_DEBUG
)
5329 ; /* don't change debugging type */
5332 selected_debug_type
= type
;
5333 type_explicitly_set_p
= da
->debug_type
!= NO_DEBUG
;
5335 write_symbols
= (level
== 0
5337 : selected_debug_type
);
5338 use_gnu_debug_info_extensions
= da
->use_extensions_p
;
5339 debug_info_level
= (enum debug_info_level
) level
;
5345 warning ("`-%s' not supported by this configuration of GCC",
5348 else if (!strcmp (str
, "o"))
5350 asm_file_name
= argv
[++i
];
5352 else if (str
[0] == 'G')
5354 const int g_switch_val
= (str
[1] != '\0') ?
5355 read_integral_parameter(str
+ 1, 0, -1) :
5356 read_integral_parameter(argv
[++i
], 0, -1);
5358 if (g_switch_val
!= -1)
5360 g_switch_set
= TRUE
;
5361 g_switch_value
= g_switch_val
;
5365 error("Invalid option `-%s'",str
);
5368 else if (!strncmp (str
, "aux-info", 8))
5370 flag_gen_aux_info
= 1;
5371 aux_info_file_name
= (str
[8] != '\0' ? str
+8 : argv
[++i
]);
5373 else if (!strcmp (str
, "-help"))
5379 error ("Invalid option `%s'", argv
[i
]);
5381 else if (argv
[i
][0] == '+')
5382 error ("Invalid option `%s'", argv
[i
]);
5387 /* Checker uses the frame pointer. */
5388 if (flag_check_memory_usage
)
5389 flag_omit_frame_pointer
= 0;
5393 /* Inlining does not work if not optimizing,
5394 so force it not to be done. */
5398 /* The c_decode_option and lang_decode_option functions set
5399 this to `2' if -Wall is used, so we can avoid giving out
5400 lots of errors for people who don't realize what -Wall does. */
5401 if (warn_uninitialized
== 1)
5402 warning ("-Wuninitialized is not supported without -O");
5405 #ifdef OVERRIDE_OPTIONS
5406 /* Some machines may reject certain combinations of options. */
5410 if (exceptions_via_longjmp
== 2)
5412 #ifdef DWARF2_UNWIND_INFO
5413 exceptions_via_longjmp
= ! DWARF2_UNWIND_INFO
;
5415 exceptions_via_longjmp
= 1;
5419 /* Set up the align_*_log variables, defaulting them to 1 if they
5420 were still unset. */
5421 if (align_loops
<= 0) align_loops
= 1;
5422 align_loops_log
= floor_log2 (align_loops
*2-1);
5423 if (align_jumps
<= 0) align_jumps
= 1;
5424 align_jumps_log
= floor_log2 (align_jumps
*2-1);
5425 if (align_labels
<= 0) align_labels
= 1;
5426 align_labels_log
= floor_log2 (align_labels
*2-1);
5427 if (align_functions
<= 0) align_functions
= 1;
5428 align_functions_log
= floor_log2 (align_functions
*2-1);
5430 if (profile_block_flag
== 3)
5432 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
5433 profile_block_flag
= 2;
5436 /* Unrolling all loops implies that standard loop unrolling must also
5438 if (flag_unroll_all_loops
)
5439 flag_unroll_loops
= 1;
5440 /* Loop unrolling requires that strength_reduction be on also. Silently
5441 turn on strength reduction here if it isn't already on. Also, the loop
5442 unrolling code assumes that cse will be run after loop, so that must
5443 be turned on also. */
5444 if (flag_unroll_loops
)
5446 flag_strength_reduce
= 1;
5447 flag_rerun_cse_after_loop
= 1;
5450 /* Warn about options that are not supported on this machine. */
5451 #ifndef INSN_SCHEDULING
5452 if (flag_schedule_insns
|| flag_schedule_insns_after_reload
)
5453 warning ("instruction scheduling not supported on this target machine");
5456 if (flag_delayed_branch
)
5457 warning ("this target machine does not have delayed branches");
5460 user_label_prefix
= USER_LABEL_PREFIX
;
5461 if (flag_leading_underscore
!= -1)
5463 /* If the default prefix is more complicated than "" or "_",
5464 issue a warning and ignore this option. */
5465 if (user_label_prefix
[0] == 0 ||
5466 (user_label_prefix
[0] == '_' && user_label_prefix
[1] == 0))
5468 user_label_prefix
= flag_leading_underscore
? "_" : "";
5471 warning ("-f%sleading-underscore not supported on this target machine",
5472 flag_leading_underscore
? "" : "no-");
5475 /* If we are in verbose mode, write out the version and maybe all the
5476 option flags in use. */
5479 print_version (stderr
, "");
5481 print_switch_values (stderr
, 0, MAX_LINE
, "", " ", "\n");
5484 compile_file (filename
);
5486 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
5489 char *lim
= (char *) sbrk (0);
5491 notice ("Data size %ld.\n", (long) (lim
- (char *) &environ
));
5496 system ("ps -l 1>&2");
5499 #endif /* not USG */
5502 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
5505 exit (FATAL_EXIT_CODE
);
5507 exit (FATAL_EXIT_CODE
);
5508 exit (SUCCESS_EXIT_CODE
);
5512 /* Decode -m switches. */
5513 /* Decode the switch -mNAME. */
5516 set_target_switch (name
)
5520 int valid_target_option
= 0;
5522 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
5523 if (!strcmp (target_switches
[j
].name
, name
))
5525 if (target_switches
[j
].value
< 0)
5526 target_flags
&= ~-target_switches
[j
].value
;
5528 target_flags
|= target_switches
[j
].value
;
5529 valid_target_option
= 1;
5532 #ifdef TARGET_OPTIONS
5533 if (!valid_target_option
)
5534 for (j
= 0; j
< sizeof target_options
/ sizeof target_options
[0]; j
++)
5536 int len
= strlen (target_options
[j
].prefix
);
5537 if (!strncmp (target_options
[j
].prefix
, name
, len
))
5539 *target_options
[j
].variable
= name
+ len
;
5540 valid_target_option
= 1;
5545 if (!valid_target_option
)
5546 error ("Invalid option `%s'", name
);
5549 /* Print version information to FILE.
5550 Each line begins with INDENT (for the case where FILE is the
5551 assembler output file). */
5554 print_version (file
, indent
)
5559 #define __VERSION__ "[?]"
5563 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
5565 "%s%s%s version %s (%s) compiled by CC.\n"
5567 , indent
, *indent
!= 0 ? " " : "",
5568 language_string
, version_string
, TARGET_NAME
, __VERSION__
);
5571 /* Print an option value and return the adjusted position in the line.
5572 ??? We don't handle error returns from fprintf (disk full); presumably
5573 other code will catch a disk full though. */
5576 print_single_switch (file
, pos
, max
, indent
, sep
, term
, type
, name
)
5579 const char *indent
, *sep
, *term
, *type
, *name
;
5581 /* The ultrix fprintf returns 0 on success, so compute the result we want
5582 here since we need it for the following test. */
5583 int len
= strlen (sep
) + strlen (type
) + strlen (name
);
5588 fprintf (file
, "%s", term
);
5593 fprintf (file
, "%s", indent
);
5594 pos
= strlen (indent
);
5596 fprintf (file
, "%s%s%s", sep
, type
, name
);
5601 /* Print active target switches to FILE.
5602 POS is the current cursor position and MAX is the size of a "line".
5603 Each line begins with INDENT and ends with TERM.
5604 Each switch is separated from the next by SEP. */
5607 print_switch_values (file
, pos
, max
, indent
, sep
, term
)
5610 const char *indent
, *sep
, *term
;
5615 /* Print the options as passed. */
5617 pos
= print_single_switch (file
, pos
, max
, indent
, *indent
? " " : "", term
,
5618 _("options passed: "), "");
5620 for (p
= &save_argv
[1]; *p
!= NULL
; p
++)
5624 if (strcmp (*p
, "-o") == 0)
5630 if (strcmp (*p
, "-quiet") == 0)
5632 if (strcmp (*p
, "-version") == 0)
5637 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
, *p
, "");
5640 fprintf (file
, "%s", term
);
5642 /* Print the -f and -m options that have been enabled.
5643 We don't handle language specific options but printing argv
5646 pos
= print_single_switch (file
, 0, max
, indent
, *indent
? " " : "", term
,
5647 _("options enabled: "), "");
5649 for (j
= 0; j
< sizeof f_options
/ sizeof f_options
[0]; j
++)
5650 if (*f_options
[j
].variable
== f_options
[j
].on_value
)
5651 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5652 "-f", f_options
[j
].string
);
5654 /* Print target specific options. */
5656 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
5657 if (target_switches
[j
].name
[0] != '\0'
5658 && target_switches
[j
].value
> 0
5659 && ((target_switches
[j
].value
& target_flags
)
5660 == target_switches
[j
].value
))
5662 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5663 "-m", target_switches
[j
].name
);
5666 #ifdef TARGET_OPTIONS
5667 for (j
= 0; j
< sizeof target_options
/ sizeof target_options
[0]; j
++)
5668 if (*target_options
[j
].variable
!= NULL
)
5671 sprintf (prefix
, "-m%s", target_options
[j
].prefix
);
5672 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5673 prefix
, *target_options
[j
].variable
);
5677 fprintf (file
, "%s", term
);
5680 /* Record the beginning of a new source file, named FILENAME. */
5683 debug_start_source_file (filename
)
5684 register char *filename ATTRIBUTE_UNUSED
;
5686 #ifdef DBX_DEBUGGING_INFO
5687 if (write_symbols
== DBX_DEBUG
)
5688 dbxout_start_new_source_file (filename
);
5690 #ifdef DWARF_DEBUGGING_INFO
5691 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5692 && write_symbols
== DWARF_DEBUG
)
5693 dwarfout_start_new_source_file (filename
);
5694 #endif /* DWARF_DEBUGGING_INFO */
5695 #ifdef DWARF2_DEBUGGING_INFO
5696 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5697 && write_symbols
== DWARF2_DEBUG
)
5698 dwarf2out_start_source_file (filename
);
5699 #endif /* DWARF2_DEBUGGING_INFO */
5700 #ifdef SDB_DEBUGGING_INFO
5701 if (write_symbols
== SDB_DEBUG
)
5702 sdbout_start_new_source_file (filename
);
5706 /* Record the resumption of a source file. LINENO is the line number in
5707 the source file we are returning to. */
5710 debug_end_source_file (lineno
)
5711 register unsigned lineno ATTRIBUTE_UNUSED
;
5713 #ifdef DBX_DEBUGGING_INFO
5714 if (write_symbols
== DBX_DEBUG
)
5715 dbxout_resume_previous_source_file ();
5717 #ifdef DWARF_DEBUGGING_INFO
5718 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5719 && write_symbols
== DWARF_DEBUG
)
5720 dwarfout_resume_previous_source_file (lineno
);
5721 #endif /* DWARF_DEBUGGING_INFO */
5722 #ifdef DWARF2_DEBUGGING_INFO
5723 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5724 && write_symbols
== DWARF2_DEBUG
)
5725 dwarf2out_end_source_file ();
5726 #endif /* DWARF2_DEBUGGING_INFO */
5727 #ifdef SDB_DEBUGGING_INFO
5728 if (write_symbols
== SDB_DEBUG
)
5729 sdbout_resume_previous_source_file ();
5733 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5734 the tail part of the directive line, i.e. the part which is past the
5735 initial whitespace, #, whitespace, directive-name, whitespace part. */
5738 debug_define (lineno
, buffer
)
5739 register unsigned lineno ATTRIBUTE_UNUSED
;
5740 register char *buffer ATTRIBUTE_UNUSED
;
5742 #ifdef DWARF_DEBUGGING_INFO
5743 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5744 && write_symbols
== DWARF_DEBUG
)
5745 dwarfout_define (lineno
, buffer
);
5746 #endif /* DWARF_DEBUGGING_INFO */
5747 #ifdef DWARF2_DEBUGGING_INFO
5748 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5749 && write_symbols
== DWARF2_DEBUG
)
5750 dwarf2out_define (lineno
, buffer
);
5751 #endif /* DWARF2_DEBUGGING_INFO */
5754 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5755 the tail part of the directive line, i.e. the part which is past the
5756 initial whitespace, #, whitespace, directive-name, whitespace part. */
5759 debug_undef (lineno
, buffer
)
5760 register unsigned lineno ATTRIBUTE_UNUSED
;
5761 register char *buffer ATTRIBUTE_UNUSED
;
5763 #ifdef DWARF_DEBUGGING_INFO
5764 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5765 && write_symbols
== DWARF_DEBUG
)
5766 dwarfout_undef (lineno
, buffer
);
5767 #endif /* DWARF_DEBUGGING_INFO */
5768 #ifdef DWARF2_DEBUGGING_INFO
5769 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5770 && write_symbols
== DWARF2_DEBUG
)
5771 dwarf2out_undef (lineno
, buffer
);
5772 #endif /* DWARF2_DEBUGGING_INFO */