* flags.h (flag_renumber_insns): Declare.
[official-gcc.git] / gcc / toplev.c
blob5e7dbc0a272f33a938a04294a18085d86afd6030
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
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. */
26 #include "config.h"
27 #undef FLOAT /* This is for hpux. They should change hpux. */
28 #undef FFS /* Some systems define this in param.h. */
29 #include "system.h"
30 #include <signal.h>
31 #include <setjmp.h>
33 #ifdef HAVE_SYS_RESOURCE_H
34 # include <sys/resource.h>
35 #endif
37 #ifdef HAVE_SYS_TIMES_H
38 # include <sys/times.h>
39 #endif
41 #include "input.h"
42 #include "tree.h"
43 #include "rtl.h"
44 #include "tm_p.h"
45 #include "flags.h"
46 #include "insn-attr.h"
47 #include "insn-codes.h"
48 #include "insn-config.h"
49 #include "recog.h"
50 #include "defaults.h"
51 #include "output.h"
52 #include "except.h"
53 #include "function.h"
54 #include "toplev.h"
55 #include "expr.h"
56 #include "basic-block.h"
57 #include "intl.h"
58 #include "ggc.h"
59 #include "graph.h"
61 #ifdef DWARF_DEBUGGING_INFO
62 #include "dwarfout.h"
63 #endif
65 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
66 #include "dwarf2out.h"
67 #endif
69 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
70 #include "dbxout.h"
71 #endif
73 #ifdef SDB_DEBUGGING_INFO
74 #include "sdbout.h"
75 #endif
77 #ifdef XCOFF_DEBUGGING_INFO
78 #include "xcoffout.h"
79 #endif
81 #ifdef VMS
82 /* The extra parameters substantially improve the I/O performance. */
83 static FILE *
84 vms_fopen (fname, type)
85 char * fname;
86 char * type;
88 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
89 fixed arguments, which matches ANSI's specification but not VAXCRTL's
90 pre-ANSI implementation. This hack circumvents the mismatch problem. */
91 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
93 if (*type == 'w')
94 return (*vmslib_fopen) (fname, type, "mbc=32",
95 "deq=64", "fop=tef", "shr=nil");
96 else
97 return (*vmslib_fopen) (fname, type, "mbc=32");
99 #define fopen vms_fopen
100 #endif /* VMS */
102 #ifndef DEFAULT_GDB_EXTENSIONS
103 #define DEFAULT_GDB_EXTENSIONS 1
104 #endif
106 /* If more than one debugging type is supported, you must define
107 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
109 This is one long line cause VAXC can't handle a \-newline. */
110 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
111 #ifndef PREFERRED_DEBUGGING_TYPE
112 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
113 #endif /* no PREFERRED_DEBUGGING_TYPE */
114 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
115 so the following code needn't care. */
116 #ifdef DBX_DEBUGGING_INFO
117 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
118 #endif
119 #ifdef SDB_DEBUGGING_INFO
120 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
121 #endif
122 #ifdef DWARF_DEBUGGING_INFO
123 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
124 #endif
125 #ifdef DWARF2_DEBUGGING_INFO
126 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
127 #endif
128 #ifdef XCOFF_DEBUGGING_INFO
129 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
130 #endif
131 #endif /* More than one debugger format enabled. */
133 /* If still not defined, must have been because no debugging formats
134 are supported. */
135 #ifndef PREFERRED_DEBUGGING_TYPE
136 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
137 #endif
139 #ifndef DIR_SEPARATOR
140 #define DIR_SEPARATOR '/'
141 #endif
143 #if ! (defined (VMS) || defined (OS2))
144 extern char **environ;
145 #endif
146 extern char *version_string;
148 /* Carry information from ASM_DECLARE_OBJECT_NAME
149 to ASM_FINISH_DECLARE_OBJECT. */
151 extern int size_directive_output;
152 extern tree last_assemble_variable_decl;
154 static void notice PVPROTO((const char *s, ...)) ATTRIBUTE_PRINTF_1;
155 static void set_target_switch PROTO((const char *));
156 static const char *decl_name PROTO((tree, int));
157 static void vmessage PROTO((const char *, const char *, va_list));
158 static void v_message_with_file_and_line PROTO((const char *, int, int,
159 const char *, va_list));
160 static void v_message_with_decl PROTO((tree, int, const char *, va_list));
161 static void file_and_line_for_asm PROTO((rtx, char **, int *));
162 static void v_error_with_file_and_line PROTO((const char *, int,
163 const char *, va_list));
164 static void v_error_with_decl PROTO((tree, const char *, va_list));
165 static void v_error_for_asm PROTO((rtx, const char *, va_list));
166 static void verror PROTO((const char *, va_list));
167 static void vfatal PROTO((const char *, va_list)) ATTRIBUTE_NORETURN;
168 static void v_warning_with_file_and_line PROTO ((const char *, int,
169 const char *, va_list));
170 static void v_warning_with_decl PROTO((tree, const char *, va_list));
171 static void v_warning_for_asm PROTO((rtx, const char *, va_list));
172 static void vwarning PROTO((const char *, va_list));
173 static void vpedwarn PROTO((const char *, va_list));
174 static void v_pedwarn_with_decl PROTO((tree, const char *, va_list));
175 static void v_pedwarn_with_file_and_line PROTO((const char *, int,
176 const char *, va_list));
177 static void vsorry PROTO((const char *, va_list));
178 extern void set_fatal_function PROTO((void (*)(const char *, va_list)));
179 static void float_signal PROTO((int)) ATTRIBUTE_NORETURN;
180 static void pipe_closed PROTO((int)) ATTRIBUTE_NORETURN;
181 #ifdef ASM_IDENTIFY_LANGUAGE
182 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
183 static void output_lang_identify PROTO((FILE *)) ATTRIBUTE_UNUSED;
184 #endif
185 static void open_dump_file PROTO((const char *, const char *));
186 static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
187 static void dump_rtl PROTO((const char *, tree, void (*) (FILE *, rtx), rtx));
188 static void clean_dump_file PROTO((const char *));
189 static void compile_file PROTO((char *));
190 static void display_help PROTO ((void));
191 static void report_file_and_line PROTO ((const char *, int, int));
192 static void vnotice PROTO ((FILE *, const char *, va_list));
193 static void mark_file_stack PROTO ((void *));
195 static void decode_d_option PROTO ((const char *));
196 static int decode_f_option PROTO ((const char *));
197 static int decode_W_option PROTO ((const char *));
198 static int decode_g_option PROTO ((const char *));
199 static unsigned independent_decode_option PROTO ((int, char **, unsigned));
201 static void print_version PROTO((FILE *, const char *));
202 static int print_single_switch PROTO((FILE *, int, int, const char *,
203 const char *, const char *,
204 const char *, const char *));
205 static void print_switch_values PROTO((FILE *, int, int, const char *,
206 const char *, const char *));
208 /* Length of line when printing switch values. */
209 #define MAX_LINE 75
211 /* Name of program invoked, sans directories. */
213 const char *progname;
215 /* Copy of arguments to main. */
216 int save_argc;
217 char **save_argv;
219 /* Name of current original source file (what was input to cpp).
220 This comes from each #-command in the actual input. */
222 char *input_filename;
224 /* Name of top-level original source file (what was input to cpp).
225 This comes from the #-command at the beginning of the actual input.
226 If there isn't any there, then this is the cc1 input file name. */
228 char *main_input_filename;
230 /* Current line number in real source file. */
232 int lineno;
234 /* Nonzero if it is unsafe to create any new pseudo registers. */
235 int no_new_pseudos;
237 /* Stack of currently pending input files. */
239 struct file_stack *input_file_stack;
241 /* Incremented on each change to input_file_stack. */
242 int input_file_stack_tick;
244 /* Name to use as base of names for dump output files. */
246 const char *dump_base_name;
248 /* Bit flags that specify the machine subtype we are compiling for.
249 Bits are tested using macros TARGET_... defined in the tm.h file
250 and set by `-m...' switches. Must be defined in rtlanal.c. */
252 extern int target_flags;
254 /* Flags saying which kinds of debugging dump have been requested. */
256 int rtl_dump = 0;
257 int rtl_dump_and_exit = 0;
258 int jump_opt_dump = 0;
259 int addressof_dump = 0;
260 int cse_dump = 0;
261 int gcse_dump = 0;
262 int loop_dump = 0;
263 int cse2_dump = 0;
264 int branch_prob_dump = 0;
265 int flow_dump = 0;
266 int combine_dump = 0;
267 int regmove_dump = 0;
268 int sched_dump = 0;
269 int local_reg_dump = 0;
270 int global_reg_dump = 0;
271 int flow2_dump = 0;
272 int peephole2_dump = 0;
273 int sched2_dump = 0;
274 int jump2_opt_dump = 0;
275 #ifdef DELAY_SLOTS
276 int dbr_sched_dump = 0;
277 #endif
278 int flag_print_asm_name = 0;
279 #ifdef STACK_REGS
280 int stack_reg_dump = 0;
281 #endif
282 #ifdef MACHINE_DEPENDENT_REORG
283 int mach_dep_reorg_dump = 0;
284 #endif
285 static int flag_print_mem = 0;
286 static int version_flag = 0;
287 static char * filename = 0;
288 enum graph_dump_types graph_dump_format;
290 /* Name for output file of assembly code, specified with -o. */
292 char *asm_file_name;
294 /* Value of the -G xx switch, and whether it was passed or not. */
295 int g_switch_value;
296 int g_switch_set;
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. */
320 int optimize = 0;
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. */
331 int errorcount = 0;
332 int warningcount = 0;
333 int sorrycount = 0;
335 /* Pointer to function to compute the name to use to print a declaration.
336 DECL is the declaration in question.
337 VERBOSITY determines what information will be printed:
338 0: DECL_NAME, demangled as necessary.
339 1: and scope information.
340 2: and any other information that might be interesting, such as function
341 parameter types in C++. */
343 const char *(*decl_printable_name) PROTO ((tree, int));
345 /* Pointer to function to compute rtl for a language-specific tree code. */
347 typedef rtx (*lang_expand_expr_t)
348 PROTO ((union tree_node *, rtx, enum machine_mode,
349 enum expand_modifier modifier));
351 lang_expand_expr_t lang_expand_expr = 0;
353 tree (*lang_expand_constant) PROTO((tree)) = 0;
355 /* Pointer to function to finish handling an incomplete decl at the
356 end of compilation. */
358 void (*incomplete_decl_finalize_hook) PROTO((tree)) = 0;
360 /* Nonzero if generating code to do profiling. */
362 int profile_flag = 0;
364 /* Nonzero if generating code to do profiling on a line-by-line basis. */
366 int profile_block_flag;
368 /* Nonzero if generating code to profile program flow graph arcs. */
370 int profile_arc_flag = 0;
372 /* Nonzero if generating info for gcov to calculate line test coverage. */
374 int flag_test_coverage = 0;
376 /* Nonzero indicates that branch taken probabilities should be calculated. */
378 int flag_branch_probabilities = 0;
380 /* Nonzero for -pedantic switch: warn about anything
381 that standard spec forbids. */
383 int pedantic = 0;
385 /* Temporarily suppress certain warnings.
386 This is set while reading code from a system header file. */
388 int in_system_header = 0;
390 /* Nonzero means do stupid register allocation.
391 Currently, this is 1 if `optimize' is 0. */
393 int obey_regdecls = 0;
395 /* Don't print functions as they are compiled and don't print
396 times taken by the various passes. -quiet. */
398 int quiet_flag = 0;
400 /* -f flags. */
402 /* Nonzero means `char' should be signed. */
404 int flag_signed_char;
406 /* Nonzero means give an enum type only as many bytes as it needs. */
408 int flag_short_enums;
410 /* Nonzero for -fcaller-saves: allocate values in regs that need to
411 be saved across function calls, if that produces overall better code.
412 Optional now, so people can test it. */
414 #ifdef DEFAULT_CALLER_SAVES
415 int flag_caller_saves = 1;
416 #else
417 int flag_caller_saves = 0;
418 #endif
420 /* Nonzero if structures and unions should be returned in memory.
422 This should only be defined if compatibility with another compiler or
423 with an ABI is needed, because it results in slower code. */
425 #ifndef DEFAULT_PCC_STRUCT_RETURN
426 #define DEFAULT_PCC_STRUCT_RETURN 1
427 #endif
429 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
431 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
433 /* Nonzero for -fforce-mem: load memory value into a register
434 before arithmetic on it. This makes better cse but slower compilation. */
436 int flag_force_mem = 0;
438 /* Nonzero for -fforce-addr: load memory address into a register before
439 reference to memory. This makes better cse but slower compilation. */
441 int flag_force_addr = 0;
443 /* Nonzero for -fdefer-pop: don't pop args after each function call;
444 instead save them up to pop many calls' args with one insns. */
446 int flag_defer_pop = 0;
448 /* Nonzero for -ffloat-store: don't allocate floats and doubles
449 in extended-precision registers. */
451 int flag_float_store = 0;
453 /* Nonzero for -fcse-follow-jumps:
454 have cse follow jumps to do a more extensive job. */
456 int flag_cse_follow_jumps;
458 /* Nonzero for -fcse-skip-blocks:
459 have cse follow a branch around a block. */
460 int flag_cse_skip_blocks;
462 /* Nonzero for -fexpensive-optimizations:
463 perform miscellaneous relatively-expensive optimizations. */
464 int flag_expensive_optimizations;
466 /* Nonzero for -fthread-jumps:
467 have jump optimize output of loop. */
469 int flag_thread_jumps;
471 /* Nonzero enables strength-reduction in loop.c. */
473 int flag_strength_reduce = 0;
475 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
476 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
477 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
478 unrolled. */
480 int flag_unroll_loops;
482 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
483 This is generally not a win. */
485 int flag_unroll_all_loops;
487 /* Nonzero forces all invariant computations in loops to be moved
488 outside the loop. */
490 int flag_move_all_movables = 0;
492 /* Nonzero forces all general induction variables in loops to be
493 strength reduced. */
495 int flag_reduce_all_givs = 0;
497 /* Nonzero to perform full register move optimization passes. This is the
498 default for -O2. */
500 int flag_regmove = 0;
502 /* Nonzero for -fwritable-strings:
503 store string constants in data segment and don't uniquize them. */
505 int flag_writable_strings = 0;
507 /* Nonzero means don't put addresses of constant functions in registers.
508 Used for compiling the Unix kernel, where strange substitutions are
509 done on the assembly output. */
511 int flag_no_function_cse = 0;
513 /* Nonzero for -fomit-frame-pointer:
514 don't make a frame pointer in simple functions that don't require one. */
516 int flag_omit_frame_pointer = 0;
518 /* Nonzero means place each function into its own section on those platforms
519 which support arbitrary section names and unlimited numbers of sections. */
521 int flag_function_sections = 0;
523 /* ... and similar for data. */
525 int flag_data_sections = 0;
527 /* Nonzero to inhibit use of define_optimization peephole opts. */
529 int flag_no_peephole = 0;
531 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
532 operations in the interest of optimization. For example it allows
533 GCC to assume arguments to sqrt are nonnegative numbers, allowing
534 faster code for sqrt to be generated. */
536 int flag_fast_math = 0;
538 /* Nonzero means the front end generally wants `errno' maintained by math
539 operations, like built-in SQRT, unless overridden by flag_fast_math. */
541 int flag_errno_math = 1;
543 /* 0 means straightforward implementation of complex divide acceptable.
544 1 means wide ranges of inputs must work for complex divide.
545 2 means C9X-like requirements for complex divide (not yet implemented). */
547 int flag_complex_divide_method = 0;
549 /* Nonzero means all references through pointers are volatile. */
551 int flag_volatile;
553 /* Nonzero means treat all global and extern variables as volatile. */
555 int flag_volatile_global;
557 /* Nonzero means treat all static variables as volatile. */
559 int flag_volatile_static;
561 /* Nonzero means just do syntax checking; don't output anything. */
563 int flag_syntax_only = 0;
565 /* Nonzero means perform global cse. */
567 static int flag_gcse;
569 /* Nonzero means to use global dataflow analysis to eliminate
570 useless null pointer tests. */
572 static int flag_delete_null_pointer_checks;
574 /* Nonzero means to rerun cse after loop optimization. This increases
575 compilation time about 20% and picks up a few more common expressions. */
577 static int flag_rerun_cse_after_loop;
579 /* Nonzero means to run loop optimizations twice. */
581 int flag_rerun_loop_opt;
583 /* Nonzero for -finline-functions: ok to inline functions that look like
584 good inline candidates. */
586 int flag_inline_functions;
588 /* Nonzero for -fkeep-inline-functions: even if we make a function
589 go inline everywhere, keep its definition around for debugging
590 purposes. */
592 int flag_keep_inline_functions;
594 /* Nonzero means that functions will not be inlined. */
596 int flag_no_inline;
598 /* Nonzero means that we should emit static const variables
599 regardless of whether or not optimization is turned on. */
601 int flag_keep_static_consts = 1;
603 /* Nonzero means we should be saving declaration info into a .X file. */
605 int flag_gen_aux_info = 0;
607 /* Specified name of aux-info file. */
609 static char *aux_info_file_name;
611 /* Nonzero means make the text shared if supported. */
613 int flag_shared_data;
615 /* Nonzero means schedule into delayed branch slots if supported. */
617 int flag_delayed_branch;
619 /* Nonzero if we are compiling pure (sharable) code.
620 Value is 1 if we are doing reasonable (i.e. simple
621 offset into offset table) pic. Value is 2 if we can
622 only perform register offsets. */
624 int flag_pic;
626 /* Nonzero means generate extra code for exception handling and enable
627 exception handling. */
629 int flag_exceptions;
631 /* Nonzero means use the new model for exception handling. Replaces
632 -DNEW_EH_MODEL as a compile option. */
634 int flag_new_exceptions = 1;
636 /* Nonzero means generate frame unwind info table when supported */
638 int flag_unwind_tables = 0;
640 /* Nonzero means don't place uninitialized global data in common storage
641 by default. */
643 int flag_no_common;
645 /* Nonzero means pretend it is OK to examine bits of target floats,
646 even if that isn't true. The resulting code will have incorrect constants,
647 but the same series of instructions that the native compiler would make. */
649 int flag_pretend_float;
651 /* Nonzero means change certain warnings into errors.
652 Usually these are warnings about failure to conform to some standard. */
654 int flag_pedantic_errors = 0;
656 /* flag_schedule_insns means schedule insns within basic blocks (before
657 local_alloc).
658 flag_schedule_insns_after_reload means schedule insns after
659 global_alloc. */
661 int flag_schedule_insns = 0;
662 int flag_schedule_insns_after_reload = 0;
664 /* The following flags have effect only for scheduling before register
665 allocation:
667 flag_schedule_interblock means schedule insns accross basic blocks.
668 flag_schedule_speculative means allow speculative motion of non-load insns.
669 flag_schedule_speculative_load means allow speculative motion of some
670 load insns.
671 flag_schedule_speculative_load_dangerous allows speculative motion of more
672 load insns. */
674 int flag_schedule_interblock = 1;
675 int flag_schedule_speculative = 1;
676 int flag_schedule_speculative_load = 0;
677 int flag_schedule_speculative_load_dangerous = 0;
679 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
680 by a cheaper branch, on a count register. */
681 int flag_branch_on_count_reg;
683 /* -finhibit-size-directive inhibits output of .size for ELF.
684 This is used only for compiling crtstuff.c,
685 and it may be extended to other effects
686 needed for crtstuff.c on other systems. */
687 int flag_inhibit_size_directive = 0;
689 /* -fverbose-asm causes extra commentary information to be produced in
690 the generated assembly code (to make it more readable). This option
691 is generally only of use to those who actually need to read the
692 generated assembly code (perhaps while debugging the compiler itself).
693 -fno-verbose-asm, the default, causes the extra information
694 to be omitted and is useful when comparing two assembler files. */
696 int flag_verbose_asm = 0;
698 /* -dA causes debug commentary information to be produced in
699 the generated assembly code (to make it more readable). This option
700 is generally only of use to those who actually need to read the
701 generated assembly code (perhaps while debugging the compiler itself).
702 Currently, this switch is only used by dwarfout.c; however, it is intended
703 to be a catchall for printing debug information in the assembler file. */
705 int flag_debug_asm = 0;
707 /* -fgnu-linker specifies use of the GNU linker for initializations.
708 (Or, more generally, a linker that handles initializations.)
709 -fno-gnu-linker says that collect2 will be used. */
710 #ifdef USE_COLLECT2
711 int flag_gnu_linker = 0;
712 #else
713 int flag_gnu_linker = 1;
714 #endif
716 /* Tag all structures with __attribute__(packed) */
717 int flag_pack_struct = 0;
719 /* Emit code to check for stack overflow; also may cause large objects
720 to be allocated dynamically. */
721 int flag_stack_check;
723 /* -fcheck-memory-usage causes extra code to be generated in order to check
724 memory accesses. This is used by a detector of bad memory accesses such
725 as Checker. */
726 int flag_check_memory_usage = 0;
728 /* -fprefix-function-name causes function name to be prefixed. This
729 can be used with -fcheck-memory-usage to isolate code compiled with
730 -fcheck-memory-usage. */
731 int flag_prefix_function_name = 0;
733 /* 0 if pointer arguments may alias each other. True in C.
734 1 if pointer arguments may not alias each other but may alias
735 global variables.
736 2 if pointer arguments may not alias each other and may not
737 alias global variables. True in Fortran.
738 This defaults to 0 for C. */
739 int flag_argument_noalias = 0;
741 /* Nonzero if we should do (language-dependent) alias analysis.
742 Typically, this analysis will assume that expressions of certain
743 types do not alias expressions of certain other types. Only used
744 if alias analysis (in general) is enabled. */
745 int flag_strict_aliasing = 0;
747 /* Instrument functions with calls at entry and exit, for profiling. */
748 int flag_instrument_function_entry_exit = 0;
750 /* Nonzero means ignore `#ident' directives. 0 means handle them.
751 On SVR4 targets, it also controls whether or not to emit a
752 string identifying the compiler. */
754 int flag_no_ident = 0;
756 /* This will perform a peephole pass before sched2. */
757 int flag_peephole2 = 0;
759 /* -fbounded-pointers causes gcc to compile pointers as composite
760 objects occupying three words: the pointer value, the base address
761 of the referent object, and the address immediately beyond the end
762 of the referent object. The base and extent allow us to perform
763 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
764 int flag_bounded_pointers = 0;
766 /* -fcheck-bounds causes gcc to generate array bounds checks.
767 For C, C++: defaults to value of flag_bounded_pointers.
768 For ObjC: defaults to off.
769 For Java: defaults to on.
770 For Fortran: defaults to off.
771 For CHILL: defaults to off. */
772 int flag_bounds_check = 0;
774 /* If one, renumber instruction UIDs to reduce the number of
775 unused UIDs if there are a lot of instructions. If greater than
776 one, unconditionally renumber instruction UIDs. */
777 int flag_renumber_insns = 1;
779 /* Values of the -falign-* flags: how much to align labels in code.
780 0 means `use default', 1 means `don't align'.
781 For each variable, there is an _log variant which is the power
782 of two not less than the variable, for .align output. */
784 int align_loops;
785 int align_loops_log;
786 int align_jumps;
787 int align_jumps_log;
788 int align_labels;
789 int align_labels_log;
790 int align_functions;
791 int align_functions_log;
793 /* Table of supported debugging formats. */
794 static struct
796 const char * arg;
797 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
798 constant expression, we use NO_DEBUG in its place. */
799 enum debug_info_type debug_type;
800 int use_extensions_p;
801 const char * description;
802 } *da,
803 debug_args[] =
805 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
806 "Generate default debug format output" },
807 { "gdb", NO_DEBUG, 1, "Generate default extended debug format output" },
808 #ifdef DBX_DEBUGGING_INFO
809 { "stabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
810 { "stabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
811 #endif
812 #ifdef DWARF_DEBUGGING_INFO
813 { "dwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
814 { "dwarf+", DWARF_DEBUG, 1,
815 "Generated extended DWARF-1 format debug output" },
816 #endif
817 #ifdef DWARF2_DEBUGGING_INFO
818 { "dwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
819 #endif
820 #ifdef XCOFF_DEBUGGING_INFO
821 { "xcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
822 { "xcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
823 #endif
824 #ifdef SDB_DEBUGGING_INFO
825 { "coff", SDB_DEBUG, 0, "Generate COFF format debug output" },
826 #endif
827 { 0, 0, 0, 0 }
830 typedef struct
832 const char * string;
833 int * variable;
834 int on_value;
835 const char * description;
837 lang_independent_options;
839 /* Add or remove a leading underscore from user symbols. */
840 int flag_leading_underscore = -1;
842 /* The user symbol prefix after having resolved same. */
843 const char *user_label_prefix;
845 /* A default for same. */
846 #ifndef USER_LABEL_PREFIX
847 #define USER_LABEL_PREFIX ""
848 #endif
850 /* Table of language-independent -f options.
851 STRING is the option name. VARIABLE is the address of the variable.
852 ON_VALUE is the value to store in VARIABLE
853 if `-fSTRING' is seen as an option.
854 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
856 lang_independent_options f_options[] =
858 {"float-store", &flag_float_store, 1,
859 "Do not store floats in registers" },
860 {"volatile", &flag_volatile, 1,
861 "Consider all mem refs through pointers as volatile"},
862 {"volatile-global", &flag_volatile_global, 1,
863 "Consider all mem refs to global data to be volatile" },
864 {"volatile-static", &flag_volatile_static, 1,
865 "Consider all mem refs to static data to be volatile" },
866 {"defer-pop", &flag_defer_pop, 1,
867 "Defer popping functions args from stack until later" },
868 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
869 "When possible do not generate stack frames"},
870 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
871 "When running CSE, follow jumps to their targets" },
872 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
873 "When running CSE, follow conditional jumps" },
874 {"expensive-optimizations", &flag_expensive_optimizations, 1,
875 "Perform a number of minor, expensive optimisations" },
876 {"thread-jumps", &flag_thread_jumps, 1,
877 "Perform jump threading optimisations"},
878 {"strength-reduce", &flag_strength_reduce, 1,
879 "Perform strength reduction optimisations" },
880 {"unroll-loops", &flag_unroll_loops, 1,
881 "Perform loop unrolling when iteration count is known" },
882 {"unroll-all-loops", &flag_unroll_all_loops, 1,
883 "Perform loop unrolling for all loops" },
884 {"move-all-movables", &flag_move_all_movables, 1,
885 "Force all loop invariant computations out of loops" },
886 {"reduce-all-givs", &flag_reduce_all_givs, 1,
887 "Strength reduce all loop general induction variables" },
888 {"writable-strings", &flag_writable_strings, 1,
889 "Store strings in writable data section" },
890 {"peephole", &flag_no_peephole, 0,
891 "Enable machine specific peephole optimisations" },
892 {"force-mem", &flag_force_mem, 1,
893 "Copy memory operands into registers before using" },
894 {"force-addr", &flag_force_addr, 1,
895 "Copy memory address constants into regs before using" },
896 {"function-cse", &flag_no_function_cse, 0,
897 "Allow function addresses to be held in registers" },
898 {"inline-functions", &flag_inline_functions, 1,
899 "Integrate simple functions into their callers" },
900 {"keep-inline-functions", &flag_keep_inline_functions, 1,
901 "Generate code for funcs even if they are fully inlined" },
902 {"inline", &flag_no_inline, 0,
903 "Pay attention to the 'inline' keyword"},
904 {"keep-static-consts", &flag_keep_static_consts, 1,
905 "Emit static const variables even if they are not used" },
906 {"syntax-only", &flag_syntax_only, 1,
907 "Check for syntax errors, then stop" },
908 {"shared-data", &flag_shared_data, 1,
909 "Mark data as shared rather than private" },
910 {"caller-saves", &flag_caller_saves, 1,
911 "Enable saving registers around function calls" },
912 {"pcc-struct-return", &flag_pcc_struct_return, 1,
913 "Return 'short' aggregates in memory, not registers" },
914 {"reg-struct-return", &flag_pcc_struct_return, 0,
915 "Return 'short' aggregates in registers" },
916 {"delayed-branch", &flag_delayed_branch, 1,
917 "Attempt to fill delay slots of branch instructions" },
918 {"gcse", &flag_gcse, 1,
919 "Perform the global common subexpression elimination" },
920 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
921 "Run CSE pass after loop optimisations"},
922 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
923 "Run the loop optimiser twice"},
924 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
925 "Delete useless null pointer checks" },
926 {"pretend-float", &flag_pretend_float, 1,
927 "Pretend that host and target use the same FP format"},
928 {"schedule-insns", &flag_schedule_insns, 1,
929 "Reschedule instructions to avoid pipeline stalls"},
930 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
931 "Run two passes of the instruction scheduler"},
932 {"sched-interblock",&flag_schedule_interblock, 1,
933 "Enable scheduling across basic blocks" },
934 {"sched-spec",&flag_schedule_speculative, 1,
935 "Allow speculative motion of non-loads" },
936 {"sched-spec-load",&flag_schedule_speculative_load, 1,
937 "Allow speculative motion of some loads" },
938 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
939 "Allow speculative motion of more loads" },
940 {"branch-count-reg",&flag_branch_on_count_reg, 1,
941 "Replace add,compare,branch with branch on count reg"},
942 {"pic", &flag_pic, 1,
943 "Generate position independent code, if possible"},
944 {"PIC", &flag_pic, 2, ""},
945 {"exceptions", &flag_exceptions, 1,
946 "Enable exception handling" },
947 {"new-exceptions", &flag_new_exceptions, 1,
948 "Use the new model for exception handling" },
949 {"unwind-tables", &flag_unwind_tables, 1,
950 "Just generate unwind tables for exception handling" },
951 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
952 "Use setjmp/longjmp to handle exceptions" },
953 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
954 "Support asynchronous exceptions" },
955 {"profile-arcs", &profile_arc_flag, 1,
956 "Insert arc based program profiling code" },
957 {"test-coverage", &flag_test_coverage, 1,
958 "Create data files needed by gcov" },
959 {"branch-probabilities", &flag_branch_probabilities, 1,
960 "Use profiling information for branch probabilities" },
961 {"fast-math", &flag_fast_math, 1,
962 "Improve FP speed by violating ANSI & IEEE rules" },
963 {"common", &flag_no_common, 0,
964 "Do not put unitialised globals in the common section" },
965 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
966 "Do not generate .size directives" },
967 {"function-sections", &flag_function_sections, 1,
968 "place each function into its own section" },
969 {"data-sections", &flag_data_sections, 1,
970 "place data items into their own section" },
971 {"verbose-asm", &flag_verbose_asm, 1,
972 "Add extra commentry to assembler output"},
973 {"gnu-linker", &flag_gnu_linker, 1,
974 "Output GNU ld formatted global initialisers"},
975 {"regmove", &flag_regmove, 1,
976 "Enables a register move optimisation"},
977 {"optimize-register-move", &flag_regmove, 1,
978 "Do the full regmove optimization pass"},
979 {"pack-struct", &flag_pack_struct, 1,
980 "Pack structure members together without holes" },
981 {"stack-check", &flag_stack_check, 1,
982 "Insert stack checking code into the program" },
983 {"argument-alias", &flag_argument_noalias, 0,
984 "Specify that arguments may alias each other & globals"},
985 {"argument-noalias", &flag_argument_noalias, 1,
986 "Assume arguments may alias globals but not each other"},
987 {"argument-noalias-global", &flag_argument_noalias, 2,
988 "Assume arguments do not alias each other or globals" },
989 {"strict-aliasing", &flag_strict_aliasing, 1,
990 "Assume strict aliasing rules apply" },
991 {"align-loops", &align_loops, 0,
992 "Align the start of loops" },
993 {"align-jumps", &align_jumps, 0,
994 "Align labels which are only reached by jumping" },
995 {"align-labels", &align_labels, 0,
996 "Align all labels" },
997 {"align-functions", &align_functions, 0,
998 "Align the start of functions" },
999 {"check-memory-usage", &flag_check_memory_usage, 1,
1000 "Generate code to check every memory access" },
1001 {"prefix-function-name", &flag_prefix_function_name, 1,
1002 "Add a prefix to all function names" },
1003 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1004 "Suppress output of instruction numbers and line number notes in debugging dumps"},
1005 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1006 "Instrument function entry/exit with profiling calls"},
1007 {"leading-underscore", &flag_leading_underscore, 1,
1008 "External symbols have a leading underscore" },
1009 {"ident", &flag_no_ident, 0,
1010 "Process #ident directives"},
1011 { "peephole2", &flag_peephole2, 1,
1012 "Enables an rtl peephole pass run before sched2" },
1013 {"math-errno", &flag_errno_math, 1,
1014 "Set errno after built-in math functions"},
1015 {"bounded-pointers", &flag_bounded_pointers, 1,
1016 "Compile pointers as triples: value, base & end" },
1017 {"bounds-check", &flag_bounds_check, 1,
1018 "Generate code to check bounds before dereferencing pointers and arrays" }
1021 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
1023 /* Table of language-specific options. */
1025 static struct lang_opt
1027 const char * option;
1028 const char * description;
1030 documented_lang_options[] =
1032 /* In order not to overload the --help output, the convention
1033 used here is to only describe those options which are not
1034 enabled by default. */
1036 { "-ansi", "Compile just for ANSI C" },
1037 { "-fallow-single-precision",
1038 "Do not promote floats to double if using -traditional" },
1039 { "-std= ", "Determine language standard"},
1041 { "-fsigned-bitfields", "" },
1042 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1043 { "-fno-signed-bitfields", "" },
1044 { "-fno-unsigned-bitfields","" },
1045 { "-fsigned-char", "Make 'char' be signed by default"},
1046 { "-funsigned-char", "Make 'char' be unsigned by default"},
1047 { "-fno-signed-char", "" },
1048 { "-fno-unsigned-char", "" },
1050 { "-ftraditional", "" },
1051 { "-traditional", "Attempt to support traditional K&R style C"},
1052 { "-fnotraditional", "" },
1053 { "-fno-traditional", "" },
1055 { "-fasm", "" },
1056 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1057 { "-fbuiltin", "" },
1058 { "-fno-builtin", "Do not recognise any built in functions" },
1059 { "-fhosted", "Assume normal C execution environment" },
1060 { "-fno-hosted", "" },
1061 { "-ffreestanding",
1062 "Assume that standard libraries & main might not exist" },
1063 { "-fno-freestanding", "" },
1064 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1065 { "-fno-cond-mismatch", "" },
1066 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1067 { "-fno-dollars-in-identifiers", "" },
1068 { "-fpreprocessed", "" },
1069 { "-fno-preprocessed", "" },
1070 { "-fshort-double", "Use the same size for double as for float" },
1071 { "-fno-short-double", "" },
1072 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1073 { "-fno-short-enums", "" },
1074 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1075 { "-fno-short-wchar", "" },
1077 { "-Wall", "Enable most warning messages" },
1078 { "-Wbad-function-cast",
1079 "Warn about casting functions to incompatible types" },
1080 { "-Wno-bad-function-cast", "" },
1081 { "-Wmissing-noreturn",
1082 "Warn about functions which might be candidates for attribute noreturn" },
1083 { "-Wno-missing-noreturn", "" },
1084 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1085 { "-Wno-cast-qual", "" },
1086 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1087 { "-Wno-char-subscripts", "" },
1088 { "-Wcomment", "Warn if nested comments are detected" },
1089 { "-Wno-comment", "" },
1090 { "-Wcomments", "Warn if nested comments are detected" },
1091 { "-Wno-comments", "" },
1092 { "-Wconversion", "Warn about possibly confusing type conversions" },
1093 { "-Wno-conversion", "" },
1094 { "-Wformat", "Warn about printf format anomalies" },
1095 { "-Wno-format", "" },
1096 { "-Wimplicit-function-declaration",
1097 "Warn about implicit function declarations" },
1098 { "-Wno-implicit-function-declaration", "" },
1099 { "-Werror-implicit-function-declaration", "" },
1100 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1101 { "-Wno-implicit-int", "" },
1102 { "-Wimplicit", "" },
1103 { "-Wno-implicit", "" },
1104 { "-Wimport", "Warn about the use of the #import directive" },
1105 { "-Wno-import", "" },
1106 { "-Wlong-long","" },
1107 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1108 { "-Wmain", "Warn about suspicious declarations of main" },
1109 { "-Wno-main", "" },
1110 { "-Wmissing-braces",
1111 "Warn about possibly missing braces around initialisers" },
1112 { "-Wno-missing-braces", "" },
1113 { "-Wmissing-declarations",
1114 "Warn about global funcs without previous declarations"},
1115 { "-Wno-missing-declarations", "" },
1116 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1117 { "-Wno-missing-prototypes", "" },
1118 { "-Wmultichar", "Warn about use of multicharacter literals"},
1119 { "-Wno-multichar", "" },
1120 { "-Wnested-externs", "Warn about externs not at file scope level" },
1121 { "-Wno-nested-externs", "" },
1122 { "-Wparentheses", "Warn about possible missing parentheses" },
1123 { "-Wno-parentheses", "" },
1124 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1125 { "-Wno-pointer-arith", "" },
1126 { "-Wredundant-decls",
1127 "Warn about multiple declarations of the same object" },
1128 { "-Wno-redundant-decls", "" },
1129 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1130 { "-Wno-sign-compare", "" },
1131 { "-Wfloat-equal", "Warn about testing equality of floating point numbers" },
1132 { "-Wno-float-equal", "" },
1133 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1134 { "-Wno-unknown-pragmas", "" },
1135 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1136 { "-Wno-strict-prototypes", "" },
1137 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1138 { "-Wno-traditional", "" },
1139 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1140 { "-Wno-trigraphs", "" },
1141 { "-Wundef", "" },
1142 { "-Wno-undef", "" },
1143 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1144 { "-Wno-write-strings", "" },
1146 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1148 /* These are for Objective C. */
1149 DEFINE_LANG_NAME ("Objective C")
1151 { "-lang-objc", "" },
1152 { "-gen-decls", "Dump decls to a .decl file" },
1153 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1154 { "-fno-gnu-runtime", "" },
1155 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1156 { "-fno-next-runtime", "" },
1157 { "-Wselector", "Warn if a selector has multiple methods" },
1158 { "-Wno-selector", "" },
1159 { "-Wprotocol", "" },
1160 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1161 { "-print-objc-runtime-info",
1162 "Generate C header of platform specific features" },
1164 #include "options.h"
1168 /* Here is a table, controlled by the tm.h file, listing each -m switch
1169 and which bits in `target_switches' it should set or clear.
1170 If VALUE is positive, it is bits to set.
1171 If VALUE is negative, -VALUE is bits to clear.
1172 (The sign bit is not used so there is no confusion.) */
1174 struct
1176 const char * name;
1177 int value;
1178 const char * description;
1180 target_switches [] = TARGET_SWITCHES;
1182 /* This table is similar, but allows the switch to have a value. */
1184 #ifdef TARGET_OPTIONS
1185 struct
1187 const char * prefix;
1188 const char ** variable;
1189 const char * description;
1191 target_options [] = TARGET_OPTIONS;
1192 #endif
1194 /* Options controlling warnings */
1196 /* Don't print warning messages. -w. */
1198 int inhibit_warnings = 0;
1200 /* Print various extra warnings. -W. */
1202 int extra_warnings = 0;
1204 /* Treat warnings as errors. -Werror. */
1206 int warnings_are_errors = 0;
1208 /* Nonzero to warn about unused local variables. */
1210 int warn_unused;
1212 /* Nonzero to warn about code which is never reached. */
1214 int warn_notreached;
1216 /* Nonzero to warn about variables used before they are initialized. */
1218 int warn_uninitialized;
1220 /* Nonzero means warn about all declarations which shadow others. */
1222 int warn_shadow;
1224 /* Warn if a switch on an enum fails to have a case for every enum value. */
1226 int warn_switch;
1228 /* Nonzero means warn about function definitions that default the return type
1229 or that use a null return and have a return-type other than void. */
1231 int warn_return_type;
1233 /* Nonzero means warn about pointer casts that increase the required
1234 alignment of the target type (and might therefore lead to a crash
1235 due to a misaligned access). */
1237 int warn_cast_align;
1239 /* Nonzero means warn about any identifiers that match in the first N
1240 characters. The value N is in `id_clash_len'. */
1242 int warn_id_clash;
1243 unsigned id_clash_len;
1245 /* Nonzero means warn about any objects definitions whose size is larger
1246 than N bytes. Also want about function definitions whose returned
1247 values are larger than N bytes. The value N is in `larger_than_size'. */
1249 int warn_larger_than;
1250 unsigned larger_than_size;
1252 /* Nonzero means warn if inline function is too large. */
1254 int warn_inline;
1256 /* Warn if a function returns an aggregate,
1257 since there are often incompatible calling conventions for doing this. */
1259 int warn_aggregate_return;
1261 /* Likewise for -W. */
1263 lang_independent_options W_options[] =
1265 {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1266 {"error", &warnings_are_errors, 1, ""},
1267 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1268 {"switch", &warn_switch, 1,
1269 "Warn about enumerated switches missing a specific case" },
1270 {"aggregate-return", &warn_aggregate_return, 1,
1271 "Warn about returning structures, unions or arrays" },
1272 {"cast-align", &warn_cast_align, 1,
1273 "Warn about pointer casts which increase alignment" },
1274 {"unreachable-code", &warn_notreached, 1,
1275 "Warn about code that will never be executed" },
1276 {"uninitialized", &warn_uninitialized, 1,
1277 "Warn about unitialized automatic variables"},
1278 {"inline", &warn_inline, 1,
1279 "Warn when an inlined function cannot be inlined"}
1282 /* Output files for assembler code (real compiler output)
1283 and debugging dumps. */
1285 FILE *asm_out_file;
1286 FILE *aux_info_file;
1287 FILE *rtl_dump_file = NULL;
1289 /* Decode the string P as an integral parameter.
1290 If the string is indeed an integer return its numeric value else
1291 issue an Invalid Option error for the option PNAME and return DEFVAL.
1292 If PNAME is zero just return DEFVAL, do not call error. */
1295 read_integral_parameter (p, pname, defval)
1296 const char *p;
1297 const char *pname;
1298 const int defval;
1300 const char *endp = p;
1302 while (*endp)
1304 if (*endp >= '0' && *endp <= '9')
1305 endp++;
1306 else
1307 break;
1310 if (*endp != 0)
1312 if (pname != 0)
1313 error ("Invalid option `%s'", pname);
1314 return defval;
1317 return atoi (p);
1321 /* Time accumulators, to count the total time spent in various passes. */
1323 int parse_time;
1324 int varconst_time;
1325 int integration_time;
1326 int jump_time;
1327 int cse_time;
1328 int gcse_time;
1329 int loop_time;
1330 int cse2_time;
1331 int branch_prob_time;
1332 int flow_time;
1333 int combine_time;
1334 int regmove_time;
1335 int sched_time;
1336 int local_alloc_time;
1337 int global_alloc_time;
1338 int flow2_time;
1339 int peephole2_time;
1340 int sched2_time;
1341 int dbr_sched_time;
1342 int shorten_branch_time;
1343 int stack_reg_time;
1344 int final_time;
1345 int symout_time;
1346 int dump_time;
1347 int gc_time;
1348 int all_time;
1350 /* Return time used so far, in microseconds. */
1352 long
1353 get_run_time ()
1355 if (quiet_flag)
1356 return 0;
1358 #ifdef __BEOS__
1359 return 0;
1360 #else /* not BeOS */
1361 #if defined (_WIN32) && !defined (__CYGWIN__)
1362 if (clock() < 0)
1363 return 0;
1364 else
1365 return (clock() * 1000);
1366 #else /* not _WIN32 */
1367 #ifdef _SC_CLK_TCK
1369 static int tick;
1370 struct tms tms;
1371 if (tick == 0)
1372 tick = 1000000 / sysconf(_SC_CLK_TCK);
1373 times (&tms);
1374 return (tms.tms_utime + tms.tms_stime) * tick;
1376 #else
1377 #ifdef USG
1379 struct tms tms;
1380 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1381 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1382 # else
1383 # ifdef CLK_TCK
1384 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1385 # else
1386 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1387 # endif
1388 # endif
1389 times (&tms);
1390 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1392 #else
1393 #ifndef VMS
1395 struct rusage rusage;
1396 getrusage (0, &rusage);
1397 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1398 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1400 #else /* VMS */
1402 struct
1404 int proc_user_time;
1405 int proc_system_time;
1406 int child_user_time;
1407 int child_system_time;
1408 } vms_times;
1409 times ((void *) &vms_times);
1410 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1412 #endif /* VMS */
1413 #endif /* USG */
1414 #endif /* _SC_CLK_TCK */
1415 #endif /* _WIN32 */
1416 #endif /* __BEOS__ */
1419 #define TIMEVAR(VAR, BODY) \
1420 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1422 void
1423 print_time (str, total)
1424 const char *str;
1425 int total;
1427 fprintf (stderr,
1428 "time in %s: %d.%06d (%.0f%%)\n",
1429 str, total / 1000000, total % 1000000,
1430 (double)total / (double)all_time * 100.0);
1433 /* Count an error or warning. Return 1 if the message should be printed. */
1436 count_error (warningp)
1437 int warningp;
1439 if (warningp && inhibit_warnings)
1440 return 0;
1442 if (warningp && !warnings_are_errors)
1443 warningcount++;
1444 else
1446 static int warning_message = 0;
1448 if (warningp && !warning_message)
1450 notice ("%s: warnings being treated as errors\n", progname);
1451 warning_message = 1;
1453 errorcount++;
1456 return 1;
1459 /* Print a fatal error message. NAME is the text.
1460 Also include a system error message based on `errno'. */
1462 void
1463 pfatal_with_name (name)
1464 const char *name;
1466 fprintf (stderr, "%s: ", progname);
1467 perror (name);
1468 exit (FATAL_EXIT_CODE);
1471 void
1472 fatal_io_error (name)
1473 const char *name;
1475 notice ("%s: %s: I/O error\n", progname, name);
1476 exit (FATAL_EXIT_CODE);
1479 /* This is the default decl_printable_name function. */
1481 static const char *
1482 decl_name (decl, verbosity)
1483 tree decl;
1484 int verbosity ATTRIBUTE_UNUSED;
1486 return IDENTIFIER_POINTER (DECL_NAME (decl));
1489 /* Mark P for GC. Also mark main_input_filename and input_filename. */
1490 static void
1491 mark_file_stack (p)
1492 void *p;
1494 struct file_stack *stack = *(struct file_stack **)p;
1496 /* We're only called for input_file_stack, so we can mark the current
1497 input_filename here as well. */
1498 ggc_mark_string (main_input_filename);
1499 ggc_mark_string (input_filename);
1501 while (stack)
1503 ggc_mark_string (stack->name);
1504 stack = stack->next;
1508 static int need_error_newline;
1510 /* Function of last error message;
1511 more generally, function such that if next error message is in it
1512 then we don't have to mention the function name. */
1513 static tree last_error_function = NULL;
1515 /* Used to detect when input_file_stack has changed since last described. */
1516 static int last_error_tick;
1518 /* Called when the start of a function definition is parsed,
1519 this function prints on stderr the name of the function. */
1521 void
1522 announce_function (decl)
1523 tree decl;
1525 if (! quiet_flag)
1527 if (rtl_dump_and_exit)
1528 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1529 else
1530 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1531 fflush (stderr);
1532 need_error_newline = 1;
1533 last_error_function = current_function_decl;
1537 /* The default function to print out name of current function that caused
1538 an error. */
1540 void
1541 default_print_error_function (file)
1542 const char *file;
1544 if (last_error_function != current_function_decl)
1546 if (file)
1547 fprintf (stderr, "%s: ", file);
1549 if (current_function_decl == NULL)
1550 notice ("At top level:\n");
1551 else
1552 notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE
1553 ? "In method `%s':\n"
1554 : "In function `%s':\n"),
1555 (*decl_printable_name) (current_function_decl, 2));
1557 last_error_function = current_function_decl;
1561 /* Called by report_error_function to print out function name.
1562 * Default may be overridden by language front-ends. */
1564 void (*print_error_function) PROTO((const char *)) =
1565 default_print_error_function;
1567 /* Prints out, if necessary, the name of the current function
1568 that caused an error. Called from all error and warning functions.
1569 We ignore the FILE parameter, as it cannot be relied upon. */
1571 void
1572 report_error_function (file)
1573 const char *file ATTRIBUTE_UNUSED;
1575 struct file_stack *p;
1577 if (need_error_newline)
1579 fprintf (stderr, "\n");
1580 need_error_newline = 0;
1583 if (input_file_stack && input_file_stack->next != 0
1584 && input_file_stack_tick != last_error_tick)
1586 for (p = input_file_stack->next; p; p = p->next)
1587 notice ((p == input_file_stack->next
1588 ? "In file included from %s:%d"
1589 : ",\n from %s:%d"),
1590 p->name, p->line);
1591 fprintf (stderr, ":\n");
1592 last_error_tick = input_file_stack_tick;
1595 (*print_error_function) (input_filename);
1598 /* Print a message. */
1600 static void
1601 vnotice (file, msgid, ap)
1602 FILE *file;
1603 const char *msgid;
1604 va_list ap;
1606 vfprintf (file, _(msgid), ap);
1609 static void
1610 notice VPROTO((const char *msgid, ...))
1612 #ifndef ANSI_PROTOTYPES
1613 char *msgid;
1614 #endif
1615 va_list ap;
1617 VA_START (ap, msgid);
1619 #ifndef ANSI_PROTOTYPES
1620 msgid = va_arg (ap, char *);
1621 #endif
1623 vnotice (stderr, msgid, ap);
1624 va_end (ap);
1627 void
1628 fnotice VPROTO((FILE *file, const char *msgid, ...))
1630 #ifndef ANSI_PROTOTYPES
1631 FILE *file;
1632 const char *msgid;
1633 #endif
1634 va_list ap;
1636 VA_START (ap, msgid);
1638 #ifndef ANSI_PROTOTYPES
1639 file = va_arg (ap, FILE *);
1640 msgid = va_arg (ap, const char *);
1641 #endif
1643 vnotice (file, msgid, ap);
1644 va_end (ap);
1647 /* Report FILE and LINE (or program name), and optionally just WARN. */
1649 static void
1650 report_file_and_line (file, line, warn)
1651 const char *file;
1652 int line;
1653 int warn;
1655 if (file)
1656 fprintf (stderr, "%s:%d: ", file, line);
1657 else
1658 fprintf (stderr, "%s: ", progname);
1660 if (warn)
1661 notice ("warning: ");
1664 /* Print a message. */
1666 static void
1667 vmessage (prefix, msgid, ap)
1668 const char *prefix;
1669 const char *msgid;
1670 va_list ap;
1672 if (prefix)
1673 fprintf (stderr, "%s: ", prefix);
1675 vfprintf (stderr, msgid, ap);
1678 /* Print a message relevant to line LINE of file FILE. */
1680 static void
1681 v_message_with_file_and_line (file, line, warn, msgid, ap)
1682 const char *file;
1683 int line;
1684 int warn;
1685 const char *msgid;
1686 va_list ap;
1688 report_file_and_line (file, line, warn);
1689 vnotice (stderr, msgid, ap);
1690 fputc ('\n', stderr);
1693 /* Print a message relevant to the given DECL. */
1695 static void
1696 v_message_with_decl (decl, warn, msgid, ap)
1697 tree decl;
1698 int warn;
1699 const char *msgid;
1700 va_list ap;
1702 const char *p;
1704 report_file_and_line (DECL_SOURCE_FILE (decl),
1705 DECL_SOURCE_LINE (decl), warn);
1707 /* Do magic to get around lack of varargs support for insertion
1708 of arguments into existing list. We know that the decl is first;
1709 we ass_u_me that it will be printed with "%s". */
1711 for (p = _(msgid); *p; ++p)
1713 if (*p == '%')
1715 if (*(p + 1) == '%')
1716 ++p;
1717 else if (*(p + 1) != 's')
1718 abort ();
1719 else
1720 break;
1724 if (p > _(msgid)) /* Print the left-hand substring. */
1726 char fmt[sizeof "%.255s"];
1727 long width = p - _(msgid);
1729 if (width > 255L) width = 255L; /* arbitrary */
1730 sprintf (fmt, "%%.%lds", width);
1731 fprintf (stderr, fmt, _(msgid));
1734 if (*p == '%') /* Print the name. */
1736 const char *n = (DECL_NAME (decl)
1737 ? (*decl_printable_name) (decl, 2)
1738 : "((anonymous))");
1739 fputs (n, stderr);
1740 while (*p)
1742 ++p;
1743 if (ISALPHA (*(p - 1) & 0xFF))
1744 break;
1748 if (*p) /* Print the rest of the message. */
1749 vmessage ((char *)NULL, p, ap);
1751 fputc ('\n', stderr);
1754 /* Figure file and line of the given INSN. */
1756 static void
1757 file_and_line_for_asm (insn, pfile, pline)
1758 rtx insn;
1759 char **pfile;
1760 int *pline;
1762 rtx body = PATTERN (insn);
1763 rtx asmop;
1765 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1766 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1767 asmop = SET_SRC (body);
1768 else if (GET_CODE (body) == ASM_OPERANDS)
1769 asmop = body;
1770 else if (GET_CODE (body) == PARALLEL
1771 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1772 asmop = SET_SRC (XVECEXP (body, 0, 0));
1773 else if (GET_CODE (body) == PARALLEL
1774 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1775 asmop = XVECEXP (body, 0, 0);
1776 else
1777 asmop = NULL;
1779 if (asmop)
1781 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1782 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1784 else
1786 *pfile = input_filename;
1787 *pline = lineno;
1791 /* Report an error at line LINE of file FILE. */
1793 static void
1794 v_error_with_file_and_line (file, line, msgid, ap)
1795 const char *file;
1796 int line;
1797 const char *msgid;
1798 va_list ap;
1800 count_error (0);
1801 report_error_function (file);
1802 v_message_with_file_and_line (file, line, 0, msgid, ap);
1805 void
1806 error_with_file_and_line VPROTO((const char *file, int line,
1807 const char *msgid, ...))
1809 #ifndef ANSI_PROTOTYPES
1810 const char *file;
1811 int line;
1812 const char *msgid;
1813 #endif
1814 va_list ap;
1816 VA_START (ap, msgid);
1818 #ifndef ANSI_PROTOTYPES
1819 file = va_arg (ap, const char *);
1820 line = va_arg (ap, int);
1821 msgid = va_arg (ap, const char *);
1822 #endif
1824 v_error_with_file_and_line (file, line, msgid, ap);
1825 va_end (ap);
1828 /* Report an error at the declaration DECL.
1829 MSGID is a format string which uses %s to substitute the declaration
1830 name; subsequent substitutions are a la printf. */
1832 static void
1833 v_error_with_decl (decl, msgid, ap)
1834 tree decl;
1835 const char *msgid;
1836 va_list ap;
1838 count_error (0);
1839 report_error_function (DECL_SOURCE_FILE (decl));
1840 v_message_with_decl (decl, 0, msgid, ap);
1843 void
1844 error_with_decl VPROTO((tree decl, const char *msgid, ...))
1846 #ifndef ANSI_PROTOTYPES
1847 tree decl;
1848 const char *msgid;
1849 #endif
1850 va_list ap;
1852 VA_START (ap, msgid);
1854 #ifndef ANSI_PROTOTYPES
1855 decl = va_arg (ap, tree);
1856 msgid = va_arg (ap, const char *);
1857 #endif
1859 v_error_with_decl (decl, msgid, ap);
1860 va_end (ap);
1863 /* Report an error at the line number of the insn INSN.
1864 This is used only when INSN is an `asm' with operands,
1865 and each ASM_OPERANDS records its own source file and line. */
1867 static void
1868 v_error_for_asm (insn, msgid, ap)
1869 rtx insn;
1870 const char *msgid;
1871 va_list ap;
1873 char *file;
1874 int line;
1876 count_error (0);
1877 file_and_line_for_asm (insn, &file, &line);
1878 report_error_function (file);
1879 v_message_with_file_and_line (file, line, 0, msgid, ap);
1882 void
1883 error_for_asm VPROTO((rtx insn, const char *msgid, ...))
1885 #ifndef ANSI_PROTOTYPES
1886 rtx insn;
1887 const char *msgid;
1888 #endif
1889 va_list ap;
1891 VA_START (ap, msgid);
1893 #ifndef ANSI_PROTOTYPES
1894 insn = va_arg (ap, rtx);
1895 msgid = va_arg (ap, const char *);
1896 #endif
1898 v_error_for_asm (insn, msgid, ap);
1899 va_end (ap);
1902 /* Report an error at the current line number. */
1904 static void
1905 verror (msgid, ap)
1906 const char *msgid;
1907 va_list ap;
1909 v_error_with_file_and_line (input_filename, lineno, msgid, ap);
1912 void
1913 error VPROTO((const char *msgid, ...))
1915 #ifndef ANSI_PROTOTYPES
1916 const char *msgid;
1917 #endif
1918 va_list ap;
1920 VA_START (ap, msgid);
1922 #ifndef ANSI_PROTOTYPES
1923 msgid = va_arg (ap, const char *);
1924 #endif
1926 verror (msgid, ap);
1927 va_end (ap);
1930 /* Report a fatal error at the current line number. Allow a front end to
1931 intercept the message. */
1933 static void (*fatal_function) PROTO ((const char *, va_list));
1935 /* Set the function to call when a fatal error occurs. */
1937 void
1938 set_fatal_function (f)
1939 void (*f) PROTO ((const char *, va_list));
1941 fatal_function = f;
1944 static void
1945 vfatal (msgid, ap)
1946 const char *msgid;
1947 va_list ap;
1949 if (fatal_function != 0)
1950 (*fatal_function) (_(msgid), ap);
1952 verror (msgid, ap);
1953 exit (FATAL_EXIT_CODE);
1956 void
1957 fatal VPROTO((const char *msgid, ...))
1959 #ifndef ANSI_PROTOTYPES
1960 const char *msgid;
1961 #endif
1962 va_list ap;
1964 VA_START (ap, msgid);
1966 #ifndef ANSI_PROTOTYPES
1967 msgid = va_arg (ap, const char *);
1968 #endif
1970 vfatal (msgid, ap);
1971 va_end (ap);
1974 void
1975 _fatal_insn (msgid, insn, file, line, function)
1976 const char *msgid;
1977 rtx insn;
1978 const char *file;
1979 int line;
1980 const char *function;
1982 error (msgid);
1983 debug_rtx (insn);
1984 fancy_abort (file, line, function);
1987 void
1988 _fatal_insn_not_found (insn, file, line, function)
1989 rtx insn;
1990 const char *file;
1991 int line;
1992 const char *function;
1994 if (INSN_CODE (insn) < 0)
1995 _fatal_insn ("Unrecognizable insn:", insn, file, line, function);
1996 else
1997 _fatal_insn ("Insn does not satisfy its constraints:",
1998 insn, file, line, function);
2001 /* Report a warning at line LINE of file FILE. */
2003 static void
2004 v_warning_with_file_and_line (file, line, msgid, ap)
2005 const char *file;
2006 int line;
2007 const char *msgid;
2008 va_list ap;
2010 if (count_error (1))
2012 report_error_function (file);
2013 v_message_with_file_and_line (file, line, 1, msgid, ap);
2017 void
2018 warning_with_file_and_line VPROTO((const char *file, int line,
2019 const char *msgid, ...))
2021 #ifndef ANSI_PROTOTYPES
2022 const char *file;
2023 int line;
2024 const char *msgid;
2025 #endif
2026 va_list ap;
2028 VA_START (ap, msgid);
2030 #ifndef ANSI_PROTOTYPES
2031 file = va_arg (ap, const char *);
2032 line = va_arg (ap, int);
2033 msgid = va_arg (ap, const char *);
2034 #endif
2036 v_warning_with_file_and_line (file, line, msgid, ap);
2037 va_end (ap);
2040 /* Report a warning at the declaration DECL.
2041 MSGID is a format string which uses %s to substitute the declaration
2042 name; subsequent substitutions are a la printf. */
2044 static void
2045 v_warning_with_decl (decl, msgid, ap)
2046 tree decl;
2047 const char *msgid;
2048 va_list ap;
2050 if (count_error (1))
2052 report_error_function (DECL_SOURCE_FILE (decl));
2053 v_message_with_decl (decl, 1, msgid, ap);
2057 void
2058 warning_with_decl VPROTO((tree decl, const char *msgid, ...))
2060 #ifndef ANSI_PROTOTYPES
2061 tree decl;
2062 const char *msgid;
2063 #endif
2064 va_list ap;
2066 VA_START (ap, msgid);
2068 #ifndef ANSI_PROTOTYPES
2069 decl = va_arg (ap, tree);
2070 msgid = va_arg (ap, const char *);
2071 #endif
2073 v_warning_with_decl (decl, msgid, ap);
2074 va_end (ap);
2077 /* Report a warning at the line number of the insn INSN.
2078 This is used only when INSN is an `asm' with operands,
2079 and each ASM_OPERANDS records its own source file and line. */
2081 static void
2082 v_warning_for_asm (insn, msgid, ap)
2083 rtx insn;
2084 const char *msgid;
2085 va_list ap;
2087 if (count_error (1))
2089 char *file;
2090 int line;
2092 file_and_line_for_asm (insn, &file, &line);
2093 report_error_function (file);
2094 v_message_with_file_and_line (file, line, 1, msgid, ap);
2098 void
2099 warning_for_asm VPROTO((rtx insn, const char *msgid, ...))
2101 #ifndef ANSI_PROTOTYPES
2102 rtx insn;
2103 const char *msgid;
2104 #endif
2105 va_list ap;
2107 VA_START (ap, msgid);
2109 #ifndef ANSI_PROTOTYPES
2110 insn = va_arg (ap, rtx);
2111 msgid = va_arg (ap, const char *);
2112 #endif
2114 v_warning_for_asm (insn, msgid, ap);
2115 va_end (ap);
2118 /* Report a warning at the current line number. */
2120 static void
2121 vwarning (msgid, ap)
2122 const char *msgid;
2123 va_list ap;
2125 v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
2128 void
2129 warning VPROTO((const char *msgid, ...))
2131 #ifndef ANSI_PROTOTYPES
2132 const char *msgid;
2133 #endif
2134 va_list ap;
2136 VA_START (ap, msgid);
2138 #ifndef ANSI_PROTOTYPES
2139 msgid = va_arg (ap, const char *);
2140 #endif
2142 vwarning (msgid, ap);
2143 va_end (ap);
2146 /* These functions issue either warnings or errors depending on
2147 -pedantic-errors. */
2149 static void
2150 vpedwarn (msgid, ap)
2151 const char *msgid;
2152 va_list ap;
2154 if (flag_pedantic_errors)
2155 verror (msgid, ap);
2156 else
2157 vwarning (msgid, ap);
2160 void
2161 pedwarn VPROTO((const char *msgid, ...))
2163 #ifndef ANSI_PROTOTYPES
2164 const char *msgid;
2165 #endif
2166 va_list ap;
2168 VA_START (ap, msgid);
2170 #ifndef ANSI_PROTOTYPES
2171 msgid = va_arg (ap, const char *);
2172 #endif
2174 vpedwarn (msgid, ap);
2175 va_end (ap);
2178 static void
2179 v_pedwarn_with_decl (decl, msgid, ap)
2180 tree decl;
2181 const char *msgid;
2182 va_list ap;
2184 /* We don't want -pedantic-errors to cause the compilation to fail from
2185 "errors" in system header files. Sometimes fixincludes can't fix what's
2186 broken (eg: unsigned char bitfields - fixing it may change the alignment
2187 which will cause programs to mysteriously fail because the C library
2188 or kernel uses the original layout). There's no point in issuing a
2189 warning either, it's just unnecessary noise. */
2191 if (! DECL_IN_SYSTEM_HEADER (decl))
2193 if (flag_pedantic_errors)
2194 v_error_with_decl (decl, msgid, ap);
2195 else
2196 v_warning_with_decl (decl, msgid, ap);
2200 void
2201 pedwarn_with_decl VPROTO((tree decl, const char *msgid, ...))
2203 #ifndef ANSI_PROTOTYPES
2204 tree decl;
2205 const char *msgid;
2206 #endif
2207 va_list ap;
2209 VA_START (ap, msgid);
2211 #ifndef ANSI_PROTOTYPES
2212 decl = va_arg (ap, tree);
2213 msgid = va_arg (ap, const char *);
2214 #endif
2216 v_pedwarn_with_decl (decl, msgid, ap);
2217 va_end (ap);
2220 static void
2221 v_pedwarn_with_file_and_line (file, line, msgid, ap)
2222 const char *file;
2223 int line;
2224 const char *msgid;
2225 va_list ap;
2227 if (flag_pedantic_errors)
2228 v_error_with_file_and_line (file, line, msgid, ap);
2229 else
2230 v_warning_with_file_and_line (file, line, msgid, ap);
2233 void
2234 pedwarn_with_file_and_line VPROTO((const char *file, int line,
2235 const char *msgid, ...))
2237 #ifndef ANSI_PROTOTYPES
2238 const char *file;
2239 int line;
2240 const char *msgid;
2241 #endif
2242 va_list ap;
2244 VA_START (ap, msgid);
2246 #ifndef ANSI_PROTOTYPES
2247 file = va_arg (ap, const char *);
2248 line = va_arg (ap, int);
2249 msgid = va_arg (ap, const char *);
2250 #endif
2252 v_pedwarn_with_file_and_line (file, line, msgid, ap);
2253 va_end (ap);
2256 /* Apologize for not implementing some feature. */
2258 static void
2259 vsorry (msgid, ap)
2260 const char *msgid;
2261 va_list ap;
2263 sorrycount++;
2264 if (input_filename)
2265 fprintf (stderr, "%s:%d: ", input_filename, lineno);
2266 else
2267 fprintf (stderr, "%s: ", progname);
2268 notice ("sorry, not implemented: ");
2269 vnotice (stderr, msgid, ap);
2270 fputc ('\n', stderr);
2273 void
2274 sorry VPROTO((const char *msgid, ...))
2276 #ifndef ANSI_PROTOTYPES
2277 const char *msgid;
2278 #endif
2279 va_list ap;
2281 VA_START (ap, msgid);
2283 #ifndef ANSI_PROTOTYPES
2284 msgid = va_arg (ap, const char *);
2285 #endif
2287 vsorry (msgid, ap);
2288 va_end (ap);
2292 /* This calls abort and is used to avoid problems when abort if a macro.
2293 It is used when we need to pass the address of abort. */
2295 void
2296 do_abort ()
2298 abort ();
2301 /* When `malloc.c' is compiled with `rcheck' defined,
2302 it calls this function to report clobberage. */
2304 void
2305 botch (s)
2306 const char * s ATTRIBUTE_UNUSED;
2308 abort ();
2311 /* Return the logarithm of X, base 2, considering X unsigned,
2312 if X is a power of 2. Otherwise, returns -1.
2314 This should be used via the `exact_log2' macro. */
2317 exact_log2_wide (x)
2318 register unsigned HOST_WIDE_INT x;
2320 register int log = 0;
2321 /* Test for 0 or a power of 2. */
2322 if (x == 0 || x != (x & -x))
2323 return -1;
2324 while ((x >>= 1) != 0)
2325 log++;
2326 return log;
2329 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2330 If X is 0, return -1.
2332 This should be used via the floor_log2 macro. */
2335 floor_log2_wide (x)
2336 register unsigned HOST_WIDE_INT x;
2338 register int log = -1;
2339 while (x != 0)
2340 log++,
2341 x >>= 1;
2342 return log;
2345 static int float_handler_set;
2346 int float_handled;
2347 jmp_buf float_handler;
2349 /* Signals actually come here. */
2351 static void
2352 float_signal (signo)
2353 /* If this is missing, some compilers complain. */
2354 int signo ATTRIBUTE_UNUSED;
2356 if (float_handled == 0)
2357 abort ();
2358 #if defined (USG) || defined (hpux)
2359 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2360 #endif
2361 float_handled = 0;
2362 signal (SIGFPE, float_signal);
2363 longjmp (float_handler, 1);
2366 /* Specify where to longjmp to when a floating arithmetic error happens.
2367 If HANDLER is 0, it means don't handle the errors any more. */
2369 void
2370 set_float_handler (handler)
2371 jmp_buf handler;
2373 float_handled = (handler != 0);
2374 if (handler)
2375 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2377 if (float_handled && ! float_handler_set)
2379 signal (SIGFPE, float_signal);
2380 float_handler_set = 1;
2384 /* This is a wrapper function for code which might elicit an
2385 arithmetic exception. That code should be passed in as a function
2386 pointer FN, and one argument DATA. DATA is usually a struct which
2387 contains the real input and output for function FN. This function
2388 returns 0 (failure) if longjmp was called (i.e. an exception
2389 occured.) It returns 1 (success) otherwise. */
2392 do_float_handler (fn, data)
2393 void (*fn) PROTO ((PTR));
2394 PTR data;
2396 jmp_buf buf;
2398 if (setjmp (buf))
2400 /* We got here via longjmp() caused by an exception in function fn() */
2401 set_float_handler (NULL);
2402 return 0;
2405 set_float_handler (buf);
2406 (*fn)(data);
2407 set_float_handler (NULL);
2408 return 1;
2411 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2412 error happens, pushing the previous specification into OLD_HANDLER.
2413 Return an indication of whether there was a previous handler in effect. */
2416 push_float_handler (handler, old_handler)
2417 jmp_buf handler, old_handler;
2419 int was_handled = float_handled;
2421 float_handled = 1;
2422 if (was_handled)
2423 memcpy ((char *) old_handler, (char *) float_handler,
2424 sizeof (float_handler));
2426 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
2427 return was_handled;
2430 /* Restore the previous specification of whether and where to longjmp to
2431 when a floating arithmetic error happens. */
2433 void
2434 pop_float_handler (handled, handler)
2435 int handled;
2436 jmp_buf handler;
2438 float_handled = handled;
2439 if (handled)
2440 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2443 /* Handler for SIGPIPE. */
2445 static void
2446 pipe_closed (signo)
2447 /* If this is missing, some compilers complain. */
2448 int signo ATTRIBUTE_UNUSED;
2450 fatal ("output pipe has been closed");
2453 /* Strip off a legitimate source ending from the input string NAME of
2454 length LEN. Rather than having to know the names used by all of
2455 our front ends, we strip off an ending of a period followed by
2456 up to five characters. (Java uses ".class".) */
2458 void
2459 strip_off_ending (name, len)
2460 char *name;
2461 int len;
2463 int i;
2464 for (i = 2; i < 6 && len > i; i++)
2466 if (name[len - i] == '.')
2468 name[len - i] = '\0';
2469 break;
2474 /* Output a quoted string. */
2476 void
2477 output_quoted_string (asm_file, string)
2478 FILE *asm_file;
2479 const char *string;
2481 #ifdef OUTPUT_QUOTED_STRING
2482 OUTPUT_QUOTED_STRING (asm_file, string);
2483 #else
2484 char c;
2486 putc ('\"', asm_file);
2487 while ((c = *string++) != 0)
2489 if (c == '\"' || c == '\\')
2490 putc ('\\', asm_file);
2491 putc (c, asm_file);
2493 putc ('\"', asm_file);
2494 #endif
2497 /* Output a file name in the form wanted by System V. */
2499 void
2500 output_file_directive (asm_file, input_name)
2501 FILE *asm_file;
2502 const char *input_name;
2504 int len = strlen (input_name);
2505 const char *na = input_name + len;
2507 /* NA gets INPUT_NAME sans directory names. */
2508 while (na > input_name)
2510 if (na[-1] == '/')
2511 break;
2512 #ifdef DIR_SEPARATOR
2513 if (na[-1] == DIR_SEPARATOR)
2514 break;
2515 #endif
2516 na--;
2519 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2520 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2521 #else
2522 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2523 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2524 #else
2525 fprintf (asm_file, "\t.file\t");
2526 output_quoted_string (asm_file, na);
2527 fputc ('\n', asm_file);
2528 #endif
2529 #endif
2532 #ifdef ASM_IDENTIFY_LANGUAGE
2533 /* Routine to build language identifier for object file. */
2534 static void
2535 output_lang_identify (asm_out_file)
2536 FILE *asm_out_file;
2538 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2539 char *s = (char *) alloca (len);
2540 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2541 ASM_OUTPUT_LABEL (asm_out_file, s);
2543 #endif
2545 /* Routine to open a dump file. */
2546 static void
2547 open_dump_file (suffix, function_name)
2548 const char *suffix;
2549 const char *function_name;
2551 char *dumpname;
2553 TIMEVAR
2554 (dump_time,
2556 dumpname = concat (dump_base_name, suffix, NULL);
2558 if (rtl_dump_file != NULL)
2559 fclose (rtl_dump_file);
2561 rtl_dump_file = fopen (dumpname, "a");
2563 if (rtl_dump_file == NULL)
2564 pfatal_with_name (dumpname);
2566 free (dumpname);
2568 if (function_name)
2569 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2572 return;
2575 /* Routine to close a dump file. */
2576 static void
2577 close_dump_file (func, insns)
2578 void (*func) PROTO ((FILE *, rtx));
2579 rtx insns;
2581 TIMEVAR
2582 (dump_time,
2584 if (func)
2585 func (rtl_dump_file, insns);
2587 fflush (rtl_dump_file);
2588 fclose (rtl_dump_file);
2590 rtl_dump_file = NULL;
2593 return;
2596 /* Routine to dump rtl into a file. */
2597 static void
2598 dump_rtl (suffix, decl, func, insns)
2599 const char *suffix;
2600 tree decl;
2601 void (*func) PROTO ((FILE *, rtx));
2602 rtx insns;
2604 open_dump_file (suffix, decl_printable_name (decl, 2));
2605 close_dump_file (func, insns);
2608 /* Routine to empty a dump file. */
2609 static void
2610 clean_dump_file (suffix)
2611 const char *suffix;
2613 char * const dumpname = concat (dump_base_name, suffix, NULL);
2615 rtl_dump_file = fopen (dumpname, "w");
2617 if (rtl_dump_file == NULL)
2618 pfatal_with_name (dumpname);
2620 free (dumpname);
2622 fclose (rtl_dump_file);
2623 rtl_dump_file = NULL;
2625 return;
2628 /* Do any final processing required for the declarations in VEC, of
2629 which there are LEN. We write out inline functions and variables
2630 that have been deferred until this point, but which are required.
2631 Returns non-zero if anything was put out. */
2633 wrapup_global_declarations (vec, len)
2634 tree *vec;
2635 int len;
2637 tree decl;
2638 int i;
2639 int reconsider;
2640 int output_something = 0;
2642 for (i = 0; i < len; i++)
2644 decl = vec[i];
2646 /* We're not deferring this any longer. */
2647 DECL_DEFER_OUTPUT (decl) = 0;
2649 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2650 && incomplete_decl_finalize_hook != 0)
2651 (*incomplete_decl_finalize_hook) (decl);
2654 /* Now emit any global variables or functions that we have been
2655 putting off. We need to loop in case one of the things emitted
2656 here references another one which comes earlier in the list. */
2659 reconsider = 0;
2660 for (i = 0; i < len; i++)
2662 decl = vec[i];
2664 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2665 continue;
2667 /* Don't write out static consts, unless we still need them.
2669 We also keep static consts if not optimizing (for debugging),
2670 unless the user specified -fno-keep-static-consts.
2671 ??? They might be better written into the debug information.
2672 This is possible when using DWARF.
2674 A language processor that wants static constants to be always
2675 written out (even if it is not used) is responsible for
2676 calling rest_of_decl_compilation itself. E.g. the C front-end
2677 calls rest_of_decl_compilation from finish_decl.
2678 One motivation for this is that is conventional in some
2679 environments to write things like:
2680 static const char rcsid[] = "... version string ...";
2681 intending to force the string to be in the executable.
2683 A language processor that would prefer to have unneeded
2684 static constants "optimized away" would just defer writing
2685 them out until here. E.g. C++ does this, because static
2686 constants are often defined in header files.
2688 ??? A tempting alternative (for both C and C++) would be
2689 to force a constant to be written if and only if it is
2690 defined in a main file, as opposed to an include file. */
2692 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2693 && (! TREE_READONLY (decl)
2694 || TREE_PUBLIC (decl)
2695 || (!optimize && flag_keep_static_consts)
2696 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2698 reconsider = 1;
2699 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2702 if (TREE_CODE (decl) == FUNCTION_DECL
2703 && DECL_INITIAL (decl) != 0
2704 && DECL_SAVED_INSNS (decl) != 0
2705 && (flag_keep_inline_functions
2706 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2707 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2709 reconsider = 1;
2710 temporary_allocation ();
2711 output_inline_function (decl);
2712 permanent_allocation (1);
2716 if (reconsider)
2717 output_something = 1;
2719 while (reconsider);
2721 return output_something;
2724 /* Issue appropriate warnings for the global declarations in VEC (of
2725 which there are LEN). Output debugging information for them. */
2726 void
2727 check_global_declarations (vec, len)
2728 tree *vec;
2729 int len;
2731 tree decl;
2732 int i;
2734 for (i = 0; i < len; i++)
2736 decl = vec[i];
2738 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2739 && ! TREE_ASM_WRITTEN (decl))
2740 /* Cancel the RTL for this decl so that, if debugging info
2741 output for global variables is still to come,
2742 this one will be omitted. */
2743 DECL_RTL (decl) = NULL;
2745 /* Warn about any function
2746 declared static but not defined.
2747 We don't warn about variables,
2748 because many programs have static variables
2749 that exist only to get some text into the object file. */
2750 if (TREE_CODE (decl) == FUNCTION_DECL
2751 && (warn_unused
2752 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2753 && DECL_INITIAL (decl) == 0
2754 && DECL_EXTERNAL (decl)
2755 && ! DECL_ARTIFICIAL (decl)
2756 && ! TREE_PUBLIC (decl))
2758 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2759 pedwarn_with_decl (decl,
2760 "`%s' used but never defined");
2761 else
2762 warning_with_decl (decl,
2763 "`%s' declared `static' but never defined");
2764 /* This symbol is effectively an "extern" declaration now. */
2765 TREE_PUBLIC (decl) = 1;
2766 assemble_external (decl);
2769 /* Warn about static fns or vars defined but not used,
2770 but not about inline functions or static consts
2771 since defining those in header files is normal practice. */
2772 if (warn_unused
2773 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2774 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2775 && ! DECL_IN_SYSTEM_HEADER (decl)
2776 && ! DECL_EXTERNAL (decl)
2777 && ! TREE_PUBLIC (decl)
2778 && ! TREE_USED (decl)
2779 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2780 /* The TREE_USED bit for file-scope decls
2781 is kept in the identifier, to handle multiple
2782 external decls in different scopes. */
2783 && ! TREE_USED (DECL_NAME (decl)))
2784 warning_with_decl (decl, "`%s' defined but not used");
2786 #ifdef SDB_DEBUGGING_INFO
2787 /* The COFF linker can move initialized global vars to the end.
2788 And that can screw up the symbol ordering.
2789 By putting the symbols in that order to begin with,
2790 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2791 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2792 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2793 && ! DECL_EXTERNAL (decl)
2794 && DECL_RTL (decl) != 0)
2795 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2797 /* Output COFF information for non-global
2798 file-scope initialized variables. */
2799 if (write_symbols == SDB_DEBUG
2800 && TREE_CODE (decl) == VAR_DECL
2801 && DECL_INITIAL (decl)
2802 && ! DECL_EXTERNAL (decl)
2803 && DECL_RTL (decl) != 0
2804 && GET_CODE (DECL_RTL (decl)) == MEM)
2805 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2806 #endif /* SDB_DEBUGGING_INFO */
2807 #ifdef DWARF_DEBUGGING_INFO
2808 /* Output DWARF information for file-scope tentative data object
2809 declarations, file-scope (extern) function declarations (which
2810 had no corresponding body) and file-scope tagged type declarations
2811 and definitions which have not yet been forced out. */
2813 if (write_symbols == DWARF_DEBUG
2814 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2815 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2816 #endif
2817 #ifdef DWARF2_DEBUGGING_INFO
2818 /* Output DWARF2 information for file-scope tentative data object
2819 declarations, file-scope (extern) function declarations (which
2820 had no corresponding body) and file-scope tagged type declarations
2821 and definitions which have not yet been forced out. */
2823 if (write_symbols == DWARF2_DEBUG
2824 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2825 TIMEVAR (symout_time, dwarf2out_decl (decl));
2826 #endif
2830 /* Compile an entire file of output from cpp, named NAME.
2831 Write a file of assembly output and various debugging dumps. */
2833 static void
2834 compile_file (name)
2835 char *name;
2837 tree globals;
2838 int start_time;
2840 int name_specified = name != 0;
2842 if (dump_base_name == 0)
2843 dump_base_name = name ? name : "gccdump";
2845 parse_time = 0;
2846 varconst_time = 0;
2847 integration_time = 0;
2848 jump_time = 0;
2849 cse_time = 0;
2850 gcse_time = 0;
2851 loop_time = 0;
2852 cse2_time = 0;
2853 branch_prob_time = 0;
2854 flow_time = 0;
2855 combine_time = 0;
2856 regmove_time = 0;
2857 sched_time = 0;
2858 local_alloc_time = 0;
2859 global_alloc_time = 0;
2860 flow2_time = 0;
2861 peephole2_time = 0;
2862 sched2_time = 0;
2863 dbr_sched_time = 0;
2864 shorten_branch_time = 0;
2865 stack_reg_time = 0;
2866 final_time = 0;
2867 symout_time = 0;
2868 dump_time = 0;
2870 /* Initialize data in various passes. */
2872 init_obstacks ();
2873 init_tree_codes ();
2874 name = init_parse (name);
2875 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2876 || debug_info_level == DINFO_LEVEL_VERBOSE
2877 || flag_test_coverage
2878 || warn_notreached);
2879 init_regs ();
2880 init_decl_processing ();
2881 init_optabs ();
2882 init_stmt ();
2883 init_eh ();
2884 init_loop ();
2885 init_reload ();
2886 init_alias_once ();
2887 init_function_once ();
2888 init_stor_layout_once ();
2889 init_varasm_once ();
2891 /* The following initialization functions need to generate rtl, so
2892 provide a dummy function context for them. */
2893 init_dummy_function_start ();
2894 init_expmed ();
2895 init_expr_once ();
2896 if (flag_caller_saves)
2897 init_caller_save ();
2898 expand_dummy_function_end ();
2900 /* If auxiliary info generation is desired, open the output file.
2901 This goes in the same directory as the source file--unlike
2902 all the other output files. */
2903 if (flag_gen_aux_info)
2905 aux_info_file = fopen (aux_info_file_name, "w");
2906 if (aux_info_file == 0)
2907 pfatal_with_name (aux_info_file_name);
2910 /* Clear the dump files. */
2911 if (rtl_dump)
2912 clean_dump_file (".00.rtl");
2913 if (jump_opt_dump)
2915 clean_dump_file (".01.jump");
2916 if (graph_dump_format != no_graph)
2917 clean_graph_dump_file (dump_base_name, ".01.jump");
2919 if (cse_dump)
2921 clean_dump_file (".02.cse");
2922 if (graph_dump_format != no_graph)
2923 clean_graph_dump_file (dump_base_name, ".02.cse");
2925 if (addressof_dump)
2927 clean_dump_file (".03.addressof");
2928 if (graph_dump_format != no_graph)
2929 clean_graph_dump_file (dump_base_name, ".03.addressof");
2931 if (gcse_dump)
2933 clean_dump_file (".04.gcse");
2934 if (graph_dump_format != no_graph)
2935 clean_graph_dump_file (dump_base_name, ".04.gcse");
2937 if (loop_dump)
2939 clean_dump_file (".05.loop");
2940 if (graph_dump_format != no_graph)
2941 clean_graph_dump_file (dump_base_name, ".05.loop");
2943 if (cse2_dump)
2945 clean_dump_file (".06.cse2");
2946 if (graph_dump_format != no_graph)
2947 clean_graph_dump_file (dump_base_name, ".06.cse2");
2949 if (branch_prob_dump)
2951 clean_dump_file (".07.bp");
2952 if (graph_dump_format != no_graph)
2953 clean_graph_dump_file (dump_base_name, ".07.bp");
2955 if (flow_dump)
2957 clean_dump_file (".08.flow");
2958 if (graph_dump_format != no_graph)
2959 clean_graph_dump_file (dump_base_name, ".08.flow");
2961 if (combine_dump)
2963 clean_dump_file (".09.combine");
2964 if (graph_dump_format != no_graph)
2965 clean_graph_dump_file (dump_base_name, ".09.combine");
2967 if (regmove_dump)
2969 clean_dump_file (".10.regmove");
2970 if (graph_dump_format != no_graph)
2971 clean_graph_dump_file (dump_base_name, ".10.regmove");
2973 #ifdef INSN_SCHEDULING
2974 if (sched_dump)
2976 clean_dump_file (".11.sched");
2977 if (graph_dump_format != no_graph)
2978 clean_graph_dump_file (dump_base_name, ".11.sched");
2980 #endif
2981 if (local_reg_dump)
2983 clean_dump_file (".12.lreg");
2984 if (graph_dump_format != no_graph)
2985 clean_graph_dump_file (dump_base_name, ".12.lreg");
2987 if (global_reg_dump)
2989 clean_dump_file (".13.greg");
2990 if (graph_dump_format != no_graph)
2991 clean_graph_dump_file (dump_base_name, ".13.greg");
2993 if (flow2_dump)
2995 clean_dump_file (".14.flow2");
2996 if (graph_dump_format != no_graph)
2997 clean_graph_dump_file (dump_base_name, ".14.flow2");
2999 #ifdef HAVE_peephole2
3000 if (peephole2_dump)
3002 clean_dump_file (".15.peephole2");
3003 if (graph_dump_format != no_graph)
3004 clean_graph_dump_file (dump_base_name, ".15.peephole2");
3006 #endif
3007 #ifdef INSN_SCHEDULING
3008 if (sched2_dump)
3010 clean_dump_file (".16.sched2");
3011 if (graph_dump_format != no_graph)
3012 clean_graph_dump_file (dump_base_name, ".16.sched2");
3014 #endif
3015 if (jump2_opt_dump)
3017 clean_dump_file (".17.jump2");
3018 if (graph_dump_format != no_graph)
3019 clean_graph_dump_file (dump_base_name, ".17.jump2");
3021 #ifdef MACHINE_DEPENDENT_REORG
3022 if (mach_dep_reorg_dump)
3024 clean_dump_file (".18.mach");
3025 if (graph_dump_format != no_graph)
3026 clean_graph_dump_file (dump_base_name, ".18.mach");
3028 #endif
3029 #ifdef DELAY_SLOTS
3030 if (dbr_sched_dump)
3032 clean_dump_file (".19.dbr");
3033 if (graph_dump_format != no_graph)
3034 clean_graph_dump_file (dump_base_name, ".19.dbr");
3036 #endif
3037 #ifdef STACK_REGS
3038 if (stack_reg_dump)
3040 clean_dump_file (".20.stack");
3041 if (graph_dump_format != no_graph)
3042 clean_graph_dump_file (dump_base_name, ".20.stack");
3044 #endif
3046 /* Open assembler code output file. */
3048 if (flag_syntax_only)
3049 asm_out_file = NULL;
3050 else
3052 if (! name_specified && asm_file_name == 0)
3053 asm_out_file = stdout;
3054 else
3056 int len = strlen (dump_base_name);
3057 register char *dumpname = (char *) xmalloc (len + 6);
3058 strcpy (dumpname, dump_base_name);
3059 strip_off_ending (dumpname, len);
3060 strcat (dumpname, ".s");
3061 if (asm_file_name == 0)
3062 asm_file_name = xstrdup (dumpname);
3063 if (!strcmp (asm_file_name, "-"))
3064 asm_out_file = stdout;
3065 else
3066 asm_out_file = fopen (asm_file_name, "w");
3067 if (asm_out_file == 0)
3068 pfatal_with_name (asm_file_name);
3071 #ifdef IO_BUFFER_SIZE
3072 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
3073 _IOFBF, IO_BUFFER_SIZE);
3074 #endif
3077 if (ggc_p)
3078 name = ggc_alloc_string (name, strlen (name));
3079 input_filename = name;
3081 /* Put an entry on the input file stack for the main input file. */
3082 input_file_stack
3083 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
3084 input_file_stack->next = 0;
3085 input_file_stack->name = input_filename;
3087 /* Perform language-specific initialization.
3088 This may set main_input_filename. */
3089 lang_init ();
3091 /* If the input doesn't start with a #line, use the input name
3092 as the official input file name. */
3093 if (main_input_filename == 0)
3094 main_input_filename = name;
3096 if (flag_syntax_only)
3098 write_symbols = NO_DEBUG;
3099 profile_flag = 0;
3100 profile_block_flag = 0;
3102 else
3104 ASM_FILE_START (asm_out_file);
3106 #ifdef ASM_COMMENT_START
3107 if (flag_verbose_asm)
3109 /* Print the list of options in effect. */
3110 print_version (asm_out_file, ASM_COMMENT_START);
3111 print_switch_values (asm_out_file, 0, MAX_LINE,
3112 ASM_COMMENT_START, " ", "\n");
3113 /* Add a blank line here so it appears in assembler output but not
3114 screen output. */
3115 fprintf (asm_out_file, "\n");
3117 #endif
3119 /* Output something to inform GDB that this compilation was by GCC. */
3120 #ifndef ASM_IDENTIFY_GCC
3121 fprintf (asm_out_file, "gcc2_compiled.:\n");
3122 #else
3123 ASM_IDENTIFY_GCC (asm_out_file);
3124 #endif
3126 /* Output something to identify which front-end produced this file. */
3127 #ifdef ASM_IDENTIFY_LANGUAGE
3128 ASM_IDENTIFY_LANGUAGE (asm_out_file);
3129 #endif
3130 } /* ! flag_syntax_only */
3132 #ifndef ASM_OUTPUT_SECTION_NAME
3133 if (flag_function_sections)
3135 warning ("-ffunction-sections not supported for this target.");
3136 flag_function_sections = 0;
3138 if (flag_data_sections)
3140 warning ("-fdata-sections not supported for this target.");
3141 flag_data_sections = 0;
3143 #endif
3145 if (flag_function_sections
3146 && (profile_flag || profile_block_flag))
3148 warning ("-ffunction-sections disabled; it makes profiling impossible.");
3149 flag_function_sections = 0;
3152 #ifndef OBJECT_FORMAT_ELF
3153 if (flag_function_sections && write_symbols != NO_DEBUG)
3154 warning ("-ffunction-sections may affect debugging on some targets.");
3155 #endif
3157 /* ??? Note: There used to be a conditional here
3158 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
3159 This was to guarantee separation between gcc_compiled. and
3160 the first function, for the sake of dbx on Suns.
3161 However, having the extra zero here confused the Emacs
3162 code for unexec, and might confuse other programs too.
3163 Therefore, I took out that change.
3164 In future versions we should find another way to solve
3165 that dbx problem. -- rms, 23 May 93. */
3167 /* Don't let the first function fall at the same address
3168 as gcc_compiled., if profiling. */
3169 if (profile_flag || profile_block_flag)
3171 /* It's best if we can write a nop here since some
3172 assemblers don't tolerate zeros in the text section. */
3173 output_asm_insn (get_insn_template (CODE_FOR_nop, NULL), NULL_PTR);
3176 /* If dbx symbol table desired, initialize writing it
3177 and output the predefined types. */
3178 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3179 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3180 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
3181 getdecls ()));
3182 #endif
3183 #ifdef SDB_DEBUGGING_INFO
3184 if (write_symbols == SDB_DEBUG)
3185 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
3186 getdecls ()));
3187 #endif
3188 #ifdef DWARF_DEBUGGING_INFO
3189 if (write_symbols == DWARF_DEBUG)
3190 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
3191 #endif
3192 #ifdef DWARF2_UNWIND_INFO
3193 if (dwarf2out_do_frame ())
3194 dwarf2out_frame_init ();
3195 #endif
3196 #ifdef DWARF2_DEBUGGING_INFO
3197 if (write_symbols == DWARF2_DEBUG)
3198 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
3199 #endif
3201 /* Initialize yet another pass. */
3203 init_final (main_input_filename);
3204 init_branch_prob (dump_base_name);
3206 start_time = get_run_time ();
3208 /* Call the parser, which parses the entire file
3209 (calling rest_of_compilation for each function). */
3211 if (yyparse () != 0)
3213 if (errorcount == 0)
3214 notice ("Errors detected in input file (your bison.simple is out of date)\n");
3216 /* In case there were missing closebraces,
3217 get us back to the global binding level. */
3218 while (! global_bindings_p ())
3219 poplevel (0, 0, 0);
3222 /* Compilation is now finished except for writing
3223 what's left of the symbol table output. */
3225 parse_time += get_run_time () - start_time;
3227 parse_time -= integration_time;
3228 parse_time -= varconst_time;
3230 if (flag_syntax_only)
3231 goto finish_syntax;
3233 globals = getdecls ();
3235 /* Really define vars that have had only a tentative definition.
3236 Really output inline functions that must actually be callable
3237 and have not been output so far. */
3240 int len = list_length (globals);
3241 tree *vec = (tree *) alloca (sizeof (tree) * len);
3242 int i;
3243 tree decl;
3245 /* Process the decls in reverse order--earliest first.
3246 Put them into VEC from back to front, then take out from front. */
3248 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
3249 vec[len - i - 1] = decl;
3251 wrapup_global_declarations (vec, len);
3253 /* This must occur after the loop to output deferred functions. Else
3254 the profiler initializer would not be emitted if all the functions
3255 in this compilation unit were deferred.
3257 output_func_start_profiler can not cause any additional functions or
3258 data to need to be output, so it need not be in the deferred function
3259 loop above. */
3260 output_func_start_profiler ();
3262 /* Now that all possible functions have been output, we can dump
3263 the exception table. */
3265 output_exception_table ();
3267 check_global_declarations (vec, len);
3270 /* Write out any pending weak symbol declarations. */
3272 weak_finish ();
3274 /* Do dbx symbols */
3275 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3276 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3277 TIMEVAR (symout_time,
3279 dbxout_finish (asm_out_file, main_input_filename);
3281 #endif
3283 #ifdef DWARF_DEBUGGING_INFO
3284 if (write_symbols == DWARF_DEBUG)
3285 TIMEVAR (symout_time,
3287 dwarfout_finish ();
3289 #endif
3291 #ifdef DWARF2_UNWIND_INFO
3292 if (dwarf2out_do_frame ())
3293 dwarf2out_frame_finish ();
3294 #endif
3296 #ifdef DWARF2_DEBUGGING_INFO
3297 if (write_symbols == DWARF2_DEBUG)
3298 TIMEVAR (symout_time,
3300 dwarf2out_finish ();
3302 #endif
3304 /* Output some stuff at end of file if nec. */
3306 end_final (dump_base_name);
3308 if (branch_prob_dump)
3309 open_dump_file (".07.bp", NULL);
3311 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
3313 if (branch_prob_dump)
3314 close_dump_file (NULL, NULL_RTX);
3316 #ifdef ASM_FILE_END
3317 ASM_FILE_END (asm_out_file);
3318 #endif
3321 /* Language-specific end of compilation actions. */
3322 finish_syntax:
3323 lang_finish ();
3325 /* Close the dump files. */
3327 if (flag_gen_aux_info)
3329 fclose (aux_info_file);
3330 if (errorcount)
3331 unlink (aux_info_file_name);
3334 if (combine_dump)
3336 open_dump_file (".09.combine", NULL);
3337 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
3338 close_dump_file (NULL, NULL_RTX);
3341 /* Close non-debugging input and output files. Take special care to note
3342 whether fclose returns an error, since the pages might still be on the
3343 buffer chain while the file is open. */
3345 finish_parse ();
3347 if (! flag_syntax_only
3348 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
3349 fatal_io_error (asm_file_name);
3351 /* Do whatever is necessary to finish printing the graphs. */
3352 if (graph_dump_format != no_graph)
3354 if (jump_opt_dump)
3355 finish_graph_dump_file (dump_base_name, ".01.jump");
3356 if (cse_dump)
3357 finish_graph_dump_file (dump_base_name, ".02.cse");
3358 if (addressof_dump)
3359 finish_graph_dump_file (dump_base_name, ".03.addressof");
3360 if (gcse_dump)
3361 finish_graph_dump_file (dump_base_name, ".04.gcse");
3362 if (loop_dump)
3363 finish_graph_dump_file (dump_base_name, ".05.loop");
3364 if (cse2_dump)
3365 finish_graph_dump_file (dump_base_name, ".06.cse2");
3366 if (branch_prob_dump)
3367 finish_graph_dump_file (dump_base_name, ".07.bp");
3368 if (flow_dump)
3369 finish_graph_dump_file (dump_base_name, ".08.flow");
3370 if (combine_dump)
3371 finish_graph_dump_file (dump_base_name, ".09.combine");
3372 if (regmove_dump)
3373 finish_graph_dump_file (dump_base_name, ".10.regmove");
3374 #ifdef INSN_SCHEDULING
3375 if (sched_dump)
3376 finish_graph_dump_file (dump_base_name, ".11.sched");
3377 #endif
3378 if (local_reg_dump)
3379 finish_graph_dump_file (dump_base_name, ".12.lreg");
3380 if (global_reg_dump)
3381 finish_graph_dump_file (dump_base_name, ".13.greg");
3382 if (flow2_dump)
3383 finish_graph_dump_file (dump_base_name, ".14.flow2");
3384 #ifdef HAVE_peephole2
3385 if (flow2_dump)
3386 finish_graph_dump_file (dump_base_name, ".15.peephole2");
3387 #endif
3388 #ifdef INSN_SCHEDULING
3389 if (sched2_dump)
3390 finish_graph_dump_file (dump_base_name, ".16.sched2");
3391 #endif
3392 if (jump2_opt_dump)
3393 finish_graph_dump_file (dump_base_name, ".17.jump2");
3394 #ifdef MACHINE_DEPENDENT_REORG
3395 if (mach_dep_reorg_dump)
3396 finish_graph_dump_file (dump_base_name, ".18.mach");
3397 #endif
3398 #ifdef DELAY_SLOTS
3399 if (dbr_sched_dump)
3400 finish_graph_dump_file (dump_base_name, ".19.dbr");
3401 #endif
3402 #ifdef STACK_REGS
3403 if (stack_reg_dump)
3404 finish_graph_dump_file (dump_base_name, ".20.stack");
3405 #endif
3408 /* Free up memory for the benefit of leak detectors. */
3409 free_reg_info ();
3411 /* Print the times. */
3413 if (! quiet_flag)
3415 all_time = get_run_time ();
3417 fprintf (stderr,"\n");
3419 print_time ("parse", parse_time);
3420 print_time ("integration", integration_time);
3421 print_time ("jump", jump_time);
3422 print_time ("cse", cse_time);
3423 print_time ("gcse", gcse_time);
3424 print_time ("loop", loop_time);
3425 print_time ("cse2", cse2_time);
3426 print_time ("branch-prob", branch_prob_time);
3427 print_time ("flow", flow_time);
3428 print_time ("combine", combine_time);
3429 print_time ("regmove", regmove_time);
3430 #ifdef INSN_SCHEDULING
3431 print_time ("sched", sched_time);
3432 #endif
3433 print_time ("local-alloc", local_alloc_time);
3434 print_time ("global-alloc", global_alloc_time);
3435 print_time ("flow2", flow2_time);
3436 #ifdef HAVE_peephole2
3437 print_time ("peephole2", peephole2_time);
3438 #endif
3439 #ifdef INSN_SCHEDULING
3440 print_time ("sched2", sched2_time);
3441 #endif
3442 #ifdef DELAY_SLOTS
3443 print_time ("dbranch", dbr_sched_time);
3444 #endif
3445 print_time ("shorten-branch", shorten_branch_time);
3446 #ifdef STACK_REGS
3447 print_time ("stack-reg", stack_reg_time);
3448 #endif
3449 print_time ("final", final_time);
3450 print_time ("varconst", varconst_time);
3451 print_time ("symout", symout_time);
3452 print_time ("dump", dump_time);
3453 if (ggc_p)
3454 print_time ("gc", gc_time);
3458 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3459 and TYPE_DECL nodes.
3461 This does nothing for local (non-static) variables, unless the
3462 variable is a register variable with an ASMSPEC. In that case, or
3463 if the variable is not an automatice, it sets up the RTL and
3464 outputs any assembler code (label definition, storage allocation
3465 and initialization).
3467 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3468 the assembler symbol name to be used. TOP_LEVEL is nonzero
3469 if this declaration is not within a function. */
3471 void
3472 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
3473 tree decl;
3474 const char *asmspec;
3475 int top_level;
3476 int at_end;
3478 /* Declarations of variables, and of functions defined elsewhere. */
3480 /* The most obvious approach, to put an #ifndef around where
3481 this macro is used, doesn't work since it's inside a macro call. */
3482 #ifndef ASM_FINISH_DECLARE_OBJECT
3483 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3484 #endif
3486 /* Forward declarations for nested functions are not "external",
3487 but we need to treat them as if they were. */
3488 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
3489 || TREE_CODE (decl) == FUNCTION_DECL)
3490 TIMEVAR (varconst_time,
3492 make_decl_rtl (decl, asmspec, top_level);
3493 /* Initialized extern variable exists to be replaced
3494 with its value, or represents something that will be
3495 output in another file. */
3496 if (! (TREE_CODE (decl) == VAR_DECL
3497 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
3498 && DECL_INITIAL (decl) != 0
3499 && DECL_INITIAL (decl) != error_mark_node))
3500 /* Don't output anything
3501 when a tentative file-scope definition is seen.
3502 But at end of compilation, do output code for them. */
3503 if (! (! at_end && top_level
3504 && (DECL_INITIAL (decl) == 0
3505 || DECL_INITIAL (decl) == error_mark_node)))
3506 assemble_variable (decl, top_level, at_end, 0);
3507 if (decl == last_assemble_variable_decl)
3509 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
3510 top_level, at_end);
3513 else if (DECL_REGISTER (decl) && asmspec != 0)
3515 if (decode_reg_name (asmspec) >= 0)
3517 DECL_RTL (decl) = 0;
3518 make_decl_rtl (decl, asmspec, top_level);
3520 else
3521 error ("invalid register name `%s' for register variable", asmspec);
3523 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3524 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3525 && TREE_CODE (decl) == TYPE_DECL)
3526 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
3527 #endif
3528 #ifdef SDB_DEBUGGING_INFO
3529 else if (write_symbols == SDB_DEBUG && top_level
3530 && TREE_CODE (decl) == TYPE_DECL)
3531 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
3532 #endif
3535 /* Called after finishing a record, union or enumeral type. */
3537 void
3538 rest_of_type_compilation (type, toplev)
3539 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3540 tree type;
3541 int toplev;
3542 #else
3543 tree type ATTRIBUTE_UNUSED;
3544 int toplev ATTRIBUTE_UNUSED;
3545 #endif
3547 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3548 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3549 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3550 #endif
3551 #ifdef SDB_DEBUGGING_INFO
3552 if (write_symbols == SDB_DEBUG)
3553 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3554 #endif
3557 /* This is called from finish_function (within yyparse)
3558 after each top-level definition is parsed.
3559 It is supposed to compile that function or variable
3560 and output the assembler code for it.
3561 After we return, the tree storage is freed. */
3563 void
3564 rest_of_compilation (decl)
3565 tree decl;
3567 register rtx insns;
3568 int start_time = get_run_time ();
3569 int tem;
3570 int failure = 0;
3571 int rebuild_label_notes_after_reload;
3573 /* First, remove any notes we don't need. That will make iterating
3574 over the instruction sequence faster, and allow the garbage
3575 collector to reclaim the memory used by the notes. */
3576 remove_unncessary_notes ();
3578 /* If we are reconsidering an inline function
3579 at the end of compilation, skip the stuff for making it inline. */
3581 if (DECL_SAVED_INSNS (decl) == 0)
3583 int inlinable = 0;
3584 tree parent;
3585 const char *lose;
3587 /* If this is nested inside an inlined external function, pretend
3588 it was only declared. Since we cannot inline such functions,
3589 generating code for this one is not only not necessary but will
3590 confuse some debugging output writers. */
3591 for (parent = DECL_CONTEXT (current_function_decl);
3592 parent != 0; parent = DECL_CONTEXT (parent))
3593 if (TREE_CODE (parent) == FUNCTION_DECL
3594 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
3596 DECL_INITIAL (decl) = 0;
3597 goto exit_rest_of_compilation;
3600 /* If requested, consider whether to make this function inline. */
3601 if (DECL_INLINE (decl) || flag_inline_functions)
3602 TIMEVAR (integration_time,
3604 lose = function_cannot_inline_p (decl);
3605 if (lose || ! optimize)
3607 if (warn_inline && DECL_INLINE (decl))
3608 warning_with_decl (decl, lose);
3609 DECL_ABSTRACT_ORIGIN (decl) = 0;
3610 /* Don't really compile an extern inline function.
3611 If we can't make it inline, pretend
3612 it was only declared. */
3613 if (DECL_EXTERNAL (decl))
3615 DECL_INITIAL (decl) = 0;
3616 goto exit_rest_of_compilation;
3619 else
3620 /* ??? Note that this has the effect of making it look
3621 like "inline" was specified for a function if we choose
3622 to inline it. This isn't quite right, but it's
3623 probably not worth the trouble to fix. */
3624 inlinable = DECL_INLINE (decl) = 1;
3627 insns = get_insns ();
3629 /* Dump the rtl code if we are dumping rtl. */
3631 if (rtl_dump)
3633 open_dump_file (".00.rtl", decl_printable_name (decl, 2));
3635 if (DECL_SAVED_INSNS (decl))
3636 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3638 close_dump_file (print_rtl, insns);
3641 /* If function is inline, and we don't yet know whether to
3642 compile it by itself, defer decision till end of compilation.
3643 finish_compilation will call rest_of_compilation again
3644 for those functions that need to be output. Also defer those
3645 functions that we are supposed to defer. */
3647 if (inlinable)
3648 DECL_DEFER_OUTPUT (decl) = 1;
3650 if (DECL_DEFER_OUTPUT (decl)
3651 || (DECL_INLINE (decl)
3652 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3653 && ! flag_keep_inline_functions)
3654 || DECL_EXTERNAL (decl))))
3656 DECL_DEFER_OUTPUT (decl) = 1;
3658 /* If -Wreturn-type, we have to do a bit of compilation.
3659 However, if we just fall through we will call
3660 save_for_inline_copying() which results in excessive
3661 memory use. Instead, we just want to call
3662 jump_optimize() to figure out whether or not we can fall
3663 off the end of the function; we do the minimum amount of
3664 work necessary to make that safe. And, we set optimize
3665 to zero to keep jump_optimize from working too hard. */
3666 if (warn_return_type)
3668 int saved_optimize = optimize;
3669 optimize = 0;
3670 find_exception_handler_labels ();
3671 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3672 !JUMP_AFTER_REGSCAN);
3673 optimize = saved_optimize;
3676 #ifdef DWARF_DEBUGGING_INFO
3677 /* Generate the DWARF info for the "abstract" instance
3678 of a function which we may later generate inlined and/or
3679 out-of-line instances of. */
3680 if (write_symbols == DWARF_DEBUG)
3682 set_decl_abstract_flags (decl, 1);
3683 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3684 set_decl_abstract_flags (decl, 0);
3686 #endif
3687 #ifdef DWARF2_DEBUGGING_INFO
3688 /* Generate the DWARF2 info for the "abstract" instance
3689 of a function which we may later generate inlined and/or
3690 out-of-line instances of. */
3691 if (write_symbols == DWARF2_DEBUG)
3693 set_decl_abstract_flags (decl, 1);
3694 TIMEVAR (symout_time, dwarf2out_decl (decl));
3695 set_decl_abstract_flags (decl, 0);
3697 #endif
3698 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3699 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
3700 goto exit_rest_of_compilation;
3703 /* If specified extern inline but we aren't inlining it, we are
3704 done. This goes for anything that gets here with DECL_EXTERNAL
3705 set, not just things with DECL_INLINE. */
3706 if (DECL_EXTERNAL (decl))
3707 goto exit_rest_of_compilation;
3710 /* Initialize some variables used by the optimizers. */
3711 init_function_for_compilation ();
3713 if (! DECL_DEFER_OUTPUT (decl))
3714 TREE_ASM_WRITTEN (decl) = 1;
3716 /* Now that integrate will no longer see our rtl, we need not distinguish
3717 between the return value of this function and the return value of called
3718 functions. */
3719 rtx_equal_function_value_matters = 0;
3721 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3722 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3724 goto exit_rest_of_compilation;
3727 /* Emit code to get eh context, if needed. */
3728 emit_eh_context ();
3730 #ifdef FINALIZE_PIC
3731 /* If we are doing position-independent code generation, now
3732 is the time to output special prologues and epilogues.
3733 We do not want to do this earlier, because it just clutters
3734 up inline functions with meaningless insns. */
3735 if (flag_pic)
3736 FINALIZE_PIC;
3737 #endif
3739 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3740 Note that that may have been done above, in save_for_inline_copying.
3741 The call to resume_temporary_allocation near the end of this function
3742 goes back to the usual state of affairs. This must be done after
3743 we've built up any unwinders for exception handling, and done
3744 the FINALIZE_PIC work, if necessary. */
3746 rtl_in_current_obstack ();
3748 insns = get_insns ();
3750 /* Copy any shared structure that should not be shared. */
3752 unshare_all_rtl (insns);
3754 init_EXPR_INSN_LIST_cache ();
3756 #ifdef SETJMP_VIA_SAVE_AREA
3757 /* This must be performed before virutal register instantiation. */
3758 if (current_function_calls_alloca)
3759 optimize_save_area_alloca (insns);
3760 #endif
3762 /* Instantiate all virtual registers. */
3764 instantiate_virtual_regs (current_function_decl, get_insns ());
3766 /* See if we have allocated stack slots that are not directly addressable.
3767 If so, scan all the insns and create explicit address computation
3768 for all references to such slots. */
3769 /* fixup_stack_slots (); */
3771 /* Find all the EH handlers. */
3772 find_exception_handler_labels ();
3774 if (jump_opt_dump)
3775 open_dump_file (".01.jump", decl_printable_name (decl, 2));
3777 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3778 are initialized and to compute whether control can drop off the end
3779 of the function. */
3780 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3781 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3782 JUMP_AFTER_REGSCAN));
3784 /* Jump optimization, and the removal of NULL pointer checks, may
3785 have reduced the number of instructions substantially. CSE, and
3786 future passes, allocate arrays whose dimensions involve the maximum
3787 instruction UID, so if we can reduce the maximum UID we'll save big on
3788 memory. */
3789 renumber_insns (rtl_dump_file);
3791 /* Dump rtl code after jump, if we are doing that. */
3792 if (jump_opt_dump)
3793 close_dump_file (print_rtl, insns);
3795 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3796 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3797 goto exit_rest_of_compilation;
3799 /* Try to identify useless null pointer tests and delete them. */
3800 if (flag_delete_null_pointer_checks)
3801 TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
3803 if (ggc_p)
3804 ggc_collect ();
3806 /* Perform common subexpression elimination.
3807 Nonzero value from `cse_main' means that jumps were simplified
3808 and some code may now be unreachable, so do
3809 jump optimization again. */
3811 if (optimize > 0)
3813 if (cse_dump)
3814 open_dump_file (".02.cse", decl_printable_name (decl, 2));
3816 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3818 if (flag_thread_jumps)
3819 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3821 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3822 0, rtl_dump_file));
3823 /* If we are not running the second CSE pass, then we are no longer
3824 expecting CSE to be run. */
3825 cse_not_expected = !flag_rerun_cse_after_loop;
3827 if (tem || optimize > 1)
3828 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3829 !JUMP_NOOP_MOVES,
3830 !JUMP_AFTER_REGSCAN));
3832 /* Run this after jump optmizations remove all the unreachable code
3833 so that unreachable code will not keep values live. */
3834 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3836 /* Try to identify useless null pointer tests and delete them. */
3837 if (flag_delete_null_pointer_checks)
3838 TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
3840 /* The second pass of jump optimization is likely to have
3841 removed a bunch more instructions. */
3842 renumber_insns (rtl_dump_file);
3844 /* Dump rtl code after cse, if we are doing that. */
3845 if (cse_dump)
3847 close_dump_file (print_rtl, insns);
3848 if (graph_dump_format != no_graph)
3849 print_rtl_graph_with_bb (dump_base_name, ".02.cse", insns);
3853 purge_addressof (insns);
3854 reg_scan (insns, max_reg_num (), 1);
3856 if (addressof_dump)
3858 dump_rtl (".03.addressof", decl, print_rtl, insns);
3859 if (graph_dump_format != no_graph)
3860 print_rtl_graph_with_bb (dump_base_name, ".03.addressof", insns);
3863 if (ggc_p)
3864 ggc_collect ();
3866 /* Perform global cse. */
3868 if (optimize > 0 && flag_gcse)
3870 if (gcse_dump)
3871 open_dump_file (".04.gcse", decl_printable_name (decl, 2));
3873 TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file));
3875 /* If gcse altered any jumps, rerun jump optimizations to clean
3876 things up. */
3877 if (tem)
3879 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3880 !JUMP_NOOP_MOVES,
3881 !JUMP_AFTER_REGSCAN));
3884 if (gcse_dump)
3886 close_dump_file (print_rtl, insns);
3887 if (graph_dump_format != no_graph)
3888 print_rtl_graph_with_bb (dump_base_name, ".04.gcse", insns);
3891 if (ggc_p)
3892 ggc_collect ();
3894 /* Move constant computations out of loops. */
3896 if (optimize > 0)
3898 if (loop_dump)
3899 open_dump_file (".05.loop", decl_printable_name (decl, 2));
3901 TIMEVAR
3902 (loop_time,
3904 if (flag_rerun_loop_opt)
3906 /* We only want to perform unrolling once. */
3908 loop_optimize (insns, rtl_dump_file, 0, 0);
3911 /* The first call to loop_optimize makes some instructions
3912 trivially dead. We delete those instructions now in the
3913 hope that doing so will make the heuristics in loop work
3914 better and possibly speed up compilation. */
3915 delete_trivially_dead_insns (insns, max_reg_num ());
3917 /* The regscan pass is currently necessary as the alias
3918 analysis code depends on this information. */
3919 reg_scan (insns, max_reg_num (), 1);
3921 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
3924 /* Dump rtl code after loop opt, if we are doing that. */
3926 if (loop_dump)
3928 close_dump_file (print_rtl, insns);
3929 if (graph_dump_format != no_graph)
3930 print_rtl_graph_with_bb (dump_base_name, ".05.loop", insns);
3933 if (ggc_p)
3934 ggc_collect ();
3937 /* ??? Well, nearly. If HAVE_conditional_arithmetic, jump_optimize
3938 has put off all if-conversion until "after CSE". If we put this
3939 off any longer we may miss out doing if-conversion entirely. */
3940 cse_not_expected = 1;
3942 if (optimize > 0)
3944 if (cse2_dump)
3945 open_dump_file (".06.cse2", decl_printable_name (decl, 2));
3947 if (flag_rerun_cse_after_loop)
3949 /* Running another jump optimization pass before the second
3950 cse pass sometimes simplifies the RTL enough to allow
3951 the second CSE pass to do a better job. Jump_optimize can change
3952 max_reg_num so we must rerun reg_scan afterwards.
3953 ??? Rework to not call reg_scan so often. */
3954 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3955 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3956 !JUMP_NOOP_MOVES,
3957 JUMP_AFTER_REGSCAN));
3959 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3960 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3961 1, rtl_dump_file));
3962 if (tem)
3963 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3964 !JUMP_NOOP_MOVES,
3965 !JUMP_AFTER_REGSCAN));
3968 if (flag_thread_jumps)
3970 /* This pass of jump threading straightens out code
3971 that was kinked by loop optimization. */
3972 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3973 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3976 /* Dump rtl code after cse, if we are doing that. */
3977 if (cse2_dump)
3979 close_dump_file (print_rtl, insns);
3980 if (graph_dump_format != no_graph)
3981 print_rtl_graph_with_bb (dump_base_name, ".06.cse2", insns);
3984 if (ggc_p)
3985 ggc_collect ();
3988 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3990 if (branch_prob_dump)
3991 open_dump_file (".07.bp", decl_printable_name (decl, 2));
3993 TIMEVAR
3994 (branch_prob_time,
3996 branch_prob (insns, rtl_dump_file);
3999 if (branch_prob_dump)
4001 close_dump_file (print_rtl, insns);
4002 if (graph_dump_format != no_graph)
4003 print_rtl_graph_with_bb (dump_base_name, ".07.bp", insns);
4006 if (ggc_p)
4007 ggc_collect ();
4010 /* Now we choose between stupid (pcc-like) register allocation
4011 (if we got the -noreg switch and not -opt)
4012 and smart register allocation. */
4014 if (optimize > 0) /* Stupid allocation probably won't work */
4015 obey_regdecls = 0; /* if optimizations being done. */
4017 regclass_init ();
4019 /* Print function header into flow dump now
4020 because doing the flow analysis makes some of the dump. */
4022 if (flow_dump)
4023 open_dump_file (".08.flow", decl_printable_name (decl, 2));
4025 if (obey_regdecls)
4027 TIMEVAR (flow_time,
4029 regclass (insns, max_reg_num ());
4030 stupid_life_analysis (insns, max_reg_num (),
4031 rtl_dump_file);
4034 else
4036 /* Do control and data flow analysis,
4037 and write some of the results to dump file. */
4039 TIMEVAR
4040 (flow_time,
4042 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4043 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4046 if (warn_uninitialized || extra_warnings)
4048 uninitialized_vars_warning (DECL_INITIAL (decl));
4049 if (extra_warnings)
4050 setjmp_args_warning ();
4054 /* Dump rtl after flow analysis. */
4056 if (flow_dump)
4058 close_dump_file (print_rtl_with_bb, insns);
4059 if (graph_dump_format != no_graph)
4060 print_rtl_graph_with_bb (dump_base_name, ".08.flow", insns);
4063 if (ggc_p)
4064 ggc_collect ();
4066 /* The first life analysis pass has finished. From now on we can not
4067 generate any new pseudos. */
4068 no_new_pseudos = 1;
4070 /* If -opt, try combining insns through substitution. */
4072 if (optimize > 0)
4074 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
4076 /* Dump rtl code after insn combination. */
4078 if (combine_dump)
4080 dump_rtl (".09.combine", decl, print_rtl_with_bb, insns);
4081 if (graph_dump_format != no_graph)
4082 print_rtl_graph_with_bb (dump_base_name, ".09.combine", insns);
4085 if (ggc_p)
4086 ggc_collect ();
4089 /* Register allocation pre-pass, to reduce number of moves
4090 necessary for two-address machines. */
4091 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
4093 if (regmove_dump)
4094 open_dump_file (".10.regmove", decl_printable_name (decl, 2));
4096 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
4097 rtl_dump_file));
4099 if (regmove_dump)
4101 close_dump_file (print_rtl_with_bb, insns);
4102 if (graph_dump_format != no_graph)
4103 print_rtl_graph_with_bb (dump_base_name, ".10.regmove", insns);
4106 if (ggc_p)
4107 ggc_collect ();
4110 /* Print function header into sched dump now
4111 because doing the sched analysis makes some of the dump. */
4113 #ifdef INSN_SCHEDULING
4114 if (optimize > 0 && flag_schedule_insns)
4116 if (sched_dump)
4117 open_dump_file (".11.sched", decl_printable_name (decl, 2));
4119 /* Do control and data sched analysis,
4120 and write some of the results to dump file. */
4122 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
4124 /* Dump rtl after instruction scheduling. */
4126 if (sched_dump)
4128 close_dump_file (print_rtl_with_bb, insns);
4129 if (graph_dump_format != no_graph)
4130 print_rtl_graph_with_bb (dump_base_name, ".11.sched", insns);
4133 if (ggc_p)
4134 ggc_collect ();
4136 #endif
4138 /* Determine if the current function is a leaf before running reload
4139 since this can impact optimizations done by the prologue and
4140 epilogue thus changing register elimination offsets. */
4141 current_function_is_leaf = leaf_function_p ();
4143 /* Unless we did stupid register allocation,
4144 allocate pseudo-regs that are used only within 1 basic block.
4146 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
4147 jump optimizer after register allocation and reloading are finished. */
4149 if (!obey_regdecls)
4150 TIMEVAR (local_alloc_time,
4152 /* We recomputed reg usage as part of updating the rest
4153 of life info during sched. */
4154 if (! flag_schedule_insns)
4155 recompute_reg_usage (insns, ! optimize_size);
4156 regclass (insns, max_reg_num ());
4157 rebuild_label_notes_after_reload = local_alloc ();
4159 else
4160 rebuild_label_notes_after_reload = 0;
4162 /* Dump rtl code after allocating regs within basic blocks. */
4164 if (local_reg_dump)
4166 open_dump_file (".12.lreg", decl_printable_name (decl, 2));
4168 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
4169 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
4171 close_dump_file (print_rtl_with_bb, insns);
4172 if (graph_dump_format != no_graph)
4173 print_rtl_graph_with_bb (dump_base_name, ".12.lreg", insns);
4176 if (ggc_p)
4177 ggc_collect ();
4179 if (global_reg_dump)
4180 open_dump_file (".13.greg", decl_printable_name (decl, 2));
4182 /* Unless we did stupid register allocation,
4183 allocate remaining pseudo-regs, then do the reload pass
4184 fixing up any insns that are invalid. */
4186 TIMEVAR (global_alloc_time,
4188 if (!obey_regdecls)
4189 failure = global_alloc (rtl_dump_file);
4190 else
4191 failure = reload (insns, 0, rtl_dump_file);
4195 if (failure)
4196 goto exit_rest_of_compilation;
4198 if (ggc_p)
4199 ggc_collect ();
4201 /* Do a very simple CSE pass over just the hard registers. */
4202 if (optimize > 0)
4203 reload_cse_regs (insns);
4205 /* Register allocation and reloading may have turned an indirect jump into
4206 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
4207 jumping instructions. */
4208 if (rebuild_label_notes_after_reload)
4209 TIMEVAR (jump_time, rebuild_jump_labels (insns));
4211 /* On some machines, the prologue and epilogue code, or parts thereof,
4212 can be represented as RTL. Doing so lets us schedule insns between
4213 it and the rest of the code and also allows delayed branch
4214 scheduling to operate in the epilogue. */
4216 thread_prologue_and_epilogue_insns (insns);
4218 /* If optimizing and we are performing instruction scheduling after
4219 reload, then go ahead and split insns now since we are about to
4220 recompute flow information anyway.
4222 reload_cse_regs may expose more splitting opportunities, expecially
4223 for double-word operations. */
4224 if (optimize > 0 && flag_schedule_insns_after_reload)
4225 split_all_insns (0);
4227 if (global_reg_dump)
4229 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
4230 close_dump_file (print_rtl_with_bb, insns);
4231 if (graph_dump_format != no_graph)
4232 print_rtl_graph_with_bb (dump_base_name, ".13.greg", insns);
4235 /* Re-create the death notes which were deleted during reload. */
4236 if (flow2_dump)
4237 open_dump_file (".14.flow2", decl_printable_name (decl, 2));
4239 if (optimize)
4241 TIMEVAR
4242 (flow2_time,
4244 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4245 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4248 if (ggc_p)
4249 ggc_collect ();
4252 flow2_completed = 1;
4254 if (flow2_dump)
4256 close_dump_file (print_rtl_with_bb, insns);
4257 if (graph_dump_format != no_graph)
4258 print_rtl_graph_with_bb (dump_base_name, ".14.flow2", insns);
4261 #ifdef HAVE_peephole2
4262 if (optimize > 0 && flag_peephole2)
4264 if (peephole2_dump)
4265 open_dump_file (".15.peephole2", decl_printable_name (decl, 2));
4267 TIMEVAR (peephole2_time, peephole2_optimize (rtl_dump_file));
4269 if (peephole2_dump)
4271 close_dump_file (print_rtl_with_bb, insns);
4272 if (graph_dump_format != no_graph)
4273 print_rtl_graph_with_bb (dump_base_name, ".15.peephole2", insns);
4276 #endif
4278 #ifdef INSN_SCHEDULING
4279 if (optimize > 0 && flag_schedule_insns_after_reload)
4281 if (sched2_dump)
4282 open_dump_file (".16.sched2", decl_printable_name (decl, 2));
4284 /* Do control and data sched analysis again,
4285 and write some more of the results to dump file. */
4287 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
4289 /* Dump rtl after post-reorder instruction scheduling. */
4291 if (sched2_dump)
4293 close_dump_file (print_rtl_with_bb, insns);
4294 if (graph_dump_format != no_graph)
4295 print_rtl_graph_with_bb (dump_base_name, ".16.sched2", insns);
4298 if (ggc_p)
4299 ggc_collect ();
4301 #endif
4303 #ifdef LEAF_REGISTERS
4304 current_function_uses_only_leaf_regs
4305 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
4306 #endif
4308 /* One more attempt to remove jumps to .+1
4309 left by dead-store-elimination.
4310 Also do cross-jumping this time
4311 and delete no-op move insns. */
4313 if (optimize > 0)
4315 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
4316 JUMP_NOOP_MOVES,
4317 !JUMP_AFTER_REGSCAN));
4319 /* Dump rtl code after jump, if we are doing that. */
4321 if (jump2_opt_dump)
4323 dump_rtl (".17.jump2", decl, print_rtl_with_bb, insns);
4324 if (graph_dump_format != no_graph)
4325 print_rtl_graph_with_bb (dump_base_name, ".17.jump2", insns);
4329 /* If a machine dependent reorganization is needed, call it. */
4330 #ifdef MACHINE_DEPENDENT_REORG
4331 if (mach_dep_reorg_dump)
4332 open_dump_file (".18.mach", decl_printable_name (decl, 2));
4334 MACHINE_DEPENDENT_REORG (insns);
4336 if (mach_dep_reorg_dump)
4338 close_dump_file (print_rtl_with_bb, insns);
4339 if (graph_dump_format != no_graph)
4340 print_rtl_graph_with_bb (dump_base_name, ".18.mach", insns);
4343 if (ggc_p)
4344 ggc_collect ();
4345 #endif
4347 /* If a scheduling pass for delayed branches is to be done,
4348 call the scheduling code. */
4350 #ifdef DELAY_SLOTS
4351 if (optimize > 0 && flag_delayed_branch)
4353 if (dbr_sched_dump)
4354 open_dump_file (".19.dbr", decl_printable_name (decl, 2));
4356 TIMEVAR
4357 (dbr_sched_time,
4359 dbr_schedule (insns, rtl_dump_file);
4362 if (dbr_sched_dump)
4364 close_dump_file (print_rtl_with_bb, insns);
4365 if (graph_dump_format != no_graph)
4366 print_rtl_graph_with_bb (dump_base_name, ".19.dbr", insns);
4370 if (ggc_p)
4371 ggc_collect ();
4372 #endif
4374 /* Shorten branches. */
4375 TIMEVAR (shorten_branch_time,
4377 shorten_branches (get_insns ());
4380 #ifdef STACK_REGS
4381 if (stack_reg_dump)
4382 open_dump_file (".20.stack", decl_printable_name (decl, 2));
4384 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
4386 if (stack_reg_dump)
4388 close_dump_file (print_rtl_with_bb, insns);
4389 if (graph_dump_format != no_graph)
4390 print_rtl_graph_with_bb (dump_base_name, ".20.stack", insns);
4393 if (ggc_p)
4394 ggc_collect ();
4395 #endif
4397 /* Now turn the rtl into assembler code. */
4399 TIMEVAR (final_time,
4401 rtx x;
4402 char *fnname;
4404 /* Get the function's name, as described by its RTL.
4405 This may be different from the DECL_NAME name used
4406 in the source file. */
4408 x = DECL_RTL (decl);
4409 if (GET_CODE (x) != MEM)
4410 abort ();
4411 x = XEXP (x, 0);
4412 if (GET_CODE (x) != SYMBOL_REF)
4413 abort ();
4414 fnname = XSTR (x, 0);
4416 assemble_start_function (decl, fnname);
4417 final_start_function (insns, asm_out_file, optimize);
4418 final (insns, asm_out_file, optimize, 0);
4419 final_end_function (insns, asm_out_file, optimize);
4420 assemble_end_function (decl, fnname);
4421 if (! quiet_flag)
4422 fflush (asm_out_file);
4424 /* Release all memory allocated by flow. */
4425 free_basic_block_vars (0);
4427 /* Release all memory held by regsets now */
4428 regset_release_memory ();
4431 if (ggc_p)
4432 ggc_collect ();
4434 /* Write DBX symbols if requested */
4436 /* Note that for those inline functions where we don't initially
4437 know for certain that we will be generating an out-of-line copy,
4438 the first invocation of this routine (rest_of_compilation) will
4439 skip over this code by doing a `goto exit_rest_of_compilation;'.
4440 Later on, finish_compilation will call rest_of_compilation again
4441 for those inline functions that need to have out-of-line copies
4442 generated. During that call, we *will* be routed past here. */
4444 #ifdef DBX_DEBUGGING_INFO
4445 if (write_symbols == DBX_DEBUG)
4446 TIMEVAR (symout_time, dbxout_function (decl));
4447 #endif
4449 #ifdef DWARF_DEBUGGING_INFO
4450 if (write_symbols == DWARF_DEBUG)
4451 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
4452 #endif
4454 #ifdef DWARF2_DEBUGGING_INFO
4455 if (write_symbols == DWARF2_DEBUG)
4456 TIMEVAR (symout_time, dwarf2out_decl (decl));
4457 #endif
4459 exit_rest_of_compilation:
4461 free_bb_mem ();
4463 /* In case the function was not output,
4464 don't leave any temporary anonymous types
4465 queued up for sdb output. */
4466 #ifdef SDB_DEBUGGING_INFO
4467 if (write_symbols == SDB_DEBUG)
4468 sdbout_types (NULL_TREE);
4469 #endif
4471 reload_completed = 0;
4472 flow2_completed = 0;
4473 no_new_pseudos = 0;
4475 TIMEVAR (final_time,
4477 /* Clear out the insn_length contents now that they are no
4478 longer valid. */
4479 init_insn_lengths ();
4481 /* Clear out the real_constant_chain before some of the rtx's
4482 it runs through become garbage. */
4483 clear_const_double_mem ();
4485 /* Cancel the effect of rtl_in_current_obstack. */
4486 resume_temporary_allocation ();
4488 /* Show no temporary slots allocated. */
4489 init_temp_slots ();
4491 free_basic_block_vars (0);
4494 /* Make sure volatile mem refs aren't considered valid operands for
4495 arithmetic insns. We must call this here if this is a nested inline
4496 function, since the above code leaves us in the init_recog state
4497 (from final.c), and the function context push/pop code does not
4498 save/restore volatile_ok.
4500 ??? Maybe it isn't necessary for expand_start_function to call this
4501 anymore if we do it here? */
4503 init_recog_no_volatile ();
4505 /* We're done with this function. Free up memory if we can. */
4506 free_after_parsing (current_function);
4507 if (! DECL_DEFER_OUTPUT (decl))
4508 free_after_compilation (current_function);
4509 current_function = 0;
4511 if (ggc_p)
4512 ggc_collect ();
4514 /* The parsing time is all the time spent in yyparse
4515 *except* what is spent in this function. */
4517 parse_time -= get_run_time () - start_time;
4520 static void
4521 display_help ()
4523 int undoc;
4524 unsigned long i;
4525 const char * lang;
4527 #ifndef USE_CPPLIB
4528 printf ("Usage: %s input [switches]\n", progname);
4529 printf ("Switches:\n");
4530 #endif
4531 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
4532 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
4533 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4534 printf (" -finline-limit=<number> Limits the size of inlined functions to <number>\n");
4536 for (i = NUM_ELEM (f_options); i--;)
4538 const char * description = f_options[i].description;
4540 if (description != NULL && * description != 0)
4541 printf (" -f%-21s %s\n",
4542 f_options[i].string, description);
4545 printf (" -O[number] Set optimisation level to [number]\n");
4546 printf (" -Os Optimise for space rather than speed\n");
4547 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
4548 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
4549 printf (" -w Suppress warnings\n");
4550 printf (" -W Enable extra warnings\n");
4552 for (i = NUM_ELEM (W_options); i--;)
4554 const char * description = W_options[i].description;
4556 if (description != NULL && * description != 0)
4557 printf (" -W%-21s %s\n",
4558 W_options[i].string, description);
4561 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4562 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4563 printf (" -p Enable function profiling\n");
4564 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4565 printf (" -a Enable block profiling \n");
4566 #endif
4567 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4568 printf (" -ax Enable jump profiling \n");
4569 #endif
4570 printf (" -o <file> Place output into <file> \n");
4571 printf (" -G <number> Put global and static data smaller than <number>\n");
4572 printf (" bytes into a special section (on some targets)\n");
4574 for (i = NUM_ELEM (debug_args); i--;)
4576 if (debug_args[i].description != NULL)
4577 printf (" -g%-21s %s\n", debug_args[i].arg, debug_args[i].description);
4580 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4581 printf (" -quiet Do not display functions compiled or elapsed time\n");
4582 printf (" -version Display the compiler's version\n");
4583 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4584 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4585 #if defined INSN_SCHEDULING
4586 printf (" -sched-verbose=<number> Set the verbosity level of the scheduler\n");
4587 #endif
4588 printf (" --help Display this information\n");
4590 undoc = 0;
4591 lang = "language";
4593 /* Display descriptions of language specific options.
4594 If there is no description, note that there is an undocumented option.
4595 If the description is empty, do not display anything. (This allows
4596 options to be deliberately undocumented, for whatever reason).
4597 If the option string is missing, then this is a marker, indicating
4598 that the description string is in fact the name of a language, whose
4599 language specific options are to follow. */
4601 if (NUM_ELEM (documented_lang_options) > 1)
4603 printf ("\nLanguage specific options:\n");
4605 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
4607 const char * description = documented_lang_options[i].description;
4608 const char * option = documented_lang_options[i].option;
4610 if (description == NULL)
4612 undoc = 1;
4614 if (extra_warnings)
4615 printf (" %-23.23s [undocumented]\n", option);
4617 else if (* description == 0)
4618 continue;
4619 else if (option == NULL)
4621 if (undoc)
4622 printf
4623 ("\nThere are undocumented %s specific options as well.\n",
4624 lang);
4625 undoc = 0;
4627 printf ("\n Options for %s:\n", description);
4629 lang = description;
4631 else
4632 printf (" %-23.23s %s\n", option, description);
4636 if (undoc)
4637 printf ("\nThere are undocumented %s specific options as well.\n", lang);
4639 if (NUM_ELEM (target_switches) > 1
4640 #ifdef TARGET_OPTIONS
4641 || NUM_ELEM (target_options) > 1
4642 #endif
4645 int doc = 0;
4647 undoc = 0;
4649 printf ("\nTarget specific options:\n");
4651 for (i = NUM_ELEM (target_switches); i--;)
4653 const char * option = target_switches[i].name;
4654 const char * description = target_switches[i].description;
4656 if (option == NULL || * option == 0)
4657 continue;
4658 else if (description == NULL)
4660 undoc = 1;
4662 if (extra_warnings)
4663 printf (" -m%-21.21s [undocumented]\n", option);
4665 else if (* description != 0)
4666 doc += printf (" -m%-21.21s %s\n", option, description);
4669 #ifdef TARGET_OPTIONS
4670 for (i = NUM_ELEM (target_options); i--;)
4672 const char * option = target_options[i].prefix;
4673 const char * description = target_options[i].description;
4675 if (option == NULL || * option == 0)
4676 continue;
4677 else if (description == NULL)
4679 undoc = 1;
4681 if (extra_warnings)
4682 printf (" -m%-21.21s [undocumented]\n", option);
4684 else if (* description != 0)
4685 doc += printf (" -m%-21.21s %s\n", option, description);
4687 #endif
4688 if (undoc)
4690 if (doc)
4691 printf ("\nThere are undocumented target specific options as well.\n");
4692 else
4693 printf (" They exist, but they are not documented.\n");
4698 /* Parse a -d... comand line switch. */
4700 static void
4701 decode_d_option (arg)
4702 const char * arg;
4704 while (* arg)
4705 switch (* arg ++)
4707 case 'a':
4708 branch_prob_dump = 1;
4709 combine_dump = 1;
4710 #ifdef DELAY_SLOTS
4711 dbr_sched_dump = 1;
4712 #endif
4713 flow_dump = 1;
4714 flow2_dump = 1;
4715 global_reg_dump = 1;
4716 jump_opt_dump = 1;
4717 addressof_dump = 1;
4718 jump2_opt_dump = 1;
4719 local_reg_dump = 1;
4720 loop_dump = 1;
4721 regmove_dump = 1;
4722 rtl_dump = 1;
4723 cse_dump = 1;
4724 cse2_dump = 1;
4725 gcse_dump = 1;
4726 sched_dump = 1;
4727 sched2_dump = 1;
4728 #ifdef STACK_REGS
4729 stack_reg_dump = 1;
4730 #endif
4731 #ifdef MACHINE_DEPENDENT_REORG
4732 mach_dep_reorg_dump = 1;
4733 #endif
4734 peephole2_dump = 1;
4735 break;
4736 case 'A':
4737 flag_debug_asm = 1;
4738 break;
4739 case 'b':
4740 branch_prob_dump = 1;
4741 break;
4742 case 'c':
4743 combine_dump = 1;
4744 break;
4745 #ifdef DELAY_SLOTS
4746 case 'd':
4747 dbr_sched_dump = 1;
4748 break;
4749 #endif
4750 case 'f':
4751 flow_dump = 1;
4752 break;
4753 case 'F':
4754 addressof_dump = 1;
4755 break;
4756 case 'g':
4757 global_reg_dump = 1;
4758 break;
4759 case 'G':
4760 gcse_dump = 1;
4761 break;
4762 case 'j':
4763 jump_opt_dump = 1;
4764 break;
4765 case 'J':
4766 jump2_opt_dump = 1;
4767 break;
4768 #ifdef STACK_REGS
4769 case 'k':
4770 stack_reg_dump = 1;
4771 break;
4772 #endif
4773 case 'l':
4774 local_reg_dump = 1;
4775 break;
4776 case 'L':
4777 loop_dump = 1;
4778 break;
4779 case 'm':
4780 flag_print_mem = 1;
4781 break;
4782 #ifdef MACHINE_DEPENDENT_REORG
4783 case 'M':
4784 mach_dep_reorg_dump = 1;
4785 break;
4786 #endif
4787 case 'p':
4788 flag_print_asm_name = 1;
4789 break;
4790 case 'r':
4791 rtl_dump = 1;
4792 break;
4793 case 'R':
4794 sched2_dump = 1;
4795 break;
4796 case 's':
4797 cse_dump = 1;
4798 break;
4799 case 'S':
4800 sched_dump = 1;
4801 break;
4802 case 't':
4803 cse2_dump = 1;
4804 break;
4805 case 'N':
4806 regmove_dump = 1;
4807 break;
4808 case 'v':
4809 graph_dump_format = vcg;
4810 break;
4811 case 'w':
4812 flow2_dump = 1;
4813 break;
4814 case 'x':
4815 rtl_dump_and_exit = 1;
4816 break;
4817 case 'y':
4818 set_yydebug (1);
4819 break;
4820 case 'z':
4821 peephole2_dump = 1;
4822 break;
4823 case 'D': /* These are handled by the preprocessor. */
4824 case 'I':
4825 break;
4826 default:
4827 warning ("unrecognised gcc debugging option: %c", arg[-1]);
4828 break;
4832 /* Parse a -f... comand line switch. ARG is the value after the -f.
4833 It is safe to access 'ARG - 2' to generate the full switch name.
4834 Return the number of strings consumed. */
4836 static int
4837 decode_f_option (arg)
4838 const char * arg;
4840 int j;
4842 /* Search for the option in the table of binary f options. */
4843 for (j = sizeof (f_options) / sizeof (f_options[0]); j--;)
4845 if (!strcmp (arg, f_options[j].string))
4847 *f_options[j].variable = f_options[j].on_value;
4848 return 1;
4851 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4852 && ! strcmp (arg + 3, f_options[j].string))
4854 *f_options[j].variable = ! f_options[j].on_value;
4855 return 1;
4859 if (!strncmp (arg, "inline-limit-", 13)
4860 || !strncmp (arg, "inline-limit=", 13))
4861 inline_max_insns =
4862 read_integral_parameter (arg + 13, arg - 2, inline_max_insns);
4863 #ifdef INSN_SCHEDULING
4864 else if (!strncmp (arg, "sched-verbose=", 14))
4865 fix_sched_param ("verbose", (const char *)(arg + 14));
4866 #endif
4867 else if (!strncmp (arg, "fixed-", 6))
4868 fix_register ((const char *)(arg + 6), 1, 1);
4869 else if (!strncmp (arg, "call-used-", 10))
4870 fix_register ((const char *)(arg + 10), 0, 1);
4871 else if (!strncmp (arg, "call-saved-", 11))
4872 fix_register ((const char *)(arg + 11), 0, 0);
4873 else if (!strncmp (arg, "align-loops=", 12))
4874 align_loops = read_integral_parameter (arg + 12, arg - 2, align_loops);
4875 else if (!strncmp (arg, "align-functions=", 16))
4876 align_functions =
4877 read_integral_parameter (arg + 16, arg - 2, align_functions);
4878 else if (!strncmp (arg, "align-jumps=", 12))
4879 align_jumps = read_integral_parameter (arg + 12, arg - 2, align_jumps);
4880 else if (!strncmp (arg, "align-labels=", 13))
4881 align_labels = read_integral_parameter (arg + 13, arg - 2, align_labels);
4882 else if (!strcmp (arg, "preprocessed"))
4883 /* Recognise this switch but do nothing. This prevents warnings
4884 about an unrecognised switch if cpplib has not been linked in. */
4886 else
4887 return 0;
4889 return 1;
4892 /* Parse a -W... comand line switch. ARG is the value after the -W.
4893 It is safe to access 'ARG - 2' to generate the full switch name.
4894 Return the number of strings consumed. */
4895 static int
4896 decode_W_option (arg)
4897 const char * arg;
4899 int j;
4901 /* Search for the option in the table of binary W options. */
4903 for (j = sizeof (W_options) / sizeof (W_options[0]); j--;)
4905 if (!strcmp (arg, W_options[j].string))
4907 *W_options[j].variable = W_options[j].on_value;
4908 return 1;
4911 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4912 && ! strcmp (arg + 3, W_options[j].string))
4914 *W_options[j].variable = ! W_options[j].on_value;
4915 return 1;
4919 if (!strncmp (arg, "id-clash-", 9))
4921 const int id_clash_val = read_integral_parameter (arg + 9, arg - 2, -1);
4923 if (id_clash_val != -1)
4925 id_clash_len = id_clash_val;
4926 warn_id_clash = 1;
4929 else if (!strncmp (arg, "larger-than-", 12))
4931 const int larger_than_val =
4932 read_integral_parameter (arg + 12, arg - 2, -1);
4933 if (larger_than_val != -1)
4935 larger_than_size = larger_than_val;
4936 warn_larger_than = 1;
4939 else
4940 return 0;
4942 return 1;
4945 /* Parse a -g... comand line switch. ARG is the value after the -g.
4946 It is safe to access 'ARG - 2' to generate the full switch name.
4947 Return the number of strings consumed. */
4949 static int
4950 decode_g_option (arg)
4951 const char * arg;
4953 unsigned level;
4954 /* A lot of code assumes write_symbols == NO_DEBUG if the
4955 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4956 of what debugging type has been selected). This records the
4957 selected type. It is an error to specify more than one
4958 debugging type. */
4959 static enum debug_info_type selected_debug_type = NO_DEBUG;
4960 /* Non-zero if debugging format has been explicitly set.
4961 -g and -ggdb don't explicitly set the debugging format so
4962 -gdwarf -g3 is equivalent to -gdwarf3. */
4963 static int type_explicitly_set_p = 0;
4964 /* Indexed by enum debug_info_type. */
4965 static const char * debug_type_names[] =
4967 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4970 /* The maximum admissible debug level value. */
4971 static const unsigned max_debug_level = 3;
4973 /* Look up ARG in the table. */
4974 for (da = debug_args; da->arg; da++)
4976 const int da_len = strlen (da->arg);
4978 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4980 enum debug_info_type type = da->debug_type;
4981 const char * p = arg + da_len;
4983 if (*p && (*p < '0' || *p > '9'))
4984 continue;
4986 /* A debug flag without a level defaults to level 2.
4987 Note we do not want to call read_integral_parameter
4988 for that case since it will call atoi which
4989 will return zero.
4991 ??? We may want to generalize the interface to
4992 read_integral_parameter to better handle this case
4993 if this case shows up often. */
4994 if (*p)
4995 level = read_integral_parameter (p, 0, max_debug_level + 1);
4996 else
4997 level = 2;
4999 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
5001 error ("use -gdwarf -g%d for DWARF v1, level %d",
5002 level, level);
5003 if (level == 2)
5004 error ("use -gdwarf-2 for DWARF v2");
5007 if (level > max_debug_level)
5009 warning ("\
5010 ignoring option `%s' due to invalid debug level specification",
5011 arg - 2);
5012 level = debug_info_level;
5015 if (type == NO_DEBUG)
5017 type = PREFERRED_DEBUGGING_TYPE;
5019 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
5021 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
5022 type = DWARF2_DEBUG;
5023 #else
5024 #ifdef DBX_DEBUGGING_INFO
5025 type = DBX_DEBUG;
5026 #endif
5027 #endif
5031 if (type == NO_DEBUG)
5032 warning ("`%s': unknown or unsupported -g option", arg - 2);
5034 /* Does it conflict with an already selected type? */
5035 if (type_explicitly_set_p
5036 /* -g/-ggdb don't conflict with anything */
5037 && da->debug_type != NO_DEBUG
5038 && type != selected_debug_type)
5039 warning ("`%s' ignored, conflicts with `-g%s'",
5040 arg - 2, debug_type_names[(int) selected_debug_type]);
5041 else
5043 /* If the format has already been set, -g/-ggdb
5044 only change the debug level. */
5045 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
5046 ; /* don't change debugging type */
5047 else
5049 selected_debug_type = type;
5050 type_explicitly_set_p = da->debug_type != NO_DEBUG;
5053 write_symbols = (level == 0
5054 ? NO_DEBUG
5055 : selected_debug_type);
5056 use_gnu_debug_info_extensions = da->use_extensions_p;
5057 debug_info_level = (enum debug_info_level) level;
5060 break;
5064 if (! da->arg)
5065 warning ("`%s': unknown or unsupported -g option", arg - 2);
5067 return 1;
5070 /* Decode the first argument in the argv as a language-independent option.
5071 Return the number of strings consumed. 'strings_processed' is the
5072 number of strings that have already been decoded in a language
5073 specific fashion before this function was invoked. */
5075 static unsigned
5076 independent_decode_option (argc, argv, strings_processed)
5077 int argc;
5078 char ** argv;
5079 unsigned strings_processed ATTRIBUTE_UNUSED;
5081 char * arg = argv[0];
5083 if (arg[0] != '-' || arg[1] == 0)
5085 if (arg[0] == '+')
5086 return 0;
5088 filename = arg;
5090 return 1;
5093 arg ++;
5095 if (!strcmp (arg, "-help"))
5097 display_help ();
5098 exit (0);
5101 if (* arg == 'Y')
5102 arg ++;
5104 switch (* arg)
5106 default:
5107 return 0;
5109 case 'O':
5110 /* Already been treated in main (). Do nothing. */
5111 break;
5113 case 'm':
5114 set_target_switch (arg + 1);
5115 break;
5117 case 'f':
5118 return decode_f_option (arg + 1);
5120 case 'g':
5121 return decode_g_option (arg + 1);
5123 case 'd':
5124 if (!strcmp (arg, "dumpbase"))
5126 if (argc == 1)
5127 return 0;
5129 dump_base_name = argv[1];
5130 return 2;
5132 else
5133 decode_d_option (arg + 1);
5134 break;
5136 case 'p':
5137 if (!strcmp (arg, "pedantic"))
5138 pedantic = 1;
5139 else if (!strcmp (arg, "pedantic-errors"))
5140 flag_pedantic_errors = pedantic = 1;
5141 else if (arg[1] == 0)
5142 profile_flag = 1;
5143 else
5144 return 0;
5145 break;
5147 case 'q':
5148 if (!strcmp (arg, "quiet"))
5149 quiet_flag = 1;
5150 else
5151 return 0;
5152 break;
5154 case 'v':
5155 if (!strcmp (arg, "version"))
5156 version_flag = 1;
5157 else
5158 return 0;
5159 break;
5161 case 'w':
5162 if (arg[1] == 0)
5163 inhibit_warnings = 1;
5164 else
5165 return 0;
5166 break;
5168 case 'W':
5169 if (arg[1] == 0)
5171 extra_warnings = 1;
5172 /* We save the value of warn_uninitialized, since if they put
5173 -Wuninitialized on the command line, we need to generate a
5174 warning about not using it without also specifying -O. */
5175 if (warn_uninitialized != 1)
5176 warn_uninitialized = 2;
5178 else
5179 return decode_W_option (arg + 1);
5180 break;
5182 case 'a':
5183 if (arg[1] == 0)
5185 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5186 warning ("`-a' option (basic block profile) not supported");
5187 #else
5188 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
5189 #endif
5191 else if (!strcmp (arg, "ax"))
5193 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5194 warning ("`-ax' option (jump profiling) not supported");
5195 #else
5196 profile_block_flag = (!profile_block_flag
5197 || profile_block_flag == 2) ? 2 : 3;
5198 #endif
5200 else if (!strncmp (arg, "aux-info", 8))
5202 flag_gen_aux_info = 1;
5203 if (arg[8] == '\0')
5205 if (argc == 1)
5206 return 0;
5208 aux_info_file_name = argv[1];
5209 return 2;
5211 else
5212 aux_info_file_name = arg + 8;
5214 else
5215 return 0;
5216 break;
5218 case 'o':
5219 if (arg[1] == 0)
5221 if (argc == 1)
5222 return 0;
5224 asm_file_name = argv[1];
5225 return 2;
5227 return 0;
5229 case 'G':
5231 int g_switch_val;
5232 int return_val;
5234 if (arg[1] == 0)
5236 if (argc == 1)
5237 return 0;
5239 g_switch_val = read_integral_parameter (argv[1], 0, -1);
5240 return_val = 2;
5242 else
5244 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
5245 return_val = 1;
5248 if (g_switch_val == -1)
5249 return_val = 0;
5250 else
5252 g_switch_set = TRUE;
5253 g_switch_value = g_switch_val;
5256 return return_val;
5260 return 1;
5263 /* Entry point of cc1/c++. Decode command args, then call compile_file.
5264 Exit code is 35 if can't open files, 34 if fatal error,
5265 33 if had nonfatal errors, else success. */
5267 extern int main PROTO ((int, char **));
5270 main (argc, argv)
5271 int argc;
5272 char **argv;
5274 register int i;
5275 char *p;
5277 /* save in case md file wants to emit args as a comment. */
5278 save_argc = argc;
5279 save_argv = argv;
5281 p = argv[0] + strlen (argv[0]);
5282 while (p != argv[0] && p[-1] != '/'
5283 #ifdef DIR_SEPARATOR
5284 && p[-1] != DIR_SEPARATOR
5285 #endif
5287 --p;
5288 progname = p;
5290 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
5291 /* Get rid of any avoidable limit on stack size. */
5293 struct rlimit rlim;
5295 /* Set the stack limit huge so that alloca does not fail. */
5296 getrlimit (RLIMIT_STACK, &rlim);
5297 rlim.rlim_cur = rlim.rlim_max;
5298 setrlimit (RLIMIT_STACK, &rlim);
5300 #endif
5302 #ifdef HAVE_LC_MESSAGES
5303 setlocale (LC_MESSAGES, "");
5304 #endif
5305 (void) bindtextdomain (PACKAGE, localedir);
5306 (void) textdomain (PACKAGE);
5308 signal (SIGFPE, float_signal);
5310 #ifdef SIGPIPE
5311 signal (SIGPIPE, pipe_closed);
5312 #endif
5314 decl_printable_name = decl_name;
5315 lang_expand_expr = (lang_expand_expr_t) do_abort;
5317 /* Initialize whether `char' is signed. */
5318 flag_signed_char = DEFAULT_SIGNED_CHAR;
5319 #ifdef DEFAULT_SHORT_ENUMS
5320 /* Initialize how much space enums occupy, by default. */
5321 flag_short_enums = DEFAULT_SHORT_ENUMS;
5322 #endif
5324 /* Initialize the garbage-collector. */
5325 init_ggc ();
5326 ggc_add_root (&input_file_stack, 1, sizeof input_file_stack,
5327 &mark_file_stack);
5329 /* Perform language-specific options intialization. */
5330 lang_init_options ();
5332 /* Scan to see what optimization level has been specified. That will
5333 determine the default value of many flags. */
5334 for (i = 1; i < argc; i++)
5336 if (!strcmp (argv[i], "-O"))
5338 optimize = 1;
5339 optimize_size = 0;
5341 else if (argv[i][0] == '-' && argv[i][1] == 'O')
5343 /* Handle -Os, -O2, -O3, -O69, ... */
5344 char *p = &argv[i][2];
5346 if ((p[0] == 's') && (p[1] == 0))
5348 optimize_size = 1;
5350 /* Optimizing for size forces optimize to be 2. */
5351 optimize = 2;
5353 else
5355 const int optimize_val = read_integral_parameter (p, p - 2, -1);
5356 if (optimize_val != -1)
5358 optimize = optimize_val;
5359 optimize_size = 0;
5365 obey_regdecls = (optimize == 0);
5367 if (optimize >= 1)
5369 flag_defer_pop = 1;
5370 flag_thread_jumps = 1;
5371 #ifdef DELAY_SLOTS
5372 flag_delayed_branch = 1;
5373 #endif
5374 #ifdef CAN_DEBUG_WITHOUT_FP
5375 flag_omit_frame_pointer = 1;
5376 #endif
5379 if (optimize >= 2)
5381 flag_cse_follow_jumps = 1;
5382 flag_cse_skip_blocks = 1;
5383 flag_gcse = 1;
5384 flag_expensive_optimizations = 1;
5385 flag_strength_reduce = 1;
5386 flag_rerun_cse_after_loop = 1;
5387 flag_rerun_loop_opt = 1;
5388 flag_caller_saves = 1;
5389 flag_force_mem = 1;
5390 flag_peephole2 = 1;
5391 #ifdef INSN_SCHEDULING
5392 flag_schedule_insns = 1;
5393 flag_schedule_insns_after_reload = 1;
5394 #endif
5395 flag_regmove = 1;
5396 flag_strict_aliasing = 1;
5397 flag_delete_null_pointer_checks = 1;
5400 if (optimize >= 3)
5402 flag_inline_functions = 1;
5405 if (optimize < 2 || optimize_size)
5407 align_loops = 1;
5408 align_jumps = 1;
5409 align_labels = 1;
5410 align_functions = 1;
5413 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
5414 modify it. */
5415 target_flags = 0;
5416 set_target_switch ("");
5418 #ifdef OPTIMIZATION_OPTIONS
5419 /* Allow default optimizations to be specified on a per-machine basis. */
5420 OPTIMIZATION_OPTIONS (optimize, optimize_size);
5421 #endif
5423 /* Initialize register usage now so switches may override. */
5424 init_reg_sets ();
5426 /* Perform normal command line switch decoding. */
5427 for (i = 1; i < argc;)
5429 unsigned lang_processed;
5430 unsigned indep_processed;
5432 /* Give the language a chance to decode the option for itself. */
5433 lang_processed = lang_decode_option (argc - i, argv + i);
5435 /* Now see if the option also has a language independent meaning.
5436 Some options are both language specific and language independent,
5437 eg --help. It is possible that there might be options that should
5438 only be decoded in a language independent way if the were not
5439 decoded in a langauge specific way, which is why 'lang_processed'
5440 is passed in. */
5441 indep_processed = independent_decode_option (argc - i, argv + i,
5442 lang_processed);
5444 if (lang_processed || indep_processed)
5445 i += (lang_processed > indep_processed
5446 ? lang_processed : indep_processed);
5447 else
5449 const char * option = NULL;
5450 const char * lang = NULL;
5451 unsigned int j;
5453 /* It is possible that the command line switch is not valid for the
5454 current language, but it is valid for another language. In order
5455 to be compatible with previous versions of the compiler (which
5456 did not issue an error message in this case) we check for this
5457 possibilty here. If we do find a match, then if extra_warnings
5458 is set we generate a warning message, otherwise we will just
5459 ignore the option. */
5460 for (j = 0; j < NUM_ELEM (documented_lang_options); j++)
5462 option = documented_lang_options[j].option;
5464 if (option == NULL)
5465 lang = documented_lang_options[j].description;
5466 else if (! strncmp (argv[i], option, strlen (option)))
5467 break;
5470 if (option)
5472 if (extra_warnings)
5474 warning ("Ignoring command line option '%s'", argv[i]);
5475 if (lang)
5476 warning ("\
5477 (It is valid for %s but not the selected langauge)", lang);
5480 else
5481 error ("Unrecognised option `%s'", argv[i]);
5483 i++;
5487 /* Checker uses the frame pointer. */
5488 if (flag_check_memory_usage)
5489 flag_omit_frame_pointer = 0;
5491 if (optimize == 0)
5493 /* Inlining does not work if not optimizing,
5494 so force it not to be done. */
5495 flag_no_inline = 1;
5496 warn_inline = 0;
5498 /* The c_decode_option and lang_decode_option functions set
5499 this to `2' if -Wall is used, so we can avoid giving out
5500 lots of errors for people who don't realize what -Wall does. */
5501 if (warn_uninitialized == 1)
5502 warning ("-Wuninitialized is not supported without -O");
5505 #ifdef OVERRIDE_OPTIONS
5506 /* Some machines may reject certain combinations of options. */
5507 OVERRIDE_OPTIONS;
5508 #endif
5510 if (exceptions_via_longjmp == 2)
5512 #ifdef DWARF2_UNWIND_INFO
5513 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
5514 #else
5515 exceptions_via_longjmp = 1;
5516 #endif
5519 /* Set up the align_*_log variables, defaulting them to 1 if they
5520 were still unset. */
5521 if (align_loops <= 0) align_loops = 1;
5522 align_loops_log = floor_log2 (align_loops*2-1);
5523 if (align_jumps <= 0) align_jumps = 1;
5524 align_jumps_log = floor_log2 (align_jumps*2-1);
5525 if (align_labels <= 0) align_labels = 1;
5526 align_labels_log = floor_log2 (align_labels*2-1);
5527 if (align_functions <= 0) align_functions = 1;
5528 align_functions_log = floor_log2 (align_functions*2-1);
5530 if (profile_block_flag == 3)
5532 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
5533 profile_block_flag = 2;
5536 /* Unrolling all loops implies that standard loop unrolling must also
5537 be done. */
5538 if (flag_unroll_all_loops)
5539 flag_unroll_loops = 1;
5540 /* Loop unrolling requires that strength_reduction be on also. Silently
5541 turn on strength reduction here if it isn't already on. Also, the loop
5542 unrolling code assumes that cse will be run after loop, so that must
5543 be turned on also. */
5544 if (flag_unroll_loops)
5546 flag_strength_reduce = 1;
5547 flag_rerun_cse_after_loop = 1;
5550 /* Warn about options that are not supported on this machine. */
5551 #ifndef INSN_SCHEDULING
5552 if (flag_schedule_insns || flag_schedule_insns_after_reload)
5553 warning ("instruction scheduling not supported on this target machine");
5554 #endif
5555 #ifndef DELAY_SLOTS
5556 if (flag_delayed_branch)
5557 warning ("this target machine does not have delayed branches");
5558 #endif
5560 user_label_prefix = USER_LABEL_PREFIX;
5561 if (flag_leading_underscore != -1)
5563 /* If the default prefix is more complicated than "" or "_",
5564 issue a warning and ignore this option. */
5565 if (user_label_prefix[0] == 0 ||
5566 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5568 user_label_prefix = flag_leading_underscore ? "_" : "";
5570 else
5571 warning ("-f%sleading-underscore not supported on this target machine",
5572 flag_leading_underscore ? "" : "no-");
5575 /* If we are in verbose mode, write out the version and maybe all the
5576 option flags in use. */
5577 if (version_flag)
5579 print_version (stderr, "");
5580 if (! quiet_flag)
5581 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5584 compile_file (filename);
5586 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
5587 if (flag_print_mem)
5589 char *lim = (char *) sbrk (0);
5591 notice ("Data size %ld.\n", (long) (lim - (char *) &environ));
5592 fflush (stderr);
5594 #ifndef __MSDOS__
5595 #ifdef USG
5596 system ("ps -l 1>&2");
5597 #else /* not USG */
5598 system ("ps v");
5599 #endif /* not USG */
5600 #endif
5602 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
5604 if (errorcount)
5605 return (FATAL_EXIT_CODE);
5606 if (sorrycount)
5607 return (FATAL_EXIT_CODE);
5608 return (SUCCESS_EXIT_CODE);
5611 /* Decode -m switches. */
5612 /* Decode the switch -mNAME. */
5614 static void
5615 set_target_switch (name)
5616 const char *name;
5618 register size_t j;
5619 int valid_target_option = 0;
5621 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5622 if (!strcmp (target_switches[j].name, name))
5624 if (target_switches[j].value < 0)
5625 target_flags &= ~-target_switches[j].value;
5626 else
5627 target_flags |= target_switches[j].value;
5628 valid_target_option = 1;
5631 #ifdef TARGET_OPTIONS
5632 if (!valid_target_option)
5633 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5635 int len = strlen (target_options[j].prefix);
5636 if (!strncmp (target_options[j].prefix, name, len))
5638 *target_options[j].variable = name + len;
5639 valid_target_option = 1;
5642 #endif
5644 if (!valid_target_option)
5645 error ("Invalid option `%s'", name);
5648 /* Print version information to FILE.
5649 Each line begins with INDENT (for the case where FILE is the
5650 assembler output file). */
5652 static void
5653 print_version (file, indent)
5654 FILE *file;
5655 const char *indent;
5657 #ifndef __VERSION__
5658 #define __VERSION__ "[?]"
5659 #endif
5660 fnotice (file,
5661 #ifdef __GNUC__
5662 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
5663 #else
5664 "%s%s%s version %s (%s) compiled by CC.\n"
5665 #endif
5666 , indent, *indent != 0 ? " " : "",
5667 language_string, version_string, TARGET_NAME, __VERSION__);
5670 /* Print an option value and return the adjusted position in the line.
5671 ??? We don't handle error returns from fprintf (disk full); presumably
5672 other code will catch a disk full though. */
5674 static int
5675 print_single_switch (file, pos, max, indent, sep, term, type, name)
5676 FILE *file;
5677 int pos, max;
5678 const char *indent, *sep, *term, *type, *name;
5680 /* The ultrix fprintf returns 0 on success, so compute the result we want
5681 here since we need it for the following test. */
5682 int len = strlen (sep) + strlen (type) + strlen (name);
5684 if (pos != 0
5685 && pos + len > max)
5687 fprintf (file, "%s", term);
5688 pos = 0;
5690 if (pos == 0)
5692 fprintf (file, "%s", indent);
5693 pos = strlen (indent);
5695 fprintf (file, "%s%s%s", sep, type, name);
5696 pos += len;
5697 return pos;
5700 /* Print active target switches to FILE.
5701 POS is the current cursor position and MAX is the size of a "line".
5702 Each line begins with INDENT and ends with TERM.
5703 Each switch is separated from the next by SEP. */
5705 static void
5706 print_switch_values (file, pos, max, indent, sep, term)
5707 FILE *file;
5708 int pos, max;
5709 const char *indent, *sep, *term;
5711 size_t j;
5712 char **p;
5714 /* Print the options as passed. */
5716 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5717 _("options passed: "), "");
5719 for (p = &save_argv[1]; *p != NULL; p++)
5720 if (**p == '-')
5722 /* Ignore these. */
5723 if (strcmp (*p, "-o") == 0)
5725 if (p[1] != NULL)
5726 p++;
5727 continue;
5729 if (strcmp (*p, "-quiet") == 0)
5730 continue;
5731 if (strcmp (*p, "-version") == 0)
5732 continue;
5733 if ((*p)[1] == 'd')
5734 continue;
5736 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5738 if (pos > 0)
5739 fprintf (file, "%s", term);
5741 /* Print the -f and -m options that have been enabled.
5742 We don't handle language specific options but printing argv
5743 should suffice. */
5745 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5746 _("options enabled: "), "");
5748 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
5749 if (*f_options[j].variable == f_options[j].on_value)
5750 pos = print_single_switch (file, pos, max, indent, sep, term,
5751 "-f", f_options[j].string);
5753 /* Print target specific options. */
5755 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5756 if (target_switches[j].name[0] != '\0'
5757 && target_switches[j].value > 0
5758 && ((target_switches[j].value & target_flags)
5759 == target_switches[j].value))
5761 pos = print_single_switch (file, pos, max, indent, sep, term,
5762 "-m", target_switches[j].name);
5765 #ifdef TARGET_OPTIONS
5766 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5767 if (*target_options[j].variable != NULL)
5769 char prefix[256];
5770 sprintf (prefix, "-m%s", target_options[j].prefix);
5771 pos = print_single_switch (file, pos, max, indent, sep, term,
5772 prefix, *target_options[j].variable);
5774 #endif
5776 fprintf (file, "%s", term);
5779 /* Record the beginning of a new source file, named FILENAME. */
5781 void
5782 debug_start_source_file (filename)
5783 register char *filename ATTRIBUTE_UNUSED;
5785 #ifdef DBX_DEBUGGING_INFO
5786 if (write_symbols == DBX_DEBUG)
5787 dbxout_start_new_source_file (filename);
5788 #endif
5789 #ifdef DWARF_DEBUGGING_INFO
5790 if (debug_info_level == DINFO_LEVEL_VERBOSE
5791 && write_symbols == DWARF_DEBUG)
5792 dwarfout_start_new_source_file (filename);
5793 #endif /* DWARF_DEBUGGING_INFO */
5794 #ifdef DWARF2_DEBUGGING_INFO
5795 if (debug_info_level == DINFO_LEVEL_VERBOSE
5796 && write_symbols == DWARF2_DEBUG)
5797 dwarf2out_start_source_file (filename);
5798 #endif /* DWARF2_DEBUGGING_INFO */
5799 #ifdef SDB_DEBUGGING_INFO
5800 if (write_symbols == SDB_DEBUG)
5801 sdbout_start_new_source_file (filename);
5802 #endif
5805 /* Record the resumption of a source file. LINENO is the line number in
5806 the source file we are returning to. */
5808 void
5809 debug_end_source_file (lineno)
5810 register unsigned lineno ATTRIBUTE_UNUSED;
5812 #ifdef DBX_DEBUGGING_INFO
5813 if (write_symbols == DBX_DEBUG)
5814 dbxout_resume_previous_source_file ();
5815 #endif
5816 #ifdef DWARF_DEBUGGING_INFO
5817 if (debug_info_level == DINFO_LEVEL_VERBOSE
5818 && write_symbols == DWARF_DEBUG)
5819 dwarfout_resume_previous_source_file (lineno);
5820 #endif /* DWARF_DEBUGGING_INFO */
5821 #ifdef DWARF2_DEBUGGING_INFO
5822 if (debug_info_level == DINFO_LEVEL_VERBOSE
5823 && write_symbols == DWARF2_DEBUG)
5824 dwarf2out_end_source_file ();
5825 #endif /* DWARF2_DEBUGGING_INFO */
5826 #ifdef SDB_DEBUGGING_INFO
5827 if (write_symbols == SDB_DEBUG)
5828 sdbout_resume_previous_source_file ();
5829 #endif
5832 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5833 the tail part of the directive line, i.e. the part which is past the
5834 initial whitespace, #, whitespace, directive-name, whitespace part. */
5836 void
5837 debug_define (lineno, buffer)
5838 register unsigned lineno ATTRIBUTE_UNUSED;
5839 register char *buffer ATTRIBUTE_UNUSED;
5841 #ifdef DWARF_DEBUGGING_INFO
5842 if (debug_info_level == DINFO_LEVEL_VERBOSE
5843 && write_symbols == DWARF_DEBUG)
5844 dwarfout_define (lineno, buffer);
5845 #endif /* DWARF_DEBUGGING_INFO */
5846 #ifdef DWARF2_DEBUGGING_INFO
5847 if (debug_info_level == DINFO_LEVEL_VERBOSE
5848 && write_symbols == DWARF2_DEBUG)
5849 dwarf2out_define (lineno, buffer);
5850 #endif /* DWARF2_DEBUGGING_INFO */
5853 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5854 the tail part of the directive line, i.e. the part which is past the
5855 initial whitespace, #, whitespace, directive-name, whitespace part. */
5857 void
5858 debug_undef (lineno, buffer)
5859 register unsigned lineno ATTRIBUTE_UNUSED;
5860 register char *buffer ATTRIBUTE_UNUSED;
5862 #ifdef DWARF_DEBUGGING_INFO
5863 if (debug_info_level == DINFO_LEVEL_VERBOSE
5864 && write_symbols == DWARF_DEBUG)
5865 dwarfout_undef (lineno, buffer);
5866 #endif /* DWARF_DEBUGGING_INFO */
5867 #ifdef DWARF2_DEBUGGING_INFO
5868 if (debug_info_level == DINFO_LEVEL_VERBOSE
5869 && write_symbols == DWARF2_DEBUG)
5870 dwarf2out_undef (lineno, buffer);
5871 #endif /* DWARF2_DEBUGGING_INFO */