* toplev.c (rest_of_decl_compilation): Update comment.
[official-gcc.git] / gcc / toplev.c
blob55c48dab0069099213698c5dbc51a5e799ab90aa
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"
60 #ifdef DWARF_DEBUGGING_INFO
61 #include "dwarfout.h"
62 #endif
64 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
65 #include "dwarf2out.h"
66 #endif
68 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
69 #include "dbxout.h"
70 #endif
72 #ifdef SDB_DEBUGGING_INFO
73 #include "sdbout.h"
74 #endif
76 #ifdef XCOFF_DEBUGGING_INFO
77 #include "xcoffout.h"
78 #endif
80 #ifdef VMS
81 /* The extra parameters substantially improve the I/O performance. */
82 static FILE *
83 vms_fopen (fname, type)
84 char * fname;
85 char * type;
87 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
88 fixed arguments, which matches ANSI's specification but not VAXCRTL's
89 pre-ANSI implementation. This hack circumvents the mismatch problem. */
90 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
92 if (*type == 'w')
93 return (*vmslib_fopen) (fname, type, "mbc=32",
94 "deq=64", "fop=tef", "shr=nil");
95 else
96 return (*vmslib_fopen) (fname, type, "mbc=32");
98 #define fopen vms_fopen
99 #endif /* VMS */
101 #ifndef DEFAULT_GDB_EXTENSIONS
102 #define DEFAULT_GDB_EXTENSIONS 1
103 #endif
105 /* If more than one debugging type is supported, you must define
106 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
108 This is one long line cause VAXC can't handle a \-newline. */
109 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
110 #ifndef PREFERRED_DEBUGGING_TYPE
111 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
112 #endif /* no PREFERRED_DEBUGGING_TYPE */
113 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
114 so the following code needn't care. */
115 #ifdef DBX_DEBUGGING_INFO
116 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
117 #endif
118 #ifdef SDB_DEBUGGING_INFO
119 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
120 #endif
121 #ifdef DWARF_DEBUGGING_INFO
122 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
123 #endif
124 #ifdef DWARF2_DEBUGGING_INFO
125 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
126 #endif
127 #ifdef XCOFF_DEBUGGING_INFO
128 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
129 #endif
130 #endif /* More than one debugger format enabled. */
132 /* If still not defined, must have been because no debugging formats
133 are supported. */
134 #ifndef PREFERRED_DEBUGGING_TYPE
135 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
136 #endif
138 #ifndef DIR_SEPARATOR
139 #define DIR_SEPARATOR '/'
140 #endif
142 #if ! (defined (VMS) || defined (OS2))
143 extern char **environ;
144 #endif
145 extern char *version_string;
147 /* Carry information from ASM_DECLARE_OBJECT_NAME
148 to ASM_FINISH_DECLARE_OBJECT. */
150 extern int size_directive_output;
151 extern tree last_assemble_variable_decl;
153 static void notice PVPROTO((const char *s, ...)) ATTRIBUTE_PRINTF_1;
154 static void set_target_switch PROTO((const char *));
155 static const char *decl_name PROTO((tree, int));
156 static void vmessage PROTO((const char *, const char *, va_list));
157 static void v_message_with_file_and_line PROTO((const char *, int, int,
158 const char *, va_list));
159 static void v_message_with_decl PROTO((tree, int, const char *, va_list));
160 static void file_and_line_for_asm PROTO((rtx, char **, int *));
161 static void v_error_with_file_and_line PROTO((const char *, int,
162 const char *, va_list));
163 static void v_error_with_decl PROTO((tree, const char *, va_list));
164 static void v_error_for_asm PROTO((rtx, const char *, va_list));
165 static void verror PROTO((const char *, va_list));
166 static void vfatal PROTO((const char *, va_list)) ATTRIBUTE_NORETURN;
167 static void v_warning_with_file_and_line PROTO ((const char *, int,
168 const char *, va_list));
169 static void v_warning_with_decl PROTO((tree, const char *, va_list));
170 static void v_warning_for_asm PROTO((rtx, const char *, va_list));
171 static void vwarning PROTO((const char *, va_list));
172 static void vpedwarn PROTO((const char *, va_list));
173 static void v_pedwarn_with_decl PROTO((tree, const char *, va_list));
174 static void v_pedwarn_with_file_and_line PROTO((const char *, int,
175 const char *, va_list));
176 static void vsorry PROTO((const char *, va_list));
177 extern void set_fatal_function PROTO((void (*)(const char *, va_list)));
178 static void float_signal PROTO((int)) ATTRIBUTE_NORETURN;
179 static void pipe_closed PROTO((int)) ATTRIBUTE_NORETURN;
180 #ifdef ASM_IDENTIFY_LANGUAGE
181 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
182 static void output_lang_identify PROTO((FILE *)) ATTRIBUTE_UNUSED;
183 #endif
184 static void open_dump_file PROTO((const char *, const char *));
185 static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
186 static void dump_rtl PROTO((const char *, tree, void (*) (FILE *, rtx), rtx));
187 static void clean_dump_file PROTO((const char *));
188 static void compile_file PROTO((char *));
189 static void display_help PROTO ((void));
190 static void report_file_and_line PROTO ((const char *, int, int));
191 static void vnotice PROTO ((FILE *, const char *, va_list));
192 static void mark_file_stack PROTO ((void *));
194 static void decode_d_option PROTO ((const char *));
195 static int decode_f_option PROTO ((const char *));
196 static int decode_W_option PROTO ((const char *));
197 static int decode_g_option PROTO ((const char *));
198 static unsigned independent_decode_option PROTO ((int, char **, unsigned));
200 static void print_version PROTO((FILE *, const char *));
201 static int print_single_switch PROTO((FILE *, int, int, const char *,
202 const char *, const char *,
203 const char *, const char *));
204 static void print_switch_values PROTO((FILE *, int, int, const char *,
205 const char *, const char *));
207 void print_rtl_graph_with_bb PROTO ((const char *, const char *, rtx));
208 void clean_graph_dump_file PROTO ((const char *, const char *));
209 void finish_graph_dump_file PROTO ((const char *, const char *));
210 /* Length of line when printing switch values. */
211 #define MAX_LINE 75
213 /* Name of program invoked, sans directories. */
215 const char *progname;
217 /* Copy of arguments to main. */
218 int save_argc;
219 char **save_argv;
221 /* Name of current original source file (what was input to cpp).
222 This comes from each #-command in the actual input. */
224 char *input_filename;
226 /* Name of top-level original source file (what was input to cpp).
227 This comes from the #-command at the beginning of the actual input.
228 If there isn't any there, then this is the cc1 input file name. */
230 char *main_input_filename;
232 /* Current line number in real source file. */
234 int lineno;
236 /* Nonzero if it is unsafe to create any new pseudo registers. */
237 int no_new_pseudos;
239 /* Stack of currently pending input files. */
241 struct file_stack *input_file_stack;
243 /* Incremented on each change to input_file_stack. */
244 int input_file_stack_tick;
246 /* Name to use as base of names for dump output files. */
248 const char *dump_base_name;
250 /* Bit flags that specify the machine subtype we are compiling for.
251 Bits are tested using macros TARGET_... defined in the tm.h file
252 and set by `-m...' switches. Must be defined in rtlanal.c. */
254 extern int target_flags;
256 /* Flags saying which kinds of debugging dump have been requested. */
258 int rtl_dump = 0;
259 int rtl_dump_and_exit = 0;
260 int jump_opt_dump = 0;
261 int addressof_dump = 0;
262 int cse_dump = 0;
263 int gcse_dump = 0;
264 int loop_dump = 0;
265 int cse2_dump = 0;
266 int branch_prob_dump = 0;
267 int flow_dump = 0;
268 int combine_dump = 0;
269 int regmove_dump = 0;
270 int sched_dump = 0;
271 int local_reg_dump = 0;
272 int global_reg_dump = 0;
273 int flow2_dump = 0;
274 int peephole2_dump = 0;
275 int sched2_dump = 0;
276 int jump2_opt_dump = 0;
277 #ifdef DELAY_SLOTS
278 int dbr_sched_dump = 0;
279 #endif
280 int flag_print_asm_name = 0;
281 #ifdef STACK_REGS
282 int stack_reg_dump = 0;
283 #endif
284 #ifdef MACHINE_DEPENDENT_REORG
285 int mach_dep_reorg_dump = 0;
286 #endif
287 static int flag_print_mem = 0;
288 static int version_flag = 0;
289 static char * filename = 0;
290 enum graph_dump_types graph_dump_format;
292 /* Name for output file of assembly code, specified with -o. */
294 char *asm_file_name;
296 /* Value of the -G xx switch, and whether it was passed or not. */
297 int g_switch_value;
298 int g_switch_set;
300 /* Type(s) of debugging information we are producing (if any).
301 See flags.h for the definitions of the different possible
302 types of debugging information. */
303 enum debug_info_type write_symbols = NO_DEBUG;
305 /* Level of debugging information we are producing. See flags.h
306 for the definitions of the different possible levels. */
307 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
309 /* Nonzero means use GNU-only extensions in the generated symbolic
310 debugging information. */
311 /* Currently, this only has an effect when write_symbols is set to
312 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
313 int use_gnu_debug_info_extensions = 0;
315 /* Nonzero means do optimizations. -O.
316 Particular numeric values stand for particular amounts of optimization;
317 thus, -O2 stores 2 here. However, the optimizations beyond the basic
318 ones are not controlled directly by this variable. Instead, they are
319 controlled by individual `flag_...' variables that are defaulted
320 based on this variable. */
322 int optimize = 0;
324 /* Nonzero means optimize for size. -Os.
325 The only valid values are zero and non-zero. When optimize_size is
326 non-zero, optimize defaults to 2, but certain individual code
327 bloating optimizations are disabled. */
329 int optimize_size = 0;
331 /* Number of error messages and warning messages so far. */
333 int errorcount = 0;
334 int warningcount = 0;
335 int sorrycount = 0;
337 /* Pointer to function to compute the name to use to print a declaration.
338 DECL is the declaration in question.
339 VERBOSITY determines what information will be printed:
340 0: DECL_NAME, demangled as necessary.
341 1: and scope information.
342 2: and any other information that might be interesting, such as function
343 parameter types in C++. */
345 const char *(*decl_printable_name) PROTO ((tree, int));
347 /* Pointer to function to compute rtl for a language-specific tree code. */
349 typedef rtx (*lang_expand_expr_t)
350 PROTO ((union tree_node *, rtx, enum machine_mode,
351 enum expand_modifier modifier));
353 lang_expand_expr_t lang_expand_expr = 0;
355 tree (*lang_expand_constant) PROTO((tree)) = 0;
357 /* Pointer to function to finish handling an incomplete decl at the
358 end of compilation. */
360 void (*incomplete_decl_finalize_hook) PROTO((tree)) = 0;
362 /* Nonzero if generating code to do profiling. */
364 int profile_flag = 0;
366 /* Nonzero if generating code to do profiling on a line-by-line basis. */
368 int profile_block_flag;
370 /* Nonzero if generating code to profile program flow graph arcs. */
372 int profile_arc_flag = 0;
374 /* Nonzero if generating info for gcov to calculate line test coverage. */
376 int flag_test_coverage = 0;
378 /* Nonzero indicates that branch taken probabilities should be calculated. */
380 int flag_branch_probabilities = 0;
382 /* Nonzero for -pedantic switch: warn about anything
383 that standard spec forbids. */
385 int pedantic = 0;
387 /* Temporarily suppress certain warnings.
388 This is set while reading code from a system header file. */
390 int in_system_header = 0;
392 /* Nonzero means do stupid register allocation.
393 Currently, this is 1 if `optimize' is 0. */
395 int obey_regdecls = 0;
397 /* Don't print functions as they are compiled and don't print
398 times taken by the various passes. -quiet. */
400 int quiet_flag = 0;
402 /* -f flags. */
404 /* Nonzero means `char' should be signed. */
406 int flag_signed_char;
408 /* Nonzero means give an enum type only as many bytes as it needs. */
410 int flag_short_enums;
412 /* Nonzero for -fcaller-saves: allocate values in regs that need to
413 be saved across function calls, if that produces overall better code.
414 Optional now, so people can test it. */
416 #ifdef DEFAULT_CALLER_SAVES
417 int flag_caller_saves = 1;
418 #else
419 int flag_caller_saves = 0;
420 #endif
422 /* Nonzero if structures and unions should be returned in memory.
424 This should only be defined if compatibility with another compiler or
425 with an ABI is needed, because it results in slower code. */
427 #ifndef DEFAULT_PCC_STRUCT_RETURN
428 #define DEFAULT_PCC_STRUCT_RETURN 1
429 #endif
431 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
433 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
435 /* Nonzero for -fforce-mem: load memory value into a register
436 before arithmetic on it. This makes better cse but slower compilation. */
438 int flag_force_mem = 0;
440 /* Nonzero for -fforce-addr: load memory address into a register before
441 reference to memory. This makes better cse but slower compilation. */
443 int flag_force_addr = 0;
445 /* Nonzero for -fdefer-pop: don't pop args after each function call;
446 instead save them up to pop many calls' args with one insns. */
448 int flag_defer_pop = 0;
450 /* Nonzero for -ffloat-store: don't allocate floats and doubles
451 in extended-precision registers. */
453 int flag_float_store = 0;
455 /* Nonzero for -fcse-follow-jumps:
456 have cse follow jumps to do a more extensive job. */
458 int flag_cse_follow_jumps;
460 /* Nonzero for -fcse-skip-blocks:
461 have cse follow a branch around a block. */
462 int flag_cse_skip_blocks;
464 /* Nonzero for -fexpensive-optimizations:
465 perform miscellaneous relatively-expensive optimizations. */
466 int flag_expensive_optimizations;
468 /* Nonzero for -fthread-jumps:
469 have jump optimize output of loop. */
471 int flag_thread_jumps;
473 /* Nonzero enables strength-reduction in loop.c. */
475 int flag_strength_reduce = 0;
477 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
478 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
479 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
480 unrolled. */
482 int flag_unroll_loops;
484 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
485 This is generally not a win. */
487 int flag_unroll_all_loops;
489 /* Nonzero forces all invariant computations in loops to be moved
490 outside the loop. */
492 int flag_move_all_movables = 0;
494 /* Nonzero forces all general induction variables in loops to be
495 strength reduced. */
497 int flag_reduce_all_givs = 0;
499 /* Nonzero to perform full register move optimization passes. This is the
500 default for -O2. */
502 int flag_regmove = 0;
504 /* Nonzero for -fwritable-strings:
505 store string constants in data segment and don't uniquize them. */
507 int flag_writable_strings = 0;
509 /* Nonzero means don't put addresses of constant functions in registers.
510 Used for compiling the Unix kernel, where strange substitutions are
511 done on the assembly output. */
513 int flag_no_function_cse = 0;
515 /* Nonzero for -fomit-frame-pointer:
516 don't make a frame pointer in simple functions that don't require one. */
518 int flag_omit_frame_pointer = 0;
520 /* Nonzero means place each function into its own section on those platforms
521 which support arbitrary section names and unlimited numbers of sections. */
523 int flag_function_sections = 0;
525 /* ... and similar for data. */
527 int flag_data_sections = 0;
529 /* Nonzero to inhibit use of define_optimization peephole opts. */
531 int flag_no_peephole = 0;
533 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
534 operations in the interest of optimization. For example it allows
535 GCC to assume arguments to sqrt are nonnegative numbers, allowing
536 faster code for sqrt to be generated. */
538 int flag_fast_math = 0;
540 /* Nonzero means the front end generally wants `errno' maintained by math
541 operations, like built-in SQRT, unless overridden by flag_fast_math. */
543 int flag_errno_math = 1;
545 /* 0 means straightforward implementation of complex divide acceptable.
546 1 means wide ranges of inputs must work for complex divide.
547 2 means C9X-like requirements for complex divide (not yet implemented). */
549 int flag_complex_divide_method = 0;
551 /* Nonzero means all references through pointers are volatile. */
553 int flag_volatile;
555 /* Nonzero means treat all global and extern variables as volatile. */
557 int flag_volatile_global;
559 /* Nonzero means treat all static variables as volatile. */
561 int flag_volatile_static;
563 /* Nonzero means just do syntax checking; don't output anything. */
565 int flag_syntax_only = 0;
567 /* Nonzero means perform global cse. */
569 static int flag_gcse;
571 /* Nonzero means to use global dataflow analysis to eliminate
572 useless null pointer tests. */
574 static int flag_delete_null_pointer_checks;
576 /* Nonzero means to rerun cse after loop optimization. This increases
577 compilation time about 20% and picks up a few more common expressions. */
579 static int flag_rerun_cse_after_loop;
581 /* Nonzero means to run loop optimizations twice. */
583 int flag_rerun_loop_opt;
585 /* Nonzero for -finline-functions: ok to inline functions that look like
586 good inline candidates. */
588 int flag_inline_functions;
590 /* Nonzero for -fkeep-inline-functions: even if we make a function
591 go inline everywhere, keep its definition around for debugging
592 purposes. */
594 int flag_keep_inline_functions;
596 /* Nonzero means that functions will not be inlined. */
598 int flag_no_inline;
600 /* Nonzero means that we should emit static const variables
601 regardless of whether or not optimization is turned on. */
603 int flag_keep_static_consts = 1;
605 /* Nonzero means we should be saving declaration info into a .X file. */
607 int flag_gen_aux_info = 0;
609 /* Specified name of aux-info file. */
611 static char *aux_info_file_name;
613 /* Nonzero means make the text shared if supported. */
615 int flag_shared_data;
617 /* Nonzero means schedule into delayed branch slots if supported. */
619 int flag_delayed_branch;
621 /* Nonzero if we are compiling pure (sharable) code.
622 Value is 1 if we are doing reasonable (i.e. simple
623 offset into offset table) pic. Value is 2 if we can
624 only perform register offsets. */
626 int flag_pic;
628 /* Nonzero means generate extra code for exception handling and enable
629 exception handling. */
631 int flag_exceptions;
633 /* Nonzero means use the new model for exception handling. Replaces
634 -DNEW_EH_MODEL as a compile option. */
636 int flag_new_exceptions = 1;
638 /* Nonzero means don't place uninitialized global data in common storage
639 by default. */
641 int flag_no_common;
643 /* Nonzero means pretend it is OK to examine bits of target floats,
644 even if that isn't true. The resulting code will have incorrect constants,
645 but the same series of instructions that the native compiler would make. */
647 int flag_pretend_float;
649 /* Nonzero means change certain warnings into errors.
650 Usually these are warnings about failure to conform to some standard. */
652 int flag_pedantic_errors = 0;
654 /* flag_schedule_insns means schedule insns within basic blocks (before
655 local_alloc).
656 flag_schedule_insns_after_reload means schedule insns after
657 global_alloc. */
659 int flag_schedule_insns = 0;
660 int flag_schedule_insns_after_reload = 0;
662 /* The following flags have effect only for scheduling before register
663 allocation:
665 flag_schedule_interblock means schedule insns accross basic blocks.
666 flag_schedule_speculative means allow speculative motion of non-load insns.
667 flag_schedule_speculative_load means allow speculative motion of some
668 load insns.
669 flag_schedule_speculative_load_dangerous allows speculative motion of more
670 load insns. */
672 int flag_schedule_interblock = 1;
673 int flag_schedule_speculative = 1;
674 int flag_schedule_speculative_load = 0;
675 int flag_schedule_speculative_load_dangerous = 0;
677 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
678 by a cheaper branch, on a count register. */
679 int flag_branch_on_count_reg;
681 /* -finhibit-size-directive inhibits output of .size for ELF.
682 This is used only for compiling crtstuff.c,
683 and it may be extended to other effects
684 needed for crtstuff.c on other systems. */
685 int flag_inhibit_size_directive = 0;
687 /* -fverbose-asm causes extra commentary information to be produced in
688 the generated assembly code (to make it more readable). This option
689 is generally only of use to those who actually need to read the
690 generated assembly code (perhaps while debugging the compiler itself).
691 -fno-verbose-asm, the default, causes the extra information
692 to be omitted and is useful when comparing two assembler files. */
694 int flag_verbose_asm = 0;
696 /* -dA causes debug commentary information to be produced in
697 the generated assembly code (to make it more readable). This option
698 is generally only of use to those who actually need to read the
699 generated assembly code (perhaps while debugging the compiler itself).
700 Currently, this switch is only used by dwarfout.c; however, it is intended
701 to be a catchall for printing debug information in the assembler file. */
703 int flag_debug_asm = 0;
705 /* -fgnu-linker specifies use of the GNU linker for initializations.
706 (Or, more generally, a linker that handles initializations.)
707 -fno-gnu-linker says that collect2 will be used. */
708 #ifdef USE_COLLECT2
709 int flag_gnu_linker = 0;
710 #else
711 int flag_gnu_linker = 1;
712 #endif
714 /* Tag all structures with __attribute__(packed) */
715 int flag_pack_struct = 0;
717 /* Emit code to check for stack overflow; also may cause large objects
718 to be allocated dynamically. */
719 int flag_stack_check;
721 /* -fcheck-memory-usage causes extra code to be generated in order to check
722 memory accesses. This is used by a detector of bad memory accesses such
723 as Checker. */
724 int flag_check_memory_usage = 0;
726 /* -fprefix-function-name causes function name to be prefixed. This
727 can be used with -fcheck-memory-usage to isolate code compiled with
728 -fcheck-memory-usage. */
729 int flag_prefix_function_name = 0;
731 /* 0 if pointer arguments may alias each other. True in C.
732 1 if pointer arguments may not alias each other but may alias
733 global variables.
734 2 if pointer arguments may not alias each other and may not
735 alias global variables. True in Fortran.
736 This defaults to 0 for C. */
737 int flag_argument_noalias = 0;
739 /* Nonzero if we should do (language-dependent) alias analysis.
740 Typically, this analysis will assume that expressions of certain
741 types do not alias expressions of certain other types. Only used
742 if alias analysis (in general) is enabled. */
743 int flag_strict_aliasing = 0;
745 /* Instrument functions with calls at entry and exit, for profiling. */
746 int flag_instrument_function_entry_exit = 0;
748 /* Nonzero means ignore `#ident' directives. 0 means handle them.
749 On SVR4 targets, it also controls whether or not to emit a
750 string identifying the compiler. */
752 int flag_no_ident = 0;
754 /* This will perform a peephole pass before sched2. */
755 int flag_peephole2 = 0;
757 /* Values of the -falign-* flags: how much to align labels in code.
758 0 means `use default', 1 means `don't align'.
759 For each variable, there is an _log variant which is the power
760 of two not less than the variable, for .align output. */
762 int align_loops;
763 int align_loops_log;
764 int align_jumps;
765 int align_jumps_log;
766 int align_labels;
767 int align_labels_log;
768 int align_functions;
769 int align_functions_log;
771 /* Table of supported debugging formats. */
772 static struct
774 const char * arg;
775 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
776 constant expression, we use NO_DEBUG in its place. */
777 enum debug_info_type debug_type;
778 int use_extensions_p;
779 const char * description;
780 } *da,
781 debug_args[] =
783 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
784 "Generate default debug format output" },
785 { "gdb", NO_DEBUG, 1, "Generate default extended debug format output" },
786 #ifdef DBX_DEBUGGING_INFO
787 { "stabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
788 { "stabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
789 #endif
790 #ifdef DWARF_DEBUGGING_INFO
791 { "dwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
792 { "dwarf+", DWARF_DEBUG, 1,
793 "Generated extended DWARF-1 format debug output" },
794 #endif
795 #ifdef DWARF2_DEBUGGING_INFO
796 { "dwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
797 #endif
798 #ifdef XCOFF_DEBUGGING_INFO
799 { "xcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
800 { "xcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
801 #endif
802 #ifdef SDB_DEBUGGING_INFO
803 { "coff", SDB_DEBUG, 0, "Generate COFF format debug output" },
804 #endif
805 { 0, 0, 0, 0 }
808 typedef struct
810 const char * string;
811 int * variable;
812 int on_value;
813 const char * description;
815 lang_independent_options;
817 /* Add or remove a leading underscore from user symbols. */
818 int flag_leading_underscore = -1;
820 /* The user symbol prefix after having resolved same. */
821 const char *user_label_prefix;
823 /* A default for same. */
824 #ifndef USER_LABEL_PREFIX
825 #define USER_LABEL_PREFIX ""
826 #endif
828 /* Table of language-independent -f options.
829 STRING is the option name. VARIABLE is the address of the variable.
830 ON_VALUE is the value to store in VARIABLE
831 if `-fSTRING' is seen as an option.
832 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
834 lang_independent_options f_options[] =
836 {"float-store", &flag_float_store, 1,
837 "Do not store floats in registers" },
838 {"volatile", &flag_volatile, 1,
839 "Consider all mem refs through pointers as volatile"},
840 {"volatile-global", &flag_volatile_global, 1,
841 "Consider all mem refs to global data to be volatile" },
842 {"volatile-static", &flag_volatile_static, 1,
843 "Consider all mem refs to static data to be volatile" },
844 {"defer-pop", &flag_defer_pop, 1,
845 "Defer popping functions args from stack until later" },
846 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
847 "When possible do not generate stack frames"},
848 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
849 "When running CSE, follow jumps to their targets" },
850 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
851 "When running CSE, follow conditional jumps" },
852 {"expensive-optimizations", &flag_expensive_optimizations, 1,
853 "Perform a number of minor, expensive optimisations" },
854 {"thread-jumps", &flag_thread_jumps, 1,
855 "Perform jump threading optimisations"},
856 {"strength-reduce", &flag_strength_reduce, 1,
857 "Perform strength reduction optimisations" },
858 {"unroll-loops", &flag_unroll_loops, 1,
859 "Perform loop unrolling when iteration count is known" },
860 {"unroll-all-loops", &flag_unroll_all_loops, 1,
861 "Perform loop unrolling for all loops" },
862 {"move-all-movables", &flag_move_all_movables, 1,
863 "Force all loop invariant computations out of loops" },
864 {"reduce-all-givs", &flag_reduce_all_givs, 1,
865 "Strength reduce all loop general induction variables" },
866 {"writable-strings", &flag_writable_strings, 1,
867 "Store strings in writable data section" },
868 {"peephole", &flag_no_peephole, 0,
869 "Enable machine specific peephole optimisations" },
870 {"force-mem", &flag_force_mem, 1,
871 "Copy memory operands into registers before using" },
872 {"force-addr", &flag_force_addr, 1,
873 "Copy memory address constants into regs before using" },
874 {"function-cse", &flag_no_function_cse, 0,
875 "Allow function addresses to be held in registers" },
876 {"inline-functions", &flag_inline_functions, 1,
877 "Integrate simple functions into their callers" },
878 {"keep-inline-functions", &flag_keep_inline_functions, 1,
879 "Generate code for funcs even if they are fully inlined" },
880 {"inline", &flag_no_inline, 0,
881 "Pay attention to the 'inline' keyword"},
882 {"keep-static-consts", &flag_keep_static_consts, 1,
883 "Emit static const variables even if they are not used" },
884 {"syntax-only", &flag_syntax_only, 1,
885 "Check for syntax errors, then stop" },
886 {"shared-data", &flag_shared_data, 1,
887 "Mark data as shared rather than private" },
888 {"caller-saves", &flag_caller_saves, 1,
889 "Enable saving registers around function calls" },
890 {"pcc-struct-return", &flag_pcc_struct_return, 1,
891 "Return 'short' aggregates in memory, not registers" },
892 {"reg-struct-return", &flag_pcc_struct_return, 0,
893 "Return 'short' aggregates in registers" },
894 {"delayed-branch", &flag_delayed_branch, 1,
895 "Attempt to fill delay slots of branch instructions" },
896 {"gcse", &flag_gcse, 1,
897 "Perform the global common subexpression elimination" },
898 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
899 "Run CSE pass after loop optimisations"},
900 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
901 "Run the loop optimiser twice"},
902 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
903 "Delete useless null pointer checks" },
904 {"pretend-float", &flag_pretend_float, 1,
905 "Pretend that host and target use the same FP format"},
906 {"schedule-insns", &flag_schedule_insns, 1,
907 "Reschedule instructions to avoid pipeline stalls"},
908 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
909 "Run two passes of the instruction scheduler"},
910 {"sched-interblock",&flag_schedule_interblock, 1,
911 "Enable scheduling across basic blocks" },
912 {"sched-spec",&flag_schedule_speculative, 1,
913 "Allow speculative motion of non-loads" },
914 {"sched-spec-load",&flag_schedule_speculative_load, 1,
915 "Allow speculative motion of some loads" },
916 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
917 "Allow speculative motion of more loads" },
918 {"branch-count-reg",&flag_branch_on_count_reg, 1,
919 "Replace add,compare,branch with branch on count reg"},
920 {"pic", &flag_pic, 1,
921 "Generate position independent code, if possible"},
922 {"PIC", &flag_pic, 2, ""},
923 {"exceptions", &flag_exceptions, 1,
924 "Enable exception handling" },
925 {"new-exceptions", &flag_new_exceptions, 1,
926 "Use the new model for exception handling" },
927 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
928 "Use setjmp/longjmp to handle exceptions" },
929 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
930 "Support asynchronous exceptions" },
931 {"profile-arcs", &profile_arc_flag, 1,
932 "Insert arc based program profiling code" },
933 {"test-coverage", &flag_test_coverage, 1,
934 "Create data files needed by gcov" },
935 {"branch-probabilities", &flag_branch_probabilities, 1,
936 "Use profiling information for branch probabilities" },
937 {"fast-math", &flag_fast_math, 1,
938 "Improve FP speed by violating ANSI & IEEE rules" },
939 {"common", &flag_no_common, 0,
940 "Do not put unitialised globals in the common section" },
941 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
942 "Do not generate .size directives" },
943 {"function-sections", &flag_function_sections, 1,
944 "place each function into its own section" },
945 {"data-sections", &flag_data_sections, 1,
946 "place data items into their own section" },
947 {"verbose-asm", &flag_verbose_asm, 1,
948 "Add extra commentry to assembler output"},
949 {"gnu-linker", &flag_gnu_linker, 1,
950 "Output GNU ld formatted global initialisers"},
951 {"regmove", &flag_regmove, 1,
952 "Enables a register move optimisation"},
953 {"optimize-register-move", &flag_regmove, 1,
954 "Do the full regmove optimization pass"},
955 {"pack-struct", &flag_pack_struct, 1,
956 "Pack structure members together without holes" },
957 {"stack-check", &flag_stack_check, 1,
958 "Insert stack checking code into the program" },
959 {"argument-alias", &flag_argument_noalias, 0,
960 "Specify that arguments may alias each other & globals"},
961 {"argument-noalias", &flag_argument_noalias, 1,
962 "Assume arguments may alias globals but not each other"},
963 {"argument-noalias-global", &flag_argument_noalias, 2,
964 "Assume arguments do not alias each other or globals" },
965 {"strict-aliasing", &flag_strict_aliasing, 1,
966 "Assume strict aliasing rules apply" },
967 {"align-loops", &align_loops, 0,
968 "Align the start of loops" },
969 {"align-jumps", &align_jumps, 0,
970 "Align labels which are only reached by jumping" },
971 {"align-labels", &align_labels, 0,
972 "Align all labels" },
973 {"align-functions", &align_functions, 0,
974 "Align the start of functions" },
975 {"check-memory-usage", &flag_check_memory_usage, 1,
976 "Generate code to check every memory access" },
977 {"prefix-function-name", &flag_prefix_function_name, 1,
978 "Add a prefix to all function names" },
979 {"dump-unnumbered", &flag_dump_unnumbered, 1,
980 "Suppress output of instruction numbers and line number notes in debugging dumps"},
981 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
982 "Instrument function entry/exit with profiling calls"},
983 {"leading-underscore", &flag_leading_underscore, 1,
984 "External symbols have a leading underscore" },
985 {"ident", &flag_no_ident, 0,
986 "Process #ident directives"},
987 { "peephole2", &flag_peephole2, 1,
988 "Enables an rtl peephole pass run before sched2" },
989 {"math-errno", &flag_errno_math, 1,
990 "Set errno after built-in math functions"}
993 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
995 /* Table of language-specific options. */
997 static struct lang_opt
999 const char * option;
1000 const char * description;
1002 documented_lang_options[] =
1004 /* In order not to overload the --help output, the convention
1005 used here is to only describe those options which are not
1006 enabled by default. */
1008 { "-ansi", "Compile just for ANSI C" },
1009 { "-fallow-single-precision",
1010 "Do not promote floats to double if using -traditional" },
1011 { "-std= ", "Determine language standard"},
1013 { "-fsigned-bitfields", "" },
1014 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1015 { "-fno-signed-bitfields", "" },
1016 { "-fno-unsigned-bitfields","" },
1017 { "-fsigned-char", "Make 'char' be signed by default"},
1018 { "-funsigned-char", "Make 'char' be unsigned by default"},
1019 { "-fno-signed-char", "" },
1020 { "-fno-unsigned-char", "" },
1022 { "-ftraditional", "" },
1023 { "-traditional", "Attempt to support traditional K&R style C"},
1024 { "-fnotraditional", "" },
1025 { "-fno-traditional", "" },
1027 { "-fasm", "" },
1028 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1029 { "-fbuiltin", "" },
1030 { "-fno-builtin", "Do not recognise any built in functions" },
1031 { "-fhosted", "Assume normal C execution environment" },
1032 { "-fno-hosted", "" },
1033 { "-ffreestanding",
1034 "Assume that standard libraries & main might not exist" },
1035 { "-fno-freestanding", "" },
1036 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1037 { "-fno-cond-mismatch", "" },
1038 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1039 { "-fno-dollars-in-identifiers", "" },
1040 { "-fpreprocessed", "" },
1041 { "-fno-preprocessed", "" },
1042 { "-fshort-double", "Use the same size for double as for float" },
1043 { "-fno-short-double", "" },
1044 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1045 { "-fno-short-enums", "" },
1046 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1047 { "-fno-short-wchar", "" },
1049 { "-Wall", "Enable most warning messages" },
1050 { "-Wbad-function-cast",
1051 "Warn about casting functions to incompatible types" },
1052 { "-Wno-bad-function-cast", "" },
1053 { "-Wmissing-noreturn",
1054 "Warn about functions which might be candidates for attribute noreturn" },
1055 { "-Wno-missing-noreturn", "" },
1056 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1057 { "-Wno-cast-qual", "" },
1058 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1059 { "-Wno-char-subscripts", "" },
1060 { "-Wcomment", "Warn if nested comments are detected" },
1061 { "-Wno-comment", "" },
1062 { "-Wcomments", "Warn if nested comments are detected" },
1063 { "-Wno-comments", "" },
1064 { "-Wconversion", "Warn about possibly confusing type conversions" },
1065 { "-Wno-conversion", "" },
1066 { "-Wformat", "Warn about printf format anomalies" },
1067 { "-Wno-format", "" },
1068 { "-Wimplicit-function-declaration",
1069 "Warn about implicit function declarations" },
1070 { "-Wno-implicit-function-declaration", "" },
1071 { "-Werror-implicit-function-declaration", "" },
1072 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1073 { "-Wno-implicit-int", "" },
1074 { "-Wimplicit", "" },
1075 { "-Wno-implicit", "" },
1076 { "-Wimport", "Warn about the use of the #import directive" },
1077 { "-Wno-import", "" },
1078 { "-Wlong-long","" },
1079 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1080 { "-Wmain", "Warn about suspicious declarations of main" },
1081 { "-Wno-main", "" },
1082 { "-Wmissing-braces",
1083 "Warn about possibly missing braces around initialisers" },
1084 { "-Wno-missing-braces", "" },
1085 { "-Wmissing-declarations",
1086 "Warn about global funcs without previous declarations"},
1087 { "-Wno-missing-declarations", "" },
1088 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1089 { "-Wno-missing-prototypes", "" },
1090 { "-Wmultichar", "Warn about use of multicharacter literals"},
1091 { "-Wno-multichar", "" },
1092 { "-Wnested-externs", "Warn about externs not at file scope level" },
1093 { "-Wno-nested-externs", "" },
1094 { "-Wparentheses", "Warn about possible missing parentheses" },
1095 { "-Wno-parentheses", "" },
1096 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1097 { "-Wno-pointer-arith", "" },
1098 { "-Wredundant-decls",
1099 "Warn about multiple declarations of the same object" },
1100 { "-Wno-redundant-decls", "" },
1101 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1102 { "-Wno-sign-compare", "" },
1103 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1104 { "-Wno-unknown-pragmas", "" },
1105 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1106 { "-Wno-strict-prototypes", "" },
1107 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1108 { "-Wno-traditional", "" },
1109 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1110 { "-Wno-trigraphs", "" },
1111 { "-Wundef", "" },
1112 { "-Wno-undef", "" },
1113 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1114 { "-Wno-write-strings", "" },
1116 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1118 /* These are for Objective C. */
1119 DEFINE_LANG_NAME ("Objective C")
1121 { "-lang-objc", "" },
1122 { "-gen-decls", "Dump decls to a .decl file" },
1123 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1124 { "-fno-gnu-runtime", "" },
1125 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1126 { "-fno-next-runtime", "" },
1127 { "-Wselector", "Warn if a selector has multiple methods" },
1128 { "-Wno-selector", "" },
1129 { "-Wprotocol", "" },
1130 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1131 { "-print-objc-runtime-info",
1132 "Generate C header of platform specific features" },
1134 #include "options.h"
1138 /* Here is a table, controlled by the tm.h file, listing each -m switch
1139 and which bits in `target_switches' it should set or clear.
1140 If VALUE is positive, it is bits to set.
1141 If VALUE is negative, -VALUE is bits to clear.
1142 (The sign bit is not used so there is no confusion.) */
1144 struct
1146 const char * name;
1147 int value;
1148 const char * description;
1150 target_switches [] = TARGET_SWITCHES;
1152 /* This table is similar, but allows the switch to have a value. */
1154 #ifdef TARGET_OPTIONS
1155 struct
1157 const char * prefix;
1158 const char ** variable;
1159 const char * description;
1161 target_options [] = TARGET_OPTIONS;
1162 #endif
1164 /* Options controlling warnings */
1166 /* Don't print warning messages. -w. */
1168 int inhibit_warnings = 0;
1170 /* Print various extra warnings. -W. */
1172 int extra_warnings = 0;
1174 /* Treat warnings as errors. -Werror. */
1176 int warnings_are_errors = 0;
1178 /* Nonzero to warn about unused local variables. */
1180 int warn_unused;
1182 /* Nonzero to warn about code which is never reached. */
1184 int warn_notreached;
1186 /* Nonzero to warn about variables used before they are initialized. */
1188 int warn_uninitialized;
1190 /* Nonzero means warn about all declarations which shadow others. */
1192 int warn_shadow;
1194 /* Warn if a switch on an enum fails to have a case for every enum value. */
1196 int warn_switch;
1198 /* Nonzero means warn about function definitions that default the return type
1199 or that use a null return and have a return-type other than void. */
1201 int warn_return_type;
1203 /* Nonzero means warn about pointer casts that increase the required
1204 alignment of the target type (and might therefore lead to a crash
1205 due to a misaligned access). */
1207 int warn_cast_align;
1209 /* Nonzero means warn about any identifiers that match in the first N
1210 characters. The value N is in `id_clash_len'. */
1212 int warn_id_clash;
1213 unsigned id_clash_len;
1215 /* Nonzero means warn about any objects definitions whose size is larger
1216 than N bytes. Also want about function definitions whose returned
1217 values are larger than N bytes. The value N is in `larger_than_size'. */
1219 int warn_larger_than;
1220 unsigned larger_than_size;
1222 /* Nonzero means warn if inline function is too large. */
1224 int warn_inline;
1226 /* Warn if a function returns an aggregate,
1227 since there are often incompatible calling conventions for doing this. */
1229 int warn_aggregate_return;
1231 /* Likewise for -W. */
1233 lang_independent_options W_options[] =
1235 {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1236 {"error", &warnings_are_errors, 1, ""},
1237 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1238 {"switch", &warn_switch, 1,
1239 "Warn about enumerated switches missing a specific case" },
1240 {"aggregate-return", &warn_aggregate_return, 1,
1241 "Warn about returning structures, unions or arrays" },
1242 {"cast-align", &warn_cast_align, 1,
1243 "Warn about pointer casts which increase alignment" },
1244 {"unreachable-code", &warn_notreached, 1,
1245 "Warn about code that will never be executed" },
1246 {"uninitialized", &warn_uninitialized, 1,
1247 "Warn about unitialized automatic variables"},
1248 {"inline", &warn_inline, 1,
1249 "Warn when an inlined function cannot be inlined"}
1252 /* Output files for assembler code (real compiler output)
1253 and debugging dumps. */
1255 FILE *asm_out_file;
1256 FILE *aux_info_file;
1257 FILE *rtl_dump_file = NULL;
1259 /* Decode the string P as an integral parameter.
1260 If the string is indeed an integer return its numeric value else
1261 issue an Invalid Option error for the option PNAME and return DEFVAL.
1262 If PNAME is zero just return DEFVAL, do not call error. */
1265 read_integral_parameter (p, pname, defval)
1266 const char *p;
1267 const char *pname;
1268 const int defval;
1270 const char *endp = p;
1272 while (*endp)
1274 if (*endp >= '0' && *endp <= '9')
1275 endp++;
1276 else
1277 break;
1280 if (*endp != 0)
1282 if (pname != 0)
1283 error ("Invalid option `%s'", pname);
1284 return defval;
1287 return atoi (p);
1291 /* Time accumulators, to count the total time spent in various passes. */
1293 int parse_time;
1294 int varconst_time;
1295 int integration_time;
1296 int jump_time;
1297 int cse_time;
1298 int gcse_time;
1299 int loop_time;
1300 int cse2_time;
1301 int branch_prob_time;
1302 int flow_time;
1303 int combine_time;
1304 int regmove_time;
1305 int sched_time;
1306 int local_alloc_time;
1307 int global_alloc_time;
1308 int flow2_time;
1309 int sched2_time;
1310 #ifdef DELAY_SLOTS
1311 int dbr_sched_time;
1312 #endif
1313 int shorten_branch_time;
1314 int stack_reg_time;
1315 int final_time;
1316 int symout_time;
1317 int dump_time;
1318 int gc_time;
1319 int all_time;
1321 /* Return time used so far, in microseconds. */
1323 long
1324 get_run_time ()
1326 if (quiet_flag)
1327 return 0;
1329 #ifdef __BEOS__
1330 return 0;
1331 #else /* not BeOS */
1332 #if defined (_WIN32) && !defined (__CYGWIN__)
1333 if (clock() < 0)
1334 return 0;
1335 else
1336 return (clock() * 1000);
1337 #else /* not _WIN32 */
1338 #ifdef _SC_CLK_TCK
1340 static int tick;
1341 struct tms tms;
1342 if (tick == 0)
1343 tick = 1000000 / sysconf(_SC_CLK_TCK);
1344 times (&tms);
1345 return (tms.tms_utime + tms.tms_stime) * tick;
1347 #else
1348 #ifdef USG
1350 struct tms tms;
1351 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1352 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1353 # else
1354 # ifdef CLK_TCK
1355 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1356 # else
1357 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1358 # endif
1359 # endif
1360 times (&tms);
1361 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1363 #else
1364 #ifndef VMS
1366 struct rusage rusage;
1367 getrusage (0, &rusage);
1368 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1369 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1371 #else /* VMS */
1373 struct
1375 int proc_user_time;
1376 int proc_system_time;
1377 int child_user_time;
1378 int child_system_time;
1379 } vms_times;
1380 times ((void *) &vms_times);
1381 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1383 #endif /* VMS */
1384 #endif /* USG */
1385 #endif /* _SC_CLK_TCK */
1386 #endif /* _WIN32 */
1387 #endif /* __BEOS__ */
1390 #define TIMEVAR(VAR, BODY) \
1391 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1393 void
1394 print_time (str, total)
1395 const char *str;
1396 int total;
1398 fprintf (stderr,
1399 "time in %s: %d.%06d (%.0f%%)\n",
1400 str, total / 1000000, total % 1000000,
1401 (double)total / (double)all_time * 100.0);
1404 /* Count an error or warning. Return 1 if the message should be printed. */
1407 count_error (warningp)
1408 int warningp;
1410 if (warningp && inhibit_warnings)
1411 return 0;
1413 if (warningp && !warnings_are_errors)
1414 warningcount++;
1415 else
1417 static int warning_message = 0;
1419 if (warningp && !warning_message)
1421 notice ("%s: warnings being treated as errors\n", progname);
1422 warning_message = 1;
1424 errorcount++;
1427 return 1;
1430 /* Print a fatal error message. NAME is the text.
1431 Also include a system error message based on `errno'. */
1433 void
1434 pfatal_with_name (name)
1435 const char *name;
1437 fprintf (stderr, "%s: ", progname);
1438 perror (name);
1439 exit (FATAL_EXIT_CODE);
1442 void
1443 fatal_io_error (name)
1444 const char *name;
1446 notice ("%s: %s: I/O error\n", progname, name);
1447 exit (FATAL_EXIT_CODE);
1450 /* This is the default decl_printable_name function. */
1452 static const char *
1453 decl_name (decl, verbosity)
1454 tree decl;
1455 int verbosity ATTRIBUTE_UNUSED;
1457 return IDENTIFIER_POINTER (DECL_NAME (decl));
1460 /* Mark P for GC. Also mark main_input_filename and input_filename. */
1461 static void
1462 mark_file_stack (p)
1463 void *p;
1465 struct file_stack *stack = *(struct file_stack **)p;
1467 /* We're only called for input_file_stack, so we can mark the current
1468 input_filename here as well. */
1469 ggc_mark_string (main_input_filename);
1470 ggc_mark_string (input_filename);
1472 while (stack)
1474 ggc_mark_string (stack->name);
1475 stack = stack->next;
1479 static int need_error_newline;
1481 /* Function of last error message;
1482 more generally, function such that if next error message is in it
1483 then we don't have to mention the function name. */
1484 static tree last_error_function = NULL;
1486 /* Used to detect when input_file_stack has changed since last described. */
1487 static int last_error_tick;
1489 /* Called when the start of a function definition is parsed,
1490 this function prints on stderr the name of the function. */
1492 void
1493 announce_function (decl)
1494 tree decl;
1496 if (! quiet_flag)
1498 if (rtl_dump_and_exit)
1499 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1500 else
1501 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1502 fflush (stderr);
1503 need_error_newline = 1;
1504 last_error_function = current_function_decl;
1508 /* The default function to print out name of current function that caused
1509 an error. */
1511 void
1512 default_print_error_function (file)
1513 const char *file;
1515 if (last_error_function != current_function_decl)
1517 if (file)
1518 fprintf (stderr, "%s: ", file);
1520 if (current_function_decl == NULL)
1521 notice ("At top level:\n");
1522 else
1523 notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE
1524 ? "In method `%s':\n"
1525 : "In function `%s':\n"),
1526 (*decl_printable_name) (current_function_decl, 2));
1528 last_error_function = current_function_decl;
1532 /* Called by report_error_function to print out function name.
1533 * Default may be overridden by language front-ends. */
1535 void (*print_error_function) PROTO((const char *)) =
1536 default_print_error_function;
1538 /* Prints out, if necessary, the name of the current function
1539 that caused an error. Called from all error and warning functions.
1540 We ignore the FILE parameter, as it cannot be relied upon. */
1542 void
1543 report_error_function (file)
1544 const char *file ATTRIBUTE_UNUSED;
1546 struct file_stack *p;
1548 if (need_error_newline)
1550 fprintf (stderr, "\n");
1551 need_error_newline = 0;
1554 if (input_file_stack && input_file_stack->next != 0
1555 && input_file_stack_tick != last_error_tick)
1557 for (p = input_file_stack->next; p; p = p->next)
1558 notice ((p == input_file_stack->next
1559 ? "In file included from %s:%d"
1560 : ",\n from %s:%d"),
1561 p->name, p->line);
1562 fprintf (stderr, ":\n");
1563 last_error_tick = input_file_stack_tick;
1566 (*print_error_function) (input_filename);
1569 /* Print a message. */
1571 static void
1572 vnotice (file, msgid, ap)
1573 FILE *file;
1574 const char *msgid;
1575 va_list ap;
1577 vfprintf (file, _(msgid), ap);
1580 static void
1581 notice VPROTO((const char *msgid, ...))
1583 #ifndef ANSI_PROTOTYPES
1584 char *msgid;
1585 #endif
1586 va_list ap;
1588 VA_START (ap, msgid);
1590 #ifndef ANSI_PROTOTYPES
1591 msgid = va_arg (ap, char *);
1592 #endif
1594 vnotice (stderr, msgid, ap);
1595 va_end (ap);
1598 void
1599 fnotice VPROTO((FILE *file, const char *msgid, ...))
1601 #ifndef ANSI_PROTOTYPES
1602 FILE *file;
1603 const char *msgid;
1604 #endif
1605 va_list ap;
1607 VA_START (ap, msgid);
1609 #ifndef ANSI_PROTOTYPES
1610 file = va_arg (ap, FILE *);
1611 msgid = va_arg (ap, const char *);
1612 #endif
1614 vnotice (file, msgid, ap);
1615 va_end (ap);
1618 /* Report FILE and LINE (or program name), and optionally just WARN. */
1620 static void
1621 report_file_and_line (file, line, warn)
1622 const char *file;
1623 int line;
1624 int warn;
1626 if (file)
1627 fprintf (stderr, "%s:%d: ", file, line);
1628 else
1629 fprintf (stderr, "%s: ", progname);
1631 if (warn)
1632 notice ("warning: ");
1635 /* Print a message. */
1637 static void
1638 vmessage (prefix, msgid, ap)
1639 const char *prefix;
1640 const char *msgid;
1641 va_list ap;
1643 if (prefix)
1644 fprintf (stderr, "%s: ", prefix);
1646 vfprintf (stderr, msgid, ap);
1649 /* Print a message relevant to line LINE of file FILE. */
1651 static void
1652 v_message_with_file_and_line (file, line, warn, msgid, ap)
1653 const char *file;
1654 int line;
1655 int warn;
1656 const char *msgid;
1657 va_list ap;
1659 report_file_and_line (file, line, warn);
1660 vnotice (stderr, msgid, ap);
1661 fputc ('\n', stderr);
1664 /* Print a message relevant to the given DECL. */
1666 static void
1667 v_message_with_decl (decl, warn, msgid, ap)
1668 tree decl;
1669 int warn;
1670 const char *msgid;
1671 va_list ap;
1673 const char *p;
1675 report_file_and_line (DECL_SOURCE_FILE (decl),
1676 DECL_SOURCE_LINE (decl), warn);
1678 /* Do magic to get around lack of varargs support for insertion
1679 of arguments into existing list. We know that the decl is first;
1680 we ass_u_me that it will be printed with "%s". */
1682 for (p = _(msgid); *p; ++p)
1684 if (*p == '%')
1686 if (*(p + 1) == '%')
1687 ++p;
1688 else if (*(p + 1) != 's')
1689 abort ();
1690 else
1691 break;
1695 if (p > _(msgid)) /* Print the left-hand substring. */
1697 char fmt[sizeof "%.255s"];
1698 long width = p - _(msgid);
1700 if (width > 255L) width = 255L; /* arbitrary */
1701 sprintf (fmt, "%%.%lds", width);
1702 fprintf (stderr, fmt, _(msgid));
1705 if (*p == '%') /* Print the name. */
1707 const char *n = (DECL_NAME (decl)
1708 ? (*decl_printable_name) (decl, 2)
1709 : "((anonymous))");
1710 fputs (n, stderr);
1711 while (*p)
1713 ++p;
1714 if (ISALPHA (*(p - 1) & 0xFF))
1715 break;
1719 if (*p) /* Print the rest of the message. */
1720 vmessage ((char *)NULL, p, ap);
1722 fputc ('\n', stderr);
1725 /* Figure file and line of the given INSN. */
1727 static void
1728 file_and_line_for_asm (insn, pfile, pline)
1729 rtx insn;
1730 char **pfile;
1731 int *pline;
1733 rtx body = PATTERN (insn);
1734 rtx asmop;
1736 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1737 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1738 asmop = SET_SRC (body);
1739 else if (GET_CODE (body) == ASM_OPERANDS)
1740 asmop = body;
1741 else if (GET_CODE (body) == PARALLEL
1742 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1743 asmop = SET_SRC (XVECEXP (body, 0, 0));
1744 else if (GET_CODE (body) == PARALLEL
1745 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1746 asmop = XVECEXP (body, 0, 0);
1747 else
1748 asmop = NULL;
1750 if (asmop)
1752 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1753 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1755 else
1757 *pfile = input_filename;
1758 *pline = lineno;
1762 /* Report an error at line LINE of file FILE. */
1764 static void
1765 v_error_with_file_and_line (file, line, msgid, ap)
1766 const char *file;
1767 int line;
1768 const char *msgid;
1769 va_list ap;
1771 count_error (0);
1772 report_error_function (file);
1773 v_message_with_file_and_line (file, line, 0, msgid, ap);
1776 void
1777 error_with_file_and_line VPROTO((const char *file, int line,
1778 const char *msgid, ...))
1780 #ifndef ANSI_PROTOTYPES
1781 const char *file;
1782 int line;
1783 const char *msgid;
1784 #endif
1785 va_list ap;
1787 VA_START (ap, msgid);
1789 #ifndef ANSI_PROTOTYPES
1790 file = va_arg (ap, const char *);
1791 line = va_arg (ap, int);
1792 msgid = va_arg (ap, const char *);
1793 #endif
1795 v_error_with_file_and_line (file, line, msgid, ap);
1796 va_end (ap);
1799 /* Report an error at the declaration DECL.
1800 MSGID is a format string which uses %s to substitute the declaration
1801 name; subsequent substitutions are a la printf. */
1803 static void
1804 v_error_with_decl (decl, msgid, ap)
1805 tree decl;
1806 const char *msgid;
1807 va_list ap;
1809 count_error (0);
1810 report_error_function (DECL_SOURCE_FILE (decl));
1811 v_message_with_decl (decl, 0, msgid, ap);
1814 void
1815 error_with_decl VPROTO((tree decl, const char *msgid, ...))
1817 #ifndef ANSI_PROTOTYPES
1818 tree decl;
1819 const char *msgid;
1820 #endif
1821 va_list ap;
1823 VA_START (ap, msgid);
1825 #ifndef ANSI_PROTOTYPES
1826 decl = va_arg (ap, tree);
1827 msgid = va_arg (ap, const char *);
1828 #endif
1830 v_error_with_decl (decl, msgid, ap);
1831 va_end (ap);
1834 /* Report an error at the line number of the insn INSN.
1835 This is used only when INSN is an `asm' with operands,
1836 and each ASM_OPERANDS records its own source file and line. */
1838 static void
1839 v_error_for_asm (insn, msgid, ap)
1840 rtx insn;
1841 const char *msgid;
1842 va_list ap;
1844 char *file;
1845 int line;
1847 count_error (0);
1848 file_and_line_for_asm (insn, &file, &line);
1849 report_error_function (file);
1850 v_message_with_file_and_line (file, line, 0, msgid, ap);
1853 void
1854 error_for_asm VPROTO((rtx insn, const char *msgid, ...))
1856 #ifndef ANSI_PROTOTYPES
1857 rtx insn;
1858 const char *msgid;
1859 #endif
1860 va_list ap;
1862 VA_START (ap, msgid);
1864 #ifndef ANSI_PROTOTYPES
1865 insn = va_arg (ap, rtx);
1866 msgid = va_arg (ap, const char *);
1867 #endif
1869 v_error_for_asm (insn, msgid, ap);
1870 va_end (ap);
1873 /* Report an error at the current line number. */
1875 static void
1876 verror (msgid, ap)
1877 const char *msgid;
1878 va_list ap;
1880 v_error_with_file_and_line (input_filename, lineno, msgid, ap);
1883 void
1884 error VPROTO((const char *msgid, ...))
1886 #ifndef ANSI_PROTOTYPES
1887 const char *msgid;
1888 #endif
1889 va_list ap;
1891 VA_START (ap, msgid);
1893 #ifndef ANSI_PROTOTYPES
1894 msgid = va_arg (ap, const char *);
1895 #endif
1897 verror (msgid, ap);
1898 va_end (ap);
1901 /* Report a fatal error at the current line number. Allow a front end to
1902 intercept the message. */
1904 static void (*fatal_function) PROTO ((const char *, va_list));
1906 /* Set the function to call when a fatal error occurs. */
1908 void
1909 set_fatal_function (f)
1910 void (*f) PROTO ((const char *, va_list));
1912 fatal_function = f;
1915 static void
1916 vfatal (msgid, ap)
1917 const char *msgid;
1918 va_list ap;
1920 if (fatal_function != 0)
1921 (*fatal_function) (_(msgid), ap);
1923 verror (msgid, ap);
1924 exit (FATAL_EXIT_CODE);
1927 void
1928 fatal VPROTO((const char *msgid, ...))
1930 #ifndef ANSI_PROTOTYPES
1931 const char *msgid;
1932 #endif
1933 va_list ap;
1935 VA_START (ap, msgid);
1937 #ifndef ANSI_PROTOTYPES
1938 msgid = va_arg (ap, const char *);
1939 #endif
1941 vfatal (msgid, ap);
1942 va_end (ap);
1945 void
1946 _fatal_insn (msgid, insn, file, line, function)
1947 const char *msgid;
1948 rtx insn;
1949 const char *file;
1950 int line;
1951 const char *function;
1953 error (msgid);
1954 debug_rtx (insn);
1955 fancy_abort (file, line, function);
1958 void
1959 _fatal_insn_not_found (insn, file, line, function)
1960 rtx insn;
1961 const char *file;
1962 int line;
1963 const char *function;
1965 if (INSN_CODE (insn) < 0)
1966 _fatal_insn ("Unrecognizable insn:", insn, file, line, function);
1967 else
1968 _fatal_insn ("Insn does not satisfy its constraints:",
1969 insn, file, line, function);
1972 /* Report a warning at line LINE of file FILE. */
1974 static void
1975 v_warning_with_file_and_line (file, line, msgid, ap)
1976 const char *file;
1977 int line;
1978 const char *msgid;
1979 va_list ap;
1981 if (count_error (1))
1983 report_error_function (file);
1984 v_message_with_file_and_line (file, line, 1, msgid, ap);
1988 void
1989 warning_with_file_and_line VPROTO((const char *file, int line,
1990 const char *msgid, ...))
1992 #ifndef ANSI_PROTOTYPES
1993 const char *file;
1994 int line;
1995 const char *msgid;
1996 #endif
1997 va_list ap;
1999 VA_START (ap, msgid);
2001 #ifndef ANSI_PROTOTYPES
2002 file = va_arg (ap, const char *);
2003 line = va_arg (ap, int);
2004 msgid = va_arg (ap, const char *);
2005 #endif
2007 v_warning_with_file_and_line (file, line, msgid, ap);
2008 va_end (ap);
2011 /* Report a warning at the declaration DECL.
2012 MSGID is a format string which uses %s to substitute the declaration
2013 name; subsequent substitutions are a la printf. */
2015 static void
2016 v_warning_with_decl (decl, msgid, ap)
2017 tree decl;
2018 const char *msgid;
2019 va_list ap;
2021 if (count_error (1))
2023 report_error_function (DECL_SOURCE_FILE (decl));
2024 v_message_with_decl (decl, 1, msgid, ap);
2028 void
2029 warning_with_decl VPROTO((tree decl, const char *msgid, ...))
2031 #ifndef ANSI_PROTOTYPES
2032 tree decl;
2033 const char *msgid;
2034 #endif
2035 va_list ap;
2037 VA_START (ap, msgid);
2039 #ifndef ANSI_PROTOTYPES
2040 decl = va_arg (ap, tree);
2041 msgid = va_arg (ap, const char *);
2042 #endif
2044 v_warning_with_decl (decl, msgid, ap);
2045 va_end (ap);
2048 /* Report a warning at the line number of the insn INSN.
2049 This is used only when INSN is an `asm' with operands,
2050 and each ASM_OPERANDS records its own source file and line. */
2052 static void
2053 v_warning_for_asm (insn, msgid, ap)
2054 rtx insn;
2055 const char *msgid;
2056 va_list ap;
2058 if (count_error (1))
2060 char *file;
2061 int line;
2063 file_and_line_for_asm (insn, &file, &line);
2064 report_error_function (file);
2065 v_message_with_file_and_line (file, line, 1, msgid, ap);
2069 void
2070 warning_for_asm VPROTO((rtx insn, const char *msgid, ...))
2072 #ifndef ANSI_PROTOTYPES
2073 rtx insn;
2074 const char *msgid;
2075 #endif
2076 va_list ap;
2078 VA_START (ap, msgid);
2080 #ifndef ANSI_PROTOTYPES
2081 insn = va_arg (ap, rtx);
2082 msgid = va_arg (ap, const char *);
2083 #endif
2085 v_warning_for_asm (insn, msgid, ap);
2086 va_end (ap);
2089 /* Report a warning at the current line number. */
2091 static void
2092 vwarning (msgid, ap)
2093 const char *msgid;
2094 va_list ap;
2096 v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
2099 void
2100 warning VPROTO((const char *msgid, ...))
2102 #ifndef ANSI_PROTOTYPES
2103 const char *msgid;
2104 #endif
2105 va_list ap;
2107 VA_START (ap, msgid);
2109 #ifndef ANSI_PROTOTYPES
2110 msgid = va_arg (ap, const char *);
2111 #endif
2113 vwarning (msgid, ap);
2114 va_end (ap);
2117 /* These functions issue either warnings or errors depending on
2118 -pedantic-errors. */
2120 static void
2121 vpedwarn (msgid, ap)
2122 const char *msgid;
2123 va_list ap;
2125 if (flag_pedantic_errors)
2126 verror (msgid, ap);
2127 else
2128 vwarning (msgid, ap);
2131 void
2132 pedwarn VPROTO((const char *msgid, ...))
2134 #ifndef ANSI_PROTOTYPES
2135 const char *msgid;
2136 #endif
2137 va_list ap;
2139 VA_START (ap, msgid);
2141 #ifndef ANSI_PROTOTYPES
2142 msgid = va_arg (ap, const char *);
2143 #endif
2145 vpedwarn (msgid, ap);
2146 va_end (ap);
2149 static void
2150 v_pedwarn_with_decl (decl, msgid, ap)
2151 tree decl;
2152 const char *msgid;
2153 va_list ap;
2155 /* We don't want -pedantic-errors to cause the compilation to fail from
2156 "errors" in system header files. Sometimes fixincludes can't fix what's
2157 broken (eg: unsigned char bitfields - fixing it may change the alignment
2158 which will cause programs to mysteriously fail because the C library
2159 or kernel uses the original layout). There's no point in issuing a
2160 warning either, it's just unnecessary noise. */
2162 if (! DECL_IN_SYSTEM_HEADER (decl))
2164 if (flag_pedantic_errors)
2165 v_error_with_decl (decl, msgid, ap);
2166 else
2167 v_warning_with_decl (decl, msgid, ap);
2171 void
2172 pedwarn_with_decl VPROTO((tree decl, const char *msgid, ...))
2174 #ifndef ANSI_PROTOTYPES
2175 tree decl;
2176 const char *msgid;
2177 #endif
2178 va_list ap;
2180 VA_START (ap, msgid);
2182 #ifndef ANSI_PROTOTYPES
2183 decl = va_arg (ap, tree);
2184 msgid = va_arg (ap, const char *);
2185 #endif
2187 v_pedwarn_with_decl (decl, msgid, ap);
2188 va_end (ap);
2191 static void
2192 v_pedwarn_with_file_and_line (file, line, msgid, ap)
2193 const char *file;
2194 int line;
2195 const char *msgid;
2196 va_list ap;
2198 if (flag_pedantic_errors)
2199 v_error_with_file_and_line (file, line, msgid, ap);
2200 else
2201 v_warning_with_file_and_line (file, line, msgid, ap);
2204 void
2205 pedwarn_with_file_and_line VPROTO((const char *file, int line,
2206 const char *msgid, ...))
2208 #ifndef ANSI_PROTOTYPES
2209 const char *file;
2210 int line;
2211 const char *msgid;
2212 #endif
2213 va_list ap;
2215 VA_START (ap, msgid);
2217 #ifndef ANSI_PROTOTYPES
2218 file = va_arg (ap, const char *);
2219 line = va_arg (ap, int);
2220 msgid = va_arg (ap, const char *);
2221 #endif
2223 v_pedwarn_with_file_and_line (file, line, msgid, ap);
2224 va_end (ap);
2227 /* Apologize for not implementing some feature. */
2229 static void
2230 vsorry (msgid, ap)
2231 const char *msgid;
2232 va_list ap;
2234 sorrycount++;
2235 if (input_filename)
2236 fprintf (stderr, "%s:%d: ", input_filename, lineno);
2237 else
2238 fprintf (stderr, "%s: ", progname);
2239 notice ("sorry, not implemented: ");
2240 vnotice (stderr, msgid, ap);
2241 fputc ('\n', stderr);
2244 void
2245 sorry VPROTO((const char *msgid, ...))
2247 #ifndef ANSI_PROTOTYPES
2248 const char *msgid;
2249 #endif
2250 va_list ap;
2252 VA_START (ap, msgid);
2254 #ifndef ANSI_PROTOTYPES
2255 msgid = va_arg (ap, const char *);
2256 #endif
2258 vsorry (msgid, ap);
2259 va_end (ap);
2263 /* This calls abort and is used to avoid problems when abort if a macro.
2264 It is used when we need to pass the address of abort. */
2266 void
2267 do_abort ()
2269 abort ();
2272 /* When `malloc.c' is compiled with `rcheck' defined,
2273 it calls this function to report clobberage. */
2275 void
2276 botch (s)
2277 const char * s ATTRIBUTE_UNUSED;
2279 abort ();
2282 /* Return the logarithm of X, base 2, considering X unsigned,
2283 if X is a power of 2. Otherwise, returns -1.
2285 This should be used via the `exact_log2' macro. */
2288 exact_log2_wide (x)
2289 register unsigned HOST_WIDE_INT x;
2291 register int log = 0;
2292 /* Test for 0 or a power of 2. */
2293 if (x == 0 || x != (x & -x))
2294 return -1;
2295 while ((x >>= 1) != 0)
2296 log++;
2297 return log;
2300 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2301 If X is 0, return -1.
2303 This should be used via the floor_log2 macro. */
2306 floor_log2_wide (x)
2307 register unsigned HOST_WIDE_INT x;
2309 register int log = -1;
2310 while (x != 0)
2311 log++,
2312 x >>= 1;
2313 return log;
2316 static int float_handler_set;
2317 int float_handled;
2318 jmp_buf float_handler;
2320 /* Signals actually come here. */
2322 static void
2323 float_signal (signo)
2324 /* If this is missing, some compilers complain. */
2325 int signo ATTRIBUTE_UNUSED;
2327 if (float_handled == 0)
2328 abort ();
2329 #if defined (USG) || defined (hpux)
2330 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2331 #endif
2332 float_handled = 0;
2333 signal (SIGFPE, float_signal);
2334 longjmp (float_handler, 1);
2337 /* Specify where to longjmp to when a floating arithmetic error happens.
2338 If HANDLER is 0, it means don't handle the errors any more. */
2340 void
2341 set_float_handler (handler)
2342 jmp_buf handler;
2344 float_handled = (handler != 0);
2345 if (handler)
2346 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2348 if (float_handled && ! float_handler_set)
2350 signal (SIGFPE, float_signal);
2351 float_handler_set = 1;
2355 /* This is a wrapper function for code which might elicit an
2356 arithmetic exception. That code should be passed in as a function
2357 pointer FN, and one argument DATA. DATA is usually a struct which
2358 contains the real input and output for function FN. This function
2359 returns 0 (failure) if longjmp was called (i.e. an exception
2360 occured.) It returns 1 (success) otherwise. */
2363 do_float_handler (fn, data)
2364 void (*fn) PROTO ((PTR));
2365 PTR data;
2367 jmp_buf buf;
2369 if (setjmp (buf))
2371 /* We got here via longjmp() caused by an exception in function fn() */
2372 set_float_handler (NULL);
2373 return 0;
2376 set_float_handler (buf);
2377 (*fn)(data);
2378 set_float_handler (NULL);
2379 return 1;
2382 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2383 error happens, pushing the previous specification into OLD_HANDLER.
2384 Return an indication of whether there was a previous handler in effect. */
2387 push_float_handler (handler, old_handler)
2388 jmp_buf handler, old_handler;
2390 int was_handled = float_handled;
2392 float_handled = 1;
2393 if (was_handled)
2394 memcpy ((char *) old_handler, (char *) float_handler,
2395 sizeof (float_handler));
2397 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
2398 return was_handled;
2401 /* Restore the previous specification of whether and where to longjmp to
2402 when a floating arithmetic error happens. */
2404 void
2405 pop_float_handler (handled, handler)
2406 int handled;
2407 jmp_buf handler;
2409 float_handled = handled;
2410 if (handled)
2411 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2414 /* Handler for SIGPIPE. */
2416 static void
2417 pipe_closed (signo)
2418 /* If this is missing, some compilers complain. */
2419 int signo ATTRIBUTE_UNUSED;
2421 fatal ("output pipe has been closed");
2424 /* Strip off a legitimate source ending from the input string NAME of
2425 length LEN. Rather than having to know the names used by all of
2426 our front ends, we strip off an ending of a period followed by
2427 up to five characters. (Java uses ".class".) */
2429 void
2430 strip_off_ending (name, len)
2431 char *name;
2432 int len;
2434 int i;
2435 for (i = 2; i < 6 && len > i; i++)
2437 if (name[len - i] == '.')
2439 name[len - i] = '\0';
2440 break;
2445 /* Output a quoted string. */
2447 void
2448 output_quoted_string (asm_file, string)
2449 FILE *asm_file;
2450 const char *string;
2452 #ifdef OUTPUT_QUOTED_STRING
2453 OUTPUT_QUOTED_STRING (asm_file, string);
2454 #else
2455 char c;
2457 putc ('\"', asm_file);
2458 while ((c = *string++) != 0)
2460 if (c == '\"' || c == '\\')
2461 putc ('\\', asm_file);
2462 putc (c, asm_file);
2464 putc ('\"', asm_file);
2465 #endif
2468 /* Output a file name in the form wanted by System V. */
2470 void
2471 output_file_directive (asm_file, input_name)
2472 FILE *asm_file;
2473 const char *input_name;
2475 int len = strlen (input_name);
2476 const char *na = input_name + len;
2478 /* NA gets INPUT_NAME sans directory names. */
2479 while (na > input_name)
2481 if (na[-1] == '/')
2482 break;
2483 #ifdef DIR_SEPARATOR
2484 if (na[-1] == DIR_SEPARATOR)
2485 break;
2486 #endif
2487 na--;
2490 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2491 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2492 #else
2493 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2494 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2495 #else
2496 fprintf (asm_file, "\t.file\t");
2497 output_quoted_string (asm_file, na);
2498 fputc ('\n', asm_file);
2499 #endif
2500 #endif
2503 #ifdef ASM_IDENTIFY_LANGUAGE
2504 /* Routine to build language identifier for object file. */
2505 static void
2506 output_lang_identify (asm_out_file)
2507 FILE *asm_out_file;
2509 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2510 char *s = (char *) alloca (len);
2511 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2512 ASM_OUTPUT_LABEL (asm_out_file, s);
2514 #endif
2516 /* Routine to open a dump file. */
2517 static void
2518 open_dump_file (suffix, function_name)
2519 const char *suffix;
2520 const char *function_name;
2522 char *dumpname;
2524 TIMEVAR
2525 (dump_time,
2527 dumpname = concat (dump_base_name, suffix, NULL);
2529 if (rtl_dump_file != NULL)
2530 fclose (rtl_dump_file);
2532 rtl_dump_file = fopen (dumpname, "a");
2534 if (rtl_dump_file == NULL)
2535 pfatal_with_name (dumpname);
2537 free (dumpname);
2539 if (function_name)
2540 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2543 return;
2546 /* Routine to close a dump file. */
2547 static void
2548 close_dump_file (func, insns)
2549 void (*func) PROTO ((FILE *, rtx));
2550 rtx insns;
2552 TIMEVAR
2553 (dump_time,
2555 if (func)
2556 func (rtl_dump_file, insns);
2558 fflush (rtl_dump_file);
2559 fclose (rtl_dump_file);
2561 rtl_dump_file = NULL;
2564 return;
2567 /* Routine to dump rtl into a file. */
2568 static void
2569 dump_rtl (suffix, decl, func, insns)
2570 const char *suffix;
2571 tree decl;
2572 void (*func) PROTO ((FILE *, rtx));
2573 rtx insns;
2575 open_dump_file (suffix, decl_printable_name (decl, 2));
2576 close_dump_file (func, insns);
2579 /* Routine to empty a dump file. */
2580 static void
2581 clean_dump_file (suffix)
2582 const char *suffix;
2584 char * const dumpname = concat (dump_base_name, suffix, NULL);
2586 rtl_dump_file = fopen (dumpname, "w");
2588 if (rtl_dump_file == NULL)
2589 pfatal_with_name (dumpname);
2591 free (dumpname);
2593 fclose (rtl_dump_file);
2594 rtl_dump_file = NULL;
2596 return;
2599 /* Do any final processing required for the declarations in VEC, of
2600 which there are LEN. We write out inline functions and variables
2601 that have been deferred until this point, but which are required.
2602 Returns non-zero if anything was put out. */
2604 wrapup_global_declarations (vec, len)
2605 tree *vec;
2606 int len;
2608 tree decl;
2609 int i;
2610 int reconsider;
2611 int output_something = 0;
2613 for (i = 0; i < len; i++)
2615 decl = vec[i];
2617 /* We're not deferring this any longer. */
2618 DECL_DEFER_OUTPUT (decl) = 0;
2620 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2621 && incomplete_decl_finalize_hook != 0)
2622 (*incomplete_decl_finalize_hook) (decl);
2625 /* Now emit any global variables or functions that we have been
2626 putting off. We need to loop in case one of the things emitted
2627 here references another one which comes earlier in the list. */
2630 reconsider = 0;
2631 for (i = 0; i < len; i++)
2633 decl = vec[i];
2635 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2636 continue;
2638 /* Don't write out static consts, unless we still need them.
2640 We also keep static consts if not optimizing (for debugging),
2641 unless the user specified -fno-keep-static-consts.
2642 ??? They might be better written into the debug information.
2643 This is possible when using DWARF.
2645 A language processor that wants static constants to be always
2646 written out (even if it is not used) is responsible for
2647 calling rest_of_decl_compilation itself. E.g. the C front-end
2648 calls rest_of_decl_compilation from finish_decl.
2649 One motivation for this is that is conventional in some
2650 environments to write things like:
2651 static const char rcsid[] = "... version string ...";
2652 intending to force the string to be in the executable.
2654 A language processor that would prefer to have unneeded
2655 static constants "optimized away" would just defer writing
2656 them out until here. E.g. C++ does this, because static
2657 constants are often defined in header files.
2659 ??? A tempting alternative (for both C and C++) would be
2660 to force a constant to be written if and only if it is
2661 defined in a main file, as opposed to an include file. */
2663 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2664 && (! TREE_READONLY (decl)
2665 || TREE_PUBLIC (decl)
2666 || (!optimize && flag_keep_static_consts)
2667 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2669 reconsider = 1;
2670 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2673 if (TREE_CODE (decl) == FUNCTION_DECL
2674 && DECL_INITIAL (decl) != 0
2675 && DECL_SAVED_INSNS (decl) != 0
2676 && (flag_keep_inline_functions
2677 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2678 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2680 reconsider = 1;
2681 temporary_allocation ();
2682 output_inline_function (decl);
2683 permanent_allocation (1);
2687 if (reconsider)
2688 output_something = 1;
2690 while (reconsider);
2692 return output_something;
2695 /* Issue appropriate warnings for the global declarations in VEC (of
2696 which there are LEN). Output debugging information for them. */
2697 void
2698 check_global_declarations (vec, len)
2699 tree *vec;
2700 int len;
2702 tree decl;
2703 int i;
2705 for (i = 0; i < len; i++)
2707 decl = vec[i];
2709 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2710 && ! TREE_ASM_WRITTEN (decl))
2711 /* Cancel the RTL for this decl so that, if debugging info
2712 output for global variables is still to come,
2713 this one will be omitted. */
2714 DECL_RTL (decl) = NULL;
2716 /* Warn about any function
2717 declared static but not defined.
2718 We don't warn about variables,
2719 because many programs have static variables
2720 that exist only to get some text into the object file. */
2721 if (TREE_CODE (decl) == FUNCTION_DECL
2722 && (warn_unused
2723 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2724 && DECL_INITIAL (decl) == 0
2725 && DECL_EXTERNAL (decl)
2726 && ! DECL_ARTIFICIAL (decl)
2727 && ! TREE_PUBLIC (decl))
2729 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2730 pedwarn_with_decl (decl,
2731 "`%s' used but never defined");
2732 else
2733 warning_with_decl (decl,
2734 "`%s' declared `static' but never defined");
2735 /* This symbol is effectively an "extern" declaration now. */
2736 TREE_PUBLIC (decl) = 1;
2737 assemble_external (decl);
2740 /* Warn about static fns or vars defined but not used,
2741 but not about inline functions or static consts
2742 since defining those in header files is normal practice. */
2743 if (warn_unused
2744 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2745 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2746 && ! DECL_IN_SYSTEM_HEADER (decl)
2747 && ! DECL_EXTERNAL (decl)
2748 && ! TREE_PUBLIC (decl)
2749 && ! TREE_USED (decl)
2750 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2751 /* The TREE_USED bit for file-scope decls
2752 is kept in the identifier, to handle multiple
2753 external decls in different scopes. */
2754 && ! TREE_USED (DECL_NAME (decl)))
2755 warning_with_decl (decl, "`%s' defined but not used");
2757 #ifdef SDB_DEBUGGING_INFO
2758 /* The COFF linker can move initialized global vars to the end.
2759 And that can screw up the symbol ordering.
2760 By putting the symbols in that order to begin with,
2761 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2762 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2763 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2764 && ! DECL_EXTERNAL (decl)
2765 && DECL_RTL (decl) != 0)
2766 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2768 /* Output COFF information for non-global
2769 file-scope initialized variables. */
2770 if (write_symbols == SDB_DEBUG
2771 && TREE_CODE (decl) == VAR_DECL
2772 && DECL_INITIAL (decl)
2773 && ! DECL_EXTERNAL (decl)
2774 && DECL_RTL (decl) != 0
2775 && GET_CODE (DECL_RTL (decl)) == MEM)
2776 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2777 #endif /* SDB_DEBUGGING_INFO */
2778 #ifdef DWARF_DEBUGGING_INFO
2779 /* Output DWARF information for file-scope tentative data object
2780 declarations, file-scope (extern) function declarations (which
2781 had no corresponding body) and file-scope tagged type declarations
2782 and definitions which have not yet been forced out. */
2784 if (write_symbols == DWARF_DEBUG
2785 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2786 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2787 #endif
2788 #ifdef DWARF2_DEBUGGING_INFO
2789 /* Output DWARF2 information for file-scope tentative data object
2790 declarations, file-scope (extern) function declarations (which
2791 had no corresponding body) and file-scope tagged type declarations
2792 and definitions which have not yet been forced out. */
2794 if (write_symbols == DWARF2_DEBUG
2795 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2796 TIMEVAR (symout_time, dwarf2out_decl (decl));
2797 #endif
2801 /* Compile an entire file of output from cpp, named NAME.
2802 Write a file of assembly output and various debugging dumps. */
2804 static void
2805 compile_file (name)
2806 char *name;
2808 tree globals;
2809 int start_time;
2811 int name_specified = name != 0;
2813 if (dump_base_name == 0)
2814 dump_base_name = name ? name : "gccdump";
2816 parse_time = 0;
2817 varconst_time = 0;
2818 integration_time = 0;
2819 jump_time = 0;
2820 cse_time = 0;
2821 gcse_time = 0;
2822 loop_time = 0;
2823 cse2_time = 0;
2824 branch_prob_time = 0;
2825 flow_time = 0;
2826 combine_time = 0;
2827 regmove_time = 0;
2828 sched_time = 0;
2829 local_alloc_time = 0;
2830 global_alloc_time = 0;
2831 flow2_time = 0;
2832 sched2_time = 0;
2833 #ifdef DELAY_SLOTS
2834 dbr_sched_time = 0;
2835 #endif
2836 shorten_branch_time = 0;
2837 stack_reg_time = 0;
2838 final_time = 0;
2839 symout_time = 0;
2840 dump_time = 0;
2842 /* Initialize data in various passes. */
2844 init_obstacks ();
2845 init_tree_codes ();
2846 name = init_parse (name);
2847 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2848 || debug_info_level == DINFO_LEVEL_VERBOSE
2849 || flag_test_coverage
2850 || warn_notreached);
2851 init_regs ();
2852 init_decl_processing ();
2853 init_optabs ();
2854 init_stmt ();
2855 init_eh ();
2856 init_loop ();
2857 init_reload ();
2858 init_alias_once ();
2859 init_function_once ();
2860 init_stor_layout_once ();
2861 init_varasm_once ();
2863 /* The following initialization functions need to generate rtl, so
2864 provide a dummy function context for them. */
2865 init_dummy_function_start ();
2866 init_expmed ();
2867 init_expr_once ();
2868 if (flag_caller_saves)
2869 init_caller_save ();
2870 expand_dummy_function_end ();
2872 /* If auxiliary info generation is desired, open the output file.
2873 This goes in the same directory as the source file--unlike
2874 all the other output files. */
2875 if (flag_gen_aux_info)
2877 aux_info_file = fopen (aux_info_file_name, "w");
2878 if (aux_info_file == 0)
2879 pfatal_with_name (aux_info_file_name);
2882 /* Clear the dump files. */
2883 if (rtl_dump)
2884 clean_dump_file (".rtl");
2885 if (jump_opt_dump)
2887 clean_dump_file (".jump");
2888 if (graph_dump_format != no_graph)
2889 clean_graph_dump_file (dump_base_name, ".jump");
2891 if (addressof_dump)
2893 clean_dump_file (".addressof");
2894 if (graph_dump_format != no_graph)
2895 clean_graph_dump_file (dump_base_name, ".addressof");
2897 if (cse_dump)
2899 clean_dump_file (".cse");
2900 if (graph_dump_format != no_graph)
2901 clean_graph_dump_file (dump_base_name, ".cse");
2903 if (loop_dump)
2905 clean_dump_file (".loop");
2906 if (graph_dump_format != no_graph)
2907 clean_graph_dump_file (dump_base_name, ".loop");
2909 if (cse2_dump)
2911 clean_dump_file (".cse2");
2912 if (graph_dump_format != no_graph)
2913 clean_graph_dump_file (dump_base_name, ".cse2");
2915 if (branch_prob_dump)
2917 clean_dump_file (".bp");
2918 if (graph_dump_format != no_graph)
2919 clean_graph_dump_file (dump_base_name, ".bp");
2921 if (flow_dump)
2923 clean_dump_file (".flow");
2924 if (graph_dump_format != no_graph)
2925 clean_graph_dump_file (dump_base_name, ".flow");
2927 if (combine_dump)
2929 clean_dump_file (".combine");
2930 if (graph_dump_format != no_graph)
2931 clean_graph_dump_file (dump_base_name, ".combine");
2933 if (regmove_dump)
2935 clean_dump_file (".regmove");
2936 if (graph_dump_format != no_graph)
2937 clean_graph_dump_file (dump_base_name, ".regmove");
2939 if (sched_dump)
2941 clean_dump_file (".sched");
2942 if (graph_dump_format != no_graph)
2943 clean_graph_dump_file (dump_base_name, ".sched");
2945 if (local_reg_dump)
2947 clean_dump_file (".lreg");
2948 if (graph_dump_format != no_graph)
2949 clean_graph_dump_file (dump_base_name, ".lreg");
2951 if (global_reg_dump)
2953 clean_dump_file (".greg");
2954 if (graph_dump_format != no_graph)
2955 clean_graph_dump_file (dump_base_name, ".greg");
2957 if (flow2_dump)
2959 clean_dump_file (".flow2");
2960 if (graph_dump_format != no_graph)
2961 clean_graph_dump_file (dump_base_name, ".flow2");
2963 if (peephole2_dump)
2965 clean_dump_file (".peephole2");
2966 if (graph_dump_format != no_graph)
2967 clean_graph_dump_file (dump_base_name, ".peephole2");
2969 if (sched2_dump)
2971 clean_dump_file (".sched2");
2972 if (graph_dump_format != no_graph)
2973 clean_graph_dump_file (dump_base_name, ".sched2");
2975 if (jump2_opt_dump)
2977 clean_dump_file (".jump2");
2978 if (graph_dump_format != no_graph)
2979 clean_graph_dump_file (dump_base_name, ".jump2");
2981 #ifdef DELAY_SLOTS
2982 if (dbr_sched_dump)
2984 clean_dump_file (".dbr");
2985 if (graph_dump_format != no_graph)
2986 clean_graph_dump_file (dump_base_name, ".dbr");
2988 #endif
2989 if (gcse_dump)
2991 clean_dump_file (".gcse");
2992 if (graph_dump_format != no_graph)
2993 clean_graph_dump_file (dump_base_name, ".gcse");
2995 #ifdef STACK_REGS
2996 if (stack_reg_dump)
2998 clean_dump_file (".stack");
2999 if (graph_dump_format != no_graph)
3000 clean_graph_dump_file (dump_base_name, ".stack");
3002 #endif
3003 #ifdef MACHINE_DEPENDENT_REORG
3004 if (mach_dep_reorg_dump)
3006 clean_dump_file (".mach");
3007 if (graph_dump_format != no_graph)
3008 clean_graph_dump_file (dump_base_name, ".mach");
3010 #endif
3012 /* Open assembler code output file. */
3014 if (flag_syntax_only)
3015 asm_out_file = NULL;
3016 else
3018 if (! name_specified && asm_file_name == 0)
3019 asm_out_file = stdout;
3020 else
3022 int len = strlen (dump_base_name);
3023 register char *dumpname = (char *) xmalloc (len + 6);
3024 strcpy (dumpname, dump_base_name);
3025 strip_off_ending (dumpname, len);
3026 strcat (dumpname, ".s");
3027 if (asm_file_name == 0)
3028 asm_file_name = xstrdup (dumpname);
3029 if (!strcmp (asm_file_name, "-"))
3030 asm_out_file = stdout;
3031 else
3032 asm_out_file = fopen (asm_file_name, "w");
3033 if (asm_out_file == 0)
3034 pfatal_with_name (asm_file_name);
3037 #ifdef IO_BUFFER_SIZE
3038 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
3039 _IOFBF, IO_BUFFER_SIZE);
3040 #endif
3043 if (ggc_p)
3044 name = ggc_alloc_string (name, strlen (name));
3045 input_filename = name;
3047 /* Put an entry on the input file stack for the main input file. */
3048 input_file_stack
3049 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
3050 input_file_stack->next = 0;
3051 input_file_stack->name = input_filename;
3053 /* Perform language-specific initialization.
3054 This may set main_input_filename. */
3055 lang_init ();
3057 /* If the input doesn't start with a #line, use the input name
3058 as the official input file name. */
3059 if (main_input_filename == 0)
3060 main_input_filename = name;
3062 if (flag_syntax_only)
3064 write_symbols = NO_DEBUG;
3065 profile_flag = 0;
3066 profile_block_flag = 0;
3068 else
3070 ASM_FILE_START (asm_out_file);
3072 #ifdef ASM_COMMENT_START
3073 if (flag_verbose_asm)
3075 /* Print the list of options in effect. */
3076 print_version (asm_out_file, ASM_COMMENT_START);
3077 print_switch_values (asm_out_file, 0, MAX_LINE,
3078 ASM_COMMENT_START, " ", "\n");
3079 /* Add a blank line here so it appears in assembler output but not
3080 screen output. */
3081 fprintf (asm_out_file, "\n");
3083 #endif
3085 /* Output something to inform GDB that this compilation was by GCC. */
3086 #ifndef ASM_IDENTIFY_GCC
3087 fprintf (asm_out_file, "gcc2_compiled.:\n");
3088 #else
3089 ASM_IDENTIFY_GCC (asm_out_file);
3090 #endif
3092 /* Output something to identify which front-end produced this file. */
3093 #ifdef ASM_IDENTIFY_LANGUAGE
3094 ASM_IDENTIFY_LANGUAGE (asm_out_file);
3095 #endif
3096 } /* ! flag_syntax_only */
3098 #ifndef ASM_OUTPUT_SECTION_NAME
3099 if (flag_function_sections)
3101 warning ("-ffunction-sections not supported for this target.");
3102 flag_function_sections = 0;
3104 if (flag_data_sections)
3106 warning ("-fdata-sections not supported for this target.");
3107 flag_data_sections = 0;
3109 #endif
3111 if (flag_function_sections
3112 && (profile_flag || profile_block_flag))
3114 warning ("-ffunction-sections disabled; it makes profiling impossible.");
3115 flag_function_sections = 0;
3118 #ifndef OBJECT_FORMAT_ELF
3119 if (flag_function_sections && write_symbols != NO_DEBUG)
3120 warning ("-ffunction-sections may affect debugging on some targets.");
3121 #endif
3123 /* ??? Note: There used to be a conditional here
3124 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
3125 This was to guarantee separation between gcc_compiled. and
3126 the first function, for the sake of dbx on Suns.
3127 However, having the extra zero here confused the Emacs
3128 code for unexec, and might confuse other programs too.
3129 Therefore, I took out that change.
3130 In future versions we should find another way to solve
3131 that dbx problem. -- rms, 23 May 93. */
3133 /* Don't let the first function fall at the same address
3134 as gcc_compiled., if profiling. */
3135 if (profile_flag || profile_block_flag)
3137 /* It's best if we can write a nop here since some
3138 assemblers don't tolerate zeros in the text section. */
3139 output_asm_insn (get_insn_template (CODE_FOR_nop, NULL), NULL_PTR);
3142 /* If dbx symbol table desired, initialize writing it
3143 and output the predefined types. */
3144 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3145 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3146 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
3147 getdecls ()));
3148 #endif
3149 #ifdef SDB_DEBUGGING_INFO
3150 if (write_symbols == SDB_DEBUG)
3151 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
3152 getdecls ()));
3153 #endif
3154 #ifdef DWARF_DEBUGGING_INFO
3155 if (write_symbols == DWARF_DEBUG)
3156 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
3157 #endif
3158 #ifdef DWARF2_UNWIND_INFO
3159 if (dwarf2out_do_frame ())
3160 dwarf2out_frame_init ();
3161 #endif
3162 #ifdef DWARF2_DEBUGGING_INFO
3163 if (write_symbols == DWARF2_DEBUG)
3164 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
3165 #endif
3167 /* Initialize yet another pass. */
3169 init_final (main_input_filename);
3170 init_branch_prob (dump_base_name);
3172 start_time = get_run_time ();
3174 /* Call the parser, which parses the entire file
3175 (calling rest_of_compilation for each function). */
3177 if (yyparse () != 0)
3179 if (errorcount == 0)
3180 notice ("Errors detected in input file (your bison.simple is out of date)\n");
3182 /* In case there were missing closebraces,
3183 get us back to the global binding level. */
3184 while (! global_bindings_p ())
3185 poplevel (0, 0, 0);
3188 /* Compilation is now finished except for writing
3189 what's left of the symbol table output. */
3191 parse_time += get_run_time () - start_time;
3193 parse_time -= integration_time;
3194 parse_time -= varconst_time;
3196 if (flag_syntax_only)
3197 goto finish_syntax;
3199 globals = getdecls ();
3201 /* Really define vars that have had only a tentative definition.
3202 Really output inline functions that must actually be callable
3203 and have not been output so far. */
3206 int len = list_length (globals);
3207 tree *vec = (tree *) alloca (sizeof (tree) * len);
3208 int i;
3209 tree decl;
3211 /* Process the decls in reverse order--earliest first.
3212 Put them into VEC from back to front, then take out from front. */
3214 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
3215 vec[len - i - 1] = decl;
3217 wrapup_global_declarations (vec, len);
3219 /* This must occur after the loop to output deferred functions. Else
3220 the profiler initializer would not be emitted if all the functions
3221 in this compilation unit were deferred.
3223 output_func_start_profiler can not cause any additional functions or
3224 data to need to be output, so it need not be in the deferred function
3225 loop above. */
3226 output_func_start_profiler ();
3228 /* Now that all possible functions have been output, we can dump
3229 the exception table. */
3231 output_exception_table ();
3233 check_global_declarations (vec, len);
3236 /* Write out any pending weak symbol declarations. */
3238 weak_finish ();
3240 /* Do dbx symbols */
3241 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3242 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3243 TIMEVAR (symout_time,
3245 dbxout_finish (asm_out_file, main_input_filename);
3247 #endif
3249 #ifdef DWARF_DEBUGGING_INFO
3250 if (write_symbols == DWARF_DEBUG)
3251 TIMEVAR (symout_time,
3253 dwarfout_finish ();
3255 #endif
3257 #ifdef DWARF2_UNWIND_INFO
3258 if (dwarf2out_do_frame ())
3259 dwarf2out_frame_finish ();
3260 #endif
3262 #ifdef DWARF2_DEBUGGING_INFO
3263 if (write_symbols == DWARF2_DEBUG)
3264 TIMEVAR (symout_time,
3266 dwarf2out_finish ();
3268 #endif
3270 /* Output some stuff at end of file if nec. */
3272 end_final (dump_base_name);
3274 if (branch_prob_dump)
3275 open_dump_file (".bp", NULL);
3277 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
3279 if (branch_prob_dump)
3280 close_dump_file (NULL, NULL_RTX);
3282 #ifdef ASM_FILE_END
3283 ASM_FILE_END (asm_out_file);
3284 #endif
3287 /* Language-specific end of compilation actions. */
3288 finish_syntax:
3289 lang_finish ();
3291 /* Close the dump files. */
3293 if (flag_gen_aux_info)
3295 fclose (aux_info_file);
3296 if (errorcount)
3297 unlink (aux_info_file_name);
3300 if (combine_dump)
3302 open_dump_file (".combine", NULL);
3303 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
3304 close_dump_file (NULL, NULL_RTX);
3307 /* Close non-debugging input and output files. Take special care to note
3308 whether fclose returns an error, since the pages might still be on the
3309 buffer chain while the file is open. */
3311 finish_parse ();
3313 if (! flag_syntax_only
3314 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
3315 fatal_io_error (asm_file_name);
3317 /* Do whatever is necessary to finish printing the graphs. */
3318 if (graph_dump_format != no_graph)
3320 if (jump_opt_dump)
3321 finish_graph_dump_file (dump_base_name, ".jump");
3322 if (addressof_dump)
3323 finish_graph_dump_file (dump_base_name, ".addressof");
3324 if (cse_dump)
3325 finish_graph_dump_file (dump_base_name, ".cse");
3326 if (loop_dump)
3327 finish_graph_dump_file (dump_base_name, ".loop");
3328 if (cse2_dump)
3329 finish_graph_dump_file (dump_base_name, ".cse2");
3330 if (branch_prob_dump)
3331 finish_graph_dump_file (dump_base_name, ".bp");
3332 if (flow_dump)
3333 finish_graph_dump_file (dump_base_name, ".flow");
3334 if (combine_dump)
3335 finish_graph_dump_file (dump_base_name, ".combine");
3336 if (regmove_dump)
3337 finish_graph_dump_file (dump_base_name, ".regmove");
3338 if (sched_dump)
3339 finish_graph_dump_file (dump_base_name, ".sched");
3340 if (local_reg_dump)
3341 finish_graph_dump_file (dump_base_name, ".lreg");
3342 if (global_reg_dump)
3343 finish_graph_dump_file (dump_base_name, ".greg");
3344 if (flow2_dump)
3345 finish_graph_dump_file (dump_base_name, ".flow2");
3346 if (sched2_dump)
3347 finish_graph_dump_file (dump_base_name, ".sched2");
3348 if (jump2_opt_dump)
3349 finish_graph_dump_file (dump_base_name, ".jump2");
3350 #ifdef DELAY_SLOTS
3351 if (dbr_sched_dump)
3352 finish_graph_dump_file (dump_base_name, ".dbr");
3353 #endif
3354 if (gcse_dump)
3355 finish_graph_dump_file (dump_base_name, ".gcse");
3356 #ifdef STACK_REGS
3357 if (stack_reg_dump)
3358 finish_graph_dump_file (dump_base_name, ".stack");
3359 #endif
3360 #ifdef MACHINE_DEPENDENT_REORG
3361 if (mach_dep_reorg_dump)
3362 finish_graph_dump_file (dump_base_name, ".mach");
3363 #endif
3366 /* Free up memory for the benefit of leak detectors. */
3367 free_reg_info ();
3369 /* Print the times. */
3371 if (! quiet_flag)
3373 all_time = get_run_time ();
3375 fprintf (stderr,"\n");
3377 print_time ("parse", parse_time);
3378 print_time ("integration", integration_time);
3379 print_time ("jump", jump_time);
3380 print_time ("cse", cse_time);
3381 print_time ("gcse", gcse_time);
3382 print_time ("loop", loop_time);
3383 print_time ("cse2", cse2_time);
3384 print_time ("branch-prob", branch_prob_time);
3385 print_time ("flow", flow_time);
3386 print_time ("combine", combine_time);
3387 print_time ("regmove", regmove_time);
3388 print_time ("sched", sched_time);
3389 print_time ("local-alloc", local_alloc_time);
3390 print_time ("global-alloc", global_alloc_time);
3391 print_time ("flow2", flow2_time);
3392 print_time ("sched2", sched2_time);
3393 #ifdef DELAY_SLOTS
3394 print_time ("dbranch", dbr_sched_time);
3395 #endif
3396 print_time ("shorten-branch", shorten_branch_time);
3397 print_time ("stack-reg", stack_reg_time);
3398 print_time ("final", final_time);
3399 print_time ("varconst", varconst_time);
3400 print_time ("symout", symout_time);
3401 print_time ("dump", dump_time);
3402 print_time ("gc", gc_time);
3406 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3407 and TYPE_DECL nodes.
3409 This does nothing for local (non-static) variables, unless the
3410 variable is a register variable with an ASMSPEC. In that case, or
3411 if the variable is not an automatice, it sets up the RTL and
3412 outputs any assembler code (label definition, storage allocation
3413 and initialization).
3415 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3416 the assembler symbol name to be used. TOP_LEVEL is nonzero
3417 if this declaration is not within a function. */
3419 void
3420 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
3421 tree decl;
3422 const char *asmspec;
3423 int top_level;
3424 int at_end;
3426 /* Declarations of variables, and of functions defined elsewhere. */
3428 /* The most obvious approach, to put an #ifndef around where
3429 this macro is used, doesn't work since it's inside a macro call. */
3430 #ifndef ASM_FINISH_DECLARE_OBJECT
3431 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3432 #endif
3434 /* Forward declarations for nested functions are not "external",
3435 but we need to treat them as if they were. */
3436 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
3437 || TREE_CODE (decl) == FUNCTION_DECL)
3438 TIMEVAR (varconst_time,
3440 make_decl_rtl (decl, asmspec, top_level);
3441 /* Initialized extern variable exists to be replaced
3442 with its value, or represents something that will be
3443 output in another file. */
3444 if (! (TREE_CODE (decl) == VAR_DECL
3445 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
3446 && DECL_INITIAL (decl) != 0
3447 && DECL_INITIAL (decl) != error_mark_node))
3448 /* Don't output anything
3449 when a tentative file-scope definition is seen.
3450 But at end of compilation, do output code for them. */
3451 if (! (! at_end && top_level
3452 && (DECL_INITIAL (decl) == 0
3453 || DECL_INITIAL (decl) == error_mark_node)))
3454 assemble_variable (decl, top_level, at_end, 0);
3455 if (decl == last_assemble_variable_decl)
3457 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
3458 top_level, at_end);
3461 else if (DECL_REGISTER (decl) && asmspec != 0)
3463 if (decode_reg_name (asmspec) >= 0)
3465 DECL_RTL (decl) = 0;
3466 make_decl_rtl (decl, asmspec, top_level);
3468 else
3469 error ("invalid register name `%s' for register variable", asmspec);
3471 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3472 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3473 && TREE_CODE (decl) == TYPE_DECL)
3474 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
3475 #endif
3476 #ifdef SDB_DEBUGGING_INFO
3477 else if (write_symbols == SDB_DEBUG && top_level
3478 && TREE_CODE (decl) == TYPE_DECL)
3479 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
3480 #endif
3483 /* Called after finishing a record, union or enumeral type. */
3485 void
3486 rest_of_type_compilation (type, toplev)
3487 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3488 tree type;
3489 int toplev;
3490 #else
3491 tree type ATTRIBUTE_UNUSED;
3492 int toplev ATTRIBUTE_UNUSED;
3493 #endif
3495 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3496 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3497 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3498 #endif
3499 #ifdef SDB_DEBUGGING_INFO
3500 if (write_symbols == SDB_DEBUG)
3501 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3502 #endif
3505 /* This is called from finish_function (within yyparse)
3506 after each top-level definition is parsed.
3507 It is supposed to compile that function or variable
3508 and output the assembler code for it.
3509 After we return, the tree storage is freed. */
3511 void
3512 rest_of_compilation (decl)
3513 tree decl;
3515 register rtx insns;
3516 int start_time = get_run_time ();
3517 int tem;
3518 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3519 to be restored after we finish compiling the function
3520 (for use when compiling inline calls to this function). */
3521 tree saved_block_tree = 0;
3522 /* Likewise, for DECL_ARGUMENTS. */
3523 tree saved_arguments = 0;
3524 int failure = 0;
3525 int rebuild_label_notes_after_reload;
3527 /* If we are reconsidering an inline function
3528 at the end of compilation, skip the stuff for making it inline. */
3530 if (DECL_SAVED_INSNS (decl) == 0)
3532 int inlinable = 0;
3533 const char *lose;
3535 /* If requested, consider whether to make this function inline. */
3536 if (DECL_INLINE (decl) || flag_inline_functions)
3537 TIMEVAR (integration_time,
3539 lose = function_cannot_inline_p (decl);
3540 if (lose || ! optimize)
3542 if (warn_inline && DECL_INLINE (decl))
3543 warning_with_decl (decl, lose);
3544 DECL_ABSTRACT_ORIGIN (decl) = 0;
3545 /* Don't really compile an extern inline function.
3546 If we can't make it inline, pretend
3547 it was only declared. */
3548 if (DECL_EXTERNAL (decl))
3550 DECL_INITIAL (decl) = 0;
3551 goto exit_rest_of_compilation;
3554 else
3555 /* ??? Note that this has the effect of making it look
3556 like "inline" was specified for a function if we choose
3557 to inline it. This isn't quite right, but it's
3558 probably not worth the trouble to fix. */
3559 inlinable = DECL_INLINE (decl) = 1;
3562 insns = get_insns ();
3564 /* Dump the rtl code if we are dumping rtl. */
3566 if (rtl_dump)
3568 open_dump_file (".rtl", decl_printable_name (decl, 2));
3570 if (DECL_SAVED_INSNS (decl))
3571 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3573 close_dump_file (print_rtl, insns);
3576 /* If function is inline, and we don't yet know whether to
3577 compile it by itself, defer decision till end of compilation.
3578 finish_compilation will call rest_of_compilation again
3579 for those functions that need to be output. Also defer those
3580 functions that we are supposed to defer. */
3582 if (inlinable)
3583 DECL_DEFER_OUTPUT (decl) = 1;
3585 if (DECL_DEFER_OUTPUT (decl)
3586 || (DECL_INLINE (decl)
3587 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3588 && ! flag_keep_inline_functions)
3589 || DECL_EXTERNAL (decl))))
3591 DECL_DEFER_OUTPUT (decl) = 1;
3593 /* If -Wreturn-type, we have to do a bit of compilation.
3594 However, if we just fall through we will call
3595 save_for_inline_copying() which results in excessive
3596 memory use. Instead, we just want to call
3597 jump_optimize() to figure out whether or not we can fall
3598 off the end of the function; we do the minimum amount of
3599 work necessary to make that safe. And, we set optimize
3600 to zero to keep jump_optimize from working too hard. */
3601 if (warn_return_type)
3603 int saved_optimize = optimize;
3604 optimize = 0;
3605 find_exception_handler_labels ();
3606 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3607 !JUMP_AFTER_REGSCAN);
3608 optimize = saved_optimize;
3611 #ifdef DWARF_DEBUGGING_INFO
3612 /* Generate the DWARF info for the "abstract" instance
3613 of a function which we may later generate inlined and/or
3614 out-of-line instances of. */
3615 if (write_symbols == DWARF_DEBUG)
3617 set_decl_abstract_flags (decl, 1);
3618 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3619 set_decl_abstract_flags (decl, 0);
3621 #endif
3622 #ifdef DWARF2_DEBUGGING_INFO
3623 /* Generate the DWARF2 info for the "abstract" instance
3624 of a function which we may later generate inlined and/or
3625 out-of-line instances of. */
3626 if (write_symbols == DWARF2_DEBUG)
3628 set_decl_abstract_flags (decl, 1);
3629 TIMEVAR (symout_time, dwarf2out_decl (decl));
3630 set_decl_abstract_flags (decl, 0);
3632 #endif
3633 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3634 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
3635 goto exit_rest_of_compilation;
3638 /* If specified extern inline but we aren't inlining it, we are
3639 done. This goes for anything that gets here with DECL_EXTERNAL
3640 set, not just things with DECL_INLINE. */
3641 if (DECL_EXTERNAL (decl))
3642 goto exit_rest_of_compilation;
3645 /* Initialize some variables used by the optimizers. */
3646 init_function_for_compilation ();
3648 if (! DECL_DEFER_OUTPUT (decl))
3649 TREE_ASM_WRITTEN (decl) = 1;
3651 /* Now that integrate will no longer see our rtl, we need not distinguish
3652 between the return value of this function and the return value of called
3653 functions. */
3654 rtx_equal_function_value_matters = 0;
3656 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3657 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3659 goto exit_rest_of_compilation;
3662 /* Emit code to get eh context, if needed. */
3663 emit_eh_context ();
3665 #ifdef FINALIZE_PIC
3666 /* If we are doing position-independent code generation, now
3667 is the time to output special prologues and epilogues.
3668 We do not want to do this earlier, because it just clutters
3669 up inline functions with meaningless insns. */
3670 if (flag_pic)
3671 FINALIZE_PIC;
3672 #endif
3674 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3675 Note that that may have been done above, in save_for_inline_copying.
3676 The call to resume_temporary_allocation near the end of this function
3677 goes back to the usual state of affairs. This must be done after
3678 we've built up any unwinders for exception handling, and done
3679 the FINALIZE_PIC work, if necessary. */
3681 rtl_in_current_obstack ();
3683 insns = get_insns ();
3685 /* Copy any shared structure that should not be shared. */
3687 unshare_all_rtl (insns);
3689 init_EXPR_INSN_LIST_cache ();
3691 #ifdef SETJMP_VIA_SAVE_AREA
3692 /* This must be performed before virutal register instantiation. */
3693 if (current_function_calls_alloca)
3694 optimize_save_area_alloca (insns);
3695 #endif
3697 /* Instantiate all virtual registers. */
3699 instantiate_virtual_regs (current_function_decl, get_insns ());
3701 /* See if we have allocated stack slots that are not directly addressable.
3702 If so, scan all the insns and create explicit address computation
3703 for all references to such slots. */
3704 /* fixup_stack_slots (); */
3706 /* Find all the EH handlers. */
3707 find_exception_handler_labels ();
3709 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3710 are initialized and to compute whether control can drop off the end
3711 of the function. */
3712 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3713 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3714 JUMP_AFTER_REGSCAN));
3716 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3717 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3718 goto exit_rest_of_compilation;
3720 /* Try to identify useless null pointer tests and delete them. */
3721 if (flag_delete_null_pointer_checks)
3722 TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
3724 /* Dump rtl code after jump, if we are doing that. */
3725 if (jump_opt_dump)
3726 dump_rtl (".jump", decl, print_rtl, insns);
3728 if (ggc_p)
3729 ggc_collect ();
3731 /* Perform common subexpression elimination.
3732 Nonzero value from `cse_main' means that jumps were simplified
3733 and some code may now be unreachable, so do
3734 jump optimization again. */
3736 if (optimize > 0)
3738 if (cse_dump)
3739 open_dump_file (".cse", decl_printable_name (decl, 2));
3741 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3743 if (flag_thread_jumps)
3744 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3746 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3747 0, rtl_dump_file));
3748 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3750 /* If we are not running the second CSE pass, then we are no longer
3751 expecting CSE to be run. */
3752 cse_not_expected = !flag_rerun_cse_after_loop;
3754 if (tem || optimize > 1)
3755 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3756 !JUMP_NOOP_MOVES,
3757 !JUMP_AFTER_REGSCAN));
3759 /* Try to identify useless null pointer tests and delete them. */
3760 if (flag_delete_null_pointer_checks)
3761 TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
3763 /* Dump rtl code after cse, if we are doing that. */
3765 if (cse_dump)
3767 close_dump_file (print_rtl, insns);
3768 if (graph_dump_format != no_graph)
3769 print_rtl_graph_with_bb (dump_base_name, ".cse", insns);
3773 purge_addressof (insns);
3774 reg_scan (insns, max_reg_num (), 1);
3776 if (addressof_dump)
3778 dump_rtl (".addressof", decl, print_rtl, insns);
3779 if (graph_dump_format != no_graph)
3780 print_rtl_graph_with_bb (dump_base_name, ".addressof", insns);
3783 if (ggc_p)
3784 ggc_collect ();
3786 /* Perform global cse. */
3788 if (optimize > 0 && flag_gcse)
3790 if (gcse_dump)
3791 open_dump_file (".gcse", decl_printable_name (decl, 2));
3793 TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file));
3795 /* If gcse altered any jumps, rerun jump optimizations to clean
3796 things up. */
3797 if (tem)
3799 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3800 !JUMP_NOOP_MOVES,
3801 !JUMP_AFTER_REGSCAN));
3804 if (gcse_dump)
3806 close_dump_file (print_rtl, insns);
3807 if (graph_dump_format != no_graph)
3808 print_rtl_graph_with_bb (dump_base_name, ".gcse", insns);
3811 if (ggc_p)
3812 ggc_collect ();
3814 /* Move constant computations out of loops. */
3816 if (optimize > 0)
3818 if (loop_dump)
3819 open_dump_file (".loop", decl_printable_name (decl, 2));
3821 TIMEVAR
3822 (loop_time,
3824 if (flag_rerun_loop_opt)
3826 /* We only want to perform unrolling once. */
3828 loop_optimize (insns, rtl_dump_file, 0, 0);
3831 /* The first call to loop_optimize makes some instructions
3832 trivially dead. We delete those instructions now in the
3833 hope that doing so will make the heuristics in loop work
3834 better and possibly speed up compilation. */
3835 delete_trivially_dead_insns (insns, max_reg_num ());
3837 /* The regscan pass is currently necessary as the alias
3838 analysis code depends on this information. */
3839 reg_scan (insns, max_reg_num (), 1);
3841 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
3844 /* Dump rtl code after loop opt, if we are doing that. */
3846 if (loop_dump)
3848 close_dump_file (print_rtl, insns);
3849 if (graph_dump_format != no_graph)
3850 print_rtl_graph_with_bb (dump_base_name, ".loop", insns);
3853 if (ggc_p)
3854 ggc_collect ();
3857 if (optimize > 0)
3859 if (cse2_dump)
3860 open_dump_file (".cse2", decl_printable_name (decl, 2));
3862 if (flag_rerun_cse_after_loop)
3864 /* Running another jump optimization pass before the second
3865 cse pass sometimes simplifies the RTL enough to allow
3866 the second CSE pass to do a better job. Jump_optimize can change
3867 max_reg_num so we must rerun reg_scan afterwards.
3868 ??? Rework to not call reg_scan so often. */
3869 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3870 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3871 !JUMP_NOOP_MOVES,
3872 JUMP_AFTER_REGSCAN));
3874 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3875 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3876 1, rtl_dump_file));
3877 if (tem)
3878 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3879 !JUMP_NOOP_MOVES,
3880 !JUMP_AFTER_REGSCAN));
3883 if (flag_thread_jumps)
3885 /* This pass of jump threading straightens out code
3886 that was kinked by loop optimization. */
3887 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3888 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3891 /* Dump rtl code after cse, if we are doing that. */
3893 if (cse2_dump)
3895 close_dump_file (print_rtl, insns);
3896 if (graph_dump_format != no_graph)
3897 print_rtl_graph_with_bb (dump_base_name, ".cse2", insns);
3900 if (ggc_p)
3901 ggc_collect ();
3904 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3906 if (branch_prob_dump)
3907 open_dump_file (".bp", decl_printable_name (decl, 2));
3909 TIMEVAR
3910 (branch_prob_time,
3912 branch_prob (insns, rtl_dump_file);
3915 if (branch_prob_dump)
3917 close_dump_file (print_rtl, insns);
3918 if (graph_dump_format != no_graph)
3919 print_rtl_graph_with_bb (dump_base_name, ".bp", insns);
3922 if (ggc_p)
3923 ggc_collect ();
3926 /* We are no longer anticipating cse in this function, at least. */
3928 cse_not_expected = 1;
3930 /* Now we choose between stupid (pcc-like) register allocation
3931 (if we got the -noreg switch and not -opt)
3932 and smart register allocation. */
3934 if (optimize > 0) /* Stupid allocation probably won't work */
3935 obey_regdecls = 0; /* if optimizations being done. */
3937 regclass_init ();
3939 /* Print function header into flow dump now
3940 because doing the flow analysis makes some of the dump. */
3942 if (flow_dump)
3943 open_dump_file (".flow", decl_printable_name (decl, 2));
3945 if (obey_regdecls)
3947 TIMEVAR (flow_time,
3949 regclass (insns, max_reg_num ());
3950 stupid_life_analysis (insns, max_reg_num (),
3951 rtl_dump_file);
3954 else
3956 /* Do control and data flow analysis,
3957 and write some of the results to dump file. */
3959 TIMEVAR
3960 (flow_time,
3962 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
3963 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
3966 if (warn_uninitialized)
3968 uninitialized_vars_warning (DECL_INITIAL (decl));
3969 setjmp_args_warning ();
3973 /* Dump rtl after flow analysis. */
3975 if (flow_dump)
3977 close_dump_file (print_rtl_with_bb, insns);
3978 if (graph_dump_format != no_graph)
3979 print_rtl_graph_with_bb (dump_base_name, ".flow", insns);
3982 if (ggc_p)
3983 ggc_collect ();
3985 /* The first life analysis pass has finished. From now on we can not
3986 generate any new pseudos. */
3987 no_new_pseudos = 1;
3989 /* If -opt, try combining insns through substitution. */
3991 if (optimize > 0)
3993 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3995 /* Dump rtl code after insn combination. */
3997 if (combine_dump)
3999 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
4000 if (graph_dump_format != no_graph)
4001 print_rtl_graph_with_bb (dump_base_name, ".combine", insns);
4004 if (ggc_p)
4005 ggc_collect ();
4008 /* Register allocation pre-pass, to reduce number of moves
4009 necessary for two-address machines. */
4010 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
4012 if (regmove_dump)
4013 open_dump_file (".regmove", decl_printable_name (decl, 2));
4015 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
4016 rtl_dump_file));
4018 if (regmove_dump)
4020 close_dump_file (print_rtl_with_bb, insns);
4021 if (graph_dump_format != no_graph)
4022 print_rtl_graph_with_bb (dump_base_name, ".regmove", insns);
4025 if (ggc_p)
4026 ggc_collect ();
4029 /* Print function header into sched dump now
4030 because doing the sched analysis makes some of the dump. */
4032 if (optimize > 0 && flag_schedule_insns)
4034 if (sched_dump)
4035 open_dump_file (".sched", decl_printable_name (decl, 2));
4037 /* Do control and data sched analysis,
4038 and write some of the results to dump file. */
4040 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
4042 /* Dump rtl after instruction scheduling. */
4044 if (sched_dump)
4046 close_dump_file (print_rtl_with_bb, insns);
4047 if (graph_dump_format != no_graph)
4048 print_rtl_graph_with_bb (dump_base_name, ".sched", insns);
4051 if (ggc_p)
4052 ggc_collect ();
4055 /* Determine if the current function is a leaf before running reload
4056 since this can impact optimizations done by the prologue and
4057 epilogue thus changing register elimination offsets. */
4058 current_function_is_leaf = leaf_function_p ();
4060 /* Unless we did stupid register allocation,
4061 allocate pseudo-regs that are used only within 1 basic block.
4063 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
4064 jump optimizer after register allocation and reloading are finished. */
4066 if (!obey_regdecls)
4067 TIMEVAR (local_alloc_time,
4069 recompute_reg_usage (insns, ! optimize_size);
4070 regclass (insns, max_reg_num ());
4071 rebuild_label_notes_after_reload = local_alloc ();
4073 else
4074 rebuild_label_notes_after_reload = 0;
4076 /* Dump rtl code after allocating regs within basic blocks. */
4078 if (local_reg_dump)
4080 open_dump_file (".lreg", decl_printable_name (decl, 2));
4082 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
4083 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
4085 close_dump_file (print_rtl_with_bb, insns);
4086 if (graph_dump_format != no_graph)
4087 print_rtl_graph_with_bb (dump_base_name, ".lreg", insns);
4090 if (ggc_p)
4091 ggc_collect ();
4093 if (global_reg_dump)
4094 open_dump_file (".greg", decl_printable_name (decl, 2));
4096 /* Unless we did stupid register allocation,
4097 allocate remaining pseudo-regs, then do the reload pass
4098 fixing up any insns that are invalid. */
4100 TIMEVAR (global_alloc_time,
4102 if (!obey_regdecls)
4103 failure = global_alloc (rtl_dump_file);
4104 else
4105 failure = reload (insns, 0, rtl_dump_file);
4109 if (failure)
4110 goto exit_rest_of_compilation;
4112 if (ggc_p)
4113 ggc_collect ();
4115 /* Do a very simple CSE pass over just the hard registers. */
4116 if (optimize > 0)
4117 reload_cse_regs (insns);
4119 /* Register allocation and reloading may have turned an indirect jump into
4120 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
4121 jumping instructions. */
4122 if (rebuild_label_notes_after_reload)
4123 TIMEVAR (jump_time, rebuild_jump_labels (insns));
4125 /* If optimizing and we are performing instruction scheduling after
4126 reload, then go ahead and split insns now since we are about to
4127 recompute flow information anyway.
4129 reload_cse_regs may expose more splitting opportunities, expecially
4130 for double-word operations. */
4131 if (optimize > 0 && flag_schedule_insns_after_reload)
4133 rtx insn;
4135 for (insn = insns; insn; insn = NEXT_INSN (insn))
4137 rtx last;
4139 if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
4140 continue;
4142 last = try_split (PATTERN (insn), insn, 1);
4144 if (last != insn)
4146 PUT_CODE (insn, NOTE);
4147 NOTE_SOURCE_FILE (insn) = 0;
4148 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
4153 if (global_reg_dump)
4155 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
4156 close_dump_file (print_rtl_with_bb, insns);
4157 if (graph_dump_format != no_graph)
4158 print_rtl_graph_with_bb (dump_base_name, ".greg", insns);
4161 /* Re-create the death notes which were deleted during reload. */
4162 if (flow2_dump)
4163 open_dump_file (".flow2", decl_printable_name (decl, 2));
4165 if (optimize)
4167 TIMEVAR
4168 (flow2_time,
4170 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4171 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4174 if (ggc_p)
4175 ggc_collect ();
4178 flow2_completed = 1;
4180 /* On some machines, the prologue and epilogue code, or parts thereof,
4181 can be represented as RTL. Doing so lets us schedule insns between
4182 it and the rest of the code and also allows delayed branch
4183 scheduling to operate in the epilogue. */
4185 thread_prologue_and_epilogue_insns (insns);
4187 if (flow2_dump)
4189 close_dump_file (print_rtl_with_bb, insns);
4190 if (graph_dump_format != no_graph)
4191 print_rtl_graph_with_bb (dump_base_name, ".flow2", insns);
4194 #ifdef HAVE_peephole2
4195 if (optimize > 0 && flag_peephole2)
4197 if (peephole2_dump)
4198 open_dump_file (".peephole2", decl_printable_name (decl, 2));
4200 peephole2_optimize (rtl_dump_file);
4202 if (peephole2_dump)
4204 close_dump_file (print_rtl_with_bb, insns);
4205 if (graph_dump_format != no_graph)
4206 print_rtl_graph_with_bb (dump_base_name, ".peephole2", insns);
4209 #endif
4211 if (optimize > 0 && flag_schedule_insns_after_reload)
4213 if (sched2_dump)
4214 open_dump_file (".sched2", decl_printable_name (decl, 2));
4216 /* Do control and data sched analysis again,
4217 and write some more of the results to dump file. */
4219 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
4221 /* Dump rtl after post-reorder instruction scheduling. */
4223 if (sched2_dump)
4225 close_dump_file (print_rtl_with_bb, insns);
4226 if (graph_dump_format != no_graph)
4227 print_rtl_graph_with_bb (dump_base_name, ".sched2", insns);
4230 if (ggc_p)
4231 ggc_collect ();
4234 #ifdef LEAF_REGISTERS
4235 current_function_uses_only_leaf_regs
4236 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
4237 #endif
4239 /* One more attempt to remove jumps to .+1
4240 left by dead-store-elimination.
4241 Also do cross-jumping this time
4242 and delete no-op move insns. */
4244 if (optimize > 0)
4246 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
4247 JUMP_NOOP_MOVES,
4248 !JUMP_AFTER_REGSCAN));
4250 /* Dump rtl code after jump, if we are doing that. */
4252 if (jump2_opt_dump)
4254 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
4255 if (graph_dump_format != no_graph)
4256 print_rtl_graph_with_bb (dump_base_name, ".jump2", insns);
4260 /* If a machine dependent reorganization is needed, call it. */
4261 #ifdef MACHINE_DEPENDENT_REORG
4262 if (mach_dep_reorg_dump)
4263 open_dump_file (".mach", decl_printable_name (decl, 2));
4265 MACHINE_DEPENDENT_REORG (insns);
4267 if (mach_dep_reorg_dump)
4269 close_dump_file (print_rtl_with_bb, insns);
4270 if (graph_dump_format != no_graph)
4271 print_rtl_graph_with_bb (dump_base_name, ".mach", insns);
4274 if (ggc_p)
4275 ggc_collect ();
4276 #endif
4278 /* If a scheduling pass for delayed branches is to be done,
4279 call the scheduling code. */
4281 #ifdef DELAY_SLOTS
4282 if (optimize > 0 && flag_delayed_branch)
4284 if (dbr_sched_dump)
4285 open_dump_file (".dbr", decl_printable_name (decl, 2));
4287 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
4289 if (dbr_sched_dump)
4291 close_dump_file (print_rtl_with_bb, insns);
4292 if (graph_dump_format != no_graph)
4293 print_rtl_graph_with_bb (dump_base_name, ".dbr", insns);
4297 if (ggc_p)
4298 ggc_collect ();
4299 #endif
4301 /* Shorten branches. */
4302 TIMEVAR (shorten_branch_time,
4304 shorten_branches (get_insns ());
4307 #ifdef STACK_REGS
4308 if (stack_reg_dump)
4309 open_dump_file (".stack", decl_printable_name (decl, 2));
4311 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
4313 if (stack_reg_dump)
4315 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
4316 if (graph_dump_format != no_graph)
4317 print_rtl_graph_with_bb (dump_base_name, ".stack", insns);
4320 if (ggc_p)
4321 ggc_collect ();
4322 #endif
4324 /* Now turn the rtl into assembler code. */
4326 TIMEVAR (final_time,
4328 rtx x;
4329 char *fnname;
4331 /* Get the function's name, as described by its RTL.
4332 This may be different from the DECL_NAME name used
4333 in the source file. */
4335 x = DECL_RTL (decl);
4336 if (GET_CODE (x) != MEM)
4337 abort ();
4338 x = XEXP (x, 0);
4339 if (GET_CODE (x) != SYMBOL_REF)
4340 abort ();
4341 fnname = XSTR (x, 0);
4343 assemble_start_function (decl, fnname);
4344 final_start_function (insns, asm_out_file, optimize);
4345 final (insns, asm_out_file, optimize, 0);
4346 final_end_function (insns, asm_out_file, optimize);
4347 assemble_end_function (decl, fnname);
4348 if (! quiet_flag)
4349 fflush (asm_out_file);
4351 /* Release all memory allocated by flow. */
4352 free_basic_block_vars (0);
4354 /* Release all memory held by regsets now */
4355 regset_release_memory ();
4358 if (ggc_p)
4359 ggc_collect ();
4361 /* Write DBX symbols if requested */
4363 /* Note that for those inline functions where we don't initially
4364 know for certain that we will be generating an out-of-line copy,
4365 the first invocation of this routine (rest_of_compilation) will
4366 skip over this code by doing a `goto exit_rest_of_compilation;'.
4367 Later on, finish_compilation will call rest_of_compilation again
4368 for those inline functions that need to have out-of-line copies
4369 generated. During that call, we *will* be routed past here. */
4371 #ifdef DBX_DEBUGGING_INFO
4372 if (write_symbols == DBX_DEBUG)
4373 TIMEVAR (symout_time, dbxout_function (decl));
4374 #endif
4376 #ifdef DWARF_DEBUGGING_INFO
4377 if (write_symbols == DWARF_DEBUG)
4378 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
4379 #endif
4381 #ifdef DWARF2_DEBUGGING_INFO
4382 if (write_symbols == DWARF2_DEBUG)
4383 TIMEVAR (symout_time, dwarf2out_decl (decl));
4384 #endif
4386 exit_rest_of_compilation:
4388 free_bb_mem ();
4390 /* In case the function was not output,
4391 don't leave any temporary anonymous types
4392 queued up for sdb output. */
4393 #ifdef SDB_DEBUGGING_INFO
4394 if (write_symbols == SDB_DEBUG)
4395 sdbout_types (NULL_TREE);
4396 #endif
4398 /* Put back the tree of subblocks and list of arguments
4399 from before we copied them.
4400 Code generation and the output of debugging info may have modified
4401 the copy, but the original is unchanged. */
4403 if (saved_block_tree != 0)
4405 DECL_INITIAL (decl) = saved_block_tree;
4406 DECL_ARGUMENTS (decl) = saved_arguments;
4407 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
4410 reload_completed = 0;
4411 flow2_completed = 0;
4412 no_new_pseudos = 0;
4414 TIMEVAR (final_time,
4416 /* Clear out the insn_length contents now that they are no
4417 longer valid. */
4418 init_insn_lengths ();
4420 /* Clear out the real_constant_chain before some of the rtx's
4421 it runs through become garbage. */
4422 clear_const_double_mem ();
4424 /* Cancel the effect of rtl_in_current_obstack. */
4425 resume_temporary_allocation ();
4427 /* Show no temporary slots allocated. */
4428 init_temp_slots ();
4430 free_basic_block_vars (0);
4433 /* Make sure volatile mem refs aren't considered valid operands for
4434 arithmetic insns. We must call this here if this is a nested inline
4435 function, since the above code leaves us in the init_recog state
4436 (from final.c), and the function context push/pop code does not
4437 save/restore volatile_ok.
4439 ??? Maybe it isn't necessary for expand_start_function to call this
4440 anymore if we do it here? */
4442 init_recog_no_volatile ();
4444 /* We're done with this function. Free up memory if we can. */
4445 free_after_parsing (current_function);
4446 if (! DECL_DEFER_OUTPUT (decl))
4447 free_after_compilation (current_function);
4448 current_function = 0;
4450 if (ggc_p)
4451 ggc_collect ();
4453 /* The parsing time is all the time spent in yyparse
4454 *except* what is spent in this function. */
4456 parse_time -= get_run_time () - start_time;
4459 static void
4460 display_help ()
4462 int undoc;
4463 unsigned long i;
4464 const char * lang;
4466 #ifndef USE_CPPLIB
4467 printf ("Usage: %s input [switches]\n", progname);
4468 printf ("Switches:\n");
4469 #endif
4470 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
4471 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
4472 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4473 printf (" -finline-limit=<number> Limits the size of inlined functions to <number>\n");
4475 for (i = NUM_ELEM (f_options); i--;)
4477 const char * description = f_options[i].description;
4479 if (description != NULL && * description != 0)
4480 printf (" -f%-21s %s\n",
4481 f_options[i].string, description);
4484 printf (" -O[number] Set optimisation level to [number]\n");
4485 printf (" -Os Optimise for space rather than speed\n");
4486 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
4487 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
4488 printf (" -w Suppress warnings\n");
4489 printf (" -W Enable extra warnings\n");
4491 for (i = NUM_ELEM (W_options); i--;)
4493 const char * description = W_options[i].description;
4495 if (description != NULL && * description != 0)
4496 printf (" -W%-21s %s\n",
4497 W_options[i].string, description);
4500 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4501 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4502 printf (" -p Enable function profiling\n");
4503 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4504 printf (" -a Enable block profiling \n");
4505 #endif
4506 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4507 printf (" -ax Enable jump profiling \n");
4508 #endif
4509 printf (" -o <file> Place output into <file> \n");
4510 printf (" -G <number> Put global and static data smaller than <number>\n");
4511 printf (" bytes into a special section (on some targets)\n");
4513 for (i = NUM_ELEM (debug_args); i--;)
4515 if (debug_args[i].description != NULL)
4516 printf (" -g%-21s %s\n", debug_args[i].arg, debug_args[i].description);
4519 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4520 printf (" -quiet Do not display functions compiled or elapsed time\n");
4521 printf (" -version Display the compiler's version\n");
4522 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4523 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4524 #if defined INSN_SCHEDULING
4525 printf (" -sched-verbose=<number> Set the verbosity level of the scheduler\n");
4526 #endif
4527 printf (" --help Display this information\n");
4529 undoc = 0;
4530 lang = "language";
4532 /* Display descriptions of language specific options.
4533 If there is no description, note that there is an undocumented option.
4534 If the description is empty, do not display anything. (This allows
4535 options to be deliberately undocumented, for whatever reason).
4536 If the option string is missing, then this is a marker, indicating
4537 that the description string is in fact the name of a language, whose
4538 language specific options are to follow. */
4540 if (NUM_ELEM (documented_lang_options) > 1)
4542 printf ("\nLanguage specific options:\n");
4544 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
4546 const char * description = documented_lang_options[i].description;
4547 const char * option = documented_lang_options[i].option;
4549 if (description == NULL)
4551 undoc = 1;
4553 if (extra_warnings)
4554 printf (" %-23.23s [undocumented]\n", option);
4556 else if (* description == 0)
4557 continue;
4558 else if (option == NULL)
4560 if (undoc)
4561 printf
4562 ("\nThere are undocumented %s specific options as well.\n",
4563 lang);
4564 undoc = 0;
4566 printf ("\n Options for %s:\n", description);
4568 lang = description;
4570 else
4571 printf (" %-23.23s %s\n", option, description);
4575 if (undoc)
4576 printf ("\nThere are undocumented %s specific options as well.\n", lang);
4578 if (NUM_ELEM (target_switches) > 1
4579 #ifdef TARGET_OPTIONS
4580 || NUM_ELEM (target_options) > 1
4581 #endif
4584 int doc = 0;
4586 undoc = 0;
4588 printf ("\nTarget specific options:\n");
4590 for (i = NUM_ELEM (target_switches); i--;)
4592 const char * option = target_switches[i].name;
4593 const char * description = target_switches[i].description;
4595 if (option == NULL || * option == 0)
4596 continue;
4597 else if (description == NULL)
4599 undoc = 1;
4601 if (extra_warnings)
4602 printf (" -m%-21.21s [undocumented]\n", option);
4604 else if (* description != 0)
4605 doc += printf (" -m%-21.21s %s\n", option, description);
4608 #ifdef TARGET_OPTIONS
4609 for (i = NUM_ELEM (target_options); i--;)
4611 const char * option = target_options[i].prefix;
4612 const char * description = target_options[i].description;
4614 if (option == NULL || * option == 0)
4615 continue;
4616 else if (description == NULL)
4618 undoc = 1;
4620 if (extra_warnings)
4621 printf (" -m%-21.21s [undocumented]\n", option);
4623 else if (* description != 0)
4624 doc += printf (" -m%-21.21s %s\n", option, description);
4626 #endif
4627 if (undoc)
4629 if (doc)
4630 printf ("\nThere are undocumented target specific options as well.\n");
4631 else
4632 printf (" They exist, but they are not documented.\n");
4637 /* Parse a -d... comand line switch. */
4639 static void
4640 decode_d_option (arg)
4641 const char * arg;
4643 while (* arg)
4644 switch (* arg ++)
4646 case 'a':
4647 branch_prob_dump = 1;
4648 combine_dump = 1;
4649 #ifdef DELAY_SLOTS
4650 dbr_sched_dump = 1;
4651 #endif
4652 flow_dump = 1;
4653 flow2_dump = 1;
4654 global_reg_dump = 1;
4655 jump_opt_dump = 1;
4656 addressof_dump = 1;
4657 jump2_opt_dump = 1;
4658 local_reg_dump = 1;
4659 loop_dump = 1;
4660 regmove_dump = 1;
4661 rtl_dump = 1;
4662 cse_dump = 1;
4663 cse2_dump = 1;
4664 gcse_dump = 1;
4665 sched_dump = 1;
4666 sched2_dump = 1;
4667 #ifdef STACK_REGS
4668 stack_reg_dump = 1;
4669 #endif
4670 #ifdef MACHINE_DEPENDENT_REORG
4671 mach_dep_reorg_dump = 1;
4672 #endif
4673 peephole2_dump = 1;
4674 break;
4675 case 'A':
4676 flag_debug_asm = 1;
4677 break;
4678 case 'b':
4679 branch_prob_dump = 1;
4680 break;
4681 case 'c':
4682 combine_dump = 1;
4683 break;
4684 #ifdef DELAY_SLOTS
4685 case 'd':
4686 dbr_sched_dump = 1;
4687 break;
4688 #endif
4689 case 'f':
4690 flow_dump = 1;
4691 break;
4692 case 'F':
4693 addressof_dump = 1;
4694 break;
4695 case 'g':
4696 global_reg_dump = 1;
4697 break;
4698 case 'G':
4699 gcse_dump = 1;
4700 break;
4701 case 'j':
4702 jump_opt_dump = 1;
4703 break;
4704 case 'J':
4705 jump2_opt_dump = 1;
4706 break;
4707 #ifdef STACK_REGS
4708 case 'k':
4709 stack_reg_dump = 1;
4710 break;
4711 #endif
4712 case 'l':
4713 local_reg_dump = 1;
4714 break;
4715 case 'L':
4716 loop_dump = 1;
4717 break;
4718 case 'm':
4719 flag_print_mem = 1;
4720 break;
4721 #ifdef MACHINE_DEPENDENT_REORG
4722 case 'M':
4723 mach_dep_reorg_dump = 1;
4724 break;
4725 #endif
4726 case 'p':
4727 flag_print_asm_name = 1;
4728 break;
4729 case 'r':
4730 rtl_dump = 1;
4731 break;
4732 case 'R':
4733 sched2_dump = 1;
4734 break;
4735 case 's':
4736 cse_dump = 1;
4737 break;
4738 case 'S':
4739 sched_dump = 1;
4740 break;
4741 case 't':
4742 cse2_dump = 1;
4743 break;
4744 case 'N':
4745 regmove_dump = 1;
4746 break;
4747 case 'v':
4748 graph_dump_format = vcg;
4749 break;
4750 case 'w':
4751 flow2_dump = 1;
4752 break;
4753 case 'x':
4754 rtl_dump_and_exit = 1;
4755 break;
4756 case 'y':
4757 set_yydebug (1);
4758 break;
4759 case 'z':
4760 peephole2_dump = 1;
4761 break;
4762 case 'D': /* These are handled by the preprocessor. */
4763 case 'I':
4764 break;
4765 default:
4766 warning ("unrecognised gcc debugging option: %c", arg[-1]);
4767 break;
4771 /* Parse a -f... comand line switch. ARG is the value after the -f.
4772 It is safe to access 'ARG - 2' to generate the full switch name.
4773 Return the number of strings consumed. */
4775 static int
4776 decode_f_option (arg)
4777 const char * arg;
4779 int j;
4781 /* Search for the option in the table of binary f options. */
4782 for (j = sizeof (f_options) / sizeof (f_options[0]); j--;)
4784 if (!strcmp (arg, f_options[j].string))
4786 *f_options[j].variable = f_options[j].on_value;
4787 return 1;
4790 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4791 && ! strcmp (arg + 3, f_options[j].string))
4793 *f_options[j].variable = ! f_options[j].on_value;
4794 return 1;
4798 if (!strncmp (arg, "inline-limit-", 13)
4799 || !strncmp (arg, "inline-limit=", 13))
4800 inline_max_insns =
4801 read_integral_parameter (arg + 13, arg - 2, inline_max_insns);
4802 #ifdef INSN_SCHEDULING
4803 else if (!strncmp (arg, "sched-verbose=", 14))
4804 fix_sched_param ("verbose", (char *)(arg + 14));
4805 #endif
4806 else if (!strncmp (arg, "fixed-", 6))
4807 fix_register ((char *)(arg + 6), 1, 1);
4808 else if (!strncmp (arg, "call-used-", 10))
4809 fix_register ((char *)(arg + 10), 0, 1);
4810 else if (!strncmp (arg, "call-saved-", 11))
4811 fix_register ((char *)(arg + 11), 0, 0);
4812 else if (!strncmp (arg, "align-loops=", 12))
4813 align_loops = read_integral_parameter (arg + 12, arg - 2, align_loops);
4814 else if (!strncmp (arg, "align-functions=", 16))
4815 align_functions =
4816 read_integral_parameter (arg + 16, arg - 2, align_functions);
4817 else if (!strncmp (arg, "align-jumps=", 12))
4818 align_jumps = read_integral_parameter (arg + 12, arg - 2, align_jumps);
4819 else if (!strncmp (arg, "align-labels=", 13))
4820 align_labels = read_integral_parameter (arg + 13, arg - 2, align_labels);
4821 else if (!strcmp (arg, "preprocessed"))
4822 /* Recognise this switch but do nothing. This prevents warnings
4823 about an unrecognised switch if cpplib has not been linked in. */
4825 else
4826 return 0;
4828 return 1;
4831 /* Parse a -W... comand line switch. ARG is the value after the -W.
4832 It is safe to access 'ARG - 2' to generate the full switch name.
4833 Return the number of strings consumed. */
4834 static int
4835 decode_W_option (arg)
4836 const char * arg;
4838 int j;
4840 /* Search for the option in the table of binary W options. */
4842 for (j = sizeof (W_options) / sizeof (W_options[0]); j--;)
4844 if (!strcmp (arg, W_options[j].string))
4846 *W_options[j].variable = W_options[j].on_value;
4847 return 1;
4850 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4851 && ! strcmp (arg + 3, W_options[j].string))
4853 *W_options[j].variable = ! W_options[j].on_value;
4854 return 1;
4858 if (!strncmp (arg, "id-clash-", 9))
4860 const int id_clash_val = read_integral_parameter (arg + 9, arg - 2, -1);
4862 if (id_clash_val != -1)
4864 id_clash_len = id_clash_val;
4865 warn_id_clash = 1;
4868 else if (!strncmp (arg, "larger-than-", 12))
4870 const int larger_than_val =
4871 read_integral_parameter (arg + 12, arg - 2, -1);
4872 if (larger_than_val != -1)
4874 larger_than_size = larger_than_val;
4875 warn_larger_than = 1;
4878 else
4879 return 0;
4881 return 1;
4884 /* Parse a -g... comand line switch. ARG is the value after the -g.
4885 It is safe to access 'ARG - 2' to generate the full switch name.
4886 Return the number of strings consumed. */
4887 static int
4888 decode_g_option (arg)
4889 const char * arg;
4891 unsigned level;
4892 /* A lot of code assumes write_symbols == NO_DEBUG if the
4893 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4894 of what debugging type has been selected). This records the
4895 selected type. It is an error to specify more than one
4896 debugging type. */
4897 static enum debug_info_type selected_debug_type = NO_DEBUG;
4898 /* Non-zero if debugging format has been explicitly set.
4899 -g and -ggdb don't explicitly set the debugging format so
4900 -gdwarf -g3 is equivalent to -gdwarf3. */
4901 static int type_explicitly_set_p = 0;
4902 /* Indexed by enum debug_info_type. */
4903 static const char * debug_type_names[] =
4905 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4908 /* The maximum admissible debug level value. */
4909 static const unsigned max_debug_level = 3;
4911 /* Look up ARG in the table. */
4912 for (da = debug_args; da->arg; da++)
4914 const int da_len = strlen (da->arg);
4916 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4918 enum debug_info_type type = da->debug_type;
4919 const char * p = arg + da_len;
4921 if (*p && (*p < '0' || *p > '9'))
4922 continue;
4924 /* A debug flag without a level defaults to level 2.
4925 Note we do not want to call read_integral_parameter
4926 for that case since it will call atoi which
4927 will return zero.
4929 ??? We may want to generalize the interface to
4930 read_integral_parameter to better handle this case
4931 if this case shows up often. */
4932 if (*p)
4933 level = read_integral_parameter (p, 0, max_debug_level + 1);
4934 else
4935 level = 2;
4937 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4939 error ("use -gdwarf -g%d for DWARF v1, level %d",
4940 level, level);
4941 if (level == 2)
4942 error ("use -gdwarf-2 for DWARF v2");
4945 if (level > max_debug_level)
4947 warning ("\
4948 ignoring option `%s' due to invalid debug level specification",
4949 arg - 2);
4950 level = debug_info_level;
4953 if (type == NO_DEBUG)
4955 type = PREFERRED_DEBUGGING_TYPE;
4957 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4959 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4960 type = DWARF2_DEBUG;
4961 #else
4962 #ifdef DBX_DEBUGGING_INFO
4963 type = DBX_DEBUG;
4964 #endif
4965 #endif
4969 if (type == NO_DEBUG)
4970 warning ("`%s' not supported by this configuration of GCC",
4971 arg - 2);
4973 /* Does it conflict with an already selected type? */
4974 if (type_explicitly_set_p
4975 /* -g/-ggdb don't conflict with anything */
4976 && da->debug_type != NO_DEBUG
4977 && type != selected_debug_type)
4978 warning ("`%s' ignored, conflicts with `-g%s'",
4979 arg - 2, debug_type_names[(int) selected_debug_type]);
4980 else
4982 /* If the format has already been set, -g/-ggdb
4983 only change the debug level. */
4984 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4985 ; /* don't change debugging type */
4986 else
4988 selected_debug_type = type;
4989 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4992 write_symbols = (level == 0
4993 ? NO_DEBUG
4994 : selected_debug_type);
4995 use_gnu_debug_info_extensions = da->use_extensions_p;
4996 debug_info_level = (enum debug_info_level) level;
4999 break;
5003 if (! da->arg)
5004 warning ("`%s' not supported by this configuration of GCC", arg - 2);
5006 return 1;
5009 /* Decode the first argument in the argv as a language-independent option.
5010 Return the number of strings consumed. 'strings_processed' is the
5011 number of strings that have already been decoded in a language
5012 specific fashion before this function was invoked. */
5014 static unsigned
5015 independent_decode_option (argc, argv, strings_processed)
5016 int argc;
5017 char ** argv;
5018 unsigned strings_processed ATTRIBUTE_UNUSED;
5020 char * arg = argv[0];
5022 if (arg[0] != '-' || arg[1] == 0)
5024 if (arg[0] == '+')
5025 return 0;
5027 filename = arg;
5029 return 1;
5032 arg ++;
5034 if (!strcmp (arg, "-help"))
5036 display_help ();
5037 exit (0);
5040 if (* arg == 'Y')
5041 arg ++;
5043 switch (* arg)
5045 default:
5046 return 0;
5048 case 'O':
5049 /* Already been treated in main (). Do nothing. */
5050 break;
5052 case 'm':
5053 set_target_switch (arg + 1);
5054 break;
5056 case 'f':
5057 return decode_f_option (arg + 1);
5059 case 'g':
5060 return decode_g_option (arg + 1);
5062 case 'd':
5063 if (!strcmp (arg, "dumpbase"))
5065 if (argc == 1)
5066 return 0;
5068 dump_base_name = argv[1];
5069 return 2;
5071 else
5072 decode_d_option (arg + 1);
5073 break;
5075 case 'p':
5076 if (!strcmp (arg, "pedantic"))
5077 pedantic = 1;
5078 else if (!strcmp (arg, "pedantic-errors"))
5079 flag_pedantic_errors = pedantic = 1;
5080 else if (arg[1] == 0)
5081 profile_flag = 1;
5082 else
5083 return 0;
5084 break;
5086 case 'q':
5087 if (!strcmp (arg, "quiet"))
5088 quiet_flag = 1;
5089 else
5090 return 0;
5091 break;
5093 case 'v':
5094 if (!strcmp (arg, "version"))
5095 version_flag = 1;
5096 else
5097 return 0;
5098 break;
5100 case 'w':
5101 if (arg[1] == 0)
5102 inhibit_warnings = 1;
5103 else
5104 return 0;
5105 break;
5107 case 'W':
5108 if (arg[1] == 0)
5110 extra_warnings = 1;
5111 /* We save the value of warn_uninitialized, since if they put
5112 -Wuninitialized on the command line, we need to generate a
5113 warning about not using it without also specifying -O. */
5114 if (warn_uninitialized != 1)
5115 warn_uninitialized = 2;
5117 else
5118 return decode_W_option (arg + 1);
5119 break;
5121 case 'a':
5122 if (arg[1] == 0)
5124 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5125 warning ("`-a' option (basic block profile) not supported");
5126 #else
5127 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
5128 #endif
5130 else if (!strcmp (arg, "ax"))
5132 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5133 warning ("`-ax' option (jump profiling) not supported");
5134 #else
5135 profile_block_flag = (!profile_block_flag
5136 || profile_block_flag == 2) ? 2 : 3;
5137 #endif
5139 else if (!strncmp (arg, "aux-info", 8))
5141 flag_gen_aux_info = 1;
5142 if (arg[8] == '\0')
5144 if (argc == 1)
5145 return 0;
5147 aux_info_file_name = argv[1];
5148 return 2;
5150 else
5151 aux_info_file_name = arg + 8;
5153 else
5154 return 0;
5155 break;
5157 case 'o':
5158 if (arg[1] == 0)
5160 if (argc == 1)
5161 return 0;
5163 asm_file_name = argv[1];
5164 return 2;
5166 return 0;
5168 case 'G':
5170 int g_switch_val;
5171 int return_val;
5173 if (arg[1] == 0)
5175 if (argc == 1)
5176 return 0;
5178 g_switch_val = read_integral_parameter (argv[1], 0, -1);
5179 return_val = 2;
5181 else
5183 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
5184 return_val = 1;
5187 if (g_switch_val == -1)
5188 return_val = 0;
5189 else
5191 g_switch_set = TRUE;
5192 g_switch_value = g_switch_val;
5195 return return_val;
5199 return 1;
5202 /* Entry point of cc1/c++. Decode command args, then call compile_file.
5203 Exit code is 35 if can't open files, 34 if fatal error,
5204 33 if had nonfatal errors, else success. */
5206 extern int main PROTO ((int, char **));
5209 main (argc, argv)
5210 int argc;
5211 char **argv;
5213 register int i;
5214 char *p;
5216 /* save in case md file wants to emit args as a comment. */
5217 save_argc = argc;
5218 save_argv = argv;
5220 p = argv[0] + strlen (argv[0]);
5221 while (p != argv[0] && p[-1] != '/'
5222 #ifdef DIR_SEPARATOR
5223 && p[-1] != DIR_SEPARATOR
5224 #endif
5226 --p;
5227 progname = p;
5229 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
5230 /* Get rid of any avoidable limit on stack size. */
5232 struct rlimit rlim;
5234 /* Set the stack limit huge so that alloca does not fail. */
5235 getrlimit (RLIMIT_STACK, &rlim);
5236 rlim.rlim_cur = rlim.rlim_max;
5237 setrlimit (RLIMIT_STACK, &rlim);
5239 #endif
5241 #ifdef HAVE_LC_MESSAGES
5242 setlocale (LC_MESSAGES, "");
5243 #endif
5244 (void) bindtextdomain (PACKAGE, localedir);
5245 (void) textdomain (PACKAGE);
5247 signal (SIGFPE, float_signal);
5249 #ifdef SIGPIPE
5250 signal (SIGPIPE, pipe_closed);
5251 #endif
5253 decl_printable_name = decl_name;
5254 lang_expand_expr = (lang_expand_expr_t) do_abort;
5256 /* Initialize whether `char' is signed. */
5257 flag_signed_char = DEFAULT_SIGNED_CHAR;
5258 #ifdef DEFAULT_SHORT_ENUMS
5259 /* Initialize how much space enums occupy, by default. */
5260 flag_short_enums = DEFAULT_SHORT_ENUMS;
5261 #endif
5263 /* Initialize the garbage-collector. */
5264 init_ggc ();
5265 ggc_add_root (&input_file_stack, 1, sizeof input_file_stack,
5266 &mark_file_stack);
5268 /* Perform language-specific options intialization. */
5269 lang_init_options ();
5271 /* Scan to see what optimization level has been specified. That will
5272 determine the default value of many flags. */
5273 for (i = 1; i < argc; i++)
5275 if (!strcmp (argv[i], "-O"))
5277 optimize = 1;
5278 optimize_size = 0;
5280 else if (argv[i][0] == '-' && argv[i][1] == 'O')
5282 /* Handle -Os, -O2, -O3, -O69, ... */
5283 char *p = &argv[i][2];
5285 if ((p[0] == 's') && (p[1] == 0))
5287 optimize_size = 1;
5289 /* Optimizing for size forces optimize to be 2. */
5290 optimize = 2;
5292 else
5294 const int optimize_val = read_integral_parameter (p, p - 2, -1);
5295 if (optimize_val != -1)
5297 optimize = optimize_val;
5298 optimize_size = 0;
5304 obey_regdecls = (optimize == 0);
5306 if (optimize >= 1)
5308 flag_defer_pop = 1;
5309 flag_thread_jumps = 1;
5310 #ifdef DELAY_SLOTS
5311 flag_delayed_branch = 1;
5312 #endif
5313 #ifdef CAN_DEBUG_WITHOUT_FP
5314 flag_omit_frame_pointer = 1;
5315 #endif
5318 if (optimize >= 2)
5320 flag_cse_follow_jumps = 1;
5321 flag_cse_skip_blocks = 1;
5322 flag_gcse = 1;
5323 flag_expensive_optimizations = 1;
5324 flag_strength_reduce = 1;
5325 flag_rerun_cse_after_loop = 1;
5326 flag_rerun_loop_opt = 1;
5327 flag_caller_saves = 1;
5328 flag_force_mem = 1;
5329 flag_peephole2 = 1;
5330 #ifdef INSN_SCHEDULING
5331 flag_schedule_insns = 1;
5332 flag_schedule_insns_after_reload = 1;
5333 #endif
5334 flag_regmove = 1;
5335 flag_strict_aliasing = 1;
5336 flag_delete_null_pointer_checks = 1;
5339 if (optimize >= 3)
5341 flag_inline_functions = 1;
5344 if (optimize < 2 || optimize_size)
5346 align_loops = 1;
5347 align_jumps = 1;
5348 align_labels = 1;
5349 align_functions = 1;
5352 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
5353 modify it. */
5354 target_flags = 0;
5355 set_target_switch ("");
5357 #ifdef OPTIMIZATION_OPTIONS
5358 /* Allow default optimizations to be specified on a per-machine basis. */
5359 OPTIMIZATION_OPTIONS (optimize, optimize_size);
5360 #endif
5362 /* Initialize register usage now so switches may override. */
5363 init_reg_sets ();
5365 /* Perform normal command line switch decoding. */
5366 for (i = 1; i < argc;)
5368 unsigned lang_processed;
5369 unsigned indep_processed;
5371 /* Give the language a chance to decode the option for itself. */
5372 lang_processed = lang_decode_option (argc - i, argv + i);
5374 /* Now see if the option also has a language independent meaning.
5375 Some options are both language specific and language independent,
5376 eg --help. It is possible that there might be options that should
5377 only be decoded in a language independent way if the were not
5378 decoded in a langauge specific way, which is why 'lang_processed'
5379 is passed in. */
5380 indep_processed = independent_decode_option (argc - i, argv + i, lang_processed);
5382 if (lang_processed || indep_processed)
5383 i += lang_processed > indep_processed ? lang_processed : indep_processed;
5384 else
5386 error ("Invalid option `%s'", argv[i]);
5387 i++;
5391 /* Checker uses the frame pointer. */
5392 if (flag_check_memory_usage)
5393 flag_omit_frame_pointer = 0;
5395 if (optimize == 0)
5397 /* Inlining does not work if not optimizing,
5398 so force it not to be done. */
5399 flag_no_inline = 1;
5400 warn_inline = 0;
5402 /* The c_decode_option and lang_decode_option functions set
5403 this to `2' if -Wall is used, so we can avoid giving out
5404 lots of errors for people who don't realize what -Wall does. */
5405 if (warn_uninitialized == 1)
5406 warning ("-Wuninitialized is not supported without -O");
5409 #ifdef OVERRIDE_OPTIONS
5410 /* Some machines may reject certain combinations of options. */
5411 OVERRIDE_OPTIONS;
5412 #endif
5414 if (exceptions_via_longjmp == 2)
5416 #ifdef DWARF2_UNWIND_INFO
5417 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
5418 #else
5419 exceptions_via_longjmp = 1;
5420 #endif
5423 /* Set up the align_*_log variables, defaulting them to 1 if they
5424 were still unset. */
5425 if (align_loops <= 0) align_loops = 1;
5426 align_loops_log = floor_log2 (align_loops*2-1);
5427 if (align_jumps <= 0) align_jumps = 1;
5428 align_jumps_log = floor_log2 (align_jumps*2-1);
5429 if (align_labels <= 0) align_labels = 1;
5430 align_labels_log = floor_log2 (align_labels*2-1);
5431 if (align_functions <= 0) align_functions = 1;
5432 align_functions_log = floor_log2 (align_functions*2-1);
5434 if (profile_block_flag == 3)
5436 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
5437 profile_block_flag = 2;
5440 /* Unrolling all loops implies that standard loop unrolling must also
5441 be done. */
5442 if (flag_unroll_all_loops)
5443 flag_unroll_loops = 1;
5444 /* Loop unrolling requires that strength_reduction be on also. Silently
5445 turn on strength reduction here if it isn't already on. Also, the loop
5446 unrolling code assumes that cse will be run after loop, so that must
5447 be turned on also. */
5448 if (flag_unroll_loops)
5450 flag_strength_reduce = 1;
5451 flag_rerun_cse_after_loop = 1;
5454 /* Warn about options that are not supported on this machine. */
5455 #ifndef INSN_SCHEDULING
5456 if (flag_schedule_insns || flag_schedule_insns_after_reload)
5457 warning ("instruction scheduling not supported on this target machine");
5458 #endif
5459 #ifndef DELAY_SLOTS
5460 if (flag_delayed_branch)
5461 warning ("this target machine does not have delayed branches");
5462 #endif
5464 user_label_prefix = USER_LABEL_PREFIX;
5465 if (flag_leading_underscore != -1)
5467 /* If the default prefix is more complicated than "" or "_",
5468 issue a warning and ignore this option. */
5469 if (user_label_prefix[0] == 0 ||
5470 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5472 user_label_prefix = flag_leading_underscore ? "_" : "";
5474 else
5475 warning ("-f%sleading-underscore not supported on this target machine",
5476 flag_leading_underscore ? "" : "no-");
5479 /* If we are in verbose mode, write out the version and maybe all the
5480 option flags in use. */
5481 if (version_flag)
5483 print_version (stderr, "");
5484 if (! quiet_flag)
5485 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5488 compile_file (filename);
5490 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
5491 if (flag_print_mem)
5493 char *lim = (char *) sbrk (0);
5495 notice ("Data size %ld.\n", (long) (lim - (char *) &environ));
5496 fflush (stderr);
5498 #ifndef __MSDOS__
5499 #ifdef USG
5500 system ("ps -l 1>&2");
5501 #else /* not USG */
5502 system ("ps v");
5503 #endif /* not USG */
5504 #endif
5506 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
5508 if (errorcount)
5509 return (FATAL_EXIT_CODE);
5510 if (sorrycount)
5511 return (FATAL_EXIT_CODE);
5512 return (SUCCESS_EXIT_CODE);
5515 /* Decode -m switches. */
5516 /* Decode the switch -mNAME. */
5518 static void
5519 set_target_switch (name)
5520 const char *name;
5522 register size_t j;
5523 int valid_target_option = 0;
5525 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5526 if (!strcmp (target_switches[j].name, name))
5528 if (target_switches[j].value < 0)
5529 target_flags &= ~-target_switches[j].value;
5530 else
5531 target_flags |= target_switches[j].value;
5532 valid_target_option = 1;
5535 #ifdef TARGET_OPTIONS
5536 if (!valid_target_option)
5537 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5539 int len = strlen (target_options[j].prefix);
5540 if (!strncmp (target_options[j].prefix, name, len))
5542 *target_options[j].variable = name + len;
5543 valid_target_option = 1;
5546 #endif
5548 if (!valid_target_option)
5549 error ("Invalid option `%s'", name);
5552 /* Print version information to FILE.
5553 Each line begins with INDENT (for the case where FILE is the
5554 assembler output file). */
5556 static void
5557 print_version (file, indent)
5558 FILE *file;
5559 const char *indent;
5561 #ifndef __VERSION__
5562 #define __VERSION__ "[?]"
5563 #endif
5564 fnotice (file,
5565 #ifdef __GNUC__
5566 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
5567 #else
5568 "%s%s%s version %s (%s) compiled by CC.\n"
5569 #endif
5570 , indent, *indent != 0 ? " " : "",
5571 language_string, version_string, TARGET_NAME, __VERSION__);
5574 /* Print an option value and return the adjusted position in the line.
5575 ??? We don't handle error returns from fprintf (disk full); presumably
5576 other code will catch a disk full though. */
5578 static int
5579 print_single_switch (file, pos, max, indent, sep, term, type, name)
5580 FILE *file;
5581 int pos, max;
5582 const char *indent, *sep, *term, *type, *name;
5584 /* The ultrix fprintf returns 0 on success, so compute the result we want
5585 here since we need it for the following test. */
5586 int len = strlen (sep) + strlen (type) + strlen (name);
5588 if (pos != 0
5589 && pos + len > max)
5591 fprintf (file, "%s", term);
5592 pos = 0;
5594 if (pos == 0)
5596 fprintf (file, "%s", indent);
5597 pos = strlen (indent);
5599 fprintf (file, "%s%s%s", sep, type, name);
5600 pos += len;
5601 return pos;
5604 /* Print active target switches to FILE.
5605 POS is the current cursor position and MAX is the size of a "line".
5606 Each line begins with INDENT and ends with TERM.
5607 Each switch is separated from the next by SEP. */
5609 static void
5610 print_switch_values (file, pos, max, indent, sep, term)
5611 FILE *file;
5612 int pos, max;
5613 const char *indent, *sep, *term;
5615 size_t j;
5616 char **p;
5618 /* Print the options as passed. */
5620 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5621 _("options passed: "), "");
5623 for (p = &save_argv[1]; *p != NULL; p++)
5624 if (**p == '-')
5626 /* Ignore these. */
5627 if (strcmp (*p, "-o") == 0)
5629 if (p[1] != NULL)
5630 p++;
5631 continue;
5633 if (strcmp (*p, "-quiet") == 0)
5634 continue;
5635 if (strcmp (*p, "-version") == 0)
5636 continue;
5637 if ((*p)[1] == 'd')
5638 continue;
5640 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5642 if (pos > 0)
5643 fprintf (file, "%s", term);
5645 /* Print the -f and -m options that have been enabled.
5646 We don't handle language specific options but printing argv
5647 should suffice. */
5649 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5650 _("options enabled: "), "");
5652 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
5653 if (*f_options[j].variable == f_options[j].on_value)
5654 pos = print_single_switch (file, pos, max, indent, sep, term,
5655 "-f", f_options[j].string);
5657 /* Print target specific options. */
5659 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5660 if (target_switches[j].name[0] != '\0'
5661 && target_switches[j].value > 0
5662 && ((target_switches[j].value & target_flags)
5663 == target_switches[j].value))
5665 pos = print_single_switch (file, pos, max, indent, sep, term,
5666 "-m", target_switches[j].name);
5669 #ifdef TARGET_OPTIONS
5670 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5671 if (*target_options[j].variable != NULL)
5673 char prefix[256];
5674 sprintf (prefix, "-m%s", target_options[j].prefix);
5675 pos = print_single_switch (file, pos, max, indent, sep, term,
5676 prefix, *target_options[j].variable);
5678 #endif
5680 fprintf (file, "%s", term);
5683 /* Record the beginning of a new source file, named FILENAME. */
5685 void
5686 debug_start_source_file (filename)
5687 register char *filename ATTRIBUTE_UNUSED;
5689 #ifdef DBX_DEBUGGING_INFO
5690 if (write_symbols == DBX_DEBUG)
5691 dbxout_start_new_source_file (filename);
5692 #endif
5693 #ifdef DWARF_DEBUGGING_INFO
5694 if (debug_info_level == DINFO_LEVEL_VERBOSE
5695 && write_symbols == DWARF_DEBUG)
5696 dwarfout_start_new_source_file (filename);
5697 #endif /* DWARF_DEBUGGING_INFO */
5698 #ifdef DWARF2_DEBUGGING_INFO
5699 if (debug_info_level == DINFO_LEVEL_VERBOSE
5700 && write_symbols == DWARF2_DEBUG)
5701 dwarf2out_start_source_file (filename);
5702 #endif /* DWARF2_DEBUGGING_INFO */
5703 #ifdef SDB_DEBUGGING_INFO
5704 if (write_symbols == SDB_DEBUG)
5705 sdbout_start_new_source_file (filename);
5706 #endif
5709 /* Record the resumption of a source file. LINENO is the line number in
5710 the source file we are returning to. */
5712 void
5713 debug_end_source_file (lineno)
5714 register unsigned lineno ATTRIBUTE_UNUSED;
5716 #ifdef DBX_DEBUGGING_INFO
5717 if (write_symbols == DBX_DEBUG)
5718 dbxout_resume_previous_source_file ();
5719 #endif
5720 #ifdef DWARF_DEBUGGING_INFO
5721 if (debug_info_level == DINFO_LEVEL_VERBOSE
5722 && write_symbols == DWARF_DEBUG)
5723 dwarfout_resume_previous_source_file (lineno);
5724 #endif /* DWARF_DEBUGGING_INFO */
5725 #ifdef DWARF2_DEBUGGING_INFO
5726 if (debug_info_level == DINFO_LEVEL_VERBOSE
5727 && write_symbols == DWARF2_DEBUG)
5728 dwarf2out_end_source_file ();
5729 #endif /* DWARF2_DEBUGGING_INFO */
5730 #ifdef SDB_DEBUGGING_INFO
5731 if (write_symbols == SDB_DEBUG)
5732 sdbout_resume_previous_source_file ();
5733 #endif
5736 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5737 the tail part of the directive line, i.e. the part which is past the
5738 initial whitespace, #, whitespace, directive-name, whitespace part. */
5740 void
5741 debug_define (lineno, buffer)
5742 register unsigned lineno ATTRIBUTE_UNUSED;
5743 register char *buffer ATTRIBUTE_UNUSED;
5745 #ifdef DWARF_DEBUGGING_INFO
5746 if (debug_info_level == DINFO_LEVEL_VERBOSE
5747 && write_symbols == DWARF_DEBUG)
5748 dwarfout_define (lineno, buffer);
5749 #endif /* DWARF_DEBUGGING_INFO */
5750 #ifdef DWARF2_DEBUGGING_INFO
5751 if (debug_info_level == DINFO_LEVEL_VERBOSE
5752 && write_symbols == DWARF2_DEBUG)
5753 dwarf2out_define (lineno, buffer);
5754 #endif /* DWARF2_DEBUGGING_INFO */
5757 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5758 the tail part of the directive line, i.e. the part which is past the
5759 initial whitespace, #, whitespace, directive-name, whitespace part. */
5761 void
5762 debug_undef (lineno, buffer)
5763 register unsigned lineno ATTRIBUTE_UNUSED;
5764 register char *buffer ATTRIBUTE_UNUSED;
5766 #ifdef DWARF_DEBUGGING_INFO
5767 if (debug_info_level == DINFO_LEVEL_VERBOSE
5768 && write_symbols == DWARF_DEBUG)
5769 dwarfout_undef (lineno, buffer);
5770 #endif /* DWARF_DEBUGGING_INFO */
5771 #ifdef DWARF2_DEBUGGING_INFO
5772 if (debug_info_level == DINFO_LEVEL_VERBOSE
5773 && write_symbols == DWARF2_DEBUG)
5774 dwarf2out_undef (lineno, buffer);
5775 #endif /* DWARF2_DEBUGGING_INFO */