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. */
32 #undef FLOAT /* This is for hpux. They should change hpux. */
33 #undef FFS /* Some systems define this in param.h. */
39 #ifdef HAVE_SYS_RESOURCE_H
40 # include <sys/resource.h>
43 #ifdef HAVE_SYS_TIMES_H
44 # include <sys/times.h>
51 #include "insn-attr.h"
52 #include "insn-codes.h"
53 #include "insn-config.h"
60 #ifdef DWARF_DEBUGGING_INFO
64 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
65 #include "dwarf2out.h"
68 #ifdef DBX_DEBUGGING_INFO
72 #ifdef SDB_DEBUGGING_INFO
76 #ifdef XCOFF_DEBUGGING_INFO
81 /* The extra parameters substantially improve the I/O performance. */
83 vms_fopen (fname, type)
87 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
88 fixed arguments, which matches ANSI's specification but not VAXCRTL's
89 pre-ANSI implementation. This hack circumvents the mismatch problem. */
90 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
93 return (*vmslib_fopen) (fname, type, "mbc=32",
94 "deq=64", "fop=tef", "shr=nil");
96 return (*vmslib_fopen) (fname, type, "mbc=32");
98 #define fopen vms_fopen
101 #ifndef DEFAULT_GDB_EXTENSIONS
102 #define DEFAULT_GDB_EXTENSIONS 1
105 /* If more than one debugging type is supported, you must define
106 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
108 This is one long line cause VAXC can't handle a \-newline. */
109 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
110 #ifndef PREFERRED_DEBUGGING_TYPE
111 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
112 #endif /* no PREFERRED_DEBUGGING_TYPE */
113 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
114 so the following code needn't care. */
115 #ifdef DBX_DEBUGGING_INFO
116 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
118 #ifdef SDB_DEBUGGING_INFO
119 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
121 #ifdef DWARF_DEBUGGING_INFO
122 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
124 #ifdef DWARF2_DEBUGGING_INFO
125 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
127 #ifdef XCOFF_DEBUGGING_INFO
128 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
130 #endif /* More than one debugger format enabled. */
132 /* If still not defined, must have been because no debugging formats
134 #ifndef PREFERRED_DEBUGGING_TYPE
135 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
138 extern int rtx_equal_function_value_matters;
140 #if ! (defined (VMS) || defined (OS2))
141 extern char **environ;
143 extern char *version_string, *language_string;
145 /* Carry information from ASM_DECLARE_OBJECT_NAME
146 to ASM_FINISH_DECLARE_OBJECT. */
148 extern int size_directive_output;
149 extern tree last_assemble_variable_decl;
151 extern char *init_parse PVPROTO((char *));
152 extern void finish_parse ();
153 extern void init_decl_processing ();
154 extern void init_obstacks ();
155 extern void init_tree_codes ();
156 extern void init_rtl ();
157 extern void init_regs ();
158 extern void init_optabs ();
159 extern void init_stmt ();
160 extern void init_reg_sets ();
161 extern void dump_flow_info ();
162 extern void dump_sched_info ();
163 extern void dump_local_alloc ();
164 extern void regset_release_memory ();
166 extern void print_rtl ();
167 extern void print_rtl_with_bb ();
169 void rest_of_decl_compilation ();
170 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
171 void error_with_decl PVPROTO((tree decl, char *s, ...));
172 void error PVPROTO((char *s, ...));
173 void fatal PVPROTO((char *s, ...));
174 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
175 void warning_with_decl PVPROTO((tree decl, char *s, ...));
176 void warning PVPROTO((char *s, ...));
177 void pedwarn PVPROTO((char *s, ...));
178 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
179 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
180 void sorry PVPROTO((char *s, ...));
181 void really_sorry PVPROTO((char *s, ...));
183 void set_target_switch ();
184 static char *decl_name PROTO((tree, int));
185 static void vmessage PROTO((char *, char *, va_list));
186 static void v_message_with_file_and_line PROTO((char *, int, char *,
188 static void v_message_with_decl PROTO((tree, char *, char *, va_list));
189 static void file_and_line_for_asm PROTO((rtx, char **, int *));
190 static void v_error_with_file_and_line PROTO((char *, int, char *, va_list));
191 static void v_error_with_decl PROTO((tree, char *, va_list));
192 static void v_error_for_asm PROTO((rtx, char *, va_list));
193 static void verror PROTO((char *, va_list));
194 static void vfatal PROTO((char *, va_list));
195 static void v_warning_with_file_and_line PROTO ((char *, int, char *, va_list));
196 static void v_warning_with_decl PROTO((tree, char *, va_list));
197 static void v_warning_for_asm PROTO((rtx, char *, va_list));
198 static void vwarning PROTO((char *, va_list));
199 static void vpedwarn PROTO((char *, va_list));
200 static void v_pedwarn_with_decl PROTO((tree, char *, va_list));
201 static void v_pedwarn_with_file_and_line PROTO((char *, int, char *, va_list));
202 static void vsorry PROTO((char *, va_list));
203 static void v_really_sorry PROTO((char *, va_list));
204 static void float_signal PROTO((int));
205 static void pipe_closed PROTO((int));
206 static void output_lang_identify PROTO((FILE *));
207 static void open_dump_file PROTO((char *, char *));
208 static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
209 static void dump_rtl PROTO((char *, tree, void (*) (FILE *, rtx), rtx));
210 static void clean_dump_file PROTO((char *));
211 static void compile_file PROTO((char *));
213 void print_version ();
214 int print_single_switch ();
215 void print_switch_values ();
216 /* Length of line when printing switch values. */
219 /* Name of program invoked, sans directories. */
223 /* Copy of arguments to main. */
227 /* Name of current original source file (what was input to cpp).
228 This comes from each #-command in the actual input. */
230 char *input_filename;
232 /* Name of top-level original source file (what was input to cpp).
233 This comes from the #-command at the beginning of the actual input.
234 If there isn't any there, then this is the cc1 input file name. */
236 char *main_input_filename;
238 /* Current line number in real source file. */
242 /* Stack of currently pending input files. */
244 struct file_stack *input_file_stack;
246 /* Incremented on each change to input_file_stack. */
247 int input_file_stack_tick;
249 /* FUNCTION_DECL for function now being parsed or compiled. */
251 extern tree current_function_decl;
253 /* Name to use as base of names for dump output files. */
255 char *dump_base_name;
257 /* Bit flags that specify the machine subtype we are compiling for.
258 Bits are tested using macros TARGET_... defined in the tm.h file
259 and set by `-m...' switches. Must be defined in rtlanal.c. */
261 extern int target_flags;
263 /* Flags saying which kinds of debugging dump have been requested. */
266 int rtl_dump_and_exit = 0;
267 int jump_opt_dump = 0;
268 int addressof_dump = 0;
273 int branch_prob_dump = 0;
275 int combine_dump = 0;
276 int regmove_dump = 0;
278 int local_reg_dump = 0;
279 int global_reg_dump = 0;
281 int jump2_opt_dump = 0;
283 int dbr_sched_dump = 0;
285 int flag_print_asm_name = 0;
287 int stack_reg_dump = 0;
289 #ifdef MACHINE_DEPENDENT_REORG
290 int mach_dep_reorg_dump = 0;
293 /* Name for output file of assembly code, specified with -o. */
297 /* Value of the -G xx switch, and whether it was passed or not. */
301 /* Type(s) of debugging information we are producing (if any).
302 See flags.h for the definitions of the different possible
303 types of debugging information. */
304 enum debug_info_type write_symbols = NO_DEBUG;
306 /* Level of debugging information we are producing. See flags.h
307 for the definitions of the different possible levels. */
308 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
310 /* Nonzero means use GNU-only extensions in the generated symbolic
311 debugging information. */
312 /* Currently, this only has an effect when write_symbols is set to
313 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
314 int use_gnu_debug_info_extensions = 0;
316 /* Nonzero means do optimizations. -O.
317 Particular numeric values stand for particular amounts of optimization;
318 thus, -O2 stores 2 here. However, the optimizations beyond the basic
319 ones are not controlled directly by this variable. Instead, they are
320 controlled by individual `flag_...' variables that are defaulted
321 based on this variable. */
325 /* Nonzero means optimize for size. -Os.
326 The only valid values are zero and non-zero. When optimize_size is
327 non-zero, optimize defaults to 2, but certain individual code
328 bloating optimizations are disabled. */
330 int optimize_size = 0;
332 /* Number of error messages and warning messages so far. */
335 int warningcount = 0;
338 /* Pointer to function to compute the name to use to print a declaration.
339 DECL is the declaration in question.
340 VERBOSITY determines what information will be printed:
341 0: DECL_NAME, demangled as necessary.
342 1: and scope information.
343 2: and any other information that might be interesting, such as function
344 parameter types in C++. */
346 char *(*decl_printable_name) (/* tree decl, int verbosity */);
348 /* Pointer to function to compute rtl for a language-specific tree code. */
350 struct rtx_def *(*lang_expand_expr) ();
352 /* Pointer to function to finish handling an incomplete decl at the
353 end of compilation. */
355 void (*incomplete_decl_finalize_hook) () = 0;
357 /* Highest label number used at the end of reload. */
359 int max_label_num_after_reload;
361 /* Nonzero if generating code to do profiling. */
363 int profile_flag = 0;
365 /* Nonzero if generating code to do profiling on a line-by-line basis. */
367 int profile_block_flag;
369 /* Nonzero if generating code to profile program flow graph arcs. */
371 int profile_arc_flag = 0;
373 /* Nonzero if generating info for gcov to calculate line test coverage. */
375 int flag_test_coverage = 0;
377 /* Nonzero indicates that branch taken probabilities should be calculated. */
379 int flag_branch_probabilities = 0;
381 /* Nonzero for -pedantic switch: warn about anything
382 that standard spec forbids. */
386 /* Temporarily suppress certain warnings.
387 This is set while reading code from a system header file. */
389 int in_system_header = 0;
391 /* Nonzero means do stupid register allocation.
392 Currently, this is 1 if `optimize' is 0. */
394 int obey_regdecls = 0;
396 /* Don't print functions as they are compiled and don't print
397 times taken by the various passes. -quiet. */
403 /* Nonzero means `char' should be signed. */
405 int flag_signed_char;
407 /* Nonzero means give an enum type only as many bytes as it needs. */
409 int flag_short_enums;
411 /* Nonzero for -fcaller-saves: allocate values in regs that need to
412 be saved across function calls, if that produces overall better code.
413 Optional now, so people can test it. */
415 #ifdef DEFAULT_CALLER_SAVES
416 int flag_caller_saves = 1;
418 int flag_caller_saves = 0;
421 /* Nonzero if structures and unions should be returned in memory.
423 This should only be defined if compatibility with another compiler or
424 with an ABI is needed, because it results in slower code. */
426 #ifndef DEFAULT_PCC_STRUCT_RETURN
427 #define DEFAULT_PCC_STRUCT_RETURN 1
430 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
432 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
434 /* Nonzero for -fforce-mem: load memory value into a register
435 before arithmetic on it. This makes better cse but slower compilation. */
437 int flag_force_mem = 0;
439 /* Nonzero for -fforce-addr: load memory address into a register before
440 reference to memory. This makes better cse but slower compilation. */
442 int flag_force_addr = 0;
444 /* Nonzero for -fdefer-pop: don't pop args after each function call;
445 instead save them up to pop many calls' args with one insns. */
447 int flag_defer_pop = 0;
449 /* Nonzero for -ffloat-store: don't allocate floats and doubles
450 in extended-precision registers. */
452 int flag_float_store = 0;
454 /* Nonzero for -fcse-follow-jumps:
455 have cse follow jumps to do a more extensive job. */
457 int flag_cse_follow_jumps;
459 /* Nonzero for -fcse-skip-blocks:
460 have cse follow a branch around a block. */
461 int flag_cse_skip_blocks;
463 /* Nonzero for -fexpensive-optimizations:
464 perform miscellaneous relatively-expensive optimizations. */
465 int flag_expensive_optimizations;
467 /* Nonzero for -fthread-jumps:
468 have jump optimize output of loop. */
470 int flag_thread_jumps;
472 /* Nonzero enables strength-reduction in loop.c. */
474 int flag_strength_reduce = 0;
476 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
477 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
478 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
481 int flag_unroll_loops;
483 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
484 This is generally not a win. */
486 int flag_unroll_all_loops;
488 /* Nonzero forces all invariant computations in loops to be moved
491 int flag_move_all_movables = 0;
493 /* Nonzero forces all general induction variables in loops to be
496 int flag_reduce_all_givs = 0;
498 /* Nonzero for -fwritable-strings:
499 store string constants in data segment and don't uniquize them. */
501 int flag_writable_strings = 0;
503 /* Nonzero means don't put addresses of constant functions in registers.
504 Used for compiling the Unix kernel, where strange substitutions are
505 done on the assembly output. */
507 int flag_no_function_cse = 0;
509 /* Nonzero for -fomit-frame-pointer:
510 don't make a frame pointer in simple functions that don't require one. */
512 int flag_omit_frame_pointer = 0;
514 /* Nonzero means place each function into its own section on those platforms
515 which support arbitrary section names and unlimited numbers of sections. */
517 int flag_function_sections = 0;
519 /* Nonzero to inhibit use of define_optimization peephole opts. */
521 int flag_no_peephole = 0;
523 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
524 operations in the interest of optimization. For example it allows
525 GCC to assume arguments to sqrt are nonnegative numbers, allowing
526 faster code for sqrt to be generated. */
528 int flag_fast_math = 0;
530 /* Nonzero means all references through pointers are volatile. */
534 /* Nonzero means treat all global and extern variables as global. */
536 int flag_volatile_global;
538 /* Nonzero means just do syntax checking; don't output anything. */
540 int flag_syntax_only = 0;
542 /* Nonzero means perform global cse. */
544 static int flag_gcse;
546 /* Nonzero means to rerun cse after loop optimization. This increases
547 compilation time about 20% and picks up a few more common expressions. */
549 static int flag_rerun_cse_after_loop;
551 /* Nonzero means to run loop optimizations twice. */
553 int flag_rerun_loop_opt;
555 /* Nonzero for -finline-functions: ok to inline functions that look like
556 good inline candidates. */
558 int flag_inline_functions;
560 /* Nonzero for -fkeep-inline-functions: even if we make a function
561 go inline everywhere, keep its definition around for debugging
564 int flag_keep_inline_functions;
566 /* Nonzero means that functions will not be inlined. */
570 /* Nonzero means that we should emit static const variables
571 regardless of whether or not optimization is turned on. */
573 int flag_keep_static_consts = 1;
575 /* Nonzero means we should be saving declaration info into a .X file. */
577 int flag_gen_aux_info = 0;
579 /* Specified name of aux-info file. */
581 static char *aux_info_file_name;
583 /* Nonzero means make the text shared if supported. */
585 int flag_shared_data;
587 /* Nonzero means schedule into delayed branch slots if supported. */
589 int flag_delayed_branch;
591 /* Nonzero if we are compiling pure (sharable) code.
592 Value is 1 if we are doing reasonable (i.e. simple
593 offset into offset table) pic. Value is 2 if we can
594 only perform register offsets. */
598 /* Nonzero means generate extra code for exception handling and enable
599 exception handling. */
603 /* Nonzero means use the new model for exception handling. Replaces
604 -DNEW_EH_MODEL as a compile option. */
606 int flag_new_exceptions = 0;
608 /* Nonzero means don't place uninitialized global data in common storage
613 /* Nonzero means pretend it is OK to examine bits of target floats,
614 even if that isn't true. The resulting code will have incorrect constants,
615 but the same series of instructions that the native compiler would make. */
617 int flag_pretend_float;
619 /* Nonzero means change certain warnings into errors.
620 Usually these are warnings about failure to conform to some standard. */
622 int flag_pedantic_errors = 0;
624 /* flag_schedule_insns means schedule insns within basic blocks (before
626 flag_schedule_insns_after_reload means schedule insns after
629 int flag_schedule_insns = 0;
630 int flag_schedule_insns_after_reload = 0;
633 /* The following flags have effect only for scheduling before register
636 flag_schedule_interblock means schedule insns accross basic blocks.
637 flag_schedule_speculative means allow speculative motion of non-load insns.
638 flag_schedule_speculative_load means allow speculative motion of some
640 flag_schedule_speculative_load_dangerous allows speculative motion of more
643 int flag_schedule_interblock = 1;
644 int flag_schedule_speculative = 1;
645 int flag_schedule_speculative_load = 0;
646 int flag_schedule_speculative_load_dangerous = 0;
648 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
649 by a cheaper branch, on a count register. */
650 int flag_branch_on_count_reg;
654 /* -finhibit-size-directive inhibits output of .size for ELF.
655 This is used only for compiling crtstuff.c,
656 and it may be extended to other effects
657 needed for crtstuff.c on other systems. */
658 int flag_inhibit_size_directive = 0;
660 /* -fverbose-asm causes extra commentary information to be produced in
661 the generated assembly code (to make it more readable). This option
662 is generally only of use to those who actually need to read the
663 generated assembly code (perhaps while debugging the compiler itself).
664 -fno-verbose-asm, the default, causes the extra information
665 to be omitted and is useful when comparing two assembler files. */
667 int flag_verbose_asm = 0;
669 /* -dA causes debug commentary information to be produced in
670 the generated assembly code (to make it more readable). This option
671 is generally only of use to those who actually need to read the
672 generated assembly code (perhaps while debugging the compiler itself).
673 Currently, this switch is only used by dwarfout.c; however, it is intended
674 to be a catchall for printing debug information in the assembler file. */
676 int flag_debug_asm = 0;
678 /* -fgnu-linker specifies use of the GNU linker for initializations.
679 (Or, more generally, a linker that handles initializations.)
680 -fno-gnu-linker says that collect2 will be used. */
682 int flag_gnu_linker = 0;
684 int flag_gnu_linker = 1;
687 /* Tag all structures with __attribute__(packed) */
688 int flag_pack_struct = 0;
690 /* Emit code to check for stack overflow; also may cause large objects
691 to be allocated dynamically. */
692 int flag_stack_check;
694 /* -fcheck-memory-usage causes extra code to be generated in order to check
695 memory accesses. This is used by a detector of bad memory accesses such
697 int flag_check_memory_usage = 0;
699 /* -fprefix-function-name causes function name to be prefixed. This
700 can be used with -fcheck-memory-usage to isolate code compiled with
701 -fcheck-memory-usage. */
702 int flag_prefix_function_name = 0;
704 int flag_regmove = 0;
706 /* 0 if pointer arguments may alias each other. True in C.
707 1 if pointer arguments may not alias each other but may alias
709 2 if pointer arguments may not alias each other and may not
710 alias global variables. True in Fortran.
711 This defaults to 0 for C. */
712 int flag_argument_noalias = 0;
714 /* Table of language-independent -f options.
715 STRING is the option name. VARIABLE is the address of the variable.
716 ON_VALUE is the value to store in VARIABLE
717 if `-fSTRING' is seen as an option.
718 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
720 struct { char *string; int *variable; int on_value;} f_options[] =
722 {"float-store", &flag_float_store, 1},
723 {"volatile", &flag_volatile, 1},
724 {"volatile-global", &flag_volatile_global, 1},
725 {"defer-pop", &flag_defer_pop, 1},
726 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
727 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
728 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
729 {"expensive-optimizations", &flag_expensive_optimizations, 1},
730 {"thread-jumps", &flag_thread_jumps, 1},
731 {"strength-reduce", &flag_strength_reduce, 1},
732 {"unroll-loops", &flag_unroll_loops, 1},
733 {"unroll-all-loops", &flag_unroll_all_loops, 1},
734 {"move-all-movables", &flag_move_all_movables, 1},
735 {"reduce-all-givs", &flag_reduce_all_givs, 1},
736 {"writable-strings", &flag_writable_strings, 1},
737 {"peephole", &flag_no_peephole, 0},
738 {"force-mem", &flag_force_mem, 1},
739 {"force-addr", &flag_force_addr, 1},
740 {"function-cse", &flag_no_function_cse, 0},
741 {"inline-functions", &flag_inline_functions, 1},
742 {"keep-inline-functions", &flag_keep_inline_functions, 1},
743 {"inline", &flag_no_inline, 0},
744 {"keep-static-consts", &flag_keep_static_consts, 1},
745 {"syntax-only", &flag_syntax_only, 1},
746 {"shared-data", &flag_shared_data, 1},
747 {"caller-saves", &flag_caller_saves, 1},
748 {"pcc-struct-return", &flag_pcc_struct_return, 1},
749 {"reg-struct-return", &flag_pcc_struct_return, 0},
750 {"delayed-branch", &flag_delayed_branch, 1},
751 {"gcse", &flag_gcse, 1},
752 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
753 {"rerun-loop-opt", &flag_rerun_loop_opt, 1},
754 {"pretend-float", &flag_pretend_float, 1},
755 {"schedule-insns", &flag_schedule_insns, 1},
756 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
758 {"sched-interblock",&flag_schedule_interblock, 1},
759 {"sched-spec",&flag_schedule_speculative, 1},
760 {"sched-spec-load",&flag_schedule_speculative_load, 1},
761 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1},
762 {"branch-count-reg",&flag_branch_on_count_reg, 1},
764 {"pic", &flag_pic, 1},
765 {"PIC", &flag_pic, 2},
766 {"exceptions", &flag_exceptions, 1},
767 {"new-exceptions", &flag_new_exceptions, 1},
768 {"sjlj-exceptions", &exceptions_via_longjmp, 1},
769 {"asynchronous-exceptions", &asynchronous_exceptions, 1},
770 {"profile-arcs", &profile_arc_flag, 1},
771 {"test-coverage", &flag_test_coverage, 1},
772 {"branch-probabilities", &flag_branch_probabilities, 1},
773 {"fast-math", &flag_fast_math, 1},
774 {"common", &flag_no_common, 0},
775 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
776 {"function-sections", &flag_function_sections, 1},
777 {"verbose-asm", &flag_verbose_asm, 1},
778 {"gnu-linker", &flag_gnu_linker, 1},
779 {"regmove", &flag_regmove, 1},
780 {"pack-struct", &flag_pack_struct, 1},
781 {"stack-check", &flag_stack_check, 1},
782 {"argument-alias", &flag_argument_noalias, 0},
783 {"argument-noalias", &flag_argument_noalias, 1},
784 {"argument-noalias-global", &flag_argument_noalias, 2},
785 {"check-memory-usage", &flag_check_memory_usage, 1},
786 {"prefix-function-name", &flag_prefix_function_name, 1}
789 /* Table of language-specific options. */
791 char *lang_options[] =
794 "-fallow-single-precision",
796 "-fsigned-bitfields",
797 "-funsigned-bitfields",
798 "-fno-signed-bitfields",
799 "-fno-unsigned-bitfields",
803 "-fno-unsigned-char",
819 "-fno-cond-mismatch",
820 "-fdollars-in-identifiers",
821 "-fno-dollars-in-identifiers",
830 "-Wbad-function-cast",
831 "-Wno-bad-function-cast",
835 "-Wno-char-subscripts",
846 "-Wimplicit-function-declaration",
847 "-Wno-implicit-function-declaration",
848 "-Werror-implicit-function-declaration",
856 "-Wno-missing-braces",
857 "-Wmissing-declarations",
858 "-Wno-missing-declarations",
859 "-Wmissing-prototypes",
860 "-Wno-missing-prototypes",
862 "-Wno-nested-externs",
866 "-Wno-pointer-arith",
868 "-Wno-redundant-decls",
872 "-Wno-unknown-pragmas",
873 "-Wstrict-prototypes",
874 "-Wno-strict-prototypes",
882 "-Wno-write-strings",
884 /* these are for obj c */
895 "-print-objc-runtime-info",
901 /* Options controlling warnings */
903 /* Don't print warning messages. -w. */
905 int inhibit_warnings = 0;
907 /* Print various extra warnings. -W. */
909 int extra_warnings = 0;
911 /* Treat warnings as errors. -Werror. */
913 int warnings_are_errors = 0;
915 /* Nonzero to warn about unused local variables. */
919 /* Nonzero to warn about variables used before they are initialized. */
921 int warn_uninitialized;
923 /* Nonzero means warn about all declarations which shadow others. */
927 /* Warn if a switch on an enum fails to have a case for every enum value. */
931 /* Nonzero means warn about function definitions that default the return type
932 or that use a null return and have a return-type other than void. */
934 int warn_return_type;
936 /* Nonzero means warn about pointer casts that increase the required
937 alignment of the target type (and might therefore lead to a crash
938 due to a misaligned access). */
942 /* Nonzero means warn about any identifiers that match in the first N
943 characters. The value N is in `id_clash_len'. */
946 unsigned id_clash_len;
948 /* Nonzero means warn about any objects definitions whose size is larger
949 than N bytes. Also want about function definitions whose returned
950 values are larger than N bytes. The value N is in `larger_than_size'. */
952 int warn_larger_than;
953 unsigned larger_than_size;
955 /* Nonzero means warn if inline function is too large. */
959 /* Warn if a function returns an aggregate,
960 since there are often incompatible calling conventions for doing this. */
962 int warn_aggregate_return;
964 /* Likewise for -W. */
966 struct { char *string; int *variable; int on_value;} W_options[] =
968 {"unused", &warn_unused, 1},
969 {"error", &warnings_are_errors, 1},
970 {"shadow", &warn_shadow, 1},
971 {"switch", &warn_switch, 1},
972 {"aggregate-return", &warn_aggregate_return, 1},
973 {"cast-align", &warn_cast_align, 1},
974 {"uninitialized", &warn_uninitialized, 1},
975 {"inline", &warn_inline, 1}
978 /* Output files for assembler code (real compiler output)
979 and debugging dumps. */
983 FILE *rtl_dump_file = NULL;
985 /* Time accumulators, to count the total time spent in various passes. */
989 int integration_time;
995 int branch_prob_time;
1000 int local_alloc_time;
1001 int global_alloc_time;
1006 int shorten_branch_time;
1012 /* Return time used so far, in microseconds. */
1022 #else /* not BeOS */
1023 #if defined (_WIN32) && !defined (__CYGWIN32__)
1027 return (clock() * 1000);
1028 #else /* not _WIN32 */
1034 tick = 1000000 / sysconf(_SC_CLK_TCK);
1036 return (tms.tms_utime + tms.tms_stime) * tick;
1042 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1043 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1046 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1048 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1052 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1057 struct rusage rusage;
1058 getrusage (0, &rusage);
1059 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1060 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1067 int proc_system_time;
1068 int child_user_time;
1069 int child_system_time;
1071 times ((void *) &vms_times);
1072 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1076 #endif /* _SC_CLK_TCK */
1078 #endif /* __BEOS__ */
1081 #define TIMEVAR(VAR, BODY) \
1082 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1085 print_time (str, total)
1090 "time in %s: %d.%06d\n",
1091 str, total / 1000000, total % 1000000);
1094 /* Count an error or warning. Return 1 if the message should be printed. */
1097 count_error (warningp)
1100 if (warningp && inhibit_warnings)
1103 if (warningp && !warnings_are_errors)
1107 static int warning_message = 0;
1109 if (warningp && !warning_message)
1111 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
1112 warning_message = 1;
1120 /* Print a fatal error message. NAME is the text.
1121 Also include a system error message based on `errno'. */
1124 pfatal_with_name (name)
1127 fprintf (stderr, "%s: ", progname);
1129 exit (FATAL_EXIT_CODE);
1133 fatal_io_error (name)
1136 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
1137 exit (FATAL_EXIT_CODE);
1140 /* Called to give a better error message for a bad insn rather than
1141 just calling abort(). */
1144 fatal_insn (message, insn)
1151 fflush (asm_out_file);
1153 fflush (aux_info_file);
1154 if (rtl_dump_file != NULL)
1155 fflush (rtl_dump_file);
1161 /* Called to give a better error message when we don't have an insn to match
1162 what we are looking for or if the insn's constraints aren't satisfied,
1163 rather than just calling abort(). */
1166 fatal_insn_not_found (insn)
1169 if (INSN_CODE (insn) < 0)
1170 fatal_insn ("internal error--unrecognizable insn:", insn);
1172 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1175 /* This is the default decl_printable_name function. */
1178 decl_name (decl, verbosity)
1182 return IDENTIFIER_POINTER (DECL_NAME (decl));
1185 static int need_error_newline;
1187 /* Function of last error message;
1188 more generally, function such that if next error message is in it
1189 then we don't have to mention the function name. */
1190 static tree last_error_function = NULL;
1192 /* Used to detect when input_file_stack has changed since last described. */
1193 static int last_error_tick;
1195 /* Called when the start of a function definition is parsed,
1196 this function prints on stderr the name of the function. */
1199 announce_function (decl)
1204 if (rtl_dump_and_exit)
1205 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1207 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1209 need_error_newline = 1;
1210 last_error_function = current_function_decl;
1214 /* The default function to print out name of current function that caused
1218 default_print_error_function (file)
1221 if (last_error_function != current_function_decl)
1223 char *kind = "function";
1224 if (current_function_decl != 0
1225 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1229 fprintf (stderr, "%s: ", file);
1231 if (current_function_decl == NULL)
1232 fprintf (stderr, "At top level:\n");
1235 char *name = (*decl_printable_name) (current_function_decl, 2);
1236 fprintf (stderr, "In %s `%s':\n", kind, name);
1239 last_error_function = current_function_decl;
1243 /* Called by report_error_function to print out function name.
1244 * Default may be overridden by language front-ends. */
1246 void (*print_error_function) PROTO((char *)) = default_print_error_function;
1248 /* Prints out, if necessary, the name of the current function
1249 that caused an error. Called from all error and warning functions. */
1252 report_error_function (file)
1255 struct file_stack *p;
1257 if (need_error_newline)
1259 fprintf (stderr, "\n");
1260 need_error_newline = 0;
1263 (*print_error_function) (file);
1265 if (input_file_stack && input_file_stack->next != 0
1266 && input_file_stack_tick != last_error_tick
1267 && file == input_filename)
1269 fprintf (stderr, "In file included");
1270 for (p = input_file_stack->next; p; p = p->next)
1272 fprintf (stderr, " from %s:%d", p->name, p->line);
1274 fprintf (stderr, ",\n ");
1276 fprintf (stderr, ":\n");
1277 last_error_tick = input_file_stack_tick;
1281 /* Print a message. */
1284 vmessage (prefix, s, ap)
1290 fprintf (stderr, "%s: ", prefix);
1292 vfprintf (stderr, s, ap);
1295 /* Print a message relevant to line LINE of file FILE. */
1298 v_message_with_file_and_line (file, line, prefix, s, ap)
1306 fprintf (stderr, "%s:%d: ", file, line);
1308 fprintf (stderr, "%s: ", progname);
1310 vmessage (prefix, s, ap);
1311 fputc ('\n', stderr);
1314 /* Print a message relevant to the given DECL. */
1317 v_message_with_decl (decl, prefix, s, ap)
1325 fprintf (stderr, "%s:%d: ",
1326 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1329 fprintf (stderr, "%s: ", prefix);
1331 /* Do magic to get around lack of varargs support for insertion
1332 of arguments into existing list. We know that the decl is first;
1333 we ass_u_me that it will be printed with "%s". */
1335 for (p = s; *p; ++p)
1339 if (*(p + 1) == '%')
1346 if (p > s) /* Print the left-hand substring. */
1348 char fmt[sizeof "%.255s"];
1351 if (width > 255L) width = 255L; /* arbitrary */
1352 sprintf (fmt, "%%.%lds", width);
1353 fprintf (stderr, fmt, s);
1356 if (*p == '%') /* Print the name. */
1358 char *n = (DECL_NAME (decl)
1359 ? (*decl_printable_name) (decl, 2)
1365 if (ISALPHA (*(p - 1) & 0xFF))
1370 if (*p) /* Print the rest of the message. */
1371 vmessage ((char *)NULL, p, ap);
1373 fputc ('\n', stderr);
1376 /* Figure file and line of the given INSN. */
1379 file_and_line_for_asm (insn, pfile, pline)
1384 rtx body = PATTERN (insn);
1387 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1388 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1389 asmop = SET_SRC (body);
1390 else if (GET_CODE (body) == ASM_OPERANDS)
1392 else if (GET_CODE (body) == PARALLEL
1393 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1394 asmop = SET_SRC (XVECEXP (body, 0, 0));
1395 else if (GET_CODE (body) == PARALLEL
1396 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1397 asmop = XVECEXP (body, 0, 0);
1403 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1404 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1408 *pfile = input_filename;
1413 /* Report an error at line LINE of file FILE. */
1416 v_error_with_file_and_line (file, line, s, ap)
1423 report_error_function (file);
1424 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1428 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1440 file = va_arg (ap, char *);
1441 line = va_arg (ap, int);
1442 s = va_arg (ap, char *);
1445 v_error_with_file_and_line (file, line, s, ap);
1449 /* Report an error at the declaration DECL.
1450 S is a format string which uses %s to substitute the declaration
1451 name; subsequent substitutions are a la printf. */
1454 v_error_with_decl (decl, s, ap)
1460 report_error_function (DECL_SOURCE_FILE (decl));
1461 v_message_with_decl (decl, (char *)NULL, s, ap);
1465 error_with_decl VPROTO((tree decl, char *s, ...))
1476 decl = va_arg (ap, tree);
1477 s = va_arg (ap, char *);
1480 v_error_with_decl (decl, s, ap);
1484 /* Report an error at the line number of the insn INSN.
1485 This is used only when INSN is an `asm' with operands,
1486 and each ASM_OPERANDS records its own source file and line. */
1489 v_error_for_asm (insn, s, ap)
1498 file_and_line_for_asm (insn, &file, &line);
1499 report_error_function (file);
1500 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1504 error_for_asm VPROTO((rtx insn, char *s, ...))
1515 insn = va_arg (ap, rtx);
1516 s = va_arg (ap, char *);
1519 v_error_for_asm (insn, s, ap);
1523 /* Report an error at the current line number. */
1530 v_error_with_file_and_line (input_filename, lineno, s, ap);
1534 error VPROTO((char *s, ...))
1544 s = va_arg (ap, char *);
1551 /* Report a fatal error at the current line number. */
1559 exit (FATAL_EXIT_CODE);
1563 fatal VPROTO((char *s, ...))
1573 s = va_arg (ap, char *);
1580 /* Report a warning at line LINE of file FILE. */
1583 v_warning_with_file_and_line (file, line, s, ap)
1589 if (count_error (1))
1591 report_error_function (file);
1592 v_message_with_file_and_line (file, line, "warning", s, ap);
1597 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1609 file = va_arg (ap, char *);
1610 line = va_arg (ap, int);
1611 s = va_arg (ap, char *);
1614 v_warning_with_file_and_line (file, line, s, ap);
1618 /* Report a warning at the declaration DECL.
1619 S is a format string which uses %s to substitute the declaration
1620 name; subsequent substitutions are a la printf. */
1623 v_warning_with_decl (decl, s, ap)
1628 if (count_error (1))
1630 report_error_function (DECL_SOURCE_FILE (decl));
1631 v_message_with_decl (decl, "warning", s, ap);
1636 warning_with_decl VPROTO((tree decl, char *s, ...))
1647 decl = va_arg (ap, tree);
1648 s = va_arg (ap, char *);
1651 v_warning_with_decl (decl, s, ap);
1655 /* Report a warning at the line number of the insn INSN.
1656 This is used only when INSN is an `asm' with operands,
1657 and each ASM_OPERANDS records its own source file and line. */
1660 v_warning_for_asm (insn, s, ap)
1665 if (count_error (1))
1670 file_and_line_for_asm (insn, &file, &line);
1671 report_error_function (file);
1672 v_message_with_file_and_line (file, line, "warning", s, ap);
1677 warning_for_asm VPROTO((rtx insn, char *s, ...))
1688 insn = va_arg (ap, rtx);
1689 s = va_arg (ap, char *);
1692 v_warning_for_asm (insn, s, ap);
1696 /* Report a warning at the current line number. */
1703 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1707 warning VPROTO((char *s, ...))
1717 s = va_arg (ap, char *);
1724 /* These functions issue either warnings or errors depending on
1725 -pedantic-errors. */
1732 if (flag_pedantic_errors)
1739 pedwarn VPROTO((char *s, ...))
1749 s = va_arg (ap, char *);
1757 v_pedwarn_with_decl (decl, s, ap)
1762 /* We don't want -pedantic-errors to cause the compilation to fail from
1763 "errors" in system header files. Sometimes fixincludes can't fix what's
1764 broken (eg: unsigned char bitfields - fixing it may change the alignment
1765 which will cause programs to mysteriously fail because the C library
1766 or kernel uses the original layout). There's no point in issuing a
1767 warning either, it's just unnecessary noise. */
1769 if (! DECL_IN_SYSTEM_HEADER (decl))
1771 if (flag_pedantic_errors)
1772 v_error_with_decl (decl, s, ap);
1774 v_warning_with_decl (decl, s, ap);
1779 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1790 decl = va_arg (ap, tree);
1791 s = va_arg (ap, char *);
1794 v_pedwarn_with_decl (decl, s, ap);
1799 v_pedwarn_with_file_and_line (file, line, s, ap)
1805 if (flag_pedantic_errors)
1806 v_error_with_file_and_line (file, line, s, ap);
1808 v_warning_with_file_and_line (file, line, s, ap);
1812 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1824 file = va_arg (ap, char *);
1825 line = va_arg (ap, int);
1826 s = va_arg (ap, char *);
1829 v_pedwarn_with_file_and_line (file, line, s, ap);
1833 /* Apologize for not implementing some feature. */
1842 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1844 fprintf (stderr, "%s: ", progname);
1845 vmessage ("sorry, not implemented", s, ap);
1846 fputc ('\n', stderr);
1850 sorry VPROTO((char *s, ...))
1860 s = va_arg (ap, char *);
1867 /* Apologize for not implementing some feature, then quit. */
1870 v_really_sorry (s, ap)
1876 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1878 fprintf (stderr, "%s: ", progname);
1879 vmessage ("sorry, not implemented", s, ap);
1880 fatal (" (fatal)\n");
1884 really_sorry VPROTO((char *s, ...))
1894 s = va_arg (ap, char *);
1897 v_really_sorry (s, ap);
1901 /* More 'friendly' abort that prints the line and file.
1902 config.h can #define abort fancy_abort if you like that sort of thing.
1904 I don't think this is actually a good idea.
1905 Other sorts of crashes will look a certain way.
1906 It is a good thing if crashes from calling abort look the same way.
1912 fatal ("internal gcc abort");
1915 /* This calls abort and is used to avoid problems when abort if a macro.
1916 It is used when we need to pass the address of abort. */
1924 /* When `malloc.c' is compiled with `rcheck' defined,
1925 it calls this function to report clobberage. */
1934 /* Same as `malloc' but report error if no memory available. */
1940 register char *value = (char *) malloc (size);
1941 if (value == 0 && size != 0)
1942 fatal ("virtual memory exhausted");
1946 /* Same as `realloc' but report error if no memory available.
1947 Also handle null PTR even if the vendor realloc gets it wrong. */
1950 xrealloc (ptr, size)
1955 ? (char *) realloc (ptr, size)
1956 : (char *) malloc (size));
1958 fatal ("virtual memory exhausted");
1962 /* Same as `strdup' but report error if no memory available. */
1968 register char *result = (char *) malloc (strlen (s) + 1);
1971 fatal ("virtual memory exhausted");
1976 /* Return the logarithm of X, base 2, considering X unsigned,
1977 if X is a power of 2. Otherwise, returns -1.
1979 This should be used via the `exact_log2' macro. */
1983 register unsigned HOST_WIDE_INT x;
1985 register int log = 0;
1986 /* Test for 0 or a power of 2. */
1987 if (x == 0 || x != (x & -x))
1989 while ((x >>= 1) != 0)
1994 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1995 If X is 0, return -1.
1997 This should be used via the floor_log2 macro. */
2001 register unsigned HOST_WIDE_INT x;
2003 register int log = -1;
2010 static int float_handler_set;
2012 jmp_buf float_handler;
2014 /* Signals actually come here. */
2017 float_signal (signo)
2018 /* If this is missing, some compilers complain. */
2019 int signo ATTRIBUTE_UNUSED;
2021 if (float_handled == 0)
2023 #if defined (USG) || defined (hpux)
2024 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2027 signal (SIGFPE, float_signal);
2028 longjmp (float_handler, 1);
2031 /* Specify where to longjmp to when a floating arithmetic error happens.
2032 If HANDLER is 0, it means don't handle the errors any more. */
2035 set_float_handler (handler)
2038 float_handled = (handler != 0);
2040 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2042 if (float_handled && ! float_handler_set)
2044 signal (SIGFPE, float_signal);
2045 float_handler_set = 1;
2049 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2050 error happens, pushing the previous specification into OLD_HANDLER.
2051 Return an indication of whether there was a previous handler in effect. */
2054 push_float_handler (handler, old_handler)
2055 jmp_buf handler, old_handler;
2057 int was_handled = float_handled;
2061 bcopy ((char *) float_handler, (char *) old_handler,
2062 sizeof (float_handler));
2064 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2068 /* Restore the previous specification of whether and where to longjmp to
2069 when a floating arithmetic error happens. */
2072 pop_float_handler (handled, handler)
2076 float_handled = handled;
2078 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2081 /* Handler for SIGPIPE. */
2085 /* If this is missing, some compilers complain. */
2086 int signo ATTRIBUTE_UNUSED;
2088 fatal ("output pipe has been closed");
2091 /* Strip off a legitimate source ending from the input string NAME of
2092 length LEN. Rather than having to know the names used by all of
2093 our front ends, we strip off an ending of a period followed by
2094 up to five characters. (Java uses ".class".) */
2097 strip_off_ending (name, len)
2102 for (i = 2; i < 6 && len > i; i++)
2104 if (name[len - i] == '.')
2106 name[len - i] = '\0';
2112 /* Output a quoted string. */
2115 output_quoted_string (asm_file, string)
2119 #ifdef OUTPUT_QUOTED_STRING
2120 OUTPUT_QUOTED_STRING (asm_file, string);
2124 putc ('\"', asm_file);
2125 while ((c = *string++) != 0)
2127 if (c == '\"' || c == '\\')
2128 putc ('\\', asm_file);
2131 putc ('\"', asm_file);
2135 /* Output a file name in the form wanted by System V. */
2138 output_file_directive (asm_file, input_name)
2142 int len = strlen (input_name);
2143 char *na = input_name + len;
2145 /* NA gets INPUT_NAME sans directory names. */
2146 while (na > input_name)
2153 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2154 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2156 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2157 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2159 fprintf (asm_file, "\t.file\t");
2160 output_quoted_string (asm_file, na);
2161 fputc ('\n', asm_file);
2166 /* Routine to build language identifier for object file. */
2169 output_lang_identify (asm_out_file)
2172 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2173 char *s = (char *) alloca (len);
2174 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2175 ASM_OUTPUT_LABEL (asm_out_file, s);
2178 /* Routine to open a dump file. */
2180 open_dump_file (suffix, function_name)
2182 char *function_name;
2189 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2191 if (rtl_dump_file != NULL)
2192 fclose (rtl_dump_file);
2194 strcpy (dumpname, dump_base_name);
2195 strcat (dumpname, suffix);
2197 rtl_dump_file = fopen (dumpname, "a");
2199 if (rtl_dump_file == NULL)
2200 pfatal_with_name (dumpname);
2205 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2211 /* Routine to close a dump file. */
2213 close_dump_file (func, insns)
2214 void (*func) PROTO ((FILE *, rtx));
2221 func (rtl_dump_file, insns);
2223 fflush (rtl_dump_file);
2224 fclose (rtl_dump_file);
2226 rtl_dump_file = NULL;
2232 /* Routine to dump rtl into a file. */
2234 dump_rtl (suffix, decl, func, insns)
2237 void (*func) PROTO ((FILE *, rtx));
2240 open_dump_file (suffix, decl_printable_name (decl, 2));
2241 close_dump_file (func, insns);
2244 /* Routine to empty a dump file. */
2246 clean_dump_file (suffix)
2251 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2253 strcpy (dumpname, dump_base_name);
2254 strcat (dumpname, suffix);
2256 rtl_dump_file = fopen (dumpname, "w");
2258 if (rtl_dump_file == NULL)
2259 pfatal_with_name (dumpname);
2263 fclose (rtl_dump_file);
2264 rtl_dump_file = NULL;
2270 /* Compile an entire file of output from cpp, named NAME.
2271 Write a file of assembly output and various debugging dumps. */
2280 int name_specified = name != 0;
2282 if (dump_base_name == 0)
2283 dump_base_name = name ? name : "gccdump";
2287 integration_time = 0;
2293 branch_prob_time = 0;
2298 local_alloc_time = 0;
2299 global_alloc_time = 0;
2304 shorten_branch_time = 0;
2310 /* Initialize data in various passes. */
2314 name = init_parse (name);
2316 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2317 || debug_info_level == DINFO_LEVEL_VERBOSE
2318 || flag_test_coverage);
2320 init_decl_processing ();
2329 if (flag_caller_saves)
2330 init_caller_save ();
2332 /* If auxiliary info generation is desired, open the output file.
2333 This goes in the same directory as the source file--unlike
2334 all the other output files. */
2335 if (flag_gen_aux_info)
2337 aux_info_file = fopen (aux_info_file_name, "w");
2338 if (aux_info_file == 0)
2339 pfatal_with_name (aux_info_file_name);
2342 /* Clear the dump files file. */
2344 clean_dump_file (".rtl");
2346 clean_dump_file (".jump");
2348 clean_dump_file (".addressof");
2350 clean_dump_file (".cse");
2352 clean_dump_file (".loop");
2354 clean_dump_file (".cse2");
2355 if (branch_prob_dump)
2356 clean_dump_file (".bp");
2358 clean_dump_file (".flow");
2360 clean_dump_file (".combine");
2362 clean_dump_file (".regmove");
2364 clean_dump_file (".sched");
2366 clean_dump_file (".lreg");
2367 if (global_reg_dump)
2368 clean_dump_file (".greg");
2370 clean_dump_file (".sched2");
2372 clean_dump_file (".jump2");
2375 clean_dump_file (".dbr");
2378 clean_dump_file (".gcse");
2381 clean_dump_file (".stack");
2383 #ifdef MACHINE_DEPENDENT_REORG
2384 if (mach_dep_reorg_dump)
2385 clean_dump_file (".mach");
2388 /* Open assembler code output file. */
2390 if (! name_specified && asm_file_name == 0)
2391 asm_out_file = stdout;
2394 int len = strlen (dump_base_name);
2395 register char *dumpname = (char *) xmalloc (len + 6);
2396 strcpy (dumpname, dump_base_name);
2397 strip_off_ending (dumpname, len);
2398 strcat (dumpname, ".s");
2399 if (asm_file_name == 0)
2401 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2402 strcpy (asm_file_name, dumpname);
2404 if (!strcmp (asm_file_name, "-"))
2405 asm_out_file = stdout;
2407 asm_out_file = fopen (asm_file_name, "w");
2408 if (asm_out_file == 0)
2409 pfatal_with_name (asm_file_name);
2412 #ifdef IO_BUFFER_SIZE
2413 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2414 _IOFBF, IO_BUFFER_SIZE);
2417 input_filename = name;
2419 /* Put an entry on the input file stack for the main input file. */
2421 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2422 input_file_stack->next = 0;
2423 input_file_stack->name = input_filename;
2425 /* Perform language-specific initialization.
2426 This may set main_input_filename. */
2429 /* If the input doesn't start with a #line, use the input name
2430 as the official input file name. */
2431 if (main_input_filename == 0)
2432 main_input_filename = name;
2434 ASM_FILE_START (asm_out_file);
2436 #ifdef ASM_COMMENT_START
2437 if (flag_verbose_asm)
2439 /* Print the list of options in effect. */
2440 print_version (asm_out_file, ASM_COMMENT_START);
2441 print_switch_values (asm_out_file, 0, MAX_LINE,
2442 ASM_COMMENT_START, " ", "\n");
2443 /* Add a blank line here so it appears in assembler output but not
2445 fprintf (asm_out_file, "\n");
2449 /* Output something to inform GDB that this compilation was by GCC. */
2450 #ifndef ASM_IDENTIFY_GCC
2451 fprintf (asm_out_file, "gcc2_compiled.:\n");
2453 ASM_IDENTIFY_GCC (asm_out_file);
2456 /* Output something to identify which front-end produced this file. */
2457 #ifdef ASM_IDENTIFY_LANGUAGE
2458 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2461 #ifndef ASM_OUTPUT_SECTION_NAME
2462 if (flag_function_sections)
2464 warning ("-ffunction-sections not supported for this target.");
2465 flag_function_sections = 0;
2469 if (flag_function_sections
2470 && (profile_flag || profile_block_flag))
2472 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2473 flag_function_sections = 0;
2476 if (flag_function_sections && write_symbols != NO_DEBUG)
2477 warning ("-ffunction-sections may affect debugging on some targets.");
2479 /* ??? Note: There used to be a conditional here
2480 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2481 This was to guarantee separation between gcc_compiled. and
2482 the first function, for the sake of dbx on Suns.
2483 However, having the extra zero here confused the Emacs
2484 code for unexec, and might confuse other programs too.
2485 Therefore, I took out that change.
2486 In future versions we should find another way to solve
2487 that dbx problem. -- rms, 23 May 93. */
2489 /* Don't let the first function fall at the same address
2490 as gcc_compiled., if profiling. */
2491 if (profile_flag || profile_block_flag)
2493 /* It's best if we can write a nop here since some
2494 assemblers don't tolerate zeros in the text section. */
2495 if (insn_template[CODE_FOR_nop] != 0)
2496 output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR);
2498 assemble_zeros (UNITS_PER_WORD);
2501 /* If dbx symbol table desired, initialize writing it
2502 and output the predefined types. */
2503 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2504 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2505 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2508 #ifdef SDB_DEBUGGING_INFO
2509 if (write_symbols == SDB_DEBUG)
2510 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2513 #ifdef DWARF_DEBUGGING_INFO
2514 if (write_symbols == DWARF_DEBUG)
2515 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2517 #ifdef DWARF2_UNWIND_INFO
2518 if (dwarf2out_do_frame ())
2519 dwarf2out_frame_init ();
2521 #ifdef DWARF2_DEBUGGING_INFO
2522 if (write_symbols == DWARF2_DEBUG)
2523 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2526 /* Initialize yet another pass. */
2528 init_final (main_input_filename);
2529 init_branch_prob (dump_base_name);
2531 start_time = get_run_time ();
2533 /* Call the parser, which parses the entire file
2534 (calling rest_of_compilation for each function). */
2536 if (yyparse () != 0)
2538 if (errorcount == 0)
2539 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2541 /* In case there were missing closebraces,
2542 get us back to the global binding level. */
2543 while (! global_bindings_p ())
2547 output_func_start_profiler ();
2549 /* Compilation is now finished except for writing
2550 what's left of the symbol table output. */
2552 parse_time += get_run_time () - start_time;
2554 parse_time -= integration_time;
2555 parse_time -= varconst_time;
2557 globals = getdecls ();
2559 /* Really define vars that have had only a tentative definition.
2560 Really output inline functions that must actually be callable
2561 and have not been output so far. */
2564 int len = list_length (globals);
2565 tree *vec = (tree *) alloca (sizeof (tree) * len);
2570 /* Process the decls in reverse order--earliest first.
2571 Put them into VEC from back to front, then take out from front. */
2573 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2574 vec[len - i - 1] = decl;
2576 for (i = 0; i < len; i++)
2580 /* We're not deferring this any longer. */
2581 DECL_DEFER_OUTPUT (decl) = 0;
2583 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2584 && incomplete_decl_finalize_hook != 0)
2585 (*incomplete_decl_finalize_hook) (decl);
2588 /* Now emit any global variables or functions that we have been putting
2589 off. We need to loop in case one of the things emitted here
2590 references another one which comes earlier in the list. */
2594 for (i = 0; i < len; i++)
2598 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2601 /* Don't write out static consts, unless we still need them.
2603 We also keep static consts if not optimizing (for debugging),
2604 unless the user specified -fno-keep-static-consts.
2605 ??? They might be better written into the debug information.
2606 This is possible when using DWARF.
2608 A language processor that wants static constants to be always
2609 written out (even if it is not used) is responsible for
2610 calling rest_of_decl_compilation itself. E.g. the C front-end
2611 calls rest_of_decl_compilation from finish_decl.
2612 One motivation for this is that is conventional in some
2613 environments to write things like:
2614 static const char rcsid[] = "... version string ...";
2615 intending to force the string to be in the executable.
2617 A language processor that would prefer to have unneeded
2618 static constants "optimized away" would just defer writing
2619 them out until here. E.g. C++ does this, because static
2620 constants are often defined in header files.
2622 ??? A tempting alternative (for both C and C++) would be
2623 to force a constant to be written if and only if it is
2624 defined in a main file, as opposed to an include file. */
2626 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2627 && (! TREE_READONLY (decl)
2628 || TREE_PUBLIC (decl)
2629 || (!optimize && flag_keep_static_consts)
2630 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2633 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2636 if (TREE_CODE (decl) == FUNCTION_DECL
2637 && DECL_INITIAL (decl) != 0
2638 && DECL_SAVED_INSNS (decl) != 0
2639 && (flag_keep_inline_functions
2640 || TREE_PUBLIC (decl)
2641 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2644 temporary_allocation ();
2645 output_inline_function (decl);
2646 permanent_allocation (1);
2651 /* Now that all possible functions have been output, we can dump
2652 the exception table. */
2654 output_exception_table ();
2656 for (i = 0; i < len; i++)
2660 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2661 && ! TREE_ASM_WRITTEN (decl))
2662 /* Cancel the RTL for this decl so that, if debugging info
2663 output for global variables is still to come,
2664 this one will be omitted. */
2665 DECL_RTL (decl) = NULL;
2667 /* Warn about any function
2668 declared static but not defined.
2669 We don't warn about variables,
2670 because many programs have static variables
2671 that exist only to get some text into the object file. */
2672 if (TREE_CODE (decl) == FUNCTION_DECL
2674 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2675 && DECL_INITIAL (decl) == 0
2676 && DECL_EXTERNAL (decl)
2677 && ! DECL_ARTIFICIAL (decl)
2678 && ! TREE_PUBLIC (decl))
2680 pedwarn_with_decl (decl,
2681 "`%s' declared `static' but never defined");
2682 /* This symbol is effectively an "extern" declaration now. */
2683 TREE_PUBLIC (decl) = 1;
2684 assemble_external (decl);
2687 /* Warn about static fns or vars defined but not used,
2688 but not about inline functions or static consts
2689 since defining those in header files is normal practice. */
2691 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2692 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2693 && ! DECL_IN_SYSTEM_HEADER (decl)
2694 && ! DECL_EXTERNAL (decl)
2695 && ! TREE_PUBLIC (decl)
2696 && ! TREE_USED (decl)
2697 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2698 /* The TREE_USED bit for file-scope decls
2699 is kept in the identifier, to handle multiple
2700 external decls in different scopes. */
2701 && ! TREE_USED (DECL_NAME (decl)))
2702 warning_with_decl (decl, "`%s' defined but not used");
2704 #ifdef SDB_DEBUGGING_INFO
2705 /* The COFF linker can move initialized global vars to the end.
2706 And that can screw up the symbol ordering.
2707 By putting the symbols in that order to begin with,
2708 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2709 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2710 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2711 && ! DECL_EXTERNAL (decl)
2712 && DECL_RTL (decl) != 0)
2713 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2715 /* Output COFF information for non-global
2716 file-scope initialized variables. */
2717 if (write_symbols == SDB_DEBUG
2718 && TREE_CODE (decl) == VAR_DECL
2719 && DECL_INITIAL (decl)
2720 && ! DECL_EXTERNAL (decl)
2721 && DECL_RTL (decl) != 0
2722 && GET_CODE (DECL_RTL (decl)) == MEM)
2723 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2724 #endif /* SDB_DEBUGGING_INFO */
2725 #ifdef DWARF_DEBUGGING_INFO
2726 /* Output DWARF information for file-scope tentative data object
2727 declarations, file-scope (extern) function declarations (which
2728 had no corresponding body) and file-scope tagged type declarations
2729 and definitions which have not yet been forced out. */
2731 if (write_symbols == DWARF_DEBUG
2732 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2733 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2735 #ifdef DWARF2_DEBUGGING_INFO
2736 /* Output DWARF2 information for file-scope tentative data object
2737 declarations, file-scope (extern) function declarations (which
2738 had no corresponding body) and file-scope tagged type declarations
2739 and definitions which have not yet been forced out. */
2741 if (write_symbols == DWARF2_DEBUG
2742 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2743 TIMEVAR (symout_time, dwarf2out_decl (decl));
2748 /* Write out any pending weak symbol declarations. */
2752 /* Do dbx symbols */
2753 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2754 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2755 TIMEVAR (symout_time,
2757 dbxout_finish (asm_out_file, main_input_filename);
2761 #ifdef DWARF_DEBUGGING_INFO
2762 if (write_symbols == DWARF_DEBUG)
2763 TIMEVAR (symout_time,
2769 #ifdef DWARF2_UNWIND_INFO
2770 if (dwarf2out_do_frame ())
2771 dwarf2out_frame_finish ();
2774 #ifdef DWARF2_DEBUGGING_INFO
2775 if (write_symbols == DWARF2_DEBUG)
2776 TIMEVAR (symout_time,
2778 dwarf2out_finish ();
2782 /* Output some stuff at end of file if nec. */
2784 end_final (dump_base_name);
2786 if (branch_prob_dump)
2787 open_dump_file (".bp", NULL);
2789 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
2791 if (branch_prob_dump)
2792 close_dump_file (NULL, NULL_RTX);
2795 ASM_FILE_END (asm_out_file);
2798 /* Language-specific end of compilation actions. */
2802 /* Close the dump files. */
2804 if (flag_gen_aux_info)
2806 fclose (aux_info_file);
2808 unlink (aux_info_file_name);
2813 open_dump_file (".combine", NULL);
2814 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
2815 close_dump_file (NULL, NULL_RTX);
2818 /* Close non-debugging input and output files. Take special care to note
2819 whether fclose returns an error, since the pages might still be on the
2820 buffer chain while the file is open. */
2824 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2825 fatal_io_error (asm_file_name);
2827 /* Print the times. */
2831 fprintf (stderr,"\n");
2832 print_time ("parse", parse_time);
2834 print_time ("integration", integration_time);
2835 print_time ("jump", jump_time);
2836 print_time ("cse", cse_time);
2837 print_time ("gcse", gcse_time);
2838 print_time ("loop", loop_time);
2839 print_time ("cse2", cse2_time);
2840 print_time ("branch-prob", branch_prob_time);
2841 print_time ("flow", flow_time);
2842 print_time ("combine", combine_time);
2843 print_time ("regmove", regmove_time);
2844 print_time ("sched", sched_time);
2845 print_time ("local-alloc", local_alloc_time);
2846 print_time ("global-alloc", global_alloc_time);
2847 print_time ("sched2", sched2_time);
2849 print_time ("dbranch", dbr_sched_time);
2851 print_time ("shorten-branch", shorten_branch_time);
2852 print_time ("stack-reg", stack_reg_time);
2853 print_time ("final", final_time);
2854 print_time ("varconst", varconst_time);
2855 print_time ("symout", symout_time);
2856 print_time ("dump", dump_time);
2860 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2861 and TYPE_DECL nodes.
2863 This does nothing for local (non-static) variables.
2864 Otherwise, it sets up the RTL and outputs any assembler code
2865 (label definition, storage allocation and initialization).
2867 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2868 the assembler symbol name to be used. TOP_LEVEL is nonzero
2869 if this declaration is not within a function. */
2872 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2878 /* Declarations of variables, and of functions defined elsewhere. */
2880 /* The most obvious approach, to put an #ifndef around where
2881 this macro is used, doesn't work since it's inside a macro call. */
2882 #ifndef ASM_FINISH_DECLARE_OBJECT
2883 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2886 /* Forward declarations for nested functions are not "external",
2887 but we need to treat them as if they were. */
2888 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2889 || TREE_CODE (decl) == FUNCTION_DECL)
2890 TIMEVAR (varconst_time,
2892 make_decl_rtl (decl, asmspec, top_level);
2893 /* Initialized extern variable exists to be replaced
2894 with its value, or represents something that will be
2895 output in another file. */
2896 if (! (TREE_CODE (decl) == VAR_DECL
2897 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2898 && DECL_INITIAL (decl) != 0
2899 && DECL_INITIAL (decl) != error_mark_node))
2900 /* Don't output anything
2901 when a tentative file-scope definition is seen.
2902 But at end of compilation, do output code for them. */
2903 if (! (! at_end && top_level
2904 && (DECL_INITIAL (decl) == 0
2905 || DECL_INITIAL (decl) == error_mark_node)))
2906 assemble_variable (decl, top_level, at_end, 0);
2907 if (decl == last_assemble_variable_decl)
2909 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2913 else if (DECL_REGISTER (decl) && asmspec != 0)
2915 if (decode_reg_name (asmspec) >= 0)
2917 DECL_RTL (decl) = 0;
2918 make_decl_rtl (decl, asmspec, top_level);
2921 error ("invalid register name `%s' for register variable", asmspec);
2923 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2924 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2925 && TREE_CODE (decl) == TYPE_DECL)
2926 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2928 #ifdef SDB_DEBUGGING_INFO
2929 else if (write_symbols == SDB_DEBUG && top_level
2930 && TREE_CODE (decl) == TYPE_DECL)
2931 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2935 /* Called after finishing a record, union or enumeral type. */
2938 rest_of_type_compilation (type, toplev)
2942 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2943 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2944 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2946 #ifdef SDB_DEBUGGING_INFO
2947 if (write_symbols == SDB_DEBUG)
2948 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2952 /* This is called from finish_function (within yyparse)
2953 after each top-level definition is parsed.
2954 It is supposed to compile that function or variable
2955 and output the assembler code for it.
2956 After we return, the tree storage is freed. */
2959 rest_of_compilation (decl)
2963 int start_time = get_run_time ();
2965 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2966 to be restored after we finish compiling the function
2967 (for use when compiling inline calls to this function). */
2968 tree saved_block_tree = 0;
2969 /* Likewise, for DECL_ARGUMENTS. */
2970 tree saved_arguments = 0;
2973 /* If we are reconsidering an inline function
2974 at the end of compilation, skip the stuff for making it inline. */
2976 if (DECL_SAVED_INSNS (decl) == 0)
2981 /* If requested, consider whether to make this function inline. */
2982 if (DECL_INLINE (decl) || flag_inline_functions)
2983 TIMEVAR (integration_time,
2985 lose = function_cannot_inline_p (decl);
2986 if (lose || ! optimize)
2988 if (warn_inline && DECL_INLINE (decl))
2989 warning_with_decl (decl, lose);
2990 DECL_ABSTRACT_ORIGIN (decl) = 0;
2991 /* Don't really compile an extern inline function.
2992 If we can't make it inline, pretend
2993 it was only declared. */
2994 if (DECL_EXTERNAL (decl))
2996 DECL_INITIAL (decl) = 0;
2997 goto exit_rest_of_compilation;
3001 /* ??? Note that this has the effect of making it look
3002 like "inline" was specified for a function if we choose
3003 to inline it. This isn't quite right, but it's
3004 probably not worth the trouble to fix. */
3005 inlinable = DECL_INLINE (decl) = 1;
3008 insns = get_insns ();
3010 /* Dump the rtl code if we are dumping rtl. */
3014 open_dump_file (".rtl", decl_printable_name (decl, 2));
3016 if (DECL_SAVED_INSNS (decl))
3017 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3019 close_dump_file (print_rtl, insns);
3022 /* If we can, defer compiling inlines until EOF.
3023 save_for_inline_copying can be extremely expensive. */
3024 if (inlinable && ! decl_function_context (decl))
3025 DECL_DEFER_OUTPUT (decl) = 1;
3027 /* If function is inline, and we don't yet know whether to
3028 compile it by itself, defer decision till end of compilation.
3029 finish_compilation will call rest_of_compilation again
3030 for those functions that need to be output. Also defer those
3031 functions that we are supposed to defer. We cannot defer
3032 functions containing nested functions since the nested function
3033 data is in our non-saved obstack. We cannot defer nested
3034 functions for the same reason. */
3036 /* If this is a nested inline, remove ADDRESSOF now so we can
3037 finish compiling ourselves. Otherwise, wait until EOF.
3038 We have to do this because the purge_addressof transformation
3039 changes the DECL_RTL for many variables, which confuses integrate. */
3042 if (decl_function_context (decl))
3043 purge_addressof (insns);
3045 DECL_DEFER_OUTPUT (decl) = 1;
3048 if (! current_function_contains_functions
3049 && ! decl_function_context (decl)
3050 && (DECL_DEFER_OUTPUT (decl)
3051 || (DECL_INLINE (decl)
3052 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3053 && ! flag_keep_inline_functions)
3054 || DECL_EXTERNAL (decl)))))
3056 DECL_DEFER_OUTPUT (decl) = 1;
3058 /* If -Wreturn-type, we have to do a bit of compilation.
3059 However, if we just fall through we will call
3060 save_for_inline_copying() which results in excessive
3061 memory use. Instead, we just want to call
3062 jump_optimize() to figure out whether or not we can fall
3063 off the end of the function; we do the minimum amount of
3064 work necessary to make that safe. And, we set optimize
3065 to zero to keep jump_optimize from working too hard. */
3066 if (warn_return_type)
3068 int saved_optimize = optimize;
3070 find_exception_handler_labels ();
3071 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3072 !JUMP_AFTER_REGSCAN);
3073 optimize = saved_optimize;
3076 #ifdef DWARF_DEBUGGING_INFO
3077 /* Generate the DWARF info for the "abstract" instance
3078 of a function which we may later generate inlined and/or
3079 out-of-line instances of. */
3080 if (write_symbols == DWARF_DEBUG)
3082 set_decl_abstract_flags (decl, 1);
3083 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3084 set_decl_abstract_flags (decl, 0);
3087 #ifdef DWARF2_DEBUGGING_INFO
3088 /* Generate the DWARF2 info for the "abstract" instance
3089 of a function which we may later generate inlined and/or
3090 out-of-line instances of. */
3091 if (write_symbols == DWARF2_DEBUG)
3093 set_decl_abstract_flags (decl, 1);
3094 TIMEVAR (symout_time, dwarf2out_decl (decl));
3095 set_decl_abstract_flags (decl, 0);
3098 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3099 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3100 goto exit_rest_of_compilation;
3103 /* If we have to compile the function now, save its rtl and subdecls
3104 so that its compilation will not affect what others get. */
3105 if (inlinable || DECL_DEFER_OUTPUT (decl))
3107 #ifdef DWARF_DEBUGGING_INFO
3108 /* Generate the DWARF info for the "abstract" instance of
3109 a function which we will generate an out-of-line instance
3110 of almost immediately (and which we may also later generate
3111 various inlined instances of). */
3112 if (write_symbols == DWARF_DEBUG)
3114 set_decl_abstract_flags (decl, 1);
3115 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3116 set_decl_abstract_flags (decl, 0);
3119 #ifdef DWARF2_DEBUGGING_INFO
3120 /* Generate the DWARF2 info for the "abstract" instance of
3121 a function which we will generate an out-of-line instance
3122 of almost immediately (and which we may also later generate
3123 various inlined instances of). */
3124 if (write_symbols == DWARF2_DEBUG)
3126 set_decl_abstract_flags (decl, 1);
3127 TIMEVAR (symout_time, dwarf2out_decl (decl));
3128 set_decl_abstract_flags (decl, 0);
3131 saved_block_tree = DECL_INITIAL (decl);
3132 saved_arguments = DECL_ARGUMENTS (decl);
3133 TIMEVAR (integration_time, save_for_inline_copying (decl));
3134 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3137 /* If specified extern inline but we aren't inlining it, we are
3139 if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
3140 goto exit_rest_of_compilation;
3143 if (! DECL_DEFER_OUTPUT (decl))
3144 TREE_ASM_WRITTEN (decl) = 1;
3146 /* Now that integrate will no longer see our rtl, we need not distinguish
3147 between the return value of this function and the return value of called
3149 rtx_equal_function_value_matters = 0;
3151 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3152 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3154 goto exit_rest_of_compilation;
3157 /* Emit code to get eh context, if needed. */
3161 /* If we are doing position-independent code generation, now
3162 is the time to output special prologues and epilogues.
3163 We do not want to do this earlier, because it just clutters
3164 up inline functions with meaningless insns. */
3169 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3170 Note that that may have been done above, in save_for_inline_copying.
3171 The call to resume_temporary_allocation near the end of this function
3172 goes back to the usual state of affairs. This must be done after
3173 we've built up any unwinders for exception handling, and done
3174 the FINALIZE_PIC work, if necessary. */
3176 rtl_in_current_obstack ();
3178 insns = get_insns ();
3180 /* Copy any shared structure that should not be shared. */
3182 unshare_all_rtl (insns);
3184 #ifdef SETJMP_VIA_SAVE_AREA
3185 /* This must be performed before virutal register instantiation. */
3186 if (current_function_calls_alloca)
3187 optimize_save_area_alloca (insns);
3190 /* Instantiate all virtual registers. */
3192 instantiate_virtual_regs (current_function_decl, get_insns ());
3194 /* See if we have allocated stack slots that are not directly addressable.
3195 If so, scan all the insns and create explicit address computation
3196 for all references to such slots. */
3197 /* fixup_stack_slots (); */
3199 /* Find all the EH handlers. */
3200 find_exception_handler_labels ();
3202 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3203 are initialized and to compute whether control can drop off the end
3205 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3206 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3207 JUMP_AFTER_REGSCAN));
3209 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3210 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3211 goto exit_rest_of_compilation;
3213 /* Dump rtl code after jump, if we are doing that. */
3216 dump_rtl (".jump", decl, print_rtl, insns);
3218 /* Perform common subexpression elimination.
3219 Nonzero value from `cse_main' means that jumps were simplified
3220 and some code may now be unreachable, so do
3221 jump optimization again. */
3226 open_dump_file (".cse", decl_printable_name (decl, 2));
3228 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3230 if (flag_thread_jumps)
3231 /* Hacks by tiemann & kenner. */
3232 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3234 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3236 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3238 if (tem || optimize > 1)
3239 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3241 !JUMP_AFTER_REGSCAN));
3243 /* Dump rtl code after cse, if we are doing that. */
3246 close_dump_file (print_rtl, insns);
3249 purge_addressof (insns);
3250 reg_scan (insns, max_reg_num (), 1);
3253 dump_rtl (".addressof", decl, print_rtl, insns);
3255 /* Perform global cse. */
3257 if (optimize > 0 && flag_gcse)
3260 open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl)));
3262 TIMEVAR (gcse_time, gcse_main (insns, rtl_dump_file));
3265 close_dump_file (print_rtl, insns);
3267 /* Move constant computations out of loops. */
3272 open_dump_file (".loop", decl_printable_name (decl, 2));
3277 if (flag_rerun_loop_opt)
3279 /* We only want to perform unrolling once. */
3281 loop_optimize (insns, rtl_dump_file, 0);
3284 /* The first call to loop_optimize makes some instructions
3285 trivially dead. We delete those instructions now in the
3286 hope that doing so will make the heuristics in loop work
3287 better and possibly speed up compilation. */
3288 delete_trivially_dead_insns (insns, max_reg_num ());
3290 /* The regscan pass is currently necessary as the alias
3291 analysis code depends on this information. */
3292 reg_scan (insns, max_reg_num (), 1);
3294 loop_optimize (insns, rtl_dump_file, flag_unroll_loops);
3297 /* Dump rtl code after loop opt, if we are doing that. */
3300 close_dump_file (print_rtl, insns);
3306 open_dump_file (".cse2", decl_printable_name (decl, 2));
3308 if (flag_rerun_cse_after_loop)
3310 /* Running another jump optimization pass before the second
3311 cse pass sometimes simplifies the RTL enough to allow
3312 the second CSE pass to do a better job. Jump_optimize can change
3313 max_reg_num so we must rerun reg_scan afterwards.
3314 ??? Rework to not call reg_scan so often. */
3315 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3316 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3318 JUMP_AFTER_REGSCAN));
3320 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3321 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3324 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3326 !JUMP_AFTER_REGSCAN));
3329 if (flag_thread_jumps)
3331 /* This pass of jump threading straightens out code
3332 that was kinked by loop optimization. */
3333 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3334 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3337 /* Dump rtl code after cse, if we are doing that. */
3340 close_dump_file (print_rtl, insns);
3343 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3345 if (branch_prob_dump)
3346 open_dump_file (".bp", decl_printable_name (decl, 2));
3351 branch_prob (insns, rtl_dump_file);
3354 if (branch_prob_dump)
3355 close_dump_file (print_rtl, insns);
3358 /* We are no longer anticipating cse in this function, at least. */
3360 cse_not_expected = 1;
3362 /* Now we choose between stupid (pcc-like) register allocation
3363 (if we got the -noreg switch and not -opt)
3364 and smart register allocation. */
3366 if (optimize > 0) /* Stupid allocation probably won't work */
3367 obey_regdecls = 0; /* if optimizations being done. */
3371 /* Print function header into flow dump now
3372 because doing the flow analysis makes some of the dump. */
3375 open_dump_file (".flow", decl_printable_name (decl, 2));
3381 regclass (insns, max_reg_num ());
3382 stupid_life_analysis (insns, max_reg_num (),
3388 /* Do control and data flow analysis,
3389 and write some of the results to dump file. */
3394 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
3395 life_analysis (insns, max_reg_num (), rtl_dump_file);
3398 if (warn_uninitialized)
3400 uninitialized_vars_warning (DECL_INITIAL (decl));
3401 setjmp_args_warning ();
3405 /* Dump rtl after flow analysis. */
3408 close_dump_file (print_rtl_with_bb, insns);
3410 /* If -opt, try combining insns through substitution. */
3414 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3416 /* Dump rtl code after insn combination. */
3419 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
3422 /* Register allocation pre-pass, to reduce number of moves
3423 necessary for two-address machines. */
3424 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3427 open_dump_file (".regmove", decl_printable_name (decl, 2));
3429 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
3433 close_dump_file (print_rtl_with_bb, insns);
3436 /* Print function header into sched dump now
3437 because doing the sched analysis makes some of the dump. */
3439 if (optimize > 0 && flag_schedule_insns)
3442 open_dump_file (".sched", decl_printable_name (decl, 2));
3444 /* Do control and data sched analysis,
3445 and write some of the results to dump file. */
3447 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
3449 /* Dump rtl after instruction scheduling. */
3452 close_dump_file (print_rtl_with_bb, insns);
3455 /* Unless we did stupid register allocation,
3456 allocate pseudo-regs that are used only within 1 basic block. */
3459 TIMEVAR (local_alloc_time,
3461 regclass (insns, max_reg_num ());
3465 /* Dump rtl code after allocating regs within basic blocks. */
3469 open_dump_file (".lreg", decl_printable_name (decl, 2));
3471 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
3472 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
3474 close_dump_file (print_rtl_with_bb, insns);
3477 if (global_reg_dump)
3478 open_dump_file (".greg", decl_printable_name (decl, 2));
3480 /* Save the last label number used so far, so reorg can tell
3481 when it's safe to kill spill regs. */
3482 max_label_num_after_reload = max_label_num ();
3484 /* Unless we did stupid register allocation,
3485 allocate remaining pseudo-regs, then do the reload pass
3486 fixing up any insns that are invalid. */
3488 TIMEVAR (global_alloc_time,
3491 failure = global_alloc (rtl_dump_file);
3493 failure = reload (insns, 0, rtl_dump_file);
3496 if (global_reg_dump)
3498 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
3499 close_dump_file (print_rtl_with_bb, insns);
3503 goto exit_rest_of_compilation;
3505 reload_completed = 1;
3507 /* Do a very simple CSE pass over just the hard registers. */
3509 reload_cse_regs (insns);
3511 /* On some machines, the prologue and epilogue code, or parts thereof,
3512 can be represented as RTL. Doing so lets us schedule insns between
3513 it and the rest of the code and also allows delayed branch
3514 scheduling to operate in the epilogue. */
3516 thread_prologue_and_epilogue_insns (insns);
3518 if (optimize > 0 && flag_schedule_insns_after_reload)
3521 open_dump_file (".sched2", decl_printable_name (decl, 2));
3523 /* Do control and data sched analysis again,
3524 and write some more of the results to dump file. */
3526 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
3528 /* Dump rtl after post-reorder instruction scheduling. */
3531 close_dump_file (print_rtl_with_bb, insns);
3534 #ifdef LEAF_REGISTERS
3536 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3540 /* One more attempt to remove jumps to .+1
3541 left by dead-store-elimination.
3542 Also do cross-jumping this time
3543 and delete no-op move insns. */
3547 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
3549 !JUMP_AFTER_REGSCAN));
3551 /* Dump rtl code after jump, if we are doing that. */
3554 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
3557 /* If a machine dependent reorganization is needed, call it. */
3558 #ifdef MACHINE_DEPENDENT_REORG
3559 MACHINE_DEPENDENT_REORG (insns);
3561 if (mach_dep_reorg_dump)
3562 dump_rtl (".mach", decl, print_rtl_with_bb, insns);
3565 /* If a scheduling pass for delayed branches is to be done,
3566 call the scheduling code. */
3569 if (optimize > 0 && flag_delayed_branch)
3571 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
3574 dump_rtl (".dbr", decl, print_rtl_with_bb, insns);
3578 /* Shorten branches. */
3579 TIMEVAR (shorten_branch_time,
3581 shorten_branches (get_insns ());
3585 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
3588 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
3591 /* Now turn the rtl into assembler code. */
3593 TIMEVAR (final_time,
3598 /* Get the function's name, as described by its RTL.
3599 This may be different from the DECL_NAME name used
3600 in the source file. */
3602 x = DECL_RTL (decl);
3603 if (GET_CODE (x) != MEM)
3606 if (GET_CODE (x) != SYMBOL_REF)
3608 fnname = XSTR (x, 0);
3610 assemble_start_function (decl, fnname);
3611 final_start_function (insns, asm_out_file, optimize);
3612 final (insns, asm_out_file, optimize, 0);
3613 final_end_function (insns, asm_out_file, optimize);
3614 assemble_end_function (decl, fnname);
3616 fflush (asm_out_file);
3618 /* Release all memory held by regsets now */
3619 regset_release_memory ();
3622 /* Write DBX symbols if requested */
3624 /* Note that for those inline functions where we don't initially
3625 know for certain that we will be generating an out-of-line copy,
3626 the first invocation of this routine (rest_of_compilation) will
3627 skip over this code by doing a `goto exit_rest_of_compilation;'.
3628 Later on, finish_compilation will call rest_of_compilation again
3629 for those inline functions that need to have out-of-line copies
3630 generated. During that call, we *will* be routed past here. */
3632 #ifdef DBX_DEBUGGING_INFO
3633 if (write_symbols == DBX_DEBUG)
3634 TIMEVAR (symout_time, dbxout_function (decl));
3637 #ifdef DWARF_DEBUGGING_INFO
3638 if (write_symbols == DWARF_DEBUG)
3639 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3642 #ifdef DWARF2_DEBUGGING_INFO
3643 if (write_symbols == DWARF2_DEBUG)
3644 TIMEVAR (symout_time, dwarf2out_decl (decl));
3647 exit_rest_of_compilation:
3649 /* In case the function was not output,
3650 don't leave any temporary anonymous types
3651 queued up for sdb output. */
3652 #ifdef SDB_DEBUGGING_INFO
3653 if (write_symbols == SDB_DEBUG)
3654 sdbout_types (NULL_TREE);
3657 /* Put back the tree of subblocks and list of arguments
3658 from before we copied them.
3659 Code generation and the output of debugging info may have modified
3660 the copy, but the original is unchanged. */
3662 if (saved_block_tree != 0)
3664 DECL_INITIAL (decl) = saved_block_tree;
3665 DECL_ARGUMENTS (decl) = saved_arguments;
3666 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3669 reload_completed = 0;
3671 TIMEVAR (final_time,
3673 /* Clear out the insn_length contents now that they are no
3675 init_insn_lengths ();
3677 /* Clear out the real_constant_chain before some of the rtx's
3678 it runs through become garbage. */
3679 clear_const_double_mem ();
3681 /* Cancel the effect of rtl_in_current_obstack. */
3682 resume_temporary_allocation ();
3684 /* Show no temporary slots allocated. */
3688 /* Make sure volatile mem refs aren't considered valid operands for
3689 arithmetic insns. We must call this here if this is a nested inline
3690 function, since the above code leaves us in the init_recog state
3691 (from final.c), and the function context push/pop code does not
3692 save/restore volatile_ok.
3694 ??? Maybe it isn't necessary for expand_start_function to call this
3695 anymore if we do it here? */
3697 init_recog_no_volatile ();
3699 /* The parsing time is all the time spent in yyparse
3700 *except* what is spent in this function. */
3702 parse_time -= get_run_time () - start_time;
3705 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3706 Exit code is 35 if can't open files, 34 if fatal error,
3707 33 if had nonfatal errors, else success. */
3710 main (argc, argv, envp)
3717 int flag_print_mem = 0;
3718 int version_flag = 0;
3721 /* save in case md file wants to emit args as a comment. */
3725 p = argv[0] + strlen (argv[0]);
3726 while (p != argv[0] && p[-1] != '/'
3727 #ifdef DIR_SEPARATOR
3728 && p[-1] != DIR_SEPARATOR
3734 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
3735 /* Get rid of any avoidable limit on stack size. */
3739 /* Set the stack limit huge so that alloca does not fail. */
3740 getrlimit (RLIMIT_STACK, &rlim);
3741 rlim.rlim_cur = rlim.rlim_max;
3742 setrlimit (RLIMIT_STACK, &rlim);
3746 signal (SIGFPE, float_signal);
3749 signal (SIGPIPE, pipe_closed);
3752 decl_printable_name = decl_name;
3753 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3755 /* Initialize whether `char' is signed. */
3756 flag_signed_char = DEFAULT_SIGNED_CHAR;
3757 #ifdef DEFAULT_SHORT_ENUMS
3758 /* Initialize how much space enums occupy, by default. */
3759 flag_short_enums = DEFAULT_SHORT_ENUMS;
3762 /* Perform language-specific options intialization. */
3763 lang_init_options ();
3765 /* Scan to see what optimization level has been specified. That will
3766 determine the default value of many flags. */
3767 for (i = 1; i < argc; i++)
3769 if (!strcmp (argv[i], "-O"))
3773 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3775 /* Handle -Os, -O2, -O3, -O69, ... */
3776 char *p = &argv[i][2];
3779 if ((p[0] == 's') && (p[1] == 0))
3784 if (! (c >= '0' && c <= '9'))
3787 optimize = atoi (&argv[i][2]);
3792 /* Optimizing for size forces optimize to be no less than 2. */
3793 if (optimize_size && (optimize < 2))
3796 obey_regdecls = (optimize == 0);
3801 flag_thread_jumps = 1;
3803 flag_delayed_branch = 1;
3805 #ifdef CAN_DEBUG_WITHOUT_FP
3806 flag_omit_frame_pointer = 1;
3812 flag_cse_follow_jumps = 1;
3813 flag_cse_skip_blocks = 1;
3815 flag_expensive_optimizations = 1;
3816 flag_strength_reduce = 1;
3817 flag_rerun_cse_after_loop = 1;
3818 flag_rerun_loop_opt = 1;
3819 flag_caller_saves = 1;
3821 #ifdef INSN_SCHEDULING
3822 flag_schedule_insns = 1;
3823 flag_schedule_insns_after_reload = 1;
3830 flag_inline_functions = 1;
3833 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
3836 set_target_switch ("");
3838 #ifdef OPTIMIZATION_OPTIONS
3839 /* Allow default optimizations to be specified on a per-machine basis. */
3840 OPTIMIZATION_OPTIONS (optimize, optimize_size);
3843 /* Initialize register usage now so switches may override. */
3846 for (i = 1; i < argc; i++)
3849 /* If this is a language-specific option,
3850 decode it in a language-specific way. */
3851 for (j = 0; lang_options[j] != 0; j++)
3852 if (!strncmp (argv[i], lang_options[j],
3853 strlen (lang_options[j])))
3855 if (lang_options[j] != 0)
3856 /* If the option is valid for *some* language,
3857 treat it as valid even if this language doesn't understand it. */
3858 lang_decode_option (argv[i]);
3859 else if (argv[i][0] == '-' && argv[i][1] != 0)
3861 register char *str = argv[i] + 1;
3866 set_target_switch (&str[1]);
3867 else if (!strcmp (str, "dumpbase"))
3869 dump_base_name = argv[++i];
3871 else if (str[0] == 'd')
3873 register char *p = &str[1];
3878 branch_prob_dump = 1;
3884 global_reg_dump = 1;
3892 cse_dump = 1, cse2_dump = 1;
3899 #ifdef MACHINE_DEPENDENT_REORG
3900 mach_dep_reorg_dump = 1;
3907 branch_prob_dump = 1;
3924 global_reg_dump = 1;
3949 #ifdef MACHINE_DEPENDENT_REORG
3951 mach_dep_reorg_dump = 1;
3955 flag_print_asm_name = 1;
3979 rtl_dump_and_exit = 1;
3982 warning ("unrecognised gcc debugging option: %c", p[-1]);
3986 else if (str[0] == 'f')
3988 register char *p = &str[1];
3991 /* Some kind of -f option.
3992 P's value is the option sans `-f'.
3993 Search for it in the table of options. */
3996 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3999 if (!strcmp (p, f_options[j].string))
4001 *f_options[j].variable = f_options[j].on_value;
4002 /* A goto here would be cleaner,
4003 but breaks the vax pcc. */
4006 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4007 && ! strcmp (p+3, f_options[j].string))
4009 *f_options[j].variable = ! f_options[j].on_value;
4017 #ifdef INSN_SCHEDULING
4018 else if (!strncmp (p, "sched-verbose-",14))
4019 fix_sched_param("verbose",&p[14]);
4022 else if (!strncmp (p, "fixed-", 6))
4023 fix_register (&p[6], 1, 1);
4024 else if (!strncmp (p, "call-used-", 10))
4025 fix_register (&p[10], 0, 1);
4026 else if (!strncmp (p, "call-saved-", 11))
4027 fix_register (&p[11], 0, 0);
4029 error ("Invalid option `%s'", argv[i]);
4031 else if (str[0] == 'O')
4033 register char *p = str+1;
4037 while (*p && *p >= '0' && *p <= '9')
4042 error ("Invalid option `%s'", argv[i]);
4044 else if (!strcmp (str, "pedantic"))
4046 else if (!strcmp (str, "pedantic-errors"))
4047 flag_pedantic_errors = pedantic = 1;
4048 else if (!strcmp (str, "quiet"))
4050 else if (!strcmp (str, "version"))
4052 else if (!strcmp (str, "w"))
4053 inhibit_warnings = 1;
4054 else if (!strcmp (str, "W"))
4057 /* We save the value of warn_uninitialized, since if they put
4058 -Wuninitialized on the command line, we need to generate a
4059 warning about not using it without also specifying -O. */
4060 if (warn_uninitialized != 1)
4061 warn_uninitialized = 2;
4063 else if (str[0] == 'W')
4065 register char *p = &str[1];
4068 /* Some kind of -W option.
4069 P's value is the option sans `-W'.
4070 Search for it in the table of options. */
4073 !found && j < sizeof (W_options) / sizeof (W_options[0]);
4076 if (!strcmp (p, W_options[j].string))
4078 *W_options[j].variable = W_options[j].on_value;
4079 /* A goto here would be cleaner,
4080 but breaks the vax pcc. */
4083 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4084 && ! strcmp (p+3, W_options[j].string))
4086 *W_options[j].variable = ! W_options[j].on_value;
4093 else if (!strncmp (p, "id-clash-", 9))
4099 if (*endp >= '0' && *endp <= '9')
4103 error ("Invalid option `%s'", argv[i]);
4108 id_clash_len = atoi (str + 10);
4111 else if (!strncmp (p, "larger-than-", 12))
4113 char *endp = p + 12;
4117 if (*endp >= '0' && *endp <= '9')
4121 error ("Invalid option `%s'", argv[i]);
4122 goto larger_than_lose;
4125 warn_larger_than = 1;
4126 larger_than_size = atoi (str + 13);
4130 error ("Invalid option `%s'", argv[i]);
4132 else if (!strcmp (str, "p"))
4136 else if (!strcmp (str, "a"))
4138 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4139 warning ("`-a' option (basic block profile) not supported");
4141 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4144 else if (!strcmp (str, "ax"))
4146 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4147 warning ("`-ax' option (jump profiling) not supported");
4149 profile_block_flag = (!profile_block_flag
4150 || profile_block_flag == 2) ? 2 : 3;
4153 else if (str[0] == 'g')
4157 /* A lot of code assumes write_symbols == NO_DEBUG if the
4158 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4159 of what debugging type has been selected). This records the
4160 selected type. It is an error to specify more than one
4162 static enum debug_info_type selected_debug_type = NO_DEBUG;
4163 /* Non-zero if debugging format has been explicitly set.
4164 -g and -ggdb don't explicitly set the debugging format so
4165 -gdwarf -g3 is equivalent to -gdwarf3. */
4166 static int type_explicitly_set_p = 0;
4167 /* Table of supported debugging formats. */
4170 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
4171 constant expression, we use NO_DEBUG in its place. */
4172 enum debug_info_type debug_type;
4173 int use_extensions_p;
4174 } *da, debug_args[] = {
4175 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS },
4176 { "ggdb", NO_DEBUG, 1 },
4177 #ifdef DBX_DEBUGGING_INFO
4178 { "gstabs", DBX_DEBUG, 0 },
4179 { "gstabs+", DBX_DEBUG, 1 },
4181 #ifdef DWARF_DEBUGGING_INFO
4182 { "gdwarf", DWARF_DEBUG, 0 },
4183 { "gdwarf+", DWARF_DEBUG, 1 },
4185 #ifdef DWARF2_DEBUGGING_INFO
4186 { "gdwarf-2", DWARF2_DEBUG, 0 },
4188 #ifdef XCOFF_DEBUGGING_INFO
4189 { "gxcoff", XCOFF_DEBUG, 0 },
4190 { "gxcoff+", XCOFF_DEBUG, 1 },
4192 #ifdef SDB_DEBUGGING_INFO
4193 { "gcoff", SDB_DEBUG, 0 },
4197 /* Indexed by enum debug_info_type. */
4198 static char *debug_type_names[] = {
4199 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4202 /* Look up STR in the table. */
4203 for (da = debug_args; da->arg; da++)
4205 if (! strncmp (str, da->arg, strlen (da->arg)))
4207 enum debug_info_type type = da->debug_type;
4210 p = str + strlen (da->arg);
4211 if (*p && (*p < '0' || *p > '9'))
4215 while (*q && (*q >= '0' && *q <= '9'))
4220 if (len > 1 && !strncmp (str, "gdwarf", len))
4222 error ("use -gdwarf -g%d for DWARF v1, level %d",
4225 error ("use -gdwarf-2 for DWARF v2");
4229 level = 2; /* default debugging info level */
4230 if (*q || level > 3)
4232 warning ("invalid debug level specification in option: `-%s'",
4234 /* ??? This error message is incorrect in the case of
4236 warning ("no debugging information will be generated");
4240 if (type == NO_DEBUG)
4242 type = PREFERRED_DEBUGGING_TYPE;
4243 if (len > 1 && strncmp (str, "ggdb", len) == 0)
4245 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4246 type = DWARF2_DEBUG;
4248 #ifdef DBX_DEBUGGING_INFO
4255 if (type == NO_DEBUG)
4256 warning ("`-%s' not supported by this configuration of GCC",
4259 /* Does it conflict with an already selected type? */
4260 if (type_explicitly_set_p
4261 /* -g/-ggdb don't conflict with anything */
4262 && da->debug_type != NO_DEBUG
4263 && type != selected_debug_type)
4264 warning ("`-%s' ignored, conflicts with `-g%s'",
4265 str, debug_type_names[(int) selected_debug_type]);
4268 /* If the format has already been set, -g/-ggdb
4269 only change the debug level. */
4270 if (type_explicitly_set_p
4271 && da->debug_type == NO_DEBUG)
4272 ; /* don't change debugging type */
4275 selected_debug_type = type;
4276 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4278 write_symbols = (level == 0
4280 : selected_debug_type);
4281 use_gnu_debug_info_extensions = da->use_extensions_p;
4282 debug_info_level = (enum debug_info_level) level;
4288 warning ("`-%s' not supported by this configuration of GCC",
4291 else if (!strcmp (str, "o"))
4293 asm_file_name = argv[++i];
4295 else if (str[0] == 'G')
4297 g_switch_set = TRUE;
4298 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
4300 else if (!strncmp (str, "aux-info", 8))
4302 flag_gen_aux_info = 1;
4303 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
4306 error ("Invalid option `%s'", argv[i]);
4308 else if (argv[i][0] == '+')
4309 error ("Invalid option `%s'", argv[i]);
4314 /* Checker uses the frame pointer. */
4315 if (flag_check_memory_usage)
4316 flag_omit_frame_pointer = 0;
4320 /* Inlining does not work if not optimizing,
4321 so force it not to be done. */
4325 /* The c_decode_option and lang_decode_option functions set
4326 this to `2' if -Wall is used, so we can avoid giving out
4327 lots of errors for people who don't realize what -Wall does. */
4328 if (warn_uninitialized == 1)
4329 warning ("-Wuninitialized is not supported without -O");
4332 #ifdef OVERRIDE_OPTIONS
4333 /* Some machines may reject certain combinations of options. */
4337 if (exceptions_via_longjmp == 2)
4339 #ifdef DWARF2_UNWIND_INFO
4340 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4342 exceptions_via_longjmp = 1;
4346 if (profile_block_flag == 3)
4348 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4349 profile_block_flag = 2;
4352 /* Unrolling all loops implies that standard loop unrolling must also
4354 if (flag_unroll_all_loops)
4355 flag_unroll_loops = 1;
4356 /* Loop unrolling requires that strength_reduction be on also. Silently
4357 turn on strength reduction here if it isn't already on. Also, the loop
4358 unrolling code assumes that cse will be run after loop, so that must
4359 be turned on also. */
4360 if (flag_unroll_loops)
4362 flag_strength_reduce = 1;
4363 flag_rerun_cse_after_loop = 1;
4366 /* Warn about options that are not supported on this machine. */
4367 #ifndef INSN_SCHEDULING
4368 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4369 warning ("instruction scheduling not supported on this target machine");
4372 if (flag_delayed_branch)
4373 warning ("this target machine does not have delayed branches");
4376 /* If we are in verbose mode, write out the version and maybe all the
4377 option flags in use. */
4380 print_version (stderr, "");
4382 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4385 compile_file (filename);
4387 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4390 char *lim = (char *) sbrk (0);
4392 fprintf (stderr, "Data size %d.\n",
4393 lim - (char *) &environ);
4398 system ("ps -l 1>&2");
4401 #endif /* not USG */
4404 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4407 exit (FATAL_EXIT_CODE);
4409 exit (FATAL_EXIT_CODE);
4410 exit (SUCCESS_EXIT_CODE);
4414 /* Decode -m switches. */
4416 /* Here is a table, controlled by the tm.h file, listing each -m switch
4417 and which bits in `target_switches' it should set or clear.
4418 If VALUE is positive, it is bits to set.
4419 If VALUE is negative, -VALUE is bits to clear.
4420 (The sign bit is not used so there is no confusion.) */
4422 struct {char *name; int value;} target_switches []
4425 /* This table is similar, but allows the switch to have a value. */
4427 #ifdef TARGET_OPTIONS
4428 struct {char *prefix; char ** variable;} target_options []
4432 /* Decode the switch -mNAME. */
4435 set_target_switch (name)
4441 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4442 if (!strcmp (target_switches[j].name, name))
4444 if (target_switches[j].value < 0)
4445 target_flags &= ~-target_switches[j].value;
4447 target_flags |= target_switches[j].value;
4451 #ifdef TARGET_OPTIONS
4453 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4455 int len = strlen (target_options[j].prefix);
4456 if (!strncmp (target_options[j].prefix, name, len))
4458 *target_options[j].variable = name + len;
4465 error ("Invalid option `%s'", name);
4468 /* Print version information to FILE.
4469 Each line begins with INDENT (for the case where FILE is the
4470 assembler output file). */
4473 print_version (file, indent)
4477 fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4478 language_string, version_string);
4479 fprintf (file, " (%s)", TARGET_NAME);
4482 #define __VERSION__ "[unknown]"
4484 fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4486 fprintf (file, " compiled by CC.\n");
4490 /* Print an option value and return the adjusted position in the line.
4491 ??? We don't handle error returns from fprintf (disk full); presumably
4492 other code will catch a disk full though. */
4495 print_single_switch (file, pos, max, indent, sep, term, type, name)
4498 char *indent, *sep, *term, *type, *name;
4500 /* The ultrix fprintf returns 0 on success, so compute the result we want
4501 here since we need it for the following test. */
4502 int len = strlen (sep) + strlen (type) + strlen (name);
4507 fprintf (file, "%s", term);
4512 fprintf (file, "%s", indent);
4513 pos = strlen (indent);
4515 fprintf (file, "%s%s%s", sep, type, name);
4520 /* Print active target switches to FILE.
4521 POS is the current cursor position and MAX is the size of a "line".
4522 Each line begins with INDENT and ends with TERM.
4523 Each switch is separated from the next by SEP. */
4526 print_switch_values (file, pos, max, indent, sep, term)
4529 char *indent, *sep, *term;
4534 /* Print the options as passed. */
4536 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4537 "options passed: ", "");
4539 for (p = &save_argv[1]; *p != NULL; p++)
4543 if (strcmp (*p, "-o") == 0)
4549 if (strcmp (*p, "-quiet") == 0)
4551 if (strcmp (*p, "-version") == 0)
4556 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4559 fprintf (file, "%s", term);
4561 /* Print the -f and -m options that have been enabled.
4562 We don't handle language specific options but printing argv
4565 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4566 "options enabled: ", "");
4568 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4569 if (*f_options[j].variable == f_options[j].on_value)
4570 pos = print_single_switch (file, pos, max, indent, sep, term,
4571 "-f", f_options[j].string);
4573 /* Print target specific options. */
4575 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4576 if (target_switches[j].name[0] != '\0'
4577 && target_switches[j].value > 0
4578 && ((target_switches[j].value & target_flags)
4579 == target_switches[j].value))
4581 pos = print_single_switch (file, pos, max, indent, sep, term,
4582 "-m", target_switches[j].name);
4585 #ifdef TARGET_OPTIONS
4586 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4587 if (*target_options[j].variable != NULL)
4590 sprintf (prefix, "-m%s", target_options[j].prefix);
4591 pos = print_single_switch (file, pos, max, indent, sep, term,
4592 prefix, *target_options[j].variable);
4596 fprintf (file, "%s", term);
4599 /* Record the beginning of a new source file, named FILENAME. */
4602 debug_start_source_file (filename)
4603 register char *filename;
4605 #ifdef DBX_DEBUGGING_INFO
4606 if (write_symbols == DBX_DEBUG)
4607 dbxout_start_new_source_file (filename);
4609 #ifdef DWARF_DEBUGGING_INFO
4610 if (debug_info_level == DINFO_LEVEL_VERBOSE
4611 && write_symbols == DWARF_DEBUG)
4612 dwarfout_start_new_source_file (filename);
4613 #endif /* DWARF_DEBUGGING_INFO */
4614 #ifdef DWARF2_DEBUGGING_INFO
4615 if (debug_info_level == DINFO_LEVEL_VERBOSE
4616 && write_symbols == DWARF2_DEBUG)
4617 dwarf2out_start_source_file (filename);
4618 #endif /* DWARF2_DEBUGGING_INFO */
4619 #ifdef SDB_DEBUGGING_INFO
4620 if (write_symbols == SDB_DEBUG)
4621 sdbout_start_new_source_file (filename);
4625 /* Record the resumption of a source file. LINENO is the line number in
4626 the source file we are returning to. */
4629 debug_end_source_file (lineno)
4630 register unsigned lineno;
4632 #ifdef DBX_DEBUGGING_INFO
4633 if (write_symbols == DBX_DEBUG)
4634 dbxout_resume_previous_source_file ();
4636 #ifdef DWARF_DEBUGGING_INFO
4637 if (debug_info_level == DINFO_LEVEL_VERBOSE
4638 && write_symbols == DWARF_DEBUG)
4639 dwarfout_resume_previous_source_file (lineno);
4640 #endif /* DWARF_DEBUGGING_INFO */
4641 #ifdef DWARF2_DEBUGGING_INFO
4642 if (debug_info_level == DINFO_LEVEL_VERBOSE
4643 && write_symbols == DWARF2_DEBUG)
4644 dwarf2out_end_source_file ();
4645 #endif /* DWARF2_DEBUGGING_INFO */
4646 #ifdef SDB_DEBUGGING_INFO
4647 if (write_symbols == SDB_DEBUG)
4648 sdbout_resume_previous_source_file ();
4652 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4653 the tail part of the directive line, i.e. the part which is past the
4654 initial whitespace, #, whitespace, directive-name, whitespace part. */
4657 debug_define (lineno, buffer)
4658 register unsigned lineno;
4659 register char *buffer;
4661 #ifdef DWARF_DEBUGGING_INFO
4662 if (debug_info_level == DINFO_LEVEL_VERBOSE
4663 && write_symbols == DWARF_DEBUG)
4664 dwarfout_define (lineno, buffer);
4665 #endif /* DWARF_DEBUGGING_INFO */
4666 #ifdef DWARF2_DEBUGGING_INFO
4667 if (debug_info_level == DINFO_LEVEL_VERBOSE
4668 && write_symbols == DWARF2_DEBUG)
4669 dwarf2out_define (lineno, buffer);
4670 #endif /* DWARF2_DEBUGGING_INFO */
4673 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4674 the tail part of the directive line, i.e. the part which is past the
4675 initial whitespace, #, whitespace, directive-name, whitespace part. */
4678 debug_undef (lineno, buffer)
4679 register unsigned lineno;
4680 register char *buffer;
4682 #ifdef DWARF_DEBUGGING_INFO
4683 if (debug_info_level == DINFO_LEVEL_VERBOSE
4684 && write_symbols == DWARF_DEBUG)
4685 dwarfout_undef (lineno, buffer);
4686 #endif /* DWARF_DEBUGGING_INFO */
4687 #ifdef DWARF2_DEBUGGING_INFO
4688 if (debug_info_level == DINFO_LEVEL_VERBOSE
4689 && write_symbols == DWARF2_DEBUG)
4690 dwarf2out_undef (lineno, buffer);
4691 #endif /* DWARF2_DEBUGGING_INFO */