1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This is the top level of cc1/c++.
22 It parses command args, opens files, invokes the various passes
23 in the proper order, and counts the time used by each.
24 Error messages and low-level interface to malloc also handled here. */
27 #undef FLOAT /* This is for hpux. They should change hpux. */
28 #undef FFS /* Some systems define this in param.h. */
33 #ifdef HAVE_SYS_RESOURCE_H
34 # include <sys/resource.h>
37 #ifdef HAVE_SYS_TIMES_H
38 # include <sys/times.h>
46 #include "insn-attr.h"
47 #include "insn-codes.h"
48 #include "insn-config.h"
56 #include "basic-block.h"
61 #ifdef DWARF_DEBUGGING_INFO
65 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
66 #include "dwarf2out.h"
69 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
73 #ifdef SDB_DEBUGGING_INFO
77 #ifdef XCOFF_DEBUGGING_INFO
82 /* The extra parameters substantially improve the I/O performance. */
84 vms_fopen (fname
, type
)
88 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
89 fixed arguments, which matches ANSI's specification but not VAXCRTL's
90 pre-ANSI implementation. This hack circumvents the mismatch problem. */
91 FILE *(*vmslib_fopen
)() = (FILE *(*)()) fopen
;
94 return (*vmslib_fopen
) (fname
, type
, "mbc=32",
95 "deq=64", "fop=tef", "shr=nil");
97 return (*vmslib_fopen
) (fname
, type
, "mbc=32");
99 #define fopen vms_fopen
102 #ifndef DEFAULT_GDB_EXTENSIONS
103 #define DEFAULT_GDB_EXTENSIONS 1
106 /* If more than one debugging type is supported, you must define
107 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
109 This is one long line cause VAXC can't handle a \-newline. */
110 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
111 #ifndef PREFERRED_DEBUGGING_TYPE
112 You Lose
! You must define PREFERRED_DEBUGGING_TYPE
!
113 #endif /* no PREFERRED_DEBUGGING_TYPE */
114 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
115 so the following code needn't care. */
116 #ifdef DBX_DEBUGGING_INFO
117 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
119 #ifdef SDB_DEBUGGING_INFO
120 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
122 #ifdef DWARF_DEBUGGING_INFO
123 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
125 #ifdef DWARF2_DEBUGGING_INFO
126 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
128 #ifdef XCOFF_DEBUGGING_INFO
129 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
131 #endif /* More than one debugger format enabled. */
133 /* If still not defined, must have been because no debugging formats
135 #ifndef PREFERRED_DEBUGGING_TYPE
136 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
139 #ifndef DIR_SEPARATOR
140 #define DIR_SEPARATOR '/'
143 #if ! (defined (VMS) || defined (OS2))
144 extern char **environ
;
146 extern char *version_string
;
148 /* Carry information from ASM_DECLARE_OBJECT_NAME
149 to ASM_FINISH_DECLARE_OBJECT. */
151 extern int size_directive_output
;
152 extern tree last_assemble_variable_decl
;
154 static void notice
PVPROTO((const char *s
, ...)) ATTRIBUTE_PRINTF_1
;
155 static void set_target_switch
PROTO((const char *));
156 static const char *decl_name
PROTO((tree
, int));
157 static void vmessage
PROTO((const char *, const char *, va_list));
158 static void v_message_with_file_and_line
PROTO((const char *, int, int,
159 const char *, va_list));
160 static void v_message_with_decl
PROTO((tree
, int, const char *, va_list));
161 static void file_and_line_for_asm
PROTO((rtx
, char **, int *));
162 static void v_error_with_file_and_line
PROTO((const char *, int,
163 const char *, va_list));
164 static void v_error_with_decl
PROTO((tree
, const char *, va_list));
165 static void v_error_for_asm
PROTO((rtx
, const char *, va_list));
166 static void verror
PROTO((const char *, va_list));
167 static void vfatal
PROTO((const char *, va_list)) ATTRIBUTE_NORETURN
;
168 static void v_warning_with_file_and_line
PROTO ((const char *, int,
169 const char *, va_list));
170 static void v_warning_with_decl
PROTO((tree
, const char *, va_list));
171 static void v_warning_for_asm
PROTO((rtx
, const char *, va_list));
172 static void vwarning
PROTO((const char *, va_list));
173 static void vpedwarn
PROTO((const char *, va_list));
174 static void v_pedwarn_with_decl
PROTO((tree
, const char *, va_list));
175 static void v_pedwarn_with_file_and_line
PROTO((const char *, int,
176 const char *, va_list));
177 static void vsorry
PROTO((const char *, va_list));
178 extern void set_fatal_function
PROTO((void (*)(const char *, va_list)));
179 static void float_signal
PROTO((int)) ATTRIBUTE_NORETURN
;
180 static void pipe_closed
PROTO((int)) ATTRIBUTE_NORETURN
;
181 #ifdef ASM_IDENTIFY_LANGUAGE
182 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
183 static void output_lang_identify
PROTO((FILE *)) ATTRIBUTE_UNUSED
;
185 static void open_dump_file
PROTO((const char *, const char *));
186 static void close_dump_file
PROTO((void (*) (FILE *, rtx
), rtx
));
187 static void dump_rtl
PROTO((const char *, tree
, void (*) (FILE *, rtx
), rtx
));
188 static void clean_dump_file
PROTO((const char *));
189 static void compile_file
PROTO((char *));
190 static void display_help
PROTO ((void));
191 static void report_file_and_line
PROTO ((const char *, int, int));
192 static void vnotice
PROTO ((FILE *, const char *, va_list));
193 static void mark_file_stack
PROTO ((void *));
195 static void decode_d_option
PROTO ((const char *));
196 static int decode_f_option
PROTO ((const char *));
197 static int decode_W_option
PROTO ((const char *));
198 static int decode_g_option
PROTO ((const char *));
199 static unsigned independent_decode_option
PROTO ((int, char **, unsigned));
201 static void print_version
PROTO((FILE *, const char *));
202 static int print_single_switch
PROTO((FILE *, int, int, const char *,
203 const char *, const char *,
204 const char *, const char *));
205 static void print_switch_values
PROTO((FILE *, int, int, const char *,
206 const char *, const char *));
208 /* Length of line when printing switch values. */
211 /* Name of program invoked, sans directories. */
213 const char *progname
;
215 /* Copy of arguments to main. */
219 /* Name of current original source file (what was input to cpp).
220 This comes from each #-command in the actual input. */
222 char *input_filename
;
224 /* Name of top-level original source file (what was input to cpp).
225 This comes from the #-command at the beginning of the actual input.
226 If there isn't any there, then this is the cc1 input file name. */
228 char *main_input_filename
;
230 /* Current line number in real source file. */
234 /* Nonzero if it is unsafe to create any new pseudo registers. */
237 /* Stack of currently pending input files. */
239 struct file_stack
*input_file_stack
;
241 /* Incremented on each change to input_file_stack. */
242 int input_file_stack_tick
;
244 /* Name to use as base of names for dump output files. */
246 const char *dump_base_name
;
248 /* Bit flags that specify the machine subtype we are compiling for.
249 Bits are tested using macros TARGET_... defined in the tm.h file
250 and set by `-m...' switches. Must be defined in rtlanal.c. */
252 extern int target_flags
;
254 /* Flags saying which kinds of debugging dump have been requested. */
257 int rtl_dump_and_exit
= 0;
258 int jump_opt_dump
= 0;
259 int addressof_dump
= 0;
264 int branch_prob_dump
= 0;
266 int combine_dump
= 0;
267 int regmove_dump
= 0;
269 int local_reg_dump
= 0;
270 int global_reg_dump
= 0;
272 int peephole2_dump
= 0;
274 int jump2_opt_dump
= 0;
276 int dbr_sched_dump
= 0;
278 int flag_print_asm_name
= 0;
280 int stack_reg_dump
= 0;
282 #ifdef MACHINE_DEPENDENT_REORG
283 int mach_dep_reorg_dump
= 0;
285 static int flag_print_mem
= 0;
286 static int version_flag
= 0;
287 static char * filename
= 0;
288 enum graph_dump_types graph_dump_format
;
290 /* Name for output file of assembly code, specified with -o. */
294 /* Value of the -G xx switch, and whether it was passed or not. */
298 /* Type(s) of debugging information we are producing (if any).
299 See flags.h for the definitions of the different possible
300 types of debugging information. */
301 enum debug_info_type write_symbols
= NO_DEBUG
;
303 /* Level of debugging information we are producing. See flags.h
304 for the definitions of the different possible levels. */
305 enum debug_info_level debug_info_level
= DINFO_LEVEL_NONE
;
307 /* Nonzero means use GNU-only extensions in the generated symbolic
308 debugging information. */
309 /* Currently, this only has an effect when write_symbols is set to
310 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
311 int use_gnu_debug_info_extensions
= 0;
313 /* Nonzero means do optimizations. -O.
314 Particular numeric values stand for particular amounts of optimization;
315 thus, -O2 stores 2 here. However, the optimizations beyond the basic
316 ones are not controlled directly by this variable. Instead, they are
317 controlled by individual `flag_...' variables that are defaulted
318 based on this variable. */
322 /* Nonzero means optimize for size. -Os.
323 The only valid values are zero and non-zero. When optimize_size is
324 non-zero, optimize defaults to 2, but certain individual code
325 bloating optimizations are disabled. */
327 int optimize_size
= 0;
329 /* Number of error messages and warning messages so far. */
332 int warningcount
= 0;
335 /* Pointer to function to compute the name to use to print a declaration.
336 DECL is the declaration in question.
337 VERBOSITY determines what information will be printed:
338 0: DECL_NAME, demangled as necessary.
339 1: and scope information.
340 2: and any other information that might be interesting, such as function
341 parameter types in C++. */
343 const char *(*decl_printable_name
) PROTO ((tree
, int));
345 /* Pointer to function to compute rtl for a language-specific tree code. */
347 typedef rtx (*lang_expand_expr_t
)
348 PROTO ((union tree_node
*, rtx
, enum machine_mode
,
349 enum expand_modifier modifier
));
351 lang_expand_expr_t lang_expand_expr
= 0;
353 tree (*lang_expand_constant
) PROTO((tree
)) = 0;
355 /* Pointer to function to finish handling an incomplete decl at the
356 end of compilation. */
358 void (*incomplete_decl_finalize_hook
) PROTO((tree
)) = 0;
360 /* Nonzero if generating code to do profiling. */
362 int profile_flag
= 0;
364 /* Nonzero if generating code to do profiling on a line-by-line basis. */
366 int profile_block_flag
;
368 /* Nonzero if generating code to profile program flow graph arcs. */
370 int profile_arc_flag
= 0;
372 /* Nonzero if generating info for gcov to calculate line test coverage. */
374 int flag_test_coverage
= 0;
376 /* Nonzero indicates that branch taken probabilities should be calculated. */
378 int flag_branch_probabilities
= 0;
380 /* Nonzero for -pedantic switch: warn about anything
381 that standard spec forbids. */
385 /* Temporarily suppress certain warnings.
386 This is set while reading code from a system header file. */
388 int in_system_header
= 0;
390 /* Nonzero means do stupid register allocation.
391 Currently, this is 1 if `optimize' is 0. */
393 int obey_regdecls
= 0;
395 /* Don't print functions as they are compiled and don't print
396 times taken by the various passes. -quiet. */
402 /* Nonzero means `char' should be signed. */
404 int flag_signed_char
;
406 /* Nonzero means give an enum type only as many bytes as it needs. */
408 int flag_short_enums
;
410 /* Nonzero for -fcaller-saves: allocate values in regs that need to
411 be saved across function calls, if that produces overall better code.
412 Optional now, so people can test it. */
414 #ifdef DEFAULT_CALLER_SAVES
415 int flag_caller_saves
= 1;
417 int flag_caller_saves
= 0;
420 /* Nonzero if structures and unions should be returned in memory.
422 This should only be defined if compatibility with another compiler or
423 with an ABI is needed, because it results in slower code. */
425 #ifndef DEFAULT_PCC_STRUCT_RETURN
426 #define DEFAULT_PCC_STRUCT_RETURN 1
429 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
431 int flag_pcc_struct_return
= DEFAULT_PCC_STRUCT_RETURN
;
433 /* Nonzero for -fforce-mem: load memory value into a register
434 before arithmetic on it. This makes better cse but slower compilation. */
436 int flag_force_mem
= 0;
438 /* Nonzero for -fforce-addr: load memory address into a register before
439 reference to memory. This makes better cse but slower compilation. */
441 int flag_force_addr
= 0;
443 /* Nonzero for -fdefer-pop: don't pop args after each function call;
444 instead save them up to pop many calls' args with one insns. */
446 int flag_defer_pop
= 0;
448 /* Nonzero for -ffloat-store: don't allocate floats and doubles
449 in extended-precision registers. */
451 int flag_float_store
= 0;
453 /* Nonzero for -fcse-follow-jumps:
454 have cse follow jumps to do a more extensive job. */
456 int flag_cse_follow_jumps
;
458 /* Nonzero for -fcse-skip-blocks:
459 have cse follow a branch around a block. */
460 int flag_cse_skip_blocks
;
462 /* Nonzero for -fexpensive-optimizations:
463 perform miscellaneous relatively-expensive optimizations. */
464 int flag_expensive_optimizations
;
466 /* Nonzero for -fthread-jumps:
467 have jump optimize output of loop. */
469 int flag_thread_jumps
;
471 /* Nonzero enables strength-reduction in loop.c. */
473 int flag_strength_reduce
= 0;
475 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
476 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
477 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
480 int flag_unroll_loops
;
482 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
483 This is generally not a win. */
485 int flag_unroll_all_loops
;
487 /* Nonzero forces all invariant computations in loops to be moved
490 int flag_move_all_movables
= 0;
492 /* Nonzero forces all general induction variables in loops to be
495 int flag_reduce_all_givs
= 0;
497 /* Nonzero to perform full register move optimization passes. This is the
500 int flag_regmove
= 0;
502 /* Nonzero for -fwritable-strings:
503 store string constants in data segment and don't uniquize them. */
505 int flag_writable_strings
= 0;
507 /* Nonzero means don't put addresses of constant functions in registers.
508 Used for compiling the Unix kernel, where strange substitutions are
509 done on the assembly output. */
511 int flag_no_function_cse
= 0;
513 /* Nonzero for -fomit-frame-pointer:
514 don't make a frame pointer in simple functions that don't require one. */
516 int flag_omit_frame_pointer
= 0;
518 /* Nonzero means place each function into its own section on those platforms
519 which support arbitrary section names and unlimited numbers of sections. */
521 int flag_function_sections
= 0;
523 /* ... and similar for data. */
525 int flag_data_sections
= 0;
527 /* Nonzero to inhibit use of define_optimization peephole opts. */
529 int flag_no_peephole
= 0;
531 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
532 operations in the interest of optimization. For example it allows
533 GCC to assume arguments to sqrt are nonnegative numbers, allowing
534 faster code for sqrt to be generated. */
536 int flag_fast_math
= 0;
538 /* Nonzero means the front end generally wants `errno' maintained by math
539 operations, like built-in SQRT, unless overridden by flag_fast_math. */
541 int flag_errno_math
= 1;
543 /* 0 means straightforward implementation of complex divide acceptable.
544 1 means wide ranges of inputs must work for complex divide.
545 2 means C9X-like requirements for complex divide (not yet implemented). */
547 int flag_complex_divide_method
= 0;
549 /* Nonzero means all references through pointers are volatile. */
553 /* Nonzero means treat all global and extern variables as volatile. */
555 int flag_volatile_global
;
557 /* Nonzero means treat all static variables as volatile. */
559 int flag_volatile_static
;
561 /* Nonzero means just do syntax checking; don't output anything. */
563 int flag_syntax_only
= 0;
565 /* Nonzero means perform global cse. */
567 static int flag_gcse
;
569 /* Nonzero means to use global dataflow analysis to eliminate
570 useless null pointer tests. */
572 static int flag_delete_null_pointer_checks
;
574 /* Nonzero means to rerun cse after loop optimization. This increases
575 compilation time about 20% and picks up a few more common expressions. */
577 static int flag_rerun_cse_after_loop
;
579 /* Nonzero means to run loop optimizations twice. */
581 int flag_rerun_loop_opt
;
583 /* Nonzero for -finline-functions: ok to inline functions that look like
584 good inline candidates. */
586 int flag_inline_functions
;
588 /* Nonzero for -fkeep-inline-functions: even if we make a function
589 go inline everywhere, keep its definition around for debugging
592 int flag_keep_inline_functions
;
594 /* Nonzero means that functions will not be inlined. */
598 /* Nonzero means that we should emit static const variables
599 regardless of whether or not optimization is turned on. */
601 int flag_keep_static_consts
= 1;
603 /* Nonzero means we should be saving declaration info into a .X file. */
605 int flag_gen_aux_info
= 0;
607 /* Specified name of aux-info file. */
609 static char *aux_info_file_name
;
611 /* Nonzero means make the text shared if supported. */
613 int flag_shared_data
;
615 /* Nonzero means schedule into delayed branch slots if supported. */
617 int flag_delayed_branch
;
619 /* Nonzero if we are compiling pure (sharable) code.
620 Value is 1 if we are doing reasonable (i.e. simple
621 offset into offset table) pic. Value is 2 if we can
622 only perform register offsets. */
626 /* Nonzero means generate extra code for exception handling and enable
627 exception handling. */
631 /* Nonzero means use the new model for exception handling. Replaces
632 -DNEW_EH_MODEL as a compile option. */
634 int flag_new_exceptions
= 1;
636 /* Nonzero means don't place uninitialized global data in common storage
641 /* Nonzero means pretend it is OK to examine bits of target floats,
642 even if that isn't true. The resulting code will have incorrect constants,
643 but the same series of instructions that the native compiler would make. */
645 int flag_pretend_float
;
647 /* Nonzero means change certain warnings into errors.
648 Usually these are warnings about failure to conform to some standard. */
650 int flag_pedantic_errors
= 0;
652 /* flag_schedule_insns means schedule insns within basic blocks (before
654 flag_schedule_insns_after_reload means schedule insns after
657 int flag_schedule_insns
= 0;
658 int flag_schedule_insns_after_reload
= 0;
660 /* The following flags have effect only for scheduling before register
663 flag_schedule_interblock means schedule insns accross basic blocks.
664 flag_schedule_speculative means allow speculative motion of non-load insns.
665 flag_schedule_speculative_load means allow speculative motion of some
667 flag_schedule_speculative_load_dangerous allows speculative motion of more
670 int flag_schedule_interblock
= 1;
671 int flag_schedule_speculative
= 1;
672 int flag_schedule_speculative_load
= 0;
673 int flag_schedule_speculative_load_dangerous
= 0;
675 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
676 by a cheaper branch, on a count register. */
677 int flag_branch_on_count_reg
;
679 /* -finhibit-size-directive inhibits output of .size for ELF.
680 This is used only for compiling crtstuff.c,
681 and it may be extended to other effects
682 needed for crtstuff.c on other systems. */
683 int flag_inhibit_size_directive
= 0;
685 /* -fverbose-asm causes extra commentary information to be produced in
686 the generated assembly code (to make it more readable). This option
687 is generally only of use to those who actually need to read the
688 generated assembly code (perhaps while debugging the compiler itself).
689 -fno-verbose-asm, the default, causes the extra information
690 to be omitted and is useful when comparing two assembler files. */
692 int flag_verbose_asm
= 0;
694 /* -dA causes debug commentary information to be produced in
695 the generated assembly code (to make it more readable). This option
696 is generally only of use to those who actually need to read the
697 generated assembly code (perhaps while debugging the compiler itself).
698 Currently, this switch is only used by dwarfout.c; however, it is intended
699 to be a catchall for printing debug information in the assembler file. */
701 int flag_debug_asm
= 0;
703 /* -fgnu-linker specifies use of the GNU linker for initializations.
704 (Or, more generally, a linker that handles initializations.)
705 -fno-gnu-linker says that collect2 will be used. */
707 int flag_gnu_linker
= 0;
709 int flag_gnu_linker
= 1;
712 /* Tag all structures with __attribute__(packed) */
713 int flag_pack_struct
= 0;
715 /* Emit code to check for stack overflow; also may cause large objects
716 to be allocated dynamically. */
717 int flag_stack_check
;
719 /* -fcheck-memory-usage causes extra code to be generated in order to check
720 memory accesses. This is used by a detector of bad memory accesses such
722 int flag_check_memory_usage
= 0;
724 /* -fprefix-function-name causes function name to be prefixed. This
725 can be used with -fcheck-memory-usage to isolate code compiled with
726 -fcheck-memory-usage. */
727 int flag_prefix_function_name
= 0;
729 /* 0 if pointer arguments may alias each other. True in C.
730 1 if pointer arguments may not alias each other but may alias
732 2 if pointer arguments may not alias each other and may not
733 alias global variables. True in Fortran.
734 This defaults to 0 for C. */
735 int flag_argument_noalias
= 0;
737 /* Nonzero if we should do (language-dependent) alias analysis.
738 Typically, this analysis will assume that expressions of certain
739 types do not alias expressions of certain other types. Only used
740 if alias analysis (in general) is enabled. */
741 int flag_strict_aliasing
= 0;
743 /* Instrument functions with calls at entry and exit, for profiling. */
744 int flag_instrument_function_entry_exit
= 0;
746 /* Nonzero means ignore `#ident' directives. 0 means handle them.
747 On SVR4 targets, it also controls whether or not to emit a
748 string identifying the compiler. */
750 int flag_no_ident
= 0;
752 /* This will perform a peephole pass before sched2. */
753 int flag_peephole2
= 0;
755 /* Values of the -falign-* flags: how much to align labels in code.
756 0 means `use default', 1 means `don't align'.
757 For each variable, there is an _log variant which is the power
758 of two not less than the variable, for .align output. */
765 int align_labels_log
;
767 int align_functions_log
;
769 /* Table of supported debugging formats. */
773 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
774 constant expression, we use NO_DEBUG in its place. */
775 enum debug_info_type debug_type
;
776 int use_extensions_p
;
777 const char * description
;
781 { "", NO_DEBUG
, DEFAULT_GDB_EXTENSIONS
,
782 "Generate default debug format output" },
783 { "gdb", NO_DEBUG
, 1, "Generate default extended debug format output" },
784 #ifdef DBX_DEBUGGING_INFO
785 { "stabs", DBX_DEBUG
, 0, "Generate STABS format debug output" },
786 { "stabs+", DBX_DEBUG
, 1, "Generate extended STABS format debug output" },
788 #ifdef DWARF_DEBUGGING_INFO
789 { "dwarf", DWARF_DEBUG
, 0, "Generate DWARF-1 format debug output"},
790 { "dwarf+", DWARF_DEBUG
, 1,
791 "Generated extended DWARF-1 format debug output" },
793 #ifdef DWARF2_DEBUGGING_INFO
794 { "dwarf-2", DWARF2_DEBUG
, 0, "Enable DWARF-2 debug output" },
796 #ifdef XCOFF_DEBUGGING_INFO
797 { "xcoff", XCOFF_DEBUG
, 0, "Generate XCOFF format debug output" },
798 { "xcoff+", XCOFF_DEBUG
, 1, "Generate extended XCOFF format debug output" },
800 #ifdef SDB_DEBUGGING_INFO
801 { "coff", SDB_DEBUG
, 0, "Generate COFF format debug output" },
811 const char * description
;
813 lang_independent_options
;
815 /* Add or remove a leading underscore from user symbols. */
816 int flag_leading_underscore
= -1;
818 /* The user symbol prefix after having resolved same. */
819 const char *user_label_prefix
;
821 /* A default for same. */
822 #ifndef USER_LABEL_PREFIX
823 #define USER_LABEL_PREFIX ""
826 /* Table of language-independent -f options.
827 STRING is the option name. VARIABLE is the address of the variable.
828 ON_VALUE is the value to store in VARIABLE
829 if `-fSTRING' is seen as an option.
830 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
832 lang_independent_options f_options
[] =
834 {"float-store", &flag_float_store
, 1,
835 "Do not store floats in registers" },
836 {"volatile", &flag_volatile
, 1,
837 "Consider all mem refs through pointers as volatile"},
838 {"volatile-global", &flag_volatile_global
, 1,
839 "Consider all mem refs to global data to be volatile" },
840 {"volatile-static", &flag_volatile_static
, 1,
841 "Consider all mem refs to static data to be volatile" },
842 {"defer-pop", &flag_defer_pop
, 1,
843 "Defer popping functions args from stack until later" },
844 {"omit-frame-pointer", &flag_omit_frame_pointer
, 1,
845 "When possible do not generate stack frames"},
846 {"cse-follow-jumps", &flag_cse_follow_jumps
, 1,
847 "When running CSE, follow jumps to their targets" },
848 {"cse-skip-blocks", &flag_cse_skip_blocks
, 1,
849 "When running CSE, follow conditional jumps" },
850 {"expensive-optimizations", &flag_expensive_optimizations
, 1,
851 "Perform a number of minor, expensive optimisations" },
852 {"thread-jumps", &flag_thread_jumps
, 1,
853 "Perform jump threading optimisations"},
854 {"strength-reduce", &flag_strength_reduce
, 1,
855 "Perform strength reduction optimisations" },
856 {"unroll-loops", &flag_unroll_loops
, 1,
857 "Perform loop unrolling when iteration count is known" },
858 {"unroll-all-loops", &flag_unroll_all_loops
, 1,
859 "Perform loop unrolling for all loops" },
860 {"move-all-movables", &flag_move_all_movables
, 1,
861 "Force all loop invariant computations out of loops" },
862 {"reduce-all-givs", &flag_reduce_all_givs
, 1,
863 "Strength reduce all loop general induction variables" },
864 {"writable-strings", &flag_writable_strings
, 1,
865 "Store strings in writable data section" },
866 {"peephole", &flag_no_peephole
, 0,
867 "Enable machine specific peephole optimisations" },
868 {"force-mem", &flag_force_mem
, 1,
869 "Copy memory operands into registers before using" },
870 {"force-addr", &flag_force_addr
, 1,
871 "Copy memory address constants into regs before using" },
872 {"function-cse", &flag_no_function_cse
, 0,
873 "Allow function addresses to be held in registers" },
874 {"inline-functions", &flag_inline_functions
, 1,
875 "Integrate simple functions into their callers" },
876 {"keep-inline-functions", &flag_keep_inline_functions
, 1,
877 "Generate code for funcs even if they are fully inlined" },
878 {"inline", &flag_no_inline
, 0,
879 "Pay attention to the 'inline' keyword"},
880 {"keep-static-consts", &flag_keep_static_consts
, 1,
881 "Emit static const variables even if they are not used" },
882 {"syntax-only", &flag_syntax_only
, 1,
883 "Check for syntax errors, then stop" },
884 {"shared-data", &flag_shared_data
, 1,
885 "Mark data as shared rather than private" },
886 {"caller-saves", &flag_caller_saves
, 1,
887 "Enable saving registers around function calls" },
888 {"pcc-struct-return", &flag_pcc_struct_return
, 1,
889 "Return 'short' aggregates in memory, not registers" },
890 {"reg-struct-return", &flag_pcc_struct_return
, 0,
891 "Return 'short' aggregates in registers" },
892 {"delayed-branch", &flag_delayed_branch
, 1,
893 "Attempt to fill delay slots of branch instructions" },
894 {"gcse", &flag_gcse
, 1,
895 "Perform the global common subexpression elimination" },
896 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop
, 1,
897 "Run CSE pass after loop optimisations"},
898 {"rerun-loop-opt", &flag_rerun_loop_opt
, 1,
899 "Run the loop optimiser twice"},
900 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks
, 1,
901 "Delete useless null pointer checks" },
902 {"pretend-float", &flag_pretend_float
, 1,
903 "Pretend that host and target use the same FP format"},
904 {"schedule-insns", &flag_schedule_insns
, 1,
905 "Reschedule instructions to avoid pipeline stalls"},
906 {"schedule-insns2", &flag_schedule_insns_after_reload
, 1,
907 "Run two passes of the instruction scheduler"},
908 {"sched-interblock",&flag_schedule_interblock
, 1,
909 "Enable scheduling across basic blocks" },
910 {"sched-spec",&flag_schedule_speculative
, 1,
911 "Allow speculative motion of non-loads" },
912 {"sched-spec-load",&flag_schedule_speculative_load
, 1,
913 "Allow speculative motion of some loads" },
914 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous
, 1,
915 "Allow speculative motion of more loads" },
916 {"branch-count-reg",&flag_branch_on_count_reg
, 1,
917 "Replace add,compare,branch with branch on count reg"},
918 {"pic", &flag_pic
, 1,
919 "Generate position independent code, if possible"},
920 {"PIC", &flag_pic
, 2, ""},
921 {"exceptions", &flag_exceptions
, 1,
922 "Enable exception handling" },
923 {"new-exceptions", &flag_new_exceptions
, 1,
924 "Use the new model for exception handling" },
925 {"sjlj-exceptions", &exceptions_via_longjmp
, 1,
926 "Use setjmp/longjmp to handle exceptions" },
927 {"asynchronous-exceptions", &asynchronous_exceptions
, 1,
928 "Support asynchronous exceptions" },
929 {"profile-arcs", &profile_arc_flag
, 1,
930 "Insert arc based program profiling code" },
931 {"test-coverage", &flag_test_coverage
, 1,
932 "Create data files needed by gcov" },
933 {"branch-probabilities", &flag_branch_probabilities
, 1,
934 "Use profiling information for branch probabilities" },
935 {"fast-math", &flag_fast_math
, 1,
936 "Improve FP speed by violating ANSI & IEEE rules" },
937 {"common", &flag_no_common
, 0,
938 "Do not put unitialised globals in the common section" },
939 {"inhibit-size-directive", &flag_inhibit_size_directive
, 1,
940 "Do not generate .size directives" },
941 {"function-sections", &flag_function_sections
, 1,
942 "place each function into its own section" },
943 {"data-sections", &flag_data_sections
, 1,
944 "place data items into their own section" },
945 {"verbose-asm", &flag_verbose_asm
, 1,
946 "Add extra commentry to assembler output"},
947 {"gnu-linker", &flag_gnu_linker
, 1,
948 "Output GNU ld formatted global initialisers"},
949 {"regmove", &flag_regmove
, 1,
950 "Enables a register move optimisation"},
951 {"optimize-register-move", &flag_regmove
, 1,
952 "Do the full regmove optimization pass"},
953 {"pack-struct", &flag_pack_struct
, 1,
954 "Pack structure members together without holes" },
955 {"stack-check", &flag_stack_check
, 1,
956 "Insert stack checking code into the program" },
957 {"argument-alias", &flag_argument_noalias
, 0,
958 "Specify that arguments may alias each other & globals"},
959 {"argument-noalias", &flag_argument_noalias
, 1,
960 "Assume arguments may alias globals but not each other"},
961 {"argument-noalias-global", &flag_argument_noalias
, 2,
962 "Assume arguments do not alias each other or globals" },
963 {"strict-aliasing", &flag_strict_aliasing
, 1,
964 "Assume strict aliasing rules apply" },
965 {"align-loops", &align_loops
, 0,
966 "Align the start of loops" },
967 {"align-jumps", &align_jumps
, 0,
968 "Align labels which are only reached by jumping" },
969 {"align-labels", &align_labels
, 0,
970 "Align all labels" },
971 {"align-functions", &align_functions
, 0,
972 "Align the start of functions" },
973 {"check-memory-usage", &flag_check_memory_usage
, 1,
974 "Generate code to check every memory access" },
975 {"prefix-function-name", &flag_prefix_function_name
, 1,
976 "Add a prefix to all function names" },
977 {"dump-unnumbered", &flag_dump_unnumbered
, 1,
978 "Suppress output of instruction numbers and line number notes in debugging dumps"},
979 {"instrument-functions", &flag_instrument_function_entry_exit
, 1,
980 "Instrument function entry/exit with profiling calls"},
981 {"leading-underscore", &flag_leading_underscore
, 1,
982 "External symbols have a leading underscore" },
983 {"ident", &flag_no_ident
, 0,
984 "Process #ident directives"},
985 { "peephole2", &flag_peephole2
, 1,
986 "Enables an rtl peephole pass run before sched2" },
987 {"math-errno", &flag_errno_math
, 1,
988 "Set errno after built-in math functions"}
991 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
993 /* Table of language-specific options. */
995 static struct lang_opt
998 const char * description
;
1000 documented_lang_options
[] =
1002 /* In order not to overload the --help output, the convention
1003 used here is to only describe those options which are not
1004 enabled by default. */
1006 { "-ansi", "Compile just for ANSI C" },
1007 { "-fallow-single-precision",
1008 "Do not promote floats to double if using -traditional" },
1009 { "-std= ", "Determine language standard"},
1011 { "-fsigned-bitfields", "" },
1012 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1013 { "-fno-signed-bitfields", "" },
1014 { "-fno-unsigned-bitfields","" },
1015 { "-fsigned-char", "Make 'char' be signed by default"},
1016 { "-funsigned-char", "Make 'char' be unsigned by default"},
1017 { "-fno-signed-char", "" },
1018 { "-fno-unsigned-char", "" },
1020 { "-ftraditional", "" },
1021 { "-traditional", "Attempt to support traditional K&R style C"},
1022 { "-fnotraditional", "" },
1023 { "-fno-traditional", "" },
1026 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1027 { "-fbuiltin", "" },
1028 { "-fno-builtin", "Do not recognise any built in functions" },
1029 { "-fhosted", "Assume normal C execution environment" },
1030 { "-fno-hosted", "" },
1032 "Assume that standard libraries & main might not exist" },
1033 { "-fno-freestanding", "" },
1034 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1035 { "-fno-cond-mismatch", "" },
1036 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1037 { "-fno-dollars-in-identifiers", "" },
1038 { "-fpreprocessed", "" },
1039 { "-fno-preprocessed", "" },
1040 { "-fshort-double", "Use the same size for double as for float" },
1041 { "-fno-short-double", "" },
1042 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1043 { "-fno-short-enums", "" },
1044 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1045 { "-fno-short-wchar", "" },
1047 { "-Wall", "Enable most warning messages" },
1048 { "-Wbad-function-cast",
1049 "Warn about casting functions to incompatible types" },
1050 { "-Wno-bad-function-cast", "" },
1051 { "-Wmissing-noreturn",
1052 "Warn about functions which might be candidates for attribute noreturn" },
1053 { "-Wno-missing-noreturn", "" },
1054 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1055 { "-Wno-cast-qual", "" },
1056 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1057 { "-Wno-char-subscripts", "" },
1058 { "-Wcomment", "Warn if nested comments are detected" },
1059 { "-Wno-comment", "" },
1060 { "-Wcomments", "Warn if nested comments are detected" },
1061 { "-Wno-comments", "" },
1062 { "-Wconversion", "Warn about possibly confusing type conversions" },
1063 { "-Wno-conversion", "" },
1064 { "-Wformat", "Warn about printf format anomalies" },
1065 { "-Wno-format", "" },
1066 { "-Wimplicit-function-declaration",
1067 "Warn about implicit function declarations" },
1068 { "-Wno-implicit-function-declaration", "" },
1069 { "-Werror-implicit-function-declaration", "" },
1070 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1071 { "-Wno-implicit-int", "" },
1072 { "-Wimplicit", "" },
1073 { "-Wno-implicit", "" },
1074 { "-Wimport", "Warn about the use of the #import directive" },
1075 { "-Wno-import", "" },
1076 { "-Wlong-long","" },
1077 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1078 { "-Wmain", "Warn about suspicious declarations of main" },
1079 { "-Wno-main", "" },
1080 { "-Wmissing-braces",
1081 "Warn about possibly missing braces around initialisers" },
1082 { "-Wno-missing-braces", "" },
1083 { "-Wmissing-declarations",
1084 "Warn about global funcs without previous declarations"},
1085 { "-Wno-missing-declarations", "" },
1086 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1087 { "-Wno-missing-prototypes", "" },
1088 { "-Wmultichar", "Warn about use of multicharacter literals"},
1089 { "-Wno-multichar", "" },
1090 { "-Wnested-externs", "Warn about externs not at file scope level" },
1091 { "-Wno-nested-externs", "" },
1092 { "-Wparentheses", "Warn about possible missing parentheses" },
1093 { "-Wno-parentheses", "" },
1094 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1095 { "-Wno-pointer-arith", "" },
1096 { "-Wredundant-decls",
1097 "Warn about multiple declarations of the same object" },
1098 { "-Wno-redundant-decls", "" },
1099 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1100 { "-Wno-sign-compare", "" },
1101 { "-Wfloat-equal", "Warn about testing equality of floating point numbers" },
1102 { "-Wno-float-equal", "" },
1103 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1104 { "-Wno-unknown-pragmas", "" },
1105 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1106 { "-Wno-strict-prototypes", "" },
1107 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1108 { "-Wno-traditional", "" },
1109 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1110 { "-Wno-trigraphs", "" },
1112 { "-Wno-undef", "" },
1113 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1114 { "-Wno-write-strings", "" },
1116 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1118 /* These are for Objective C. */
1119 DEFINE_LANG_NAME ("Objective C")
1121 { "-lang-objc", "" },
1122 { "-gen-decls", "Dump decls to a .decl file" },
1123 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1124 { "-fno-gnu-runtime", "" },
1125 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1126 { "-fno-next-runtime", "" },
1127 { "-Wselector", "Warn if a selector has multiple methods" },
1128 { "-Wno-selector", "" },
1129 { "-Wprotocol", "" },
1130 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1131 { "-print-objc-runtime-info",
1132 "Generate C header of platform specific features" },
1134 #include "options.h"
1138 /* Here is a table, controlled by the tm.h file, listing each -m switch
1139 and which bits in `target_switches' it should set or clear.
1140 If VALUE is positive, it is bits to set.
1141 If VALUE is negative, -VALUE is bits to clear.
1142 (The sign bit is not used so there is no confusion.) */
1148 const char * description
;
1150 target_switches
[] = TARGET_SWITCHES
;
1152 /* This table is similar, but allows the switch to have a value. */
1154 #ifdef TARGET_OPTIONS
1157 const char * prefix
;
1158 const char ** variable
;
1159 const char * description
;
1161 target_options
[] = TARGET_OPTIONS
;
1164 /* Options controlling warnings */
1166 /* Don't print warning messages. -w. */
1168 int inhibit_warnings
= 0;
1170 /* Print various extra warnings. -W. */
1172 int extra_warnings
= 0;
1174 /* Treat warnings as errors. -Werror. */
1176 int warnings_are_errors
= 0;
1178 /* Nonzero to warn about unused local variables. */
1182 /* Nonzero to warn about code which is never reached. */
1184 int warn_notreached
;
1186 /* Nonzero to warn about variables used before they are initialized. */
1188 int warn_uninitialized
;
1190 /* Nonzero means warn about all declarations which shadow others. */
1194 /* Warn if a switch on an enum fails to have a case for every enum value. */
1198 /* Nonzero means warn about function definitions that default the return type
1199 or that use a null return and have a return-type other than void. */
1201 int warn_return_type
;
1203 /* Nonzero means warn about pointer casts that increase the required
1204 alignment of the target type (and might therefore lead to a crash
1205 due to a misaligned access). */
1207 int warn_cast_align
;
1209 /* Nonzero means warn about any identifiers that match in the first N
1210 characters. The value N is in `id_clash_len'. */
1213 unsigned id_clash_len
;
1215 /* Nonzero means warn about any objects definitions whose size is larger
1216 than N bytes. Also want about function definitions whose returned
1217 values are larger than N bytes. The value N is in `larger_than_size'. */
1219 int warn_larger_than
;
1220 unsigned larger_than_size
;
1222 /* Nonzero means warn if inline function is too large. */
1226 /* Warn if a function returns an aggregate,
1227 since there are often incompatible calling conventions for doing this. */
1229 int warn_aggregate_return
;
1231 /* Likewise for -W. */
1233 lang_independent_options W_options
[] =
1235 {"unused", &warn_unused
, 1, "Warn when a variable is unused" },
1236 {"error", &warnings_are_errors
, 1, ""},
1237 {"shadow", &warn_shadow
, 1, "Warn when one local variable shadows another" },
1238 {"switch", &warn_switch
, 1,
1239 "Warn about enumerated switches missing a specific case" },
1240 {"aggregate-return", &warn_aggregate_return
, 1,
1241 "Warn about returning structures, unions or arrays" },
1242 {"cast-align", &warn_cast_align
, 1,
1243 "Warn about pointer casts which increase alignment" },
1244 {"unreachable-code", &warn_notreached
, 1,
1245 "Warn about code that will never be executed" },
1246 {"uninitialized", &warn_uninitialized
, 1,
1247 "Warn about unitialized automatic variables"},
1248 {"inline", &warn_inline
, 1,
1249 "Warn when an inlined function cannot be inlined"}
1252 /* Output files for assembler code (real compiler output)
1253 and debugging dumps. */
1256 FILE *aux_info_file
;
1257 FILE *rtl_dump_file
= NULL
;
1259 /* Decode the string P as an integral parameter.
1260 If the string is indeed an integer return its numeric value else
1261 issue an Invalid Option error for the option PNAME and return DEFVAL.
1262 If PNAME is zero just return DEFVAL, do not call error. */
1265 read_integral_parameter (p
, pname
, defval
)
1270 const char *endp
= p
;
1274 if (*endp
>= '0' && *endp
<= '9')
1283 error ("Invalid option `%s'", pname
);
1291 /* Time accumulators, to count the total time spent in various passes. */
1295 int integration_time
;
1301 int branch_prob_time
;
1306 int local_alloc_time
;
1307 int global_alloc_time
;
1313 int shorten_branch_time
;
1321 /* Return time used so far, in microseconds. */
1331 #else /* not BeOS */
1332 #if defined (_WIN32) && !defined (__CYGWIN__)
1336 return (clock() * 1000);
1337 #else /* not _WIN32 */
1343 tick
= 1000000 / sysconf(_SC_CLK_TCK
);
1345 return (tms
.tms_utime
+ tms
.tms_stime
) * tick
;
1351 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1352 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1355 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1357 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1361 return (tms
.tms_utime
+ tms
.tms_stime
) * (1000000 / TICKS_PER_SECOND
);
1366 struct rusage rusage
;
1367 getrusage (0, &rusage
);
1368 return (rusage
.ru_utime
.tv_sec
* 1000000 + rusage
.ru_utime
.tv_usec
1369 + rusage
.ru_stime
.tv_sec
* 1000000 + rusage
.ru_stime
.tv_usec
);
1376 int proc_system_time
;
1377 int child_user_time
;
1378 int child_system_time
;
1380 times ((void *) &vms_times
);
1381 return (vms_times
.proc_user_time
+ vms_times
.proc_system_time
) * 10000;
1385 #endif /* _SC_CLK_TCK */
1387 #endif /* __BEOS__ */
1390 #define TIMEVAR(VAR, BODY) \
1391 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1394 print_time (str
, total
)
1399 "time in %s: %d.%06d (%.0f%%)\n",
1400 str
, total
/ 1000000, total
% 1000000,
1401 (double)total
/ (double)all_time
* 100.0);
1404 /* Count an error or warning. Return 1 if the message should be printed. */
1407 count_error (warningp
)
1410 if (warningp
&& inhibit_warnings
)
1413 if (warningp
&& !warnings_are_errors
)
1417 static int warning_message
= 0;
1419 if (warningp
&& !warning_message
)
1421 notice ("%s: warnings being treated as errors\n", progname
);
1422 warning_message
= 1;
1430 /* Print a fatal error message. NAME is the text.
1431 Also include a system error message based on `errno'. */
1434 pfatal_with_name (name
)
1437 fprintf (stderr
, "%s: ", progname
);
1439 exit (FATAL_EXIT_CODE
);
1443 fatal_io_error (name
)
1446 notice ("%s: %s: I/O error\n", progname
, name
);
1447 exit (FATAL_EXIT_CODE
);
1450 /* This is the default decl_printable_name function. */
1453 decl_name (decl
, verbosity
)
1455 int verbosity ATTRIBUTE_UNUSED
;
1457 return IDENTIFIER_POINTER (DECL_NAME (decl
));
1460 /* Mark P for GC. Also mark main_input_filename and input_filename. */
1465 struct file_stack
*stack
= *(struct file_stack
**)p
;
1467 /* We're only called for input_file_stack, so we can mark the current
1468 input_filename here as well. */
1469 ggc_mark_string (main_input_filename
);
1470 ggc_mark_string (input_filename
);
1474 ggc_mark_string (stack
->name
);
1475 stack
= stack
->next
;
1479 static int need_error_newline
;
1481 /* Function of last error message;
1482 more generally, function such that if next error message is in it
1483 then we don't have to mention the function name. */
1484 static tree last_error_function
= NULL
;
1486 /* Used to detect when input_file_stack has changed since last described. */
1487 static int last_error_tick
;
1489 /* Called when the start of a function definition is parsed,
1490 this function prints on stderr the name of the function. */
1493 announce_function (decl
)
1498 if (rtl_dump_and_exit
)
1499 fprintf (stderr
, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl
)));
1501 fprintf (stderr
, " %s", (*decl_printable_name
) (decl
, 2));
1503 need_error_newline
= 1;
1504 last_error_function
= current_function_decl
;
1508 /* The default function to print out name of current function that caused
1512 default_print_error_function (file
)
1515 if (last_error_function
!= current_function_decl
)
1518 fprintf (stderr
, "%s: ", file
);
1520 if (current_function_decl
== NULL
)
1521 notice ("At top level:\n");
1523 notice ((TREE_CODE (TREE_TYPE (current_function_decl
)) == METHOD_TYPE
1524 ? "In method `%s':\n"
1525 : "In function `%s':\n"),
1526 (*decl_printable_name
) (current_function_decl
, 2));
1528 last_error_function
= current_function_decl
;
1532 /* Called by report_error_function to print out function name.
1533 * Default may be overridden by language front-ends. */
1535 void (*print_error_function
) PROTO((const char *)) =
1536 default_print_error_function
;
1538 /* Prints out, if necessary, the name of the current function
1539 that caused an error. Called from all error and warning functions.
1540 We ignore the FILE parameter, as it cannot be relied upon. */
1543 report_error_function (file
)
1544 const char *file ATTRIBUTE_UNUSED
;
1546 struct file_stack
*p
;
1548 if (need_error_newline
)
1550 fprintf (stderr
, "\n");
1551 need_error_newline
= 0;
1554 if (input_file_stack
&& input_file_stack
->next
!= 0
1555 && input_file_stack_tick
!= last_error_tick
)
1557 for (p
= input_file_stack
->next
; p
; p
= p
->next
)
1558 notice ((p
== input_file_stack
->next
1559 ? "In file included from %s:%d"
1560 : ",\n from %s:%d"),
1562 fprintf (stderr
, ":\n");
1563 last_error_tick
= input_file_stack_tick
;
1566 (*print_error_function
) (input_filename
);
1569 /* Print a message. */
1572 vnotice (file
, msgid
, ap
)
1577 vfprintf (file
, _(msgid
), ap
);
1581 notice
VPROTO((const char *msgid
, ...))
1583 #ifndef ANSI_PROTOTYPES
1588 VA_START (ap
, msgid
);
1590 #ifndef ANSI_PROTOTYPES
1591 msgid
= va_arg (ap
, char *);
1594 vnotice (stderr
, msgid
, ap
);
1599 fnotice
VPROTO((FILE *file
, const char *msgid
, ...))
1601 #ifndef ANSI_PROTOTYPES
1607 VA_START (ap
, msgid
);
1609 #ifndef ANSI_PROTOTYPES
1610 file
= va_arg (ap
, FILE *);
1611 msgid
= va_arg (ap
, const char *);
1614 vnotice (file
, msgid
, ap
);
1618 /* Report FILE and LINE (or program name), and optionally just WARN. */
1621 report_file_and_line (file
, line
, warn
)
1627 fprintf (stderr
, "%s:%d: ", file
, line
);
1629 fprintf (stderr
, "%s: ", progname
);
1632 notice ("warning: ");
1635 /* Print a message. */
1638 vmessage (prefix
, msgid
, ap
)
1644 fprintf (stderr
, "%s: ", prefix
);
1646 vfprintf (stderr
, msgid
, ap
);
1649 /* Print a message relevant to line LINE of file FILE. */
1652 v_message_with_file_and_line (file
, line
, warn
, msgid
, ap
)
1659 report_file_and_line (file
, line
, warn
);
1660 vnotice (stderr
, msgid
, ap
);
1661 fputc ('\n', stderr
);
1664 /* Print a message relevant to the given DECL. */
1667 v_message_with_decl (decl
, warn
, msgid
, ap
)
1675 report_file_and_line (DECL_SOURCE_FILE (decl
),
1676 DECL_SOURCE_LINE (decl
), warn
);
1678 /* Do magic to get around lack of varargs support for insertion
1679 of arguments into existing list. We know that the decl is first;
1680 we ass_u_me that it will be printed with "%s". */
1682 for (p
= _(msgid
); *p
; ++p
)
1686 if (*(p
+ 1) == '%')
1688 else if (*(p
+ 1) != 's')
1695 if (p
> _(msgid
)) /* Print the left-hand substring. */
1697 char fmt
[sizeof "%.255s"];
1698 long width
= p
- _(msgid
);
1700 if (width
> 255L) width
= 255L; /* arbitrary */
1701 sprintf (fmt
, "%%.%lds", width
);
1702 fprintf (stderr
, fmt
, _(msgid
));
1705 if (*p
== '%') /* Print the name. */
1707 const char *n
= (DECL_NAME (decl
)
1708 ? (*decl_printable_name
) (decl
, 2)
1714 if (ISALPHA (*(p
- 1) & 0xFF))
1719 if (*p
) /* Print the rest of the message. */
1720 vmessage ((char *)NULL
, p
, ap
);
1722 fputc ('\n', stderr
);
1725 /* Figure file and line of the given INSN. */
1728 file_and_line_for_asm (insn
, pfile
, pline
)
1733 rtx body
= PATTERN (insn
);
1736 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1737 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
1738 asmop
= SET_SRC (body
);
1739 else if (GET_CODE (body
) == ASM_OPERANDS
)
1741 else if (GET_CODE (body
) == PARALLEL
1742 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
)
1743 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
1744 else if (GET_CODE (body
) == PARALLEL
1745 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
1746 asmop
= XVECEXP (body
, 0, 0);
1752 *pfile
= ASM_OPERANDS_SOURCE_FILE (asmop
);
1753 *pline
= ASM_OPERANDS_SOURCE_LINE (asmop
);
1757 *pfile
= input_filename
;
1762 /* Report an error at line LINE of file FILE. */
1765 v_error_with_file_and_line (file
, line
, msgid
, ap
)
1772 report_error_function (file
);
1773 v_message_with_file_and_line (file
, line
, 0, msgid
, ap
);
1777 error_with_file_and_line
VPROTO((const char *file
, int line
,
1778 const char *msgid
, ...))
1780 #ifndef ANSI_PROTOTYPES
1787 VA_START (ap
, msgid
);
1789 #ifndef ANSI_PROTOTYPES
1790 file
= va_arg (ap
, const char *);
1791 line
= va_arg (ap
, int);
1792 msgid
= va_arg (ap
, const char *);
1795 v_error_with_file_and_line (file
, line
, msgid
, ap
);
1799 /* Report an error at the declaration DECL.
1800 MSGID is a format string which uses %s to substitute the declaration
1801 name; subsequent substitutions are a la printf. */
1804 v_error_with_decl (decl
, msgid
, ap
)
1810 report_error_function (DECL_SOURCE_FILE (decl
));
1811 v_message_with_decl (decl
, 0, msgid
, ap
);
1815 error_with_decl
VPROTO((tree decl
, const char *msgid
, ...))
1817 #ifndef ANSI_PROTOTYPES
1823 VA_START (ap
, msgid
);
1825 #ifndef ANSI_PROTOTYPES
1826 decl
= va_arg (ap
, tree
);
1827 msgid
= va_arg (ap
, const char *);
1830 v_error_with_decl (decl
, msgid
, ap
);
1834 /* Report an error at the line number of the insn INSN.
1835 This is used only when INSN is an `asm' with operands,
1836 and each ASM_OPERANDS records its own source file and line. */
1839 v_error_for_asm (insn
, msgid
, ap
)
1848 file_and_line_for_asm (insn
, &file
, &line
);
1849 report_error_function (file
);
1850 v_message_with_file_and_line (file
, line
, 0, msgid
, ap
);
1854 error_for_asm
VPROTO((rtx insn
, const char *msgid
, ...))
1856 #ifndef ANSI_PROTOTYPES
1862 VA_START (ap
, msgid
);
1864 #ifndef ANSI_PROTOTYPES
1865 insn
= va_arg (ap
, rtx
);
1866 msgid
= va_arg (ap
, const char *);
1869 v_error_for_asm (insn
, msgid
, ap
);
1873 /* Report an error at the current line number. */
1880 v_error_with_file_and_line (input_filename
, lineno
, msgid
, ap
);
1884 error
VPROTO((const char *msgid
, ...))
1886 #ifndef ANSI_PROTOTYPES
1891 VA_START (ap
, msgid
);
1893 #ifndef ANSI_PROTOTYPES
1894 msgid
= va_arg (ap
, const char *);
1901 /* Report a fatal error at the current line number. Allow a front end to
1902 intercept the message. */
1904 static void (*fatal_function
) PROTO ((const char *, va_list));
1906 /* Set the function to call when a fatal error occurs. */
1909 set_fatal_function (f
)
1910 void (*f
) PROTO ((const char *, va_list));
1920 if (fatal_function
!= 0)
1921 (*fatal_function
) (_(msgid
), ap
);
1924 exit (FATAL_EXIT_CODE
);
1928 fatal
VPROTO((const char *msgid
, ...))
1930 #ifndef ANSI_PROTOTYPES
1935 VA_START (ap
, msgid
);
1937 #ifndef ANSI_PROTOTYPES
1938 msgid
= va_arg (ap
, const char *);
1946 _fatal_insn (msgid
, insn
, file
, line
, function
)
1951 const char *function
;
1955 fancy_abort (file
, line
, function
);
1959 _fatal_insn_not_found (insn
, file
, line
, function
)
1963 const char *function
;
1965 if (INSN_CODE (insn
) < 0)
1966 _fatal_insn ("Unrecognizable insn:", insn
, file
, line
, function
);
1968 _fatal_insn ("Insn does not satisfy its constraints:",
1969 insn
, file
, line
, function
);
1972 /* Report a warning at line LINE of file FILE. */
1975 v_warning_with_file_and_line (file
, line
, msgid
, ap
)
1981 if (count_error (1))
1983 report_error_function (file
);
1984 v_message_with_file_and_line (file
, line
, 1, msgid
, ap
);
1989 warning_with_file_and_line
VPROTO((const char *file
, int line
,
1990 const char *msgid
, ...))
1992 #ifndef ANSI_PROTOTYPES
1999 VA_START (ap
, msgid
);
2001 #ifndef ANSI_PROTOTYPES
2002 file
= va_arg (ap
, const char *);
2003 line
= va_arg (ap
, int);
2004 msgid
= va_arg (ap
, const char *);
2007 v_warning_with_file_and_line (file
, line
, msgid
, ap
);
2011 /* Report a warning at the declaration DECL.
2012 MSGID is a format string which uses %s to substitute the declaration
2013 name; subsequent substitutions are a la printf. */
2016 v_warning_with_decl (decl
, msgid
, ap
)
2021 if (count_error (1))
2023 report_error_function (DECL_SOURCE_FILE (decl
));
2024 v_message_with_decl (decl
, 1, msgid
, ap
);
2029 warning_with_decl
VPROTO((tree decl
, const char *msgid
, ...))
2031 #ifndef ANSI_PROTOTYPES
2037 VA_START (ap
, msgid
);
2039 #ifndef ANSI_PROTOTYPES
2040 decl
= va_arg (ap
, tree
);
2041 msgid
= va_arg (ap
, const char *);
2044 v_warning_with_decl (decl
, msgid
, ap
);
2048 /* Report a warning at the line number of the insn INSN.
2049 This is used only when INSN is an `asm' with operands,
2050 and each ASM_OPERANDS records its own source file and line. */
2053 v_warning_for_asm (insn
, msgid
, ap
)
2058 if (count_error (1))
2063 file_and_line_for_asm (insn
, &file
, &line
);
2064 report_error_function (file
);
2065 v_message_with_file_and_line (file
, line
, 1, msgid
, ap
);
2070 warning_for_asm
VPROTO((rtx insn
, const char *msgid
, ...))
2072 #ifndef ANSI_PROTOTYPES
2078 VA_START (ap
, msgid
);
2080 #ifndef ANSI_PROTOTYPES
2081 insn
= va_arg (ap
, rtx
);
2082 msgid
= va_arg (ap
, const char *);
2085 v_warning_for_asm (insn
, msgid
, ap
);
2089 /* Report a warning at the current line number. */
2092 vwarning (msgid
, ap
)
2096 v_warning_with_file_and_line (input_filename
, lineno
, msgid
, ap
);
2100 warning
VPROTO((const char *msgid
, ...))
2102 #ifndef ANSI_PROTOTYPES
2107 VA_START (ap
, msgid
);
2109 #ifndef ANSI_PROTOTYPES
2110 msgid
= va_arg (ap
, const char *);
2113 vwarning (msgid
, ap
);
2117 /* These functions issue either warnings or errors depending on
2118 -pedantic-errors. */
2121 vpedwarn (msgid
, ap
)
2125 if (flag_pedantic_errors
)
2128 vwarning (msgid
, ap
);
2132 pedwarn
VPROTO((const char *msgid
, ...))
2134 #ifndef ANSI_PROTOTYPES
2139 VA_START (ap
, msgid
);
2141 #ifndef ANSI_PROTOTYPES
2142 msgid
= va_arg (ap
, const char *);
2145 vpedwarn (msgid
, ap
);
2150 v_pedwarn_with_decl (decl
, msgid
, ap
)
2155 /* We don't want -pedantic-errors to cause the compilation to fail from
2156 "errors" in system header files. Sometimes fixincludes can't fix what's
2157 broken (eg: unsigned char bitfields - fixing it may change the alignment
2158 which will cause programs to mysteriously fail because the C library
2159 or kernel uses the original layout). There's no point in issuing a
2160 warning either, it's just unnecessary noise. */
2162 if (! DECL_IN_SYSTEM_HEADER (decl
))
2164 if (flag_pedantic_errors
)
2165 v_error_with_decl (decl
, msgid
, ap
);
2167 v_warning_with_decl (decl
, msgid
, ap
);
2172 pedwarn_with_decl
VPROTO((tree decl
, const char *msgid
, ...))
2174 #ifndef ANSI_PROTOTYPES
2180 VA_START (ap
, msgid
);
2182 #ifndef ANSI_PROTOTYPES
2183 decl
= va_arg (ap
, tree
);
2184 msgid
= va_arg (ap
, const char *);
2187 v_pedwarn_with_decl (decl
, msgid
, ap
);
2192 v_pedwarn_with_file_and_line (file
, line
, msgid
, ap
)
2198 if (flag_pedantic_errors
)
2199 v_error_with_file_and_line (file
, line
, msgid
, ap
);
2201 v_warning_with_file_and_line (file
, line
, msgid
, ap
);
2205 pedwarn_with_file_and_line
VPROTO((const char *file
, int line
,
2206 const char *msgid
, ...))
2208 #ifndef ANSI_PROTOTYPES
2215 VA_START (ap
, msgid
);
2217 #ifndef ANSI_PROTOTYPES
2218 file
= va_arg (ap
, const char *);
2219 line
= va_arg (ap
, int);
2220 msgid
= va_arg (ap
, const char *);
2223 v_pedwarn_with_file_and_line (file
, line
, msgid
, ap
);
2227 /* Apologize for not implementing some feature. */
2236 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
2238 fprintf (stderr
, "%s: ", progname
);
2239 notice ("sorry, not implemented: ");
2240 vnotice (stderr
, msgid
, ap
);
2241 fputc ('\n', stderr
);
2245 sorry
VPROTO((const char *msgid
, ...))
2247 #ifndef ANSI_PROTOTYPES
2252 VA_START (ap
, msgid
);
2254 #ifndef ANSI_PROTOTYPES
2255 msgid
= va_arg (ap
, const char *);
2263 /* This calls abort and is used to avoid problems when abort if a macro.
2264 It is used when we need to pass the address of abort. */
2272 /* When `malloc.c' is compiled with `rcheck' defined,
2273 it calls this function to report clobberage. */
2277 const char * s ATTRIBUTE_UNUSED
;
2282 /* Return the logarithm of X, base 2, considering X unsigned,
2283 if X is a power of 2. Otherwise, returns -1.
2285 This should be used via the `exact_log2' macro. */
2289 register unsigned HOST_WIDE_INT x
;
2291 register int log
= 0;
2292 /* Test for 0 or a power of 2. */
2293 if (x
== 0 || x
!= (x
& -x
))
2295 while ((x
>>= 1) != 0)
2300 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2301 If X is 0, return -1.
2303 This should be used via the floor_log2 macro. */
2307 register unsigned HOST_WIDE_INT x
;
2309 register int log
= -1;
2316 static int float_handler_set
;
2318 jmp_buf float_handler
;
2320 /* Signals actually come here. */
2323 float_signal (signo
)
2324 /* If this is missing, some compilers complain. */
2325 int signo ATTRIBUTE_UNUSED
;
2327 if (float_handled
== 0)
2329 #if defined (USG) || defined (hpux)
2330 signal (SIGFPE
, float_signal
); /* re-enable the signal catcher */
2333 signal (SIGFPE
, float_signal
);
2334 longjmp (float_handler
, 1);
2337 /* Specify where to longjmp to when a floating arithmetic error happens.
2338 If HANDLER is 0, it means don't handle the errors any more. */
2341 set_float_handler (handler
)
2344 float_handled
= (handler
!= 0);
2346 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
2348 if (float_handled
&& ! float_handler_set
)
2350 signal (SIGFPE
, float_signal
);
2351 float_handler_set
= 1;
2355 /* This is a wrapper function for code which might elicit an
2356 arithmetic exception. That code should be passed in as a function
2357 pointer FN, and one argument DATA. DATA is usually a struct which
2358 contains the real input and output for function FN. This function
2359 returns 0 (failure) if longjmp was called (i.e. an exception
2360 occured.) It returns 1 (success) otherwise. */
2363 do_float_handler (fn
, data
)
2364 void (*fn
) PROTO ((PTR
));
2371 /* We got here via longjmp() caused by an exception in function fn() */
2372 set_float_handler (NULL
);
2376 set_float_handler (buf
);
2378 set_float_handler (NULL
);
2382 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2383 error happens, pushing the previous specification into OLD_HANDLER.
2384 Return an indication of whether there was a previous handler in effect. */
2387 push_float_handler (handler
, old_handler
)
2388 jmp_buf handler
, old_handler
;
2390 int was_handled
= float_handled
;
2394 memcpy ((char *) old_handler
, (char *) float_handler
,
2395 sizeof (float_handler
));
2397 memcpy ((char *) float_handler
, (char *) handler
, sizeof (float_handler
));
2401 /* Restore the previous specification of whether and where to longjmp to
2402 when a floating arithmetic error happens. */
2405 pop_float_handler (handled
, handler
)
2409 float_handled
= handled
;
2411 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
2414 /* Handler for SIGPIPE. */
2418 /* If this is missing, some compilers complain. */
2419 int signo ATTRIBUTE_UNUSED
;
2421 fatal ("output pipe has been closed");
2424 /* Strip off a legitimate source ending from the input string NAME of
2425 length LEN. Rather than having to know the names used by all of
2426 our front ends, we strip off an ending of a period followed by
2427 up to five characters. (Java uses ".class".) */
2430 strip_off_ending (name
, len
)
2435 for (i
= 2; i
< 6 && len
> i
; i
++)
2437 if (name
[len
- i
] == '.')
2439 name
[len
- i
] = '\0';
2445 /* Output a quoted string. */
2448 output_quoted_string (asm_file
, string
)
2452 #ifdef OUTPUT_QUOTED_STRING
2453 OUTPUT_QUOTED_STRING (asm_file
, string
);
2457 putc ('\"', asm_file
);
2458 while ((c
= *string
++) != 0)
2460 if (c
== '\"' || c
== '\\')
2461 putc ('\\', asm_file
);
2464 putc ('\"', asm_file
);
2468 /* Output a file name in the form wanted by System V. */
2471 output_file_directive (asm_file
, input_name
)
2473 const char *input_name
;
2475 int len
= strlen (input_name
);
2476 const char *na
= input_name
+ len
;
2478 /* NA gets INPUT_NAME sans directory names. */
2479 while (na
> input_name
)
2483 #ifdef DIR_SEPARATOR
2484 if (na
[-1] == DIR_SEPARATOR
)
2490 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2491 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file
, na
);
2493 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2494 ASM_OUTPUT_SOURCE_FILENAME (asm_file
, na
);
2496 fprintf (asm_file
, "\t.file\t");
2497 output_quoted_string (asm_file
, na
);
2498 fputc ('\n', asm_file
);
2503 #ifdef ASM_IDENTIFY_LANGUAGE
2504 /* Routine to build language identifier for object file. */
2506 output_lang_identify (asm_out_file
)
2509 int len
= strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2510 char *s
= (char *) alloca (len
);
2511 sprintf (s
, "__gnu_compiled_%s", lang_identify ());
2512 ASM_OUTPUT_LABEL (asm_out_file
, s
);
2516 /* Routine to open a dump file. */
2518 open_dump_file (suffix
, function_name
)
2520 const char *function_name
;
2527 dumpname
= concat (dump_base_name
, suffix
, NULL
);
2529 if (rtl_dump_file
!= NULL
)
2530 fclose (rtl_dump_file
);
2532 rtl_dump_file
= fopen (dumpname
, "a");
2534 if (rtl_dump_file
== NULL
)
2535 pfatal_with_name (dumpname
);
2540 fprintf (rtl_dump_file
, "\n;; Function %s\n\n", function_name
);
2546 /* Routine to close a dump file. */
2548 close_dump_file (func
, insns
)
2549 void (*func
) PROTO ((FILE *, rtx
));
2556 func (rtl_dump_file
, insns
);
2558 fflush (rtl_dump_file
);
2559 fclose (rtl_dump_file
);
2561 rtl_dump_file
= NULL
;
2567 /* Routine to dump rtl into a file. */
2569 dump_rtl (suffix
, decl
, func
, insns
)
2572 void (*func
) PROTO ((FILE *, rtx
));
2575 open_dump_file (suffix
, decl_printable_name (decl
, 2));
2576 close_dump_file (func
, insns
);
2579 /* Routine to empty a dump file. */
2581 clean_dump_file (suffix
)
2584 char * const dumpname
= concat (dump_base_name
, suffix
, NULL
);
2586 rtl_dump_file
= fopen (dumpname
, "w");
2588 if (rtl_dump_file
== NULL
)
2589 pfatal_with_name (dumpname
);
2593 fclose (rtl_dump_file
);
2594 rtl_dump_file
= NULL
;
2599 /* Do any final processing required for the declarations in VEC, of
2600 which there are LEN. We write out inline functions and variables
2601 that have been deferred until this point, but which are required.
2602 Returns non-zero if anything was put out. */
2604 wrapup_global_declarations (vec
, len
)
2611 int output_something
= 0;
2613 for (i
= 0; i
< len
; i
++)
2617 /* We're not deferring this any longer. */
2618 DECL_DEFER_OUTPUT (decl
) = 0;
2620 if (TREE_CODE (decl
) == VAR_DECL
&& DECL_SIZE (decl
) == 0
2621 && incomplete_decl_finalize_hook
!= 0)
2622 (*incomplete_decl_finalize_hook
) (decl
);
2625 /* Now emit any global variables or functions that we have been
2626 putting off. We need to loop in case one of the things emitted
2627 here references another one which comes earlier in the list. */
2631 for (i
= 0; i
< len
; i
++)
2635 if (TREE_ASM_WRITTEN (decl
) || DECL_EXTERNAL (decl
))
2638 /* Don't write out static consts, unless we still need them.
2640 We also keep static consts if not optimizing (for debugging),
2641 unless the user specified -fno-keep-static-consts.
2642 ??? They might be better written into the debug information.
2643 This is possible when using DWARF.
2645 A language processor that wants static constants to be always
2646 written out (even if it is not used) is responsible for
2647 calling rest_of_decl_compilation itself. E.g. the C front-end
2648 calls rest_of_decl_compilation from finish_decl.
2649 One motivation for this is that is conventional in some
2650 environments to write things like:
2651 static const char rcsid[] = "... version string ...";
2652 intending to force the string to be in the executable.
2654 A language processor that would prefer to have unneeded
2655 static constants "optimized away" would just defer writing
2656 them out until here. E.g. C++ does this, because static
2657 constants are often defined in header files.
2659 ??? A tempting alternative (for both C and C++) would be
2660 to force a constant to be written if and only if it is
2661 defined in a main file, as opposed to an include file. */
2663 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
2664 && (! TREE_READONLY (decl
)
2665 || TREE_PUBLIC (decl
)
2666 || (!optimize
&& flag_keep_static_consts
)
2667 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
2670 rest_of_decl_compilation (decl
, NULL_PTR
, 1, 1);
2673 if (TREE_CODE (decl
) == FUNCTION_DECL
2674 && DECL_INITIAL (decl
) != 0
2675 && DECL_SAVED_INSNS (decl
) != 0
2676 && (flag_keep_inline_functions
2677 || (TREE_PUBLIC (decl
) && !DECL_COMDAT (decl
))
2678 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
2681 temporary_allocation ();
2682 output_inline_function (decl
);
2683 permanent_allocation (1);
2688 output_something
= 1;
2692 return output_something
;
2695 /* Issue appropriate warnings for the global declarations in VEC (of
2696 which there are LEN). Output debugging information for them. */
2698 check_global_declarations (vec
, len
)
2705 for (i
= 0; i
< len
; i
++)
2709 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
2710 && ! TREE_ASM_WRITTEN (decl
))
2711 /* Cancel the RTL for this decl so that, if debugging info
2712 output for global variables is still to come,
2713 this one will be omitted. */
2714 DECL_RTL (decl
) = NULL
;
2716 /* Warn about any function
2717 declared static but not defined.
2718 We don't warn about variables,
2719 because many programs have static variables
2720 that exist only to get some text into the object file. */
2721 if (TREE_CODE (decl
) == FUNCTION_DECL
2723 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
2724 && DECL_INITIAL (decl
) == 0
2725 && DECL_EXTERNAL (decl
)
2726 && ! DECL_ARTIFICIAL (decl
)
2727 && ! TREE_PUBLIC (decl
))
2729 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
2730 pedwarn_with_decl (decl
,
2731 "`%s' used but never defined");
2733 warning_with_decl (decl
,
2734 "`%s' declared `static' but never defined");
2735 /* This symbol is effectively an "extern" declaration now. */
2736 TREE_PUBLIC (decl
) = 1;
2737 assemble_external (decl
);
2740 /* Warn about static fns or vars defined but not used,
2741 but not about inline functions or static consts
2742 since defining those in header files is normal practice. */
2744 && ((TREE_CODE (decl
) == FUNCTION_DECL
&& ! DECL_INLINE (decl
))
2745 || (TREE_CODE (decl
) == VAR_DECL
&& ! TREE_READONLY (decl
)))
2746 && ! DECL_IN_SYSTEM_HEADER (decl
)
2747 && ! DECL_EXTERNAL (decl
)
2748 && ! TREE_PUBLIC (decl
)
2749 && ! TREE_USED (decl
)
2750 && (TREE_CODE (decl
) == FUNCTION_DECL
|| ! DECL_REGISTER (decl
))
2751 /* The TREE_USED bit for file-scope decls
2752 is kept in the identifier, to handle multiple
2753 external decls in different scopes. */
2754 && ! TREE_USED (DECL_NAME (decl
)))
2755 warning_with_decl (decl
, "`%s' defined but not used");
2757 #ifdef SDB_DEBUGGING_INFO
2758 /* The COFF linker can move initialized global vars to the end.
2759 And that can screw up the symbol ordering.
2760 By putting the symbols in that order to begin with,
2761 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2762 if (write_symbols
== SDB_DEBUG
&& TREE_CODE (decl
) == VAR_DECL
2763 && TREE_PUBLIC (decl
) && DECL_INITIAL (decl
)
2764 && ! DECL_EXTERNAL (decl
)
2765 && DECL_RTL (decl
) != 0)
2766 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
2768 /* Output COFF information for non-global
2769 file-scope initialized variables. */
2770 if (write_symbols
== SDB_DEBUG
2771 && TREE_CODE (decl
) == VAR_DECL
2772 && DECL_INITIAL (decl
)
2773 && ! DECL_EXTERNAL (decl
)
2774 && DECL_RTL (decl
) != 0
2775 && GET_CODE (DECL_RTL (decl
)) == MEM
)
2776 TIMEVAR (symout_time
, sdbout_toplevel_data (decl
));
2777 #endif /* SDB_DEBUGGING_INFO */
2778 #ifdef DWARF_DEBUGGING_INFO
2779 /* Output DWARF information for file-scope tentative data object
2780 declarations, file-scope (extern) function declarations (which
2781 had no corresponding body) and file-scope tagged type declarations
2782 and definitions which have not yet been forced out. */
2784 if (write_symbols
== DWARF_DEBUG
2785 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
2786 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 1));
2788 #ifdef DWARF2_DEBUGGING_INFO
2789 /* Output DWARF2 information for file-scope tentative data object
2790 declarations, file-scope (extern) function declarations (which
2791 had no corresponding body) and file-scope tagged type declarations
2792 and definitions which have not yet been forced out. */
2794 if (write_symbols
== DWARF2_DEBUG
2795 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
2796 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
2801 /* Compile an entire file of output from cpp, named NAME.
2802 Write a file of assembly output and various debugging dumps. */
2811 int name_specified
= name
!= 0;
2813 if (dump_base_name
== 0)
2814 dump_base_name
= name
? name
: "gccdump";
2818 integration_time
= 0;
2824 branch_prob_time
= 0;
2829 local_alloc_time
= 0;
2830 global_alloc_time
= 0;
2836 shorten_branch_time
= 0;
2842 /* Initialize data in various passes. */
2846 name
= init_parse (name
);
2847 init_emit_once (debug_info_level
== DINFO_LEVEL_NORMAL
2848 || debug_info_level
== DINFO_LEVEL_VERBOSE
2849 || flag_test_coverage
2850 || warn_notreached
);
2852 init_decl_processing ();
2859 init_function_once ();
2860 init_stor_layout_once ();
2861 init_varasm_once ();
2863 /* The following initialization functions need to generate rtl, so
2864 provide a dummy function context for them. */
2865 init_dummy_function_start ();
2868 if (flag_caller_saves
)
2869 init_caller_save ();
2870 expand_dummy_function_end ();
2872 /* If auxiliary info generation is desired, open the output file.
2873 This goes in the same directory as the source file--unlike
2874 all the other output files. */
2875 if (flag_gen_aux_info
)
2877 aux_info_file
= fopen (aux_info_file_name
, "w");
2878 if (aux_info_file
== 0)
2879 pfatal_with_name (aux_info_file_name
);
2882 /* Clear the dump files. */
2884 clean_dump_file (".rtl");
2887 clean_dump_file (".jump");
2888 if (graph_dump_format
!= no_graph
)
2889 clean_graph_dump_file (dump_base_name
, ".jump");
2893 clean_dump_file (".addressof");
2894 if (graph_dump_format
!= no_graph
)
2895 clean_graph_dump_file (dump_base_name
, ".addressof");
2899 clean_dump_file (".cse");
2900 if (graph_dump_format
!= no_graph
)
2901 clean_graph_dump_file (dump_base_name
, ".cse");
2905 clean_dump_file (".loop");
2906 if (graph_dump_format
!= no_graph
)
2907 clean_graph_dump_file (dump_base_name
, ".loop");
2911 clean_dump_file (".cse2");
2912 if (graph_dump_format
!= no_graph
)
2913 clean_graph_dump_file (dump_base_name
, ".cse2");
2915 if (branch_prob_dump
)
2917 clean_dump_file (".bp");
2918 if (graph_dump_format
!= no_graph
)
2919 clean_graph_dump_file (dump_base_name
, ".bp");
2923 clean_dump_file (".flow");
2924 if (graph_dump_format
!= no_graph
)
2925 clean_graph_dump_file (dump_base_name
, ".flow");
2929 clean_dump_file (".combine");
2930 if (graph_dump_format
!= no_graph
)
2931 clean_graph_dump_file (dump_base_name
, ".combine");
2935 clean_dump_file (".regmove");
2936 if (graph_dump_format
!= no_graph
)
2937 clean_graph_dump_file (dump_base_name
, ".regmove");
2941 clean_dump_file (".sched");
2942 if (graph_dump_format
!= no_graph
)
2943 clean_graph_dump_file (dump_base_name
, ".sched");
2947 clean_dump_file (".lreg");
2948 if (graph_dump_format
!= no_graph
)
2949 clean_graph_dump_file (dump_base_name
, ".lreg");
2951 if (global_reg_dump
)
2953 clean_dump_file (".greg");
2954 if (graph_dump_format
!= no_graph
)
2955 clean_graph_dump_file (dump_base_name
, ".greg");
2959 clean_dump_file (".flow2");
2960 if (graph_dump_format
!= no_graph
)
2961 clean_graph_dump_file (dump_base_name
, ".flow2");
2965 clean_dump_file (".peephole2");
2966 if (graph_dump_format
!= no_graph
)
2967 clean_graph_dump_file (dump_base_name
, ".peephole2");
2971 clean_dump_file (".sched2");
2972 if (graph_dump_format
!= no_graph
)
2973 clean_graph_dump_file (dump_base_name
, ".sched2");
2977 clean_dump_file (".jump2");
2978 if (graph_dump_format
!= no_graph
)
2979 clean_graph_dump_file (dump_base_name
, ".jump2");
2984 clean_dump_file (".dbr");
2985 if (graph_dump_format
!= no_graph
)
2986 clean_graph_dump_file (dump_base_name
, ".dbr");
2991 clean_dump_file (".gcse");
2992 if (graph_dump_format
!= no_graph
)
2993 clean_graph_dump_file (dump_base_name
, ".gcse");
2998 clean_dump_file (".stack");
2999 if (graph_dump_format
!= no_graph
)
3000 clean_graph_dump_file (dump_base_name
, ".stack");
3003 #ifdef MACHINE_DEPENDENT_REORG
3004 if (mach_dep_reorg_dump
)
3006 clean_dump_file (".mach");
3007 if (graph_dump_format
!= no_graph
)
3008 clean_graph_dump_file (dump_base_name
, ".mach");
3012 /* Open assembler code output file. */
3014 if (flag_syntax_only
)
3015 asm_out_file
= NULL
;
3018 if (! name_specified
&& asm_file_name
== 0)
3019 asm_out_file
= stdout
;
3022 int len
= strlen (dump_base_name
);
3023 register char *dumpname
= (char *) xmalloc (len
+ 6);
3024 strcpy (dumpname
, dump_base_name
);
3025 strip_off_ending (dumpname
, len
);
3026 strcat (dumpname
, ".s");
3027 if (asm_file_name
== 0)
3028 asm_file_name
= xstrdup (dumpname
);
3029 if (!strcmp (asm_file_name
, "-"))
3030 asm_out_file
= stdout
;
3032 asm_out_file
= fopen (asm_file_name
, "w");
3033 if (asm_out_file
== 0)
3034 pfatal_with_name (asm_file_name
);
3037 #ifdef IO_BUFFER_SIZE
3038 setvbuf (asm_out_file
, (char *) xmalloc (IO_BUFFER_SIZE
),
3039 _IOFBF
, IO_BUFFER_SIZE
);
3044 name
= ggc_alloc_string (name
, strlen (name
));
3045 input_filename
= name
;
3047 /* Put an entry on the input file stack for the main input file. */
3049 = (struct file_stack
*) xmalloc (sizeof (struct file_stack
));
3050 input_file_stack
->next
= 0;
3051 input_file_stack
->name
= input_filename
;
3053 /* Perform language-specific initialization.
3054 This may set main_input_filename. */
3057 /* If the input doesn't start with a #line, use the input name
3058 as the official input file name. */
3059 if (main_input_filename
== 0)
3060 main_input_filename
= name
;
3062 if (flag_syntax_only
)
3064 write_symbols
= NO_DEBUG
;
3066 profile_block_flag
= 0;
3070 ASM_FILE_START (asm_out_file
);
3072 #ifdef ASM_COMMENT_START
3073 if (flag_verbose_asm
)
3075 /* Print the list of options in effect. */
3076 print_version (asm_out_file
, ASM_COMMENT_START
);
3077 print_switch_values (asm_out_file
, 0, MAX_LINE
,
3078 ASM_COMMENT_START
, " ", "\n");
3079 /* Add a blank line here so it appears in assembler output but not
3081 fprintf (asm_out_file
, "\n");
3085 /* Output something to inform GDB that this compilation was by GCC. */
3086 #ifndef ASM_IDENTIFY_GCC
3087 fprintf (asm_out_file
, "gcc2_compiled.:\n");
3089 ASM_IDENTIFY_GCC (asm_out_file
);
3092 /* Output something to identify which front-end produced this file. */
3093 #ifdef ASM_IDENTIFY_LANGUAGE
3094 ASM_IDENTIFY_LANGUAGE (asm_out_file
);
3096 } /* ! flag_syntax_only */
3098 #ifndef ASM_OUTPUT_SECTION_NAME
3099 if (flag_function_sections
)
3101 warning ("-ffunction-sections not supported for this target.");
3102 flag_function_sections
= 0;
3104 if (flag_data_sections
)
3106 warning ("-fdata-sections not supported for this target.");
3107 flag_data_sections
= 0;
3111 if (flag_function_sections
3112 && (profile_flag
|| profile_block_flag
))
3114 warning ("-ffunction-sections disabled; it makes profiling impossible.");
3115 flag_function_sections
= 0;
3118 #ifndef OBJECT_FORMAT_ELF
3119 if (flag_function_sections
&& write_symbols
!= NO_DEBUG
)
3120 warning ("-ffunction-sections may affect debugging on some targets.");
3123 /* ??? Note: There used to be a conditional here
3124 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
3125 This was to guarantee separation between gcc_compiled. and
3126 the first function, for the sake of dbx on Suns.
3127 However, having the extra zero here confused the Emacs
3128 code for unexec, and might confuse other programs too.
3129 Therefore, I took out that change.
3130 In future versions we should find another way to solve
3131 that dbx problem. -- rms, 23 May 93. */
3133 /* Don't let the first function fall at the same address
3134 as gcc_compiled., if profiling. */
3135 if (profile_flag
|| profile_block_flag
)
3137 /* It's best if we can write a nop here since some
3138 assemblers don't tolerate zeros in the text section. */
3139 output_asm_insn (get_insn_template (CODE_FOR_nop
, NULL
), NULL_PTR
);
3142 /* If dbx symbol table desired, initialize writing it
3143 and output the predefined types. */
3144 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3145 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3146 TIMEVAR (symout_time
, dbxout_init (asm_out_file
, main_input_filename
,
3149 #ifdef SDB_DEBUGGING_INFO
3150 if (write_symbols
== SDB_DEBUG
)
3151 TIMEVAR (symout_time
, sdbout_init (asm_out_file
, main_input_filename
,
3154 #ifdef DWARF_DEBUGGING_INFO
3155 if (write_symbols
== DWARF_DEBUG
)
3156 TIMEVAR (symout_time
, dwarfout_init (asm_out_file
, main_input_filename
));
3158 #ifdef DWARF2_UNWIND_INFO
3159 if (dwarf2out_do_frame ())
3160 dwarf2out_frame_init ();
3162 #ifdef DWARF2_DEBUGGING_INFO
3163 if (write_symbols
== DWARF2_DEBUG
)
3164 TIMEVAR (symout_time
, dwarf2out_init (asm_out_file
, main_input_filename
));
3167 /* Initialize yet another pass. */
3169 init_final (main_input_filename
);
3170 init_branch_prob (dump_base_name
);
3172 start_time
= get_run_time ();
3174 /* Call the parser, which parses the entire file
3175 (calling rest_of_compilation for each function). */
3177 if (yyparse () != 0)
3179 if (errorcount
== 0)
3180 notice ("Errors detected in input file (your bison.simple is out of date)\n");
3182 /* In case there were missing closebraces,
3183 get us back to the global binding level. */
3184 while (! global_bindings_p ())
3188 /* Compilation is now finished except for writing
3189 what's left of the symbol table output. */
3191 parse_time
+= get_run_time () - start_time
;
3193 parse_time
-= integration_time
;
3194 parse_time
-= varconst_time
;
3196 if (flag_syntax_only
)
3199 globals
= getdecls ();
3201 /* Really define vars that have had only a tentative definition.
3202 Really output inline functions that must actually be callable
3203 and have not been output so far. */
3206 int len
= list_length (globals
);
3207 tree
*vec
= (tree
*) alloca (sizeof (tree
) * len
);
3211 /* Process the decls in reverse order--earliest first.
3212 Put them into VEC from back to front, then take out from front. */
3214 for (i
= 0, decl
= globals
; i
< len
; i
++, decl
= TREE_CHAIN (decl
))
3215 vec
[len
- i
- 1] = decl
;
3217 wrapup_global_declarations (vec
, len
);
3219 /* This must occur after the loop to output deferred functions. Else
3220 the profiler initializer would not be emitted if all the functions
3221 in this compilation unit were deferred.
3223 output_func_start_profiler can not cause any additional functions or
3224 data to need to be output, so it need not be in the deferred function
3226 output_func_start_profiler ();
3228 /* Now that all possible functions have been output, we can dump
3229 the exception table. */
3231 output_exception_table ();
3233 check_global_declarations (vec
, len
);
3236 /* Write out any pending weak symbol declarations. */
3240 /* Do dbx symbols */
3241 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3242 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3243 TIMEVAR (symout_time
,
3245 dbxout_finish (asm_out_file
, main_input_filename
);
3249 #ifdef DWARF_DEBUGGING_INFO
3250 if (write_symbols
== DWARF_DEBUG
)
3251 TIMEVAR (symout_time
,
3257 #ifdef DWARF2_UNWIND_INFO
3258 if (dwarf2out_do_frame ())
3259 dwarf2out_frame_finish ();
3262 #ifdef DWARF2_DEBUGGING_INFO
3263 if (write_symbols
== DWARF2_DEBUG
)
3264 TIMEVAR (symout_time
,
3266 dwarf2out_finish ();
3270 /* Output some stuff at end of file if nec. */
3272 end_final (dump_base_name
);
3274 if (branch_prob_dump
)
3275 open_dump_file (".bp", NULL
);
3277 TIMEVAR (dump_time
, end_branch_prob (rtl_dump_file
));
3279 if (branch_prob_dump
)
3280 close_dump_file (NULL
, NULL_RTX
);
3283 ASM_FILE_END (asm_out_file
);
3287 /* Language-specific end of compilation actions. */
3291 /* Close the dump files. */
3293 if (flag_gen_aux_info
)
3295 fclose (aux_info_file
);
3297 unlink (aux_info_file_name
);
3302 open_dump_file (".combine", NULL
);
3303 TIMEVAR (dump_time
, dump_combine_total_stats (rtl_dump_file
));
3304 close_dump_file (NULL
, NULL_RTX
);
3307 /* Close non-debugging input and output files. Take special care to note
3308 whether fclose returns an error, since the pages might still be on the
3309 buffer chain while the file is open. */
3313 if (! flag_syntax_only
3314 && (ferror (asm_out_file
) != 0 || fclose (asm_out_file
) != 0))
3315 fatal_io_error (asm_file_name
);
3317 /* Do whatever is necessary to finish printing the graphs. */
3318 if (graph_dump_format
!= no_graph
)
3321 finish_graph_dump_file (dump_base_name
, ".jump");
3323 finish_graph_dump_file (dump_base_name
, ".addressof");
3325 finish_graph_dump_file (dump_base_name
, ".cse");
3327 finish_graph_dump_file (dump_base_name
, ".loop");
3329 finish_graph_dump_file (dump_base_name
, ".cse2");
3330 if (branch_prob_dump
)
3331 finish_graph_dump_file (dump_base_name
, ".bp");
3333 finish_graph_dump_file (dump_base_name
, ".flow");
3335 finish_graph_dump_file (dump_base_name
, ".combine");
3337 finish_graph_dump_file (dump_base_name
, ".regmove");
3339 finish_graph_dump_file (dump_base_name
, ".sched");
3341 finish_graph_dump_file (dump_base_name
, ".lreg");
3342 if (global_reg_dump
)
3343 finish_graph_dump_file (dump_base_name
, ".greg");
3345 finish_graph_dump_file (dump_base_name
, ".flow2");
3347 finish_graph_dump_file (dump_base_name
, ".sched2");
3349 finish_graph_dump_file (dump_base_name
, ".jump2");
3352 finish_graph_dump_file (dump_base_name
, ".dbr");
3355 finish_graph_dump_file (dump_base_name
, ".gcse");
3358 finish_graph_dump_file (dump_base_name
, ".stack");
3360 #ifdef MACHINE_DEPENDENT_REORG
3361 if (mach_dep_reorg_dump
)
3362 finish_graph_dump_file (dump_base_name
, ".mach");
3366 /* Free up memory for the benefit of leak detectors. */
3369 /* Print the times. */
3373 all_time
= get_run_time ();
3375 fprintf (stderr
,"\n");
3377 print_time ("parse", parse_time
);
3378 print_time ("integration", integration_time
);
3379 print_time ("jump", jump_time
);
3380 print_time ("cse", cse_time
);
3381 print_time ("gcse", gcse_time
);
3382 print_time ("loop", loop_time
);
3383 print_time ("cse2", cse2_time
);
3384 print_time ("branch-prob", branch_prob_time
);
3385 print_time ("flow", flow_time
);
3386 print_time ("combine", combine_time
);
3387 print_time ("regmove", regmove_time
);
3388 print_time ("sched", sched_time
);
3389 print_time ("local-alloc", local_alloc_time
);
3390 print_time ("global-alloc", global_alloc_time
);
3391 print_time ("flow2", flow2_time
);
3392 print_time ("sched2", sched2_time
);
3394 print_time ("dbranch", dbr_sched_time
);
3396 print_time ("shorten-branch", shorten_branch_time
);
3397 print_time ("stack-reg", stack_reg_time
);
3398 print_time ("final", final_time
);
3399 print_time ("varconst", varconst_time
);
3400 print_time ("symout", symout_time
);
3401 print_time ("dump", dump_time
);
3402 print_time ("gc", gc_time
);
3406 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3407 and TYPE_DECL nodes.
3409 This does nothing for local (non-static) variables, unless the
3410 variable is a register variable with an ASMSPEC. In that case, or
3411 if the variable is not an automatice, it sets up the RTL and
3412 outputs any assembler code (label definition, storage allocation
3413 and initialization).
3415 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3416 the assembler symbol name to be used. TOP_LEVEL is nonzero
3417 if this declaration is not within a function. */
3420 rest_of_decl_compilation (decl
, asmspec
, top_level
, at_end
)
3422 const char *asmspec
;
3426 /* Declarations of variables, and of functions defined elsewhere. */
3428 /* The most obvious approach, to put an #ifndef around where
3429 this macro is used, doesn't work since it's inside a macro call. */
3430 #ifndef ASM_FINISH_DECLARE_OBJECT
3431 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3434 /* Forward declarations for nested functions are not "external",
3435 but we need to treat them as if they were. */
3436 if (TREE_STATIC (decl
) || DECL_EXTERNAL (decl
)
3437 || TREE_CODE (decl
) == FUNCTION_DECL
)
3438 TIMEVAR (varconst_time
,
3440 make_decl_rtl (decl
, asmspec
, top_level
);
3441 /* Initialized extern variable exists to be replaced
3442 with its value, or represents something that will be
3443 output in another file. */
3444 if (! (TREE_CODE (decl
) == VAR_DECL
3445 && DECL_EXTERNAL (decl
) && TREE_READONLY (decl
)
3446 && DECL_INITIAL (decl
) != 0
3447 && DECL_INITIAL (decl
) != error_mark_node
))
3448 /* Don't output anything
3449 when a tentative file-scope definition is seen.
3450 But at end of compilation, do output code for them. */
3451 if (! (! at_end
&& top_level
3452 && (DECL_INITIAL (decl
) == 0
3453 || DECL_INITIAL (decl
) == error_mark_node
)))
3454 assemble_variable (decl
, top_level
, at_end
, 0);
3455 if (decl
== last_assemble_variable_decl
)
3457 ASM_FINISH_DECLARE_OBJECT (asm_out_file
, decl
,
3461 else if (DECL_REGISTER (decl
) && asmspec
!= 0)
3463 if (decode_reg_name (asmspec
) >= 0)
3465 DECL_RTL (decl
) = 0;
3466 make_decl_rtl (decl
, asmspec
, top_level
);
3469 error ("invalid register name `%s' for register variable", asmspec
);
3471 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3472 else if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3473 && TREE_CODE (decl
) == TYPE_DECL
)
3474 TIMEVAR (symout_time
, dbxout_symbol (decl
, 0));
3476 #ifdef SDB_DEBUGGING_INFO
3477 else if (write_symbols
== SDB_DEBUG
&& top_level
3478 && TREE_CODE (decl
) == TYPE_DECL
)
3479 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
3483 /* Called after finishing a record, union or enumeral type. */
3486 rest_of_type_compilation (type
, toplev
)
3487 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3491 tree type ATTRIBUTE_UNUSED
;
3492 int toplev ATTRIBUTE_UNUSED
;
3495 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3496 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3497 TIMEVAR (symout_time
, dbxout_symbol (TYPE_STUB_DECL (type
), !toplev
));
3499 #ifdef SDB_DEBUGGING_INFO
3500 if (write_symbols
== SDB_DEBUG
)
3501 TIMEVAR (symout_time
, sdbout_symbol (TYPE_STUB_DECL (type
), !toplev
));
3505 /* This is called from finish_function (within yyparse)
3506 after each top-level definition is parsed.
3507 It is supposed to compile that function or variable
3508 and output the assembler code for it.
3509 After we return, the tree storage is freed. */
3512 rest_of_compilation (decl
)
3516 int start_time
= get_run_time ();
3518 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3519 to be restored after we finish compiling the function
3520 (for use when compiling inline calls to this function). */
3521 tree saved_block_tree
= 0;
3522 /* Likewise, for DECL_ARGUMENTS. */
3523 tree saved_arguments
= 0;
3525 int rebuild_label_notes_after_reload
;
3527 /* If we are reconsidering an inline function
3528 at the end of compilation, skip the stuff for making it inline. */
3530 if (DECL_SAVED_INSNS (decl
) == 0)
3535 /* If requested, consider whether to make this function inline. */
3536 if (DECL_INLINE (decl
) || flag_inline_functions
)
3537 TIMEVAR (integration_time
,
3539 lose
= function_cannot_inline_p (decl
);
3540 if (lose
|| ! optimize
)
3542 if (warn_inline
&& DECL_INLINE (decl
))
3543 warning_with_decl (decl
, lose
);
3544 DECL_ABSTRACT_ORIGIN (decl
) = 0;
3545 /* Don't really compile an extern inline function.
3546 If we can't make it inline, pretend
3547 it was only declared. */
3548 if (DECL_EXTERNAL (decl
))
3550 DECL_INITIAL (decl
) = 0;
3551 goto exit_rest_of_compilation
;
3555 /* ??? Note that this has the effect of making it look
3556 like "inline" was specified for a function if we choose
3557 to inline it. This isn't quite right, but it's
3558 probably not worth the trouble to fix. */
3559 inlinable
= DECL_INLINE (decl
) = 1;
3562 insns
= get_insns ();
3564 /* Dump the rtl code if we are dumping rtl. */
3568 open_dump_file (".rtl", decl_printable_name (decl
, 2));
3570 if (DECL_SAVED_INSNS (decl
))
3571 fprintf (rtl_dump_file
, ";; (integrable)\n\n");
3573 close_dump_file (print_rtl
, insns
);
3576 /* If function is inline, and we don't yet know whether to
3577 compile it by itself, defer decision till end of compilation.
3578 finish_compilation will call rest_of_compilation again
3579 for those functions that need to be output. Also defer those
3580 functions that we are supposed to defer. */
3583 DECL_DEFER_OUTPUT (decl
) = 1;
3585 if (DECL_DEFER_OUTPUT (decl
)
3586 || (DECL_INLINE (decl
)
3587 && ((! TREE_PUBLIC (decl
) && ! TREE_ADDRESSABLE (decl
)
3588 && ! flag_keep_inline_functions
)
3589 || DECL_EXTERNAL (decl
))))
3591 DECL_DEFER_OUTPUT (decl
) = 1;
3593 /* If -Wreturn-type, we have to do a bit of compilation.
3594 However, if we just fall through we will call
3595 save_for_inline_copying() which results in excessive
3596 memory use. Instead, we just want to call
3597 jump_optimize() to figure out whether or not we can fall
3598 off the end of the function; we do the minimum amount of
3599 work necessary to make that safe. And, we set optimize
3600 to zero to keep jump_optimize from working too hard. */
3601 if (warn_return_type
)
3603 int saved_optimize
= optimize
;
3605 find_exception_handler_labels ();
3606 jump_optimize (get_insns(), !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
3607 !JUMP_AFTER_REGSCAN
);
3608 optimize
= saved_optimize
;
3611 #ifdef DWARF_DEBUGGING_INFO
3612 /* Generate the DWARF info for the "abstract" instance
3613 of a function which we may later generate inlined and/or
3614 out-of-line instances of. */
3615 if (write_symbols
== DWARF_DEBUG
)
3617 set_decl_abstract_flags (decl
, 1);
3618 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
3619 set_decl_abstract_flags (decl
, 0);
3622 #ifdef DWARF2_DEBUGGING_INFO
3623 /* Generate the DWARF2 info for the "abstract" instance
3624 of a function which we may later generate inlined and/or
3625 out-of-line instances of. */
3626 if (write_symbols
== DWARF2_DEBUG
)
3628 set_decl_abstract_flags (decl
, 1);
3629 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
3630 set_decl_abstract_flags (decl
, 0);
3633 TIMEVAR (integration_time
, save_for_inline_nocopy (decl
));
3634 DECL_SAVED_INSNS (decl
)->inlinable
= inlinable
;
3635 goto exit_rest_of_compilation
;
3638 /* If specified extern inline but we aren't inlining it, we are
3639 done. This goes for anything that gets here with DECL_EXTERNAL
3640 set, not just things with DECL_INLINE. */
3641 if (DECL_EXTERNAL (decl
))
3642 goto exit_rest_of_compilation
;
3645 /* Initialize some variables used by the optimizers. */
3646 init_function_for_compilation ();
3648 if (! DECL_DEFER_OUTPUT (decl
))
3649 TREE_ASM_WRITTEN (decl
) = 1;
3651 /* Now that integrate will no longer see our rtl, we need not distinguish
3652 between the return value of this function and the return value of called
3654 rtx_equal_function_value_matters
= 0;
3656 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3657 if ((rtl_dump_and_exit
|| flag_syntax_only
) && !warn_return_type
)
3659 goto exit_rest_of_compilation
;
3662 /* Emit code to get eh context, if needed. */
3666 /* If we are doing position-independent code generation, now
3667 is the time to output special prologues and epilogues.
3668 We do not want to do this earlier, because it just clutters
3669 up inline functions with meaningless insns. */
3674 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3675 Note that that may have been done above, in save_for_inline_copying.
3676 The call to resume_temporary_allocation near the end of this function
3677 goes back to the usual state of affairs. This must be done after
3678 we've built up any unwinders for exception handling, and done
3679 the FINALIZE_PIC work, if necessary. */
3681 rtl_in_current_obstack ();
3683 insns
= get_insns ();
3685 /* Copy any shared structure that should not be shared. */
3687 unshare_all_rtl (insns
);
3689 init_EXPR_INSN_LIST_cache ();
3691 #ifdef SETJMP_VIA_SAVE_AREA
3692 /* This must be performed before virutal register instantiation. */
3693 if (current_function_calls_alloca
)
3694 optimize_save_area_alloca (insns
);
3697 /* Instantiate all virtual registers. */
3699 instantiate_virtual_regs (current_function_decl
, get_insns ());
3701 /* See if we have allocated stack slots that are not directly addressable.
3702 If so, scan all the insns and create explicit address computation
3703 for all references to such slots. */
3704 /* fixup_stack_slots (); */
3706 /* Find all the EH handlers. */
3707 find_exception_handler_labels ();
3709 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3710 are initialized and to compute whether control can drop off the end
3712 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3713 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
3714 JUMP_AFTER_REGSCAN
));
3716 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3717 if (rtl_dump_and_exit
|| flag_syntax_only
|| DECL_DEFER_OUTPUT (decl
))
3718 goto exit_rest_of_compilation
;
3720 /* Try to identify useless null pointer tests and delete them. */
3721 if (flag_delete_null_pointer_checks
)
3722 TIMEVAR (jump_time
, delete_null_pointer_checks (get_insns ()));
3724 /* Dump rtl code after jump, if we are doing that. */
3726 dump_rtl (".jump", decl
, print_rtl
, insns
);
3731 /* Perform common subexpression elimination.
3732 Nonzero value from `cse_main' means that jumps were simplified
3733 and some code may now be unreachable, so do
3734 jump optimization again. */
3739 open_dump_file (".cse", decl_printable_name (decl
, 2));
3741 TIMEVAR (cse_time
, reg_scan (insns
, max_reg_num (), 1));
3743 if (flag_thread_jumps
)
3744 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 1));
3746 TIMEVAR (cse_time
, tem
= cse_main (insns
, max_reg_num (),
3748 /* If we are not running the second CSE pass, then we are no longer
3749 expecting CSE to be run. */
3750 cse_not_expected
= !flag_rerun_cse_after_loop
;
3752 if (tem
|| optimize
> 1)
3753 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3755 !JUMP_AFTER_REGSCAN
));
3757 /* Run this after jump optmizations remove all the unreachable code
3758 so that unreachable code will not keep values live. */
3759 TIMEVAR (cse_time
, delete_trivially_dead_insns (insns
, max_reg_num ()));
3761 /* Try to identify useless null pointer tests and delete them. */
3762 if (flag_delete_null_pointer_checks
)
3763 TIMEVAR (jump_time
, delete_null_pointer_checks (get_insns ()));
3765 /* Dump rtl code after cse, if we are doing that. */
3769 close_dump_file (print_rtl
, insns
);
3770 if (graph_dump_format
!= no_graph
)
3771 print_rtl_graph_with_bb (dump_base_name
, ".cse", insns
);
3775 purge_addressof (insns
);
3776 reg_scan (insns
, max_reg_num (), 1);
3780 dump_rtl (".addressof", decl
, print_rtl
, insns
);
3781 if (graph_dump_format
!= no_graph
)
3782 print_rtl_graph_with_bb (dump_base_name
, ".addressof", insns
);
3788 /* Perform global cse. */
3790 if (optimize
> 0 && flag_gcse
)
3793 open_dump_file (".gcse", decl_printable_name (decl
, 2));
3795 TIMEVAR (gcse_time
, tem
= gcse_main (insns
, rtl_dump_file
));
3797 /* If gcse altered any jumps, rerun jump optimizations to clean
3801 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3803 !JUMP_AFTER_REGSCAN
));
3808 close_dump_file (print_rtl
, insns
);
3809 if (graph_dump_format
!= no_graph
)
3810 print_rtl_graph_with_bb (dump_base_name
, ".gcse", insns
);
3816 /* Move constant computations out of loops. */
3821 open_dump_file (".loop", decl_printable_name (decl
, 2));
3826 if (flag_rerun_loop_opt
)
3828 /* We only want to perform unrolling once. */
3830 loop_optimize (insns
, rtl_dump_file
, 0, 0);
3833 /* The first call to loop_optimize makes some instructions
3834 trivially dead. We delete those instructions now in the
3835 hope that doing so will make the heuristics in loop work
3836 better and possibly speed up compilation. */
3837 delete_trivially_dead_insns (insns
, max_reg_num ());
3839 /* The regscan pass is currently necessary as the alias
3840 analysis code depends on this information. */
3841 reg_scan (insns
, max_reg_num (), 1);
3843 loop_optimize (insns
, rtl_dump_file
, flag_unroll_loops
, 1);
3846 /* Dump rtl code after loop opt, if we are doing that. */
3850 close_dump_file (print_rtl
, insns
);
3851 if (graph_dump_format
!= no_graph
)
3852 print_rtl_graph_with_bb (dump_base_name
, ".loop", insns
);
3862 open_dump_file (".cse2", decl_printable_name (decl
, 2));
3864 if (flag_rerun_cse_after_loop
)
3866 /* Running another jump optimization pass before the second
3867 cse pass sometimes simplifies the RTL enough to allow
3868 the second CSE pass to do a better job. Jump_optimize can change
3869 max_reg_num so we must rerun reg_scan afterwards.
3870 ??? Rework to not call reg_scan so often. */
3871 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3872 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3874 JUMP_AFTER_REGSCAN
));
3876 TIMEVAR (cse2_time
, reg_scan (insns
, max_reg_num (), 0));
3877 TIMEVAR (cse2_time
, tem
= cse_main (insns
, max_reg_num (),
3880 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3882 !JUMP_AFTER_REGSCAN
));
3885 if (flag_thread_jumps
)
3887 /* This pass of jump threading straightens out code
3888 that was kinked by loop optimization. */
3889 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3890 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 0));
3893 /* Dump rtl code after cse, if we are doing that. */
3897 close_dump_file (print_rtl
, insns
);
3898 if (graph_dump_format
!= no_graph
)
3899 print_rtl_graph_with_bb (dump_base_name
, ".cse2", insns
);
3906 if (profile_arc_flag
|| flag_test_coverage
|| flag_branch_probabilities
)
3908 if (branch_prob_dump
)
3909 open_dump_file (".bp", decl_printable_name (decl
, 2));
3914 branch_prob (insns
, rtl_dump_file
);
3917 if (branch_prob_dump
)
3919 close_dump_file (print_rtl
, insns
);
3920 if (graph_dump_format
!= no_graph
)
3921 print_rtl_graph_with_bb (dump_base_name
, ".bp", insns
);
3928 /* We are no longer anticipating cse in this function, at least. */
3930 cse_not_expected
= 1;
3932 /* Now we choose between stupid (pcc-like) register allocation
3933 (if we got the -noreg switch and not -opt)
3934 and smart register allocation. */
3936 if (optimize
> 0) /* Stupid allocation probably won't work */
3937 obey_regdecls
= 0; /* if optimizations being done. */
3941 /* Print function header into flow dump now
3942 because doing the flow analysis makes some of the dump. */
3945 open_dump_file (".flow", decl_printable_name (decl
, 2));
3951 regclass (insns
, max_reg_num ());
3952 stupid_life_analysis (insns
, max_reg_num (),
3958 /* Do control and data flow analysis,
3959 and write some of the results to dump file. */
3964 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
, 1);
3965 life_analysis (insns
, max_reg_num (), rtl_dump_file
, 1);
3968 if (warn_uninitialized
)
3970 uninitialized_vars_warning (DECL_INITIAL (decl
));
3971 setjmp_args_warning ();
3975 /* Dump rtl after flow analysis. */
3979 close_dump_file (print_rtl_with_bb
, insns
);
3980 if (graph_dump_format
!= no_graph
)
3981 print_rtl_graph_with_bb (dump_base_name
, ".flow", insns
);
3987 /* The first life analysis pass has finished. From now on we can not
3988 generate any new pseudos. */
3991 /* If -opt, try combining insns through substitution. */
3995 TIMEVAR (combine_time
, combine_instructions (insns
, max_reg_num ()));
3997 /* Dump rtl code after insn combination. */
4001 dump_rtl (".combine", decl
, print_rtl_with_bb
, insns
);
4002 if (graph_dump_format
!= no_graph
)
4003 print_rtl_graph_with_bb (dump_base_name
, ".combine", insns
);
4010 /* Register allocation pre-pass, to reduce number of moves
4011 necessary for two-address machines. */
4012 if (optimize
> 0 && (flag_regmove
|| flag_expensive_optimizations
))
4015 open_dump_file (".regmove", decl_printable_name (decl
, 2));
4017 TIMEVAR (regmove_time
, regmove_optimize (insns
, max_reg_num (),
4022 close_dump_file (print_rtl_with_bb
, insns
);
4023 if (graph_dump_format
!= no_graph
)
4024 print_rtl_graph_with_bb (dump_base_name
, ".regmove", insns
);
4031 /* Print function header into sched dump now
4032 because doing the sched analysis makes some of the dump. */
4034 if (optimize
> 0 && flag_schedule_insns
)
4037 open_dump_file (".sched", decl_printable_name (decl
, 2));
4039 /* Do control and data sched analysis,
4040 and write some of the results to dump file. */
4042 TIMEVAR (sched_time
, schedule_insns (rtl_dump_file
));
4044 /* Dump rtl after instruction scheduling. */
4048 close_dump_file (print_rtl_with_bb
, insns
);
4049 if (graph_dump_format
!= no_graph
)
4050 print_rtl_graph_with_bb (dump_base_name
, ".sched", insns
);
4057 /* Determine if the current function is a leaf before running reload
4058 since this can impact optimizations done by the prologue and
4059 epilogue thus changing register elimination offsets. */
4060 current_function_is_leaf
= leaf_function_p ();
4062 /* Unless we did stupid register allocation,
4063 allocate pseudo-regs that are used only within 1 basic block.
4065 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
4066 jump optimizer after register allocation and reloading are finished. */
4069 TIMEVAR (local_alloc_time
,
4071 recompute_reg_usage (insns
, ! optimize_size
);
4072 regclass (insns
, max_reg_num ());
4073 rebuild_label_notes_after_reload
= local_alloc ();
4076 rebuild_label_notes_after_reload
= 0;
4078 /* Dump rtl code after allocating regs within basic blocks. */
4082 open_dump_file (".lreg", decl_printable_name (decl
, 2));
4084 TIMEVAR (dump_time
, dump_flow_info (rtl_dump_file
));
4085 TIMEVAR (dump_time
, dump_local_alloc (rtl_dump_file
));
4087 close_dump_file (print_rtl_with_bb
, insns
);
4088 if (graph_dump_format
!= no_graph
)
4089 print_rtl_graph_with_bb (dump_base_name
, ".lreg", insns
);
4095 if (global_reg_dump
)
4096 open_dump_file (".greg", decl_printable_name (decl
, 2));
4098 /* Unless we did stupid register allocation,
4099 allocate remaining pseudo-regs, then do the reload pass
4100 fixing up any insns that are invalid. */
4102 TIMEVAR (global_alloc_time
,
4105 failure
= global_alloc (rtl_dump_file
);
4107 failure
= reload (insns
, 0, rtl_dump_file
);
4112 goto exit_rest_of_compilation
;
4117 /* Do a very simple CSE pass over just the hard registers. */
4119 reload_cse_regs (insns
);
4121 /* Register allocation and reloading may have turned an indirect jump into
4122 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
4123 jumping instructions. */
4124 if (rebuild_label_notes_after_reload
)
4125 TIMEVAR (jump_time
, rebuild_jump_labels (insns
));
4127 /* If optimizing and we are performing instruction scheduling after
4128 reload, then go ahead and split insns now since we are about to
4129 recompute flow information anyway.
4131 reload_cse_regs may expose more splitting opportunities, expecially
4132 for double-word operations. */
4133 if (optimize
> 0 && flag_schedule_insns_after_reload
)
4137 for (insn
= insns
; insn
; insn
= NEXT_INSN (insn
))
4141 if (GET_RTX_CLASS (GET_CODE (insn
)) != 'i')
4144 last
= try_split (PATTERN (insn
), insn
, 1);
4148 PUT_CODE (insn
, NOTE
);
4149 NOTE_SOURCE_FILE (insn
) = 0;
4150 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
4155 if (global_reg_dump
)
4157 TIMEVAR (dump_time
, dump_global_regs (rtl_dump_file
));
4158 close_dump_file (print_rtl_with_bb
, insns
);
4159 if (graph_dump_format
!= no_graph
)
4160 print_rtl_graph_with_bb (dump_base_name
, ".greg", insns
);
4163 /* Re-create the death notes which were deleted during reload. */
4165 open_dump_file (".flow2", decl_printable_name (decl
, 2));
4172 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
, 1);
4173 life_analysis (insns
, max_reg_num (), rtl_dump_file
, 1);
4180 flow2_completed
= 1;
4182 /* On some machines, the prologue and epilogue code, or parts thereof,
4183 can be represented as RTL. Doing so lets us schedule insns between
4184 it and the rest of the code and also allows delayed branch
4185 scheduling to operate in the epilogue. */
4187 thread_prologue_and_epilogue_insns (insns
);
4191 close_dump_file (print_rtl_with_bb
, insns
);
4192 if (graph_dump_format
!= no_graph
)
4193 print_rtl_graph_with_bb (dump_base_name
, ".flow2", insns
);
4196 #ifdef HAVE_peephole2
4197 if (optimize
> 0 && flag_peephole2
)
4200 open_dump_file (".peephole2", decl_printable_name (decl
, 2));
4202 peephole2_optimize (rtl_dump_file
);
4206 close_dump_file (print_rtl_with_bb
, insns
);
4207 if (graph_dump_format
!= no_graph
)
4208 print_rtl_graph_with_bb (dump_base_name
, ".peephole2", insns
);
4213 if (optimize
> 0 && flag_schedule_insns_after_reload
)
4216 open_dump_file (".sched2", decl_printable_name (decl
, 2));
4218 /* Do control and data sched analysis again,
4219 and write some more of the results to dump file. */
4221 TIMEVAR (sched2_time
, schedule_insns (rtl_dump_file
));
4223 /* Dump rtl after post-reorder instruction scheduling. */
4227 close_dump_file (print_rtl_with_bb
, insns
);
4228 if (graph_dump_format
!= no_graph
)
4229 print_rtl_graph_with_bb (dump_base_name
, ".sched2", insns
);
4236 #ifdef LEAF_REGISTERS
4237 current_function_uses_only_leaf_regs
4238 = optimize
> 0 && only_leaf_regs_used () && leaf_function_p ();
4241 /* One more attempt to remove jumps to .+1
4242 left by dead-store-elimination.
4243 Also do cross-jumping this time
4244 and delete no-op move insns. */
4248 TIMEVAR (jump_time
, jump_optimize (insns
, JUMP_CROSS_JUMP
,
4250 !JUMP_AFTER_REGSCAN
));
4252 /* Dump rtl code after jump, if we are doing that. */
4256 dump_rtl (".jump2", decl
, print_rtl_with_bb
, insns
);
4257 if (graph_dump_format
!= no_graph
)
4258 print_rtl_graph_with_bb (dump_base_name
, ".jump2", insns
);
4262 /* If a machine dependent reorganization is needed, call it. */
4263 #ifdef MACHINE_DEPENDENT_REORG
4264 if (mach_dep_reorg_dump
)
4265 open_dump_file (".mach", decl_printable_name (decl
, 2));
4267 MACHINE_DEPENDENT_REORG (insns
);
4269 if (mach_dep_reorg_dump
)
4271 close_dump_file (print_rtl_with_bb
, insns
);
4272 if (graph_dump_format
!= no_graph
)
4273 print_rtl_graph_with_bb (dump_base_name
, ".mach", insns
);
4280 /* If a scheduling pass for delayed branches is to be done,
4281 call the scheduling code. */
4284 if (optimize
> 0 && flag_delayed_branch
)
4287 open_dump_file (".dbr", decl_printable_name (decl
, 2));
4289 TIMEVAR (dbr_sched_time
, dbr_schedule (insns
, rtl_dump_file
));
4293 close_dump_file (print_rtl_with_bb
, insns
);
4294 if (graph_dump_format
!= no_graph
)
4295 print_rtl_graph_with_bb (dump_base_name
, ".dbr", insns
);
4303 /* Shorten branches. */
4304 TIMEVAR (shorten_branch_time
,
4306 shorten_branches (get_insns ());
4311 open_dump_file (".stack", decl_printable_name (decl
, 2));
4313 TIMEVAR (stack_reg_time
, reg_to_stack (insns
, rtl_dump_file
));
4317 dump_rtl (".stack", decl
, print_rtl_with_bb
, insns
);
4318 if (graph_dump_format
!= no_graph
)
4319 print_rtl_graph_with_bb (dump_base_name
, ".stack", insns
);
4326 /* Now turn the rtl into assembler code. */
4328 TIMEVAR (final_time
,
4333 /* Get the function's name, as described by its RTL.
4334 This may be different from the DECL_NAME name used
4335 in the source file. */
4337 x
= DECL_RTL (decl
);
4338 if (GET_CODE (x
) != MEM
)
4341 if (GET_CODE (x
) != SYMBOL_REF
)
4343 fnname
= XSTR (x
, 0);
4345 assemble_start_function (decl
, fnname
);
4346 final_start_function (insns
, asm_out_file
, optimize
);
4347 final (insns
, asm_out_file
, optimize
, 0);
4348 final_end_function (insns
, asm_out_file
, optimize
);
4349 assemble_end_function (decl
, fnname
);
4351 fflush (asm_out_file
);
4353 /* Release all memory allocated by flow. */
4354 free_basic_block_vars (0);
4356 /* Release all memory held by regsets now */
4357 regset_release_memory ();
4363 /* Write DBX symbols if requested */
4365 /* Note that for those inline functions where we don't initially
4366 know for certain that we will be generating an out-of-line copy,
4367 the first invocation of this routine (rest_of_compilation) will
4368 skip over this code by doing a `goto exit_rest_of_compilation;'.
4369 Later on, finish_compilation will call rest_of_compilation again
4370 for those inline functions that need to have out-of-line copies
4371 generated. During that call, we *will* be routed past here. */
4373 #ifdef DBX_DEBUGGING_INFO
4374 if (write_symbols
== DBX_DEBUG
)
4375 TIMEVAR (symout_time
, dbxout_function (decl
));
4378 #ifdef DWARF_DEBUGGING_INFO
4379 if (write_symbols
== DWARF_DEBUG
)
4380 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
4383 #ifdef DWARF2_DEBUGGING_INFO
4384 if (write_symbols
== DWARF2_DEBUG
)
4385 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
4388 exit_rest_of_compilation
:
4392 /* In case the function was not output,
4393 don't leave any temporary anonymous types
4394 queued up for sdb output. */
4395 #ifdef SDB_DEBUGGING_INFO
4396 if (write_symbols
== SDB_DEBUG
)
4397 sdbout_types (NULL_TREE
);
4400 /* Put back the tree of subblocks and list of arguments
4401 from before we copied them.
4402 Code generation and the output of debugging info may have modified
4403 the copy, but the original is unchanged. */
4405 if (saved_block_tree
!= 0)
4407 DECL_INITIAL (decl
) = saved_block_tree
;
4408 DECL_ARGUMENTS (decl
) = saved_arguments
;
4409 DECL_ABSTRACT_ORIGIN (decl
) = NULL_TREE
;
4412 reload_completed
= 0;
4413 flow2_completed
= 0;
4416 TIMEVAR (final_time
,
4418 /* Clear out the insn_length contents now that they are no
4420 init_insn_lengths ();
4422 /* Clear out the real_constant_chain before some of the rtx's
4423 it runs through become garbage. */
4424 clear_const_double_mem ();
4426 /* Cancel the effect of rtl_in_current_obstack. */
4427 resume_temporary_allocation ();
4429 /* Show no temporary slots allocated. */
4432 free_basic_block_vars (0);
4435 /* Make sure volatile mem refs aren't considered valid operands for
4436 arithmetic insns. We must call this here if this is a nested inline
4437 function, since the above code leaves us in the init_recog state
4438 (from final.c), and the function context push/pop code does not
4439 save/restore volatile_ok.
4441 ??? Maybe it isn't necessary for expand_start_function to call this
4442 anymore if we do it here? */
4444 init_recog_no_volatile ();
4446 /* We're done with this function. Free up memory if we can. */
4447 free_after_parsing (current_function
);
4448 if (! DECL_DEFER_OUTPUT (decl
))
4449 free_after_compilation (current_function
);
4450 current_function
= 0;
4455 /* The parsing time is all the time spent in yyparse
4456 *except* what is spent in this function. */
4458 parse_time
-= get_run_time () - start_time
;
4469 printf ("Usage: %s input [switches]\n", progname
);
4470 printf ("Switches:\n");
4472 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
4473 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
4474 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4475 printf (" -finline-limit=<number> Limits the size of inlined functions to <number>\n");
4477 for (i
= NUM_ELEM (f_options
); i
--;)
4479 const char * description
= f_options
[i
].description
;
4481 if (description
!= NULL
&& * description
!= 0)
4482 printf (" -f%-21s %s\n",
4483 f_options
[i
].string
, description
);
4486 printf (" -O[number] Set optimisation level to [number]\n");
4487 printf (" -Os Optimise for space rather than speed\n");
4488 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
4489 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
4490 printf (" -w Suppress warnings\n");
4491 printf (" -W Enable extra warnings\n");
4493 for (i
= NUM_ELEM (W_options
); i
--;)
4495 const char * description
= W_options
[i
].description
;
4497 if (description
!= NULL
&& * description
!= 0)
4498 printf (" -W%-21s %s\n",
4499 W_options
[i
].string
, description
);
4502 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4503 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4504 printf (" -p Enable function profiling\n");
4505 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4506 printf (" -a Enable block profiling \n");
4508 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4509 printf (" -ax Enable jump profiling \n");
4511 printf (" -o <file> Place output into <file> \n");
4512 printf (" -G <number> Put global and static data smaller than <number>\n");
4513 printf (" bytes into a special section (on some targets)\n");
4515 for (i
= NUM_ELEM (debug_args
); i
--;)
4517 if (debug_args
[i
].description
!= NULL
)
4518 printf (" -g%-21s %s\n", debug_args
[i
].arg
, debug_args
[i
].description
);
4521 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4522 printf (" -quiet Do not display functions compiled or elapsed time\n");
4523 printf (" -version Display the compiler's version\n");
4524 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4525 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4526 #if defined INSN_SCHEDULING
4527 printf (" -sched-verbose=<number> Set the verbosity level of the scheduler\n");
4529 printf (" --help Display this information\n");
4534 /* Display descriptions of language specific options.
4535 If there is no description, note that there is an undocumented option.
4536 If the description is empty, do not display anything. (This allows
4537 options to be deliberately undocumented, for whatever reason).
4538 If the option string is missing, then this is a marker, indicating
4539 that the description string is in fact the name of a language, whose
4540 language specific options are to follow. */
4542 if (NUM_ELEM (documented_lang_options
) > 1)
4544 printf ("\nLanguage specific options:\n");
4546 for (i
= 0; i
< NUM_ELEM (documented_lang_options
); i
++)
4548 const char * description
= documented_lang_options
[i
].description
;
4549 const char * option
= documented_lang_options
[i
].option
;
4551 if (description
== NULL
)
4556 printf (" %-23.23s [undocumented]\n", option
);
4558 else if (* description
== 0)
4560 else if (option
== NULL
)
4564 ("\nThere are undocumented %s specific options as well.\n",
4568 printf ("\n Options for %s:\n", description
);
4573 printf (" %-23.23s %s\n", option
, description
);
4578 printf ("\nThere are undocumented %s specific options as well.\n", lang
);
4580 if (NUM_ELEM (target_switches
) > 1
4581 #ifdef TARGET_OPTIONS
4582 || NUM_ELEM (target_options
) > 1
4590 printf ("\nTarget specific options:\n");
4592 for (i
= NUM_ELEM (target_switches
); i
--;)
4594 const char * option
= target_switches
[i
].name
;
4595 const char * description
= target_switches
[i
].description
;
4597 if (option
== NULL
|| * option
== 0)
4599 else if (description
== NULL
)
4604 printf (" -m%-21.21s [undocumented]\n", option
);
4606 else if (* description
!= 0)
4607 doc
+= printf (" -m%-21.21s %s\n", option
, description
);
4610 #ifdef TARGET_OPTIONS
4611 for (i
= NUM_ELEM (target_options
); i
--;)
4613 const char * option
= target_options
[i
].prefix
;
4614 const char * description
= target_options
[i
].description
;
4616 if (option
== NULL
|| * option
== 0)
4618 else if (description
== NULL
)
4623 printf (" -m%-21.21s [undocumented]\n", option
);
4625 else if (* description
!= 0)
4626 doc
+= printf (" -m%-21.21s %s\n", option
, description
);
4632 printf ("\nThere are undocumented target specific options as well.\n");
4634 printf (" They exist, but they are not documented.\n");
4639 /* Parse a -d... comand line switch. */
4642 decode_d_option (arg
)
4649 branch_prob_dump
= 1;
4656 global_reg_dump
= 1;
4672 #ifdef MACHINE_DEPENDENT_REORG
4673 mach_dep_reorg_dump
= 1;
4681 branch_prob_dump
= 1;
4698 global_reg_dump
= 1;
4723 #ifdef MACHINE_DEPENDENT_REORG
4725 mach_dep_reorg_dump
= 1;
4729 flag_print_asm_name
= 1;
4750 graph_dump_format
= vcg
;
4756 rtl_dump_and_exit
= 1;
4764 case 'D': /* These are handled by the preprocessor. */
4768 warning ("unrecognised gcc debugging option: %c", arg
[-1]);
4773 /* Parse a -f... comand line switch. ARG is the value after the -f.
4774 It is safe to access 'ARG - 2' to generate the full switch name.
4775 Return the number of strings consumed. */
4778 decode_f_option (arg
)
4783 /* Search for the option in the table of binary f options. */
4784 for (j
= sizeof (f_options
) / sizeof (f_options
[0]); j
--;)
4786 if (!strcmp (arg
, f_options
[j
].string
))
4788 *f_options
[j
].variable
= f_options
[j
].on_value
;
4792 if (arg
[0] == 'n' && arg
[1] == 'o' && arg
[2] == '-'
4793 && ! strcmp (arg
+ 3, f_options
[j
].string
))
4795 *f_options
[j
].variable
= ! f_options
[j
].on_value
;
4800 if (!strncmp (arg
, "inline-limit-", 13)
4801 || !strncmp (arg
, "inline-limit=", 13))
4803 read_integral_parameter (arg
+ 13, arg
- 2, inline_max_insns
);
4804 #ifdef INSN_SCHEDULING
4805 else if (!strncmp (arg
, "sched-verbose=", 14))
4806 fix_sched_param ("verbose", (char *)(arg
+ 14));
4808 else if (!strncmp (arg
, "fixed-", 6))
4809 fix_register ((char *)(arg
+ 6), 1, 1);
4810 else if (!strncmp (arg
, "call-used-", 10))
4811 fix_register ((char *)(arg
+ 10), 0, 1);
4812 else if (!strncmp (arg
, "call-saved-", 11))
4813 fix_register ((char *)(arg
+ 11), 0, 0);
4814 else if (!strncmp (arg
, "align-loops=", 12))
4815 align_loops
= read_integral_parameter (arg
+ 12, arg
- 2, align_loops
);
4816 else if (!strncmp (arg
, "align-functions=", 16))
4818 read_integral_parameter (arg
+ 16, arg
- 2, align_functions
);
4819 else if (!strncmp (arg
, "align-jumps=", 12))
4820 align_jumps
= read_integral_parameter (arg
+ 12, arg
- 2, align_jumps
);
4821 else if (!strncmp (arg
, "align-labels=", 13))
4822 align_labels
= read_integral_parameter (arg
+ 13, arg
- 2, align_labels
);
4823 else if (!strcmp (arg
, "preprocessed"))
4824 /* Recognise this switch but do nothing. This prevents warnings
4825 about an unrecognised switch if cpplib has not been linked in. */
4833 /* Parse a -W... comand line switch. ARG is the value after the -W.
4834 It is safe to access 'ARG - 2' to generate the full switch name.
4835 Return the number of strings consumed. */
4837 decode_W_option (arg
)
4842 /* Search for the option in the table of binary W options. */
4844 for (j
= sizeof (W_options
) / sizeof (W_options
[0]); j
--;)
4846 if (!strcmp (arg
, W_options
[j
].string
))
4848 *W_options
[j
].variable
= W_options
[j
].on_value
;
4852 if (arg
[0] == 'n' && arg
[1] == 'o' && arg
[2] == '-'
4853 && ! strcmp (arg
+ 3, W_options
[j
].string
))
4855 *W_options
[j
].variable
= ! W_options
[j
].on_value
;
4860 if (!strncmp (arg
, "id-clash-", 9))
4862 const int id_clash_val
= read_integral_parameter (arg
+ 9, arg
- 2, -1);
4864 if (id_clash_val
!= -1)
4866 id_clash_len
= id_clash_val
;
4870 else if (!strncmp (arg
, "larger-than-", 12))
4872 const int larger_than_val
=
4873 read_integral_parameter (arg
+ 12, arg
- 2, -1);
4874 if (larger_than_val
!= -1)
4876 larger_than_size
= larger_than_val
;
4877 warn_larger_than
= 1;
4886 /* Parse a -g... comand line switch. ARG is the value after the -g.
4887 It is safe to access 'ARG - 2' to generate the full switch name.
4888 Return the number of strings consumed. */
4890 decode_g_option (arg
)
4894 /* A lot of code assumes write_symbols == NO_DEBUG if the
4895 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4896 of what debugging type has been selected). This records the
4897 selected type. It is an error to specify more than one
4899 static enum debug_info_type selected_debug_type
= NO_DEBUG
;
4900 /* Non-zero if debugging format has been explicitly set.
4901 -g and -ggdb don't explicitly set the debugging format so
4902 -gdwarf -g3 is equivalent to -gdwarf3. */
4903 static int type_explicitly_set_p
= 0;
4904 /* Indexed by enum debug_info_type. */
4905 static const char * debug_type_names
[] =
4907 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4910 /* The maximum admissible debug level value. */
4911 static const unsigned max_debug_level
= 3;
4913 /* Look up ARG in the table. */
4914 for (da
= debug_args
; da
->arg
; da
++)
4916 const int da_len
= strlen (da
->arg
);
4918 if (da_len
== 0 || ! strncmp (arg
, da
->arg
, da_len
))
4920 enum debug_info_type type
= da
->debug_type
;
4921 const char * p
= arg
+ da_len
;
4923 if (*p
&& (*p
< '0' || *p
> '9'))
4926 /* A debug flag without a level defaults to level 2.
4927 Note we do not want to call read_integral_parameter
4928 for that case since it will call atoi which
4931 ??? We may want to generalize the interface to
4932 read_integral_parameter to better handle this case
4933 if this case shows up often. */
4935 level
= read_integral_parameter (p
, 0, max_debug_level
+ 1);
4939 if (da_len
> 1 && *p
&& !strncmp (arg
, "dwarf", da_len
))
4941 error ("use -gdwarf -g%d for DWARF v1, level %d",
4944 error ("use -gdwarf-2 for DWARF v2");
4947 if (level
> max_debug_level
)
4950 ignoring option `%s' due to invalid debug level specification",
4952 level
= debug_info_level
;
4955 if (type
== NO_DEBUG
)
4957 type
= PREFERRED_DEBUGGING_TYPE
;
4959 if (da_len
> 1 && strncmp (arg
, "gdb", da_len
) == 0)
4961 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4962 type
= DWARF2_DEBUG
;
4964 #ifdef DBX_DEBUGGING_INFO
4971 if (type
== NO_DEBUG
)
4972 warning ("`%s' not supported by this configuration of GCC",
4975 /* Does it conflict with an already selected type? */
4976 if (type_explicitly_set_p
4977 /* -g/-ggdb don't conflict with anything */
4978 && da
->debug_type
!= NO_DEBUG
4979 && type
!= selected_debug_type
)
4980 warning ("`%s' ignored, conflicts with `-g%s'",
4981 arg
- 2, debug_type_names
[(int) selected_debug_type
]);
4984 /* If the format has already been set, -g/-ggdb
4985 only change the debug level. */
4986 if (type_explicitly_set_p
&& da
->debug_type
== NO_DEBUG
)
4987 ; /* don't change debugging type */
4990 selected_debug_type
= type
;
4991 type_explicitly_set_p
= da
->debug_type
!= NO_DEBUG
;
4994 write_symbols
= (level
== 0
4996 : selected_debug_type
);
4997 use_gnu_debug_info_extensions
= da
->use_extensions_p
;
4998 debug_info_level
= (enum debug_info_level
) level
;
5006 warning ("`%s' not supported by this configuration of GCC", arg
- 2);
5011 /* Decode the first argument in the argv as a language-independent option.
5012 Return the number of strings consumed. 'strings_processed' is the
5013 number of strings that have already been decoded in a language
5014 specific fashion before this function was invoked. */
5017 independent_decode_option (argc
, argv
, strings_processed
)
5020 unsigned strings_processed ATTRIBUTE_UNUSED
;
5022 char * arg
= argv
[0];
5024 if (arg
[0] != '-' || arg
[1] == 0)
5036 if (!strcmp (arg
, "-help"))
5051 /* Already been treated in main (). Do nothing. */
5055 set_target_switch (arg
+ 1);
5059 return decode_f_option (arg
+ 1);
5062 return decode_g_option (arg
+ 1);
5065 if (!strcmp (arg
, "dumpbase"))
5070 dump_base_name
= argv
[1];
5074 decode_d_option (arg
+ 1);
5078 if (!strcmp (arg
, "pedantic"))
5080 else if (!strcmp (arg
, "pedantic-errors"))
5081 flag_pedantic_errors
= pedantic
= 1;
5082 else if (arg
[1] == 0)
5089 if (!strcmp (arg
, "quiet"))
5096 if (!strcmp (arg
, "version"))
5104 inhibit_warnings
= 1;
5113 /* We save the value of warn_uninitialized, since if they put
5114 -Wuninitialized on the command line, we need to generate a
5115 warning about not using it without also specifying -O. */
5116 if (warn_uninitialized
!= 1)
5117 warn_uninitialized
= 2;
5120 return decode_W_option (arg
+ 1);
5126 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5127 warning ("`-a' option (basic block profile) not supported");
5129 profile_block_flag
= (profile_block_flag
< 2) ? 1 : 3;
5132 else if (!strcmp (arg
, "ax"))
5134 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5135 warning ("`-ax' option (jump profiling) not supported");
5137 profile_block_flag
= (!profile_block_flag
5138 || profile_block_flag
== 2) ? 2 : 3;
5141 else if (!strncmp (arg
, "aux-info", 8))
5143 flag_gen_aux_info
= 1;
5149 aux_info_file_name
= argv
[1];
5153 aux_info_file_name
= arg
+ 8;
5165 asm_file_name
= argv
[1];
5180 g_switch_val
= read_integral_parameter (argv
[1], 0, -1);
5185 g_switch_val
= read_integral_parameter (arg
+ 1, 0, -1);
5189 if (g_switch_val
== -1)
5193 g_switch_set
= TRUE
;
5194 g_switch_value
= g_switch_val
;
5204 /* Entry point of cc1/c++. Decode command args, then call compile_file.
5205 Exit code is 35 if can't open files, 34 if fatal error,
5206 33 if had nonfatal errors, else success. */
5208 extern int main
PROTO ((int, char **));
5218 /* save in case md file wants to emit args as a comment. */
5222 p
= argv
[0] + strlen (argv
[0]);
5223 while (p
!= argv
[0] && p
[-1] != '/'
5224 #ifdef DIR_SEPARATOR
5225 && p
[-1] != DIR_SEPARATOR
5231 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
5232 /* Get rid of any avoidable limit on stack size. */
5236 /* Set the stack limit huge so that alloca does not fail. */
5237 getrlimit (RLIMIT_STACK
, &rlim
);
5238 rlim
.rlim_cur
= rlim
.rlim_max
;
5239 setrlimit (RLIMIT_STACK
, &rlim
);
5243 #ifdef HAVE_LC_MESSAGES
5244 setlocale (LC_MESSAGES
, "");
5246 (void) bindtextdomain (PACKAGE
, localedir
);
5247 (void) textdomain (PACKAGE
);
5249 signal (SIGFPE
, float_signal
);
5252 signal (SIGPIPE
, pipe_closed
);
5255 decl_printable_name
= decl_name
;
5256 lang_expand_expr
= (lang_expand_expr_t
) do_abort
;
5258 /* Initialize whether `char' is signed. */
5259 flag_signed_char
= DEFAULT_SIGNED_CHAR
;
5260 #ifdef DEFAULT_SHORT_ENUMS
5261 /* Initialize how much space enums occupy, by default. */
5262 flag_short_enums
= DEFAULT_SHORT_ENUMS
;
5265 /* Initialize the garbage-collector. */
5267 ggc_add_root (&input_file_stack
, 1, sizeof input_file_stack
,
5270 /* Perform language-specific options intialization. */
5271 lang_init_options ();
5273 /* Scan to see what optimization level has been specified. That will
5274 determine the default value of many flags. */
5275 for (i
= 1; i
< argc
; i
++)
5277 if (!strcmp (argv
[i
], "-O"))
5282 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'O')
5284 /* Handle -Os, -O2, -O3, -O69, ... */
5285 char *p
= &argv
[i
][2];
5287 if ((p
[0] == 's') && (p
[1] == 0))
5291 /* Optimizing for size forces optimize to be 2. */
5296 const int optimize_val
= read_integral_parameter (p
, p
- 2, -1);
5297 if (optimize_val
!= -1)
5299 optimize
= optimize_val
;
5306 obey_regdecls
= (optimize
== 0);
5311 flag_thread_jumps
= 1;
5313 flag_delayed_branch
= 1;
5315 #ifdef CAN_DEBUG_WITHOUT_FP
5316 flag_omit_frame_pointer
= 1;
5322 flag_cse_follow_jumps
= 1;
5323 flag_cse_skip_blocks
= 1;
5325 flag_expensive_optimizations
= 1;
5326 flag_strength_reduce
= 1;
5327 flag_rerun_cse_after_loop
= 1;
5328 flag_rerun_loop_opt
= 1;
5329 flag_caller_saves
= 1;
5332 #ifdef INSN_SCHEDULING
5333 flag_schedule_insns
= 1;
5334 flag_schedule_insns_after_reload
= 1;
5337 flag_strict_aliasing
= 1;
5338 flag_delete_null_pointer_checks
= 1;
5343 flag_inline_functions
= 1;
5346 if (optimize
< 2 || optimize_size
)
5351 align_functions
= 1;
5354 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
5357 set_target_switch ("");
5359 #ifdef OPTIMIZATION_OPTIONS
5360 /* Allow default optimizations to be specified on a per-machine basis. */
5361 OPTIMIZATION_OPTIONS (optimize
, optimize_size
);
5364 /* Initialize register usage now so switches may override. */
5367 /* Perform normal command line switch decoding. */
5368 for (i
= 1; i
< argc
;)
5370 unsigned lang_processed
;
5371 unsigned indep_processed
;
5373 /* Give the language a chance to decode the option for itself. */
5374 lang_processed
= lang_decode_option (argc
- i
, argv
+ i
);
5376 /* Now see if the option also has a language independent meaning.
5377 Some options are both language specific and language independent,
5378 eg --help. It is possible that there might be options that should
5379 only be decoded in a language independent way if the were not
5380 decoded in a langauge specific way, which is why 'lang_processed'
5382 indep_processed
= independent_decode_option (argc
- i
, argv
+ i
, lang_processed
);
5384 if (lang_processed
|| indep_processed
)
5385 i
+= lang_processed
> indep_processed
? lang_processed
: indep_processed
;
5388 error ("Invalid option `%s'", argv
[i
]);
5393 /* Checker uses the frame pointer. */
5394 if (flag_check_memory_usage
)
5395 flag_omit_frame_pointer
= 0;
5399 /* Inlining does not work if not optimizing,
5400 so force it not to be done. */
5404 /* The c_decode_option and lang_decode_option functions set
5405 this to `2' if -Wall is used, so we can avoid giving out
5406 lots of errors for people who don't realize what -Wall does. */
5407 if (warn_uninitialized
== 1)
5408 warning ("-Wuninitialized is not supported without -O");
5411 #ifdef OVERRIDE_OPTIONS
5412 /* Some machines may reject certain combinations of options. */
5416 if (exceptions_via_longjmp
== 2)
5418 #ifdef DWARF2_UNWIND_INFO
5419 exceptions_via_longjmp
= ! DWARF2_UNWIND_INFO
;
5421 exceptions_via_longjmp
= 1;
5425 /* Set up the align_*_log variables, defaulting them to 1 if they
5426 were still unset. */
5427 if (align_loops
<= 0) align_loops
= 1;
5428 align_loops_log
= floor_log2 (align_loops
*2-1);
5429 if (align_jumps
<= 0) align_jumps
= 1;
5430 align_jumps_log
= floor_log2 (align_jumps
*2-1);
5431 if (align_labels
<= 0) align_labels
= 1;
5432 align_labels_log
= floor_log2 (align_labels
*2-1);
5433 if (align_functions
<= 0) align_functions
= 1;
5434 align_functions_log
= floor_log2 (align_functions
*2-1);
5436 if (profile_block_flag
== 3)
5438 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
5439 profile_block_flag
= 2;
5442 /* Unrolling all loops implies that standard loop unrolling must also
5444 if (flag_unroll_all_loops
)
5445 flag_unroll_loops
= 1;
5446 /* Loop unrolling requires that strength_reduction be on also. Silently
5447 turn on strength reduction here if it isn't already on. Also, the loop
5448 unrolling code assumes that cse will be run after loop, so that must
5449 be turned on also. */
5450 if (flag_unroll_loops
)
5452 flag_strength_reduce
= 1;
5453 flag_rerun_cse_after_loop
= 1;
5456 /* Warn about options that are not supported on this machine. */
5457 #ifndef INSN_SCHEDULING
5458 if (flag_schedule_insns
|| flag_schedule_insns_after_reload
)
5459 warning ("instruction scheduling not supported on this target machine");
5462 if (flag_delayed_branch
)
5463 warning ("this target machine does not have delayed branches");
5466 user_label_prefix
= USER_LABEL_PREFIX
;
5467 if (flag_leading_underscore
!= -1)
5469 /* If the default prefix is more complicated than "" or "_",
5470 issue a warning and ignore this option. */
5471 if (user_label_prefix
[0] == 0 ||
5472 (user_label_prefix
[0] == '_' && user_label_prefix
[1] == 0))
5474 user_label_prefix
= flag_leading_underscore
? "_" : "";
5477 warning ("-f%sleading-underscore not supported on this target machine",
5478 flag_leading_underscore
? "" : "no-");
5481 /* If we are in verbose mode, write out the version and maybe all the
5482 option flags in use. */
5485 print_version (stderr
, "");
5487 print_switch_values (stderr
, 0, MAX_LINE
, "", " ", "\n");
5490 compile_file (filename
);
5492 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
5495 char *lim
= (char *) sbrk (0);
5497 notice ("Data size %ld.\n", (long) (lim
- (char *) &environ
));
5502 system ("ps -l 1>&2");
5505 #endif /* not USG */
5508 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
5511 return (FATAL_EXIT_CODE
);
5513 return (FATAL_EXIT_CODE
);
5514 return (SUCCESS_EXIT_CODE
);
5517 /* Decode -m switches. */
5518 /* Decode the switch -mNAME. */
5521 set_target_switch (name
)
5525 int valid_target_option
= 0;
5527 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
5528 if (!strcmp (target_switches
[j
].name
, name
))
5530 if (target_switches
[j
].value
< 0)
5531 target_flags
&= ~-target_switches
[j
].value
;
5533 target_flags
|= target_switches
[j
].value
;
5534 valid_target_option
= 1;
5537 #ifdef TARGET_OPTIONS
5538 if (!valid_target_option
)
5539 for (j
= 0; j
< sizeof target_options
/ sizeof target_options
[0]; j
++)
5541 int len
= strlen (target_options
[j
].prefix
);
5542 if (!strncmp (target_options
[j
].prefix
, name
, len
))
5544 *target_options
[j
].variable
= name
+ len
;
5545 valid_target_option
= 1;
5550 if (!valid_target_option
)
5551 error ("Invalid option `%s'", name
);
5554 /* Print version information to FILE.
5555 Each line begins with INDENT (for the case where FILE is the
5556 assembler output file). */
5559 print_version (file
, indent
)
5564 #define __VERSION__ "[?]"
5568 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
5570 "%s%s%s version %s (%s) compiled by CC.\n"
5572 , indent
, *indent
!= 0 ? " " : "",
5573 language_string
, version_string
, TARGET_NAME
, __VERSION__
);
5576 /* Print an option value and return the adjusted position in the line.
5577 ??? We don't handle error returns from fprintf (disk full); presumably
5578 other code will catch a disk full though. */
5581 print_single_switch (file
, pos
, max
, indent
, sep
, term
, type
, name
)
5584 const char *indent
, *sep
, *term
, *type
, *name
;
5586 /* The ultrix fprintf returns 0 on success, so compute the result we want
5587 here since we need it for the following test. */
5588 int len
= strlen (sep
) + strlen (type
) + strlen (name
);
5593 fprintf (file
, "%s", term
);
5598 fprintf (file
, "%s", indent
);
5599 pos
= strlen (indent
);
5601 fprintf (file
, "%s%s%s", sep
, type
, name
);
5606 /* Print active target switches to FILE.
5607 POS is the current cursor position and MAX is the size of a "line".
5608 Each line begins with INDENT and ends with TERM.
5609 Each switch is separated from the next by SEP. */
5612 print_switch_values (file
, pos
, max
, indent
, sep
, term
)
5615 const char *indent
, *sep
, *term
;
5620 /* Print the options as passed. */
5622 pos
= print_single_switch (file
, pos
, max
, indent
, *indent
? " " : "", term
,
5623 _("options passed: "), "");
5625 for (p
= &save_argv
[1]; *p
!= NULL
; p
++)
5629 if (strcmp (*p
, "-o") == 0)
5635 if (strcmp (*p
, "-quiet") == 0)
5637 if (strcmp (*p
, "-version") == 0)
5642 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
, *p
, "");
5645 fprintf (file
, "%s", term
);
5647 /* Print the -f and -m options that have been enabled.
5648 We don't handle language specific options but printing argv
5651 pos
= print_single_switch (file
, 0, max
, indent
, *indent
? " " : "", term
,
5652 _("options enabled: "), "");
5654 for (j
= 0; j
< sizeof f_options
/ sizeof f_options
[0]; j
++)
5655 if (*f_options
[j
].variable
== f_options
[j
].on_value
)
5656 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5657 "-f", f_options
[j
].string
);
5659 /* Print target specific options. */
5661 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
5662 if (target_switches
[j
].name
[0] != '\0'
5663 && target_switches
[j
].value
> 0
5664 && ((target_switches
[j
].value
& target_flags
)
5665 == target_switches
[j
].value
))
5667 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5668 "-m", target_switches
[j
].name
);
5671 #ifdef TARGET_OPTIONS
5672 for (j
= 0; j
< sizeof target_options
/ sizeof target_options
[0]; j
++)
5673 if (*target_options
[j
].variable
!= NULL
)
5676 sprintf (prefix
, "-m%s", target_options
[j
].prefix
);
5677 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5678 prefix
, *target_options
[j
].variable
);
5682 fprintf (file
, "%s", term
);
5685 /* Record the beginning of a new source file, named FILENAME. */
5688 debug_start_source_file (filename
)
5689 register char *filename ATTRIBUTE_UNUSED
;
5691 #ifdef DBX_DEBUGGING_INFO
5692 if (write_symbols
== DBX_DEBUG
)
5693 dbxout_start_new_source_file (filename
);
5695 #ifdef DWARF_DEBUGGING_INFO
5696 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5697 && write_symbols
== DWARF_DEBUG
)
5698 dwarfout_start_new_source_file (filename
);
5699 #endif /* DWARF_DEBUGGING_INFO */
5700 #ifdef DWARF2_DEBUGGING_INFO
5701 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5702 && write_symbols
== DWARF2_DEBUG
)
5703 dwarf2out_start_source_file (filename
);
5704 #endif /* DWARF2_DEBUGGING_INFO */
5705 #ifdef SDB_DEBUGGING_INFO
5706 if (write_symbols
== SDB_DEBUG
)
5707 sdbout_start_new_source_file (filename
);
5711 /* Record the resumption of a source file. LINENO is the line number in
5712 the source file we are returning to. */
5715 debug_end_source_file (lineno
)
5716 register unsigned lineno ATTRIBUTE_UNUSED
;
5718 #ifdef DBX_DEBUGGING_INFO
5719 if (write_symbols
== DBX_DEBUG
)
5720 dbxout_resume_previous_source_file ();
5722 #ifdef DWARF_DEBUGGING_INFO
5723 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5724 && write_symbols
== DWARF_DEBUG
)
5725 dwarfout_resume_previous_source_file (lineno
);
5726 #endif /* DWARF_DEBUGGING_INFO */
5727 #ifdef DWARF2_DEBUGGING_INFO
5728 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5729 && write_symbols
== DWARF2_DEBUG
)
5730 dwarf2out_end_source_file ();
5731 #endif /* DWARF2_DEBUGGING_INFO */
5732 #ifdef SDB_DEBUGGING_INFO
5733 if (write_symbols
== SDB_DEBUG
)
5734 sdbout_resume_previous_source_file ();
5738 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5739 the tail part of the directive line, i.e. the part which is past the
5740 initial whitespace, #, whitespace, directive-name, whitespace part. */
5743 debug_define (lineno
, buffer
)
5744 register unsigned lineno ATTRIBUTE_UNUSED
;
5745 register char *buffer ATTRIBUTE_UNUSED
;
5747 #ifdef DWARF_DEBUGGING_INFO
5748 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5749 && write_symbols
== DWARF_DEBUG
)
5750 dwarfout_define (lineno
, buffer
);
5751 #endif /* DWARF_DEBUGGING_INFO */
5752 #ifdef DWARF2_DEBUGGING_INFO
5753 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5754 && write_symbols
== DWARF2_DEBUG
)
5755 dwarf2out_define (lineno
, buffer
);
5756 #endif /* DWARF2_DEBUGGING_INFO */
5759 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5760 the tail part of the directive line, i.e. the part which is past the
5761 initial whitespace, #, whitespace, directive-name, whitespace part. */
5764 debug_undef (lineno
, buffer
)
5765 register unsigned lineno ATTRIBUTE_UNUSED
;
5766 register char *buffer ATTRIBUTE_UNUSED
;
5768 #ifdef DWARF_DEBUGGING_INFO
5769 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5770 && write_symbols
== DWARF_DEBUG
)
5771 dwarfout_undef (lineno
, buffer
);
5772 #endif /* DWARF_DEBUGGING_INFO */
5773 #ifdef DWARF2_DEBUGGING_INFO
5774 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5775 && write_symbols
== DWARF2_DEBUG
)
5776 dwarf2out_undef (lineno
, buffer
);
5777 #endif /* DWARF2_DEBUGGING_INFO */