1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-7, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This is the top level of cc1/c++.
22 It parses command args, opens files, invokes the various passes
23 in the proper order, and counts the time used by each.
24 Error messages and low-level interface to malloc also handled here. */
27 #undef FLOAT /* This is for hpux. They should change hpux. */
28 #undef FFS /* Some systems define this in param.h. */
34 #ifdef HAVE_SYS_RESOURCE_H
35 # include <sys/resource.h>
38 #ifdef HAVE_SYS_TIMES_H
39 # include <sys/times.h>
46 #include "insn-attr.h"
47 #include "insn-codes.h"
48 #include "insn-config.h"
56 #ifdef DWARF_DEBUGGING_INFO
60 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
61 #include "dwarf2out.h"
64 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
68 #ifdef SDB_DEBUGGING_INFO
72 #ifdef XCOFF_DEBUGGING_INFO
77 /* The extra parameters substantially improve the I/O performance. */
79 vms_fopen (fname, type)
83 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
84 fixed arguments, which matches ANSI's specification but not VAXCRTL's
85 pre-ANSI implementation. This hack circumvents the mismatch problem. */
86 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
89 return (*vmslib_fopen) (fname, type, "mbc=32",
90 "deq=64", "fop=tef", "shr=nil");
92 return (*vmslib_fopen) (fname, type, "mbc=32");
94 #define fopen vms_fopen
97 #ifndef DEFAULT_GDB_EXTENSIONS
98 #define DEFAULT_GDB_EXTENSIONS 1
101 /* If more than one debugging type is supported, you must define
102 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
104 This is one long line cause VAXC can't handle a \-newline. */
105 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
106 #ifndef PREFERRED_DEBUGGING_TYPE
107 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
108 #endif /* no PREFERRED_DEBUGGING_TYPE */
109 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
110 so the following code needn't care. */
111 #ifdef DBX_DEBUGGING_INFO
112 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
114 #ifdef SDB_DEBUGGING_INFO
115 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
117 #ifdef DWARF_DEBUGGING_INFO
118 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
120 #ifdef DWARF2_DEBUGGING_INFO
121 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
123 #ifdef XCOFF_DEBUGGING_INFO
124 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
126 #endif /* More than one debugger format enabled. */
128 /* If still not defined, must have been because no debugging formats
130 #ifndef PREFERRED_DEBUGGING_TYPE
131 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
134 extern int rtx_equal_function_value_matters;
136 #if ! (defined (VMS) || defined (OS2))
137 extern char **environ;
139 extern char *version_string, *language_string;
141 /* Carry information from ASM_DECLARE_OBJECT_NAME
142 to ASM_FINISH_DECLARE_OBJECT. */
144 extern int size_directive_output;
145 extern tree last_assemble_variable_decl;
147 extern char *init_parse PVPROTO((char *));
148 extern void finish_parse ();
149 extern void init_decl_processing ();
150 extern void init_obstacks ();
151 extern void init_tree_codes ();
152 extern void init_rtl ();
153 extern void init_regs ();
154 extern void init_optabs ();
155 extern void init_stmt ();
156 extern void init_reg_sets ();
157 extern void dump_flow_info ();
158 extern void dump_sched_info ();
159 extern void dump_local_alloc ();
160 extern void regset_release_memory ();
162 extern void print_rtl ();
163 extern void print_rtl_with_bb ();
165 void rest_of_decl_compilation ();
166 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
167 void error_with_decl PVPROTO((tree decl, char *s, ...));
168 void error PVPROTO((char *s, ...));
169 void fatal PVPROTO((char *s, ...));
170 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
171 void warning_with_decl PVPROTO((tree decl, char *s, ...));
172 void warning PVPROTO((char *s, ...));
173 void pedwarn PVPROTO((char *s, ...));
174 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
175 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
176 void sorry PVPROTO((char *s, ...));
177 static void set_target_switch PROTO((char *));
178 static char *decl_name PROTO((tree, int));
179 static void vmessage PROTO((char *, char *, va_list));
180 static void v_message_with_file_and_line PROTO((char *, int, char *,
182 static void v_message_with_decl PROTO((tree, char *, char *, va_list));
183 static void file_and_line_for_asm PROTO((rtx, char **, int *));
184 static void v_error_with_file_and_line PROTO((char *, int, char *, va_list));
185 static void v_error_with_decl PROTO((tree, char *, va_list));
186 static void v_error_for_asm PROTO((rtx, char *, va_list));
187 static void verror PROTO((char *, va_list));
188 static void vfatal PROTO((char *, va_list)) ATTRIBUTE_NORETURN;
189 static void v_warning_with_file_and_line PROTO ((char *, int, char *, va_list));
190 static void v_warning_with_decl PROTO((tree, char *, va_list));
191 static void v_warning_for_asm PROTO((rtx, char *, va_list));
192 static void vwarning PROTO((char *, va_list));
193 static void vpedwarn PROTO((char *, va_list));
194 static void v_pedwarn_with_decl PROTO((tree, char *, va_list));
195 static void v_pedwarn_with_file_and_line PROTO((char *, int, char *, va_list));
196 static void vsorry PROTO((char *, va_list));
197 static void v_really_sorry PROTO((char *, va_list)) ATTRIBUTE_NORETURN;
198 static void float_signal PROTO((int));
199 static void pipe_closed PROTO((int));
200 static void output_lang_identify PROTO((FILE *));
201 static void open_dump_file PROTO((char *, char *));
202 static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
203 static void dump_rtl PROTO((char *, tree, void (*) (FILE *, rtx), rtx));
204 static void clean_dump_file PROTO((char *));
205 static void compile_file PROTO((char *));
206 static void display_help PROTO ((void));
208 static void print_version PROTO((FILE *, char *));
209 static int print_single_switch PROTO((FILE *, int, int, char *, char *, char *,
211 static void print_switch_values PROTO((FILE *, int, int, char *, char *,
213 /* Length of line when printing switch values. */
216 /* Name of program invoked, sans directories. */
220 /* Copy of arguments to main. */
224 /* Name of current original source file (what was input to cpp).
225 This comes from each #-command in the actual input. */
227 char *input_filename;
229 /* Name of top-level original source file (what was input to cpp).
230 This comes from the #-command at the beginning of the actual input.
231 If there isn't any there, then this is the cc1 input file name. */
233 char *main_input_filename;
235 /* Current line number in real source file. */
239 /* Stack of currently pending input files. */
241 struct file_stack *input_file_stack;
243 /* Incremented on each change to input_file_stack. */
244 int input_file_stack_tick;
246 /* FUNCTION_DECL for function now being parsed or compiled. */
248 extern tree current_function_decl;
250 /* Name to use as base of names for dump output files. */
252 char *dump_base_name;
254 /* Bit flags that specify the machine subtype we are compiling for.
255 Bits are tested using macros TARGET_... defined in the tm.h file
256 and set by `-m...' switches. Must be defined in rtlanal.c. */
258 extern int target_flags;
260 /* Flags saying which kinds of debugging dump have been requested. */
263 int rtl_dump_and_exit = 0;
264 int jump_opt_dump = 0;
265 int addressof_dump = 0;
270 int branch_prob_dump = 0;
272 int combine_dump = 0;
273 int regmove_dump = 0;
275 int local_reg_dump = 0;
276 int global_reg_dump = 0;
278 int jump2_opt_dump = 0;
280 int dbr_sched_dump = 0;
282 int flag_print_asm_name = 0;
284 int stack_reg_dump = 0;
286 #ifdef MACHINE_DEPENDENT_REORG
287 int mach_dep_reorg_dump = 0;
290 /* Name for output file of assembly code, specified with -o. */
294 /* Value of the -G xx switch, and whether it was passed or not. */
298 /* Type(s) of debugging information we are producing (if any).
299 See flags.h for the definitions of the different possible
300 types of debugging information. */
301 enum debug_info_type write_symbols = NO_DEBUG;
303 /* Level of debugging information we are producing. See flags.h
304 for the definitions of the different possible levels. */
305 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
307 /* Nonzero means use GNU-only extensions in the generated symbolic
308 debugging information. */
309 /* Currently, this only has an effect when write_symbols is set to
310 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
311 int use_gnu_debug_info_extensions = 0;
313 /* Nonzero means do optimizations. -O.
314 Particular numeric values stand for particular amounts of optimization;
315 thus, -O2 stores 2 here. However, the optimizations beyond the basic
316 ones are not controlled directly by this variable. Instead, they are
317 controlled by individual `flag_...' variables that are defaulted
318 based on this variable. */
322 /* Nonzero means optimize for size. -Os.
323 The only valid values are zero and non-zero. When optimize_size is
324 non-zero, optimize defaults to 2, but certain individual code
325 bloating optimizations are disabled. */
327 int optimize_size = 0;
329 /* Number of error messages and warning messages so far. */
332 int warningcount = 0;
335 /* Pointer to function to compute the name to use to print a declaration.
336 DECL is the declaration in question.
337 VERBOSITY determines what information will be printed:
338 0: DECL_NAME, demangled as necessary.
339 1: and scope information.
340 2: and any other information that might be interesting, such as function
341 parameter types in C++. */
343 char *(*decl_printable_name) PROTO ((tree, int));
345 /* Pointer to function to compute rtl for a language-specific tree code. */
347 typedef rtx (*lang_expand_expr_t)
348 PROTO ((union tree_node *, rtx, enum machine_mode,
349 enum expand_modifier modifier));
351 lang_expand_expr_t lang_expand_expr = 0;
353 /* Pointer to function to finish handling an incomplete decl at the
354 end of compilation. */
356 void (*incomplete_decl_finalize_hook) PROTO((tree)) = 0;
358 /* Highest label number used at the end of reload. */
360 int max_label_num_after_reload;
362 /* Nonzero if generating code to do profiling. */
364 int profile_flag = 0;
366 /* Nonzero if generating code to do profiling on a line-by-line basis. */
368 int profile_block_flag;
370 /* Nonzero if generating code to profile program flow graph arcs. */
372 int profile_arc_flag = 0;
374 /* Nonzero if generating info for gcov to calculate line test coverage. */
376 int flag_test_coverage = 0;
378 /* Nonzero indicates that branch taken probabilities should be calculated. */
380 int flag_branch_probabilities = 0;
382 /* Nonzero for -pedantic switch: warn about anything
383 that standard spec forbids. */
387 /* Temporarily suppress certain warnings.
388 This is set while reading code from a system header file. */
390 int in_system_header = 0;
392 /* Nonzero means do stupid register allocation.
393 Currently, this is 1 if `optimize' is 0. */
395 int obey_regdecls = 0;
397 /* Don't print functions as they are compiled and don't print
398 times taken by the various passes. -quiet. */
404 /* Nonzero means `char' should be signed. */
406 int flag_signed_char;
408 /* Nonzero means give an enum type only as many bytes as it needs. */
410 int flag_short_enums;
412 /* Nonzero for -fcaller-saves: allocate values in regs that need to
413 be saved across function calls, if that produces overall better code.
414 Optional now, so people can test it. */
416 #ifdef DEFAULT_CALLER_SAVES
417 int flag_caller_saves = 1;
419 int flag_caller_saves = 0;
422 /* Nonzero if structures and unions should be returned in memory.
424 This should only be defined if compatibility with another compiler or
425 with an ABI is needed, because it results in slower code. */
427 #ifndef DEFAULT_PCC_STRUCT_RETURN
428 #define DEFAULT_PCC_STRUCT_RETURN 1
431 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
433 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
435 /* Nonzero for -fforce-mem: load memory value into a register
436 before arithmetic on it. This makes better cse but slower compilation. */
438 int flag_force_mem = 0;
440 /* Nonzero for -fforce-addr: load memory address into a register before
441 reference to memory. This makes better cse but slower compilation. */
443 int flag_force_addr = 0;
445 /* Nonzero for -fdefer-pop: don't pop args after each function call;
446 instead save them up to pop many calls' args with one insns. */
448 int flag_defer_pop = 0;
450 /* Nonzero for -ffloat-store: don't allocate floats and doubles
451 in extended-precision registers. */
453 int flag_float_store = 0;
455 /* Nonzero for -fcse-follow-jumps:
456 have cse follow jumps to do a more extensive job. */
458 int flag_cse_follow_jumps;
460 /* Nonzero for -fcse-skip-blocks:
461 have cse follow a branch around a block. */
462 int flag_cse_skip_blocks;
464 /* Nonzero for -fexpensive-optimizations:
465 perform miscellaneous relatively-expensive optimizations. */
466 int flag_expensive_optimizations;
468 /* Nonzero for -fthread-jumps:
469 have jump optimize output of loop. */
471 int flag_thread_jumps;
473 /* Nonzero enables strength-reduction in loop.c. */
475 int flag_strength_reduce = 0;
477 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
478 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
479 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
482 int flag_unroll_loops;
484 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
485 This is generally not a win. */
487 int flag_unroll_all_loops;
489 /* Nonzero forces all invariant computations in loops to be moved
492 int flag_move_all_movables = 0;
494 /* Nonzero forces all general induction variables in loops to be
497 int flag_reduce_all_givs = 0;
499 /* Nonzero to perform full register move optimization passes. This is the
502 int flag_regmove = 0;
504 /* Nonzero for -fwritable-strings:
505 store string constants in data segment and don't uniquize them. */
507 int flag_writable_strings = 0;
509 /* Nonzero means don't put addresses of constant functions in registers.
510 Used for compiling the Unix kernel, where strange substitutions are
511 done on the assembly output. */
513 int flag_no_function_cse = 0;
515 /* Nonzero for -fomit-frame-pointer:
516 don't make a frame pointer in simple functions that don't require one. */
518 int flag_omit_frame_pointer = 0;
520 /* Nonzero means place each function into its own section on those platforms
521 which support arbitrary section names and unlimited numbers of sections. */
523 int flag_function_sections = 0;
525 /* ... and similar for data. */
527 int flag_data_sections = 0;
529 /* Nonzero to inhibit use of define_optimization peephole opts. */
531 int flag_no_peephole = 0;
533 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
534 operations in the interest of optimization. For example it allows
535 GCC to assume arguments to sqrt are nonnegative numbers, allowing
536 faster code for sqrt to be generated. */
538 int flag_fast_math = 0;
540 /* Nonzero means all references through pointers are volatile. */
544 /* Nonzero means treat all global and extern variables as global. */
546 int flag_volatile_global;
548 /* Nonzero means just do syntax checking; don't output anything. */
550 int flag_syntax_only = 0;
552 /* Nonzero means perform global cse. */
554 static int flag_gcse;
556 /* Nonzero means to rerun cse after loop optimization. This increases
557 compilation time about 20% and picks up a few more common expressions. */
559 static int flag_rerun_cse_after_loop;
561 /* Nonzero means to run loop optimizations twice. */
563 int flag_rerun_loop_opt;
565 /* Nonzero for -finline-functions: ok to inline functions that look like
566 good inline candidates. */
568 int flag_inline_functions;
570 /* Nonzero for -fkeep-inline-functions: even if we make a function
571 go inline everywhere, keep its definition around for debugging
574 int flag_keep_inline_functions;
576 /* Nonzero means that functions will not be inlined. */
580 /* Nonzero means that we should emit static const variables
581 regardless of whether or not optimization is turned on. */
583 int flag_keep_static_consts = 1;
585 /* Nonzero means we should be saving declaration info into a .X file. */
587 int flag_gen_aux_info = 0;
589 /* Specified name of aux-info file. */
591 static char *aux_info_file_name;
593 /* Nonzero means make the text shared if supported. */
595 int flag_shared_data;
597 /* Nonzero means schedule into delayed branch slots if supported. */
599 int flag_delayed_branch;
601 /* Nonzero if we are compiling pure (sharable) code.
602 Value is 1 if we are doing reasonable (i.e. simple
603 offset into offset table) pic. Value is 2 if we can
604 only perform register offsets. */
608 /* Nonzero means generate extra code for exception handling and enable
609 exception handling. */
613 /* Nonzero means use the new model for exception handling. Replaces
614 -DNEW_EH_MODEL as a compile option. */
616 int flag_new_exceptions = 0;
618 /* Nonzero means don't place uninitialized global data in common storage
623 /* Nonzero means pretend it is OK to examine bits of target floats,
624 even if that isn't true. The resulting code will have incorrect constants,
625 but the same series of instructions that the native compiler would make. */
627 int flag_pretend_float;
629 /* Nonzero means change certain warnings into errors.
630 Usually these are warnings about failure to conform to some standard. */
632 int flag_pedantic_errors = 0;
634 /* flag_schedule_insns means schedule insns within basic blocks (before
636 flag_schedule_insns_after_reload means schedule insns after
639 int flag_schedule_insns = 0;
640 int flag_schedule_insns_after_reload = 0;
643 /* The following flags have effect only for scheduling before register
646 flag_schedule_interblock means schedule insns accross basic blocks.
647 flag_schedule_speculative means allow speculative motion of non-load insns.
648 flag_schedule_speculative_load means allow speculative motion of some
650 flag_schedule_speculative_load_dangerous allows speculative motion of more
653 int flag_schedule_interblock = 1;
654 int flag_schedule_speculative = 1;
655 int flag_schedule_speculative_load = 0;
656 int flag_schedule_speculative_load_dangerous = 0;
658 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
659 by a cheaper branch, on a count register. */
660 int flag_branch_on_count_reg;
664 /* -finhibit-size-directive inhibits output of .size for ELF.
665 This is used only for compiling crtstuff.c,
666 and it may be extended to other effects
667 needed for crtstuff.c on other systems. */
668 int flag_inhibit_size_directive = 0;
670 /* -fverbose-asm causes extra commentary information to be produced in
671 the generated assembly code (to make it more readable). This option
672 is generally only of use to those who actually need to read the
673 generated assembly code (perhaps while debugging the compiler itself).
674 -fno-verbose-asm, the default, causes the extra information
675 to be omitted and is useful when comparing two assembler files. */
677 int flag_verbose_asm = 0;
679 /* -dA causes debug commentary information to be produced in
680 the generated assembly code (to make it more readable). This option
681 is generally only of use to those who actually need to read the
682 generated assembly code (perhaps while debugging the compiler itself).
683 Currently, this switch is only used by dwarfout.c; however, it is intended
684 to be a catchall for printing debug information in the assembler file. */
686 int flag_debug_asm = 0;
688 /* -fgnu-linker specifies use of the GNU linker for initializations.
689 (Or, more generally, a linker that handles initializations.)
690 -fno-gnu-linker says that collect2 will be used. */
692 int flag_gnu_linker = 0;
694 int flag_gnu_linker = 1;
697 /* Tag all structures with __attribute__(packed) */
698 int flag_pack_struct = 0;
700 /* Emit code to check for stack overflow; also may cause large objects
701 to be allocated dynamically. */
702 int flag_stack_check;
704 /* -fcheck-memory-usage causes extra code to be generated in order to check
705 memory accesses. This is used by a detector of bad memory accesses such
707 int flag_check_memory_usage = 0;
709 /* -fprefix-function-name causes function name to be prefixed. This
710 can be used with -fcheck-memory-usage to isolate code compiled with
711 -fcheck-memory-usage. */
712 int flag_prefix_function_name = 0;
714 /* 0 if pointer arguments may alias each other. True in C.
715 1 if pointer arguments may not alias each other but may alias
717 2 if pointer arguments may not alias each other and may not
718 alias global variables. True in Fortran.
719 This defaults to 0 for C. */
720 int flag_argument_noalias = 0;
722 /* Nonzero if we should do (language-dependent) alias analysis.
723 Typically, this analysis will assume that expressions of certain
724 types do not alias expressions of certain other types. Only used
725 if alias analysis (in general) is enabled. */
726 int flag_strict_aliasing = 0;
728 extern int flag_dump_unnumbered;
730 /* Instrument functions with calls at entry and exit, for profiling. */
731 int flag_instrument_function_entry_exit = 0;
734 /* Table of supported debugging formats. */
738 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
739 constant expression, we use NO_DEBUG in its place. */
740 enum debug_info_type debug_type;
741 int use_extensions_p;
746 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
747 "Generate default debug format output" },
748 { "ggdb", NO_DEBUG, 1, "Generate default extended debug format output" },
749 #ifdef DBX_DEBUGGING_INFO
750 { "gstabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
751 { "gstabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
753 #ifdef DWARF_DEBUGGING_INFO
754 { "gdwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
755 { "gdwarf+", DWARF_DEBUG, 1,
756 "Generated extended DWARF-1 format debug output" },
758 #ifdef DWARF2_DEBUGGING_INFO
759 { "gdwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
761 #ifdef XCOFF_DEBUGGING_INFO
762 { "gxcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
763 { "gxcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
765 #ifdef SDB_DEBUGGING_INFO
766 { "gcoff", SDB_DEBUG, 0, "Generate COFF format debug output" },
778 lang_independent_options;
780 /* Table of language-independent -f options.
781 STRING is the option name. VARIABLE is the address of the variable.
782 ON_VALUE is the value to store in VARIABLE
783 if `-fSTRING' is seen as an option.
784 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
786 lang_independent_options f_options[] =
788 {"float-store", &flag_float_store, 1,
789 "Do not store floats in registers" },
790 {"volatile", &flag_volatile, 1,
791 "Consider all mem refs through pointers as volatile"},
792 {"volatile-global", &flag_volatile_global, 1,
793 "Consider all mem refs to global data to be volatile" },
794 {"defer-pop", &flag_defer_pop, 1,
795 "Defer popping functions args from stack until later" },
796 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
797 "When possible do not generate stack frames"},
798 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
799 "When running CSE, follow jumps to their targets" },
800 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
801 "When running CSE, follow conditional jumps" },
802 {"expensive-optimizations", &flag_expensive_optimizations, 1,
803 "Perform a number of minor, expensive optimisations" },
804 {"thread-jumps", &flag_thread_jumps, 1,
805 "Perform jump threading optimisations"},
806 {"strength-reduce", &flag_strength_reduce, 1,
807 "Perform strength reduction optimisations" },
808 {"unroll-loops", &flag_unroll_loops, 1,
809 "Perform loop unrolling when interation count is known" },
810 {"unroll-all-loops", &flag_unroll_all_loops, 1,
811 "Perofm loop onrolling for all loops" },
812 {"move-all-movables", &flag_move_all_movables, 1,
813 "Force all loop invariant computations out of loops" },
814 {"reduce-all-givs", &flag_reduce_all_givs, 1,
815 "Strength reduce all loop general induction variables" },
816 {"writable-strings", &flag_writable_strings, 1,
817 "Store strings in writable data section" },
818 {"peephole", &flag_no_peephole, 0,
819 "Enable machine specific peephole optimisations" },
820 {"force-mem", &flag_force_mem, 1,
821 "Copy memory operands into registers before using" },
822 {"force-addr", &flag_force_addr, 1,
823 "Copy memory address constants into regs before using" },
824 {"function-cse", &flag_no_function_cse, 0,
825 "Allow function addresses to be held in registers" },
826 {"inline-functions", &flag_inline_functions, 1,
827 "Integrate simple functions into their callers" },
828 {"keep-inline-functions", &flag_keep_inline_functions, 1,
829 "Generate code for funcs even if they are fully inlined" },
830 {"inline", &flag_no_inline, 0,
831 "Pay attention to the 'inline' keyword"},
832 {"keep-static-consts", &flag_keep_static_consts, 1,
833 "Emit static const variables even if they are not used" },
834 {"syntax-only", &flag_syntax_only, 1,
835 "Check for syntax errors, then stop" },
836 {"shared-data", &flag_shared_data, 1,
837 "Mark data as shared rather than private" },
838 {"caller-saves", &flag_caller_saves, 1,
839 "Enable saving registers around function calls" },
840 {"pcc-struct-return", &flag_pcc_struct_return, 1,
841 "Return 'short' aggregates in memory, not registers" },
842 {"reg-struct-return", &flag_pcc_struct_return, 0,
843 "Return 'short' aggregates in registers" },
844 {"delayed-branch", &flag_delayed_branch, 1,
845 "Attempt to fill delay slots of branch instructions" },
846 {"gcse", &flag_gcse, 1,
847 "Perform the global common subexpression elimination" },
848 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
849 "Run CSE pass after loop optimisations"},
850 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
851 "Run the loop optimiser twice"},
852 {"pretend-float", &flag_pretend_float, 1,
853 "Pretend that host and target use the same FP format"},
854 {"schedule-insns", &flag_schedule_insns, 1,
855 "Reschedule instructions to avoid pipeline stalls"},
856 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
857 "Run two passes of the instruction scheduler"},
859 {"sched-interblock",&flag_schedule_interblock, 1,
860 "Enable scheduling across basic blocks" },
861 {"sched-spec",&flag_schedule_speculative, 1,
862 "Allow speculative motion of non-loads" },
863 {"sched-spec-load",&flag_schedule_speculative_load, 1,
864 "Allow speculative motion of some loads" },
865 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
866 "Allow speculative motion of more loads" },
867 {"branch-count-reg",&flag_branch_on_count_reg, 1,
868 "Replace add,compare,branch with branch on count reg"},
870 {"pic", &flag_pic, 1,
871 "Generate position independent code, if possible"},
872 {"PIC", &flag_pic, 2, ""},
873 {"exceptions", &flag_exceptions, 1,
874 "Enable exception handling" },
875 {"new-exceptions", &flag_new_exceptions, 1,
876 "Use the new model for exception handling" },
877 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
878 "Use setjmp/longjmp to handle exceptions" },
879 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
880 "Support asynchronous exceptions" },
881 {"profile-arcs", &profile_arc_flag, 1,
882 "Insert arc based program profiling code" },
883 {"test-coverage", &flag_test_coverage, 1,
884 "Create data files needed by gcov" },
885 {"branch-probabilities", &flag_branch_probabilities, 1,
886 "Use profiling information for branch porbabilities" },
887 {"fast-math", &flag_fast_math, 1,
888 "Improve FP speed by violating ANSI & IEEE rules" },
889 {"common", &flag_no_common, 0,
890 "Do not put unitialised globals in the common section" },
891 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
892 "Do not generate .size directives" },
893 {"function-sections", &flag_function_sections, 1,
894 "place each function into its own section" },
895 {"verbose-asm", &flag_verbose_asm, 1,
896 "Add extra commentry to assembler output"},
897 {"gnu-linker", &flag_gnu_linker, 1,
898 "Output GNU ld formatted global initialisers"},
899 {"regmove", &flag_regmove, 1,
900 "Enables a regoster move optimisation"},
901 {"optimize-register-move", &flag_regmove, 1},
902 {"pack-struct", &flag_pack_struct, 1,
903 "Pack structure members together without holes" },
904 {"stack-check", &flag_stack_check, 1,
905 "Insert stack checking code into the program" },
906 {"argument-alias", &flag_argument_noalias, 0,
907 "Specify that arguments may alias each other & globals"},
908 {"argument-noalias", &flag_argument_noalias, 1,
909 "Assume arguments may alias globals but not each other"},
910 {"argument-noalias-global", &flag_argument_noalias, 2,
911 "Assume arguments do not alias each other or globals" },
912 {"strict-aliasing", &flag_strict_aliasing, 1,
913 "Assume strict aliasing rules apply" },
914 {"check-memory-usage", &flag_check_memory_usage, 1,
915 "Generate code to check every memory access" },
916 {"prefix-function-name", &flag_prefix_function_name, 1,
917 "Add a prefix to all function names" },
918 {"dump-unnumbered", &flag_dump_unnumbered, 1},
919 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
920 "Instrument function entry/exit with profiling calls"},
923 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
925 /* Table of language-specific options. */
927 static struct lang_opt
932 documented_lang_options[] =
934 /* In order not to overload the --help output, the convention
935 used here is to only describe those options which are not
936 enabled by default. */
938 { "-ansi", "Compile just for ANSI C" },
939 {"data-sections", &flag_data_sections, 1,
940 "place data items into their own section" },
941 { "-fallow-single-precision",
942 "Do not promote floats to double if using -traditional" },
944 { "-fsigned-bitfields", "" },
945 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
946 { "-fno-signed-bitfields", "" },
947 { "-fno-unsigned-bitfields","" },
948 { "-fsigned-char", "Make 'char' be signed by default"},
949 { "-funsigned-char", "Make 'char' be unsigned by default"},
950 { "-fno-signed-char", "" },
951 { "-fno-unsigned-char", "" },
953 { "-ftraditional", "" },
954 { "-traditional", "Attempt to support traditional K&R style C"},
955 { "-fnotraditional", "" },
956 { "-fno-traditional", "" },
959 { "-fno-asm", "Do not recognise the 'asm' keyword" },
961 { "-fno-builtin", "Do not recognise any built in functions" },
962 { "-fhosted", "Assume normal C execution environment" },
963 { "-fno-hosted", "" },
965 "Assume that standard libraries & main might not exist" },
966 { "-fno-freestanding", "" },
967 { "-fcond-mismatch", "Allow different types as args of ? operator"},
968 { "-fno-cond-mismatch", "" },
969 { "-fdollars-in-identifiers", "Allow the use of $ inside indentifiers" },
970 { "-fno-dollars-in-identifiers", "" },
972 { "-fno-ident", "Ignore #ident directives" },
973 { "-fshort-double", "Use the same size for double as for float" },
974 { "-fno-short-double", "" },
975 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
976 { "-fno-short-enums", "" },
978 { "-Wall", "Enable most warning messages" },
979 { "-Wbad-function-cast",
980 "Warn about casting functions to incompatible types" },
981 { "-Wno-bad-function-cast", "" },
982 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
983 { "-Wno-cast-qual", "" },
984 { "-Wchar-subscripts", "Warn about subscripts whoes type is 'char'"},
985 { "-Wno-char-subscripts", "" },
986 { "-Wcomment", "Warn if nested comments are detected" },
989 { "-Wno-comments", },
990 { "-Wconversion", "Warn about possibly confusing type conversions" },
991 { "-Wno-conversion", "" },
992 { "-Wformat", "Warn about printf format anomalies" },
993 { "-Wno-format", "" },
994 { "-Wimplicit-function-declaration",
995 "Warn about implicit function declarations" },
996 { "-Wno-implicit-function-declaration", "" },
997 { "-Werror-implicit-function-declaration", "" },
998 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
999 { "-Wno-implicit-int", "" },
1000 { "-Wimplicit", "" },
1001 { "-Wno-implicit", "" },
1002 { "-Wimport", "Warn about the use of the #import directive" },
1003 { "-Wno-import", "" },
1004 { "-Wlong-long","" },
1005 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1006 { "-Wmain", "Warn about suspicious declarations of main" },
1007 { "-Wno-main", "" },
1008 { "-Wmissing-braces",
1009 "Warn about possibly missing braces around initialisers" },
1010 { "-Wno-missing-braces", "" },
1011 { "-Wmissing-declarations",
1012 "Warn about global funcs without previous declarations"},
1013 { "-Wno-missing-declarations", "" },
1014 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1015 { "-Wno-missing-prototypes", "" },
1016 { "-Wmultichar", "Warn about use of multicharacter literals"},
1017 { "-Wno-multichar", "" },
1018 { "-Wnested-externs", "Warn about externs not at file scope level" },
1019 { "-Wno-nested-externs", "" },
1020 { "-Wparentheses", "Warn about possible missing parentheses" },
1021 { "-Wno-parentheses", "" },
1022 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1023 { "-Wno-pointer-arith", "" },
1024 { "-Wredundant-decls",
1025 "Warn about multiple declarations of the same object" },
1026 { "-Wno-redundant-decls", "" },
1027 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1028 { "-Wno-sign-compare", "" },
1029 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1030 { "-Wno-unknown-pragmas", "" },
1031 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1032 { "-Wno-strict-prototypes", "" },
1033 { "-Wtraditional", "Warn about constructs whoes meaning change in ANSI C"},
1034 { "-Wno-traditional", "" },
1035 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1036 { "-Wno-trigraphs", "" },
1038 { "-Wno-undef", "" },
1039 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1040 { "-Wno-write-strings", "" },
1042 /* These are for languages with USE_CPPLIB. */
1043 /* These options are already documented in cpplib.c */
1049 { "-idirafter", "" },
1053 { "-lang-c89", "" },
1054 { "-lang-c++", "" },
1055 { "-nostdinc", "" },
1056 { "-nostdinc++", "" },
1057 { "-trigraphs", "" },
1061 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1063 /* These are for obj c. */
1064 DEFINE_LANG_NAME ("Objective C")
1066 { "-lang-objc", "" },
1067 { "-gen-decls", "Dump decls to a .decl file" },
1068 { "-fgnu-runtime", "Generate code for GNU runtime envrionment" },
1069 { "-fno-gnu-runtime", "" },
1070 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1071 { "-fno-next-runtime", "" },
1072 { "-Wselector", "Warn if a selector has multiple methods" },
1073 { "-Wno-selector", "" },
1074 { "-Wprotocol", "" },
1075 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1076 { "-print-objc-runtime-info",
1077 "Generate C header of platform specific features" },
1079 #include "options.h"
1083 /* Here is a table, controlled by the tm.h file, listing each -m switch
1084 and which bits in `target_switches' it should set or clear.
1085 If VALUE is positive, it is bits to set.
1086 If VALUE is negative, -VALUE is bits to clear.
1087 (The sign bit is not used so there is no confusion.) */
1095 target_switches [] = TARGET_SWITCHES;
1097 /* This table is similar, but allows the switch to have a value. */
1099 #ifdef TARGET_OPTIONS
1106 target_options [] = TARGET_OPTIONS;
1109 /* Options controlling warnings */
1111 /* Don't print warning messages. -w. */
1113 int inhibit_warnings = 0;
1115 /* Print various extra warnings. -W. */
1117 int extra_warnings = 0;
1119 /* Treat warnings as errors. -Werror. */
1121 int warnings_are_errors = 0;
1123 /* Nonzero to warn about unused local variables. */
1127 /* Nonzero to warn about variables used before they are initialized. */
1129 int warn_uninitialized;
1131 /* Nonzero means warn about all declarations which shadow others. */
1135 /* Warn if a switch on an enum fails to have a case for every enum value. */
1139 /* Nonzero means warn about function definitions that default the return type
1140 or that use a null return and have a return-type other than void. */
1142 int warn_return_type;
1144 /* Nonzero means warn about pointer casts that increase the required
1145 alignment of the target type (and might therefore lead to a crash
1146 due to a misaligned access). */
1148 int warn_cast_align;
1150 /* Nonzero means warn about any identifiers that match in the first N
1151 characters. The value N is in `id_clash_len'. */
1154 unsigned id_clash_len;
1156 /* Nonzero means warn about any objects definitions whose size is larger
1157 than N bytes. Also want about function definitions whose returned
1158 values are larger than N bytes. The value N is in `larger_than_size'. */
1160 int warn_larger_than;
1161 unsigned larger_than_size;
1163 /* Nonzero means warn if inline function is too large. */
1167 /* Warn if a function returns an aggregate,
1168 since there are often incompatible calling conventions for doing this. */
1170 int warn_aggregate_return;
1172 /* Likewise for -W. */
1174 lang_independent_options W_options[] =
1176 {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1177 {"error", &warnings_are_errors, 1, ""},
1178 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1179 {"switch", &warn_switch, 1,
1180 "Warn about enumerated switches missing a specific case" },
1181 {"aggregate-return", &warn_aggregate_return, 1,
1182 "Warn about returning structures, unions or arrays" },
1183 {"cast-align", &warn_cast_align, 1,
1184 "Warn about pointer casts which increase alignment" },
1185 {"uninitialized", &warn_uninitialized, 1,
1186 "Warn about unitialized automatic variables"},
1187 {"inline", &warn_inline, 1,
1188 "Warn when an inlined function cannot be inlined"}
1191 /* Output files for assembler code (real compiler output)
1192 and debugging dumps. */
1195 FILE *aux_info_file;
1196 FILE *rtl_dump_file = NULL;
1198 /* Time accumulators, to count the total time spent in various passes. */
1202 int integration_time;
1208 int branch_prob_time;
1213 int local_alloc_time;
1214 int global_alloc_time;
1219 int shorten_branch_time;
1225 /* Return time used so far, in microseconds. */
1235 #else /* not BeOS */
1236 #if defined (_WIN32) && !defined (__CYGWIN32__)
1240 return (clock() * 1000);
1241 #else /* not _WIN32 */
1247 tick = 1000000 / sysconf(_SC_CLK_TCK);
1249 return (tms.tms_utime + tms.tms_stime) * tick;
1255 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1256 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1259 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1261 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1265 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1270 struct rusage rusage;
1271 getrusage (0, &rusage);
1272 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1273 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1280 int proc_system_time;
1281 int child_user_time;
1282 int child_system_time;
1284 times ((void *) &vms_times);
1285 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1289 #endif /* _SC_CLK_TCK */
1291 #endif /* __BEOS__ */
1294 #define TIMEVAR(VAR, BODY) \
1295 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1298 print_time (str, total)
1303 "time in %s: %d.%06d\n",
1304 str, total / 1000000, total % 1000000);
1307 /* Count an error or warning. Return 1 if the message should be printed. */
1310 count_error (warningp)
1313 if (warningp && inhibit_warnings)
1316 if (warningp && !warnings_are_errors)
1320 static int warning_message = 0;
1322 if (warningp && !warning_message)
1324 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
1325 warning_message = 1;
1333 /* Print a fatal error message. NAME is the text.
1334 Also include a system error message based on `errno'. */
1337 pfatal_with_name (name)
1340 fprintf (stderr, "%s: ", progname);
1342 exit (FATAL_EXIT_CODE);
1346 fatal_io_error (name)
1349 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
1350 exit (FATAL_EXIT_CODE);
1353 /* Called to give a better error message for a bad insn rather than
1354 just calling abort(). */
1357 fatal_insn (message, insn)
1364 fflush (asm_out_file);
1366 fflush (aux_info_file);
1367 if (rtl_dump_file != NULL)
1368 fflush (rtl_dump_file);
1374 /* Called to give a better error message when we don't have an insn to match
1375 what we are looking for or if the insn's constraints aren't satisfied,
1376 rather than just calling abort(). */
1379 fatal_insn_not_found (insn)
1382 if (INSN_CODE (insn) < 0)
1383 fatal_insn ("internal error--unrecognizable insn:", insn);
1385 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1388 /* This is the default decl_printable_name function. */
1391 decl_name (decl, verbosity)
1393 int verbosity ATTRIBUTE_UNUSED;
1395 return IDENTIFIER_POINTER (DECL_NAME (decl));
1398 static int need_error_newline;
1400 /* Function of last error message;
1401 more generally, function such that if next error message is in it
1402 then we don't have to mention the function name. */
1403 static tree last_error_function = NULL;
1405 /* Used to detect when input_file_stack has changed since last described. */
1406 static int last_error_tick;
1408 /* Called when the start of a function definition is parsed,
1409 this function prints on stderr the name of the function. */
1412 announce_function (decl)
1417 if (rtl_dump_and_exit)
1418 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1420 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1422 need_error_newline = 1;
1423 last_error_function = current_function_decl;
1427 /* The default function to print out name of current function that caused
1431 default_print_error_function (file)
1434 if (last_error_function != current_function_decl)
1436 char *kind = "function";
1437 if (current_function_decl != 0
1438 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1442 fprintf (stderr, "%s: ", file);
1444 if (current_function_decl == NULL)
1445 fprintf (stderr, "At top level:\n");
1448 char *name = (*decl_printable_name) (current_function_decl, 2);
1449 fprintf (stderr, "In %s `%s':\n", kind, name);
1452 last_error_function = current_function_decl;
1456 /* Called by report_error_function to print out function name.
1457 * Default may be overridden by language front-ends. */
1459 void (*print_error_function) PROTO((char *)) = default_print_error_function;
1461 /* Prints out, if necessary, the name of the current function
1462 that caused an error. Called from all error and warning functions. */
1465 report_error_function (file)
1468 struct file_stack *p;
1470 if (need_error_newline)
1472 fprintf (stderr, "\n");
1473 need_error_newline = 0;
1476 (*print_error_function) (file);
1478 if (input_file_stack && input_file_stack->next != 0
1479 && input_file_stack_tick != last_error_tick
1480 && file == input_filename)
1482 fprintf (stderr, "In file included");
1483 for (p = input_file_stack->next; p; p = p->next)
1485 fprintf (stderr, " from %s:%d", p->name, p->line);
1487 fprintf (stderr, ",\n ");
1489 fprintf (stderr, ":\n");
1490 last_error_tick = input_file_stack_tick;
1494 /* Print a message. */
1497 vmessage (prefix, s, ap)
1503 fprintf (stderr, "%s: ", prefix);
1505 vfprintf (stderr, s, ap);
1508 /* Print a message relevant to line LINE of file FILE. */
1511 v_message_with_file_and_line (file, line, prefix, s, ap)
1519 fprintf (stderr, "%s:%d: ", file, line);
1521 fprintf (stderr, "%s: ", progname);
1523 vmessage (prefix, s, ap);
1524 fputc ('\n', stderr);
1527 /* Print a message relevant to the given DECL. */
1530 v_message_with_decl (decl, prefix, s, ap)
1538 fprintf (stderr, "%s:%d: ",
1539 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1542 fprintf (stderr, "%s: ", prefix);
1544 /* Do magic to get around lack of varargs support for insertion
1545 of arguments into existing list. We know that the decl is first;
1546 we ass_u_me that it will be printed with "%s". */
1548 for (p = s; *p; ++p)
1552 if (*(p + 1) == '%')
1559 if (p > s) /* Print the left-hand substring. */
1561 char fmt[sizeof "%.255s"];
1564 if (width > 255L) width = 255L; /* arbitrary */
1565 sprintf (fmt, "%%.%lds", width);
1566 fprintf (stderr, fmt, s);
1569 if (*p == '%') /* Print the name. */
1571 char *n = (DECL_NAME (decl)
1572 ? (*decl_printable_name) (decl, 2)
1578 if (ISALPHA (*(p - 1) & 0xFF))
1583 if (*p) /* Print the rest of the message. */
1584 vmessage ((char *)NULL, p, ap);
1586 fputc ('\n', stderr);
1589 /* Figure file and line of the given INSN. */
1592 file_and_line_for_asm (insn, pfile, pline)
1597 rtx body = PATTERN (insn);
1600 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1601 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1602 asmop = SET_SRC (body);
1603 else if (GET_CODE (body) == ASM_OPERANDS)
1605 else if (GET_CODE (body) == PARALLEL
1606 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1607 asmop = SET_SRC (XVECEXP (body, 0, 0));
1608 else if (GET_CODE (body) == PARALLEL
1609 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1610 asmop = XVECEXP (body, 0, 0);
1616 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1617 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1621 *pfile = input_filename;
1626 /* Report an error at line LINE of file FILE. */
1629 v_error_with_file_and_line (file, line, s, ap)
1636 report_error_function (file);
1637 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1641 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1653 file = va_arg (ap, char *);
1654 line = va_arg (ap, int);
1655 s = va_arg (ap, char *);
1658 v_error_with_file_and_line (file, line, s, ap);
1662 /* Report an error at the declaration DECL.
1663 S is a format string which uses %s to substitute the declaration
1664 name; subsequent substitutions are a la printf. */
1667 v_error_with_decl (decl, s, ap)
1673 report_error_function (DECL_SOURCE_FILE (decl));
1674 v_message_with_decl (decl, (char *)NULL, s, ap);
1678 error_with_decl VPROTO((tree decl, char *s, ...))
1689 decl = va_arg (ap, tree);
1690 s = va_arg (ap, char *);
1693 v_error_with_decl (decl, s, ap);
1697 /* Report an error at the line number of the insn INSN.
1698 This is used only when INSN is an `asm' with operands,
1699 and each ASM_OPERANDS records its own source file and line. */
1702 v_error_for_asm (insn, s, ap)
1711 file_and_line_for_asm (insn, &file, &line);
1712 report_error_function (file);
1713 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1717 error_for_asm VPROTO((rtx insn, char *s, ...))
1728 insn = va_arg (ap, rtx);
1729 s = va_arg (ap, char *);
1732 v_error_for_asm (insn, s, ap);
1736 /* Report an error at the current line number. */
1743 v_error_with_file_and_line (input_filename, lineno, s, ap);
1747 error VPROTO((char *s, ...))
1757 s = va_arg (ap, char *);
1764 /* Report a fatal error at the current line number. */
1772 exit (FATAL_EXIT_CODE);
1776 fatal VPROTO((char *s, ...))
1786 s = va_arg (ap, char *);
1793 /* Report a warning at line LINE of file FILE. */
1796 v_warning_with_file_and_line (file, line, s, ap)
1802 if (count_error (1))
1804 report_error_function (file);
1805 v_message_with_file_and_line (file, line, "warning", s, ap);
1810 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1822 file = va_arg (ap, char *);
1823 line = va_arg (ap, int);
1824 s = va_arg (ap, char *);
1827 v_warning_with_file_and_line (file, line, s, ap);
1831 /* Report a warning at the declaration DECL.
1832 S is a format string which uses %s to substitute the declaration
1833 name; subsequent substitutions are a la printf. */
1836 v_warning_with_decl (decl, s, ap)
1841 if (count_error (1))
1843 report_error_function (DECL_SOURCE_FILE (decl));
1844 v_message_with_decl (decl, "warning", s, ap);
1849 warning_with_decl VPROTO((tree decl, char *s, ...))
1860 decl = va_arg (ap, tree);
1861 s = va_arg (ap, char *);
1864 v_warning_with_decl (decl, s, ap);
1868 /* Report a warning at the line number of the insn INSN.
1869 This is used only when INSN is an `asm' with operands,
1870 and each ASM_OPERANDS records its own source file and line. */
1873 v_warning_for_asm (insn, s, ap)
1878 if (count_error (1))
1883 file_and_line_for_asm (insn, &file, &line);
1884 report_error_function (file);
1885 v_message_with_file_and_line (file, line, "warning", s, ap);
1890 warning_for_asm VPROTO((rtx insn, char *s, ...))
1901 insn = va_arg (ap, rtx);
1902 s = va_arg (ap, char *);
1905 v_warning_for_asm (insn, s, ap);
1909 /* Report a warning at the current line number. */
1916 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1920 warning VPROTO((char *s, ...))
1930 s = va_arg (ap, char *);
1937 /* These functions issue either warnings or errors depending on
1938 -pedantic-errors. */
1945 if (flag_pedantic_errors)
1952 pedwarn VPROTO((char *s, ...))
1962 s = va_arg (ap, char *);
1970 v_pedwarn_with_decl (decl, s, ap)
1975 /* We don't want -pedantic-errors to cause the compilation to fail from
1976 "errors" in system header files. Sometimes fixincludes can't fix what's
1977 broken (eg: unsigned char bitfields - fixing it may change the alignment
1978 which will cause programs to mysteriously fail because the C library
1979 or kernel uses the original layout). There's no point in issuing a
1980 warning either, it's just unnecessary noise. */
1982 if (! DECL_IN_SYSTEM_HEADER (decl))
1984 if (flag_pedantic_errors)
1985 v_error_with_decl (decl, s, ap);
1987 v_warning_with_decl (decl, s, ap);
1992 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
2003 decl = va_arg (ap, tree);
2004 s = va_arg (ap, char *);
2007 v_pedwarn_with_decl (decl, s, ap);
2012 v_pedwarn_with_file_and_line (file, line, s, ap)
2018 if (flag_pedantic_errors)
2019 v_error_with_file_and_line (file, line, s, ap);
2021 v_warning_with_file_and_line (file, line, s, ap);
2025 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
2037 file = va_arg (ap, char *);
2038 line = va_arg (ap, int);
2039 s = va_arg (ap, char *);
2042 v_pedwarn_with_file_and_line (file, line, s, ap);
2046 /* Apologize for not implementing some feature. */
2055 fprintf (stderr, "%s:%d: ", input_filename, lineno);
2057 fprintf (stderr, "%s: ", progname);
2058 vmessage ("sorry, not implemented", s, ap);
2059 fputc ('\n', stderr);
2063 sorry VPROTO((char *s, ...))
2073 s = va_arg (ap, char *);
2080 /* Apologize for not implementing some feature, then quit. */
2083 v_really_sorry (s, ap)
2089 fprintf (stderr, "%s:%d: ", input_filename, lineno);
2091 fprintf (stderr, "%s: ", progname);
2092 vmessage ("sorry, not implemented", s, ap);
2093 fatal (" (fatal)\n");
2097 really_sorry VPROTO((char *s, ...))
2107 s = va_arg (ap, char *);
2110 v_really_sorry (s, ap);
2114 /* More 'friendly' abort that prints the line and file.
2115 config.h can #define abort fancy_abort if you like that sort of thing.
2117 I don't think this is actually a good idea.
2118 Other sorts of crashes will look a certain way.
2119 It is a good thing if crashes from calling abort look the same way.
2125 fatal ("internal gcc abort");
2128 /* This calls abort and is used to avoid problems when abort if a macro.
2129 It is used when we need to pass the address of abort. */
2137 /* When `malloc.c' is compiled with `rcheck' defined,
2138 it calls this function to report clobberage. */
2142 char * s ATTRIBUTE_UNUSED;
2147 /* Same as `malloc' but report error if no memory available. */
2153 register char *value;
2158 value = (char *) malloc (size);
2160 fatal ("virtual memory exhausted");
2164 /* Same as `calloc' but report error if no memory available. */
2167 xcalloc (size1, size2)
2168 unsigned size1, size2;
2170 register char *value;
2172 if (size1 == 0 || size2 == 0)
2175 value = (char *) calloc (size1, size2);
2177 fatal ("virtual memory exhausted");
2182 /* Same as `realloc' but report error if no memory available.
2183 Also handle null PTR even if the vendor realloc gets it wrong. */
2186 xrealloc (ptr, size)
2196 ? (char *) realloc (ptr, size)
2197 : (char *) malloc (size));
2200 fatal ("virtual memory exhausted");
2205 /* Same as `strdup' but report error if no memory available. */
2211 register char *result = (char *) malloc (strlen (s) + 1);
2214 fatal ("virtual memory exhausted");
2219 /* Return the logarithm of X, base 2, considering X unsigned,
2220 if X is a power of 2. Otherwise, returns -1.
2222 This should be used via the `exact_log2' macro. */
2226 register unsigned HOST_WIDE_INT x;
2228 register int log = 0;
2229 /* Test for 0 or a power of 2. */
2230 if (x == 0 || x != (x & -x))
2232 while ((x >>= 1) != 0)
2237 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2238 If X is 0, return -1.
2240 This should be used via the floor_log2 macro. */
2244 register unsigned HOST_WIDE_INT x;
2246 register int log = -1;
2253 static int float_handler_set;
2255 jmp_buf float_handler;
2257 /* Signals actually come here. */
2260 float_signal (signo)
2261 /* If this is missing, some compilers complain. */
2262 int signo ATTRIBUTE_UNUSED;
2264 if (float_handled == 0)
2266 #if defined (USG) || defined (hpux)
2267 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2270 signal (SIGFPE, float_signal);
2271 longjmp (float_handler, 1);
2274 /* Specify where to longjmp to when a floating arithmetic error happens.
2275 If HANDLER is 0, it means don't handle the errors any more. */
2278 set_float_handler (handler)
2281 float_handled = (handler != 0);
2283 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2285 if (float_handled && ! float_handler_set)
2287 signal (SIGFPE, float_signal);
2288 float_handler_set = 1;
2292 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2293 error happens, pushing the previous specification into OLD_HANDLER.
2294 Return an indication of whether there was a previous handler in effect. */
2297 push_float_handler (handler, old_handler)
2298 jmp_buf handler, old_handler;
2300 int was_handled = float_handled;
2304 memcpy ((char *) old_handler, (char *) float_handler,
2305 sizeof (float_handler));
2307 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
2311 /* Restore the previous specification of whether and where to longjmp to
2312 when a floating arithmetic error happens. */
2315 pop_float_handler (handled, handler)
2319 float_handled = handled;
2321 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2324 /* Handler for SIGPIPE. */
2328 /* If this is missing, some compilers complain. */
2329 int signo ATTRIBUTE_UNUSED;
2331 fatal ("output pipe has been closed");
2334 /* Strip off a legitimate source ending from the input string NAME of
2335 length LEN. Rather than having to know the names used by all of
2336 our front ends, we strip off an ending of a period followed by
2337 up to five characters. (Java uses ".class".) */
2340 strip_off_ending (name, len)
2345 for (i = 2; i < 6 && len > i; i++)
2347 if (name[len - i] == '.')
2349 name[len - i] = '\0';
2355 /* Output a quoted string. */
2358 output_quoted_string (asm_file, string)
2362 #ifdef OUTPUT_QUOTED_STRING
2363 OUTPUT_QUOTED_STRING (asm_file, string);
2367 putc ('\"', asm_file);
2368 while ((c = *string++) != 0)
2370 if (c == '\"' || c == '\\')
2371 putc ('\\', asm_file);
2374 putc ('\"', asm_file);
2378 /* Output a file name in the form wanted by System V. */
2381 output_file_directive (asm_file, input_name)
2385 int len = strlen (input_name);
2386 char *na = input_name + len;
2388 /* NA gets INPUT_NAME sans directory names. */
2389 while (na > input_name)
2396 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2397 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2399 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2400 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2402 fprintf (asm_file, "\t.file\t");
2403 output_quoted_string (asm_file, na);
2404 fputc ('\n', asm_file);
2409 /* Routine to build language identifier for object file. */
2412 output_lang_identify (asm_out_file)
2415 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2416 char *s = (char *) alloca (len);
2417 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2418 ASM_OUTPUT_LABEL (asm_out_file, s);
2421 /* Routine to open a dump file. */
2423 open_dump_file (suffix, function_name)
2425 char *function_name;
2432 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2434 if (rtl_dump_file != NULL)
2435 fclose (rtl_dump_file);
2437 strcpy (dumpname, dump_base_name);
2438 strcat (dumpname, suffix);
2440 rtl_dump_file = fopen (dumpname, "a");
2442 if (rtl_dump_file == NULL)
2443 pfatal_with_name (dumpname);
2448 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2454 /* Routine to close a dump file. */
2456 close_dump_file (func, insns)
2457 void (*func) PROTO ((FILE *, rtx));
2464 func (rtl_dump_file, insns);
2466 fflush (rtl_dump_file);
2467 fclose (rtl_dump_file);
2469 rtl_dump_file = NULL;
2475 /* Routine to dump rtl into a file. */
2477 dump_rtl (suffix, decl, func, insns)
2480 void (*func) PROTO ((FILE *, rtx));
2483 open_dump_file (suffix, decl_printable_name (decl, 2));
2484 close_dump_file (func, insns);
2487 /* Routine to empty a dump file. */
2489 clean_dump_file (suffix)
2494 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2496 strcpy (dumpname, dump_base_name);
2497 strcat (dumpname, suffix);
2499 rtl_dump_file = fopen (dumpname, "w");
2501 if (rtl_dump_file == NULL)
2502 pfatal_with_name (dumpname);
2506 fclose (rtl_dump_file);
2507 rtl_dump_file = NULL;
2513 /* Compile an entire file of output from cpp, named NAME.
2514 Write a file of assembly output and various debugging dumps. */
2523 int name_specified = name != 0;
2525 if (dump_base_name == 0)
2526 dump_base_name = name ? name : "gccdump";
2530 integration_time = 0;
2536 branch_prob_time = 0;
2541 local_alloc_time = 0;
2542 global_alloc_time = 0;
2547 shorten_branch_time = 0;
2553 /* Initialize data in various passes. */
2557 name = init_parse (name);
2559 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2560 || debug_info_level == DINFO_LEVEL_VERBOSE
2561 || flag_test_coverage);
2563 init_decl_processing ();
2572 if (flag_caller_saves)
2573 init_caller_save ();
2575 /* If auxiliary info generation is desired, open the output file.
2576 This goes in the same directory as the source file--unlike
2577 all the other output files. */
2578 if (flag_gen_aux_info)
2580 aux_info_file = fopen (aux_info_file_name, "w");
2581 if (aux_info_file == 0)
2582 pfatal_with_name (aux_info_file_name);
2585 /* Clear the dump files file. */
2587 clean_dump_file (".rtl");
2589 clean_dump_file (".jump");
2591 clean_dump_file (".addressof");
2593 clean_dump_file (".cse");
2595 clean_dump_file (".loop");
2597 clean_dump_file (".cse2");
2598 if (branch_prob_dump)
2599 clean_dump_file (".bp");
2601 clean_dump_file (".flow");
2603 clean_dump_file (".combine");
2605 clean_dump_file (".regmove");
2607 clean_dump_file (".sched");
2609 clean_dump_file (".lreg");
2610 if (global_reg_dump)
2611 clean_dump_file (".greg");
2613 clean_dump_file (".sched2");
2615 clean_dump_file (".jump2");
2618 clean_dump_file (".dbr");
2621 clean_dump_file (".gcse");
2624 clean_dump_file (".stack");
2626 #ifdef MACHINE_DEPENDENT_REORG
2627 if (mach_dep_reorg_dump)
2628 clean_dump_file (".mach");
2631 /* Open assembler code output file. */
2633 if (! name_specified && asm_file_name == 0)
2634 asm_out_file = stdout;
2637 int len = strlen (dump_base_name);
2638 register char *dumpname = (char *) xmalloc (len + 6);
2639 strcpy (dumpname, dump_base_name);
2640 strip_off_ending (dumpname, len);
2641 strcat (dumpname, ".s");
2642 if (asm_file_name == 0)
2644 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2645 strcpy (asm_file_name, dumpname);
2647 if (!strcmp (asm_file_name, "-"))
2648 asm_out_file = stdout;
2650 asm_out_file = fopen (asm_file_name, "w");
2651 if (asm_out_file == 0)
2652 pfatal_with_name (asm_file_name);
2655 #ifdef IO_BUFFER_SIZE
2656 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2657 _IOFBF, IO_BUFFER_SIZE);
2660 input_filename = name;
2662 /* Put an entry on the input file stack for the main input file. */
2664 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2665 input_file_stack->next = 0;
2666 input_file_stack->name = input_filename;
2668 /* Perform language-specific initialization.
2669 This may set main_input_filename. */
2672 /* If the input doesn't start with a #line, use the input name
2673 as the official input file name. */
2674 if (main_input_filename == 0)
2675 main_input_filename = name;
2677 ASM_FILE_START (asm_out_file);
2679 #ifdef ASM_COMMENT_START
2680 if (flag_verbose_asm)
2682 /* Print the list of options in effect. */
2683 print_version (asm_out_file, ASM_COMMENT_START);
2684 print_switch_values (asm_out_file, 0, MAX_LINE,
2685 ASM_COMMENT_START, " ", "\n");
2686 /* Add a blank line here so it appears in assembler output but not
2688 fprintf (asm_out_file, "\n");
2692 /* Output something to inform GDB that this compilation was by GCC. */
2693 #ifndef ASM_IDENTIFY_GCC
2694 fprintf (asm_out_file, "gcc2_compiled.:\n");
2696 ASM_IDENTIFY_GCC (asm_out_file);
2699 /* Output something to identify which front-end produced this file. */
2700 #ifdef ASM_IDENTIFY_LANGUAGE
2701 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2704 #ifndef ASM_OUTPUT_SECTION_NAME
2705 if (flag_function_sections)
2707 warning ("-ffunction-sections not supported for this target.");
2708 flag_function_sections = 0;
2712 if (flag_function_sections
2713 && (profile_flag || profile_block_flag))
2715 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2716 flag_function_sections = 0;
2719 if (flag_function_sections && write_symbols != NO_DEBUG)
2720 warning ("-ffunction-sections may affect debugging on some targets.");
2722 /* ??? Note: There used to be a conditional here
2723 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2724 This was to guarantee separation between gcc_compiled. and
2725 the first function, for the sake of dbx on Suns.
2726 However, having the extra zero here confused the Emacs
2727 code for unexec, and might confuse other programs too.
2728 Therefore, I took out that change.
2729 In future versions we should find another way to solve
2730 that dbx problem. -- rms, 23 May 93. */
2732 /* Don't let the first function fall at the same address
2733 as gcc_compiled., if profiling. */
2734 if (profile_flag || profile_block_flag)
2736 /* It's best if we can write a nop here since some
2737 assemblers don't tolerate zeros in the text section. */
2738 if (insn_template[CODE_FOR_nop] != 0)
2739 output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR);
2741 assemble_zeros (UNITS_PER_WORD);
2744 /* If dbx symbol table desired, initialize writing it
2745 and output the predefined types. */
2746 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2747 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2748 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2751 #ifdef SDB_DEBUGGING_INFO
2752 if (write_symbols == SDB_DEBUG)
2753 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2756 #ifdef DWARF_DEBUGGING_INFO
2757 if (write_symbols == DWARF_DEBUG)
2758 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2760 #ifdef DWARF2_UNWIND_INFO
2761 if (dwarf2out_do_frame ())
2762 dwarf2out_frame_init ();
2764 #ifdef DWARF2_DEBUGGING_INFO
2765 if (write_symbols == DWARF2_DEBUG)
2766 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2769 /* Initialize yet another pass. */
2771 init_final (main_input_filename);
2772 init_branch_prob (dump_base_name);
2774 start_time = get_run_time ();
2776 /* Call the parser, which parses the entire file
2777 (calling rest_of_compilation for each function). */
2779 if (yyparse () != 0)
2781 if (errorcount == 0)
2782 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2784 /* In case there were missing closebraces,
2785 get us back to the global binding level. */
2786 while (! global_bindings_p ())
2790 output_func_start_profiler ();
2792 /* Compilation is now finished except for writing
2793 what's left of the symbol table output. */
2795 parse_time += get_run_time () - start_time;
2797 parse_time -= integration_time;
2798 parse_time -= varconst_time;
2800 globals = getdecls ();
2802 /* Really define vars that have had only a tentative definition.
2803 Really output inline functions that must actually be callable
2804 and have not been output so far. */
2807 int len = list_length (globals);
2808 tree *vec = (tree *) alloca (sizeof (tree) * len);
2813 /* Process the decls in reverse order--earliest first.
2814 Put them into VEC from back to front, then take out from front. */
2816 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2817 vec[len - i - 1] = decl;
2818 if (flag_data_sections)
2820 warning ("-fdata-sections not supported for this target.");
2821 flag_data_sections = 0;
2825 for (i = 0; i < len; i++)
2829 /* We're not deferring this any longer. */
2830 DECL_DEFER_OUTPUT (decl) = 0;
2832 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2833 && incomplete_decl_finalize_hook != 0)
2834 (*incomplete_decl_finalize_hook) (decl);
2837 /* Now emit any global variables or functions that we have been putting
2838 off. We need to loop in case one of the things emitted here
2839 references another one which comes earlier in the list. */
2843 for (i = 0; i < len; i++)
2847 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2850 /* Don't write out static consts, unless we still need them.
2852 We also keep static consts if not optimizing (for debugging),
2853 unless the user specified -fno-keep-static-consts.
2854 ??? They might be better written into the debug information.
2855 This is possible when using DWARF.
2857 A language processor that wants static constants to be always
2858 written out (even if it is not used) is responsible for
2859 calling rest_of_decl_compilation itself. E.g. the C front-end
2860 calls rest_of_decl_compilation from finish_decl.
2861 One motivation for this is that is conventional in some
2862 environments to write things like:
2863 static const char rcsid[] = "... version string ...";
2864 intending to force the string to be in the executable.
2866 A language processor that would prefer to have unneeded
2867 static constants "optimized away" would just defer writing
2868 them out until here. E.g. C++ does this, because static
2869 constants are often defined in header files.
2871 ??? A tempting alternative (for both C and C++) would be
2872 to force a constant to be written if and only if it is
2873 defined in a main file, as opposed to an include file. */
2875 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2876 && (! TREE_READONLY (decl)
2877 || TREE_PUBLIC (decl)
2878 || (!optimize && flag_keep_static_consts)
2879 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2882 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2885 if (TREE_CODE (decl) == FUNCTION_DECL
2886 && DECL_INITIAL (decl) != 0
2887 && DECL_SAVED_INSNS (decl) != 0
2888 && (flag_keep_inline_functions
2889 || TREE_PUBLIC (decl)
2890 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2893 temporary_allocation ();
2894 output_inline_function (decl);
2895 permanent_allocation (1);
2900 /* Now that all possible functions have been output, we can dump
2901 the exception table. */
2903 output_exception_table ();
2905 for (i = 0; i < len; i++)
2909 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2910 && ! TREE_ASM_WRITTEN (decl))
2911 /* Cancel the RTL for this decl so that, if debugging info
2912 output for global variables is still to come,
2913 this one will be omitted. */
2914 DECL_RTL (decl) = NULL;
2916 /* Warn about any function
2917 declared static but not defined.
2918 We don't warn about variables,
2919 because many programs have static variables
2920 that exist only to get some text into the object file. */
2921 if (TREE_CODE (decl) == FUNCTION_DECL
2923 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2924 && DECL_INITIAL (decl) == 0
2925 && DECL_EXTERNAL (decl)
2926 && ! DECL_ARTIFICIAL (decl)
2927 && ! TREE_PUBLIC (decl))
2929 pedwarn_with_decl (decl,
2930 "`%s' declared `static' but never defined");
2931 /* This symbol is effectively an "extern" declaration now. */
2932 TREE_PUBLIC (decl) = 1;
2933 assemble_external (decl);
2936 /* Warn about static fns or vars defined but not used,
2937 but not about inline functions or static consts
2938 since defining those in header files is normal practice. */
2940 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2941 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2942 && ! DECL_IN_SYSTEM_HEADER (decl)
2943 && ! DECL_EXTERNAL (decl)
2944 && ! TREE_PUBLIC (decl)
2945 && ! TREE_USED (decl)
2946 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2947 /* The TREE_USED bit for file-scope decls
2948 is kept in the identifier, to handle multiple
2949 external decls in different scopes. */
2950 && ! TREE_USED (DECL_NAME (decl)))
2951 warning_with_decl (decl, "`%s' defined but not used");
2953 #ifdef SDB_DEBUGGING_INFO
2954 /* The COFF linker can move initialized global vars to the end.
2955 And that can screw up the symbol ordering.
2956 By putting the symbols in that order to begin with,
2957 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2958 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2959 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2960 && ! DECL_EXTERNAL (decl)
2961 && DECL_RTL (decl) != 0)
2962 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2964 /* Output COFF information for non-global
2965 file-scope initialized variables. */
2966 if (write_symbols == SDB_DEBUG
2967 && TREE_CODE (decl) == VAR_DECL
2968 && DECL_INITIAL (decl)
2969 && ! DECL_EXTERNAL (decl)
2970 && DECL_RTL (decl) != 0
2971 && GET_CODE (DECL_RTL (decl)) == MEM)
2972 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2973 #endif /* SDB_DEBUGGING_INFO */
2974 #ifdef DWARF_DEBUGGING_INFO
2975 /* Output DWARF information for file-scope tentative data object
2976 declarations, file-scope (extern) function declarations (which
2977 had no corresponding body) and file-scope tagged type declarations
2978 and definitions which have not yet been forced out. */
2980 if (write_symbols == DWARF_DEBUG
2981 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2982 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2984 #ifdef DWARF2_DEBUGGING_INFO
2985 /* Output DWARF2 information for file-scope tentative data object
2986 declarations, file-scope (extern) function declarations (which
2987 had no corresponding body) and file-scope tagged type declarations
2988 and definitions which have not yet been forced out. */
2990 if (write_symbols == DWARF2_DEBUG
2991 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2992 TIMEVAR (symout_time, dwarf2out_decl (decl));
2997 /* Write out any pending weak symbol declarations. */
3001 /* Do dbx symbols */
3002 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3003 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3004 TIMEVAR (symout_time,
3006 dbxout_finish (asm_out_file, main_input_filename);
3010 #ifdef DWARF_DEBUGGING_INFO
3011 if (write_symbols == DWARF_DEBUG)
3012 TIMEVAR (symout_time,
3018 #ifdef DWARF2_UNWIND_INFO
3019 if (dwarf2out_do_frame ())
3020 dwarf2out_frame_finish ();
3023 #ifdef DWARF2_DEBUGGING_INFO
3024 if (write_symbols == DWARF2_DEBUG)
3025 TIMEVAR (symout_time,
3027 dwarf2out_finish ();
3031 /* Output some stuff at end of file if nec. */
3033 end_final (dump_base_name);
3035 if (branch_prob_dump)
3036 open_dump_file (".bp", NULL);
3038 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
3040 if (branch_prob_dump)
3041 close_dump_file (NULL, NULL_RTX);
3044 ASM_FILE_END (asm_out_file);
3047 /* Language-specific end of compilation actions. */
3051 /* Close the dump files. */
3053 if (flag_gen_aux_info)
3055 fclose (aux_info_file);
3057 unlink (aux_info_file_name);
3062 open_dump_file (".combine", NULL);
3063 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
3064 close_dump_file (NULL, NULL_RTX);
3067 /* Close non-debugging input and output files. Take special care to note
3068 whether fclose returns an error, since the pages might still be on the
3069 buffer chain while the file is open. */
3073 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
3074 fatal_io_error (asm_file_name);
3076 /* Print the times. */
3080 fprintf (stderr,"\n");
3081 print_time ("parse", parse_time);
3083 print_time ("integration", integration_time);
3084 print_time ("jump", jump_time);
3085 print_time ("cse", cse_time);
3086 print_time ("gcse", gcse_time);
3087 print_time ("loop", loop_time);
3088 print_time ("cse2", cse2_time);
3089 print_time ("branch-prob", branch_prob_time);
3090 print_time ("flow", flow_time);
3091 print_time ("combine", combine_time);
3092 print_time ("regmove", regmove_time);
3093 print_time ("sched", sched_time);
3094 print_time ("local-alloc", local_alloc_time);
3095 print_time ("global-alloc", global_alloc_time);
3096 print_time ("sched2", sched2_time);
3098 print_time ("dbranch", dbr_sched_time);
3100 print_time ("shorten-branch", shorten_branch_time);
3101 print_time ("stack-reg", stack_reg_time);
3102 print_time ("final", final_time);
3103 print_time ("varconst", varconst_time);
3104 print_time ("symout", symout_time);
3105 print_time ("dump", dump_time);
3109 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3110 and TYPE_DECL nodes.
3112 This does nothing for local (non-static) variables.
3113 Otherwise, it sets up the RTL and outputs any assembler code
3114 (label definition, storage allocation and initialization).
3116 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3117 the assembler symbol name to be used. TOP_LEVEL is nonzero
3118 if this declaration is not within a function. */
3121 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
3127 /* Declarations of variables, and of functions defined elsewhere. */
3129 /* The most obvious approach, to put an #ifndef around where
3130 this macro is used, doesn't work since it's inside a macro call. */
3131 #ifndef ASM_FINISH_DECLARE_OBJECT
3132 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3135 /* Forward declarations for nested functions are not "external",
3136 but we need to treat them as if they were. */
3137 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
3138 || TREE_CODE (decl) == FUNCTION_DECL)
3139 TIMEVAR (varconst_time,
3141 make_decl_rtl (decl, asmspec, top_level);
3142 /* Initialized extern variable exists to be replaced
3143 with its value, or represents something that will be
3144 output in another file. */
3145 if (! (TREE_CODE (decl) == VAR_DECL
3146 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
3147 && DECL_INITIAL (decl) != 0
3148 && DECL_INITIAL (decl) != error_mark_node))
3149 /* Don't output anything
3150 when a tentative file-scope definition is seen.
3151 But at end of compilation, do output code for them. */
3152 if (! (! at_end && top_level
3153 && (DECL_INITIAL (decl) == 0
3154 || DECL_INITIAL (decl) == error_mark_node)))
3155 assemble_variable (decl, top_level, at_end, 0);
3156 if (decl == last_assemble_variable_decl)
3158 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
3162 else if (DECL_REGISTER (decl) && asmspec != 0)
3164 if (decode_reg_name (asmspec) >= 0)
3166 DECL_RTL (decl) = 0;
3167 make_decl_rtl (decl, asmspec, top_level);
3170 error ("invalid register name `%s' for register variable", asmspec);
3172 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3173 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3174 && TREE_CODE (decl) == TYPE_DECL)
3175 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
3177 #ifdef SDB_DEBUGGING_INFO
3178 else if (write_symbols == SDB_DEBUG && top_level
3179 && TREE_CODE (decl) == TYPE_DECL)
3180 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
3184 /* Called after finishing a record, union or enumeral type. */
3187 rest_of_type_compilation (type, toplev)
3188 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3192 tree type ATTRIBUTE_UNUSED;
3193 int toplev ATTRIBUTE_UNUSED;
3196 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3197 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3198 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3200 #ifdef SDB_DEBUGGING_INFO
3201 if (write_symbols == SDB_DEBUG)
3202 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3206 /* This is called from finish_function (within yyparse)
3207 after each top-level definition is parsed.
3208 It is supposed to compile that function or variable
3209 and output the assembler code for it.
3210 After we return, the tree storage is freed. */
3213 rest_of_compilation (decl)
3217 int start_time = get_run_time ();
3219 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3220 to be restored after we finish compiling the function
3221 (for use when compiling inline calls to this function). */
3222 tree saved_block_tree = 0;
3223 /* Likewise, for DECL_ARGUMENTS. */
3224 tree saved_arguments = 0;
3227 /* If we are reconsidering an inline function
3228 at the end of compilation, skip the stuff for making it inline. */
3230 if (DECL_SAVED_INSNS (decl) == 0)
3235 /* If requested, consider whether to make this function inline. */
3236 if (DECL_INLINE (decl) || flag_inline_functions)
3237 TIMEVAR (integration_time,
3239 lose = function_cannot_inline_p (decl);
3240 if (lose || ! optimize)
3242 if (warn_inline && DECL_INLINE (decl))
3243 warning_with_decl (decl, lose);
3244 DECL_ABSTRACT_ORIGIN (decl) = 0;
3245 /* Don't really compile an extern inline function.
3246 If we can't make it inline, pretend
3247 it was only declared. */
3248 if (DECL_EXTERNAL (decl))
3250 DECL_INITIAL (decl) = 0;
3251 goto exit_rest_of_compilation;
3255 /* ??? Note that this has the effect of making it look
3256 like "inline" was specified for a function if we choose
3257 to inline it. This isn't quite right, but it's
3258 probably not worth the trouble to fix. */
3259 inlinable = DECL_INLINE (decl) = 1;
3262 insns = get_insns ();
3264 /* Dump the rtl code if we are dumping rtl. */
3268 open_dump_file (".rtl", decl_printable_name (decl, 2));
3270 if (DECL_SAVED_INSNS (decl))
3271 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3273 close_dump_file (print_rtl, insns);
3276 /* If we can, defer compiling inlines until EOF.
3277 save_for_inline_copying can be extremely expensive. */
3278 if (inlinable && ! decl_function_context (decl))
3279 DECL_DEFER_OUTPUT (decl) = 1;
3281 /* If function is inline, and we don't yet know whether to
3282 compile it by itself, defer decision till end of compilation.
3283 finish_compilation will call rest_of_compilation again
3284 for those functions that need to be output. Also defer those
3285 functions that we are supposed to defer. We cannot defer
3286 functions containing nested functions since the nested function
3287 data is in our non-saved obstack. We cannot defer nested
3288 functions for the same reason. */
3290 /* If this is a nested inline, remove ADDRESSOF now so we can
3291 finish compiling ourselves. Otherwise, wait until EOF.
3292 We have to do this because the purge_addressof transformation
3293 changes the DECL_RTL for many variables, which confuses integrate. */
3296 if (decl_function_context (decl))
3297 purge_addressof (insns);
3299 DECL_DEFER_OUTPUT (decl) = 1;
3302 if (! current_function_contains_functions
3303 && (DECL_DEFER_OUTPUT (decl)
3304 || (DECL_INLINE (decl)
3305 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3306 && ! flag_keep_inline_functions)
3307 || DECL_EXTERNAL (decl)))))
3309 DECL_DEFER_OUTPUT (decl) = 1;
3311 /* If -Wreturn-type, we have to do a bit of compilation.
3312 However, if we just fall through we will call
3313 save_for_inline_copying() which results in excessive
3314 memory use. Instead, we just want to call
3315 jump_optimize() to figure out whether or not we can fall
3316 off the end of the function; we do the minimum amount of
3317 work necessary to make that safe. And, we set optimize
3318 to zero to keep jump_optimize from working too hard. */
3319 if (warn_return_type)
3321 int saved_optimize = optimize;
3323 find_exception_handler_labels ();
3324 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3325 !JUMP_AFTER_REGSCAN);
3326 optimize = saved_optimize;
3329 #ifdef DWARF_DEBUGGING_INFO
3330 /* Generate the DWARF info for the "abstract" instance
3331 of a function which we may later generate inlined and/or
3332 out-of-line instances of. */
3333 if (write_symbols == DWARF_DEBUG)
3335 set_decl_abstract_flags (decl, 1);
3336 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3337 set_decl_abstract_flags (decl, 0);
3340 #ifdef DWARF2_DEBUGGING_INFO
3341 /* Generate the DWARF2 info for the "abstract" instance
3342 of a function which we may later generate inlined and/or
3343 out-of-line instances of. */
3344 if (write_symbols == DWARF2_DEBUG)
3346 set_decl_abstract_flags (decl, 1);
3347 TIMEVAR (symout_time, dwarf2out_decl (decl));
3348 set_decl_abstract_flags (decl, 0);
3351 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3352 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3353 goto exit_rest_of_compilation;
3356 /* If we have to compile the function now, save its rtl and subdecls
3357 so that its compilation will not affect what others get. */
3358 if (inlinable || DECL_DEFER_OUTPUT (decl))
3360 #ifdef DWARF_DEBUGGING_INFO
3361 /* Generate the DWARF info for the "abstract" instance of
3362 a function which we will generate an out-of-line instance
3363 of almost immediately (and which we may also later generate
3364 various inlined instances of). */
3365 if (write_symbols == DWARF_DEBUG)
3367 set_decl_abstract_flags (decl, 1);
3368 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3369 set_decl_abstract_flags (decl, 0);
3372 #ifdef DWARF2_DEBUGGING_INFO
3373 /* Generate the DWARF2 info for the "abstract" instance of
3374 a function which we will generate an out-of-line instance
3375 of almost immediately (and which we may also later generate
3376 various inlined instances of). */
3377 if (write_symbols == DWARF2_DEBUG)
3379 set_decl_abstract_flags (decl, 1);
3380 TIMEVAR (symout_time, dwarf2out_decl (decl));
3381 set_decl_abstract_flags (decl, 0);
3384 saved_block_tree = DECL_INITIAL (decl);
3385 saved_arguments = DECL_ARGUMENTS (decl);
3386 TIMEVAR (integration_time, save_for_inline_copying (decl));
3387 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3390 /* If specified extern inline but we aren't inlining it, we are
3391 done. This goes for anything that gets here with DECL_EXTERNAL
3392 set, not just things with DECL_INLINE. */
3393 if (DECL_EXTERNAL (decl))
3394 goto exit_rest_of_compilation;
3397 if (! DECL_DEFER_OUTPUT (decl))
3398 TREE_ASM_WRITTEN (decl) = 1;
3400 /* Now that integrate will no longer see our rtl, we need not distinguish
3401 between the return value of this function and the return value of called
3403 rtx_equal_function_value_matters = 0;
3405 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3406 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3408 goto exit_rest_of_compilation;
3411 /* Emit code to get eh context, if needed. */
3415 /* If we are doing position-independent code generation, now
3416 is the time to output special prologues and epilogues.
3417 We do not want to do this earlier, because it just clutters
3418 up inline functions with meaningless insns. */
3423 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3424 Note that that may have been done above, in save_for_inline_copying.
3425 The call to resume_temporary_allocation near the end of this function
3426 goes back to the usual state of affairs. This must be done after
3427 we've built up any unwinders for exception handling, and done
3428 the FINALIZE_PIC work, if necessary. */
3430 rtl_in_current_obstack ();
3432 insns = get_insns ();
3434 /* Copy any shared structure that should not be shared. */
3436 unshare_all_rtl (insns);
3438 #ifdef SETJMP_VIA_SAVE_AREA
3439 /* This must be performed before virutal register instantiation. */
3440 if (current_function_calls_alloca)
3441 optimize_save_area_alloca (insns);
3444 /* Instantiate all virtual registers. */
3446 instantiate_virtual_regs (current_function_decl, get_insns ());
3448 /* See if we have allocated stack slots that are not directly addressable.
3449 If so, scan all the insns and create explicit address computation
3450 for all references to such slots. */
3451 /* fixup_stack_slots (); */
3453 /* Find all the EH handlers. */
3454 find_exception_handler_labels ();
3456 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3457 are initialized and to compute whether control can drop off the end
3459 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3460 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3461 JUMP_AFTER_REGSCAN));
3463 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3464 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3465 goto exit_rest_of_compilation;
3467 /* Dump rtl code after jump, if we are doing that. */
3470 dump_rtl (".jump", decl, print_rtl, insns);
3472 /* Perform common subexpression elimination.
3473 Nonzero value from `cse_main' means that jumps were simplified
3474 and some code may now be unreachable, so do
3475 jump optimization again. */
3480 open_dump_file (".cse", decl_printable_name (decl, 2));
3482 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3484 if (flag_thread_jumps)
3485 /* Hacks by tiemann & kenner. */
3486 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3488 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3490 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3492 if (tem || optimize > 1)
3493 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3495 !JUMP_AFTER_REGSCAN));
3497 /* Dump rtl code after cse, if we are doing that. */
3500 close_dump_file (print_rtl, insns);
3503 purge_addressof (insns);
3504 reg_scan (insns, max_reg_num (), 1);
3507 dump_rtl (".addressof", decl, print_rtl, insns);
3509 /* Perform global cse. */
3511 if (optimize > 0 && flag_gcse)
3514 open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl)));
3516 TIMEVAR (gcse_time, gcse_main (insns, rtl_dump_file));
3519 close_dump_file (print_rtl, insns);
3521 /* Move constant computations out of loops. */
3526 open_dump_file (".loop", decl_printable_name (decl, 2));
3531 if (flag_rerun_loop_opt)
3533 /* We only want to perform unrolling once. */
3535 loop_optimize (insns, rtl_dump_file, 0, 0);
3538 /* The first call to loop_optimize makes some instructions
3539 trivially dead. We delete those instructions now in the
3540 hope that doing so will make the heuristics in loop work
3541 better and possibly speed up compilation. */
3542 delete_trivially_dead_insns (insns, max_reg_num ());
3544 /* The regscan pass is currently necessary as the alias
3545 analysis code depends on this information. */
3546 reg_scan (insns, max_reg_num (), 1);
3548 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
3551 /* Dump rtl code after loop opt, if we are doing that. */
3554 close_dump_file (print_rtl, insns);
3560 open_dump_file (".cse2", decl_printable_name (decl, 2));
3562 if (flag_rerun_cse_after_loop)
3564 /* Running another jump optimization pass before the second
3565 cse pass sometimes simplifies the RTL enough to allow
3566 the second CSE pass to do a better job. Jump_optimize can change
3567 max_reg_num so we must rerun reg_scan afterwards.
3568 ??? Rework to not call reg_scan so often. */
3569 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3570 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3572 JUMP_AFTER_REGSCAN));
3574 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3575 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3578 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3580 !JUMP_AFTER_REGSCAN));
3583 if (flag_thread_jumps)
3585 /* This pass of jump threading straightens out code
3586 that was kinked by loop optimization. */
3587 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3588 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3591 /* Dump rtl code after cse, if we are doing that. */
3594 close_dump_file (print_rtl, insns);
3597 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3599 if (branch_prob_dump)
3600 open_dump_file (".bp", decl_printable_name (decl, 2));
3605 branch_prob (insns, rtl_dump_file);
3608 if (branch_prob_dump)
3609 close_dump_file (print_rtl, insns);
3612 /* We are no longer anticipating cse in this function, at least. */
3614 cse_not_expected = 1;
3616 /* Now we choose between stupid (pcc-like) register allocation
3617 (if we got the -noreg switch and not -opt)
3618 and smart register allocation. */
3620 if (optimize > 0) /* Stupid allocation probably won't work */
3621 obey_regdecls = 0; /* if optimizations being done. */
3625 /* Print function header into flow dump now
3626 because doing the flow analysis makes some of the dump. */
3629 open_dump_file (".flow", decl_printable_name (decl, 2));
3635 regclass (insns, max_reg_num ());
3636 stupid_life_analysis (insns, max_reg_num (),
3642 /* Do control and data flow analysis,
3643 and write some of the results to dump file. */
3648 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
3649 life_analysis (insns, max_reg_num (), rtl_dump_file);
3652 if (warn_uninitialized)
3654 uninitialized_vars_warning (DECL_INITIAL (decl));
3655 setjmp_args_warning ();
3659 /* Dump rtl after flow analysis. */
3662 close_dump_file (print_rtl_with_bb, insns);
3664 /* If -opt, try combining insns through substitution. */
3668 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3670 /* Dump rtl code after insn combination. */
3673 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
3676 /* Register allocation pre-pass, to reduce number of moves
3677 necessary for two-address machines. */
3678 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3681 open_dump_file (".regmove", decl_printable_name (decl, 2));
3683 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
3687 close_dump_file (print_rtl_with_bb, insns);
3690 /* Print function header into sched dump now
3691 because doing the sched analysis makes some of the dump. */
3693 if (optimize > 0 && flag_schedule_insns)
3696 open_dump_file (".sched", decl_printable_name (decl, 2));
3698 /* Do control and data sched analysis,
3699 and write some of the results to dump file. */
3701 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
3703 /* Dump rtl after instruction scheduling. */
3706 close_dump_file (print_rtl_with_bb, insns);
3709 /* Unless we did stupid register allocation,
3710 allocate pseudo-regs that are used only within 1 basic block. */
3713 TIMEVAR (local_alloc_time,
3715 recompute_reg_usage (insns);
3716 regclass (insns, max_reg_num ());
3720 /* Dump rtl code after allocating regs within basic blocks. */
3724 open_dump_file (".lreg", decl_printable_name (decl, 2));
3726 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
3727 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
3729 close_dump_file (print_rtl_with_bb, insns);
3732 if (global_reg_dump)
3733 open_dump_file (".greg", decl_printable_name (decl, 2));
3735 /* Save the last label number used so far, so reorg can tell
3736 when it's safe to kill spill regs. */
3737 max_label_num_after_reload = max_label_num ();
3739 /* Unless we did stupid register allocation,
3740 allocate remaining pseudo-regs, then do the reload pass
3741 fixing up any insns that are invalid. */
3743 TIMEVAR (global_alloc_time,
3746 failure = global_alloc (rtl_dump_file);
3748 failure = reload (insns, 0, rtl_dump_file);
3753 goto exit_rest_of_compilation;
3755 reload_completed = 1;
3757 /* Do a very simple CSE pass over just the hard registers. */
3759 reload_cse_regs (insns);
3761 /* On some machines, the prologue and epilogue code, or parts thereof,
3762 can be represented as RTL. Doing so lets us schedule insns between
3763 it and the rest of the code and also allows delayed branch
3764 scheduling to operate in the epilogue. */
3766 thread_prologue_and_epilogue_insns (insns);
3768 if (global_reg_dump)
3770 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
3771 close_dump_file (print_rtl_with_bb, insns);
3773 if (optimize > 0 && flag_schedule_insns_after_reload)
3776 open_dump_file (".sched2", decl_printable_name (decl, 2));
3778 /* Do control and data sched analysis again,
3779 and write some more of the results to dump file. */
3781 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
3783 /* Dump rtl after post-reorder instruction scheduling. */
3786 close_dump_file (print_rtl_with_bb, insns);
3789 #ifdef LEAF_REGISTERS
3791 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3795 /* One more attempt to remove jumps to .+1
3796 left by dead-store-elimination.
3797 Also do cross-jumping this time
3798 and delete no-op move insns. */
3802 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
3804 !JUMP_AFTER_REGSCAN));
3806 /* Dump rtl code after jump, if we are doing that. */
3809 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
3812 /* If a machine dependent reorganization is needed, call it. */
3813 #ifdef MACHINE_DEPENDENT_REORG
3814 MACHINE_DEPENDENT_REORG (insns);
3816 if (mach_dep_reorg_dump)
3817 dump_rtl (".mach", decl, print_rtl_with_bb, insns);
3820 /* If a scheduling pass for delayed branches is to be done,
3821 call the scheduling code. */
3824 if (optimize > 0 && flag_delayed_branch)
3826 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
3829 dump_rtl (".dbr", decl, print_rtl_with_bb, insns);
3833 /* Shorten branches. */
3834 TIMEVAR (shorten_branch_time,
3836 shorten_branches (get_insns ());
3841 open_dump_file (".stack", decl_printable_name (decl, 2));
3843 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
3846 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
3849 /* Now turn the rtl into assembler code. */
3851 TIMEVAR (final_time,
3856 /* Get the function's name, as described by its RTL.
3857 This may be different from the DECL_NAME name used
3858 in the source file. */
3860 x = DECL_RTL (decl);
3861 if (GET_CODE (x) != MEM)
3864 if (GET_CODE (x) != SYMBOL_REF)
3866 fnname = XSTR (x, 0);
3868 assemble_start_function (decl, fnname);
3869 final_start_function (insns, asm_out_file, optimize);
3870 final (insns, asm_out_file, optimize, 0);
3871 final_end_function (insns, asm_out_file, optimize);
3872 assemble_end_function (decl, fnname);
3874 fflush (asm_out_file);
3876 /* Release all memory held by regsets now */
3877 regset_release_memory ();
3880 /* Write DBX symbols if requested */
3882 /* Note that for those inline functions where we don't initially
3883 know for certain that we will be generating an out-of-line copy,
3884 the first invocation of this routine (rest_of_compilation) will
3885 skip over this code by doing a `goto exit_rest_of_compilation;'.
3886 Later on, finish_compilation will call rest_of_compilation again
3887 for those inline functions that need to have out-of-line copies
3888 generated. During that call, we *will* be routed past here. */
3890 #ifdef DBX_DEBUGGING_INFO
3891 if (write_symbols == DBX_DEBUG)
3892 TIMEVAR (symout_time, dbxout_function (decl));
3895 #ifdef DWARF_DEBUGGING_INFO
3896 if (write_symbols == DWARF_DEBUG)
3897 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3900 #ifdef DWARF2_DEBUGGING_INFO
3901 if (write_symbols == DWARF2_DEBUG)
3902 TIMEVAR (symout_time, dwarf2out_decl (decl));
3905 exit_rest_of_compilation:
3907 /* In case the function was not output,
3908 don't leave any temporary anonymous types
3909 queued up for sdb output. */
3910 #ifdef SDB_DEBUGGING_INFO
3911 if (write_symbols == SDB_DEBUG)
3912 sdbout_types (NULL_TREE);
3915 /* Put back the tree of subblocks and list of arguments
3916 from before we copied them.
3917 Code generation and the output of debugging info may have modified
3918 the copy, but the original is unchanged. */
3920 if (saved_block_tree != 0)
3922 DECL_INITIAL (decl) = saved_block_tree;
3923 DECL_ARGUMENTS (decl) = saved_arguments;
3924 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3927 reload_completed = 0;
3929 TIMEVAR (final_time,
3931 /* Clear out the insn_length contents now that they are no
3933 init_insn_lengths ();
3935 /* Clear out the real_constant_chain before some of the rtx's
3936 it runs through become garbage. */
3937 clear_const_double_mem ();
3939 /* Cancel the effect of rtl_in_current_obstack. */
3940 resume_temporary_allocation ();
3942 /* Show no temporary slots allocated. */
3946 /* Make sure volatile mem refs aren't considered valid operands for
3947 arithmetic insns. We must call this here if this is a nested inline
3948 function, since the above code leaves us in the init_recog state
3949 (from final.c), and the function context push/pop code does not
3950 save/restore volatile_ok.
3952 ??? Maybe it isn't necessary for expand_start_function to call this
3953 anymore if we do it here? */
3955 init_recog_no_volatile ();
3957 /* The parsing time is all the time spent in yyparse
3958 *except* what is spent in this function. */
3960 parse_time -= get_run_time () - start_time;
3971 printf ("Usage: %s input [switches]\n", progname);
3972 printf ("Switches:\n");
3974 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
3975 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
3976 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
3978 for (i = NUM_ELEM (f_options); i--;)
3980 char * description = f_options[i].description;
3982 if (description != NULL && * description != 0)
3983 printf (" -f%-21s %s\n",
3984 f_options[i].string, description);
3987 printf (" -O[number] Set optimisation level to [number]\n");
3988 printf (" -Os Optimise for space rather than speed\n");
3989 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
3990 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
3991 printf (" -w Suppress warnings\n");
3992 printf (" -W Enable extra warnings\n");
3994 for (i = NUM_ELEM (W_options); i--;)
3996 char * description = W_options[i].description;
3998 if (description != NULL && * description != 0)
3999 printf (" -W%-21s %s\n",
4000 W_options[i].string, description);
4003 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4004 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4005 printf (" -p Enable function profiling\n");
4006 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4007 printf (" -a Enable block profiling \n");
4009 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4010 printf (" -ax Enable jump profiling \n");
4012 printf (" -o <file> Place output into <file> \n");
4013 printf (" -G <number> Put global and static data smaller than <number>\n");
4014 printf (" bytes into a special section (on some targets)\n");
4016 for (i = NUM_ELEM (debug_args); i--;)
4018 if (debug_args[i].description != NULL)
4019 printf (" -%-22s %s\n", debug_args[i].arg, debug_args[i].description);
4022 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4023 printf (" -quiet Do not display functions compiled or elapsed time\n");
4024 printf (" -version Display the compiler's version\n");
4025 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4026 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4027 #if defined HAIFA || defined INSN_SCHEDULING
4028 printf (" -sched-verbose-<number> Set the verbosity level of the scheduler\n");
4030 printf (" --help Display this information\n");
4035 /* Display descriptions of language specific options.
4036 If there is no description, note that there is an undocumented option.
4037 If the description is empty, do not display anything. (This allows
4038 options to be deliberately undocumented, for whatever reason).
4039 If the option string is missing, then this is a marker, indicating
4040 that the description string is in fact the name of a language, whoes
4041 language specific options are to follow. */
4043 if (NUM_ELEM (documented_lang_options) > 1)
4045 printf ("\nLanguage specific options:\n");
4047 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
4049 char * description = documented_lang_options[i].description;
4050 char * option = documented_lang_options[i].option;
4052 if (description == NULL)
4054 else if (* description == 0)
4056 else if (option == NULL)
4060 ("\nThere are undocumented %s specific options as well.\n",
4064 printf ("\n Options for %s:\n", description);
4069 printf (" %-23.23s %s\n", option, description);
4074 printf ("\nThere are undocumented %s specific options as well.\n", lang);
4076 if (NUM_ELEM (target_switches) > 1
4077 #ifdef TARGET_OPTIONS
4078 || NUM_ELEM (target_options) > 1
4086 printf ("\nTarget specific options:\n");
4088 for (i = NUM_ELEM (target_switches); i--;)
4090 char * option = target_switches[i].name;
4091 char * description = target_switches[i].description;
4095 else if (description == NULL)
4097 else if (* description != 0)
4098 doc += printf (" %-23.23s %s\n", option, description);
4101 #ifdef TARGET_OPTIONS
4102 for (i = NUM_ELEM (target_options); i--;)
4104 char * option = target_options[i].prefix;
4105 char * description = target_options[i].description;
4109 else if (description == NULL)
4111 else if (* description != 0)
4112 doc += printf (" %-23.23s %s\n", option, description);
4118 printf ("\nThere are undocumented target specific options as well.\n");
4120 printf (" They exist, but they are not documented.\n");
4125 /* Compare the user specified 'option' with the language
4126 specific 'lang_option'. Return true if they match, or
4127 if 'option' is a viable prefix of 'lang_option'. */
4130 check_lang_option (option, lang_option)
4134 lang_independent_options * indep_options;
4138 /* Ignore NULL entries. */
4139 if (option == NULL || lang_option == NULL)
4142 len = strlen (lang_option);
4144 /* If they do not match to the first n characters then fail. */
4145 if (strncmp (option, lang_option, len) != 0)
4148 /* Do not accept a lang option, if it matches a normal -f or -W
4149 option. Chill defines a -fpack, but we want to support
4152 /* An exact match is OK */
4153 if (strlen (option) == len)
4156 /* If it is not an -f or -W option allow the match */
4157 if (option[0] != '-')
4162 case 'f': indep_options = f_options; break;
4163 case 'W': indep_options = W_options; break;
4167 /* The option is a -f or -W option.
4168 Skip past the prefix and search for the remainder in the
4169 appropriate table of options. */
4172 if (option[0] == 'n' && option[1] == 'o' && option[2] == '-')
4175 for (k = NUM_ELEM (indep_options); k--;)
4177 if (!strcmp (option, indep_options[k].string))
4179 /* The option matched a language independent option,
4180 do not allow the language specific match. */
4186 /* The option matches the start of the langauge specific option
4187 and it is not an exact match for a language independent option. */
4191 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4192 Exit code is 35 if can't open files, 34 if fatal error,
4193 33 if had nonfatal errors, else success. */
4202 int flag_print_mem = 0;
4203 int version_flag = 0;
4206 /* save in case md file wants to emit args as a comment. */
4210 p = argv[0] + strlen (argv[0]);
4211 while (p != argv[0] && p[-1] != '/'
4212 #ifdef DIR_SEPARATOR
4213 && p[-1] != DIR_SEPARATOR
4219 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
4220 /* Get rid of any avoidable limit on stack size. */
4224 /* Set the stack limit huge so that alloca does not fail. */
4225 getrlimit (RLIMIT_STACK, &rlim);
4226 rlim.rlim_cur = rlim.rlim_max;
4227 setrlimit (RLIMIT_STACK, &rlim);
4231 signal (SIGFPE, float_signal);
4234 signal (SIGPIPE, pipe_closed);
4237 decl_printable_name = decl_name;
4238 lang_expand_expr = (lang_expand_expr_t) do_abort;
4240 /* Initialize whether `char' is signed. */
4241 flag_signed_char = DEFAULT_SIGNED_CHAR;
4242 #ifdef DEFAULT_SHORT_ENUMS
4243 /* Initialize how much space enums occupy, by default. */
4244 flag_short_enums = DEFAULT_SHORT_ENUMS;
4247 /* Perform language-specific options intialization. */
4248 lang_init_options ();
4250 /* Scan to see what optimization level has been specified. That will
4251 determine the default value of many flags. */
4252 for (i = 1; i < argc; i++)
4254 if (!strcmp (argv[i], "-O"))
4258 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4260 /* Handle -Os, -O2, -O3, -O69, ... */
4261 char *p = &argv[i][2];
4264 if ((p[0] == 's') && (p[1] == 0))
4269 if (! (c >= '0' && c <= '9'))
4272 optimize = atoi (&argv[i][2]);
4277 /* Optimizing for size forces optimize to be no less than 2. */
4278 if (optimize_size && (optimize < 2))
4281 obey_regdecls = (optimize == 0);
4286 flag_thread_jumps = 1;
4288 flag_delayed_branch = 1;
4290 #ifdef CAN_DEBUG_WITHOUT_FP
4291 flag_omit_frame_pointer = 1;
4297 flag_cse_follow_jumps = 1;
4298 flag_cse_skip_blocks = 1;
4300 flag_expensive_optimizations = 1;
4301 flag_strength_reduce = 1;
4302 flag_rerun_cse_after_loop = 1;
4303 flag_rerun_loop_opt = 1;
4304 flag_caller_saves = 1;
4306 #ifdef INSN_SCHEDULING
4307 flag_schedule_insns = 1;
4308 flag_schedule_insns_after_reload = 1;
4311 flag_strict_aliasing = 1;
4316 flag_inline_functions = 1;
4319 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4322 set_target_switch ("");
4324 #ifdef OPTIMIZATION_OPTIONS
4325 /* Allow default optimizations to be specified on a per-machine basis. */
4326 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4329 /* Initialize register usage now so switches may override. */
4332 for (i = 1; i < argc; i++)
4336 /* If this is a language-specific option,
4337 decode it in a language-specific way. */
4338 for (j = NUM_ELEM (documented_lang_options); j--;)
4339 if (check_lang_option (argv[i], documented_lang_options[j].option))
4342 if (j != (size_t)-1)
4344 /* If the option is valid for *some* language,
4345 treat it as valid even if this language doesn't understand it. */
4346 int strings_processed = lang_decode_option (argc - i, argv + i);
4348 if (!strcmp (argv[i], "--help"))
4354 if (strings_processed != 0)
4355 i += strings_processed - 1;
4357 else if (argv[i][0] == '-' && argv[i][1] != 0)
4359 register char *str = argv[i] + 1;
4364 set_target_switch (&str[1]);
4365 else if (!strcmp (str, "dumpbase"))
4367 dump_base_name = argv[++i];
4369 else if (str[0] == 'd')
4371 register char *p = &str[1];
4376 branch_prob_dump = 1;
4382 global_reg_dump = 1;
4390 cse_dump = 1, cse2_dump = 1;
4397 #ifdef MACHINE_DEPENDENT_REORG
4398 mach_dep_reorg_dump = 1;
4405 branch_prob_dump = 1;
4422 global_reg_dump = 1;
4447 #ifdef MACHINE_DEPENDENT_REORG
4449 mach_dep_reorg_dump = 1;
4453 flag_print_asm_name = 1;
4477 rtl_dump_and_exit = 1;
4480 warning ("unrecognised gcc debugging option: %c", p[-1]);
4484 else if (str[0] == 'f')
4486 register char *p = &str[1];
4489 /* Some kind of -f option.
4490 P's value is the option sans `-f'.
4491 Search for it in the table of options. */
4494 !found && j < sizeof (f_options) / sizeof (f_options[0]);
4497 if (!strcmp (p, f_options[j].string))
4499 *f_options[j].variable = f_options[j].on_value;
4500 /* A goto here would be cleaner,
4501 but breaks the vax pcc. */
4504 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4505 && ! strcmp (p+3, f_options[j].string))
4507 *f_options[j].variable = ! f_options[j].on_value;
4515 #ifdef INSN_SCHEDULING
4516 else if (!strncmp (p, "sched-verbose-",14))
4517 fix_sched_param("verbose",&p[14]);
4520 else if (!strncmp (p, "fixed-", 6))
4521 fix_register (&p[6], 1, 1);
4522 else if (!strncmp (p, "call-used-", 10))
4523 fix_register (&p[10], 0, 1);
4524 else if (!strncmp (p, "call-saved-", 11))
4525 fix_register (&p[11], 0, 0);
4527 error ("Invalid option `%s'", argv[i]);
4529 else if (str[0] == 'O')
4531 register char *p = str+1;
4535 while (*p && *p >= '0' && *p <= '9')
4540 error ("Invalid option `%s'", argv[i]);
4542 else if (!strcmp (str, "pedantic"))
4544 else if (!strcmp (str, "pedantic-errors"))
4545 flag_pedantic_errors = pedantic = 1;
4546 else if (!strcmp (str, "quiet"))
4548 else if (!strcmp (str, "version"))
4550 else if (!strcmp (str, "w"))
4551 inhibit_warnings = 1;
4552 else if (!strcmp (str, "W"))
4555 /* We save the value of warn_uninitialized, since if they put
4556 -Wuninitialized on the command line, we need to generate a
4557 warning about not using it without also specifying -O. */
4558 if (warn_uninitialized != 1)
4559 warn_uninitialized = 2;
4561 else if (str[0] == 'W')
4563 register char *p = &str[1];
4566 /* Some kind of -W option.
4567 P's value is the option sans `-W'.
4568 Search for it in the table of options. */
4571 !found && j < sizeof (W_options) / sizeof (W_options[0]);
4574 if (!strcmp (p, W_options[j].string))
4576 *W_options[j].variable = W_options[j].on_value;
4577 /* A goto here would be cleaner,
4578 but breaks the vax pcc. */
4581 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4582 && ! strcmp (p+3, W_options[j].string))
4584 *W_options[j].variable = ! W_options[j].on_value;
4591 else if (!strncmp (p, "id-clash-", 9))
4597 if (*endp >= '0' && *endp <= '9')
4601 error ("Invalid option `%s'", argv[i]);
4606 id_clash_len = atoi (str + 10);
4609 else if (!strncmp (p, "larger-than-", 12))
4611 char *endp = p + 12;
4615 if (*endp >= '0' && *endp <= '9')
4619 error ("Invalid option `%s'", argv[i]);
4620 goto larger_than_lose;
4623 warn_larger_than = 1;
4624 larger_than_size = atoi (str + 13);
4628 error ("Invalid option `%s'", argv[i]);
4630 else if (!strcmp (str, "p"))
4634 else if (!strcmp (str, "a"))
4636 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4637 warning ("`-a' option (basic block profile) not supported");
4639 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4642 else if (!strcmp (str, "ax"))
4644 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4645 warning ("`-ax' option (jump profiling) not supported");
4647 profile_block_flag = (!profile_block_flag
4648 || profile_block_flag == 2) ? 2 : 3;
4651 else if (str[0] == 'g')
4655 /* A lot of code assumes write_symbols == NO_DEBUG if the
4656 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4657 of what debugging type has been selected). This records the
4658 selected type. It is an error to specify more than one
4660 static enum debug_info_type selected_debug_type = NO_DEBUG;
4661 /* Non-zero if debugging format has been explicitly set.
4662 -g and -ggdb don't explicitly set the debugging format so
4663 -gdwarf -g3 is equivalent to -gdwarf3. */
4664 static int type_explicitly_set_p = 0;
4665 /* Indexed by enum debug_info_type. */
4666 static char *debug_type_names[] =
4668 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4671 /* Look up STR in the table. */
4672 for (da = debug_args; da->arg; da++)
4674 if (! strncmp (str, da->arg, strlen (da->arg)))
4676 enum debug_info_type type = da->debug_type;
4679 p = str + strlen (da->arg);
4680 if (*p && (*p < '0' || *p > '9'))
4684 while (*q && (*q >= '0' && *q <= '9'))
4689 if (len > 1 && !strncmp (str, "gdwarf", len))
4691 error ("use -gdwarf -g%d for DWARF v1, level %d",
4694 error ("use -gdwarf-2 for DWARF v2");
4698 level = 2; /* default debugging info level */
4699 if (*q || level > 3)
4701 warning ("invalid debug level specification in option: `-%s'",
4703 /* ??? This error message is incorrect in the case of
4705 warning ("no debugging information will be generated");
4709 if (type == NO_DEBUG)
4711 type = PREFERRED_DEBUGGING_TYPE;
4712 if (len > 1 && strncmp (str, "ggdb", len) == 0)
4714 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4715 type = DWARF2_DEBUG;
4717 #ifdef DBX_DEBUGGING_INFO
4724 if (type == NO_DEBUG)
4725 warning ("`-%s' not supported by this configuration of GCC",
4728 /* Does it conflict with an already selected type? */
4729 if (type_explicitly_set_p
4730 /* -g/-ggdb don't conflict with anything */
4731 && da->debug_type != NO_DEBUG
4732 && type != selected_debug_type)
4733 warning ("`-%s' ignored, conflicts with `-g%s'",
4734 str, debug_type_names[(int) selected_debug_type]);
4737 /* If the format has already been set, -g/-ggdb
4738 only change the debug level. */
4739 if (type_explicitly_set_p
4740 && da->debug_type == NO_DEBUG)
4741 ; /* don't change debugging type */
4744 selected_debug_type = type;
4745 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4747 write_symbols = (level == 0
4749 : selected_debug_type);
4750 use_gnu_debug_info_extensions = da->use_extensions_p;
4751 debug_info_level = (enum debug_info_level) level;
4757 warning ("`-%s' not supported by this configuration of GCC",
4760 else if (!strcmp (str, "o"))
4762 asm_file_name = argv[++i];
4764 else if (str[0] == 'G')
4766 g_switch_set = TRUE;
4767 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
4769 else if (!strncmp (str, "aux-info", 8))
4771 flag_gen_aux_info = 1;
4772 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
4774 else if (!strcmp (str, "-help"))
4780 error ("Invalid option `%s'", argv[i]);
4782 else if (argv[i][0] == '+')
4783 error ("Invalid option `%s'", argv[i]);
4788 /* Checker uses the frame pointer. */
4789 if (flag_check_memory_usage)
4790 flag_omit_frame_pointer = 0;
4794 /* Inlining does not work if not optimizing,
4795 so force it not to be done. */
4799 /* The c_decode_option and lang_decode_option functions set
4800 this to `2' if -Wall is used, so we can avoid giving out
4801 lots of errors for people who don't realize what -Wall does. */
4802 if (warn_uninitialized == 1)
4803 warning ("-Wuninitialized is not supported without -O");
4806 #ifdef OVERRIDE_OPTIONS
4807 /* Some machines may reject certain combinations of options. */
4811 if (exceptions_via_longjmp == 2)
4813 #ifdef DWARF2_UNWIND_INFO
4814 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4816 exceptions_via_longjmp = 1;
4820 if (profile_block_flag == 3)
4822 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4823 profile_block_flag = 2;
4826 /* Unrolling all loops implies that standard loop unrolling must also
4828 if (flag_unroll_all_loops)
4829 flag_unroll_loops = 1;
4830 /* Loop unrolling requires that strength_reduction be on also. Silently
4831 turn on strength reduction here if it isn't already on. Also, the loop
4832 unrolling code assumes that cse will be run after loop, so that must
4833 be turned on also. */
4834 if (flag_unroll_loops)
4836 flag_strength_reduce = 1;
4837 flag_rerun_cse_after_loop = 1;
4840 /* Warn about options that are not supported on this machine. */
4841 #ifndef INSN_SCHEDULING
4842 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4843 warning ("instruction scheduling not supported on this target machine");
4846 if (flag_delayed_branch)
4847 warning ("this target machine does not have delayed branches");
4850 /* If we are in verbose mode, write out the version and maybe all the
4851 option flags in use. */
4854 print_version (stderr, "");
4856 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4859 compile_file (filename);
4861 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4864 char *lim = (char *) sbrk (0);
4866 fprintf (stderr, "Data size %ld.\n", (long)(lim - (char *) &environ));
4871 system ("ps -l 1>&2");
4874 #endif /* not USG */
4877 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4880 exit (FATAL_EXIT_CODE);
4882 exit (FATAL_EXIT_CODE);
4883 exit (SUCCESS_EXIT_CODE);
4887 /* Decode -m switches. */
4888 /* Decode the switch -mNAME. */
4891 set_target_switch (name)
4897 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4898 if (!strcmp (target_switches[j].name, name))
4900 if (target_switches[j].value < 0)
4901 target_flags &= ~-target_switches[j].value;
4903 target_flags |= target_switches[j].value;
4907 #ifdef TARGET_OPTIONS
4909 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4911 int len = strlen (target_options[j].prefix);
4912 if (!strncmp (target_options[j].prefix, name, len))
4914 *target_options[j].variable = name + len;
4921 error ("Invalid option `%s'", name);
4924 /* Print version information to FILE.
4925 Each line begins with INDENT (for the case where FILE is the
4926 assembler output file). */
4929 print_version (file, indent)
4933 fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4934 language_string, version_string);
4935 fprintf (file, " (%s)", TARGET_NAME);
4938 #define __VERSION__ "[unknown]"
4940 fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4942 fprintf (file, " compiled by CC.\n");
4946 /* Print an option value and return the adjusted position in the line.
4947 ??? We don't handle error returns from fprintf (disk full); presumably
4948 other code will catch a disk full though. */
4951 print_single_switch (file, pos, max, indent, sep, term, type, name)
4954 char *indent, *sep, *term, *type, *name;
4956 /* The ultrix fprintf returns 0 on success, so compute the result we want
4957 here since we need it for the following test. */
4958 int len = strlen (sep) + strlen (type) + strlen (name);
4963 fprintf (file, "%s", term);
4968 fprintf (file, "%s", indent);
4969 pos = strlen (indent);
4971 fprintf (file, "%s%s%s", sep, type, name);
4976 /* Print active target switches to FILE.
4977 POS is the current cursor position and MAX is the size of a "line".
4978 Each line begins with INDENT and ends with TERM.
4979 Each switch is separated from the next by SEP. */
4982 print_switch_values (file, pos, max, indent, sep, term)
4985 char *indent, *sep, *term;
4990 /* Print the options as passed. */
4992 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4993 "options passed: ", "");
4995 for (p = &save_argv[1]; *p != NULL; p++)
4999 if (strcmp (*p, "-o") == 0)
5005 if (strcmp (*p, "-quiet") == 0)
5007 if (strcmp (*p, "-version") == 0)
5012 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5015 fprintf (file, "%s", term);
5017 /* Print the -f and -m options that have been enabled.
5018 We don't handle language specific options but printing argv
5021 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5022 "options enabled: ", "");
5024 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
5025 if (*f_options[j].variable == f_options[j].on_value)
5026 pos = print_single_switch (file, pos, max, indent, sep, term,
5027 "-f", f_options[j].string);
5029 /* Print target specific options. */
5031 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5032 if (target_switches[j].name[0] != '\0'
5033 && target_switches[j].value > 0
5034 && ((target_switches[j].value & target_flags)
5035 == target_switches[j].value))
5037 pos = print_single_switch (file, pos, max, indent, sep, term,
5038 "-m", target_switches[j].name);
5041 #ifdef TARGET_OPTIONS
5042 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5043 if (*target_options[j].variable != NULL)
5046 sprintf (prefix, "-m%s", target_options[j].prefix);
5047 pos = print_single_switch (file, pos, max, indent, sep, term,
5048 prefix, *target_options[j].variable);
5052 fprintf (file, "%s", term);
5055 /* Record the beginning of a new source file, named FILENAME. */
5058 debug_start_source_file (filename)
5059 register char *filename;
5061 #ifdef DBX_DEBUGGING_INFO
5062 if (write_symbols == DBX_DEBUG)
5063 dbxout_start_new_source_file (filename);
5065 #ifdef DWARF_DEBUGGING_INFO
5066 if (debug_info_level == DINFO_LEVEL_VERBOSE
5067 && write_symbols == DWARF_DEBUG)
5068 dwarfout_start_new_source_file (filename);
5069 #endif /* DWARF_DEBUGGING_INFO */
5070 #ifdef DWARF2_DEBUGGING_INFO
5071 if (debug_info_level == DINFO_LEVEL_VERBOSE
5072 && write_symbols == DWARF2_DEBUG)
5073 dwarf2out_start_source_file (filename);
5074 #endif /* DWARF2_DEBUGGING_INFO */
5075 #ifdef SDB_DEBUGGING_INFO
5076 if (write_symbols == SDB_DEBUG)
5077 sdbout_start_new_source_file (filename);
5081 /* Record the resumption of a source file. LINENO is the line number in
5082 the source file we are returning to. */
5085 debug_end_source_file (lineno)
5086 register unsigned lineno;
5088 #ifdef DBX_DEBUGGING_INFO
5089 if (write_symbols == DBX_DEBUG)
5090 dbxout_resume_previous_source_file ();
5092 #ifdef DWARF_DEBUGGING_INFO
5093 if (debug_info_level == DINFO_LEVEL_VERBOSE
5094 && write_symbols == DWARF_DEBUG)
5095 dwarfout_resume_previous_source_file (lineno);
5096 #endif /* DWARF_DEBUGGING_INFO */
5097 #ifdef DWARF2_DEBUGGING_INFO
5098 if (debug_info_level == DINFO_LEVEL_VERBOSE
5099 && write_symbols == DWARF2_DEBUG)
5100 dwarf2out_end_source_file ();
5101 #endif /* DWARF2_DEBUGGING_INFO */
5102 #ifdef SDB_DEBUGGING_INFO
5103 if (write_symbols == SDB_DEBUG)
5104 sdbout_resume_previous_source_file ();
5108 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5109 the tail part of the directive line, i.e. the part which is past the
5110 initial whitespace, #, whitespace, directive-name, whitespace part. */
5113 debug_define (lineno, buffer)
5114 register unsigned lineno;
5115 register char *buffer;
5117 #ifdef DWARF_DEBUGGING_INFO
5118 if (debug_info_level == DINFO_LEVEL_VERBOSE
5119 && write_symbols == DWARF_DEBUG)
5120 dwarfout_define (lineno, buffer);
5121 #endif /* DWARF_DEBUGGING_INFO */
5122 #ifdef DWARF2_DEBUGGING_INFO
5123 if (debug_info_level == DINFO_LEVEL_VERBOSE
5124 && write_symbols == DWARF2_DEBUG)
5125 dwarf2out_define (lineno, buffer);
5126 #endif /* DWARF2_DEBUGGING_INFO */
5129 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5130 the tail part of the directive line, i.e. the part which is past the
5131 initial whitespace, #, whitespace, directive-name, whitespace part. */
5134 debug_undef (lineno, buffer)
5135 register unsigned lineno;
5136 register char *buffer;
5138 #ifdef DWARF_DEBUGGING_INFO
5139 if (debug_info_level == DINFO_LEVEL_VERBOSE
5140 && write_symbols == DWARF_DEBUG)
5141 dwarfout_undef (lineno, buffer);
5142 #endif /* DWARF_DEBUGGING_INFO */
5143 #ifdef DWARF2_DEBUGGING_INFO
5144 if (debug_info_level == DINFO_LEVEL_VERBOSE
5145 && write_symbols == DWARF2_DEBUG)
5146 dwarf2out_undef (lineno, buffer);
5147 #endif /* DWARF2_DEBUGGING_INFO */