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 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_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 to perform full register move optimization passes. This is the
501 int flag_regmove = 0;
503 /* Nonzero for -fwritable-strings:
504 store string constants in data segment and don't uniquize them. */
506 int flag_writable_strings = 0;
508 /* Nonzero means don't put addresses of constant functions in registers.
509 Used for compiling the Unix kernel, where strange substitutions are
510 done on the assembly output. */
512 int flag_no_function_cse = 0;
514 /* Nonzero for -fomit-frame-pointer:
515 don't make a frame pointer in simple functions that don't require one. */
517 int flag_omit_frame_pointer = 0;
519 /* Nonzero means place each function into its own section on those platforms
520 which support arbitrary section names and unlimited numbers of sections. */
522 int flag_function_sections = 0;
524 /* Nonzero to inhibit use of define_optimization peephole opts. */
526 int flag_no_peephole = 0;
528 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
529 operations in the interest of optimization. For example it allows
530 GCC to assume arguments to sqrt are nonnegative numbers, allowing
531 faster code for sqrt to be generated. */
533 int flag_fast_math = 0;
535 /* Nonzero means all references through pointers are volatile. */
539 /* Nonzero means treat all global and extern variables as global. */
541 int flag_volatile_global;
543 /* Nonzero means just do syntax checking; don't output anything. */
545 int flag_syntax_only = 0;
547 /* Nonzero means perform global cse. */
549 static int flag_gcse;
551 /* Nonzero means to rerun cse after loop optimization. This increases
552 compilation time about 20% and picks up a few more common expressions. */
554 static int flag_rerun_cse_after_loop;
556 /* Nonzero means to run loop optimizations twice. */
558 int flag_rerun_loop_opt;
560 /* Nonzero for -finline-functions: ok to inline functions that look like
561 good inline candidates. */
563 int flag_inline_functions;
565 /* Nonzero for -fkeep-inline-functions: even if we make a function
566 go inline everywhere, keep its definition around for debugging
569 int flag_keep_inline_functions;
571 /* Nonzero means that functions will not be inlined. */
575 /* Nonzero means that we should emit static const variables
576 regardless of whether or not optimization is turned on. */
578 int flag_keep_static_consts = 1;
580 /* Nonzero means we should be saving declaration info into a .X file. */
582 int flag_gen_aux_info = 0;
584 /* Specified name of aux-info file. */
586 static char *aux_info_file_name;
588 /* Nonzero means make the text shared if supported. */
590 int flag_shared_data;
592 /* Nonzero means schedule into delayed branch slots if supported. */
594 int flag_delayed_branch;
596 /* Nonzero if we are compiling pure (sharable) code.
597 Value is 1 if we are doing reasonable (i.e. simple
598 offset into offset table) pic. Value is 2 if we can
599 only perform register offsets. */
603 /* Nonzero means generate extra code for exception handling and enable
604 exception handling. */
608 /* Nonzero means use the new model for exception handling. Replaces
609 -DNEW_EH_MODEL as a compile option. */
611 int flag_new_exceptions = 0;
613 /* Nonzero means don't place uninitialized global data in common storage
618 /* Nonzero means pretend it is OK to examine bits of target floats,
619 even if that isn't true. The resulting code will have incorrect constants,
620 but the same series of instructions that the native compiler would make. */
622 int flag_pretend_float;
624 /* Nonzero means change certain warnings into errors.
625 Usually these are warnings about failure to conform to some standard. */
627 int flag_pedantic_errors = 0;
629 /* flag_schedule_insns means schedule insns within basic blocks (before
631 flag_schedule_insns_after_reload means schedule insns after
634 int flag_schedule_insns = 0;
635 int flag_schedule_insns_after_reload = 0;
638 /* The following flags have effect only for scheduling before register
641 flag_schedule_interblock means schedule insns accross basic blocks.
642 flag_schedule_speculative means allow speculative motion of non-load insns.
643 flag_schedule_speculative_load means allow speculative motion of some
645 flag_schedule_speculative_load_dangerous allows speculative motion of more
648 int flag_schedule_interblock = 1;
649 int flag_schedule_speculative = 1;
650 int flag_schedule_speculative_load = 0;
651 int flag_schedule_speculative_load_dangerous = 0;
653 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
654 by a cheaper branch, on a count register. */
655 int flag_branch_on_count_reg;
659 /* -finhibit-size-directive inhibits output of .size for ELF.
660 This is used only for compiling crtstuff.c,
661 and it may be extended to other effects
662 needed for crtstuff.c on other systems. */
663 int flag_inhibit_size_directive = 0;
665 /* -fverbose-asm causes extra commentary information to be produced in
666 the generated assembly code (to make it more readable). This option
667 is generally only of use to those who actually need to read the
668 generated assembly code (perhaps while debugging the compiler itself).
669 -fno-verbose-asm, the default, causes the extra information
670 to be omitted and is useful when comparing two assembler files. */
672 int flag_verbose_asm = 0;
674 /* -dA causes debug commentary information to be produced in
675 the generated assembly code (to make it more readable). This option
676 is generally only of use to those who actually need to read the
677 generated assembly code (perhaps while debugging the compiler itself).
678 Currently, this switch is only used by dwarfout.c; however, it is intended
679 to be a catchall for printing debug information in the assembler file. */
681 int flag_debug_asm = 0;
683 /* -fgnu-linker specifies use of the GNU linker for initializations.
684 (Or, more generally, a linker that handles initializations.)
685 -fno-gnu-linker says that collect2 will be used. */
687 int flag_gnu_linker = 0;
689 int flag_gnu_linker = 1;
692 /* Tag all structures with __attribute__(packed) */
693 int flag_pack_struct = 0;
695 /* Emit code to check for stack overflow; also may cause large objects
696 to be allocated dynamically. */
697 int flag_stack_check;
699 /* -fcheck-memory-usage causes extra code to be generated in order to check
700 memory accesses. This is used by a detector of bad memory accesses such
702 int flag_check_memory_usage = 0;
704 /* -fprefix-function-name causes function name to be prefixed. This
705 can be used with -fcheck-memory-usage to isolate code compiled with
706 -fcheck-memory-usage. */
707 int flag_prefix_function_name = 0;
709 /* 0 if pointer arguments may alias each other. True in C.
710 1 if pointer arguments may not alias each other but may alias
712 2 if pointer arguments may not alias each other and may not
713 alias global variables. True in Fortran.
714 This defaults to 0 for C. */
715 int flag_argument_noalias = 0;
717 /* Nonzero if we should do (language-dependent) alias analysis.
718 Typically, this analysis will assume that expressions of certain
719 types do not alias expressions of certain other types. Only used
720 if alias analysis (in general) is enabled. */
721 int flag_strict_aliasing = 0;
723 extern int flag_dump_unnumbered;
725 /* Table of language-independent -f options.
726 STRING is the option name. VARIABLE is the address of the variable.
727 ON_VALUE is the value to store in VARIABLE
728 if `-fSTRING' is seen as an option.
729 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
731 struct { char *string; int *variable; int on_value;} f_options[] =
733 {"float-store", &flag_float_store, 1},
734 {"volatile", &flag_volatile, 1},
735 {"volatile-global", &flag_volatile_global, 1},
736 {"defer-pop", &flag_defer_pop, 1},
737 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
738 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
739 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
740 {"expensive-optimizations", &flag_expensive_optimizations, 1},
741 {"thread-jumps", &flag_thread_jumps, 1},
742 {"strength-reduce", &flag_strength_reduce, 1},
743 {"unroll-loops", &flag_unroll_loops, 1},
744 {"unroll-all-loops", &flag_unroll_all_loops, 1},
745 {"move-all-movables", &flag_move_all_movables, 1},
746 {"reduce-all-givs", &flag_reduce_all_givs, 1},
747 {"writable-strings", &flag_writable_strings, 1},
748 {"peephole", &flag_no_peephole, 0},
749 {"force-mem", &flag_force_mem, 1},
750 {"force-addr", &flag_force_addr, 1},
751 {"function-cse", &flag_no_function_cse, 0},
752 {"inline-functions", &flag_inline_functions, 1},
753 {"keep-inline-functions", &flag_keep_inline_functions, 1},
754 {"inline", &flag_no_inline, 0},
755 {"keep-static-consts", &flag_keep_static_consts, 1},
756 {"syntax-only", &flag_syntax_only, 1},
757 {"shared-data", &flag_shared_data, 1},
758 {"caller-saves", &flag_caller_saves, 1},
759 {"pcc-struct-return", &flag_pcc_struct_return, 1},
760 {"reg-struct-return", &flag_pcc_struct_return, 0},
761 {"delayed-branch", &flag_delayed_branch, 1},
762 {"gcse", &flag_gcse, 1},
763 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
764 {"rerun-loop-opt", &flag_rerun_loop_opt, 1},
765 {"pretend-float", &flag_pretend_float, 1},
766 {"schedule-insns", &flag_schedule_insns, 1},
767 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
769 {"sched-interblock",&flag_schedule_interblock, 1},
770 {"sched-spec",&flag_schedule_speculative, 1},
771 {"sched-spec-load",&flag_schedule_speculative_load, 1},
772 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1},
773 {"branch-count-reg",&flag_branch_on_count_reg, 1},
775 {"pic", &flag_pic, 1},
776 {"PIC", &flag_pic, 2},
777 {"exceptions", &flag_exceptions, 1},
778 {"new-exceptions", &flag_new_exceptions, 1},
779 {"sjlj-exceptions", &exceptions_via_longjmp, 1},
780 {"asynchronous-exceptions", &asynchronous_exceptions, 1},
781 {"profile-arcs", &profile_arc_flag, 1},
782 {"test-coverage", &flag_test_coverage, 1},
783 {"branch-probabilities", &flag_branch_probabilities, 1},
784 {"fast-math", &flag_fast_math, 1},
785 {"common", &flag_no_common, 0},
786 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
787 {"function-sections", &flag_function_sections, 1},
788 {"verbose-asm", &flag_verbose_asm, 1},
789 {"gnu-linker", &flag_gnu_linker, 1},
790 {"regmove", &flag_regmove, 1},
791 {"optimize-register-move", &flag_regmove, 1},
792 {"pack-struct", &flag_pack_struct, 1},
793 {"stack-check", &flag_stack_check, 1},
794 {"argument-alias", &flag_argument_noalias, 0},
795 {"argument-noalias", &flag_argument_noalias, 1},
796 {"argument-noalias-global", &flag_argument_noalias, 2},
797 {"strict-aliasing", &flag_strict_aliasing, 1},
798 {"check-memory-usage", &flag_check_memory_usage, 1},
799 {"prefix-function-name", &flag_prefix_function_name, 1},
800 {"dump-unnumbered", &flag_dump_unnumbered, 1}
803 /* Table of language-specific options. */
805 char *lang_options[] =
808 "-fallow-single-precision",
810 "-fsigned-bitfields",
811 "-funsigned-bitfields",
812 "-fno-signed-bitfields",
813 "-fno-unsigned-bitfields",
817 "-fno-unsigned-char",
833 "-fno-cond-mismatch",
834 "-fdollars-in-identifiers",
835 "-fno-dollars-in-identifiers",
844 "-Wbad-function-cast",
845 "-Wno-bad-function-cast",
849 "-Wno-char-subscripts",
860 "-Wimplicit-function-declaration",
861 "-Wno-implicit-function-declaration",
862 "-Werror-implicit-function-declaration",
870 "-Wno-missing-braces",
871 "-Wmissing-declarations",
872 "-Wno-missing-declarations",
873 "-Wmissing-prototypes",
874 "-Wno-missing-prototypes",
876 "-Wno-nested-externs",
880 "-Wno-pointer-arith",
882 "-Wno-redundant-decls",
886 "-Wno-unknown-pragmas",
887 "-Wstrict-prototypes",
888 "-Wno-strict-prototypes",
896 "-Wno-write-strings",
898 /* these are for obj c */
909 "-print-objc-runtime-info",
911 /* These are for languages with USE_CPPLIB. */
932 /* Options controlling warnings */
934 /* Don't print warning messages. -w. */
936 int inhibit_warnings = 0;
938 /* Print various extra warnings. -W. */
940 int extra_warnings = 0;
942 /* Treat warnings as errors. -Werror. */
944 int warnings_are_errors = 0;
946 /* Nonzero to warn about unused local variables. */
950 /* Nonzero to warn about variables used before they are initialized. */
952 int warn_uninitialized;
954 /* Nonzero means warn about all declarations which shadow others. */
958 /* Warn if a switch on an enum fails to have a case for every enum value. */
962 /* Nonzero means warn about function definitions that default the return type
963 or that use a null return and have a return-type other than void. */
965 int warn_return_type;
967 /* Nonzero means warn about pointer casts that increase the required
968 alignment of the target type (and might therefore lead to a crash
969 due to a misaligned access). */
973 /* Nonzero means warn about any identifiers that match in the first N
974 characters. The value N is in `id_clash_len'. */
977 unsigned id_clash_len;
979 /* Nonzero means warn about any objects definitions whose size is larger
980 than N bytes. Also want about function definitions whose returned
981 values are larger than N bytes. The value N is in `larger_than_size'. */
983 int warn_larger_than;
984 unsigned larger_than_size;
986 /* Nonzero means warn if inline function is too large. */
990 /* Warn if a function returns an aggregate,
991 since there are often incompatible calling conventions for doing this. */
993 int warn_aggregate_return;
995 /* Likewise for -W. */
997 struct { char *string; int *variable; int on_value;} W_options[] =
999 {"unused", &warn_unused, 1},
1000 {"error", &warnings_are_errors, 1},
1001 {"shadow", &warn_shadow, 1},
1002 {"switch", &warn_switch, 1},
1003 {"aggregate-return", &warn_aggregate_return, 1},
1004 {"cast-align", &warn_cast_align, 1},
1005 {"uninitialized", &warn_uninitialized, 1},
1006 {"inline", &warn_inline, 1}
1009 /* Output files for assembler code (real compiler output)
1010 and debugging dumps. */
1013 FILE *aux_info_file;
1014 FILE *rtl_dump_file = NULL;
1016 /* Time accumulators, to count the total time spent in various passes. */
1020 int integration_time;
1026 int branch_prob_time;
1031 int local_alloc_time;
1032 int global_alloc_time;
1037 int shorten_branch_time;
1043 /* Return time used so far, in microseconds. */
1053 #else /* not BeOS */
1054 #if defined (_WIN32) && !defined (__CYGWIN32__)
1058 return (clock() * 1000);
1059 #else /* not _WIN32 */
1065 tick = 1000000 / sysconf(_SC_CLK_TCK);
1067 return (tms.tms_utime + tms.tms_stime) * tick;
1073 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1074 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1077 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1079 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1083 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1088 struct rusage rusage;
1089 getrusage (0, &rusage);
1090 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1091 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1098 int proc_system_time;
1099 int child_user_time;
1100 int child_system_time;
1102 times ((void *) &vms_times);
1103 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1107 #endif /* _SC_CLK_TCK */
1109 #endif /* __BEOS__ */
1112 #define TIMEVAR(VAR, BODY) \
1113 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1116 print_time (str, total)
1121 "time in %s: %d.%06d\n",
1122 str, total / 1000000, total % 1000000);
1125 /* Count an error or warning. Return 1 if the message should be printed. */
1128 count_error (warningp)
1131 if (warningp && inhibit_warnings)
1134 if (warningp && !warnings_are_errors)
1138 static int warning_message = 0;
1140 if (warningp && !warning_message)
1142 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
1143 warning_message = 1;
1151 /* Print a fatal error message. NAME is the text.
1152 Also include a system error message based on `errno'. */
1155 pfatal_with_name (name)
1158 fprintf (stderr, "%s: ", progname);
1160 exit (FATAL_EXIT_CODE);
1164 fatal_io_error (name)
1167 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
1168 exit (FATAL_EXIT_CODE);
1171 /* Called to give a better error message for a bad insn rather than
1172 just calling abort(). */
1175 fatal_insn (message, insn)
1182 fflush (asm_out_file);
1184 fflush (aux_info_file);
1185 if (rtl_dump_file != NULL)
1186 fflush (rtl_dump_file);
1192 /* Called to give a better error message when we don't have an insn to match
1193 what we are looking for or if the insn's constraints aren't satisfied,
1194 rather than just calling abort(). */
1197 fatal_insn_not_found (insn)
1200 if (INSN_CODE (insn) < 0)
1201 fatal_insn ("internal error--unrecognizable insn:", insn);
1203 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1206 /* This is the default decl_printable_name function. */
1209 decl_name (decl, verbosity)
1213 return IDENTIFIER_POINTER (DECL_NAME (decl));
1216 static int need_error_newline;
1218 /* Function of last error message;
1219 more generally, function such that if next error message is in it
1220 then we don't have to mention the function name. */
1221 static tree last_error_function = NULL;
1223 /* Used to detect when input_file_stack has changed since last described. */
1224 static int last_error_tick;
1226 /* Called when the start of a function definition is parsed,
1227 this function prints on stderr the name of the function. */
1230 announce_function (decl)
1235 if (rtl_dump_and_exit)
1236 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1238 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1240 need_error_newline = 1;
1241 last_error_function = current_function_decl;
1245 /* The default function to print out name of current function that caused
1249 default_print_error_function (file)
1252 if (last_error_function != current_function_decl)
1254 char *kind = "function";
1255 if (current_function_decl != 0
1256 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1260 fprintf (stderr, "%s: ", file);
1262 if (current_function_decl == NULL)
1263 fprintf (stderr, "At top level:\n");
1266 char *name = (*decl_printable_name) (current_function_decl, 2);
1267 fprintf (stderr, "In %s `%s':\n", kind, name);
1270 last_error_function = current_function_decl;
1274 /* Called by report_error_function to print out function name.
1275 * Default may be overridden by language front-ends. */
1277 void (*print_error_function) PROTO((char *)) = default_print_error_function;
1279 /* Prints out, if necessary, the name of the current function
1280 that caused an error. Called from all error and warning functions. */
1283 report_error_function (file)
1286 struct file_stack *p;
1288 if (need_error_newline)
1290 fprintf (stderr, "\n");
1291 need_error_newline = 0;
1294 (*print_error_function) (file);
1296 if (input_file_stack && input_file_stack->next != 0
1297 && input_file_stack_tick != last_error_tick
1298 && file == input_filename)
1300 fprintf (stderr, "In file included");
1301 for (p = input_file_stack->next; p; p = p->next)
1303 fprintf (stderr, " from %s:%d", p->name, p->line);
1305 fprintf (stderr, ",\n ");
1307 fprintf (stderr, ":\n");
1308 last_error_tick = input_file_stack_tick;
1312 /* Print a message. */
1315 vmessage (prefix, s, ap)
1321 fprintf (stderr, "%s: ", prefix);
1323 vfprintf (stderr, s, ap);
1326 /* Print a message relevant to line LINE of file FILE. */
1329 v_message_with_file_and_line (file, line, prefix, s, ap)
1337 fprintf (stderr, "%s:%d: ", file, line);
1339 fprintf (stderr, "%s: ", progname);
1341 vmessage (prefix, s, ap);
1342 fputc ('\n', stderr);
1345 /* Print a message relevant to the given DECL. */
1348 v_message_with_decl (decl, prefix, s, ap)
1356 fprintf (stderr, "%s:%d: ",
1357 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1360 fprintf (stderr, "%s: ", prefix);
1362 /* Do magic to get around lack of varargs support for insertion
1363 of arguments into existing list. We know that the decl is first;
1364 we ass_u_me that it will be printed with "%s". */
1366 for (p = s; *p; ++p)
1370 if (*(p + 1) == '%')
1377 if (p > s) /* Print the left-hand substring. */
1379 char fmt[sizeof "%.255s"];
1382 if (width > 255L) width = 255L; /* arbitrary */
1383 sprintf (fmt, "%%.%lds", width);
1384 fprintf (stderr, fmt, s);
1387 if (*p == '%') /* Print the name. */
1389 char *n = (DECL_NAME (decl)
1390 ? (*decl_printable_name) (decl, 2)
1396 if (ISALPHA (*(p - 1) & 0xFF))
1401 if (*p) /* Print the rest of the message. */
1402 vmessage ((char *)NULL, p, ap);
1404 fputc ('\n', stderr);
1407 /* Figure file and line of the given INSN. */
1410 file_and_line_for_asm (insn, pfile, pline)
1415 rtx body = PATTERN (insn);
1418 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1419 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1420 asmop = SET_SRC (body);
1421 else if (GET_CODE (body) == ASM_OPERANDS)
1423 else if (GET_CODE (body) == PARALLEL
1424 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1425 asmop = SET_SRC (XVECEXP (body, 0, 0));
1426 else if (GET_CODE (body) == PARALLEL
1427 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1428 asmop = XVECEXP (body, 0, 0);
1434 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1435 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1439 *pfile = input_filename;
1444 /* Report an error at line LINE of file FILE. */
1447 v_error_with_file_and_line (file, line, s, ap)
1454 report_error_function (file);
1455 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1459 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1471 file = va_arg (ap, char *);
1472 line = va_arg (ap, int);
1473 s = va_arg (ap, char *);
1476 v_error_with_file_and_line (file, line, s, ap);
1480 /* Report an error at the declaration DECL.
1481 S is a format string which uses %s to substitute the declaration
1482 name; subsequent substitutions are a la printf. */
1485 v_error_with_decl (decl, s, ap)
1491 report_error_function (DECL_SOURCE_FILE (decl));
1492 v_message_with_decl (decl, (char *)NULL, s, ap);
1496 error_with_decl VPROTO((tree decl, char *s, ...))
1507 decl = va_arg (ap, tree);
1508 s = va_arg (ap, char *);
1511 v_error_with_decl (decl, s, ap);
1515 /* Report an error at the line number of the insn INSN.
1516 This is used only when INSN is an `asm' with operands,
1517 and each ASM_OPERANDS records its own source file and line. */
1520 v_error_for_asm (insn, s, ap)
1529 file_and_line_for_asm (insn, &file, &line);
1530 report_error_function (file);
1531 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1535 error_for_asm VPROTO((rtx insn, char *s, ...))
1546 insn = va_arg (ap, rtx);
1547 s = va_arg (ap, char *);
1550 v_error_for_asm (insn, s, ap);
1554 /* Report an error at the current line number. */
1561 v_error_with_file_and_line (input_filename, lineno, s, ap);
1565 error VPROTO((char *s, ...))
1575 s = va_arg (ap, char *);
1582 /* Report a fatal error at the current line number. */
1590 exit (FATAL_EXIT_CODE);
1594 fatal VPROTO((char *s, ...))
1604 s = va_arg (ap, char *);
1611 /* Report a warning at line LINE of file FILE. */
1614 v_warning_with_file_and_line (file, line, s, ap)
1620 if (count_error (1))
1622 report_error_function (file);
1623 v_message_with_file_and_line (file, line, "warning", s, ap);
1628 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1640 file = va_arg (ap, char *);
1641 line = va_arg (ap, int);
1642 s = va_arg (ap, char *);
1645 v_warning_with_file_and_line (file, line, s, ap);
1649 /* Report a warning at the declaration DECL.
1650 S is a format string which uses %s to substitute the declaration
1651 name; subsequent substitutions are a la printf. */
1654 v_warning_with_decl (decl, s, ap)
1659 if (count_error (1))
1661 report_error_function (DECL_SOURCE_FILE (decl));
1662 v_message_with_decl (decl, "warning", s, ap);
1667 warning_with_decl VPROTO((tree decl, char *s, ...))
1678 decl = va_arg (ap, tree);
1679 s = va_arg (ap, char *);
1682 v_warning_with_decl (decl, s, ap);
1686 /* Report a warning at the line number of the insn INSN.
1687 This is used only when INSN is an `asm' with operands,
1688 and each ASM_OPERANDS records its own source file and line. */
1691 v_warning_for_asm (insn, s, ap)
1696 if (count_error (1))
1701 file_and_line_for_asm (insn, &file, &line);
1702 report_error_function (file);
1703 v_message_with_file_and_line (file, line, "warning", s, ap);
1708 warning_for_asm VPROTO((rtx insn, char *s, ...))
1719 insn = va_arg (ap, rtx);
1720 s = va_arg (ap, char *);
1723 v_warning_for_asm (insn, s, ap);
1727 /* Report a warning at the current line number. */
1734 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1738 warning VPROTO((char *s, ...))
1748 s = va_arg (ap, char *);
1755 /* These functions issue either warnings or errors depending on
1756 -pedantic-errors. */
1763 if (flag_pedantic_errors)
1770 pedwarn VPROTO((char *s, ...))
1780 s = va_arg (ap, char *);
1788 v_pedwarn_with_decl (decl, s, ap)
1793 /* We don't want -pedantic-errors to cause the compilation to fail from
1794 "errors" in system header files. Sometimes fixincludes can't fix what's
1795 broken (eg: unsigned char bitfields - fixing it may change the alignment
1796 which will cause programs to mysteriously fail because the C library
1797 or kernel uses the original layout). There's no point in issuing a
1798 warning either, it's just unnecessary noise. */
1800 if (! DECL_IN_SYSTEM_HEADER (decl))
1802 if (flag_pedantic_errors)
1803 v_error_with_decl (decl, s, ap);
1805 v_warning_with_decl (decl, s, ap);
1810 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1821 decl = va_arg (ap, tree);
1822 s = va_arg (ap, char *);
1825 v_pedwarn_with_decl (decl, s, ap);
1830 v_pedwarn_with_file_and_line (file, line, s, ap)
1836 if (flag_pedantic_errors)
1837 v_error_with_file_and_line (file, line, s, ap);
1839 v_warning_with_file_and_line (file, line, s, ap);
1843 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1855 file = va_arg (ap, char *);
1856 line = va_arg (ap, int);
1857 s = va_arg (ap, char *);
1860 v_pedwarn_with_file_and_line (file, line, s, ap);
1864 /* Apologize for not implementing some feature. */
1873 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1875 fprintf (stderr, "%s: ", progname);
1876 vmessage ("sorry, not implemented", s, ap);
1877 fputc ('\n', stderr);
1881 sorry VPROTO((char *s, ...))
1891 s = va_arg (ap, char *);
1898 /* Apologize for not implementing some feature, then quit. */
1901 v_really_sorry (s, ap)
1907 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1909 fprintf (stderr, "%s: ", progname);
1910 vmessage ("sorry, not implemented", s, ap);
1911 fatal (" (fatal)\n");
1915 really_sorry VPROTO((char *s, ...))
1925 s = va_arg (ap, char *);
1928 v_really_sorry (s, ap);
1932 /* More 'friendly' abort that prints the line and file.
1933 config.h can #define abort fancy_abort if you like that sort of thing.
1935 I don't think this is actually a good idea.
1936 Other sorts of crashes will look a certain way.
1937 It is a good thing if crashes from calling abort look the same way.
1943 fatal ("internal gcc abort");
1946 /* This calls abort and is used to avoid problems when abort if a macro.
1947 It is used when we need to pass the address of abort. */
1955 /* When `malloc.c' is compiled with `rcheck' defined,
1956 it calls this function to report clobberage. */
1965 /* Same as `malloc' but report error if no memory available. */
1971 register char *value;
1976 value = (char *) malloc (size);
1978 fatal ("virtual memory exhausted");
1982 /* Same as `calloc' but report error if no memory available. */
1985 xcalloc (size1, size2)
1986 unsigned size1, size2;
1988 register char *value;
1990 if (size1 == 0 || size2 == 0)
1993 value = (char *) calloc (size1, size2);
1995 fatal ("virtual memory exhausted");
2000 /* Same as `realloc' but report error if no memory available.
2001 Also handle null PTR even if the vendor realloc gets it wrong. */
2004 xrealloc (ptr, size)
2014 ? (char *) realloc (ptr, size)
2015 : (char *) malloc (size));
2018 fatal ("virtual memory exhausted");
2023 /* Same as `strdup' but report error if no memory available. */
2029 register char *result = (char *) malloc (strlen (s) + 1);
2032 fatal ("virtual memory exhausted");
2037 /* Return the logarithm of X, base 2, considering X unsigned,
2038 if X is a power of 2. Otherwise, returns -1.
2040 This should be used via the `exact_log2' macro. */
2044 register unsigned HOST_WIDE_INT x;
2046 register int log = 0;
2047 /* Test for 0 or a power of 2. */
2048 if (x == 0 || x != (x & -x))
2050 while ((x >>= 1) != 0)
2055 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2056 If X is 0, return -1.
2058 This should be used via the floor_log2 macro. */
2062 register unsigned HOST_WIDE_INT x;
2064 register int log = -1;
2071 static int float_handler_set;
2073 jmp_buf float_handler;
2075 /* Signals actually come here. */
2078 float_signal (signo)
2079 /* If this is missing, some compilers complain. */
2080 int signo ATTRIBUTE_UNUSED;
2082 if (float_handled == 0)
2084 #if defined (USG) || defined (hpux)
2085 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2088 signal (SIGFPE, float_signal);
2089 longjmp (float_handler, 1);
2092 /* Specify where to longjmp to when a floating arithmetic error happens.
2093 If HANDLER is 0, it means don't handle the errors any more. */
2096 set_float_handler (handler)
2099 float_handled = (handler != 0);
2101 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2103 if (float_handled && ! float_handler_set)
2105 signal (SIGFPE, float_signal);
2106 float_handler_set = 1;
2110 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2111 error happens, pushing the previous specification into OLD_HANDLER.
2112 Return an indication of whether there was a previous handler in effect. */
2115 push_float_handler (handler, old_handler)
2116 jmp_buf handler, old_handler;
2118 int was_handled = float_handled;
2122 bcopy ((char *) float_handler, (char *) old_handler,
2123 sizeof (float_handler));
2125 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2129 /* Restore the previous specification of whether and where to longjmp to
2130 when a floating arithmetic error happens. */
2133 pop_float_handler (handled, handler)
2137 float_handled = handled;
2139 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2142 /* Handler for SIGPIPE. */
2146 /* If this is missing, some compilers complain. */
2147 int signo ATTRIBUTE_UNUSED;
2149 fatal ("output pipe has been closed");
2152 /* Strip off a legitimate source ending from the input string NAME of
2153 length LEN. Rather than having to know the names used by all of
2154 our front ends, we strip off an ending of a period followed by
2155 up to five characters. (Java uses ".class".) */
2158 strip_off_ending (name, len)
2163 for (i = 2; i < 6 && len > i; i++)
2165 if (name[len - i] == '.')
2167 name[len - i] = '\0';
2173 /* Output a quoted string. */
2176 output_quoted_string (asm_file, string)
2180 #ifdef OUTPUT_QUOTED_STRING
2181 OUTPUT_QUOTED_STRING (asm_file, string);
2185 putc ('\"', asm_file);
2186 while ((c = *string++) != 0)
2188 if (c == '\"' || c == '\\')
2189 putc ('\\', asm_file);
2192 putc ('\"', asm_file);
2196 /* Output a file name in the form wanted by System V. */
2199 output_file_directive (asm_file, input_name)
2203 int len = strlen (input_name);
2204 char *na = input_name + len;
2206 /* NA gets INPUT_NAME sans directory names. */
2207 while (na > input_name)
2214 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2215 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2217 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2218 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2220 fprintf (asm_file, "\t.file\t");
2221 output_quoted_string (asm_file, na);
2222 fputc ('\n', asm_file);
2227 /* Routine to build language identifier for object file. */
2230 output_lang_identify (asm_out_file)
2233 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2234 char *s = (char *) alloca (len);
2235 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2236 ASM_OUTPUT_LABEL (asm_out_file, s);
2239 /* Routine to open a dump file. */
2241 open_dump_file (suffix, function_name)
2243 char *function_name;
2250 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2252 if (rtl_dump_file != NULL)
2253 fclose (rtl_dump_file);
2255 strcpy (dumpname, dump_base_name);
2256 strcat (dumpname, suffix);
2258 rtl_dump_file = fopen (dumpname, "a");
2260 if (rtl_dump_file == NULL)
2261 pfatal_with_name (dumpname);
2266 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2272 /* Routine to close a dump file. */
2274 close_dump_file (func, insns)
2275 void (*func) PROTO ((FILE *, rtx));
2282 func (rtl_dump_file, insns);
2284 fflush (rtl_dump_file);
2285 fclose (rtl_dump_file);
2287 rtl_dump_file = NULL;
2293 /* Routine to dump rtl into a file. */
2295 dump_rtl (suffix, decl, func, insns)
2298 void (*func) PROTO ((FILE *, rtx));
2301 open_dump_file (suffix, decl_printable_name (decl, 2));
2302 close_dump_file (func, insns);
2305 /* Routine to empty a dump file. */
2307 clean_dump_file (suffix)
2312 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2314 strcpy (dumpname, dump_base_name);
2315 strcat (dumpname, suffix);
2317 rtl_dump_file = fopen (dumpname, "w");
2319 if (rtl_dump_file == NULL)
2320 pfatal_with_name (dumpname);
2324 fclose (rtl_dump_file);
2325 rtl_dump_file = NULL;
2331 /* Compile an entire file of output from cpp, named NAME.
2332 Write a file of assembly output and various debugging dumps. */
2341 int name_specified = name != 0;
2343 if (dump_base_name == 0)
2344 dump_base_name = name ? name : "gccdump";
2348 integration_time = 0;
2354 branch_prob_time = 0;
2359 local_alloc_time = 0;
2360 global_alloc_time = 0;
2365 shorten_branch_time = 0;
2371 /* Initialize data in various passes. */
2375 name = init_parse (name);
2377 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2378 || debug_info_level == DINFO_LEVEL_VERBOSE
2379 || flag_test_coverage);
2381 init_decl_processing ();
2390 if (flag_caller_saves)
2391 init_caller_save ();
2393 /* If auxiliary info generation is desired, open the output file.
2394 This goes in the same directory as the source file--unlike
2395 all the other output files. */
2396 if (flag_gen_aux_info)
2398 aux_info_file = fopen (aux_info_file_name, "w");
2399 if (aux_info_file == 0)
2400 pfatal_with_name (aux_info_file_name);
2403 /* Clear the dump files file. */
2405 clean_dump_file (".rtl");
2407 clean_dump_file (".jump");
2409 clean_dump_file (".addressof");
2411 clean_dump_file (".cse");
2413 clean_dump_file (".loop");
2415 clean_dump_file (".cse2");
2416 if (branch_prob_dump)
2417 clean_dump_file (".bp");
2419 clean_dump_file (".flow");
2421 clean_dump_file (".combine");
2423 clean_dump_file (".regmove");
2425 clean_dump_file (".sched");
2427 clean_dump_file (".lreg");
2428 if (global_reg_dump)
2429 clean_dump_file (".greg");
2431 clean_dump_file (".sched2");
2433 clean_dump_file (".jump2");
2436 clean_dump_file (".dbr");
2439 clean_dump_file (".gcse");
2442 clean_dump_file (".stack");
2444 #ifdef MACHINE_DEPENDENT_REORG
2445 if (mach_dep_reorg_dump)
2446 clean_dump_file (".mach");
2449 /* Open assembler code output file. */
2451 if (! name_specified && asm_file_name == 0)
2452 asm_out_file = stdout;
2455 int len = strlen (dump_base_name);
2456 register char *dumpname = (char *) xmalloc (len + 6);
2457 strcpy (dumpname, dump_base_name);
2458 strip_off_ending (dumpname, len);
2459 strcat (dumpname, ".s");
2460 if (asm_file_name == 0)
2462 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2463 strcpy (asm_file_name, dumpname);
2465 if (!strcmp (asm_file_name, "-"))
2466 asm_out_file = stdout;
2468 asm_out_file = fopen (asm_file_name, "w");
2469 if (asm_out_file == 0)
2470 pfatal_with_name (asm_file_name);
2473 #ifdef IO_BUFFER_SIZE
2474 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2475 _IOFBF, IO_BUFFER_SIZE);
2478 input_filename = name;
2480 /* Put an entry on the input file stack for the main input file. */
2482 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2483 input_file_stack->next = 0;
2484 input_file_stack->name = input_filename;
2486 /* Perform language-specific initialization.
2487 This may set main_input_filename. */
2490 /* If the input doesn't start with a #line, use the input name
2491 as the official input file name. */
2492 if (main_input_filename == 0)
2493 main_input_filename = name;
2495 ASM_FILE_START (asm_out_file);
2497 #ifdef ASM_COMMENT_START
2498 if (flag_verbose_asm)
2500 /* Print the list of options in effect. */
2501 print_version (asm_out_file, ASM_COMMENT_START);
2502 print_switch_values (asm_out_file, 0, MAX_LINE,
2503 ASM_COMMENT_START, " ", "\n");
2504 /* Add a blank line here so it appears in assembler output but not
2506 fprintf (asm_out_file, "\n");
2510 /* Output something to inform GDB that this compilation was by GCC. */
2511 #ifndef ASM_IDENTIFY_GCC
2512 fprintf (asm_out_file, "gcc2_compiled.:\n");
2514 ASM_IDENTIFY_GCC (asm_out_file);
2517 /* Output something to identify which front-end produced this file. */
2518 #ifdef ASM_IDENTIFY_LANGUAGE
2519 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2522 #ifndef ASM_OUTPUT_SECTION_NAME
2523 if (flag_function_sections)
2525 warning ("-ffunction-sections not supported for this target.");
2526 flag_function_sections = 0;
2530 if (flag_function_sections
2531 && (profile_flag || profile_block_flag))
2533 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2534 flag_function_sections = 0;
2537 if (flag_function_sections && write_symbols != NO_DEBUG)
2538 warning ("-ffunction-sections may affect debugging on some targets.");
2540 /* ??? Note: There used to be a conditional here
2541 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2542 This was to guarantee separation between gcc_compiled. and
2543 the first function, for the sake of dbx on Suns.
2544 However, having the extra zero here confused the Emacs
2545 code for unexec, and might confuse other programs too.
2546 Therefore, I took out that change.
2547 In future versions we should find another way to solve
2548 that dbx problem. -- rms, 23 May 93. */
2550 /* Don't let the first function fall at the same address
2551 as gcc_compiled., if profiling. */
2552 if (profile_flag || profile_block_flag)
2554 /* It's best if we can write a nop here since some
2555 assemblers don't tolerate zeros in the text section. */
2556 if (insn_template[CODE_FOR_nop] != 0)
2557 output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR);
2559 assemble_zeros (UNITS_PER_WORD);
2562 /* If dbx symbol table desired, initialize writing it
2563 and output the predefined types. */
2564 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2565 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2566 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2569 #ifdef SDB_DEBUGGING_INFO
2570 if (write_symbols == SDB_DEBUG)
2571 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2574 #ifdef DWARF_DEBUGGING_INFO
2575 if (write_symbols == DWARF_DEBUG)
2576 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2578 #ifdef DWARF2_UNWIND_INFO
2579 if (dwarf2out_do_frame ())
2580 dwarf2out_frame_init ();
2582 #ifdef DWARF2_DEBUGGING_INFO
2583 if (write_symbols == DWARF2_DEBUG)
2584 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2587 /* Initialize yet another pass. */
2589 init_final (main_input_filename);
2590 init_branch_prob (dump_base_name);
2592 start_time = get_run_time ();
2594 /* Call the parser, which parses the entire file
2595 (calling rest_of_compilation for each function). */
2597 if (yyparse () != 0)
2599 if (errorcount == 0)
2600 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2602 /* In case there were missing closebraces,
2603 get us back to the global binding level. */
2604 while (! global_bindings_p ())
2608 output_func_start_profiler ();
2610 /* Compilation is now finished except for writing
2611 what's left of the symbol table output. */
2613 parse_time += get_run_time () - start_time;
2615 parse_time -= integration_time;
2616 parse_time -= varconst_time;
2618 globals = getdecls ();
2620 /* Really define vars that have had only a tentative definition.
2621 Really output inline functions that must actually be callable
2622 and have not been output so far. */
2625 int len = list_length (globals);
2626 tree *vec = (tree *) alloca (sizeof (tree) * len);
2631 /* Process the decls in reverse order--earliest first.
2632 Put them into VEC from back to front, then take out from front. */
2634 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2635 vec[len - i - 1] = decl;
2637 for (i = 0; i < len; i++)
2641 /* We're not deferring this any longer. */
2642 DECL_DEFER_OUTPUT (decl) = 0;
2644 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2645 && incomplete_decl_finalize_hook != 0)
2646 (*incomplete_decl_finalize_hook) (decl);
2649 /* Now emit any global variables or functions that we have been putting
2650 off. We need to loop in case one of the things emitted here
2651 references another one which comes earlier in the list. */
2655 for (i = 0; i < len; i++)
2659 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2662 /* Don't write out static consts, unless we still need them.
2664 We also keep static consts if not optimizing (for debugging),
2665 unless the user specified -fno-keep-static-consts.
2666 ??? They might be better written into the debug information.
2667 This is possible when using DWARF.
2669 A language processor that wants static constants to be always
2670 written out (even if it is not used) is responsible for
2671 calling rest_of_decl_compilation itself. E.g. the C front-end
2672 calls rest_of_decl_compilation from finish_decl.
2673 One motivation for this is that is conventional in some
2674 environments to write things like:
2675 static const char rcsid[] = "... version string ...";
2676 intending to force the string to be in the executable.
2678 A language processor that would prefer to have unneeded
2679 static constants "optimized away" would just defer writing
2680 them out until here. E.g. C++ does this, because static
2681 constants are often defined in header files.
2683 ??? A tempting alternative (for both C and C++) would be
2684 to force a constant to be written if and only if it is
2685 defined in a main file, as opposed to an include file. */
2687 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2688 && (! TREE_READONLY (decl)
2689 || TREE_PUBLIC (decl)
2690 || (!optimize && flag_keep_static_consts)
2691 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2694 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2697 if (TREE_CODE (decl) == FUNCTION_DECL
2698 && DECL_INITIAL (decl) != 0
2699 && DECL_SAVED_INSNS (decl) != 0
2700 && (flag_keep_inline_functions
2701 || TREE_PUBLIC (decl)
2702 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2705 temporary_allocation ();
2706 output_inline_function (decl);
2707 permanent_allocation (1);
2712 /* Now that all possible functions have been output, we can dump
2713 the exception table. */
2715 output_exception_table ();
2717 for (i = 0; i < len; i++)
2721 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2722 && ! TREE_ASM_WRITTEN (decl))
2723 /* Cancel the RTL for this decl so that, if debugging info
2724 output for global variables is still to come,
2725 this one will be omitted. */
2726 DECL_RTL (decl) = NULL;
2728 /* Warn about any function
2729 declared static but not defined.
2730 We don't warn about variables,
2731 because many programs have static variables
2732 that exist only to get some text into the object file. */
2733 if (TREE_CODE (decl) == FUNCTION_DECL
2735 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2736 && DECL_INITIAL (decl) == 0
2737 && DECL_EXTERNAL (decl)
2738 && ! DECL_ARTIFICIAL (decl)
2739 && ! TREE_PUBLIC (decl))
2741 pedwarn_with_decl (decl,
2742 "`%s' declared `static' but never defined");
2743 /* This symbol is effectively an "extern" declaration now. */
2744 TREE_PUBLIC (decl) = 1;
2745 assemble_external (decl);
2748 /* Warn about static fns or vars defined but not used,
2749 but not about inline functions or static consts
2750 since defining those in header files is normal practice. */
2752 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2753 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2754 && ! DECL_IN_SYSTEM_HEADER (decl)
2755 && ! DECL_EXTERNAL (decl)
2756 && ! TREE_PUBLIC (decl)
2757 && ! TREE_USED (decl)
2758 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2759 /* The TREE_USED bit for file-scope decls
2760 is kept in the identifier, to handle multiple
2761 external decls in different scopes. */
2762 && ! TREE_USED (DECL_NAME (decl)))
2763 warning_with_decl (decl, "`%s' defined but not used");
2765 #ifdef SDB_DEBUGGING_INFO
2766 /* The COFF linker can move initialized global vars to the end.
2767 And that can screw up the symbol ordering.
2768 By putting the symbols in that order to begin with,
2769 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2770 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2771 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2772 && ! DECL_EXTERNAL (decl)
2773 && DECL_RTL (decl) != 0)
2774 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2776 /* Output COFF information for non-global
2777 file-scope initialized variables. */
2778 if (write_symbols == SDB_DEBUG
2779 && TREE_CODE (decl) == VAR_DECL
2780 && DECL_INITIAL (decl)
2781 && ! DECL_EXTERNAL (decl)
2782 && DECL_RTL (decl) != 0
2783 && GET_CODE (DECL_RTL (decl)) == MEM)
2784 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2785 #endif /* SDB_DEBUGGING_INFO */
2786 #ifdef DWARF_DEBUGGING_INFO
2787 /* Output DWARF information for file-scope tentative data object
2788 declarations, file-scope (extern) function declarations (which
2789 had no corresponding body) and file-scope tagged type declarations
2790 and definitions which have not yet been forced out. */
2792 if (write_symbols == DWARF_DEBUG
2793 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2794 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2796 #ifdef DWARF2_DEBUGGING_INFO
2797 /* Output DWARF2 information for file-scope tentative data object
2798 declarations, file-scope (extern) function declarations (which
2799 had no corresponding body) and file-scope tagged type declarations
2800 and definitions which have not yet been forced out. */
2802 if (write_symbols == DWARF2_DEBUG
2803 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2804 TIMEVAR (symout_time, dwarf2out_decl (decl));
2809 /* Write out any pending weak symbol declarations. */
2813 /* Do dbx symbols */
2814 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2815 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2816 TIMEVAR (symout_time,
2818 dbxout_finish (asm_out_file, main_input_filename);
2822 #ifdef DWARF_DEBUGGING_INFO
2823 if (write_symbols == DWARF_DEBUG)
2824 TIMEVAR (symout_time,
2830 #ifdef DWARF2_UNWIND_INFO
2831 if (dwarf2out_do_frame ())
2832 dwarf2out_frame_finish ();
2835 #ifdef DWARF2_DEBUGGING_INFO
2836 if (write_symbols == DWARF2_DEBUG)
2837 TIMEVAR (symout_time,
2839 dwarf2out_finish ();
2843 /* Output some stuff at end of file if nec. */
2845 end_final (dump_base_name);
2847 if (branch_prob_dump)
2848 open_dump_file (".bp", NULL);
2850 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
2852 if (branch_prob_dump)
2853 close_dump_file (NULL, NULL_RTX);
2856 ASM_FILE_END (asm_out_file);
2859 /* Language-specific end of compilation actions. */
2863 /* Close the dump files. */
2865 if (flag_gen_aux_info)
2867 fclose (aux_info_file);
2869 unlink (aux_info_file_name);
2874 open_dump_file (".combine", NULL);
2875 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
2876 close_dump_file (NULL, NULL_RTX);
2879 /* Close non-debugging input and output files. Take special care to note
2880 whether fclose returns an error, since the pages might still be on the
2881 buffer chain while the file is open. */
2885 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2886 fatal_io_error (asm_file_name);
2888 /* Print the times. */
2892 fprintf (stderr,"\n");
2893 print_time ("parse", parse_time);
2895 print_time ("integration", integration_time);
2896 print_time ("jump", jump_time);
2897 print_time ("cse", cse_time);
2898 print_time ("gcse", gcse_time);
2899 print_time ("loop", loop_time);
2900 print_time ("cse2", cse2_time);
2901 print_time ("branch-prob", branch_prob_time);
2902 print_time ("flow", flow_time);
2903 print_time ("combine", combine_time);
2904 print_time ("regmove", regmove_time);
2905 print_time ("sched", sched_time);
2906 print_time ("local-alloc", local_alloc_time);
2907 print_time ("global-alloc", global_alloc_time);
2908 print_time ("sched2", sched2_time);
2910 print_time ("dbranch", dbr_sched_time);
2912 print_time ("shorten-branch", shorten_branch_time);
2913 print_time ("stack-reg", stack_reg_time);
2914 print_time ("final", final_time);
2915 print_time ("varconst", varconst_time);
2916 print_time ("symout", symout_time);
2917 print_time ("dump", dump_time);
2921 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2922 and TYPE_DECL nodes.
2924 This does nothing for local (non-static) variables.
2925 Otherwise, it sets up the RTL and outputs any assembler code
2926 (label definition, storage allocation and initialization).
2928 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2929 the assembler symbol name to be used. TOP_LEVEL is nonzero
2930 if this declaration is not within a function. */
2933 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2939 /* Declarations of variables, and of functions defined elsewhere. */
2941 /* The most obvious approach, to put an #ifndef around where
2942 this macro is used, doesn't work since it's inside a macro call. */
2943 #ifndef ASM_FINISH_DECLARE_OBJECT
2944 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2947 /* Forward declarations for nested functions are not "external",
2948 but we need to treat them as if they were. */
2949 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2950 || TREE_CODE (decl) == FUNCTION_DECL)
2951 TIMEVAR (varconst_time,
2953 make_decl_rtl (decl, asmspec, top_level);
2954 /* Initialized extern variable exists to be replaced
2955 with its value, or represents something that will be
2956 output in another file. */
2957 if (! (TREE_CODE (decl) == VAR_DECL
2958 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2959 && DECL_INITIAL (decl) != 0
2960 && DECL_INITIAL (decl) != error_mark_node))
2961 /* Don't output anything
2962 when a tentative file-scope definition is seen.
2963 But at end of compilation, do output code for them. */
2964 if (! (! at_end && top_level
2965 && (DECL_INITIAL (decl) == 0
2966 || DECL_INITIAL (decl) == error_mark_node)))
2967 assemble_variable (decl, top_level, at_end, 0);
2968 if (decl == last_assemble_variable_decl)
2970 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2974 else if (DECL_REGISTER (decl) && asmspec != 0)
2976 if (decode_reg_name (asmspec) >= 0)
2978 DECL_RTL (decl) = 0;
2979 make_decl_rtl (decl, asmspec, top_level);
2982 error ("invalid register name `%s' for register variable", asmspec);
2984 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2985 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2986 && TREE_CODE (decl) == TYPE_DECL)
2987 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2989 #ifdef SDB_DEBUGGING_INFO
2990 else if (write_symbols == SDB_DEBUG && top_level
2991 && TREE_CODE (decl) == TYPE_DECL)
2992 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2996 /* Called after finishing a record, union or enumeral type. */
2999 rest_of_type_compilation (type, toplev)
3003 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3004 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3005 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3007 #ifdef SDB_DEBUGGING_INFO
3008 if (write_symbols == SDB_DEBUG)
3009 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3013 /* This is called from finish_function (within yyparse)
3014 after each top-level definition is parsed.
3015 It is supposed to compile that function or variable
3016 and output the assembler code for it.
3017 After we return, the tree storage is freed. */
3020 rest_of_compilation (decl)
3024 int start_time = get_run_time ();
3026 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3027 to be restored after we finish compiling the function
3028 (for use when compiling inline calls to this function). */
3029 tree saved_block_tree = 0;
3030 /* Likewise, for DECL_ARGUMENTS. */
3031 tree saved_arguments = 0;
3034 /* If we are reconsidering an inline function
3035 at the end of compilation, skip the stuff for making it inline. */
3037 if (DECL_SAVED_INSNS (decl) == 0)
3042 /* If requested, consider whether to make this function inline. */
3043 if (DECL_INLINE (decl) || flag_inline_functions)
3044 TIMEVAR (integration_time,
3046 lose = function_cannot_inline_p (decl);
3047 if (lose || ! optimize)
3049 if (warn_inline && DECL_INLINE (decl))
3050 warning_with_decl (decl, lose);
3051 DECL_ABSTRACT_ORIGIN (decl) = 0;
3052 /* Don't really compile an extern inline function.
3053 If we can't make it inline, pretend
3054 it was only declared. */
3055 if (DECL_EXTERNAL (decl))
3057 DECL_INITIAL (decl) = 0;
3058 goto exit_rest_of_compilation;
3062 /* ??? Note that this has the effect of making it look
3063 like "inline" was specified for a function if we choose
3064 to inline it. This isn't quite right, but it's
3065 probably not worth the trouble to fix. */
3066 inlinable = DECL_INLINE (decl) = 1;
3069 insns = get_insns ();
3071 /* Dump the rtl code if we are dumping rtl. */
3075 open_dump_file (".rtl", decl_printable_name (decl, 2));
3077 if (DECL_SAVED_INSNS (decl))
3078 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3080 close_dump_file (print_rtl, insns);
3083 /* If we can, defer compiling inlines until EOF.
3084 save_for_inline_copying can be extremely expensive. */
3085 if (inlinable && ! decl_function_context (decl))
3086 DECL_DEFER_OUTPUT (decl) = 1;
3088 /* If function is inline, and we don't yet know whether to
3089 compile it by itself, defer decision till end of compilation.
3090 finish_compilation will call rest_of_compilation again
3091 for those functions that need to be output. Also defer those
3092 functions that we are supposed to defer. We cannot defer
3093 functions containing nested functions since the nested function
3094 data is in our non-saved obstack. We cannot defer nested
3095 functions for the same reason. */
3097 /* If this is a nested inline, remove ADDRESSOF now so we can
3098 finish compiling ourselves. Otherwise, wait until EOF.
3099 We have to do this because the purge_addressof transformation
3100 changes the DECL_RTL for many variables, which confuses integrate. */
3103 if (decl_function_context (decl))
3104 purge_addressof (insns);
3106 DECL_DEFER_OUTPUT (decl) = 1;
3109 if (! current_function_contains_functions
3110 && (DECL_DEFER_OUTPUT (decl)
3111 || (DECL_INLINE (decl)
3112 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3113 && ! flag_keep_inline_functions)
3114 || DECL_EXTERNAL (decl)))))
3116 DECL_DEFER_OUTPUT (decl) = 1;
3118 /* If -Wreturn-type, we have to do a bit of compilation.
3119 However, if we just fall through we will call
3120 save_for_inline_copying() which results in excessive
3121 memory use. Instead, we just want to call
3122 jump_optimize() to figure out whether or not we can fall
3123 off the end of the function; we do the minimum amount of
3124 work necessary to make that safe. And, we set optimize
3125 to zero to keep jump_optimize from working too hard. */
3126 if (warn_return_type)
3128 int saved_optimize = optimize;
3130 find_exception_handler_labels ();
3131 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3132 !JUMP_AFTER_REGSCAN);
3133 optimize = saved_optimize;
3136 #ifdef DWARF_DEBUGGING_INFO
3137 /* Generate the DWARF info for the "abstract" instance
3138 of a function which we may later generate inlined and/or
3139 out-of-line instances of. */
3140 if (write_symbols == DWARF_DEBUG)
3142 set_decl_abstract_flags (decl, 1);
3143 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3144 set_decl_abstract_flags (decl, 0);
3147 #ifdef DWARF2_DEBUGGING_INFO
3148 /* Generate the DWARF2 info for the "abstract" instance
3149 of a function which we may later generate inlined and/or
3150 out-of-line instances of. */
3151 if (write_symbols == DWARF2_DEBUG)
3153 set_decl_abstract_flags (decl, 1);
3154 TIMEVAR (symout_time, dwarf2out_decl (decl));
3155 set_decl_abstract_flags (decl, 0);
3158 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3159 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3160 goto exit_rest_of_compilation;
3163 /* If we have to compile the function now, save its rtl and subdecls
3164 so that its compilation will not affect what others get. */
3165 if (inlinable || DECL_DEFER_OUTPUT (decl))
3167 #ifdef DWARF_DEBUGGING_INFO
3168 /* Generate the DWARF info for the "abstract" instance of
3169 a function which we will generate an out-of-line instance
3170 of almost immediately (and which we may also later generate
3171 various inlined instances of). */
3172 if (write_symbols == DWARF_DEBUG)
3174 set_decl_abstract_flags (decl, 1);
3175 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3176 set_decl_abstract_flags (decl, 0);
3179 #ifdef DWARF2_DEBUGGING_INFO
3180 /* Generate the DWARF2 info for the "abstract" instance of
3181 a function which we will generate an out-of-line instance
3182 of almost immediately (and which we may also later generate
3183 various inlined instances of). */
3184 if (write_symbols == DWARF2_DEBUG)
3186 set_decl_abstract_flags (decl, 1);
3187 TIMEVAR (symout_time, dwarf2out_decl (decl));
3188 set_decl_abstract_flags (decl, 0);
3191 saved_block_tree = DECL_INITIAL (decl);
3192 saved_arguments = DECL_ARGUMENTS (decl);
3193 TIMEVAR (integration_time, save_for_inline_copying (decl));
3194 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3197 /* If specified extern inline but we aren't inlining it, we are
3199 if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
3200 goto exit_rest_of_compilation;
3203 if (! DECL_DEFER_OUTPUT (decl))
3204 TREE_ASM_WRITTEN (decl) = 1;
3206 /* Now that integrate will no longer see our rtl, we need not distinguish
3207 between the return value of this function and the return value of called
3209 rtx_equal_function_value_matters = 0;
3211 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3212 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3214 goto exit_rest_of_compilation;
3217 /* Emit code to get eh context, if needed. */
3221 /* If we are doing position-independent code generation, now
3222 is the time to output special prologues and epilogues.
3223 We do not want to do this earlier, because it just clutters
3224 up inline functions with meaningless insns. */
3229 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3230 Note that that may have been done above, in save_for_inline_copying.
3231 The call to resume_temporary_allocation near the end of this function
3232 goes back to the usual state of affairs. This must be done after
3233 we've built up any unwinders for exception handling, and done
3234 the FINALIZE_PIC work, if necessary. */
3236 rtl_in_current_obstack ();
3238 insns = get_insns ();
3240 /* Copy any shared structure that should not be shared. */
3242 unshare_all_rtl (insns);
3244 #ifdef SETJMP_VIA_SAVE_AREA
3245 /* This must be performed before virutal register instantiation. */
3246 if (current_function_calls_alloca)
3247 optimize_save_area_alloca (insns);
3250 /* Instantiate all virtual registers. */
3252 instantiate_virtual_regs (current_function_decl, get_insns ());
3254 /* See if we have allocated stack slots that are not directly addressable.
3255 If so, scan all the insns and create explicit address computation
3256 for all references to such slots. */
3257 /* fixup_stack_slots (); */
3259 /* Find all the EH handlers. */
3260 find_exception_handler_labels ();
3262 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3263 are initialized and to compute whether control can drop off the end
3265 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3266 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3267 JUMP_AFTER_REGSCAN));
3269 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3270 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3271 goto exit_rest_of_compilation;
3273 /* Dump rtl code after jump, if we are doing that. */
3276 dump_rtl (".jump", decl, print_rtl, insns);
3278 /* Perform common subexpression elimination.
3279 Nonzero value from `cse_main' means that jumps were simplified
3280 and some code may now be unreachable, so do
3281 jump optimization again. */
3286 open_dump_file (".cse", decl_printable_name (decl, 2));
3288 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3290 if (flag_thread_jumps)
3291 /* Hacks by tiemann & kenner. */
3292 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3294 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3296 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3298 if (tem || optimize > 1)
3299 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3301 !JUMP_AFTER_REGSCAN));
3303 /* Dump rtl code after cse, if we are doing that. */
3306 close_dump_file (print_rtl, insns);
3309 purge_addressof (insns);
3310 reg_scan (insns, max_reg_num (), 1);
3313 dump_rtl (".addressof", decl, print_rtl, insns);
3315 /* Perform global cse. */
3317 if (optimize > 0 && flag_gcse)
3320 open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl)));
3322 TIMEVAR (gcse_time, gcse_main (insns, rtl_dump_file));
3325 close_dump_file (print_rtl, insns);
3327 /* Move constant computations out of loops. */
3332 open_dump_file (".loop", decl_printable_name (decl, 2));
3337 if (flag_rerun_loop_opt)
3339 /* We only want to perform unrolling once. */
3341 loop_optimize (insns, rtl_dump_file, 0);
3344 /* The first call to loop_optimize makes some instructions
3345 trivially dead. We delete those instructions now in the
3346 hope that doing so will make the heuristics in loop work
3347 better and possibly speed up compilation. */
3348 delete_trivially_dead_insns (insns, max_reg_num ());
3350 /* The regscan pass is currently necessary as the alias
3351 analysis code depends on this information. */
3352 reg_scan (insns, max_reg_num (), 1);
3354 loop_optimize (insns, rtl_dump_file, flag_unroll_loops);
3357 /* Dump rtl code after loop opt, if we are doing that. */
3360 close_dump_file (print_rtl, insns);
3366 open_dump_file (".cse2", decl_printable_name (decl, 2));
3368 if (flag_rerun_cse_after_loop)
3370 /* Running another jump optimization pass before the second
3371 cse pass sometimes simplifies the RTL enough to allow
3372 the second CSE pass to do a better job. Jump_optimize can change
3373 max_reg_num so we must rerun reg_scan afterwards.
3374 ??? Rework to not call reg_scan so often. */
3375 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3376 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3378 JUMP_AFTER_REGSCAN));
3380 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3381 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3384 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3386 !JUMP_AFTER_REGSCAN));
3389 if (flag_thread_jumps)
3391 /* This pass of jump threading straightens out code
3392 that was kinked by loop optimization. */
3393 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3394 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3397 /* Dump rtl code after cse, if we are doing that. */
3400 close_dump_file (print_rtl, insns);
3403 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3405 if (branch_prob_dump)
3406 open_dump_file (".bp", decl_printable_name (decl, 2));
3411 branch_prob (insns, rtl_dump_file);
3414 if (branch_prob_dump)
3415 close_dump_file (print_rtl, insns);
3418 /* We are no longer anticipating cse in this function, at least. */
3420 cse_not_expected = 1;
3422 /* Now we choose between stupid (pcc-like) register allocation
3423 (if we got the -noreg switch and not -opt)
3424 and smart register allocation. */
3426 if (optimize > 0) /* Stupid allocation probably won't work */
3427 obey_regdecls = 0; /* if optimizations being done. */
3431 /* Print function header into flow dump now
3432 because doing the flow analysis makes some of the dump. */
3435 open_dump_file (".flow", decl_printable_name (decl, 2));
3441 regclass (insns, max_reg_num ());
3442 stupid_life_analysis (insns, max_reg_num (),
3448 /* Do control and data flow analysis,
3449 and write some of the results to dump file. */
3454 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
3455 life_analysis (insns, max_reg_num (), rtl_dump_file);
3458 if (warn_uninitialized)
3460 uninitialized_vars_warning (DECL_INITIAL (decl));
3461 setjmp_args_warning ();
3465 /* Dump rtl after flow analysis. */
3468 close_dump_file (print_rtl_with_bb, insns);
3470 /* If -opt, try combining insns through substitution. */
3474 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3476 /* Dump rtl code after insn combination. */
3479 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
3482 /* Register allocation pre-pass, to reduce number of moves
3483 necessary for two-address machines. */
3484 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3487 open_dump_file (".regmove", decl_printable_name (decl, 2));
3489 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
3493 close_dump_file (print_rtl_with_bb, insns);
3496 /* Print function header into sched dump now
3497 because doing the sched analysis makes some of the dump. */
3499 if (optimize > 0 && flag_schedule_insns)
3502 open_dump_file (".sched", decl_printable_name (decl, 2));
3504 /* Do control and data sched analysis,
3505 and write some of the results to dump file. */
3507 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
3509 /* Dump rtl after instruction scheduling. */
3512 close_dump_file (print_rtl_with_bb, insns);
3515 /* Unless we did stupid register allocation,
3516 allocate pseudo-regs that are used only within 1 basic block. */
3519 TIMEVAR (local_alloc_time,
3521 recompute_reg_usage (insns);
3522 regclass (insns, max_reg_num ());
3526 /* Dump rtl code after allocating regs within basic blocks. */
3530 open_dump_file (".lreg", decl_printable_name (decl, 2));
3532 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
3533 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
3535 close_dump_file (print_rtl_with_bb, insns);
3538 if (global_reg_dump)
3539 open_dump_file (".greg", decl_printable_name (decl, 2));
3541 /* Save the last label number used so far, so reorg can tell
3542 when it's safe to kill spill regs. */
3543 max_label_num_after_reload = max_label_num ();
3545 /* Unless we did stupid register allocation,
3546 allocate remaining pseudo-regs, then do the reload pass
3547 fixing up any insns that are invalid. */
3549 TIMEVAR (global_alloc_time,
3552 failure = global_alloc (rtl_dump_file);
3554 failure = reload (insns, 0, rtl_dump_file);
3559 goto exit_rest_of_compilation;
3561 reload_completed = 1;
3563 /* Do a very simple CSE pass over just the hard registers. */
3565 reload_cse_regs (insns);
3567 /* On some machines, the prologue and epilogue code, or parts thereof,
3568 can be represented as RTL. Doing so lets us schedule insns between
3569 it and the rest of the code and also allows delayed branch
3570 scheduling to operate in the epilogue. */
3572 thread_prologue_and_epilogue_insns (insns);
3574 if (global_reg_dump)
3576 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
3577 close_dump_file (print_rtl_with_bb, insns);
3579 if (optimize > 0 && flag_schedule_insns_after_reload)
3582 open_dump_file (".sched2", decl_printable_name (decl, 2));
3584 /* Do control and data sched analysis again,
3585 and write some more of the results to dump file. */
3587 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
3589 /* Dump rtl after post-reorder instruction scheduling. */
3592 close_dump_file (print_rtl_with_bb, insns);
3595 #ifdef LEAF_REGISTERS
3597 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3601 /* One more attempt to remove jumps to .+1
3602 left by dead-store-elimination.
3603 Also do cross-jumping this time
3604 and delete no-op move insns. */
3608 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
3610 !JUMP_AFTER_REGSCAN));
3612 /* Dump rtl code after jump, if we are doing that. */
3615 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
3618 /* If a machine dependent reorganization is needed, call it. */
3619 #ifdef MACHINE_DEPENDENT_REORG
3620 MACHINE_DEPENDENT_REORG (insns);
3622 if (mach_dep_reorg_dump)
3623 dump_rtl (".mach", decl, print_rtl_with_bb, insns);
3626 /* If a scheduling pass for delayed branches is to be done,
3627 call the scheduling code. */
3630 if (optimize > 0 && flag_delayed_branch)
3632 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
3635 dump_rtl (".dbr", decl, print_rtl_with_bb, insns);
3639 /* Shorten branches. */
3640 TIMEVAR (shorten_branch_time,
3642 shorten_branches (get_insns ());
3646 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
3649 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
3652 /* Now turn the rtl into assembler code. */
3654 TIMEVAR (final_time,
3659 /* Get the function's name, as described by its RTL.
3660 This may be different from the DECL_NAME name used
3661 in the source file. */
3663 x = DECL_RTL (decl);
3664 if (GET_CODE (x) != MEM)
3667 if (GET_CODE (x) != SYMBOL_REF)
3669 fnname = XSTR (x, 0);
3671 assemble_start_function (decl, fnname);
3672 final_start_function (insns, asm_out_file, optimize);
3673 final (insns, asm_out_file, optimize, 0);
3674 final_end_function (insns, asm_out_file, optimize);
3675 assemble_end_function (decl, fnname);
3677 fflush (asm_out_file);
3679 /* Release all memory held by regsets now */
3680 regset_release_memory ();
3683 /* Write DBX symbols if requested */
3685 /* Note that for those inline functions where we don't initially
3686 know for certain that we will be generating an out-of-line copy,
3687 the first invocation of this routine (rest_of_compilation) will
3688 skip over this code by doing a `goto exit_rest_of_compilation;'.
3689 Later on, finish_compilation will call rest_of_compilation again
3690 for those inline functions that need to have out-of-line copies
3691 generated. During that call, we *will* be routed past here. */
3693 #ifdef DBX_DEBUGGING_INFO
3694 if (write_symbols == DBX_DEBUG)
3695 TIMEVAR (symout_time, dbxout_function (decl));
3698 #ifdef DWARF_DEBUGGING_INFO
3699 if (write_symbols == DWARF_DEBUG)
3700 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3703 #ifdef DWARF2_DEBUGGING_INFO
3704 if (write_symbols == DWARF2_DEBUG)
3705 TIMEVAR (symout_time, dwarf2out_decl (decl));
3708 exit_rest_of_compilation:
3710 /* In case the function was not output,
3711 don't leave any temporary anonymous types
3712 queued up for sdb output. */
3713 #ifdef SDB_DEBUGGING_INFO
3714 if (write_symbols == SDB_DEBUG)
3715 sdbout_types (NULL_TREE);
3718 /* Put back the tree of subblocks and list of arguments
3719 from before we copied them.
3720 Code generation and the output of debugging info may have modified
3721 the copy, but the original is unchanged. */
3723 if (saved_block_tree != 0)
3725 DECL_INITIAL (decl) = saved_block_tree;
3726 DECL_ARGUMENTS (decl) = saved_arguments;
3727 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3730 reload_completed = 0;
3732 TIMEVAR (final_time,
3734 /* Clear out the insn_length contents now that they are no
3736 init_insn_lengths ();
3738 /* Clear out the real_constant_chain before some of the rtx's
3739 it runs through become garbage. */
3740 clear_const_double_mem ();
3742 /* Cancel the effect of rtl_in_current_obstack. */
3743 resume_temporary_allocation ();
3745 /* Show no temporary slots allocated. */
3749 /* Make sure volatile mem refs aren't considered valid operands for
3750 arithmetic insns. We must call this here if this is a nested inline
3751 function, since the above code leaves us in the init_recog state
3752 (from final.c), and the function context push/pop code does not
3753 save/restore volatile_ok.
3755 ??? Maybe it isn't necessary for expand_start_function to call this
3756 anymore if we do it here? */
3758 init_recog_no_volatile ();
3760 /* The parsing time is all the time spent in yyparse
3761 *except* what is spent in this function. */
3763 parse_time -= get_run_time () - start_time;
3766 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3767 Exit code is 35 if can't open files, 34 if fatal error,
3768 33 if had nonfatal errors, else success. */
3771 main (argc, argv, envp)
3778 int flag_print_mem = 0;
3779 int version_flag = 0;
3782 /* save in case md file wants to emit args as a comment. */
3786 p = argv[0] + strlen (argv[0]);
3787 while (p != argv[0] && p[-1] != '/'
3788 #ifdef DIR_SEPARATOR
3789 && p[-1] != DIR_SEPARATOR
3795 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
3796 /* Get rid of any avoidable limit on stack size. */
3800 /* Set the stack limit huge so that alloca does not fail. */
3801 getrlimit (RLIMIT_STACK, &rlim);
3802 rlim.rlim_cur = rlim.rlim_max;
3803 setrlimit (RLIMIT_STACK, &rlim);
3807 signal (SIGFPE, float_signal);
3810 signal (SIGPIPE, pipe_closed);
3813 decl_printable_name = decl_name;
3814 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3816 /* Initialize whether `char' is signed. */
3817 flag_signed_char = DEFAULT_SIGNED_CHAR;
3818 #ifdef DEFAULT_SHORT_ENUMS
3819 /* Initialize how much space enums occupy, by default. */
3820 flag_short_enums = DEFAULT_SHORT_ENUMS;
3823 /* Perform language-specific options intialization. */
3824 lang_init_options ();
3826 /* Scan to see what optimization level has been specified. That will
3827 determine the default value of many flags. */
3828 for (i = 1; i < argc; i++)
3830 if (!strcmp (argv[i], "-O"))
3834 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3836 /* Handle -Os, -O2, -O3, -O69, ... */
3837 char *p = &argv[i][2];
3840 if ((p[0] == 's') && (p[1] == 0))
3845 if (! (c >= '0' && c <= '9'))
3848 optimize = atoi (&argv[i][2]);
3853 /* Optimizing for size forces optimize to be no less than 2. */
3854 if (optimize_size && (optimize < 2))
3857 obey_regdecls = (optimize == 0);
3862 flag_thread_jumps = 1;
3864 flag_delayed_branch = 1;
3866 #ifdef CAN_DEBUG_WITHOUT_FP
3867 flag_omit_frame_pointer = 1;
3873 flag_cse_follow_jumps = 1;
3874 flag_cse_skip_blocks = 1;
3876 flag_expensive_optimizations = 1;
3877 flag_strength_reduce = 1;
3878 flag_rerun_cse_after_loop = 1;
3879 flag_rerun_loop_opt = 1;
3880 flag_caller_saves = 1;
3882 #ifdef INSN_SCHEDULING
3883 flag_schedule_insns = 1;
3884 flag_schedule_insns_after_reload = 1;
3887 /* We don't set flag_strict_aliasing here because we're still
3888 testing the functionality. After it has been tested, it
3889 should be turned on here. */
3894 flag_inline_functions = 1;
3897 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
3900 set_target_switch ("");
3902 #ifdef OPTIMIZATION_OPTIONS
3903 /* Allow default optimizations to be specified on a per-machine basis. */
3904 OPTIMIZATION_OPTIONS (optimize, optimize_size);
3907 /* Initialize register usage now so switches may override. */
3910 for (i = 1; i < argc; i++)
3913 /* If this is a language-specific option,
3914 decode it in a language-specific way. */
3915 for (j = 0; lang_options[j] != 0; j++)
3916 if (!strncmp (argv[i], lang_options[j],
3917 strlen (lang_options[j])))
3919 if (lang_options[j] != 0)
3921 /* If the option is valid for *some* language,
3922 treat it as valid even if this language doesn't understand it. */
3923 int strings_processed = lang_decode_option (argc - i, argv + i);
3924 if (strings_processed != 0)
3925 i += strings_processed - 1;
3927 else if (argv[i][0] == '-' && argv[i][1] != 0)
3929 register char *str = argv[i] + 1;
3934 set_target_switch (&str[1]);
3935 else if (!strcmp (str, "dumpbase"))
3937 dump_base_name = argv[++i];
3939 else if (str[0] == 'd')
3941 register char *p = &str[1];
3946 branch_prob_dump = 1;
3952 global_reg_dump = 1;
3960 cse_dump = 1, cse2_dump = 1;
3967 #ifdef MACHINE_DEPENDENT_REORG
3968 mach_dep_reorg_dump = 1;
3975 branch_prob_dump = 1;
3992 global_reg_dump = 1;
4017 #ifdef MACHINE_DEPENDENT_REORG
4019 mach_dep_reorg_dump = 1;
4023 flag_print_asm_name = 1;
4047 rtl_dump_and_exit = 1;
4050 warning ("unrecognised gcc debugging option: %c", p[-1]);
4054 else if (str[0] == 'f')
4056 register char *p = &str[1];
4059 /* Some kind of -f option.
4060 P's value is the option sans `-f'.
4061 Search for it in the table of options. */
4064 !found && j < sizeof (f_options) / sizeof (f_options[0]);
4067 if (!strcmp (p, f_options[j].string))
4069 *f_options[j].variable = f_options[j].on_value;
4070 /* A goto here would be cleaner,
4071 but breaks the vax pcc. */
4074 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4075 && ! strcmp (p+3, f_options[j].string))
4077 *f_options[j].variable = ! f_options[j].on_value;
4085 #ifdef INSN_SCHEDULING
4086 else if (!strncmp (p, "sched-verbose-",14))
4087 fix_sched_param("verbose",&p[14]);
4090 else if (!strncmp (p, "fixed-", 6))
4091 fix_register (&p[6], 1, 1);
4092 else if (!strncmp (p, "call-used-", 10))
4093 fix_register (&p[10], 0, 1);
4094 else if (!strncmp (p, "call-saved-", 11))
4095 fix_register (&p[11], 0, 0);
4097 error ("Invalid option `%s'", argv[i]);
4099 else if (str[0] == 'O')
4101 register char *p = str+1;
4105 while (*p && *p >= '0' && *p <= '9')
4110 error ("Invalid option `%s'", argv[i]);
4112 else if (!strcmp (str, "pedantic"))
4114 else if (!strcmp (str, "pedantic-errors"))
4115 flag_pedantic_errors = pedantic = 1;
4116 else if (!strcmp (str, "quiet"))
4118 else if (!strcmp (str, "version"))
4120 else if (!strcmp (str, "w"))
4121 inhibit_warnings = 1;
4122 else if (!strcmp (str, "W"))
4125 /* We save the value of warn_uninitialized, since if they put
4126 -Wuninitialized on the command line, we need to generate a
4127 warning about not using it without also specifying -O. */
4128 if (warn_uninitialized != 1)
4129 warn_uninitialized = 2;
4131 else if (str[0] == 'W')
4133 register char *p = &str[1];
4136 /* Some kind of -W option.
4137 P's value is the option sans `-W'.
4138 Search for it in the table of options. */
4141 !found && j < sizeof (W_options) / sizeof (W_options[0]);
4144 if (!strcmp (p, W_options[j].string))
4146 *W_options[j].variable = W_options[j].on_value;
4147 /* A goto here would be cleaner,
4148 but breaks the vax pcc. */
4151 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4152 && ! strcmp (p+3, W_options[j].string))
4154 *W_options[j].variable = ! W_options[j].on_value;
4161 else if (!strncmp (p, "id-clash-", 9))
4167 if (*endp >= '0' && *endp <= '9')
4171 error ("Invalid option `%s'", argv[i]);
4176 id_clash_len = atoi (str + 10);
4179 else if (!strncmp (p, "larger-than-", 12))
4181 char *endp = p + 12;
4185 if (*endp >= '0' && *endp <= '9')
4189 error ("Invalid option `%s'", argv[i]);
4190 goto larger_than_lose;
4193 warn_larger_than = 1;
4194 larger_than_size = atoi (str + 13);
4198 error ("Invalid option `%s'", argv[i]);
4200 else if (!strcmp (str, "p"))
4204 else if (!strcmp (str, "a"))
4206 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4207 warning ("`-a' option (basic block profile) not supported");
4209 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4212 else if (!strcmp (str, "ax"))
4214 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4215 warning ("`-ax' option (jump profiling) not supported");
4217 profile_block_flag = (!profile_block_flag
4218 || profile_block_flag == 2) ? 2 : 3;
4221 else if (str[0] == 'g')
4225 /* A lot of code assumes write_symbols == NO_DEBUG if the
4226 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4227 of what debugging type has been selected). This records the
4228 selected type. It is an error to specify more than one
4230 static enum debug_info_type selected_debug_type = NO_DEBUG;
4231 /* Non-zero if debugging format has been explicitly set.
4232 -g and -ggdb don't explicitly set the debugging format so
4233 -gdwarf -g3 is equivalent to -gdwarf3. */
4234 static int type_explicitly_set_p = 0;
4235 /* Table of supported debugging formats. */
4238 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
4239 constant expression, we use NO_DEBUG in its place. */
4240 enum debug_info_type debug_type;
4241 int use_extensions_p;
4242 } *da, debug_args[] = {
4243 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS },
4244 { "ggdb", NO_DEBUG, 1 },
4245 #ifdef DBX_DEBUGGING_INFO
4246 { "gstabs", DBX_DEBUG, 0 },
4247 { "gstabs+", DBX_DEBUG, 1 },
4249 #ifdef DWARF_DEBUGGING_INFO
4250 { "gdwarf", DWARF_DEBUG, 0 },
4251 { "gdwarf+", DWARF_DEBUG, 1 },
4253 #ifdef DWARF2_DEBUGGING_INFO
4254 { "gdwarf-2", DWARF2_DEBUG, 0 },
4256 #ifdef XCOFF_DEBUGGING_INFO
4257 { "gxcoff", XCOFF_DEBUG, 0 },
4258 { "gxcoff+", XCOFF_DEBUG, 1 },
4260 #ifdef SDB_DEBUGGING_INFO
4261 { "gcoff", SDB_DEBUG, 0 },
4265 /* Indexed by enum debug_info_type. */
4266 static char *debug_type_names[] = {
4267 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4270 /* Look up STR in the table. */
4271 for (da = debug_args; da->arg; da++)
4273 if (! strncmp (str, da->arg, strlen (da->arg)))
4275 enum debug_info_type type = da->debug_type;
4278 p = str + strlen (da->arg);
4279 if (*p && (*p < '0' || *p > '9'))
4283 while (*q && (*q >= '0' && *q <= '9'))
4288 if (len > 1 && !strncmp (str, "gdwarf", len))
4290 error ("use -gdwarf -g%d for DWARF v1, level %d",
4293 error ("use -gdwarf-2 for DWARF v2");
4297 level = 2; /* default debugging info level */
4298 if (*q || level > 3)
4300 warning ("invalid debug level specification in option: `-%s'",
4302 /* ??? This error message is incorrect in the case of
4304 warning ("no debugging information will be generated");
4308 if (type == NO_DEBUG)
4310 type = PREFERRED_DEBUGGING_TYPE;
4311 if (len > 1 && strncmp (str, "ggdb", len) == 0)
4313 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4314 type = DWARF2_DEBUG;
4316 #ifdef DBX_DEBUGGING_INFO
4323 if (type == NO_DEBUG)
4324 warning ("`-%s' not supported by this configuration of GCC",
4327 /* Does it conflict with an already selected type? */
4328 if (type_explicitly_set_p
4329 /* -g/-ggdb don't conflict with anything */
4330 && da->debug_type != NO_DEBUG
4331 && type != selected_debug_type)
4332 warning ("`-%s' ignored, conflicts with `-g%s'",
4333 str, debug_type_names[(int) selected_debug_type]);
4336 /* If the format has already been set, -g/-ggdb
4337 only change the debug level. */
4338 if (type_explicitly_set_p
4339 && da->debug_type == NO_DEBUG)
4340 ; /* don't change debugging type */
4343 selected_debug_type = type;
4344 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4346 write_symbols = (level == 0
4348 : selected_debug_type);
4349 use_gnu_debug_info_extensions = da->use_extensions_p;
4350 debug_info_level = (enum debug_info_level) level;
4356 warning ("`-%s' not supported by this configuration of GCC",
4359 else if (!strcmp (str, "o"))
4361 asm_file_name = argv[++i];
4363 else if (str[0] == 'G')
4365 g_switch_set = TRUE;
4366 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
4368 else if (!strncmp (str, "aux-info", 8))
4370 flag_gen_aux_info = 1;
4371 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
4374 error ("Invalid option `%s'", argv[i]);
4376 else if (argv[i][0] == '+')
4377 error ("Invalid option `%s'", argv[i]);
4382 /* Checker uses the frame pointer. */
4383 if (flag_check_memory_usage)
4384 flag_omit_frame_pointer = 0;
4388 /* Inlining does not work if not optimizing,
4389 so force it not to be done. */
4393 /* The c_decode_option and lang_decode_option functions set
4394 this to `2' if -Wall is used, so we can avoid giving out
4395 lots of errors for people who don't realize what -Wall does. */
4396 if (warn_uninitialized == 1)
4397 warning ("-Wuninitialized is not supported without -O");
4400 #ifdef OVERRIDE_OPTIONS
4401 /* Some machines may reject certain combinations of options. */
4405 if (exceptions_via_longjmp == 2)
4407 #ifdef DWARF2_UNWIND_INFO
4408 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4410 exceptions_via_longjmp = 1;
4414 if (profile_block_flag == 3)
4416 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4417 profile_block_flag = 2;
4420 /* Unrolling all loops implies that standard loop unrolling must also
4422 if (flag_unroll_all_loops)
4423 flag_unroll_loops = 1;
4424 /* Loop unrolling requires that strength_reduction be on also. Silently
4425 turn on strength reduction here if it isn't already on. Also, the loop
4426 unrolling code assumes that cse will be run after loop, so that must
4427 be turned on also. */
4428 if (flag_unroll_loops)
4430 flag_strength_reduce = 1;
4431 flag_rerun_cse_after_loop = 1;
4434 /* Warn about options that are not supported on this machine. */
4435 #ifndef INSN_SCHEDULING
4436 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4437 warning ("instruction scheduling not supported on this target machine");
4440 if (flag_delayed_branch)
4441 warning ("this target machine does not have delayed branches");
4444 /* If we are in verbose mode, write out the version and maybe all the
4445 option flags in use. */
4448 print_version (stderr, "");
4450 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4453 compile_file (filename);
4455 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4458 char *lim = (char *) sbrk (0);
4460 fprintf (stderr, "Data size %ld.\n", (long)(lim - (char *) &environ));
4465 system ("ps -l 1>&2");
4468 #endif /* not USG */
4471 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4474 exit (FATAL_EXIT_CODE);
4476 exit (FATAL_EXIT_CODE);
4477 exit (SUCCESS_EXIT_CODE);
4481 /* Decode -m switches. */
4483 /* Here is a table, controlled by the tm.h file, listing each -m switch
4484 and which bits in `target_switches' it should set or clear.
4485 If VALUE is positive, it is bits to set.
4486 If VALUE is negative, -VALUE is bits to clear.
4487 (The sign bit is not used so there is no confusion.) */
4489 struct {char *name; int value;} target_switches []
4492 /* This table is similar, but allows the switch to have a value. */
4494 #ifdef TARGET_OPTIONS
4495 struct {char *prefix; char ** variable;} target_options []
4499 /* Decode the switch -mNAME. */
4502 set_target_switch (name)
4508 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4509 if (!strcmp (target_switches[j].name, name))
4511 if (target_switches[j].value < 0)
4512 target_flags &= ~-target_switches[j].value;
4514 target_flags |= target_switches[j].value;
4518 #ifdef TARGET_OPTIONS
4520 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4522 int len = strlen (target_options[j].prefix);
4523 if (!strncmp (target_options[j].prefix, name, len))
4525 *target_options[j].variable = name + len;
4532 error ("Invalid option `%s'", name);
4535 /* Print version information to FILE.
4536 Each line begins with INDENT (for the case where FILE is the
4537 assembler output file). */
4540 print_version (file, indent)
4544 fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4545 language_string, version_string);
4546 fprintf (file, " (%s)", TARGET_NAME);
4549 #define __VERSION__ "[unknown]"
4551 fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4553 fprintf (file, " compiled by CC.\n");
4557 /* Print an option value and return the adjusted position in the line.
4558 ??? We don't handle error returns from fprintf (disk full); presumably
4559 other code will catch a disk full though. */
4562 print_single_switch (file, pos, max, indent, sep, term, type, name)
4565 char *indent, *sep, *term, *type, *name;
4567 /* The ultrix fprintf returns 0 on success, so compute the result we want
4568 here since we need it for the following test. */
4569 int len = strlen (sep) + strlen (type) + strlen (name);
4574 fprintf (file, "%s", term);
4579 fprintf (file, "%s", indent);
4580 pos = strlen (indent);
4582 fprintf (file, "%s%s%s", sep, type, name);
4587 /* Print active target switches to FILE.
4588 POS is the current cursor position and MAX is the size of a "line".
4589 Each line begins with INDENT and ends with TERM.
4590 Each switch is separated from the next by SEP. */
4593 print_switch_values (file, pos, max, indent, sep, term)
4596 char *indent, *sep, *term;
4601 /* Print the options as passed. */
4603 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4604 "options passed: ", "");
4606 for (p = &save_argv[1]; *p != NULL; p++)
4610 if (strcmp (*p, "-o") == 0)
4616 if (strcmp (*p, "-quiet") == 0)
4618 if (strcmp (*p, "-version") == 0)
4623 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4626 fprintf (file, "%s", term);
4628 /* Print the -f and -m options that have been enabled.
4629 We don't handle language specific options but printing argv
4632 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4633 "options enabled: ", "");
4635 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4636 if (*f_options[j].variable == f_options[j].on_value)
4637 pos = print_single_switch (file, pos, max, indent, sep, term,
4638 "-f", f_options[j].string);
4640 /* Print target specific options. */
4642 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4643 if (target_switches[j].name[0] != '\0'
4644 && target_switches[j].value > 0
4645 && ((target_switches[j].value & target_flags)
4646 == target_switches[j].value))
4648 pos = print_single_switch (file, pos, max, indent, sep, term,
4649 "-m", target_switches[j].name);
4652 #ifdef TARGET_OPTIONS
4653 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4654 if (*target_options[j].variable != NULL)
4657 sprintf (prefix, "-m%s", target_options[j].prefix);
4658 pos = print_single_switch (file, pos, max, indent, sep, term,
4659 prefix, *target_options[j].variable);
4663 fprintf (file, "%s", term);
4666 /* Record the beginning of a new source file, named FILENAME. */
4669 debug_start_source_file (filename)
4670 register char *filename;
4672 #ifdef DBX_DEBUGGING_INFO
4673 if (write_symbols == DBX_DEBUG)
4674 dbxout_start_new_source_file (filename);
4676 #ifdef DWARF_DEBUGGING_INFO
4677 if (debug_info_level == DINFO_LEVEL_VERBOSE
4678 && write_symbols == DWARF_DEBUG)
4679 dwarfout_start_new_source_file (filename);
4680 #endif /* DWARF_DEBUGGING_INFO */
4681 #ifdef DWARF2_DEBUGGING_INFO
4682 if (debug_info_level == DINFO_LEVEL_VERBOSE
4683 && write_symbols == DWARF2_DEBUG)
4684 dwarf2out_start_source_file (filename);
4685 #endif /* DWARF2_DEBUGGING_INFO */
4686 #ifdef SDB_DEBUGGING_INFO
4687 if (write_symbols == SDB_DEBUG)
4688 sdbout_start_new_source_file (filename);
4692 /* Record the resumption of a source file. LINENO is the line number in
4693 the source file we are returning to. */
4696 debug_end_source_file (lineno)
4697 register unsigned lineno;
4699 #ifdef DBX_DEBUGGING_INFO
4700 if (write_symbols == DBX_DEBUG)
4701 dbxout_resume_previous_source_file ();
4703 #ifdef DWARF_DEBUGGING_INFO
4704 if (debug_info_level == DINFO_LEVEL_VERBOSE
4705 && write_symbols == DWARF_DEBUG)
4706 dwarfout_resume_previous_source_file (lineno);
4707 #endif /* DWARF_DEBUGGING_INFO */
4708 #ifdef DWARF2_DEBUGGING_INFO
4709 if (debug_info_level == DINFO_LEVEL_VERBOSE
4710 && write_symbols == DWARF2_DEBUG)
4711 dwarf2out_end_source_file ();
4712 #endif /* DWARF2_DEBUGGING_INFO */
4713 #ifdef SDB_DEBUGGING_INFO
4714 if (write_symbols == SDB_DEBUG)
4715 sdbout_resume_previous_source_file ();
4719 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4720 the tail part of the directive line, i.e. the part which is past the
4721 initial whitespace, #, whitespace, directive-name, whitespace part. */
4724 debug_define (lineno, buffer)
4725 register unsigned lineno;
4726 register char *buffer;
4728 #ifdef DWARF_DEBUGGING_INFO
4729 if (debug_info_level == DINFO_LEVEL_VERBOSE
4730 && write_symbols == DWARF_DEBUG)
4731 dwarfout_define (lineno, buffer);
4732 #endif /* DWARF_DEBUGGING_INFO */
4733 #ifdef DWARF2_DEBUGGING_INFO
4734 if (debug_info_level == DINFO_LEVEL_VERBOSE
4735 && write_symbols == DWARF2_DEBUG)
4736 dwarf2out_define (lineno, buffer);
4737 #endif /* DWARF2_DEBUGGING_INFO */
4740 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4741 the tail part of the directive line, i.e. the part which is past the
4742 initial whitespace, #, whitespace, directive-name, whitespace part. */
4745 debug_undef (lineno, buffer)
4746 register unsigned lineno;
4747 register char *buffer;
4749 #ifdef DWARF_DEBUGGING_INFO
4750 if (debug_info_level == DINFO_LEVEL_VERBOSE
4751 && write_symbols == DWARF_DEBUG)
4752 dwarfout_undef (lineno, buffer);
4753 #endif /* DWARF_DEBUGGING_INFO */
4754 #ifdef DWARF2_DEBUGGING_INFO
4755 if (debug_info_level == DINFO_LEVEL_VERBOSE
4756 && write_symbols == DWARF2_DEBUG)
4757 dwarf2out_undef (lineno, buffer);
4758 #endif /* DWARF2_DEBUGGING_INFO */