1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-7, 1998 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. */
34 #ifdef HAVE_SYS_RESOURCE_H
35 # include <sys/resource.h>
38 #ifdef HAVE_SYS_TIMES_H
39 # include <sys/times.h>
46 #include "insn-attr.h"
47 #include "insn-codes.h"
48 #include "insn-config.h"
56 #ifdef DWARF_DEBUGGING_INFO
60 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
61 #include "dwarf2out.h"
64 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
68 #ifdef SDB_DEBUGGING_INFO
72 #ifdef XCOFF_DEBUGGING_INFO
77 /* The extra parameters substantially improve the I/O performance. */
79 vms_fopen (fname
, type
)
83 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
84 fixed arguments, which matches ANSI's specification but not VAXCRTL's
85 pre-ANSI implementation. This hack circumvents the mismatch problem. */
86 FILE *(*vmslib_fopen
)() = (FILE *(*)()) fopen
;
89 return (*vmslib_fopen
) (fname
, type
, "mbc=32",
90 "deq=64", "fop=tef", "shr=nil");
92 return (*vmslib_fopen
) (fname
, type
, "mbc=32");
94 #define fopen vms_fopen
97 #ifndef DEFAULT_GDB_EXTENSIONS
98 #define DEFAULT_GDB_EXTENSIONS 1
101 /* If more than one debugging type is supported, you must define
102 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
104 This is one long line cause VAXC can't handle a \-newline. */
105 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
106 #ifndef PREFERRED_DEBUGGING_TYPE
107 You Lose
! You must define PREFERRED_DEBUGGING_TYPE
!
108 #endif /* no PREFERRED_DEBUGGING_TYPE */
109 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
110 so the following code needn't care. */
111 #ifdef DBX_DEBUGGING_INFO
112 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
114 #ifdef SDB_DEBUGGING_INFO
115 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
117 #ifdef DWARF_DEBUGGING_INFO
118 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
120 #ifdef DWARF2_DEBUGGING_INFO
121 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
123 #ifdef XCOFF_DEBUGGING_INFO
124 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
126 #endif /* More than one debugger format enabled. */
128 /* If still not defined, must have been because no debugging formats
130 #ifndef PREFERRED_DEBUGGING_TYPE
131 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
134 extern int rtx_equal_function_value_matters
;
136 #if ! (defined (VMS) || defined (OS2))
137 extern char **environ
;
139 extern char *version_string
, *language_string
;
141 /* Carry information from ASM_DECLARE_OBJECT_NAME
142 to ASM_FINISH_DECLARE_OBJECT. */
144 extern int size_directive_output
;
145 extern tree last_assemble_variable_decl
;
147 extern char *init_parse
PVPROTO((char *));
148 extern void finish_parse ();
149 extern void init_decl_processing ();
150 extern void init_obstacks ();
151 extern void init_tree_codes ();
152 extern void init_rtl ();
153 extern void init_regs ();
154 extern void init_optabs ();
155 extern void init_stmt ();
156 extern void init_reg_sets ();
157 extern void dump_flow_info ();
158 extern void dump_sched_info ();
159 extern void dump_local_alloc ();
160 extern void regset_release_memory ();
162 extern void print_rtl ();
163 extern void print_rtl_with_bb ();
165 void rest_of_decl_compilation ();
166 void error_with_file_and_line
PVPROTO((char *file
, int line
, char *s
, ...));
167 void error_with_decl
PVPROTO((tree decl
, char *s
, ...));
168 void error
PVPROTO((char *s
, ...));
169 void fatal
PVPROTO((char *s
, ...));
170 void warning_with_file_and_line
PVPROTO((char *file
, int line
, char *s
, ...));
171 void warning_with_decl
PVPROTO((tree decl
, char *s
, ...));
172 void warning
PVPROTO((char *s
, ...));
173 void pedwarn
PVPROTO((char *s
, ...));
174 void pedwarn_with_decl
PVPROTO((tree decl
, char *s
, ...));
175 void pedwarn_with_file_and_line
PVPROTO((char *file
, int line
, char *s
, ...));
176 void sorry
PVPROTO((char *s
, ...));
177 static void set_target_switch
PROTO((char *));
178 static char *decl_name
PROTO((tree
, int));
179 static void vmessage
PROTO((char *, char *, va_list));
180 static void v_message_with_file_and_line
PROTO((char *, int, char *,
182 static void v_message_with_decl
PROTO((tree
, char *, char *, va_list));
183 static void file_and_line_for_asm
PROTO((rtx
, char **, int *));
184 static void v_error_with_file_and_line
PROTO((char *, int, char *, va_list));
185 static void v_error_with_decl
PROTO((tree
, char *, va_list));
186 static void v_error_for_asm
PROTO((rtx
, char *, va_list));
187 static void verror
PROTO((char *, va_list));
188 static void vfatal
PROTO((char *, va_list)) ATTRIBUTE_NORETURN
;
189 static void v_warning_with_file_and_line
PROTO ((char *, int, char *, va_list));
190 static void v_warning_with_decl
PROTO((tree
, char *, va_list));
191 static void v_warning_for_asm
PROTO((rtx
, char *, va_list));
192 static void vwarning
PROTO((char *, va_list));
193 static void vpedwarn
PROTO((char *, va_list));
194 static void v_pedwarn_with_decl
PROTO((tree
, char *, va_list));
195 static void v_pedwarn_with_file_and_line
PROTO((char *, int, char *, va_list));
196 static void vsorry
PROTO((char *, va_list));
197 static void v_really_sorry
PROTO((char *, va_list)) ATTRIBUTE_NORETURN
;
198 static void float_signal
PROTO((int));
199 static void pipe_closed
PROTO((int));
200 static void output_lang_identify
PROTO((FILE *));
201 static void open_dump_file
PROTO((char *, char *));
202 static void close_dump_file
PROTO((void (*) (FILE *, rtx
), rtx
));
203 static void dump_rtl
PROTO((char *, tree
, void (*) (FILE *, rtx
), rtx
));
204 static void clean_dump_file
PROTO((char *));
205 static void compile_file
PROTO((char *));
206 static void display_help
PROTO ((void));
208 static void print_version
PROTO((FILE *, char *));
209 static int print_single_switch
PROTO((FILE *, int, int, char *, char *, char *,
211 static void print_switch_values
PROTO((FILE *, int, int, char *, char *,
213 /* Length of line when printing switch values. */
216 /* Name of program invoked, sans directories. */
220 /* Copy of arguments to main. */
224 /* Name of current original source file (what was input to cpp).
225 This comes from each #-command in the actual input. */
227 char *input_filename
;
229 /* Name of top-level original source file (what was input to cpp).
230 This comes from the #-command at the beginning of the actual input.
231 If there isn't any there, then this is the cc1 input file name. */
233 char *main_input_filename
;
235 /* Current line number in real source file. */
239 /* Stack of currently pending input files. */
241 struct file_stack
*input_file_stack
;
243 /* Incremented on each change to input_file_stack. */
244 int input_file_stack_tick
;
246 /* FUNCTION_DECL for function now being parsed or compiled. */
248 extern tree current_function_decl
;
250 /* Name to use as base of names for dump output files. */
252 char *dump_base_name
;
254 /* Bit flags that specify the machine subtype we are compiling for.
255 Bits are tested using macros TARGET_... defined in the tm.h file
256 and set by `-m...' switches. Must be defined in rtlanal.c. */
258 extern int target_flags
;
260 /* Flags saying which kinds of debugging dump have been requested. */
263 int rtl_dump_and_exit
= 0;
264 int jump_opt_dump
= 0;
265 int addressof_dump
= 0;
270 int branch_prob_dump
= 0;
272 int combine_dump
= 0;
273 int regmove_dump
= 0;
275 int local_reg_dump
= 0;
276 int global_reg_dump
= 0;
278 int jump2_opt_dump
= 0;
280 int dbr_sched_dump
= 0;
282 int flag_print_asm_name
= 0;
284 int stack_reg_dump
= 0;
286 #ifdef MACHINE_DEPENDENT_REORG
287 int mach_dep_reorg_dump
= 0;
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 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 /* Pointer to function to finish handling an incomplete decl at the
354 end of compilation. */
356 void (*incomplete_decl_finalize_hook
) PROTO((tree
)) = 0;
358 /* Highest label number used at the end of reload. */
360 int max_label_num_after_reload
;
362 /* Nonzero if generating code to do profiling. */
364 int profile_flag
= 0;
366 /* Nonzero if generating code to do profiling on a line-by-line basis. */
368 int profile_block_flag
;
370 /* Nonzero if generating code to profile program flow graph arcs. */
372 int profile_arc_flag
= 0;
374 /* Nonzero if generating info for gcov to calculate line test coverage. */
376 int flag_test_coverage
= 0;
378 /* Nonzero indicates that branch taken probabilities should be calculated. */
380 int flag_branch_probabilities
= 0;
382 /* Nonzero for -pedantic switch: warn about anything
383 that standard spec forbids. */
387 /* Temporarily suppress certain warnings.
388 This is set while reading code from a system header file. */
390 int in_system_header
= 0;
392 /* Nonzero means do stupid register allocation.
393 Currently, this is 1 if `optimize' is 0. */
395 int obey_regdecls
= 0;
397 /* Don't print functions as they are compiled and don't print
398 times taken by the various passes. -quiet. */
404 /* Nonzero means `char' should be signed. */
406 int flag_signed_char
;
408 /* Nonzero means give an enum type only as many bytes as it needs. */
410 int flag_short_enums
;
412 /* Nonzero for -fcaller-saves: allocate values in regs that need to
413 be saved across function calls, if that produces overall better code.
414 Optional now, so people can test it. */
416 #ifdef DEFAULT_CALLER_SAVES
417 int flag_caller_saves
= 1;
419 int flag_caller_saves
= 0;
422 /* Nonzero if structures and unions should be returned in memory.
424 This should only be defined if compatibility with another compiler or
425 with an ABI is needed, because it results in slower code. */
427 #ifndef DEFAULT_PCC_STRUCT_RETURN
428 #define DEFAULT_PCC_STRUCT_RETURN 1
431 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
433 int flag_pcc_struct_return
= DEFAULT_PCC_STRUCT_RETURN
;
435 /* Nonzero for -fforce-mem: load memory value into a register
436 before arithmetic on it. This makes better cse but slower compilation. */
438 int flag_force_mem
= 0;
440 /* Nonzero for -fforce-addr: load memory address into a register before
441 reference to memory. This makes better cse but slower compilation. */
443 int flag_force_addr
= 0;
445 /* Nonzero for -fdefer-pop: don't pop args after each function call;
446 instead save them up to pop many calls' args with one insns. */
448 int flag_defer_pop
= 0;
450 /* Nonzero for -ffloat-store: don't allocate floats and doubles
451 in extended-precision registers. */
453 int flag_float_store
= 0;
455 /* Nonzero for -fcse-follow-jumps:
456 have cse follow jumps to do a more extensive job. */
458 int flag_cse_follow_jumps
;
460 /* Nonzero for -fcse-skip-blocks:
461 have cse follow a branch around a block. */
462 int flag_cse_skip_blocks
;
464 /* Nonzero for -fexpensive-optimizations:
465 perform miscellaneous relatively-expensive optimizations. */
466 int flag_expensive_optimizations
;
468 /* Nonzero for -fthread-jumps:
469 have jump optimize output of loop. */
471 int flag_thread_jumps
;
473 /* Nonzero enables strength-reduction in loop.c. */
475 int flag_strength_reduce
= 0;
477 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
478 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
479 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
482 int flag_unroll_loops
;
484 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
485 This is generally not a win. */
487 int flag_unroll_all_loops
;
489 /* Nonzero forces all invariant computations in loops to be moved
492 int flag_move_all_movables
= 0;
494 /* Nonzero forces all general induction variables in loops to be
497 int flag_reduce_all_givs
= 0;
499 /* Nonzero to perform full register move optimization passes. This is the
502 int flag_regmove
= 0;
504 /* Nonzero for -fwritable-strings:
505 store string constants in data segment and don't uniquize them. */
507 int flag_writable_strings
= 0;
509 /* Nonzero means don't put addresses of constant functions in registers.
510 Used for compiling the Unix kernel, where strange substitutions are
511 done on the assembly output. */
513 int flag_no_function_cse
= 0;
515 /* Nonzero for -fomit-frame-pointer:
516 don't make a frame pointer in simple functions that don't require one. */
518 int flag_omit_frame_pointer
= 0;
520 /* Nonzero means place each function into its own section on those platforms
521 which support arbitrary section names and unlimited numbers of sections. */
523 int flag_function_sections
= 0;
525 /* Nonzero to inhibit use of define_optimization peephole opts. */
527 int flag_no_peephole
= 0;
529 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
530 operations in the interest of optimization. For example it allows
531 GCC to assume arguments to sqrt are nonnegative numbers, allowing
532 faster code for sqrt to be generated. */
534 int flag_fast_math
= 0;
536 /* Nonzero means all references through pointers are volatile. */
540 /* Nonzero means treat all global and extern variables as global. */
542 int flag_volatile_global
;
544 /* Nonzero means just do syntax checking; don't output anything. */
546 int flag_syntax_only
= 0;
548 /* Nonzero means perform global cse. */
550 static int flag_gcse
;
552 /* Nonzero means to rerun cse after loop optimization. This increases
553 compilation time about 20% and picks up a few more common expressions. */
555 static int flag_rerun_cse_after_loop
;
557 /* Nonzero means to run loop optimizations twice. */
559 int flag_rerun_loop_opt
;
561 /* Nonzero for -finline-functions: ok to inline functions that look like
562 good inline candidates. */
564 int flag_inline_functions
;
566 /* Nonzero for -fkeep-inline-functions: even if we make a function
567 go inline everywhere, keep its definition around for debugging
570 int flag_keep_inline_functions
;
572 /* Nonzero means that functions will not be inlined. */
576 /* Nonzero means that we should emit static const variables
577 regardless of whether or not optimization is turned on. */
579 int flag_keep_static_consts
= 1;
581 /* Nonzero means we should be saving declaration info into a .X file. */
583 int flag_gen_aux_info
= 0;
585 /* Specified name of aux-info file. */
587 static char *aux_info_file_name
;
589 /* Nonzero means make the text shared if supported. */
591 int flag_shared_data
;
593 /* Nonzero means schedule into delayed branch slots if supported. */
595 int flag_delayed_branch
;
597 /* Nonzero if we are compiling pure (sharable) code.
598 Value is 1 if we are doing reasonable (i.e. simple
599 offset into offset table) pic. Value is 2 if we can
600 only perform register offsets. */
604 /* Nonzero means generate extra code for exception handling and enable
605 exception handling. */
609 /* Nonzero means use the new model for exception handling. Replaces
610 -DNEW_EH_MODEL as a compile option. */
612 int flag_new_exceptions
= 0;
614 /* Nonzero means don't place uninitialized global data in common storage
619 /* Nonzero means pretend it is OK to examine bits of target floats,
620 even if that isn't true. The resulting code will have incorrect constants,
621 but the same series of instructions that the native compiler would make. */
623 int flag_pretend_float
;
625 /* Nonzero means change certain warnings into errors.
626 Usually these are warnings about failure to conform to some standard. */
628 int flag_pedantic_errors
= 0;
630 /* flag_schedule_insns means schedule insns within basic blocks (before
632 flag_schedule_insns_after_reload means schedule insns after
635 int flag_schedule_insns
= 0;
636 int flag_schedule_insns_after_reload
= 0;
639 /* The following flags have effect only for scheduling before register
642 flag_schedule_interblock means schedule insns accross basic blocks.
643 flag_schedule_speculative means allow speculative motion of non-load insns.
644 flag_schedule_speculative_load means allow speculative motion of some
646 flag_schedule_speculative_load_dangerous allows speculative motion of more
649 int flag_schedule_interblock
= 1;
650 int flag_schedule_speculative
= 1;
651 int flag_schedule_speculative_load
= 0;
652 int flag_schedule_speculative_load_dangerous
= 0;
654 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
655 by a cheaper branch, on a count register. */
656 int flag_branch_on_count_reg
;
660 /* -finhibit-size-directive inhibits output of .size for ELF.
661 This is used only for compiling crtstuff.c,
662 and it may be extended to other effects
663 needed for crtstuff.c on other systems. */
664 int flag_inhibit_size_directive
= 0;
666 /* -fverbose-asm causes extra commentary information to be produced in
667 the generated assembly code (to make it more readable). This option
668 is generally only of use to those who actually need to read the
669 generated assembly code (perhaps while debugging the compiler itself).
670 -fno-verbose-asm, the default, causes the extra information
671 to be omitted and is useful when comparing two assembler files. */
673 int flag_verbose_asm
= 0;
675 /* -dA causes debug commentary information to be produced in
676 the generated assembly code (to make it more readable). This option
677 is generally only of use to those who actually need to read the
678 generated assembly code (perhaps while debugging the compiler itself).
679 Currently, this switch is only used by dwarfout.c; however, it is intended
680 to be a catchall for printing debug information in the assembler file. */
682 int flag_debug_asm
= 0;
684 /* -fgnu-linker specifies use of the GNU linker for initializations.
685 (Or, more generally, a linker that handles initializations.)
686 -fno-gnu-linker says that collect2 will be used. */
688 int flag_gnu_linker
= 0;
690 int flag_gnu_linker
= 1;
693 /* Tag all structures with __attribute__(packed) */
694 int flag_pack_struct
= 0;
696 /* Emit code to check for stack overflow; also may cause large objects
697 to be allocated dynamically. */
698 int flag_stack_check
;
700 /* -fcheck-memory-usage causes extra code to be generated in order to check
701 memory accesses. This is used by a detector of bad memory accesses such
703 int flag_check_memory_usage
= 0;
705 /* -fprefix-function-name causes function name to be prefixed. This
706 can be used with -fcheck-memory-usage to isolate code compiled with
707 -fcheck-memory-usage. */
708 int flag_prefix_function_name
= 0;
710 /* 0 if pointer arguments may alias each other. True in C.
711 1 if pointer arguments may not alias each other but may alias
713 2 if pointer arguments may not alias each other and may not
714 alias global variables. True in Fortran.
715 This defaults to 0 for C. */
716 int flag_argument_noalias
= 0;
718 /* Nonzero if we should do (language-dependent) alias analysis.
719 Typically, this analysis will assume that expressions of certain
720 types do not alias expressions of certain other types. Only used
721 if alias analysis (in general) is enabled. */
722 int flag_strict_aliasing
= 0;
724 extern int flag_dump_unnumbered
;
726 /* Instrument functions with calls at entry and exit, for profiling. */
727 int flag_instrument_function_entry_exit
= 0;
730 /* Table of supported debugging formats. */
734 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
735 constant expression, we use NO_DEBUG in its place. */
736 enum debug_info_type debug_type
;
737 int use_extensions_p
;
742 { "g", NO_DEBUG
, DEFAULT_GDB_EXTENSIONS
,
743 "Generate default debug format output" },
744 { "ggdb", NO_DEBUG
, 1, "Generate default extended debug format output" },
745 #ifdef DBX_DEBUGGING_INFO
746 { "gstabs", DBX_DEBUG
, 0, "Generate STABS format debug output" },
747 { "gstabs+", DBX_DEBUG
, 1, "Generate extended STABS format debug output" },
749 #ifdef DWARF_DEBUGGING_INFO
750 { "gdwarf", DWARF_DEBUG
, 0, "Generate DWARF-1 format debug output"},
751 { "gdwarf+", DWARF_DEBUG
, 1,
752 "Generated extended DWARF-1 format debug output" },
754 #ifdef DWARF2_DEBUGGING_INFO
755 { "gdwarf-2", DWARF2_DEBUG
, 0, "Enable DWARF-2 debug output" },
757 #ifdef XCOFF_DEBUGGING_INFO
758 { "gxcoff", XCOFF_DEBUG
, 0, "Generate XCOFF format debug output" },
759 { "gxcoff+", XCOFF_DEBUG
, 1, "Generate extended XCOFF format debug output" },
761 #ifdef SDB_DEBUGGING_INFO
762 { "gcoff", SDB_DEBUG
, 0, "Generate COFF format debug output" },
774 lang_independent_options
;
776 /* Table of language-independent -f options.
777 STRING is the option name. VARIABLE is the address of the variable.
778 ON_VALUE is the value to store in VARIABLE
779 if `-fSTRING' is seen as an option.
780 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
782 lang_independent_options f_options
[] =
784 {"float-store", &flag_float_store
, 1,
785 "Do not store floats in registers" },
786 {"volatile", &flag_volatile
, 1,
787 "Consider all mem refs through pointers as volatile"},
788 {"volatile-global", &flag_volatile_global
, 1,
789 "Consider all mem refs to global data to be volatile" },
790 {"defer-pop", &flag_defer_pop
, 1,
791 "Defer popping functions args from stack until later" },
792 {"omit-frame-pointer", &flag_omit_frame_pointer
, 1,
793 "When possible do not generate stack frames"},
794 {"cse-follow-jumps", &flag_cse_follow_jumps
, 1,
795 "When running CSE, follow jumps to their targets" },
796 {"cse-skip-blocks", &flag_cse_skip_blocks
, 1,
797 "When running CSE, follow conditional jumps" },
798 {"expensive-optimizations", &flag_expensive_optimizations
, 1,
799 "Perform a number of minor, expensive optimisations" },
800 {"thread-jumps", &flag_thread_jumps
, 1,
801 "Perform jump threading optimisations"},
802 {"strength-reduce", &flag_strength_reduce
, 1,
803 "Perform strength reduction optimisations" },
804 {"unroll-loops", &flag_unroll_loops
, 1,
805 "Perform loop unrolling when interation count is known" },
806 {"unroll-all-loops", &flag_unroll_all_loops
, 1,
807 "Perofm loop onrolling for all loops" },
808 {"move-all-movables", &flag_move_all_movables
, 1,
809 "Force all loop invariant computations out of loops" },
810 {"reduce-all-givs", &flag_reduce_all_givs
, 1,
811 "Strength reduce all loop general induction variables" },
812 {"writable-strings", &flag_writable_strings
, 1,
813 "Store strings in writable data section" },
814 {"peephole", &flag_no_peephole
, 0,
815 "Enable machine specific peephole optimisations" },
816 {"force-mem", &flag_force_mem
, 1,
817 "Copy memory operands into registers before using" },
818 {"force-addr", &flag_force_addr
, 1,
819 "Copy memory address constants into regs before using" },
820 {"function-cse", &flag_no_function_cse
, 0,
821 "Allow function addresses to be held in registers" },
822 {"inline-functions", &flag_inline_functions
, 1,
823 "Integrate simple functions into their callers" },
824 {"keep-inline-functions", &flag_keep_inline_functions
, 1,
825 "Generate code for funcs even if they are fully inlined" },
826 {"inline", &flag_no_inline
, 0,
827 "Pay attention to the 'inline' keyword"},
828 {"keep-static-consts", &flag_keep_static_consts
, 1,
829 "Emit static const variables even if they are not used" },
830 {"syntax-only", &flag_syntax_only
, 1,
831 "Check for syntax errors, then stop" },
832 {"shared-data", &flag_shared_data
, 1,
833 "Mark data as shared rather than private" },
834 {"caller-saves", &flag_caller_saves
, 1,
835 "Enable saving registers around function calls" },
836 {"pcc-struct-return", &flag_pcc_struct_return
, 1,
837 "Return 'short' aggregates in memory, not registers" },
838 {"reg-struct-return", &flag_pcc_struct_return
, 0,
839 "Return 'short' aggregates in registers" },
840 {"delayed-branch", &flag_delayed_branch
, 1,
841 "Attempt to fill delay slots of branch instructions" },
842 {"gcse", &flag_gcse
, 1,
843 "Perform the global common subexpression elimination" },
844 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop
, 1,
845 "Run CSE pass after loop optimisations"},
846 {"rerun-loop-opt", &flag_rerun_loop_opt
, 1,
847 "Run the loop optimiser twice"},
848 {"pretend-float", &flag_pretend_float
, 1,
849 "Pretend that host and target use the same FP format"},
850 {"schedule-insns", &flag_schedule_insns
, 1,
851 "Reschedule instructions to avoid pipeline stalls"},
852 {"schedule-insns2", &flag_schedule_insns_after_reload
, 1,
853 "Run two passes of the instruction scheduler"},
855 {"sched-interblock",&flag_schedule_interblock
, 1,
856 "Enable scheduling across basic blocks" },
857 {"sched-spec",&flag_schedule_speculative
, 1,
858 "Allow speculative motion of non-loads" },
859 {"sched-spec-load",&flag_schedule_speculative_load
, 1,
860 "Allow speculative motion of some loads" },
861 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous
, 1,
862 "Allow speculative motion of more loads" },
863 {"branch-count-reg",&flag_branch_on_count_reg
, 1,
864 "Replace add,compare,branch with branch on count reg"},
866 {"pic", &flag_pic
, 1,
867 "Generate position independent code, if possible"},
868 {"PIC", &flag_pic
, 2, ""},
869 {"exceptions", &flag_exceptions
, 1,
870 "Enable exception handling" },
871 {"new-exceptions", &flag_new_exceptions
, 1,
872 "Use the new model for exception handling" },
873 {"sjlj-exceptions", &exceptions_via_longjmp
, 1,
874 "Use setjmp/longjmp to handle exceptions" },
875 {"asynchronous-exceptions", &asynchronous_exceptions
, 1,
876 "Support asynchronous exceptions" },
877 {"profile-arcs", &profile_arc_flag
, 1,
878 "Insert arc based program profiling code" },
879 {"test-coverage", &flag_test_coverage
, 1,
880 "Create data files needed by gcov" },
881 {"branch-probabilities", &flag_branch_probabilities
, 1,
882 "Use profiling information for branch porbabilities" },
883 {"fast-math", &flag_fast_math
, 1,
884 "Improve FP speed by violating ANSI & IEEE rules" },
885 {"common", &flag_no_common
, 0,
886 "Do not put unitialised globals in the common section" },
887 {"inhibit-size-directive", &flag_inhibit_size_directive
, 1,
888 "Do not generate .size directives" },
889 {"function-sections", &flag_function_sections
, 1,
890 "place each function into its own section" },
891 {"verbose-asm", &flag_verbose_asm
, 1,
892 "Add extra commentry to assembler output"},
893 {"gnu-linker", &flag_gnu_linker
, 1,
894 "Output GNU ld formatted global initialisers"},
895 {"regmove", &flag_regmove
, 1,
896 "Enables a regoster move optimisation"},
897 {"optimize-register-move", &flag_regmove
, 1},
898 {"pack-struct", &flag_pack_struct
, 1,
899 "Pack structure members together without holes" },
900 {"stack-check", &flag_stack_check
, 1,
901 "Insert stack checking code into the program" },
902 {"argument-alias", &flag_argument_noalias
, 0,
903 "Specify that arguments may alias each other & globals"},
904 {"argument-noalias", &flag_argument_noalias
, 1,
905 "Assume arguments may alias globals but not each other"},
906 {"argument-noalias-global", &flag_argument_noalias
, 2,
907 "Assume arguments do not alias each other or globals" },
908 {"strict-aliasing", &flag_strict_aliasing
, 1,
909 "Assume strict aliasing rules apply" },
910 {"check-memory-usage", &flag_check_memory_usage
, 1,
911 "Generate code to check every memory access" },
912 {"prefix-function-name", &flag_prefix_function_name
, 1,
913 "Add a prefix to all function names" },
914 {"dump-unnumbered", &flag_dump_unnumbered
, 1},
915 {"instrument-functions", &flag_instrument_function_entry_exit
, 1,
916 "Instrument function entry/exit with profiling calls"},
919 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
921 /* Table of language-specific options. */
923 static struct lang_opt
928 documented_lang_options
[] =
930 /* In order not to overload the --help output, the convention
931 used here is to only describe those options which are not
932 enabled by default. */
934 { "-ansi", "Compile just for ANSI C" },
935 { "-fallow-single-precision",
936 "Do not promote floats to double if using -traditional" },
938 { "-fsigned-bitfields", "" },
939 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
940 { "-fno-signed-bitfields", "" },
941 { "-fno-unsigned-bitfields","" },
942 { "-fsigned-char", "Make 'char' be signed by default"},
943 { "-funsigned-char", "Make 'char' be unsigned by default"},
944 { "-fno-signed-char", "" },
945 { "-fno-unsigned-char", "" },
947 { "-ftraditional", "" },
948 { "-traditional", "Attempt to support traditional K&R style C"},
949 { "-fnotraditional", "" },
950 { "-fno-traditional", "" },
953 { "-fno-asm", "Do not recognise the 'asm' keyword" },
955 { "-fno-builtin", "Do not recognise any built in functions" },
956 { "-fhosted", "Assume normal C execution environment" },
957 { "-fno-hosted", "" },
959 "Assume that standard libraries & main might not exist" },
960 { "-fno-freestanding", "" },
961 { "-fcond-mismatch", "Allow different types as args of ? operator"},
962 { "-fno-cond-mismatch", "" },
963 { "-fdollars-in-identifiers", "Allow the use of $ inside indentifiers" },
964 { "-fno-dollars-in-identifiers", "" },
966 { "-fno-ident", "Ignore #ident directives" },
967 { "-fshort-double", "Use the same size for double as for float" },
968 { "-fno-short-double", "" },
969 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
970 { "-fno-short-enums", "" },
972 { "-Wall", "Enable most warning messages" },
973 { "-Wbad-function-cast",
974 "Warn about casting functions to incompatible types" },
975 { "-Wno-bad-function-cast", "" },
976 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
977 { "-Wno-cast-qual", "" },
978 { "-Wchar-subscripts", "Warn about subscripts whoes type is 'char'"},
979 { "-Wno-char-subscripts", "" },
980 { "-Wcomment", "Warn if nested comments are detected" },
983 { "-Wno-comments", },
984 { "-Wconversion", "Warn about possibly confusing type conversions" },
985 { "-Wno-conversion", "" },
986 { "-Wformat", "Warn about printf format anomalies" },
987 { "-Wno-format", "" },
988 { "-Wimplicit-function-declaration",
989 "Warn about implicit function declarations" },
990 { "-Wno-implicit-function-declaration", "" },
991 { "-Werror-implicit-function-declaration", "" },
992 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
993 { "-Wno-implicit-int", "" },
994 { "-Wimplicit", "" },
995 { "-Wno-implicit", "" },
996 { "-Wimport", "Warn about the use of the #import directive" },
997 { "-Wno-import", "" },
998 { "-Wlong-long","" },
999 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1000 { "-Wmain", "Warn about suspicious declarations of main" },
1001 { "-Wno-main", "" },
1002 { "-Wmissing-braces",
1003 "Warn about possibly missing braces around initialisers" },
1004 { "-Wno-missing-braces", "" },
1005 { "-Wmissing-declarations",
1006 "Warn about global funcs without previous declarations"},
1007 { "-Wno-missing-declarations", "" },
1008 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1009 { "-Wno-missing-prototypes", "" },
1010 { "-Wmultichar", "Warn about use of multicharacter literals"},
1011 { "-Wno-multichar", "" },
1012 { "-Wnested-externs", "Warn about externs not at file scope level" },
1013 { "-Wno-nested-externs", "" },
1014 { "-Wparentheses", "Warn about possible missing parentheses" },
1015 { "-Wno-parentheses", "" },
1016 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1017 { "-Wno-pointer-arith", "" },
1018 { "-Wredundant-decls",
1019 "Warn about multiple declarations of the same object" },
1020 { "-Wno-redundant-decls", "" },
1021 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1022 { "-Wno-sign-compare", "" },
1023 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1024 { "-Wno-unknown-pragmas", "" },
1025 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1026 { "-Wno-strict-prototypes", "" },
1027 { "-Wtraditional", "Warn about constructs whoes meaning change in ANSI C"},
1028 { "-Wno-traditional", "" },
1029 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1030 { "-Wno-trigraphs", "" },
1032 { "-Wno-undef", "" },
1033 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1034 { "-Wno-write-strings", "" },
1036 /* These are for languages with USE_CPPLIB. */
1037 /* These options are already documented in cpplib.c */
1043 { "-idirafter", "" },
1047 { "-lang-c89", "" },
1048 { "-lang-c++", "" },
1049 { "-nostdinc", "" },
1050 { "-nostdinc++", "" },
1051 { "-trigraphs", "" },
1055 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1057 /* These are for obj c. */
1058 DEFINE_LANG_NAME ("Objective C")
1060 { "-lang-objc", "" },
1061 { "-gen-decls", "Dump decls to a .decl file" },
1062 { "-fgnu-runtime", "Generate code for GNU runtime envrionment" },
1063 { "-fno-gnu-runtime", "" },
1064 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1065 { "-fno-next-runtime", "" },
1066 { "-Wselector", "Warn if a selector has multiple methods" },
1067 { "-Wno-selector", "" },
1068 { "-Wprotocol", "" },
1069 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1070 { "-print-objc-runtime-info",
1071 "Generate C header of platform specific features" },
1073 #include "options.h"
1077 /* Here is a table, controlled by the tm.h file, listing each -m switch
1078 and which bits in `target_switches' it should set or clear.
1079 If VALUE is positive, it is bits to set.
1080 If VALUE is negative, -VALUE is bits to clear.
1081 (The sign bit is not used so there is no confusion.) */
1089 target_switches
[] = TARGET_SWITCHES
;
1091 /* This table is similar, but allows the switch to have a value. */
1093 #ifdef TARGET_OPTIONS
1100 target_options
[] = TARGET_OPTIONS
;
1103 /* Options controlling warnings */
1105 /* Don't print warning messages. -w. */
1107 int inhibit_warnings
= 0;
1109 /* Print various extra warnings. -W. */
1111 int extra_warnings
= 0;
1113 /* Treat warnings as errors. -Werror. */
1115 int warnings_are_errors
= 0;
1117 /* Nonzero to warn about unused local variables. */
1121 /* Nonzero to warn about variables used before they are initialized. */
1123 int warn_uninitialized
;
1125 /* Nonzero means warn about all declarations which shadow others. */
1129 /* Warn if a switch on an enum fails to have a case for every enum value. */
1133 /* Nonzero means warn about function definitions that default the return type
1134 or that use a null return and have a return-type other than void. */
1136 int warn_return_type
;
1138 /* Nonzero means warn about pointer casts that increase the required
1139 alignment of the target type (and might therefore lead to a crash
1140 due to a misaligned access). */
1142 int warn_cast_align
;
1144 /* Nonzero means warn about any identifiers that match in the first N
1145 characters. The value N is in `id_clash_len'. */
1148 unsigned id_clash_len
;
1150 /* Nonzero means warn about any objects definitions whose size is larger
1151 than N bytes. Also want about function definitions whose returned
1152 values are larger than N bytes. The value N is in `larger_than_size'. */
1154 int warn_larger_than
;
1155 unsigned larger_than_size
;
1157 /* Nonzero means warn if inline function is too large. */
1161 /* Warn if a function returns an aggregate,
1162 since there are often incompatible calling conventions for doing this. */
1164 int warn_aggregate_return
;
1166 /* Likewise for -W. */
1168 lang_independent_options W_options
[] =
1170 {"unused", &warn_unused
, 1, "Warn when a variable is unused" },
1171 {"error", &warnings_are_errors
, 1, ""},
1172 {"shadow", &warn_shadow
, 1, "Warn when one local variable shadows another" },
1173 {"switch", &warn_switch
, 1,
1174 "Warn about enumerated switches missing a specific case" },
1175 {"aggregate-return", &warn_aggregate_return
, 1,
1176 "Warn about returning structures, unions or arrays" },
1177 {"cast-align", &warn_cast_align
, 1,
1178 "Warn about pointer casts which increase alignment" },
1179 {"uninitialized", &warn_uninitialized
, 1,
1180 "Warn about unitialized automatic variables"},
1181 {"inline", &warn_inline
, 1,
1182 "Warn when an inlined function cannot be inlined"}
1185 /* Output files for assembler code (real compiler output)
1186 and debugging dumps. */
1189 FILE *aux_info_file
;
1190 FILE *rtl_dump_file
= NULL
;
1192 /* Time accumulators, to count the total time spent in various passes. */
1196 int integration_time
;
1202 int branch_prob_time
;
1207 int local_alloc_time
;
1208 int global_alloc_time
;
1213 int shorten_branch_time
;
1219 /* Return time used so far, in microseconds. */
1229 #else /* not BeOS */
1230 #if defined (_WIN32) && !defined (__CYGWIN32__)
1234 return (clock() * 1000);
1235 #else /* not _WIN32 */
1241 tick
= 1000000 / sysconf(_SC_CLK_TCK
);
1243 return (tms
.tms_utime
+ tms
.tms_stime
) * tick
;
1249 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1250 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1253 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1255 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1259 return (tms
.tms_utime
+ tms
.tms_stime
) * (1000000 / TICKS_PER_SECOND
);
1264 struct rusage rusage
;
1265 getrusage (0, &rusage
);
1266 return (rusage
.ru_utime
.tv_sec
* 1000000 + rusage
.ru_utime
.tv_usec
1267 + rusage
.ru_stime
.tv_sec
* 1000000 + rusage
.ru_stime
.tv_usec
);
1274 int proc_system_time
;
1275 int child_user_time
;
1276 int child_system_time
;
1278 times ((void *) &vms_times
);
1279 return (vms_times
.proc_user_time
+ vms_times
.proc_system_time
) * 10000;
1283 #endif /* _SC_CLK_TCK */
1285 #endif /* __BEOS__ */
1288 #define TIMEVAR(VAR, BODY) \
1289 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1292 print_time (str
, total
)
1297 "time in %s: %d.%06d\n",
1298 str
, total
/ 1000000, total
% 1000000);
1301 /* Count an error or warning. Return 1 if the message should be printed. */
1304 count_error (warningp
)
1307 if (warningp
&& inhibit_warnings
)
1310 if (warningp
&& !warnings_are_errors
)
1314 static int warning_message
= 0;
1316 if (warningp
&& !warning_message
)
1318 fprintf (stderr
, "%s: warnings being treated as errors\n", progname
);
1319 warning_message
= 1;
1327 /* Print a fatal error message. NAME is the text.
1328 Also include a system error message based on `errno'. */
1331 pfatal_with_name (name
)
1334 fprintf (stderr
, "%s: ", progname
);
1336 exit (FATAL_EXIT_CODE
);
1340 fatal_io_error (name
)
1343 fprintf (stderr
, "%s: %s: I/O error\n", progname
, name
);
1344 exit (FATAL_EXIT_CODE
);
1347 /* Called to give a better error message for a bad insn rather than
1348 just calling abort(). */
1351 fatal_insn (message
, insn
)
1358 fflush (asm_out_file
);
1360 fflush (aux_info_file
);
1361 if (rtl_dump_file
!= NULL
)
1362 fflush (rtl_dump_file
);
1368 /* Called to give a better error message when we don't have an insn to match
1369 what we are looking for or if the insn's constraints aren't satisfied,
1370 rather than just calling abort(). */
1373 fatal_insn_not_found (insn
)
1376 if (INSN_CODE (insn
) < 0)
1377 fatal_insn ("internal error--unrecognizable insn:", insn
);
1379 fatal_insn ("internal error--insn does not satisfy its constraints:", insn
);
1382 /* This is the default decl_printable_name function. */
1385 decl_name (decl
, verbosity
)
1387 int verbosity ATTRIBUTE_UNUSED
;
1389 return IDENTIFIER_POINTER (DECL_NAME (decl
));
1392 static int need_error_newline
;
1394 /* Function of last error message;
1395 more generally, function such that if next error message is in it
1396 then we don't have to mention the function name. */
1397 static tree last_error_function
= NULL
;
1399 /* Used to detect when input_file_stack has changed since last described. */
1400 static int last_error_tick
;
1402 /* Called when the start of a function definition is parsed,
1403 this function prints on stderr the name of the function. */
1406 announce_function (decl
)
1411 if (rtl_dump_and_exit
)
1412 fprintf (stderr
, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl
)));
1414 fprintf (stderr
, " %s", (*decl_printable_name
) (decl
, 2));
1416 need_error_newline
= 1;
1417 last_error_function
= current_function_decl
;
1421 /* The default function to print out name of current function that caused
1425 default_print_error_function (file
)
1428 if (last_error_function
!= current_function_decl
)
1430 char *kind
= "function";
1431 if (current_function_decl
!= 0
1432 && TREE_CODE (TREE_TYPE (current_function_decl
)) == METHOD_TYPE
)
1436 fprintf (stderr
, "%s: ", file
);
1438 if (current_function_decl
== NULL
)
1439 fprintf (stderr
, "At top level:\n");
1442 char *name
= (*decl_printable_name
) (current_function_decl
, 2);
1443 fprintf (stderr
, "In %s `%s':\n", kind
, name
);
1446 last_error_function
= current_function_decl
;
1450 /* Called by report_error_function to print out function name.
1451 * Default may be overridden by language front-ends. */
1453 void (*print_error_function
) PROTO((char *)) = default_print_error_function
;
1455 /* Prints out, if necessary, the name of the current function
1456 that caused an error. Called from all error and warning functions. */
1459 report_error_function (file
)
1462 struct file_stack
*p
;
1464 if (need_error_newline
)
1466 fprintf (stderr
, "\n");
1467 need_error_newline
= 0;
1470 (*print_error_function
) (file
);
1472 if (input_file_stack
&& input_file_stack
->next
!= 0
1473 && input_file_stack_tick
!= last_error_tick
1474 && file
== input_filename
)
1476 fprintf (stderr
, "In file included");
1477 for (p
= input_file_stack
->next
; p
; p
= p
->next
)
1479 fprintf (stderr
, " from %s:%d", p
->name
, p
->line
);
1481 fprintf (stderr
, ",\n ");
1483 fprintf (stderr
, ":\n");
1484 last_error_tick
= input_file_stack_tick
;
1488 /* Print a message. */
1491 vmessage (prefix
, s
, ap
)
1497 fprintf (stderr
, "%s: ", prefix
);
1499 vfprintf (stderr
, s
, ap
);
1502 /* Print a message relevant to line LINE of file FILE. */
1505 v_message_with_file_and_line (file
, line
, prefix
, s
, ap
)
1513 fprintf (stderr
, "%s:%d: ", file
, line
);
1515 fprintf (stderr
, "%s: ", progname
);
1517 vmessage (prefix
, s
, ap
);
1518 fputc ('\n', stderr
);
1521 /* Print a message relevant to the given DECL. */
1524 v_message_with_decl (decl
, prefix
, s
, ap
)
1532 fprintf (stderr
, "%s:%d: ",
1533 DECL_SOURCE_FILE (decl
), DECL_SOURCE_LINE (decl
));
1536 fprintf (stderr
, "%s: ", prefix
);
1538 /* Do magic to get around lack of varargs support for insertion
1539 of arguments into existing list. We know that the decl is first;
1540 we ass_u_me that it will be printed with "%s". */
1542 for (p
= s
; *p
; ++p
)
1546 if (*(p
+ 1) == '%')
1553 if (p
> s
) /* Print the left-hand substring. */
1555 char fmt
[sizeof "%.255s"];
1558 if (width
> 255L) width
= 255L; /* arbitrary */
1559 sprintf (fmt
, "%%.%lds", width
);
1560 fprintf (stderr
, fmt
, s
);
1563 if (*p
== '%') /* Print the name. */
1565 char *n
= (DECL_NAME (decl
)
1566 ? (*decl_printable_name
) (decl
, 2)
1572 if (ISALPHA (*(p
- 1) & 0xFF))
1577 if (*p
) /* Print the rest of the message. */
1578 vmessage ((char *)NULL
, p
, ap
);
1580 fputc ('\n', stderr
);
1583 /* Figure file and line of the given INSN. */
1586 file_and_line_for_asm (insn
, pfile
, pline
)
1591 rtx body
= PATTERN (insn
);
1594 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1595 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
1596 asmop
= SET_SRC (body
);
1597 else if (GET_CODE (body
) == ASM_OPERANDS
)
1599 else if (GET_CODE (body
) == PARALLEL
1600 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
)
1601 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
1602 else if (GET_CODE (body
) == PARALLEL
1603 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
1604 asmop
= XVECEXP (body
, 0, 0);
1610 *pfile
= ASM_OPERANDS_SOURCE_FILE (asmop
);
1611 *pline
= ASM_OPERANDS_SOURCE_LINE (asmop
);
1615 *pfile
= input_filename
;
1620 /* Report an error at line LINE of file FILE. */
1623 v_error_with_file_and_line (file
, line
, s
, ap
)
1630 report_error_function (file
);
1631 v_message_with_file_and_line (file
, line
, (char *)NULL
, s
, ap
);
1635 error_with_file_and_line
VPROTO((char *file
, int line
, char *s
, ...))
1647 file
= va_arg (ap
, char *);
1648 line
= va_arg (ap
, int);
1649 s
= va_arg (ap
, char *);
1652 v_error_with_file_and_line (file
, line
, s
, ap
);
1656 /* Report an error at the declaration DECL.
1657 S is a format string which uses %s to substitute the declaration
1658 name; subsequent substitutions are a la printf. */
1661 v_error_with_decl (decl
, s
, ap
)
1667 report_error_function (DECL_SOURCE_FILE (decl
));
1668 v_message_with_decl (decl
, (char *)NULL
, s
, ap
);
1672 error_with_decl
VPROTO((tree decl
, char *s
, ...))
1683 decl
= va_arg (ap
, tree
);
1684 s
= va_arg (ap
, char *);
1687 v_error_with_decl (decl
, s
, ap
);
1691 /* Report an error at the line number of the insn INSN.
1692 This is used only when INSN is an `asm' with operands,
1693 and each ASM_OPERANDS records its own source file and line. */
1696 v_error_for_asm (insn
, s
, ap
)
1705 file_and_line_for_asm (insn
, &file
, &line
);
1706 report_error_function (file
);
1707 v_message_with_file_and_line (file
, line
, (char *)NULL
, s
, ap
);
1711 error_for_asm
VPROTO((rtx insn
, char *s
, ...))
1722 insn
= va_arg (ap
, rtx
);
1723 s
= va_arg (ap
, char *);
1726 v_error_for_asm (insn
, s
, ap
);
1730 /* Report an error at the current line number. */
1737 v_error_with_file_and_line (input_filename
, lineno
, s
, ap
);
1741 error
VPROTO((char *s
, ...))
1751 s
= va_arg (ap
, char *);
1758 /* Report a fatal error at the current line number. */
1766 exit (FATAL_EXIT_CODE
);
1770 fatal
VPROTO((char *s
, ...))
1780 s
= va_arg (ap
, char *);
1787 /* Report a warning at line LINE of file FILE. */
1790 v_warning_with_file_and_line (file
, line
, s
, ap
)
1796 if (count_error (1))
1798 report_error_function (file
);
1799 v_message_with_file_and_line (file
, line
, "warning", s
, ap
);
1804 warning_with_file_and_line
VPROTO((char *file
, int line
, char *s
, ...))
1816 file
= va_arg (ap
, char *);
1817 line
= va_arg (ap
, int);
1818 s
= va_arg (ap
, char *);
1821 v_warning_with_file_and_line (file
, line
, s
, ap
);
1825 /* Report a warning at the declaration DECL.
1826 S is a format string which uses %s to substitute the declaration
1827 name; subsequent substitutions are a la printf. */
1830 v_warning_with_decl (decl
, s
, ap
)
1835 if (count_error (1))
1837 report_error_function (DECL_SOURCE_FILE (decl
));
1838 v_message_with_decl (decl
, "warning", s
, ap
);
1843 warning_with_decl
VPROTO((tree decl
, char *s
, ...))
1854 decl
= va_arg (ap
, tree
);
1855 s
= va_arg (ap
, char *);
1858 v_warning_with_decl (decl
, s
, ap
);
1862 /* Report a warning at the line number of the insn INSN.
1863 This is used only when INSN is an `asm' with operands,
1864 and each ASM_OPERANDS records its own source file and line. */
1867 v_warning_for_asm (insn
, s
, ap
)
1872 if (count_error (1))
1877 file_and_line_for_asm (insn
, &file
, &line
);
1878 report_error_function (file
);
1879 v_message_with_file_and_line (file
, line
, "warning", s
, ap
);
1884 warning_for_asm
VPROTO((rtx insn
, char *s
, ...))
1895 insn
= va_arg (ap
, rtx
);
1896 s
= va_arg (ap
, char *);
1899 v_warning_for_asm (insn
, s
, ap
);
1903 /* Report a warning at the current line number. */
1910 v_warning_with_file_and_line (input_filename
, lineno
, s
, ap
);
1914 warning
VPROTO((char *s
, ...))
1924 s
= va_arg (ap
, char *);
1931 /* These functions issue either warnings or errors depending on
1932 -pedantic-errors. */
1939 if (flag_pedantic_errors
)
1946 pedwarn
VPROTO((char *s
, ...))
1956 s
= va_arg (ap
, char *);
1964 v_pedwarn_with_decl (decl
, s
, ap
)
1969 /* We don't want -pedantic-errors to cause the compilation to fail from
1970 "errors" in system header files. Sometimes fixincludes can't fix what's
1971 broken (eg: unsigned char bitfields - fixing it may change the alignment
1972 which will cause programs to mysteriously fail because the C library
1973 or kernel uses the original layout). There's no point in issuing a
1974 warning either, it's just unnecessary noise. */
1976 if (! DECL_IN_SYSTEM_HEADER (decl
))
1978 if (flag_pedantic_errors
)
1979 v_error_with_decl (decl
, s
, ap
);
1981 v_warning_with_decl (decl
, s
, ap
);
1986 pedwarn_with_decl
VPROTO((tree decl
, char *s
, ...))
1997 decl
= va_arg (ap
, tree
);
1998 s
= va_arg (ap
, char *);
2001 v_pedwarn_with_decl (decl
, s
, ap
);
2006 v_pedwarn_with_file_and_line (file
, line
, s
, ap
)
2012 if (flag_pedantic_errors
)
2013 v_error_with_file_and_line (file
, line
, s
, ap
);
2015 v_warning_with_file_and_line (file
, line
, s
, ap
);
2019 pedwarn_with_file_and_line
VPROTO((char *file
, int line
, char *s
, ...))
2031 file
= va_arg (ap
, char *);
2032 line
= va_arg (ap
, int);
2033 s
= va_arg (ap
, char *);
2036 v_pedwarn_with_file_and_line (file
, line
, s
, ap
);
2040 /* Apologize for not implementing some feature. */
2049 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
2051 fprintf (stderr
, "%s: ", progname
);
2052 vmessage ("sorry, not implemented", s
, ap
);
2053 fputc ('\n', stderr
);
2057 sorry
VPROTO((char *s
, ...))
2067 s
= va_arg (ap
, char *);
2074 /* Apologize for not implementing some feature, then quit. */
2077 v_really_sorry (s
, ap
)
2083 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
2085 fprintf (stderr
, "%s: ", progname
);
2086 vmessage ("sorry, not implemented", s
, ap
);
2087 fatal (" (fatal)\n");
2091 really_sorry
VPROTO((char *s
, ...))
2101 s
= va_arg (ap
, char *);
2104 v_really_sorry (s
, ap
);
2108 /* More 'friendly' abort that prints the line and file.
2109 config.h can #define abort fancy_abort if you like that sort of thing.
2111 I don't think this is actually a good idea.
2112 Other sorts of crashes will look a certain way.
2113 It is a good thing if crashes from calling abort look the same way.
2119 fatal ("internal gcc abort");
2122 /* This calls abort and is used to avoid problems when abort if a macro.
2123 It is used when we need to pass the address of abort. */
2131 /* When `malloc.c' is compiled with `rcheck' defined,
2132 it calls this function to report clobberage. */
2136 char * s ATTRIBUTE_UNUSED
;
2141 /* Same as `malloc' but report error if no memory available. */
2147 register char *value
;
2152 value
= (char *) malloc (size
);
2154 fatal ("virtual memory exhausted");
2158 /* Same as `calloc' but report error if no memory available. */
2161 xcalloc (size1
, size2
)
2162 unsigned size1
, size2
;
2164 register char *value
;
2166 if (size1
== 0 || size2
== 0)
2169 value
= (char *) calloc (size1
, size2
);
2171 fatal ("virtual memory exhausted");
2176 /* Same as `realloc' but report error if no memory available.
2177 Also handle null PTR even if the vendor realloc gets it wrong. */
2180 xrealloc (ptr
, size
)
2190 ? (char *) realloc (ptr
, size
)
2191 : (char *) malloc (size
));
2194 fatal ("virtual memory exhausted");
2199 /* Same as `strdup' but report error if no memory available. */
2205 register char *result
= (char *) malloc (strlen (s
) + 1);
2208 fatal ("virtual memory exhausted");
2213 /* Return the logarithm of X, base 2, considering X unsigned,
2214 if X is a power of 2. Otherwise, returns -1.
2216 This should be used via the `exact_log2' macro. */
2220 register unsigned HOST_WIDE_INT x
;
2222 register int log
= 0;
2223 /* Test for 0 or a power of 2. */
2224 if (x
== 0 || x
!= (x
& -x
))
2226 while ((x
>>= 1) != 0)
2231 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2232 If X is 0, return -1.
2234 This should be used via the floor_log2 macro. */
2238 register unsigned HOST_WIDE_INT x
;
2240 register int log
= -1;
2247 static int float_handler_set
;
2249 jmp_buf float_handler
;
2251 /* Signals actually come here. */
2254 float_signal (signo
)
2255 /* If this is missing, some compilers complain. */
2256 int signo ATTRIBUTE_UNUSED
;
2258 if (float_handled
== 0)
2260 #if defined (USG) || defined (hpux)
2261 signal (SIGFPE
, float_signal
); /* re-enable the signal catcher */
2264 signal (SIGFPE
, float_signal
);
2265 longjmp (float_handler
, 1);
2268 /* Specify where to longjmp to when a floating arithmetic error happens.
2269 If HANDLER is 0, it means don't handle the errors any more. */
2272 set_float_handler (handler
)
2275 float_handled
= (handler
!= 0);
2277 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
2279 if (float_handled
&& ! float_handler_set
)
2281 signal (SIGFPE
, float_signal
);
2282 float_handler_set
= 1;
2286 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2287 error happens, pushing the previous specification into OLD_HANDLER.
2288 Return an indication of whether there was a previous handler in effect. */
2291 push_float_handler (handler
, old_handler
)
2292 jmp_buf handler
, old_handler
;
2294 int was_handled
= float_handled
;
2298 memcpy ((char *) old_handler
, (char *) float_handler
,
2299 sizeof (float_handler
));
2301 memcpy ((char *) float_handler
, (char *) handler
, sizeof (float_handler
));
2305 /* Restore the previous specification of whether and where to longjmp to
2306 when a floating arithmetic error happens. */
2309 pop_float_handler (handled
, handler
)
2313 float_handled
= handled
;
2315 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
2318 /* Handler for SIGPIPE. */
2322 /* If this is missing, some compilers complain. */
2323 int signo ATTRIBUTE_UNUSED
;
2325 fatal ("output pipe has been closed");
2328 /* Strip off a legitimate source ending from the input string NAME of
2329 length LEN. Rather than having to know the names used by all of
2330 our front ends, we strip off an ending of a period followed by
2331 up to five characters. (Java uses ".class".) */
2334 strip_off_ending (name
, len
)
2339 for (i
= 2; i
< 6 && len
> i
; i
++)
2341 if (name
[len
- i
] == '.')
2343 name
[len
- i
] = '\0';
2349 /* Output a quoted string. */
2352 output_quoted_string (asm_file
, string
)
2356 #ifdef OUTPUT_QUOTED_STRING
2357 OUTPUT_QUOTED_STRING (asm_file
, string
);
2361 putc ('\"', asm_file
);
2362 while ((c
= *string
++) != 0)
2364 if (c
== '\"' || c
== '\\')
2365 putc ('\\', asm_file
);
2368 putc ('\"', asm_file
);
2372 /* Output a file name in the form wanted by System V. */
2375 output_file_directive (asm_file
, input_name
)
2379 int len
= strlen (input_name
);
2380 char *na
= input_name
+ len
;
2382 /* NA gets INPUT_NAME sans directory names. */
2383 while (na
> input_name
)
2390 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2391 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file
, na
);
2393 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2394 ASM_OUTPUT_SOURCE_FILENAME (asm_file
, na
);
2396 fprintf (asm_file
, "\t.file\t");
2397 output_quoted_string (asm_file
, na
);
2398 fputc ('\n', asm_file
);
2403 /* Routine to build language identifier for object file. */
2406 output_lang_identify (asm_out_file
)
2409 int len
= strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2410 char *s
= (char *) alloca (len
);
2411 sprintf (s
, "__gnu_compiled_%s", lang_identify ());
2412 ASM_OUTPUT_LABEL (asm_out_file
, s
);
2415 /* Routine to open a dump file. */
2417 open_dump_file (suffix
, function_name
)
2419 char *function_name
;
2426 dumpname
= (char *) xmalloc (strlen (dump_base_name
) + strlen (suffix
) + 1);
2428 if (rtl_dump_file
!= NULL
)
2429 fclose (rtl_dump_file
);
2431 strcpy (dumpname
, dump_base_name
);
2432 strcat (dumpname
, suffix
);
2434 rtl_dump_file
= fopen (dumpname
, "a");
2436 if (rtl_dump_file
== NULL
)
2437 pfatal_with_name (dumpname
);
2442 fprintf (rtl_dump_file
, "\n;; Function %s\n\n", function_name
);
2448 /* Routine to close a dump file. */
2450 close_dump_file (func
, insns
)
2451 void (*func
) PROTO ((FILE *, rtx
));
2458 func (rtl_dump_file
, insns
);
2460 fflush (rtl_dump_file
);
2461 fclose (rtl_dump_file
);
2463 rtl_dump_file
= NULL
;
2469 /* Routine to dump rtl into a file. */
2471 dump_rtl (suffix
, decl
, func
, insns
)
2474 void (*func
) PROTO ((FILE *, rtx
));
2477 open_dump_file (suffix
, decl_printable_name (decl
, 2));
2478 close_dump_file (func
, insns
);
2481 /* Routine to empty a dump file. */
2483 clean_dump_file (suffix
)
2488 dumpname
= (char *) xmalloc (strlen (dump_base_name
) + strlen (suffix
) + 1);
2490 strcpy (dumpname
, dump_base_name
);
2491 strcat (dumpname
, suffix
);
2493 rtl_dump_file
= fopen (dumpname
, "w");
2495 if (rtl_dump_file
== NULL
)
2496 pfatal_with_name (dumpname
);
2500 fclose (rtl_dump_file
);
2501 rtl_dump_file
= NULL
;
2507 /* Compile an entire file of output from cpp, named NAME.
2508 Write a file of assembly output and various debugging dumps. */
2517 int name_specified
= name
!= 0;
2519 if (dump_base_name
== 0)
2520 dump_base_name
= name
? name
: "gccdump";
2524 integration_time
= 0;
2530 branch_prob_time
= 0;
2535 local_alloc_time
= 0;
2536 global_alloc_time
= 0;
2541 shorten_branch_time
= 0;
2547 /* Initialize data in various passes. */
2551 name
= init_parse (name
);
2553 init_emit_once (debug_info_level
== DINFO_LEVEL_NORMAL
2554 || debug_info_level
== DINFO_LEVEL_VERBOSE
2555 || flag_test_coverage
);
2557 init_decl_processing ();
2566 if (flag_caller_saves
)
2567 init_caller_save ();
2569 /* If auxiliary info generation is desired, open the output file.
2570 This goes in the same directory as the source file--unlike
2571 all the other output files. */
2572 if (flag_gen_aux_info
)
2574 aux_info_file
= fopen (aux_info_file_name
, "w");
2575 if (aux_info_file
== 0)
2576 pfatal_with_name (aux_info_file_name
);
2579 /* Clear the dump files file. */
2581 clean_dump_file (".rtl");
2583 clean_dump_file (".jump");
2585 clean_dump_file (".addressof");
2587 clean_dump_file (".cse");
2589 clean_dump_file (".loop");
2591 clean_dump_file (".cse2");
2592 if (branch_prob_dump
)
2593 clean_dump_file (".bp");
2595 clean_dump_file (".flow");
2597 clean_dump_file (".combine");
2599 clean_dump_file (".regmove");
2601 clean_dump_file (".sched");
2603 clean_dump_file (".lreg");
2604 if (global_reg_dump
)
2605 clean_dump_file (".greg");
2607 clean_dump_file (".sched2");
2609 clean_dump_file (".jump2");
2612 clean_dump_file (".dbr");
2615 clean_dump_file (".gcse");
2618 clean_dump_file (".stack");
2620 #ifdef MACHINE_DEPENDENT_REORG
2621 if (mach_dep_reorg_dump
)
2622 clean_dump_file (".mach");
2625 /* Open assembler code output file. */
2627 if (! name_specified
&& asm_file_name
== 0)
2628 asm_out_file
= stdout
;
2631 int len
= strlen (dump_base_name
);
2632 register char *dumpname
= (char *) xmalloc (len
+ 6);
2633 strcpy (dumpname
, dump_base_name
);
2634 strip_off_ending (dumpname
, len
);
2635 strcat (dumpname
, ".s");
2636 if (asm_file_name
== 0)
2638 asm_file_name
= (char *) xmalloc (strlen (dumpname
) + 1);
2639 strcpy (asm_file_name
, dumpname
);
2641 if (!strcmp (asm_file_name
, "-"))
2642 asm_out_file
= stdout
;
2644 asm_out_file
= fopen (asm_file_name
, "w");
2645 if (asm_out_file
== 0)
2646 pfatal_with_name (asm_file_name
);
2649 #ifdef IO_BUFFER_SIZE
2650 setvbuf (asm_out_file
, (char *) xmalloc (IO_BUFFER_SIZE
),
2651 _IOFBF
, IO_BUFFER_SIZE
);
2654 input_filename
= name
;
2656 /* Put an entry on the input file stack for the main input file. */
2658 = (struct file_stack
*) xmalloc (sizeof (struct file_stack
));
2659 input_file_stack
->next
= 0;
2660 input_file_stack
->name
= input_filename
;
2662 /* Perform language-specific initialization.
2663 This may set main_input_filename. */
2666 /* If the input doesn't start with a #line, use the input name
2667 as the official input file name. */
2668 if (main_input_filename
== 0)
2669 main_input_filename
= name
;
2671 ASM_FILE_START (asm_out_file
);
2673 #ifdef ASM_COMMENT_START
2674 if (flag_verbose_asm
)
2676 /* Print the list of options in effect. */
2677 print_version (asm_out_file
, ASM_COMMENT_START
);
2678 print_switch_values (asm_out_file
, 0, MAX_LINE
,
2679 ASM_COMMENT_START
, " ", "\n");
2680 /* Add a blank line here so it appears in assembler output but not
2682 fprintf (asm_out_file
, "\n");
2686 /* Output something to inform GDB that this compilation was by GCC. */
2687 #ifndef ASM_IDENTIFY_GCC
2688 fprintf (asm_out_file
, "gcc2_compiled.:\n");
2690 ASM_IDENTIFY_GCC (asm_out_file
);
2693 /* Output something to identify which front-end produced this file. */
2694 #ifdef ASM_IDENTIFY_LANGUAGE
2695 ASM_IDENTIFY_LANGUAGE (asm_out_file
);
2698 #ifndef ASM_OUTPUT_SECTION_NAME
2699 if (flag_function_sections
)
2701 warning ("-ffunction-sections not supported for this target.");
2702 flag_function_sections
= 0;
2706 if (flag_function_sections
2707 && (profile_flag
|| profile_block_flag
))
2709 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2710 flag_function_sections
= 0;
2713 if (flag_function_sections
&& write_symbols
!= NO_DEBUG
)
2714 warning ("-ffunction-sections may affect debugging on some targets.");
2716 /* ??? Note: There used to be a conditional here
2717 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2718 This was to guarantee separation between gcc_compiled. and
2719 the first function, for the sake of dbx on Suns.
2720 However, having the extra zero here confused the Emacs
2721 code for unexec, and might confuse other programs too.
2722 Therefore, I took out that change.
2723 In future versions we should find another way to solve
2724 that dbx problem. -- rms, 23 May 93. */
2726 /* Don't let the first function fall at the same address
2727 as gcc_compiled., if profiling. */
2728 if (profile_flag
|| profile_block_flag
)
2730 /* It's best if we can write a nop here since some
2731 assemblers don't tolerate zeros in the text section. */
2732 if (insn_template
[CODE_FOR_nop
] != 0)
2733 output_asm_insn (insn_template
[CODE_FOR_nop
], NULL_PTR
);
2735 assemble_zeros (UNITS_PER_WORD
);
2738 /* If dbx symbol table desired, initialize writing it
2739 and output the predefined types. */
2740 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2741 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2742 TIMEVAR (symout_time
, dbxout_init (asm_out_file
, main_input_filename
,
2745 #ifdef SDB_DEBUGGING_INFO
2746 if (write_symbols
== SDB_DEBUG
)
2747 TIMEVAR (symout_time
, sdbout_init (asm_out_file
, main_input_filename
,
2750 #ifdef DWARF_DEBUGGING_INFO
2751 if (write_symbols
== DWARF_DEBUG
)
2752 TIMEVAR (symout_time
, dwarfout_init (asm_out_file
, main_input_filename
));
2754 #ifdef DWARF2_UNWIND_INFO
2755 if (dwarf2out_do_frame ())
2756 dwarf2out_frame_init ();
2758 #ifdef DWARF2_DEBUGGING_INFO
2759 if (write_symbols
== DWARF2_DEBUG
)
2760 TIMEVAR (symout_time
, dwarf2out_init (asm_out_file
, main_input_filename
));
2763 /* Initialize yet another pass. */
2765 init_final (main_input_filename
);
2766 init_branch_prob (dump_base_name
);
2768 start_time
= get_run_time ();
2770 /* Call the parser, which parses the entire file
2771 (calling rest_of_compilation for each function). */
2773 if (yyparse () != 0)
2775 if (errorcount
== 0)
2776 fprintf (stderr
, "Errors detected in input file (your bison.simple is out of date)");
2778 /* In case there were missing closebraces,
2779 get us back to the global binding level. */
2780 while (! global_bindings_p ())
2784 output_func_start_profiler ();
2786 /* Compilation is now finished except for writing
2787 what's left of the symbol table output. */
2789 parse_time
+= get_run_time () - start_time
;
2791 parse_time
-= integration_time
;
2792 parse_time
-= varconst_time
;
2794 globals
= getdecls ();
2796 /* Really define vars that have had only a tentative definition.
2797 Really output inline functions that must actually be callable
2798 and have not been output so far. */
2801 int len
= list_length (globals
);
2802 tree
*vec
= (tree
*) alloca (sizeof (tree
) * len
);
2807 /* Process the decls in reverse order--earliest first.
2808 Put them into VEC from back to front, then take out from front. */
2810 for (i
= 0, decl
= globals
; i
< len
; i
++, decl
= TREE_CHAIN (decl
))
2811 vec
[len
- i
- 1] = decl
;
2813 for (i
= 0; i
< len
; i
++)
2817 /* We're not deferring this any longer. */
2818 DECL_DEFER_OUTPUT (decl
) = 0;
2820 if (TREE_CODE (decl
) == VAR_DECL
&& DECL_SIZE (decl
) == 0
2821 && incomplete_decl_finalize_hook
!= 0)
2822 (*incomplete_decl_finalize_hook
) (decl
);
2825 /* Now emit any global variables or functions that we have been putting
2826 off. We need to loop in case one of the things emitted here
2827 references another one which comes earlier in the list. */
2831 for (i
= 0; i
< len
; i
++)
2835 if (TREE_ASM_WRITTEN (decl
) || DECL_EXTERNAL (decl
))
2838 /* Don't write out static consts, unless we still need them.
2840 We also keep static consts if not optimizing (for debugging),
2841 unless the user specified -fno-keep-static-consts.
2842 ??? They might be better written into the debug information.
2843 This is possible when using DWARF.
2845 A language processor that wants static constants to be always
2846 written out (even if it is not used) is responsible for
2847 calling rest_of_decl_compilation itself. E.g. the C front-end
2848 calls rest_of_decl_compilation from finish_decl.
2849 One motivation for this is that is conventional in some
2850 environments to write things like:
2851 static const char rcsid[] = "... version string ...";
2852 intending to force the string to be in the executable.
2854 A language processor that would prefer to have unneeded
2855 static constants "optimized away" would just defer writing
2856 them out until here. E.g. C++ does this, because static
2857 constants are often defined in header files.
2859 ??? A tempting alternative (for both C and C++) would be
2860 to force a constant to be written if and only if it is
2861 defined in a main file, as opposed to an include file. */
2863 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
2864 && (! TREE_READONLY (decl
)
2865 || TREE_PUBLIC (decl
)
2866 || (!optimize
&& flag_keep_static_consts
)
2867 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
2870 rest_of_decl_compilation (decl
, NULL_PTR
, 1, 1);
2873 if (TREE_CODE (decl
) == FUNCTION_DECL
2874 && DECL_INITIAL (decl
) != 0
2875 && DECL_SAVED_INSNS (decl
) != 0
2876 && (flag_keep_inline_functions
2877 || TREE_PUBLIC (decl
)
2878 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
2881 temporary_allocation ();
2882 output_inline_function (decl
);
2883 permanent_allocation (1);
2888 /* Now that all possible functions have been output, we can dump
2889 the exception table. */
2891 output_exception_table ();
2893 for (i
= 0; i
< len
; i
++)
2897 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
2898 && ! TREE_ASM_WRITTEN (decl
))
2899 /* Cancel the RTL for this decl so that, if debugging info
2900 output for global variables is still to come,
2901 this one will be omitted. */
2902 DECL_RTL (decl
) = NULL
;
2904 /* Warn about any function
2905 declared static but not defined.
2906 We don't warn about variables,
2907 because many programs have static variables
2908 that exist only to get some text into the object file. */
2909 if (TREE_CODE (decl
) == FUNCTION_DECL
2911 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
2912 && DECL_INITIAL (decl
) == 0
2913 && DECL_EXTERNAL (decl
)
2914 && ! DECL_ARTIFICIAL (decl
)
2915 && ! TREE_PUBLIC (decl
))
2917 pedwarn_with_decl (decl
,
2918 "`%s' declared `static' but never defined");
2919 /* This symbol is effectively an "extern" declaration now. */
2920 TREE_PUBLIC (decl
) = 1;
2921 assemble_external (decl
);
2924 /* Warn about static fns or vars defined but not used,
2925 but not about inline functions or static consts
2926 since defining those in header files is normal practice. */
2928 && ((TREE_CODE (decl
) == FUNCTION_DECL
&& ! DECL_INLINE (decl
))
2929 || (TREE_CODE (decl
) == VAR_DECL
&& ! TREE_READONLY (decl
)))
2930 && ! DECL_IN_SYSTEM_HEADER (decl
)
2931 && ! DECL_EXTERNAL (decl
)
2932 && ! TREE_PUBLIC (decl
)
2933 && ! TREE_USED (decl
)
2934 && (TREE_CODE (decl
) == FUNCTION_DECL
|| ! DECL_REGISTER (decl
))
2935 /* The TREE_USED bit for file-scope decls
2936 is kept in the identifier, to handle multiple
2937 external decls in different scopes. */
2938 && ! TREE_USED (DECL_NAME (decl
)))
2939 warning_with_decl (decl
, "`%s' defined but not used");
2941 #ifdef SDB_DEBUGGING_INFO
2942 /* The COFF linker can move initialized global vars to the end.
2943 And that can screw up the symbol ordering.
2944 By putting the symbols in that order to begin with,
2945 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2946 if (write_symbols
== SDB_DEBUG
&& TREE_CODE (decl
) == VAR_DECL
2947 && TREE_PUBLIC (decl
) && DECL_INITIAL (decl
)
2948 && ! DECL_EXTERNAL (decl
)
2949 && DECL_RTL (decl
) != 0)
2950 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
2952 /* Output COFF information for non-global
2953 file-scope initialized variables. */
2954 if (write_symbols
== SDB_DEBUG
2955 && TREE_CODE (decl
) == VAR_DECL
2956 && DECL_INITIAL (decl
)
2957 && ! DECL_EXTERNAL (decl
)
2958 && DECL_RTL (decl
) != 0
2959 && GET_CODE (DECL_RTL (decl
)) == MEM
)
2960 TIMEVAR (symout_time
, sdbout_toplevel_data (decl
));
2961 #endif /* SDB_DEBUGGING_INFO */
2962 #ifdef DWARF_DEBUGGING_INFO
2963 /* Output DWARF information for file-scope tentative data object
2964 declarations, file-scope (extern) function declarations (which
2965 had no corresponding body) and file-scope tagged type declarations
2966 and definitions which have not yet been forced out. */
2968 if (write_symbols
== DWARF_DEBUG
2969 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
2970 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 1));
2972 #ifdef DWARF2_DEBUGGING_INFO
2973 /* Output DWARF2 information for file-scope tentative data object
2974 declarations, file-scope (extern) function declarations (which
2975 had no corresponding body) and file-scope tagged type declarations
2976 and definitions which have not yet been forced out. */
2978 if (write_symbols
== DWARF2_DEBUG
2979 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
2980 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
2985 /* Write out any pending weak symbol declarations. */
2989 /* Do dbx symbols */
2990 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2991 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2992 TIMEVAR (symout_time
,
2994 dbxout_finish (asm_out_file
, main_input_filename
);
2998 #ifdef DWARF_DEBUGGING_INFO
2999 if (write_symbols
== DWARF_DEBUG
)
3000 TIMEVAR (symout_time
,
3006 #ifdef DWARF2_UNWIND_INFO
3007 if (dwarf2out_do_frame ())
3008 dwarf2out_frame_finish ();
3011 #ifdef DWARF2_DEBUGGING_INFO
3012 if (write_symbols
== DWARF2_DEBUG
)
3013 TIMEVAR (symout_time
,
3015 dwarf2out_finish ();
3019 /* Output some stuff at end of file if nec. */
3021 end_final (dump_base_name
);
3023 if (branch_prob_dump
)
3024 open_dump_file (".bp", NULL
);
3026 TIMEVAR (dump_time
, end_branch_prob (rtl_dump_file
));
3028 if (branch_prob_dump
)
3029 close_dump_file (NULL
, NULL_RTX
);
3032 ASM_FILE_END (asm_out_file
);
3035 /* Language-specific end of compilation actions. */
3039 /* Close the dump files. */
3041 if (flag_gen_aux_info
)
3043 fclose (aux_info_file
);
3045 unlink (aux_info_file_name
);
3050 open_dump_file (".combine", NULL
);
3051 TIMEVAR (dump_time
, dump_combine_total_stats (rtl_dump_file
));
3052 close_dump_file (NULL
, NULL_RTX
);
3055 /* Close non-debugging input and output files. Take special care to note
3056 whether fclose returns an error, since the pages might still be on the
3057 buffer chain while the file is open. */
3061 if (ferror (asm_out_file
) != 0 || fclose (asm_out_file
) != 0)
3062 fatal_io_error (asm_file_name
);
3064 /* Print the times. */
3068 fprintf (stderr
,"\n");
3069 print_time ("parse", parse_time
);
3071 print_time ("integration", integration_time
);
3072 print_time ("jump", jump_time
);
3073 print_time ("cse", cse_time
);
3074 print_time ("gcse", gcse_time
);
3075 print_time ("loop", loop_time
);
3076 print_time ("cse2", cse2_time
);
3077 print_time ("branch-prob", branch_prob_time
);
3078 print_time ("flow", flow_time
);
3079 print_time ("combine", combine_time
);
3080 print_time ("regmove", regmove_time
);
3081 print_time ("sched", sched_time
);
3082 print_time ("local-alloc", local_alloc_time
);
3083 print_time ("global-alloc", global_alloc_time
);
3084 print_time ("sched2", sched2_time
);
3086 print_time ("dbranch", dbr_sched_time
);
3088 print_time ("shorten-branch", shorten_branch_time
);
3089 print_time ("stack-reg", stack_reg_time
);
3090 print_time ("final", final_time
);
3091 print_time ("varconst", varconst_time
);
3092 print_time ("symout", symout_time
);
3093 print_time ("dump", dump_time
);
3097 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3098 and TYPE_DECL nodes.
3100 This does nothing for local (non-static) variables.
3101 Otherwise, it sets up the RTL and outputs any assembler code
3102 (label definition, storage allocation and initialization).
3104 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3105 the assembler symbol name to be used. TOP_LEVEL is nonzero
3106 if this declaration is not within a function. */
3109 rest_of_decl_compilation (decl
, asmspec
, top_level
, at_end
)
3115 /* Declarations of variables, and of functions defined elsewhere. */
3117 /* The most obvious approach, to put an #ifndef around where
3118 this macro is used, doesn't work since it's inside a macro call. */
3119 #ifndef ASM_FINISH_DECLARE_OBJECT
3120 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3123 /* Forward declarations for nested functions are not "external",
3124 but we need to treat them as if they were. */
3125 if (TREE_STATIC (decl
) || DECL_EXTERNAL (decl
)
3126 || TREE_CODE (decl
) == FUNCTION_DECL
)
3127 TIMEVAR (varconst_time
,
3129 make_decl_rtl (decl
, asmspec
, top_level
);
3130 /* Initialized extern variable exists to be replaced
3131 with its value, or represents something that will be
3132 output in another file. */
3133 if (! (TREE_CODE (decl
) == VAR_DECL
3134 && DECL_EXTERNAL (decl
) && TREE_READONLY (decl
)
3135 && DECL_INITIAL (decl
) != 0
3136 && DECL_INITIAL (decl
) != error_mark_node
))
3137 /* Don't output anything
3138 when a tentative file-scope definition is seen.
3139 But at end of compilation, do output code for them. */
3140 if (! (! at_end
&& top_level
3141 && (DECL_INITIAL (decl
) == 0
3142 || DECL_INITIAL (decl
) == error_mark_node
)))
3143 assemble_variable (decl
, top_level
, at_end
, 0);
3144 if (decl
== last_assemble_variable_decl
)
3146 ASM_FINISH_DECLARE_OBJECT (asm_out_file
, decl
,
3150 else if (DECL_REGISTER (decl
) && asmspec
!= 0)
3152 if (decode_reg_name (asmspec
) >= 0)
3154 DECL_RTL (decl
) = 0;
3155 make_decl_rtl (decl
, asmspec
, top_level
);
3158 error ("invalid register name `%s' for register variable", asmspec
);
3160 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3161 else if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3162 && TREE_CODE (decl
) == TYPE_DECL
)
3163 TIMEVAR (symout_time
, dbxout_symbol (decl
, 0));
3165 #ifdef SDB_DEBUGGING_INFO
3166 else if (write_symbols
== SDB_DEBUG
&& top_level
3167 && TREE_CODE (decl
) == TYPE_DECL
)
3168 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
3172 /* Called after finishing a record, union or enumeral type. */
3175 rest_of_type_compilation (type
, toplev
)
3176 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3180 tree type ATTRIBUTE_UNUSED
;
3181 int toplev ATTRIBUTE_UNUSED
;
3184 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3185 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3186 TIMEVAR (symout_time
, dbxout_symbol (TYPE_STUB_DECL (type
), !toplev
));
3188 #ifdef SDB_DEBUGGING_INFO
3189 if (write_symbols
== SDB_DEBUG
)
3190 TIMEVAR (symout_time
, sdbout_symbol (TYPE_STUB_DECL (type
), !toplev
));
3194 /* This is called from finish_function (within yyparse)
3195 after each top-level definition is parsed.
3196 It is supposed to compile that function or variable
3197 and output the assembler code for it.
3198 After we return, the tree storage is freed. */
3201 rest_of_compilation (decl
)
3205 int start_time
= get_run_time ();
3207 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3208 to be restored after we finish compiling the function
3209 (for use when compiling inline calls to this function). */
3210 tree saved_block_tree
= 0;
3211 /* Likewise, for DECL_ARGUMENTS. */
3212 tree saved_arguments
= 0;
3215 /* If we are reconsidering an inline function
3216 at the end of compilation, skip the stuff for making it inline. */
3218 if (DECL_SAVED_INSNS (decl
) == 0)
3223 /* If requested, consider whether to make this function inline. */
3224 if (DECL_INLINE (decl
) || flag_inline_functions
)
3225 TIMEVAR (integration_time
,
3227 lose
= function_cannot_inline_p (decl
);
3228 if (lose
|| ! optimize
)
3230 if (warn_inline
&& DECL_INLINE (decl
))
3231 warning_with_decl (decl
, lose
);
3232 DECL_ABSTRACT_ORIGIN (decl
) = 0;
3233 /* Don't really compile an extern inline function.
3234 If we can't make it inline, pretend
3235 it was only declared. */
3236 if (DECL_EXTERNAL (decl
))
3238 DECL_INITIAL (decl
) = 0;
3239 goto exit_rest_of_compilation
;
3243 /* ??? Note that this has the effect of making it look
3244 like "inline" was specified for a function if we choose
3245 to inline it. This isn't quite right, but it's
3246 probably not worth the trouble to fix. */
3247 inlinable
= DECL_INLINE (decl
) = 1;
3250 insns
= get_insns ();
3252 /* Dump the rtl code if we are dumping rtl. */
3256 open_dump_file (".rtl", decl_printable_name (decl
, 2));
3258 if (DECL_SAVED_INSNS (decl
))
3259 fprintf (rtl_dump_file
, ";; (integrable)\n\n");
3261 close_dump_file (print_rtl
, insns
);
3264 /* If we can, defer compiling inlines until EOF.
3265 save_for_inline_copying can be extremely expensive. */
3266 if (inlinable
&& ! decl_function_context (decl
))
3267 DECL_DEFER_OUTPUT (decl
) = 1;
3269 /* If function is inline, and we don't yet know whether to
3270 compile it by itself, defer decision till end of compilation.
3271 finish_compilation will call rest_of_compilation again
3272 for those functions that need to be output. Also defer those
3273 functions that we are supposed to defer. We cannot defer
3274 functions containing nested functions since the nested function
3275 data is in our non-saved obstack. We cannot defer nested
3276 functions for the same reason. */
3278 /* If this is a nested inline, remove ADDRESSOF now so we can
3279 finish compiling ourselves. Otherwise, wait until EOF.
3280 We have to do this because the purge_addressof transformation
3281 changes the DECL_RTL for many variables, which confuses integrate. */
3284 if (decl_function_context (decl
))
3285 purge_addressof (insns
);
3287 DECL_DEFER_OUTPUT (decl
) = 1;
3290 if (! current_function_contains_functions
3291 && (DECL_DEFER_OUTPUT (decl
)
3292 || (DECL_INLINE (decl
)
3293 && ((! TREE_PUBLIC (decl
) && ! TREE_ADDRESSABLE (decl
)
3294 && ! flag_keep_inline_functions
)
3295 || DECL_EXTERNAL (decl
)))))
3297 DECL_DEFER_OUTPUT (decl
) = 1;
3299 /* If -Wreturn-type, we have to do a bit of compilation.
3300 However, if we just fall through we will call
3301 save_for_inline_copying() which results in excessive
3302 memory use. Instead, we just want to call
3303 jump_optimize() to figure out whether or not we can fall
3304 off the end of the function; we do the minimum amount of
3305 work necessary to make that safe. And, we set optimize
3306 to zero to keep jump_optimize from working too hard. */
3307 if (warn_return_type
)
3309 int saved_optimize
= optimize
;
3311 find_exception_handler_labels ();
3312 jump_optimize (get_insns(), !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
3313 !JUMP_AFTER_REGSCAN
);
3314 optimize
= saved_optimize
;
3317 #ifdef DWARF_DEBUGGING_INFO
3318 /* Generate the DWARF info for the "abstract" instance
3319 of a function which we may later generate inlined and/or
3320 out-of-line instances of. */
3321 if (write_symbols
== DWARF_DEBUG
)
3323 set_decl_abstract_flags (decl
, 1);
3324 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
3325 set_decl_abstract_flags (decl
, 0);
3328 #ifdef DWARF2_DEBUGGING_INFO
3329 /* Generate the DWARF2 info for the "abstract" instance
3330 of a function which we may later generate inlined and/or
3331 out-of-line instances of. */
3332 if (write_symbols
== DWARF2_DEBUG
)
3334 set_decl_abstract_flags (decl
, 1);
3335 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
3336 set_decl_abstract_flags (decl
, 0);
3339 TIMEVAR (integration_time
, save_for_inline_nocopy (decl
));
3340 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl
)) = inlinable
;
3341 goto exit_rest_of_compilation
;
3344 /* If we have to compile the function now, save its rtl and subdecls
3345 so that its compilation will not affect what others get. */
3346 if (inlinable
|| DECL_DEFER_OUTPUT (decl
))
3348 #ifdef DWARF_DEBUGGING_INFO
3349 /* Generate the DWARF info for the "abstract" instance of
3350 a function which we will generate an out-of-line instance
3351 of almost immediately (and which we may also later generate
3352 various inlined instances of). */
3353 if (write_symbols
== DWARF_DEBUG
)
3355 set_decl_abstract_flags (decl
, 1);
3356 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
3357 set_decl_abstract_flags (decl
, 0);
3360 #ifdef DWARF2_DEBUGGING_INFO
3361 /* Generate the DWARF2 info for the "abstract" instance of
3362 a function which we will generate an out-of-line instance
3363 of almost immediately (and which we may also later generate
3364 various inlined instances of). */
3365 if (write_symbols
== DWARF2_DEBUG
)
3367 set_decl_abstract_flags (decl
, 1);
3368 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
3369 set_decl_abstract_flags (decl
, 0);
3372 saved_block_tree
= DECL_INITIAL (decl
);
3373 saved_arguments
= DECL_ARGUMENTS (decl
);
3374 TIMEVAR (integration_time
, save_for_inline_copying (decl
));
3375 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl
)) = inlinable
;
3378 /* If specified extern inline but we aren't inlining it, we are
3380 if (DECL_INLINE (decl
) && DECL_EXTERNAL (decl
))
3381 goto exit_rest_of_compilation
;
3384 if (! DECL_DEFER_OUTPUT (decl
))
3385 TREE_ASM_WRITTEN (decl
) = 1;
3387 /* Now that integrate will no longer see our rtl, we need not distinguish
3388 between the return value of this function and the return value of called
3390 rtx_equal_function_value_matters
= 0;
3392 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3393 if ((rtl_dump_and_exit
|| flag_syntax_only
) && !warn_return_type
)
3395 goto exit_rest_of_compilation
;
3398 /* Emit code to get eh context, if needed. */
3402 /* If we are doing position-independent code generation, now
3403 is the time to output special prologues and epilogues.
3404 We do not want to do this earlier, because it just clutters
3405 up inline functions with meaningless insns. */
3410 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3411 Note that that may have been done above, in save_for_inline_copying.
3412 The call to resume_temporary_allocation near the end of this function
3413 goes back to the usual state of affairs. This must be done after
3414 we've built up any unwinders for exception handling, and done
3415 the FINALIZE_PIC work, if necessary. */
3417 rtl_in_current_obstack ();
3419 insns
= get_insns ();
3421 /* Copy any shared structure that should not be shared. */
3423 unshare_all_rtl (insns
);
3425 #ifdef SETJMP_VIA_SAVE_AREA
3426 /* This must be performed before virutal register instantiation. */
3427 if (current_function_calls_alloca
)
3428 optimize_save_area_alloca (insns
);
3431 /* Instantiate all virtual registers. */
3433 instantiate_virtual_regs (current_function_decl
, get_insns ());
3435 /* See if we have allocated stack slots that are not directly addressable.
3436 If so, scan all the insns and create explicit address computation
3437 for all references to such slots. */
3438 /* fixup_stack_slots (); */
3440 /* Find all the EH handlers. */
3441 find_exception_handler_labels ();
3443 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3444 are initialized and to compute whether control can drop off the end
3446 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3447 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
3448 JUMP_AFTER_REGSCAN
));
3450 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3451 if (rtl_dump_and_exit
|| flag_syntax_only
|| DECL_DEFER_OUTPUT (decl
))
3452 goto exit_rest_of_compilation
;
3454 /* Dump rtl code after jump, if we are doing that. */
3457 dump_rtl (".jump", decl
, print_rtl
, insns
);
3459 /* Perform common subexpression elimination.
3460 Nonzero value from `cse_main' means that jumps were simplified
3461 and some code may now be unreachable, so do
3462 jump optimization again. */
3467 open_dump_file (".cse", decl_printable_name (decl
, 2));
3469 TIMEVAR (cse_time
, reg_scan (insns
, max_reg_num (), 1));
3471 if (flag_thread_jumps
)
3472 /* Hacks by tiemann & kenner. */
3473 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 1));
3475 TIMEVAR (cse_time
, tem
= cse_main (insns
, max_reg_num (),
3477 TIMEVAR (cse_time
, delete_trivially_dead_insns (insns
, max_reg_num ()));
3479 if (tem
|| optimize
> 1)
3480 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3482 !JUMP_AFTER_REGSCAN
));
3484 /* Dump rtl code after cse, if we are doing that. */
3487 close_dump_file (print_rtl
, insns
);
3490 purge_addressof (insns
);
3491 reg_scan (insns
, max_reg_num (), 1);
3494 dump_rtl (".addressof", decl
, print_rtl
, insns
);
3496 /* Perform global cse. */
3498 if (optimize
> 0 && flag_gcse
)
3501 open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl
)));
3503 TIMEVAR (gcse_time
, gcse_main (insns
, rtl_dump_file
));
3506 close_dump_file (print_rtl
, insns
);
3508 /* Move constant computations out of loops. */
3513 open_dump_file (".loop", decl_printable_name (decl
, 2));
3518 if (flag_rerun_loop_opt
)
3520 /* We only want to perform unrolling once. */
3522 loop_optimize (insns
, rtl_dump_file
, 0, 0);
3525 /* The first call to loop_optimize makes some instructions
3526 trivially dead. We delete those instructions now in the
3527 hope that doing so will make the heuristics in loop work
3528 better and possibly speed up compilation. */
3529 delete_trivially_dead_insns (insns
, max_reg_num ());
3531 /* The regscan pass is currently necessary as the alias
3532 analysis code depends on this information. */
3533 reg_scan (insns
, max_reg_num (), 1);
3535 loop_optimize (insns
, rtl_dump_file
, flag_unroll_loops
, 1);
3538 /* Dump rtl code after loop opt, if we are doing that. */
3541 close_dump_file (print_rtl
, insns
);
3547 open_dump_file (".cse2", decl_printable_name (decl
, 2));
3549 if (flag_rerun_cse_after_loop
)
3551 /* Running another jump optimization pass before the second
3552 cse pass sometimes simplifies the RTL enough to allow
3553 the second CSE pass to do a better job. Jump_optimize can change
3554 max_reg_num so we must rerun reg_scan afterwards.
3555 ??? Rework to not call reg_scan so often. */
3556 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3557 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3559 JUMP_AFTER_REGSCAN
));
3561 TIMEVAR (cse2_time
, reg_scan (insns
, max_reg_num (), 0));
3562 TIMEVAR (cse2_time
, tem
= cse_main (insns
, max_reg_num (),
3565 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3567 !JUMP_AFTER_REGSCAN
));
3570 if (flag_thread_jumps
)
3572 /* This pass of jump threading straightens out code
3573 that was kinked by loop optimization. */
3574 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3575 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 0));
3578 /* Dump rtl code after cse, if we are doing that. */
3581 close_dump_file (print_rtl
, insns
);
3584 if (profile_arc_flag
|| flag_test_coverage
|| flag_branch_probabilities
)
3586 if (branch_prob_dump
)
3587 open_dump_file (".bp", decl_printable_name (decl
, 2));
3592 branch_prob (insns
, rtl_dump_file
);
3595 if (branch_prob_dump
)
3596 close_dump_file (print_rtl
, insns
);
3599 /* We are no longer anticipating cse in this function, at least. */
3601 cse_not_expected
= 1;
3603 /* Now we choose between stupid (pcc-like) register allocation
3604 (if we got the -noreg switch and not -opt)
3605 and smart register allocation. */
3607 if (optimize
> 0) /* Stupid allocation probably won't work */
3608 obey_regdecls
= 0; /* if optimizations being done. */
3612 /* Print function header into flow dump now
3613 because doing the flow analysis makes some of the dump. */
3616 open_dump_file (".flow", decl_printable_name (decl
, 2));
3622 regclass (insns
, max_reg_num ());
3623 stupid_life_analysis (insns
, max_reg_num (),
3629 /* Do control and data flow analysis,
3630 and write some of the results to dump file. */
3635 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
, 1);
3636 life_analysis (insns
, max_reg_num (), rtl_dump_file
);
3639 if (warn_uninitialized
)
3641 uninitialized_vars_warning (DECL_INITIAL (decl
));
3642 setjmp_args_warning ();
3646 /* Dump rtl after flow analysis. */
3649 close_dump_file (print_rtl_with_bb
, insns
);
3651 /* If -opt, try combining insns through substitution. */
3655 TIMEVAR (combine_time
, combine_instructions (insns
, max_reg_num ()));
3657 /* Dump rtl code after insn combination. */
3660 dump_rtl (".combine", decl
, print_rtl_with_bb
, insns
);
3663 /* Register allocation pre-pass, to reduce number of moves
3664 necessary for two-address machines. */
3665 if (optimize
> 0 && (flag_regmove
|| flag_expensive_optimizations
))
3668 open_dump_file (".regmove", decl_printable_name (decl
, 2));
3670 TIMEVAR (regmove_time
, regmove_optimize (insns
, max_reg_num (),
3674 close_dump_file (print_rtl_with_bb
, insns
);
3677 /* Print function header into sched dump now
3678 because doing the sched analysis makes some of the dump. */
3680 if (optimize
> 0 && flag_schedule_insns
)
3683 open_dump_file (".sched", decl_printable_name (decl
, 2));
3685 /* Do control and data sched analysis,
3686 and write some of the results to dump file. */
3688 TIMEVAR (sched_time
, schedule_insns (rtl_dump_file
));
3690 /* Dump rtl after instruction scheduling. */
3693 close_dump_file (print_rtl_with_bb
, insns
);
3696 /* Unless we did stupid register allocation,
3697 allocate pseudo-regs that are used only within 1 basic block. */
3700 TIMEVAR (local_alloc_time
,
3702 recompute_reg_usage (insns
);
3703 regclass (insns
, max_reg_num ());
3707 /* Dump rtl code after allocating regs within basic blocks. */
3711 open_dump_file (".lreg", decl_printable_name (decl
, 2));
3713 TIMEVAR (dump_time
, dump_flow_info (rtl_dump_file
));
3714 TIMEVAR (dump_time
, dump_local_alloc (rtl_dump_file
));
3716 close_dump_file (print_rtl_with_bb
, insns
);
3719 if (global_reg_dump
)
3720 open_dump_file (".greg", decl_printable_name (decl
, 2));
3722 /* Save the last label number used so far, so reorg can tell
3723 when it's safe to kill spill regs. */
3724 max_label_num_after_reload
= max_label_num ();
3726 /* Unless we did stupid register allocation,
3727 allocate remaining pseudo-regs, then do the reload pass
3728 fixing up any insns that are invalid. */
3730 TIMEVAR (global_alloc_time
,
3733 failure
= global_alloc (rtl_dump_file
);
3735 failure
= reload (insns
, 0, rtl_dump_file
);
3740 goto exit_rest_of_compilation
;
3742 reload_completed
= 1;
3744 /* Do a very simple CSE pass over just the hard registers. */
3746 reload_cse_regs (insns
);
3748 /* On some machines, the prologue and epilogue code, or parts thereof,
3749 can be represented as RTL. Doing so lets us schedule insns between
3750 it and the rest of the code and also allows delayed branch
3751 scheduling to operate in the epilogue. */
3753 thread_prologue_and_epilogue_insns (insns
);
3755 if (global_reg_dump
)
3757 TIMEVAR (dump_time
, dump_global_regs (rtl_dump_file
));
3758 close_dump_file (print_rtl_with_bb
, insns
);
3760 if (optimize
> 0 && flag_schedule_insns_after_reload
)
3763 open_dump_file (".sched2", decl_printable_name (decl
, 2));
3765 /* Do control and data sched analysis again,
3766 and write some more of the results to dump file. */
3768 TIMEVAR (sched2_time
, schedule_insns (rtl_dump_file
));
3770 /* Dump rtl after post-reorder instruction scheduling. */
3773 close_dump_file (print_rtl_with_bb
, insns
);
3776 #ifdef LEAF_REGISTERS
3778 if (optimize
> 0 && only_leaf_regs_used () && leaf_function_p ())
3782 /* One more attempt to remove jumps to .+1
3783 left by dead-store-elimination.
3784 Also do cross-jumping this time
3785 and delete no-op move insns. */
3789 TIMEVAR (jump_time
, jump_optimize (insns
, JUMP_CROSS_JUMP
,
3791 !JUMP_AFTER_REGSCAN
));
3793 /* Dump rtl code after jump, if we are doing that. */
3796 dump_rtl (".jump2", decl
, print_rtl_with_bb
, insns
);
3799 /* If a machine dependent reorganization is needed, call it. */
3800 #ifdef MACHINE_DEPENDENT_REORG
3801 MACHINE_DEPENDENT_REORG (insns
);
3803 if (mach_dep_reorg_dump
)
3804 dump_rtl (".mach", decl
, print_rtl_with_bb
, insns
);
3807 /* If a scheduling pass for delayed branches is to be done,
3808 call the scheduling code. */
3811 if (optimize
> 0 && flag_delayed_branch
)
3813 TIMEVAR (dbr_sched_time
, dbr_schedule (insns
, rtl_dump_file
));
3816 dump_rtl (".dbr", decl
, print_rtl_with_bb
, insns
);
3820 /* Shorten branches. */
3821 TIMEVAR (shorten_branch_time
,
3823 shorten_branches (get_insns ());
3828 open_dump_file (".stack", decl_printable_name (decl
, 2));
3830 TIMEVAR (stack_reg_time
, reg_to_stack (insns
, rtl_dump_file
));
3833 dump_rtl (".stack", decl
, print_rtl_with_bb
, insns
);
3836 /* Now turn the rtl into assembler code. */
3838 TIMEVAR (final_time
,
3843 /* Get the function's name, as described by its RTL.
3844 This may be different from the DECL_NAME name used
3845 in the source file. */
3847 x
= DECL_RTL (decl
);
3848 if (GET_CODE (x
) != MEM
)
3851 if (GET_CODE (x
) != SYMBOL_REF
)
3853 fnname
= XSTR (x
, 0);
3855 assemble_start_function (decl
, fnname
);
3856 final_start_function (insns
, asm_out_file
, optimize
);
3857 final (insns
, asm_out_file
, optimize
, 0);
3858 final_end_function (insns
, asm_out_file
, optimize
);
3859 assemble_end_function (decl
, fnname
);
3861 fflush (asm_out_file
);
3863 /* Release all memory held by regsets now */
3864 regset_release_memory ();
3867 /* Write DBX symbols if requested */
3869 /* Note that for those inline functions where we don't initially
3870 know for certain that we will be generating an out-of-line copy,
3871 the first invocation of this routine (rest_of_compilation) will
3872 skip over this code by doing a `goto exit_rest_of_compilation;'.
3873 Later on, finish_compilation will call rest_of_compilation again
3874 for those inline functions that need to have out-of-line copies
3875 generated. During that call, we *will* be routed past here. */
3877 #ifdef DBX_DEBUGGING_INFO
3878 if (write_symbols
== DBX_DEBUG
)
3879 TIMEVAR (symout_time
, dbxout_function (decl
));
3882 #ifdef DWARF_DEBUGGING_INFO
3883 if (write_symbols
== DWARF_DEBUG
)
3884 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
3887 #ifdef DWARF2_DEBUGGING_INFO
3888 if (write_symbols
== DWARF2_DEBUG
)
3889 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
3892 exit_rest_of_compilation
:
3894 /* In case the function was not output,
3895 don't leave any temporary anonymous types
3896 queued up for sdb output. */
3897 #ifdef SDB_DEBUGGING_INFO
3898 if (write_symbols
== SDB_DEBUG
)
3899 sdbout_types (NULL_TREE
);
3902 /* Put back the tree of subblocks and list of arguments
3903 from before we copied them.
3904 Code generation and the output of debugging info may have modified
3905 the copy, but the original is unchanged. */
3907 if (saved_block_tree
!= 0)
3909 DECL_INITIAL (decl
) = saved_block_tree
;
3910 DECL_ARGUMENTS (decl
) = saved_arguments
;
3911 DECL_ABSTRACT_ORIGIN (decl
) = NULL_TREE
;
3914 reload_completed
= 0;
3916 TIMEVAR (final_time
,
3918 /* Clear out the insn_length contents now that they are no
3920 init_insn_lengths ();
3922 /* Clear out the real_constant_chain before some of the rtx's
3923 it runs through become garbage. */
3924 clear_const_double_mem ();
3926 /* Cancel the effect of rtl_in_current_obstack. */
3927 resume_temporary_allocation ();
3929 /* Show no temporary slots allocated. */
3933 /* Make sure volatile mem refs aren't considered valid operands for
3934 arithmetic insns. We must call this here if this is a nested inline
3935 function, since the above code leaves us in the init_recog state
3936 (from final.c), and the function context push/pop code does not
3937 save/restore volatile_ok.
3939 ??? Maybe it isn't necessary for expand_start_function to call this
3940 anymore if we do it here? */
3942 init_recog_no_volatile ();
3944 /* The parsing time is all the time spent in yyparse
3945 *except* what is spent in this function. */
3947 parse_time
-= get_run_time () - start_time
;
3958 printf ("Usage: %s input [switches]\n", progname
);
3959 printf ("Switches:\n");
3961 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
3962 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
3963 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
3965 for (i
= NUM_ELEM (f_options
); i
--;)
3967 char * description
= f_options
[i
].description
;
3969 if (description
!= NULL
&& * description
!= 0)
3970 printf (" -f%-21s %s\n",
3971 f_options
[i
].string
, description
);
3974 printf (" -O[number] Set optimisation level to [number]\n");
3975 printf (" -Os Optimise for space rather than speed\n");
3976 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
3977 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
3978 printf (" -w Suppress warnings\n");
3979 printf (" -W Enable extra warnings\n");
3981 for (i
= NUM_ELEM (W_options
); i
--;)
3983 char * description
= W_options
[i
].description
;
3985 if (description
!= NULL
&& * description
!= 0)
3986 printf (" -W%-21s %s\n",
3987 W_options
[i
].string
, description
);
3990 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
3991 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
3992 printf (" -p Enable function profiling\n");
3993 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3994 printf (" -a Enable block profiling \n");
3996 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3997 printf (" -ax Enable jump profiling \n");
3999 printf (" -o <file> Place output into <file> \n");
4000 printf (" -G <number> Put global and static data smaller than <number>\n");
4001 printf (" bytes into a special section (on some targets)\n");
4003 for (i
= NUM_ELEM (debug_args
); i
--;)
4005 if (debug_args
[i
].description
!= NULL
)
4006 printf (" -%-22s %s\n", debug_args
[i
].arg
, debug_args
[i
].description
);
4009 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4010 printf (" -quiet Do not display functions compiled or elapsed time\n");
4011 printf (" -version Display the compiler's version\n");
4012 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4013 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4014 #if defined HAIFA || defined INSN_SCHEDULING
4015 printf (" -sched-verbose-<number> Set the verbosity level of the scheduler\n");
4017 printf (" --help Display this information\n");
4022 /* Display descriptions of language specific options.
4023 If there is no description, note that there is an undocumented option.
4024 If the description is empty, do not display anything. (This allows
4025 options to be deliberately undocumented, for whatever reason).
4026 If the option string is missing, then this is a marker, indicating
4027 that the description string is in fact the name of a language, whoes
4028 language specific options are to follow. */
4030 if (NUM_ELEM (documented_lang_options
) > 1)
4032 printf ("\nLanguage specific options:\n");
4034 for (i
= 0; i
< NUM_ELEM (documented_lang_options
); i
++)
4036 char * description
= documented_lang_options
[i
].description
;
4037 char * option
= documented_lang_options
[i
].option
;
4039 if (description
== NULL
)
4041 else if (* description
== 0)
4043 else if (option
== NULL
)
4047 ("\nThere are undocumented %s specific options as well.\n",
4051 printf ("\n Options for %s:\n", description
);
4056 printf (" %-23.23s %s\n", option
, description
);
4061 printf ("\nThere are undocumented %s specific options as well.\n", lang
);
4063 if (NUM_ELEM (target_switches
) > 1
4064 #ifdef TARGET_OPTIONS
4065 || NUM_ELEM (target_options
) > 1
4073 printf ("\nTarget specific options:\n");
4075 for (i
= NUM_ELEM (target_switches
); i
--;)
4077 char * option
= target_switches
[i
].name
;
4078 char * description
= target_switches
[i
].description
;
4082 else if (description
== NULL
)
4084 else if (* description
!= 0)
4085 doc
+= printf (" %-23.23s %s\n", option
, description
);
4088 #ifdef TARGET_OPTIONS
4089 for (i
= NUM_ELEM (target_options
); i
--;)
4091 char * option
= target_options
[i
].prefix
;
4092 char * description
= target_options
[i
].description
;
4096 else if (description
== NULL
)
4098 else if (* description
!= 0)
4099 doc
+= printf (" %-23.23s %s\n", option
, description
);
4105 printf ("\nThere are undocumented target specific options as well.\n");
4107 printf (" They exist, but they are not documented.\n");
4112 /* Compare the user specified 'option' with the language
4113 specific 'lang_option'. Return true if they match, or
4114 if 'option' is a viable prefix of 'lang_option'. */
4117 check_lang_option (option
, lang_option
)
4121 lang_independent_options
* indep_options
;
4125 /* Ignore NULL entries. */
4126 if (option
== NULL
|| lang_option
== NULL
)
4129 len
= strlen (lang_option
);
4131 /* If they do not match to the first n characters then fail. */
4132 if (strncmp (option
, lang_option
, len
) != 0)
4135 /* Do not accept a lang option, if it matches a normal -f or -W
4136 option. Chill defines a -fpack, but we want to support
4139 /* An exact match is OK */
4140 if (strlen (option
) == len
)
4143 /* If it is not an -f or -W option allow the match */
4144 if (option
[0] != '-')
4149 case 'f': indep_options
= f_options
; break;
4150 case 'W': indep_options
= W_options
; break;
4154 /* The option is a -f or -W option.
4155 Skip past the prefix and search for the remainder in the
4156 appropriate table of options. */
4159 if (option
[0] == 'n' && option
[1] == 'o' && option
[2] == '-')
4162 for (k
= NUM_ELEM (indep_options
); k
--;)
4164 if (!strcmp (option
, indep_options
[k
].string
))
4166 /* The option matched a language independent option,
4167 do not allow the language specific match. */
4173 /* The option matches the start of the langauge specific option
4174 and it is not an exact match for a language independent option. */
4178 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4179 Exit code is 35 if can't open files, 34 if fatal error,
4180 33 if had nonfatal errors, else success. */
4189 int flag_print_mem
= 0;
4190 int version_flag
= 0;
4193 /* save in case md file wants to emit args as a comment. */
4197 p
= argv
[0] + strlen (argv
[0]);
4198 while (p
!= argv
[0] && p
[-1] != '/'
4199 #ifdef DIR_SEPARATOR
4200 && p
[-1] != DIR_SEPARATOR
4206 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
4207 /* Get rid of any avoidable limit on stack size. */
4211 /* Set the stack limit huge so that alloca does not fail. */
4212 getrlimit (RLIMIT_STACK
, &rlim
);
4213 rlim
.rlim_cur
= rlim
.rlim_max
;
4214 setrlimit (RLIMIT_STACK
, &rlim
);
4218 signal (SIGFPE
, float_signal
);
4221 signal (SIGPIPE
, pipe_closed
);
4224 decl_printable_name
= decl_name
;
4225 lang_expand_expr
= (lang_expand_expr_t
) do_abort
;
4227 /* Initialize whether `char' is signed. */
4228 flag_signed_char
= DEFAULT_SIGNED_CHAR
;
4229 #ifdef DEFAULT_SHORT_ENUMS
4230 /* Initialize how much space enums occupy, by default. */
4231 flag_short_enums
= DEFAULT_SHORT_ENUMS
;
4234 /* Perform language-specific options intialization. */
4235 lang_init_options ();
4237 /* Scan to see what optimization level has been specified. That will
4238 determine the default value of many flags. */
4239 for (i
= 1; i
< argc
; i
++)
4241 if (!strcmp (argv
[i
], "-O"))
4245 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'O')
4247 /* Handle -Os, -O2, -O3, -O69, ... */
4248 char *p
= &argv
[i
][2];
4251 if ((p
[0] == 's') && (p
[1] == 0))
4256 if (! (c
>= '0' && c
<= '9'))
4259 optimize
= atoi (&argv
[i
][2]);
4264 /* Optimizing for size forces optimize to be no less than 2. */
4265 if (optimize_size
&& (optimize
< 2))
4268 obey_regdecls
= (optimize
== 0);
4273 flag_thread_jumps
= 1;
4275 flag_delayed_branch
= 1;
4277 #ifdef CAN_DEBUG_WITHOUT_FP
4278 flag_omit_frame_pointer
= 1;
4284 flag_cse_follow_jumps
= 1;
4285 flag_cse_skip_blocks
= 1;
4287 flag_expensive_optimizations
= 1;
4288 flag_strength_reduce
= 1;
4289 flag_rerun_cse_after_loop
= 1;
4290 flag_rerun_loop_opt
= 1;
4291 flag_caller_saves
= 1;
4293 #ifdef INSN_SCHEDULING
4294 flag_schedule_insns
= 1;
4295 flag_schedule_insns_after_reload
= 1;
4298 flag_strict_aliasing
= 1;
4303 flag_inline_functions
= 1;
4306 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4309 set_target_switch ("");
4311 #ifdef OPTIMIZATION_OPTIONS
4312 /* Allow default optimizations to be specified on a per-machine basis. */
4313 OPTIMIZATION_OPTIONS (optimize
, optimize_size
);
4316 /* Initialize register usage now so switches may override. */
4319 for (i
= 1; i
< argc
; i
++)
4323 /* If this is a language-specific option,
4324 decode it in a language-specific way. */
4325 for (j
= NUM_ELEM (documented_lang_options
); j
--;)
4326 if (check_lang_option (argv
[i
], documented_lang_options
[j
].option
))
4329 if (j
!= (size_t)-1)
4331 /* If the option is valid for *some* language,
4332 treat it as valid even if this language doesn't understand it. */
4333 int strings_processed
= lang_decode_option (argc
- i
, argv
+ i
);
4335 if (!strcmp (argv
[i
], "--help"))
4341 if (strings_processed
!= 0)
4342 i
+= strings_processed
- 1;
4344 else if (argv
[i
][0] == '-' && argv
[i
][1] != 0)
4346 register char *str
= argv
[i
] + 1;
4351 set_target_switch (&str
[1]);
4352 else if (!strcmp (str
, "dumpbase"))
4354 dump_base_name
= argv
[++i
];
4356 else if (str
[0] == 'd')
4358 register char *p
= &str
[1];
4363 branch_prob_dump
= 1;
4369 global_reg_dump
= 1;
4377 cse_dump
= 1, cse2_dump
= 1;
4384 #ifdef MACHINE_DEPENDENT_REORG
4385 mach_dep_reorg_dump
= 1;
4392 branch_prob_dump
= 1;
4409 global_reg_dump
= 1;
4434 #ifdef MACHINE_DEPENDENT_REORG
4436 mach_dep_reorg_dump
= 1;
4440 flag_print_asm_name
= 1;
4464 rtl_dump_and_exit
= 1;
4467 warning ("unrecognised gcc debugging option: %c", p
[-1]);
4471 else if (str
[0] == 'f')
4473 register char *p
= &str
[1];
4476 /* Some kind of -f option.
4477 P's value is the option sans `-f'.
4478 Search for it in the table of options. */
4481 !found
&& j
< sizeof (f_options
) / sizeof (f_options
[0]);
4484 if (!strcmp (p
, f_options
[j
].string
))
4486 *f_options
[j
].variable
= f_options
[j
].on_value
;
4487 /* A goto here would be cleaner,
4488 but breaks the vax pcc. */
4491 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
4492 && ! strcmp (p
+3, f_options
[j
].string
))
4494 *f_options
[j
].variable
= ! f_options
[j
].on_value
;
4502 #ifdef INSN_SCHEDULING
4503 else if (!strncmp (p
, "sched-verbose-",14))
4504 fix_sched_param("verbose",&p
[14]);
4507 else if (!strncmp (p
, "fixed-", 6))
4508 fix_register (&p
[6], 1, 1);
4509 else if (!strncmp (p
, "call-used-", 10))
4510 fix_register (&p
[10], 0, 1);
4511 else if (!strncmp (p
, "call-saved-", 11))
4512 fix_register (&p
[11], 0, 0);
4514 error ("Invalid option `%s'", argv
[i
]);
4516 else if (str
[0] == 'O')
4518 register char *p
= str
+1;
4522 while (*p
&& *p
>= '0' && *p
<= '9')
4527 error ("Invalid option `%s'", argv
[i
]);
4529 else if (!strcmp (str
, "pedantic"))
4531 else if (!strcmp (str
, "pedantic-errors"))
4532 flag_pedantic_errors
= pedantic
= 1;
4533 else if (!strcmp (str
, "quiet"))
4535 else if (!strcmp (str
, "version"))
4537 else if (!strcmp (str
, "w"))
4538 inhibit_warnings
= 1;
4539 else if (!strcmp (str
, "W"))
4542 /* We save the value of warn_uninitialized, since if they put
4543 -Wuninitialized on the command line, we need to generate a
4544 warning about not using it without also specifying -O. */
4545 if (warn_uninitialized
!= 1)
4546 warn_uninitialized
= 2;
4548 else if (str
[0] == 'W')
4550 register char *p
= &str
[1];
4553 /* Some kind of -W option.
4554 P's value is the option sans `-W'.
4555 Search for it in the table of options. */
4558 !found
&& j
< sizeof (W_options
) / sizeof (W_options
[0]);
4561 if (!strcmp (p
, W_options
[j
].string
))
4563 *W_options
[j
].variable
= W_options
[j
].on_value
;
4564 /* A goto here would be cleaner,
4565 but breaks the vax pcc. */
4568 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
4569 && ! strcmp (p
+3, W_options
[j
].string
))
4571 *W_options
[j
].variable
= ! W_options
[j
].on_value
;
4578 else if (!strncmp (p
, "id-clash-", 9))
4584 if (*endp
>= '0' && *endp
<= '9')
4588 error ("Invalid option `%s'", argv
[i
]);
4593 id_clash_len
= atoi (str
+ 10);
4596 else if (!strncmp (p
, "larger-than-", 12))
4598 char *endp
= p
+ 12;
4602 if (*endp
>= '0' && *endp
<= '9')
4606 error ("Invalid option `%s'", argv
[i
]);
4607 goto larger_than_lose
;
4610 warn_larger_than
= 1;
4611 larger_than_size
= atoi (str
+ 13);
4615 error ("Invalid option `%s'", argv
[i
]);
4617 else if (!strcmp (str
, "p"))
4621 else if (!strcmp (str
, "a"))
4623 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4624 warning ("`-a' option (basic block profile) not supported");
4626 profile_block_flag
= (profile_block_flag
< 2) ? 1 : 3;
4629 else if (!strcmp (str
, "ax"))
4631 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4632 warning ("`-ax' option (jump profiling) not supported");
4634 profile_block_flag
= (!profile_block_flag
4635 || profile_block_flag
== 2) ? 2 : 3;
4638 else if (str
[0] == 'g')
4642 /* A lot of code assumes write_symbols == NO_DEBUG if the
4643 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4644 of what debugging type has been selected). This records the
4645 selected type. It is an error to specify more than one
4647 static enum debug_info_type selected_debug_type
= NO_DEBUG
;
4648 /* Non-zero if debugging format has been explicitly set.
4649 -g and -ggdb don't explicitly set the debugging format so
4650 -gdwarf -g3 is equivalent to -gdwarf3. */
4651 static int type_explicitly_set_p
= 0;
4652 /* Indexed by enum debug_info_type. */
4653 static char *debug_type_names
[] =
4655 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4658 /* Look up STR in the table. */
4659 for (da
= debug_args
; da
->arg
; da
++)
4661 if (! strncmp (str
, da
->arg
, strlen (da
->arg
)))
4663 enum debug_info_type type
= da
->debug_type
;
4666 p
= str
+ strlen (da
->arg
);
4667 if (*p
&& (*p
< '0' || *p
> '9'))
4671 while (*q
&& (*q
>= '0' && *q
<= '9'))
4676 if (len
> 1 && !strncmp (str
, "gdwarf", len
))
4678 error ("use -gdwarf -g%d for DWARF v1, level %d",
4681 error ("use -gdwarf-2 for DWARF v2");
4685 level
= 2; /* default debugging info level */
4686 if (*q
|| level
> 3)
4688 warning ("invalid debug level specification in option: `-%s'",
4690 /* ??? This error message is incorrect in the case of
4692 warning ("no debugging information will be generated");
4696 if (type
== NO_DEBUG
)
4698 type
= PREFERRED_DEBUGGING_TYPE
;
4699 if (len
> 1 && strncmp (str
, "ggdb", len
) == 0)
4701 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4702 type
= DWARF2_DEBUG
;
4704 #ifdef DBX_DEBUGGING_INFO
4711 if (type
== NO_DEBUG
)
4712 warning ("`-%s' not supported by this configuration of GCC",
4715 /* Does it conflict with an already selected type? */
4716 if (type_explicitly_set_p
4717 /* -g/-ggdb don't conflict with anything */
4718 && da
->debug_type
!= NO_DEBUG
4719 && type
!= selected_debug_type
)
4720 warning ("`-%s' ignored, conflicts with `-g%s'",
4721 str
, debug_type_names
[(int) selected_debug_type
]);
4724 /* If the format has already been set, -g/-ggdb
4725 only change the debug level. */
4726 if (type_explicitly_set_p
4727 && da
->debug_type
== NO_DEBUG
)
4728 ; /* don't change debugging type */
4731 selected_debug_type
= type
;
4732 type_explicitly_set_p
= da
->debug_type
!= NO_DEBUG
;
4734 write_symbols
= (level
== 0
4736 : selected_debug_type
);
4737 use_gnu_debug_info_extensions
= da
->use_extensions_p
;
4738 debug_info_level
= (enum debug_info_level
) level
;
4744 warning ("`-%s' not supported by this configuration of GCC",
4747 else if (!strcmp (str
, "o"))
4749 asm_file_name
= argv
[++i
];
4751 else if (str
[0] == 'G')
4753 g_switch_set
= TRUE
;
4754 g_switch_value
= atoi ((str
[1] != '\0') ? str
+1 : argv
[++i
]);
4756 else if (!strncmp (str
, "aux-info", 8))
4758 flag_gen_aux_info
= 1;
4759 aux_info_file_name
= (str
[8] != '\0' ? str
+8 : argv
[++i
]);
4761 else if (!strcmp (str
, "-help"))
4767 error ("Invalid option `%s'", argv
[i
]);
4769 else if (argv
[i
][0] == '+')
4770 error ("Invalid option `%s'", argv
[i
]);
4775 /* Checker uses the frame pointer. */
4776 if (flag_check_memory_usage
)
4777 flag_omit_frame_pointer
= 0;
4781 /* Inlining does not work if not optimizing,
4782 so force it not to be done. */
4786 /* The c_decode_option and lang_decode_option functions set
4787 this to `2' if -Wall is used, so we can avoid giving out
4788 lots of errors for people who don't realize what -Wall does. */
4789 if (warn_uninitialized
== 1)
4790 warning ("-Wuninitialized is not supported without -O");
4793 #ifdef OVERRIDE_OPTIONS
4794 /* Some machines may reject certain combinations of options. */
4798 if (exceptions_via_longjmp
== 2)
4800 #ifdef DWARF2_UNWIND_INFO
4801 exceptions_via_longjmp
= ! DWARF2_UNWIND_INFO
;
4803 exceptions_via_longjmp
= 1;
4807 if (profile_block_flag
== 3)
4809 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4810 profile_block_flag
= 2;
4813 /* Unrolling all loops implies that standard loop unrolling must also
4815 if (flag_unroll_all_loops
)
4816 flag_unroll_loops
= 1;
4817 /* Loop unrolling requires that strength_reduction be on also. Silently
4818 turn on strength reduction here if it isn't already on. Also, the loop
4819 unrolling code assumes that cse will be run after loop, so that must
4820 be turned on also. */
4821 if (flag_unroll_loops
)
4823 flag_strength_reduce
= 1;
4824 flag_rerun_cse_after_loop
= 1;
4827 /* Warn about options that are not supported on this machine. */
4828 #ifndef INSN_SCHEDULING
4829 if (flag_schedule_insns
|| flag_schedule_insns_after_reload
)
4830 warning ("instruction scheduling not supported on this target machine");
4833 if (flag_delayed_branch
)
4834 warning ("this target machine does not have delayed branches");
4837 /* If we are in verbose mode, write out the version and maybe all the
4838 option flags in use. */
4841 print_version (stderr
, "");
4843 print_switch_values (stderr
, 0, MAX_LINE
, "", " ", "\n");
4846 compile_file (filename
);
4848 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4851 char *lim
= (char *) sbrk (0);
4853 fprintf (stderr
, "Data size %ld.\n", (long)(lim
- (char *) &environ
));
4858 system ("ps -l 1>&2");
4861 #endif /* not USG */
4864 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4867 exit (FATAL_EXIT_CODE
);
4869 exit (FATAL_EXIT_CODE
);
4870 exit (SUCCESS_EXIT_CODE
);
4874 /* Decode -m switches. */
4875 /* Decode the switch -mNAME. */
4878 set_target_switch (name
)
4884 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
4885 if (!strcmp (target_switches
[j
].name
, name
))
4887 if (target_switches
[j
].value
< 0)
4888 target_flags
&= ~-target_switches
[j
].value
;
4890 target_flags
|= target_switches
[j
].value
;
4894 #ifdef TARGET_OPTIONS
4896 for (j
= 0; j
< sizeof target_options
/ sizeof target_options
[0]; j
++)
4898 int len
= strlen (target_options
[j
].prefix
);
4899 if (!strncmp (target_options
[j
].prefix
, name
, len
))
4901 *target_options
[j
].variable
= name
+ len
;
4908 error ("Invalid option `%s'", name
);
4911 /* Print version information to FILE.
4912 Each line begins with INDENT (for the case where FILE is the
4913 assembler output file). */
4916 print_version (file
, indent
)
4920 fprintf (file
, "%s%s%s version %s", indent
, *indent
!= 0 ? " " : "",
4921 language_string
, version_string
);
4922 fprintf (file
, " (%s)", TARGET_NAME
);
4925 #define __VERSION__ "[unknown]"
4927 fprintf (file
, " compiled by GNU C version %s.\n", __VERSION__
);
4929 fprintf (file
, " compiled by CC.\n");
4933 /* Print an option value and return the adjusted position in the line.
4934 ??? We don't handle error returns from fprintf (disk full); presumably
4935 other code will catch a disk full though. */
4938 print_single_switch (file
, pos
, max
, indent
, sep
, term
, type
, name
)
4941 char *indent
, *sep
, *term
, *type
, *name
;
4943 /* The ultrix fprintf returns 0 on success, so compute the result we want
4944 here since we need it for the following test. */
4945 int len
= strlen (sep
) + strlen (type
) + strlen (name
);
4950 fprintf (file
, "%s", term
);
4955 fprintf (file
, "%s", indent
);
4956 pos
= strlen (indent
);
4958 fprintf (file
, "%s%s%s", sep
, type
, name
);
4963 /* Print active target switches to FILE.
4964 POS is the current cursor position and MAX is the size of a "line".
4965 Each line begins with INDENT and ends with TERM.
4966 Each switch is separated from the next by SEP. */
4969 print_switch_values (file
, pos
, max
, indent
, sep
, term
)
4972 char *indent
, *sep
, *term
;
4977 /* Print the options as passed. */
4979 pos
= print_single_switch (file
, pos
, max
, indent
, *indent
? " " : "", term
,
4980 "options passed: ", "");
4982 for (p
= &save_argv
[1]; *p
!= NULL
; p
++)
4986 if (strcmp (*p
, "-o") == 0)
4992 if (strcmp (*p
, "-quiet") == 0)
4994 if (strcmp (*p
, "-version") == 0)
4999 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
, *p
, "");
5002 fprintf (file
, "%s", term
);
5004 /* Print the -f and -m options that have been enabled.
5005 We don't handle language specific options but printing argv
5008 pos
= print_single_switch (file
, 0, max
, indent
, *indent
? " " : "", term
,
5009 "options enabled: ", "");
5011 for (j
= 0; j
< sizeof f_options
/ sizeof f_options
[0]; j
++)
5012 if (*f_options
[j
].variable
== f_options
[j
].on_value
)
5013 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5014 "-f", f_options
[j
].string
);
5016 /* Print target specific options. */
5018 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
5019 if (target_switches
[j
].name
[0] != '\0'
5020 && target_switches
[j
].value
> 0
5021 && ((target_switches
[j
].value
& target_flags
)
5022 == target_switches
[j
].value
))
5024 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5025 "-m", target_switches
[j
].name
);
5028 #ifdef TARGET_OPTIONS
5029 for (j
= 0; j
< sizeof target_options
/ sizeof target_options
[0]; j
++)
5030 if (*target_options
[j
].variable
!= NULL
)
5033 sprintf (prefix
, "-m%s", target_options
[j
].prefix
);
5034 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5035 prefix
, *target_options
[j
].variable
);
5039 fprintf (file
, "%s", term
);
5042 /* Record the beginning of a new source file, named FILENAME. */
5045 debug_start_source_file (filename
)
5046 register char *filename
;
5048 #ifdef DBX_DEBUGGING_INFO
5049 if (write_symbols
== DBX_DEBUG
)
5050 dbxout_start_new_source_file (filename
);
5052 #ifdef DWARF_DEBUGGING_INFO
5053 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5054 && write_symbols
== DWARF_DEBUG
)
5055 dwarfout_start_new_source_file (filename
);
5056 #endif /* DWARF_DEBUGGING_INFO */
5057 #ifdef DWARF2_DEBUGGING_INFO
5058 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5059 && write_symbols
== DWARF2_DEBUG
)
5060 dwarf2out_start_source_file (filename
);
5061 #endif /* DWARF2_DEBUGGING_INFO */
5062 #ifdef SDB_DEBUGGING_INFO
5063 if (write_symbols
== SDB_DEBUG
)
5064 sdbout_start_new_source_file (filename
);
5068 /* Record the resumption of a source file. LINENO is the line number in
5069 the source file we are returning to. */
5072 debug_end_source_file (lineno
)
5073 register unsigned lineno
;
5075 #ifdef DBX_DEBUGGING_INFO
5076 if (write_symbols
== DBX_DEBUG
)
5077 dbxout_resume_previous_source_file ();
5079 #ifdef DWARF_DEBUGGING_INFO
5080 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5081 && write_symbols
== DWARF_DEBUG
)
5082 dwarfout_resume_previous_source_file (lineno
);
5083 #endif /* DWARF_DEBUGGING_INFO */
5084 #ifdef DWARF2_DEBUGGING_INFO
5085 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5086 && write_symbols
== DWARF2_DEBUG
)
5087 dwarf2out_end_source_file ();
5088 #endif /* DWARF2_DEBUGGING_INFO */
5089 #ifdef SDB_DEBUGGING_INFO
5090 if (write_symbols
== SDB_DEBUG
)
5091 sdbout_resume_previous_source_file ();
5095 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5096 the tail part of the directive line, i.e. the part which is past the
5097 initial whitespace, #, whitespace, directive-name, whitespace part. */
5100 debug_define (lineno
, buffer
)
5101 register unsigned lineno
;
5102 register char *buffer
;
5104 #ifdef DWARF_DEBUGGING_INFO
5105 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5106 && write_symbols
== DWARF_DEBUG
)
5107 dwarfout_define (lineno
, buffer
);
5108 #endif /* DWARF_DEBUGGING_INFO */
5109 #ifdef DWARF2_DEBUGGING_INFO
5110 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5111 && write_symbols
== DWARF2_DEBUG
)
5112 dwarf2out_define (lineno
, buffer
);
5113 #endif /* DWARF2_DEBUGGING_INFO */
5116 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5117 the tail part of the directive line, i.e. the part which is past the
5118 initial whitespace, #, whitespace, directive-name, whitespace part. */
5121 debug_undef (lineno
, buffer
)
5122 register unsigned lineno
;
5123 register char *buffer
;
5125 #ifdef DWARF_DEBUGGING_INFO
5126 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5127 && write_symbols
== DWARF_DEBUG
)
5128 dwarfout_undef (lineno
, buffer
);
5129 #endif /* DWARF_DEBUGGING_INFO */
5130 #ifdef DWARF2_DEBUGGING_INFO
5131 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5132 && write_symbols
== DWARF2_DEBUG
)
5133 dwarf2out_undef (lineno
, buffer
);
5134 #endif /* DWARF2_DEBUGGING_INFO */