* decl.c (grokdeclarator): Remove const and volatile from type after
[official-gcc.git] / gcc / toplev.c
blob5fbf36dedba81a7214f15be279d40efea9b61c73
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-7, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
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 #ifdef __STDC__
28 #include <stdarg.h>
29 #else
30 #include <varargs.h>
31 #endif
32 #undef FLOAT /* This is for hpux. They should change hpux. */
33 #undef FFS /* Some systems define this in param.h. */
34 #include "system.h"
35 #include <signal.h>
36 #include <setjmp.h>
37 #include <sys/stat.h>
39 #ifdef HAVE_SYS_RESOURCE_H
40 # include <sys/resource.h>
41 #endif
43 #ifdef HAVE_SYS_TIMES_H
44 # include <sys/times.h>
45 #endif
47 #include "input.h"
48 #include "tree.h"
49 #include "rtl.h"
50 #include "flags.h"
51 #include "insn-attr.h"
52 #include "defaults.h"
53 #include "output.h"
54 #include "except.h"
56 #ifdef XCOFF_DEBUGGING_INFO
57 #include "xcoffout.h"
58 #endif
60 #ifdef VMS
61 /* The extra parameters substantially improve the I/O performance. */
62 static FILE *
63 vms_fopen (fname, type)
64 char * fname;
65 char * type;
67 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
68 fixed arguments, which matches ANSI's specification but not VAXCRTL's
69 pre-ANSI implementation. This hack circumvents the mismatch problem. */
70 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
72 if (*type == 'w')
73 return (*vmslib_fopen) (fname, type, "mbc=32",
74 "deq=64", "fop=tef", "shr=nil");
75 else
76 return (*vmslib_fopen) (fname, type, "mbc=32");
78 #define fopen vms_fopen
79 #endif /* VMS */
81 #ifndef DEFAULT_GDB_EXTENSIONS
82 #define DEFAULT_GDB_EXTENSIONS 1
83 #endif
85 /* If more than one debugging type is supported, you must define
86 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
88 This is one long line cause VAXC can't handle a \-newline. */
89 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
90 #ifndef PREFERRED_DEBUGGING_TYPE
91 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
92 #endif /* no PREFERRED_DEBUGGING_TYPE */
93 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
94 so the following code needn't care. */
95 #ifdef DBX_DEBUGGING_INFO
96 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
97 #endif
98 #ifdef SDB_DEBUGGING_INFO
99 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
100 #endif
101 #ifdef DWARF_DEBUGGING_INFO
102 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
103 #endif
104 #ifdef DWARF2_DEBUGGING_INFO
105 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
106 #endif
107 #ifdef XCOFF_DEBUGGING_INFO
108 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
109 #endif
110 #endif /* More than one debugger format enabled. */
112 /* If still not defined, must have been because no debugging formats
113 are supported. */
114 #ifndef PREFERRED_DEBUGGING_TYPE
115 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
116 #endif
118 extern int rtx_equal_function_value_matters;
120 #if ! (defined (VMS) || defined (OS2))
121 extern char **environ;
122 #endif
123 extern char *version_string, *language_string;
125 /* Carry information from ASM_DECLARE_OBJECT_NAME
126 to ASM_FINISH_DECLARE_OBJECT. */
128 extern int size_directive_output;
129 extern tree last_assemble_variable_decl;
131 extern void init_lex ();
132 extern void init_decl_processing ();
133 extern void init_obstacks ();
134 extern void init_tree_codes ();
135 extern void init_rtl ();
136 extern void init_regs ();
137 extern void init_optabs ();
138 extern void init_stmt ();
139 extern void init_reg_sets ();
140 extern void dump_flow_info ();
141 extern void dump_sched_info ();
142 extern void dump_local_alloc ();
143 extern void regset_release_memory ();
145 extern void print_rtl ();
146 extern void print_rtl_with_bb ();
148 void rest_of_decl_compilation ();
149 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
150 void error_with_decl PVPROTO((tree decl, char *s, ...));
151 void error_for_asm PVPROTO((rtx insn, char *s, ...));
152 void error PVPROTO((char *s, ...));
153 void fatal PVPROTO((char *s, ...));
154 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
155 void warning_with_decl PVPROTO((tree decl, char *s, ...));
156 void warning_for_asm PVPROTO((rtx insn, char *s, ...));
157 void warning PVPROTO((char *s, ...));
158 void pedwarn PVPROTO((char *s, ...));
159 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
160 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
161 void sorry PVPROTO((char *s, ...));
162 void really_sorry PVPROTO((char *s, ...));
163 void fancy_abort ();
164 void set_target_switch ();
165 static char *decl_name ();
167 void print_version ();
168 int print_single_switch ();
169 void print_switch_values ();
170 /* Length of line when printing switch values. */
171 #define MAX_LINE 75
173 #ifdef NEED_DECLARATION_ABORT
174 void abort ();
175 #endif
177 #ifdef NEED_DECLARATION_SBRK
178 extern char *sbrk ();
179 #endif
181 /* Name of program invoked, sans directories. */
183 char *progname;
185 /* Copy of arguments to main. */
186 int save_argc;
187 char **save_argv;
189 /* Name of current original source file (what was input to cpp).
190 This comes from each #-command in the actual input. */
192 char *input_filename;
194 /* Name of top-level original source file (what was input to cpp).
195 This comes from the #-command at the beginning of the actual input.
196 If there isn't any there, then this is the cc1 input file name. */
198 char *main_input_filename;
200 #if !USE_CPPLIB
201 /* Stream for reading from the input file. */
202 FILE *finput;
203 #endif
205 /* Current line number in real source file. */
207 int lineno;
209 /* Stack of currently pending input files. */
211 struct file_stack *input_file_stack;
213 /* Incremented on each change to input_file_stack. */
214 int input_file_stack_tick;
216 /* FUNCTION_DECL for function now being parsed or compiled. */
218 extern tree current_function_decl;
220 /* Name to use as base of names for dump output files. */
222 char *dump_base_name;
224 /* Bit flags that specify the machine subtype we are compiling for.
225 Bits are tested using macros TARGET_... defined in the tm.h file
226 and set by `-m...' switches. Must be defined in rtlanal.c. */
228 extern int target_flags;
230 /* Flags saying which kinds of debugging dump have been requested. */
232 int rtl_dump = 0;
233 int rtl_dump_and_exit = 0;
234 int jump_opt_dump = 0;
235 int addressof_dump = 0;
236 int cse_dump = 0;
237 int loop_dump = 0;
238 int cse2_dump = 0;
239 int branch_prob_dump = 0;
240 int flow_dump = 0;
241 int combine_dump = 0;
242 int regmove_dump = 0;
243 int sched_dump = 0;
244 int local_reg_dump = 0;
245 int global_reg_dump = 0;
246 int sched2_dump = 0;
247 int jump2_opt_dump = 0;
248 #ifdef DELAY_SLOTS
249 int dbr_sched_dump = 0;
250 #endif
251 int flag_print_asm_name = 0;
252 #ifdef STACK_REGS
253 int stack_reg_dump = 0;
254 #endif
255 #ifdef MACHINE_DEPENDENT_REORG
256 int mach_dep_reorg_dump = 0;
257 #endif
259 /* Name for output file of assembly code, specified with -o. */
261 char *asm_file_name;
263 /* Value of the -G xx switch, and whether it was passed or not. */
264 int g_switch_value;
265 int g_switch_set;
267 /* Type(s) of debugging information we are producing (if any).
268 See flags.h for the definitions of the different possible
269 types of debugging information. */
270 enum debug_info_type write_symbols = NO_DEBUG;
272 /* Level of debugging information we are producing. See flags.h
273 for the definitions of the different possible levels. */
274 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
276 /* Nonzero means use GNU-only extensions in the generated symbolic
277 debugging information. */
278 /* Currently, this only has an effect when write_symbols is set to
279 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
280 int use_gnu_debug_info_extensions = 0;
282 /* Nonzero means do optimizations. -O.
283 Particular numeric values stand for particular amounts of optimization;
284 thus, -O2 stores 2 here. However, the optimizations beyond the basic
285 ones are not controlled directly by this variable. Instead, they are
286 controlled by individual `flag_...' variables that are defaulted
287 based on this variable. */
289 int optimize = 0;
291 /* Nonzero means optimize for size. -Os.
292 The only valid values are zero and non-zero. When optimize_size is
293 non-zero, optimize defaults to 2, but certain individual code
294 bloating optimizations are disabled. */
296 int optimize_size = 0;
298 /* Number of error messages and warning messages so far. */
300 int errorcount = 0;
301 int warningcount = 0;
302 int sorrycount = 0;
304 /* Pointer to function to compute the name to use to print a declaration.
305 DECL is the declaration in question.
306 VERBOSITY determines what information will be printed:
307 0: DECL_NAME, demangled as necessary.
308 1: and scope information.
309 2: and any other information that might be interesting, such as function
310 parameter types in C++. */
312 char *(*decl_printable_name) (/* tree decl, int verbosity */);
314 /* Pointer to function to compute rtl for a language-specific tree code. */
316 struct rtx_def *(*lang_expand_expr) ();
318 /* Pointer to function to finish handling an incomplete decl at the
319 end of compilation. */
321 void (*incomplete_decl_finalize_hook) () = 0;
323 /* Highest label number used at the end of reload. */
325 int max_label_num_after_reload;
327 /* Nonzero if generating code to do profiling. */
329 int profile_flag = 0;
331 /* Nonzero if generating code to do profiling on a line-by-line basis. */
333 int profile_block_flag;
335 /* Nonzero if generating code to profile program flow graph arcs. */
337 int profile_arc_flag = 0;
339 /* Nonzero if generating info for gcov to calculate line test coverage. */
341 int flag_test_coverage = 0;
343 /* Nonzero indicates that branch taken probabilities should be calculated. */
345 int flag_branch_probabilities = 0;
347 /* Nonzero for -pedantic switch: warn about anything
348 that standard spec forbids. */
350 int pedantic = 0;
352 /* Temporarily suppress certain warnings.
353 This is set while reading code from a system header file. */
355 int in_system_header = 0;
357 /* Nonzero means do stupid register allocation.
358 Currently, this is 1 if `optimize' is 0. */
360 int obey_regdecls = 0;
362 /* Don't print functions as they are compiled and don't print
363 times taken by the various passes. -quiet. */
365 int quiet_flag = 0;
367 /* -f flags. */
369 /* Nonzero means `char' should be signed. */
371 int flag_signed_char;
373 /* Nonzero means give an enum type only as many bytes as it needs. */
375 int flag_short_enums;
377 /* Nonzero for -fcaller-saves: allocate values in regs that need to
378 be saved across function calls, if that produces overall better code.
379 Optional now, so people can test it. */
381 #ifdef DEFAULT_CALLER_SAVES
382 int flag_caller_saves = 1;
383 #else
384 int flag_caller_saves = 0;
385 #endif
387 /* Nonzero if structures and unions should be returned in memory.
389 This should only be defined if compatibility with another compiler or
390 with an ABI is needed, because it results in slower code. */
392 #ifndef DEFAULT_PCC_STRUCT_RETURN
393 #define DEFAULT_PCC_STRUCT_RETURN 1
394 #endif
396 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
398 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
400 /* Nonzero for -fforce-mem: load memory value into a register
401 before arithmetic on it. This makes better cse but slower compilation. */
403 int flag_force_mem = 0;
405 /* Nonzero for -fforce-addr: load memory address into a register before
406 reference to memory. This makes better cse but slower compilation. */
408 int flag_force_addr = 0;
410 /* Nonzero for -fdefer-pop: don't pop args after each function call;
411 instead save them up to pop many calls' args with one insns. */
413 int flag_defer_pop = 0;
415 /* Nonzero for -ffloat-store: don't allocate floats and doubles
416 in extended-precision registers. */
418 int flag_float_store = 0;
420 /* Nonzero for -fcse-follow-jumps:
421 have cse follow jumps to do a more extensive job. */
423 int flag_cse_follow_jumps;
425 /* Nonzero for -fcse-skip-blocks:
426 have cse follow a branch around a block. */
427 int flag_cse_skip_blocks;
429 /* Nonzero for -fexpensive-optimizations:
430 perform miscellaneous relatively-expensive optimizations. */
431 int flag_expensive_optimizations;
433 /* Nonzero for -fthread-jumps:
434 have jump optimize output of loop. */
436 int flag_thread_jumps;
438 /* Nonzero enables strength-reduction in loop.c. */
440 int flag_strength_reduce = 0;
442 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
443 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
444 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
445 unrolled. */
447 int flag_unroll_loops;
449 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
450 This is generally not a win. */
452 int flag_unroll_all_loops;
454 /* Nonzero forces all invariant computations in loops to be moved
455 outside the loop. */
457 int flag_move_all_movables = 0;
459 /* Nonzero forces all general induction variables in loops to be
460 strength reduced. */
462 int flag_reduce_all_givs = 0;
464 /* Nonzero for -fwritable-strings:
465 store string constants in data segment and don't uniquize them. */
467 int flag_writable_strings = 0;
469 /* Nonzero means don't put addresses of constant functions in registers.
470 Used for compiling the Unix kernel, where strange substitutions are
471 done on the assembly output. */
473 int flag_no_function_cse = 0;
475 /* Nonzero for -fomit-frame-pointer:
476 don't make a frame pointer in simple functions that don't require one. */
478 int flag_omit_frame_pointer = 0;
480 /* Nonzero means place each function into its own section on those platforms
481 which support arbitrary section names and unlimited numbers of sections. */
483 int flag_function_sections = 0;
485 /* Nonzero to inhibit use of define_optimization peephole opts. */
487 int flag_no_peephole = 0;
489 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
490 operations in the interest of optimization. For example it allows
491 GCC to assume arguments to sqrt are nonnegative numbers, allowing
492 faster code for sqrt to be generated. */
494 int flag_fast_math = 0;
496 /* Nonzero means all references through pointers are volatile. */
498 int flag_volatile;
500 /* Nonzero means treat all global and extern variables as global. */
502 int flag_volatile_global;
504 /* Nonzero means just do syntax checking; don't output anything. */
506 int flag_syntax_only = 0;
508 /* Nonzero means to rerun cse after loop optimization. This increases
509 compilation time about 20% and picks up a few more common expressions. */
511 static int flag_rerun_cse_after_loop;
513 /* Nonzero means to run loop optimizations twice. */
515 int flag_rerun_loop_opt;
517 /* Nonzero for -finline-functions: ok to inline functions that look like
518 good inline candidates. */
520 int flag_inline_functions;
522 /* Nonzero for -fkeep-inline-functions: even if we make a function
523 go inline everywhere, keep its definition around for debugging
524 purposes. */
526 int flag_keep_inline_functions;
528 /* Nonzero means that functions will not be inlined. */
530 int flag_no_inline;
532 /* Nonzero means that we should emit static const variables
533 regardless of whether or not optimization is turned on. */
535 int flag_keep_static_consts = 1;
537 /* Nonzero means we should be saving declaration info into a .X file. */
539 int flag_gen_aux_info = 0;
541 /* Specified name of aux-info file. */
543 static char *aux_info_file_name;
545 /* Nonzero means make the text shared if supported. */
547 int flag_shared_data;
549 /* Nonzero means schedule into delayed branch slots if supported. */
551 int flag_delayed_branch;
553 /* Nonzero if we are compiling pure (sharable) code.
554 Value is 1 if we are doing reasonable (i.e. simple
555 offset into offset table) pic. Value is 2 if we can
556 only perform register offsets. */
558 int flag_pic;
560 /* Nonzero means generate extra code for exception handling and enable
561 exception handling. */
563 int flag_exceptions = 2;
565 /* Nonzero means don't place uninitialized global data in common storage
566 by default. */
568 int flag_no_common;
570 /* Nonzero means pretend it is OK to examine bits of target floats,
571 even if that isn't true. The resulting code will have incorrect constants,
572 but the same series of instructions that the native compiler would make. */
574 int flag_pretend_float;
576 /* Nonzero means change certain warnings into errors.
577 Usually these are warnings about failure to conform to some standard. */
579 int flag_pedantic_errors = 0;
581 /* flag_schedule_insns means schedule insns within basic blocks (before
582 local_alloc).
583 flag_schedule_insns_after_reload means schedule insns after
584 global_alloc. */
586 int flag_schedule_insns = 0;
587 int flag_schedule_insns_after_reload = 0;
589 #ifdef HAIFA
590 /* The following flags have effect only for scheduling before register
591 allocation:
593 flag_schedule_interblock means schedule insns accross basic blocks.
594 flag_schedule_speculative means allow speculative motion of non-load insns.
595 flag_schedule_speculative_load means allow speculative motion of some
596 load insns.
597 flag_schedule_speculative_load_dangerous allows speculative motion of more
598 load insns. */
600 int flag_schedule_interblock = 1;
601 int flag_schedule_speculative = 1;
602 int flag_schedule_speculative_load = 0;
603 int flag_schedule_speculative_load_dangerous = 0;
605 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
606 by a cheaper branch, on a count register. */
607 int flag_branch_on_count_reg;
608 #endif /* HAIFA */
611 /* -finhibit-size-directive inhibits output of .size for ELF.
612 This is used only for compiling crtstuff.c,
613 and it may be extended to other effects
614 needed for crtstuff.c on other systems. */
615 int flag_inhibit_size_directive = 0;
617 /* -fverbose-asm causes extra commentary information to be produced in
618 the generated assembly code (to make it more readable). This option
619 is generally only of use to those who actually need to read the
620 generated assembly code (perhaps while debugging the compiler itself).
621 -fno-verbose-asm, the default, causes the extra information
622 to be omitted and is useful when comparing two assembler files. */
624 int flag_verbose_asm = 0;
626 /* -dA causes debug commentary information to be produced in
627 the generated assembly code (to make it more readable). This option
628 is generally only of use to those who actually need to read the
629 generated assembly code (perhaps while debugging the compiler itself).
630 Currently, this switch is only used by dwarfout.c; however, it is intended
631 to be a catchall for printing debug information in the assembler file. */
633 int flag_debug_asm = 0;
635 /* -fgnu-linker specifies use of the GNU linker for initializations.
636 (Or, more generally, a linker that handles initializations.)
637 -fno-gnu-linker says that collect2 will be used. */
638 #ifdef USE_COLLECT2
639 int flag_gnu_linker = 0;
640 #else
641 int flag_gnu_linker = 1;
642 #endif
644 /* Tag all structures with __attribute__(packed) */
645 int flag_pack_struct = 0;
647 /* Emit code to check for stack overflow; also may cause large objects
648 to be allocated dynamically. */
649 int flag_stack_check;
651 /* -fcheck-memory-usage causes extra code to be generated in order to check
652 memory accesses. This is used by a detector of bad memory accesses such
653 as Checker. */
654 int flag_check_memory_usage = 0;
656 /* -fprefix-function-name causes function name to be prefixed. This
657 can be used with -fcheck-memory-usage to isolate code compiled with
658 -fcheck-memory-usage. */
659 int flag_prefix_function_name = 0;
661 int flag_regmove = 0;
663 /* 0 if pointer arguments may alias each other. True in C.
664 1 if pointer arguments may not alias each other but may alias
665 global variables.
666 2 if pointer arguments may not alias each other and may not
667 alias global variables. True in Fortran.
668 This defaults to 0 for C. */
669 int flag_argument_noalias = 0;
671 /* Table of language-independent -f options.
672 STRING is the option name. VARIABLE is the address of the variable.
673 ON_VALUE is the value to store in VARIABLE
674 if `-fSTRING' is seen as an option.
675 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
677 struct { char *string; int *variable; int on_value;} f_options[] =
679 {"float-store", &flag_float_store, 1},
680 {"volatile", &flag_volatile, 1},
681 {"volatile-global", &flag_volatile_global, 1},
682 {"defer-pop", &flag_defer_pop, 1},
683 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
684 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
685 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
686 {"expensive-optimizations", &flag_expensive_optimizations, 1},
687 {"thread-jumps", &flag_thread_jumps, 1},
688 {"strength-reduce", &flag_strength_reduce, 1},
689 {"unroll-loops", &flag_unroll_loops, 1},
690 {"unroll-all-loops", &flag_unroll_all_loops, 1},
691 {"move-all-movables", &flag_move_all_movables, 1},
692 {"reduce-all-givs", &flag_reduce_all_givs, 1},
693 {"writable-strings", &flag_writable_strings, 1},
694 {"peephole", &flag_no_peephole, 0},
695 {"force-mem", &flag_force_mem, 1},
696 {"force-addr", &flag_force_addr, 1},
697 {"function-cse", &flag_no_function_cse, 0},
698 {"inline-functions", &flag_inline_functions, 1},
699 {"keep-inline-functions", &flag_keep_inline_functions, 1},
700 {"inline", &flag_no_inline, 0},
701 {"keep-static-consts", &flag_keep_static_consts, 1},
702 {"syntax-only", &flag_syntax_only, 1},
703 {"shared-data", &flag_shared_data, 1},
704 {"caller-saves", &flag_caller_saves, 1},
705 {"pcc-struct-return", &flag_pcc_struct_return, 1},
706 {"reg-struct-return", &flag_pcc_struct_return, 0},
707 {"delayed-branch", &flag_delayed_branch, 1},
708 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
709 {"rerun-loop-opt", &flag_rerun_loop_opt, 1},
710 {"pretend-float", &flag_pretend_float, 1},
711 {"schedule-insns", &flag_schedule_insns, 1},
712 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
713 #ifdef HAIFA
714 {"sched-interblock",&flag_schedule_interblock, 1},
715 {"sched-spec",&flag_schedule_speculative, 1},
716 {"sched-spec-load",&flag_schedule_speculative_load, 1},
717 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1},
718 {"branch-count-reg",&flag_branch_on_count_reg, 1},
719 #endif /* HAIFA */
720 {"pic", &flag_pic, 1},
721 {"PIC", &flag_pic, 2},
722 {"exceptions", &flag_exceptions, 1},
723 {"sjlj-exceptions", &exceptions_via_longjmp, 1},
724 {"asynchronous-exceptions", &asynchronous_exceptions, 1},
725 {"profile-arcs", &profile_arc_flag, 1},
726 {"test-coverage", &flag_test_coverage, 1},
727 {"branch-probabilities", &flag_branch_probabilities, 1},
728 {"fast-math", &flag_fast_math, 1},
729 {"common", &flag_no_common, 0},
730 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
731 {"function-sections", &flag_function_sections, 1},
732 {"verbose-asm", &flag_verbose_asm, 1},
733 {"gnu-linker", &flag_gnu_linker, 1},
734 {"regmove", &flag_regmove, 1},
735 {"pack-struct", &flag_pack_struct, 1},
736 {"stack-check", &flag_stack_check, 1},
737 {"argument-alias", &flag_argument_noalias, 0},
738 {"argument-noalias", &flag_argument_noalias, 1},
739 {"argument-noalias-global", &flag_argument_noalias, 2},
740 {"check-memory-usage", &flag_check_memory_usage, 1},
741 {"prefix-function-name", &flag_prefix_function_name, 1}
744 /* Table of language-specific options. */
746 char *lang_options[] =
748 "-ansi",
749 "-fallow-single-precision",
751 "-fsigned-bitfields",
752 "-funsigned-bitfields",
753 "-fno-signed-bitfields",
754 "-fno-unsigned-bitfields",
755 "-fsigned-char",
756 "-funsigned-char",
757 "-fno-signed-char",
758 "-fno-unsigned-char",
760 "-ftraditional",
761 "-traditional",
762 "-fnotraditional",
763 "-fno-traditional",
765 "-fasm",
766 "-fno-asm",
767 "-fbuiltin",
768 "-fno-builtin",
769 "-fhosted",
770 "-fno-hosted",
771 "-ffreestanding",
772 "-fno-freestanding",
773 "-fcond-mismatch",
774 "-fno-cond-mismatch",
775 "-fdollars-in-identifiers",
776 "-fno-dollars-in-identifiers",
777 "-fident",
778 "-fno-ident",
779 "-fshort-double",
780 "-fno-short-double",
781 "-fshort-enums",
782 "-fno-short-enums",
784 "-Wall",
785 "-Wbad-function-cast",
786 "-Wno-bad-function-cast",
787 "-Wcast-qual",
788 "-Wno-cast-qual",
789 "-Wchar-subscripts",
790 "-Wno-char-subscripts",
791 "-Wcomment",
792 "-Wno-comment",
793 "-Wcomments",
794 "-Wno-comments",
795 "-Wconversion",
796 "-Wno-conversion",
797 "-Wformat",
798 "-Wno-format",
799 "-Wimport",
800 "-Wno-import",
801 "-Wimplicit-function-declaration",
802 "-Wno-implicit-function-declaration",
803 "-Werror-implicit-function-declaration",
804 "-Wimplicit-int",
805 "-Wno-implicit-int",
806 "-Wimplicit",
807 "-Wno-implicit",
808 "-Wmain",
809 "-Wno-main",
810 "-Wmissing-braces",
811 "-Wno-missing-braces",
812 "-Wmissing-declarations",
813 "-Wno-missing-declarations",
814 "-Wmissing-prototypes",
815 "-Wno-missing-prototypes",
816 "-Wnested-externs",
817 "-Wno-nested-externs",
818 "-Wparentheses",
819 "-Wno-parentheses",
820 "-Wpointer-arith",
821 "-Wno-pointer-arith",
822 "-Wredundant-decls",
823 "-Wno-redundant-decls",
824 "-Wsign-compare",
825 "-Wno-sign-compare",
826 "-Wunknown-pragmas",
827 "-Wno-unknown-pragmas",
828 "-Wstrict-prototypes",
829 "-Wno-strict-prototypes",
830 "-Wtraditional",
831 "-Wno-traditional",
832 "-Wtrigraphs",
833 "-Wno-trigraphs",
834 "-Wundef",
835 "-Wno-undef",
836 "-Wwrite-strings",
837 "-Wno-write-strings",
839 /* these are for obj c */
840 "-lang-objc",
841 "-gen-decls",
842 "-fgnu-runtime",
843 "-fno-gnu-runtime",
844 "-fnext-runtime",
845 "-fno-next-runtime",
846 "-Wselector",
847 "-Wno-selector",
848 "-Wprotocol",
849 "-Wno-protocol",
850 "-print-objc-runtime-info",
852 #include "options.h"
856 /* Options controlling warnings */
858 /* Don't print warning messages. -w. */
860 int inhibit_warnings = 0;
862 /* Print various extra warnings. -W. */
864 int extra_warnings = 0;
866 /* Treat warnings as errors. -Werror. */
868 int warnings_are_errors = 0;
870 /* Nonzero to warn about unused local variables. */
872 int warn_unused;
874 /* Nonzero to warn about variables used before they are initialized. */
876 int warn_uninitialized;
878 /* Nonzero means warn about all declarations which shadow others. */
880 int warn_shadow;
882 /* Warn if a switch on an enum fails to have a case for every enum value. */
884 int warn_switch;
886 /* Nonzero means warn about function definitions that default the return type
887 or that use a null return and have a return-type other than void. */
889 int warn_return_type;
891 /* Nonzero means warn about pointer casts that increase the required
892 alignment of the target type (and might therefore lead to a crash
893 due to a misaligned access). */
895 int warn_cast_align;
897 /* Nonzero means warn about any identifiers that match in the first N
898 characters. The value N is in `id_clash_len'. */
900 int warn_id_clash;
901 unsigned id_clash_len;
903 /* Nonzero means warn about any objects definitions whose size is larger
904 than N bytes. Also want about function definitions whose returned
905 values are larger than N bytes. The value N is in `larger_than_size'. */
907 int warn_larger_than;
908 unsigned larger_than_size;
910 /* Nonzero means warn if inline function is too large. */
912 int warn_inline;
914 /* Warn if a function returns an aggregate,
915 since there are often incompatible calling conventions for doing this. */
917 int warn_aggregate_return;
919 /* Likewise for -W. */
921 struct { char *string; int *variable; int on_value;} W_options[] =
923 {"unused", &warn_unused, 1},
924 {"error", &warnings_are_errors, 1},
925 {"shadow", &warn_shadow, 1},
926 {"switch", &warn_switch, 1},
927 {"aggregate-return", &warn_aggregate_return, 1},
928 {"cast-align", &warn_cast_align, 1},
929 {"uninitialized", &warn_uninitialized, 1},
930 {"inline", &warn_inline, 1}
933 /* Output files for assembler code (real compiler output)
934 and debugging dumps. */
936 FILE *asm_out_file;
937 FILE *aux_info_file;
938 FILE *rtl_dump_file = NULL;
940 /* Time accumulators, to count the total time spent in various passes. */
942 int parse_time;
943 int varconst_time;
944 int integration_time;
945 int jump_time;
946 int cse_time;
947 int loop_time;
948 int cse2_time;
949 int branch_prob_time;
950 int flow_time;
951 int combine_time;
952 int regmove_time;
953 int sched_time;
954 int local_alloc_time;
955 int global_alloc_time;
956 int sched2_time;
957 #ifdef DELAY_SLOTS
958 int dbr_sched_time;
959 #endif
960 int shorten_branch_time;
961 int stack_reg_time;
962 int final_time;
963 int symout_time;
964 int dump_time;
966 /* Return time used so far, in microseconds. */
969 get_run_time ()
971 if (quiet_flag)
972 return 0;
974 #ifdef __BEOS__
975 return 0;
976 #else /* not BeOS */
977 #if defined (_WIN32) && !defined (__CYGWIN32__)
978 if (clock() < 0)
979 return 0;
980 else
981 return (clock() * 1000);
982 #else /* not _WIN32 */
983 #ifdef _SC_CLK_TCK
985 static int tick;
986 struct tms tms;
987 if (tick == 0)
988 tick = 1000000 / sysconf(_SC_CLK_TCK);
989 times (&tms);
990 return (tms.tms_utime + tms.tms_stime) * tick;
992 #else
993 #ifdef USG
995 struct tms tms;
996 times (&tms);
997 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
999 #else
1000 #ifndef VMS
1002 struct rusage rusage;
1003 getrusage (0, &rusage);
1004 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1005 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1007 #else /* VMS */
1009 struct
1011 int proc_user_time;
1012 int proc_system_time;
1013 int child_user_time;
1014 int child_system_time;
1015 } vms_times;
1016 times ((void *) &vms_times);
1017 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1019 #endif /* VMS */
1020 #endif /* USG */
1021 #endif /* _SC_CLK_TCK */
1022 #endif /* _WIN32 */
1023 #endif /* __BEOS__ */
1026 #define TIMEVAR(VAR, BODY) \
1027 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1029 void
1030 print_time (str, total)
1031 char *str;
1032 int total;
1034 fprintf (stderr,
1035 "time in %s: %d.%06d\n",
1036 str, total / 1000000, total % 1000000);
1039 /* Count an error or warning. Return 1 if the message should be printed. */
1042 count_error (warningp)
1043 int warningp;
1045 if (warningp && inhibit_warnings)
1046 return 0;
1048 if (warningp && !warnings_are_errors)
1049 warningcount++;
1050 else
1052 static int warning_message = 0;
1054 if (warningp && !warning_message)
1056 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
1057 warning_message = 1;
1059 errorcount++;
1062 return 1;
1065 /* Print a fatal error message. NAME is the text.
1066 Also include a system error message based on `errno'. */
1068 void
1069 pfatal_with_name (name)
1070 char *name;
1072 fprintf (stderr, "%s: ", progname);
1073 perror (name);
1074 exit (FATAL_EXIT_CODE);
1077 void
1078 fatal_io_error (name)
1079 char *name;
1081 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
1082 exit (FATAL_EXIT_CODE);
1085 /* Called to give a better error message for a bad insn rather than
1086 just calling abort(). */
1088 void
1089 fatal_insn (message, insn)
1090 char *message;
1091 rtx insn;
1093 error (message);
1094 debug_rtx (insn);
1095 if (asm_out_file)
1096 fflush (asm_out_file);
1097 if (aux_info_file)
1098 fflush (aux_info_file);
1099 if (rtl_dump_file != NULL)
1100 fflush (rtl_dump_file);
1101 fflush (stdout);
1102 fflush (stderr);
1103 abort ();
1106 /* Called to give a better error message when we don't have an insn to match
1107 what we are looking for or if the insn's constraints aren't satisfied,
1108 rather than just calling abort(). */
1110 void
1111 fatal_insn_not_found (insn)
1112 rtx insn;
1114 if (INSN_CODE (insn) < 0)
1115 fatal_insn ("internal error--unrecognizable insn:", insn);
1116 else
1117 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1120 /* This is the default decl_printable_name function. */
1122 static char *
1123 decl_name (decl, verbosity)
1124 tree decl;
1125 int verbosity;
1127 return IDENTIFIER_POINTER (DECL_NAME (decl));
1130 static int need_error_newline;
1132 /* Function of last error message;
1133 more generally, function such that if next error message is in it
1134 then we don't have to mention the function name. */
1135 static tree last_error_function = NULL;
1137 /* Used to detect when input_file_stack has changed since last described. */
1138 static int last_error_tick;
1140 /* Called when the start of a function definition is parsed,
1141 this function prints on stderr the name of the function. */
1143 void
1144 announce_function (decl)
1145 tree decl;
1147 if (! quiet_flag)
1149 if (rtl_dump_and_exit)
1150 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1151 else
1152 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1153 fflush (stderr);
1154 need_error_newline = 1;
1155 last_error_function = current_function_decl;
1159 /* The default function to print out name of current function that caused
1160 an error. */
1162 void
1163 default_print_error_function (file)
1164 char *file;
1166 if (last_error_function != current_function_decl)
1168 char *kind = "function";
1169 if (current_function_decl != 0
1170 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1171 kind = "method";
1173 if (file)
1174 fprintf (stderr, "%s: ", file);
1176 if (current_function_decl == NULL)
1177 fprintf (stderr, "At top level:\n");
1178 else
1180 char *name = (*decl_printable_name) (current_function_decl, 2);
1181 fprintf (stderr, "In %s `%s':\n", kind, name);
1184 last_error_function = current_function_decl;
1188 /* Called by report_error_function to print out function name.
1189 * Default may be overridden by language front-ends. */
1191 void (*print_error_function) PROTO((char *)) = default_print_error_function;
1193 /* Prints out, if necessary, the name of the current function
1194 that caused an error. Called from all error and warning functions. */
1196 void
1197 report_error_function (file)
1198 char *file;
1200 struct file_stack *p;
1202 if (need_error_newline)
1204 fprintf (stderr, "\n");
1205 need_error_newline = 0;
1208 (*print_error_function) (file);
1210 if (input_file_stack && input_file_stack->next != 0
1211 && input_file_stack_tick != last_error_tick
1212 && file == input_filename)
1214 fprintf (stderr, "In file included");
1215 for (p = input_file_stack->next; p; p = p->next)
1217 fprintf (stderr, " from %s:%d", p->name, p->line);
1218 if (p->next)
1219 fprintf (stderr, ",\n ");
1221 fprintf (stderr, ":\n");
1222 last_error_tick = input_file_stack_tick;
1226 /* Print a message. */
1228 static void
1229 vmessage (prefix, s, ap)
1230 char *prefix;
1231 char *s;
1232 va_list ap;
1234 if (prefix)
1235 fprintf (stderr, "%s: ", prefix);
1237 #ifdef HAVE_VPRINTF
1238 vfprintf (stderr, s, ap);
1239 #else
1241 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1242 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1243 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1244 HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT);
1245 fprintf (stderr, s, v1, v2, v3, v4);
1247 #endif
1250 /* Print a message relevant to line LINE of file FILE. */
1252 static void
1253 v_message_with_file_and_line (file, line, prefix, s, ap)
1254 char *file;
1255 int line;
1256 char *prefix;
1257 char *s;
1258 va_list ap;
1260 if (file)
1261 fprintf (stderr, "%s:%d: ", file, line);
1262 else
1263 fprintf (stderr, "%s: ", progname);
1265 vmessage (prefix, s, ap);
1266 fputc ('\n', stderr);
1269 /* Print a message relevant to the given DECL. */
1271 static void
1272 v_message_with_decl (decl, prefix, s, ap)
1273 tree decl;
1274 char *prefix;
1275 char *s;
1276 va_list ap;
1278 char *p;
1280 fprintf (stderr, "%s:%d: ",
1281 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1283 if (prefix)
1284 fprintf (stderr, "%s: ", prefix);
1286 /* Do magic to get around lack of varargs support for insertion
1287 of arguments into existing list. We know that the decl is first;
1288 we ass_u_me that it will be printed with "%s". */
1290 for (p = s; *p; ++p)
1292 if (*p == '%')
1294 if (*(p + 1) == '%')
1295 ++p;
1296 else
1297 break;
1301 if (p > s) /* Print the left-hand substring. */
1303 char fmt[sizeof "%.255s"];
1304 long width = p - s;
1306 if (width > 255L) width = 255L; /* arbitrary */
1307 sprintf (fmt, "%%.%lds", width);
1308 fprintf (stderr, fmt, s);
1311 if (*p == '%') /* Print the name. */
1313 char *n = (DECL_NAME (decl)
1314 ? (*decl_printable_name) (decl, 2)
1315 : "((anonymous))");
1316 fputs (n, stderr);
1317 while (*p)
1319 ++p;
1320 if (isalpha (*(p - 1) & 0xFF))
1321 break;
1325 if (*p) /* Print the rest of the message. */
1326 vmessage ((char *)NULL, p, ap);
1328 fputc ('\n', stderr);
1331 /* Figure file and line of the given INSN. */
1333 static void
1334 file_and_line_for_asm (insn, pfile, pline)
1335 rtx insn;
1336 char **pfile;
1337 int *pline;
1339 rtx body = PATTERN (insn);
1340 rtx asmop;
1342 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1343 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1344 asmop = SET_SRC (body);
1345 else if (GET_CODE (body) == ASM_OPERANDS)
1346 asmop = body;
1347 else if (GET_CODE (body) == PARALLEL
1348 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1349 asmop = SET_SRC (XVECEXP (body, 0, 0));
1350 else if (GET_CODE (body) == PARALLEL
1351 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1352 asmop = XVECEXP (body, 0, 0);
1353 else
1354 asmop = NULL;
1356 if (asmop)
1358 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1359 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1361 else
1363 *pfile = input_filename;
1364 *pline = lineno;
1368 /* Report an error at line LINE of file FILE. */
1370 static void
1371 v_error_with_file_and_line (file, line, s, ap)
1372 char *file;
1373 int line;
1374 char *s;
1375 va_list ap;
1377 count_error (0);
1378 report_error_function (file);
1379 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1382 void
1383 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1385 #ifndef __STDC__
1386 char *file;
1387 int line;
1388 char *s;
1389 #endif
1390 va_list ap;
1392 VA_START (ap, s);
1394 #ifndef __STDC__
1395 file = va_arg (ap, char *);
1396 line = va_arg (ap, int);
1397 s = va_arg (ap, char *);
1398 #endif
1400 v_error_with_file_and_line (file, line, s, ap);
1401 va_end (ap);
1404 /* Report an error at the declaration DECL.
1405 S is a format string which uses %s to substitute the declaration
1406 name; subsequent substitutions are a la printf. */
1408 static void
1409 v_error_with_decl (decl, s, ap)
1410 tree decl;
1411 char *s;
1412 va_list ap;
1414 count_error (0);
1415 report_error_function (DECL_SOURCE_FILE (decl));
1416 v_message_with_decl (decl, (char *)NULL, s, ap);
1419 void
1420 error_with_decl VPROTO((tree decl, char *s, ...))
1422 #ifndef __STDC__
1423 tree decl;
1424 char *s;
1425 #endif
1426 va_list ap;
1428 VA_START (ap, s);
1430 #ifndef __STDC__
1431 decl = va_arg (ap, tree);
1432 s = va_arg (ap, char *);
1433 #endif
1435 v_error_with_decl (decl, s, ap);
1436 va_end (ap);
1439 /* Report an error at the line number of the insn INSN.
1440 This is used only when INSN is an `asm' with operands,
1441 and each ASM_OPERANDS records its own source file and line. */
1443 static void
1444 v_error_for_asm (insn, s, ap)
1445 rtx insn;
1446 char *s;
1447 va_list ap;
1449 char *file;
1450 int line;
1452 count_error (0);
1453 file_and_line_for_asm (insn, &file, &line);
1454 report_error_function (file);
1455 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1458 void
1459 error_for_asm VPROTO((rtx insn, char *s, ...))
1461 #ifndef __STDC__
1462 rtx insn;
1463 char *s;
1464 #endif
1465 va_list ap;
1467 VA_START (ap, s);
1469 #ifndef __STDC__
1470 insn = va_arg (ap, rtx);
1471 s = va_arg (ap, char *);
1472 #endif
1474 v_error_for_asm (insn, s, ap);
1475 va_end (ap);
1478 /* Report an error at the current line number. */
1480 static void
1481 verror (s, ap)
1482 char *s;
1483 va_list ap;
1485 v_error_with_file_and_line (input_filename, lineno, s, ap);
1488 void
1489 error VPROTO((char *s, ...))
1491 #ifndef __STDC__
1492 char *s;
1493 #endif
1494 va_list ap;
1496 VA_START (ap, s);
1498 #ifndef __STDC__
1499 s = va_arg (ap, char *);
1500 #endif
1502 verror (s, ap);
1503 va_end (ap);
1506 /* Report a fatal error at the current line number. */
1508 static void
1509 vfatal (s, ap)
1510 char *s;
1511 va_list ap;
1513 verror (s, ap);
1514 exit (FATAL_EXIT_CODE);
1517 void
1518 fatal VPROTO((char *s, ...))
1520 #ifndef __STDC__
1521 char *s;
1522 #endif
1523 va_list ap;
1525 VA_START (ap, s);
1527 #ifndef __STDC__
1528 s = va_arg (ap, char *);
1529 #endif
1531 vfatal (s, ap);
1532 va_end (ap);
1535 /* Report a warning at line LINE of file FILE. */
1537 static void
1538 v_warning_with_file_and_line (file, line, s, ap)
1539 char *file;
1540 int line;
1541 char *s;
1542 va_list ap;
1544 if (count_error (1))
1546 report_error_function (file);
1547 v_message_with_file_and_line (file, line, "warning", s, ap);
1551 void
1552 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1554 #ifndef __STDC__
1555 char *file;
1556 int line;
1557 char *s;
1558 #endif
1559 va_list ap;
1561 VA_START (ap, s);
1563 #ifndef __STDC__
1564 file = va_arg (ap, char *);
1565 line = va_arg (ap, int);
1566 s = va_arg (ap, char *);
1567 #endif
1569 v_warning_with_file_and_line (file, line, s, ap);
1570 va_end (ap);
1573 /* Report a warning at the declaration DECL.
1574 S is a format string which uses %s to substitute the declaration
1575 name; subsequent substitutions are a la printf. */
1577 static void
1578 v_warning_with_decl (decl, s, ap)
1579 tree decl;
1580 char *s;
1581 va_list ap;
1583 if (count_error (1))
1585 report_error_function (DECL_SOURCE_FILE (decl));
1586 v_message_with_decl (decl, "warning", s, ap);
1590 void
1591 warning_with_decl VPROTO((tree decl, char *s, ...))
1593 #ifndef __STDC__
1594 tree decl;
1595 char *s;
1596 #endif
1597 va_list ap;
1599 VA_START (ap, s);
1601 #ifndef __STDC__
1602 decl = va_arg (ap, tree);
1603 s = va_arg (ap, char *);
1604 #endif
1606 v_warning_with_decl (decl, s, ap);
1607 va_end (ap);
1610 /* Report a warning at the line number of the insn INSN.
1611 This is used only when INSN is an `asm' with operands,
1612 and each ASM_OPERANDS records its own source file and line. */
1614 static void
1615 v_warning_for_asm (insn, s, ap)
1616 rtx insn;
1617 char *s;
1618 va_list ap;
1620 if (count_error (1))
1622 char *file;
1623 int line;
1625 file_and_line_for_asm (insn, &file, &line);
1626 report_error_function (file);
1627 v_message_with_file_and_line (file, line, "warning", s, ap);
1631 void
1632 warning_for_asm VPROTO((rtx insn, char *s, ...))
1634 #ifndef __STDC__
1635 rtx insn;
1636 char *s;
1637 #endif
1638 va_list ap;
1640 VA_START (ap, s);
1642 #ifndef __STDC__
1643 insn = va_arg (ap, rtx);
1644 s = va_arg (ap, char *);
1645 #endif
1647 v_warning_for_asm (insn, s, ap);
1648 va_end (ap);
1651 /* Report a warning at the current line number. */
1653 static void
1654 vwarning (s, ap)
1655 char *s;
1656 va_list ap;
1658 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1661 void
1662 warning VPROTO((char *s, ...))
1664 #ifndef __STDC__
1665 char *s;
1666 #endif
1667 va_list ap;
1669 VA_START (ap, s);
1671 #ifndef __STDC__
1672 s = va_arg (ap, char *);
1673 #endif
1675 vwarning (s, ap);
1676 va_end (ap);
1679 /* These functions issue either warnings or errors depending on
1680 -pedantic-errors. */
1682 static void
1683 vpedwarn (s, ap)
1684 char *s;
1685 va_list ap;
1687 if (flag_pedantic_errors)
1688 verror (s, ap);
1689 else
1690 vwarning (s, ap);
1693 void
1694 pedwarn VPROTO((char *s, ...))
1696 #ifndef __STDC__
1697 char *s;
1698 #endif
1699 va_list ap;
1701 VA_START (ap, s);
1703 #ifndef __STDC__
1704 s = va_arg (ap, char *);
1705 #endif
1707 vpedwarn (s, ap);
1708 va_end (ap);
1711 static void
1712 v_pedwarn_with_decl (decl, s, ap)
1713 tree decl;
1714 char *s;
1715 va_list ap;
1717 /* We don't want -pedantic-errors to cause the compilation to fail from
1718 "errors" in system header files. Sometimes fixincludes can't fix what's
1719 broken (eg: unsigned char bitfields - fixing it may change the alignment
1720 which will cause programs to mysteriously fail because the C library
1721 or kernel uses the original layout). There's no point in issuing a
1722 warning either, it's just unnecessary noise. */
1724 if (! DECL_IN_SYSTEM_HEADER (decl))
1726 if (flag_pedantic_errors)
1727 v_error_with_decl (decl, s, ap);
1728 else
1729 v_warning_with_decl (decl, s, ap);
1733 void
1734 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1736 #ifndef __STDC__
1737 tree decl;
1738 char *s;
1739 #endif
1740 va_list ap;
1742 VA_START (ap, s);
1744 #ifndef __STDC__
1745 decl = va_arg (ap, tree);
1746 s = va_arg (ap, char *);
1747 #endif
1749 v_pedwarn_with_decl (decl, s, ap);
1750 va_end (ap);
1753 static void
1754 v_pedwarn_with_file_and_line (file, line, s, ap)
1755 char *file;
1756 int line;
1757 char *s;
1758 va_list ap;
1760 if (flag_pedantic_errors)
1761 v_error_with_file_and_line (file, line, s, ap);
1762 else
1763 v_warning_with_file_and_line (file, line, s, ap);
1766 void
1767 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1769 #ifndef __STDC__
1770 char *file;
1771 int line;
1772 char *s;
1773 #endif
1774 va_list ap;
1776 VA_START (ap, s);
1778 #ifndef __STDC__
1779 file = va_arg (ap, char *);
1780 line = va_arg (ap, int);
1781 s = va_arg (ap, char *);
1782 #endif
1784 v_pedwarn_with_file_and_line (file, line, s, ap);
1785 va_end (ap);
1788 /* Apologize for not implementing some feature. */
1790 static void
1791 vsorry (s, ap)
1792 char *s;
1793 va_list ap;
1795 sorrycount++;
1796 if (input_filename)
1797 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1798 else
1799 fprintf (stderr, "%s: ", progname);
1800 vmessage ("sorry, not implemented", s, ap);
1801 fputc ('\n', stderr);
1804 void
1805 sorry VPROTO((char *s, ...))
1807 #ifndef __STDC__
1808 char *s;
1809 #endif
1810 va_list ap;
1812 VA_START (ap, s);
1814 #ifndef __STDC__
1815 s = va_arg (ap, char *);
1816 #endif
1818 vsorry (s, ap);
1819 va_end (ap);
1822 /* Apologize for not implementing some feature, then quit. */
1824 static void
1825 v_really_sorry (s, ap)
1826 char *s;
1827 va_list ap;
1829 sorrycount++;
1830 if (input_filename)
1831 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1832 else
1833 fprintf (stderr, "%s: ", progname);
1834 vmessage ("sorry, not implemented", s, ap);
1835 fatal (" (fatal)\n");
1838 void
1839 really_sorry VPROTO((char *s, ...))
1841 #ifndef __STDC__
1842 char *s;
1843 #endif
1844 va_list ap;
1846 VA_START (ap, s);
1848 #ifndef __STDC__
1849 s = va_arg (ap, char *);
1850 #endif
1852 v_really_sorry (s, ap);
1853 va_end (ap);
1856 /* More 'friendly' abort that prints the line and file.
1857 config.h can #define abort fancy_abort if you like that sort of thing.
1859 I don't think this is actually a good idea.
1860 Other sorts of crashes will look a certain way.
1861 It is a good thing if crashes from calling abort look the same way.
1862 -- RMS */
1864 void
1865 fancy_abort ()
1867 fatal ("internal gcc abort");
1870 /* This calls abort and is used to avoid problems when abort if a macro.
1871 It is used when we need to pass the address of abort. */
1873 void
1874 do_abort ()
1876 abort ();
1879 /* When `malloc.c' is compiled with `rcheck' defined,
1880 it calls this function to report clobberage. */
1882 void
1883 botch (s)
1884 char * s;
1886 abort ();
1889 /* Same as `malloc' but report error if no memory available. */
1891 char *
1892 xmalloc (size)
1893 unsigned size;
1895 register char *value = (char *) malloc (size);
1896 if (value == 0 && size != 0)
1897 fatal ("virtual memory exhausted");
1898 return value;
1901 /* Same as `realloc' but report error if no memory available.
1902 Also handle null PTR even if the vendor realloc gets it wrong. */
1904 char *
1905 xrealloc (ptr, size)
1906 char *ptr;
1907 int size;
1909 char *result = (ptr
1910 ? (char *) realloc (ptr, size)
1911 : (char *) malloc (size));
1912 if (!result)
1913 fatal ("virtual memory exhausted");
1914 return result;
1917 /* Same as `strdup' but report error if no memory available. */
1919 char *
1920 xstrdup (s)
1921 register char *s;
1923 register char *result = (char *) malloc (strlen (s) + 1);
1925 if (! result)
1926 fatal ("virtual memory exhausted");
1927 strcpy (result, s);
1928 return result;
1931 /* Return the logarithm of X, base 2, considering X unsigned,
1932 if X is a power of 2. Otherwise, returns -1.
1934 This should be used via the `exact_log2' macro. */
1937 exact_log2_wide (x)
1938 register unsigned HOST_WIDE_INT x;
1940 register int log = 0;
1941 /* Test for 0 or a power of 2. */
1942 if (x == 0 || x != (x & -x))
1943 return -1;
1944 while ((x >>= 1) != 0)
1945 log++;
1946 return log;
1949 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1950 If X is 0, return -1.
1952 This should be used via the floor_log2 macro. */
1955 floor_log2_wide (x)
1956 register unsigned HOST_WIDE_INT x;
1958 register int log = -1;
1959 while (x != 0)
1960 log++,
1961 x >>= 1;
1962 return log;
1965 static int float_handler_set;
1966 int float_handled;
1967 jmp_buf float_handler;
1969 /* Signals actually come here. */
1971 static void
1972 float_signal (signo)
1973 /* If this is missing, some compilers complain. */
1974 int signo;
1976 if (float_handled == 0)
1977 abort ();
1978 #if defined (USG) || defined (hpux)
1979 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1980 #endif
1981 float_handled = 0;
1982 signal (SIGFPE, float_signal);
1983 longjmp (float_handler, 1);
1986 /* Specify where to longjmp to when a floating arithmetic error happens.
1987 If HANDLER is 0, it means don't handle the errors any more. */
1989 void
1990 set_float_handler (handler)
1991 jmp_buf handler;
1993 float_handled = (handler != 0);
1994 if (handler)
1995 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1997 if (float_handled && ! float_handler_set)
1999 signal (SIGFPE, float_signal);
2000 float_handler_set = 1;
2004 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2005 error happens, pushing the previous specification into OLD_HANDLER.
2006 Return an indication of whether there was a previous handler in effect. */
2009 push_float_handler (handler, old_handler)
2010 jmp_buf handler, old_handler;
2012 int was_handled = float_handled;
2014 float_handled = 1;
2015 if (was_handled)
2016 bcopy ((char *) float_handler, (char *) old_handler,
2017 sizeof (float_handler));
2019 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2020 return was_handled;
2023 /* Restore the previous specification of whether and where to longjmp to
2024 when a floating arithmetic error happens. */
2026 void
2027 pop_float_handler (handled, handler)
2028 int handled;
2029 jmp_buf handler;
2031 float_handled = handled;
2032 if (handled)
2033 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2036 /* Handler for SIGPIPE. */
2038 static void
2039 pipe_closed (signo)
2040 /* If this is missing, some compilers complain. */
2041 int signo;
2043 fatal ("output pipe has been closed");
2046 /* Strip off a legitimate source ending from the input string NAME of
2047 length LEN. Rather than having to know the names used by all of
2048 our front ends, we strip off an ending of a period followed by
2049 up to five characters. (Java uses ".class".) */
2051 void
2052 strip_off_ending (name, len)
2053 char *name;
2054 int len;
2056 int i;
2057 for (i = 2; i < 6 && len > i; i++)
2059 if (name[len - i] == '.')
2061 name[len - i] = '\0';
2062 break;
2067 /* Output a quoted string. */
2069 void
2070 output_quoted_string (asm_file, string)
2071 FILE *asm_file;
2072 char *string;
2074 #ifdef OUTPUT_QUOTED_STRING
2075 OUTPUT_QUOTED_STRING (asm_file, string);
2076 #else
2077 char c;
2079 putc ('\"', asm_file);
2080 while ((c = *string++) != 0)
2082 if (c == '\"' || c == '\\')
2083 putc ('\\', asm_file);
2084 putc (c, asm_file);
2086 putc ('\"', asm_file);
2087 #endif
2090 /* Output a file name in the form wanted by System V. */
2092 void
2093 output_file_directive (asm_file, input_name)
2094 FILE *asm_file;
2095 char *input_name;
2097 int len = strlen (input_name);
2098 char *na = input_name + len;
2100 /* NA gets INPUT_NAME sans directory names. */
2101 while (na > input_name)
2103 if (na[-1] == '/')
2104 break;
2105 na--;
2108 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2109 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2110 #else
2111 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2112 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2113 #else
2114 fprintf (asm_file, "\t.file\t");
2115 output_quoted_string (asm_file, na);
2116 fputc ('\n', asm_file);
2117 #endif
2118 #endif
2121 /* Routine to build language identifier for object file. */
2123 static void
2124 output_lang_identify (asm_out_file)
2125 FILE *asm_out_file;
2127 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2128 char *s = (char *) alloca (len);
2129 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2130 ASM_OUTPUT_LABEL (asm_out_file, s);
2133 /* Routine to open a dump file. */
2134 static void
2135 open_dump_file (suffix, function_name)
2136 char *suffix;
2137 char *function_name;
2139 char *dumpname;
2141 TIMEVAR
2142 (dump_time,
2144 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2146 if (rtl_dump_file != NULL)
2147 fclose (rtl_dump_file);
2149 strcpy (dumpname, dump_base_name);
2150 strcat (dumpname, suffix);
2152 rtl_dump_file = fopen (dumpname, "a");
2154 if (rtl_dump_file == NULL)
2155 pfatal_with_name (dumpname);
2157 free (dumpname);
2159 if (function_name)
2160 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2163 return;
2166 /* Routine to close a dump file. */
2167 static void
2168 close_dump_file (func, insns)
2169 void (*func) PROTO ((FILE *, rtx));
2170 rtx insns;
2172 TIMEVAR
2173 (dump_time,
2175 if (func)
2176 func (rtl_dump_file, insns);
2178 fflush (rtl_dump_file);
2179 fclose (rtl_dump_file);
2181 rtl_dump_file = NULL;
2184 return;
2187 /* Routine to dump rtl into a file. */
2188 static void
2189 dump_rtl (suffix, decl, func, insns)
2190 char *suffix;
2191 tree decl;
2192 void (*func) PROTO ((FILE *, rtx));
2193 rtx insns;
2195 open_dump_file (suffix, decl_printable_name (decl, 2));
2196 close_dump_file (func, insns);
2199 /* Routine to empty a dump file. */
2200 static void
2201 clean_dump_file (suffix)
2202 char * suffix;
2204 char * dumpname;
2206 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2208 strcpy (dumpname, dump_base_name);
2209 strcat (dumpname, suffix);
2211 rtl_dump_file = fopen (dumpname, "w");
2213 if (rtl_dump_file == NULL)
2214 pfatal_with_name (dumpname);
2216 free (dumpname);
2218 fclose (rtl_dump_file);
2219 rtl_dump_file = NULL;
2221 return;
2225 /* Compile an entire file of output from cpp, named NAME.
2226 Write a file of assembly output and various debugging dumps. */
2228 static void
2229 compile_file (name)
2230 char *name;
2232 tree globals;
2233 int start_time;
2235 int name_specified = name != 0;
2237 if (dump_base_name == 0)
2238 dump_base_name = name ? name : "gccdump";
2240 parse_time = 0;
2241 varconst_time = 0;
2242 integration_time = 0;
2243 jump_time = 0;
2244 cse_time = 0;
2245 loop_time = 0;
2246 cse2_time = 0;
2247 branch_prob_time = 0;
2248 flow_time = 0;
2249 combine_time = 0;
2250 regmove_time = 0;
2251 sched_time = 0;
2252 local_alloc_time = 0;
2253 global_alloc_time = 0;
2254 sched2_time = 0;
2255 #ifdef DELAY_SLOTS
2256 dbr_sched_time = 0;
2257 #endif
2258 shorten_branch_time = 0;
2259 stack_reg_time = 0;
2260 final_time = 0;
2261 symout_time = 0;
2262 dump_time = 0;
2264 #if !USE_CPPLIB
2265 /* Open input file. */
2267 if (name == 0 || !strcmp (name, "-"))
2269 finput = stdin;
2270 name = "stdin";
2272 else
2273 finput = fopen (name, "r");
2274 if (finput == 0)
2275 pfatal_with_name (name);
2277 #ifdef IO_BUFFER_SIZE
2278 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2279 #endif
2280 #endif /* !USE_CPPLIB */
2282 /* Initialize data in various passes. */
2284 init_obstacks ();
2285 init_tree_codes ();
2286 #if USE_CPPLIB
2287 init_parse (name);
2288 #else
2289 init_lex ();
2290 #endif
2291 init_rtl ();
2292 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2293 || debug_info_level == DINFO_LEVEL_VERBOSE
2294 || flag_test_coverage);
2295 init_regs ();
2296 init_decl_processing ();
2297 init_optabs ();
2298 init_stmt ();
2299 init_expmed ();
2300 init_expr_once ();
2301 init_loop ();
2302 init_reload ();
2303 init_alias_once ();
2305 if (flag_caller_saves)
2306 init_caller_save ();
2308 /* If auxiliary info generation is desired, open the output file.
2309 This goes in the same directory as the source file--unlike
2310 all the other output files. */
2311 if (flag_gen_aux_info)
2313 aux_info_file = fopen (aux_info_file_name, "w");
2314 if (aux_info_file == 0)
2315 pfatal_with_name (aux_info_file_name);
2318 /* Clear the dump files file. */
2319 if (rtl_dump)
2320 clean_dump_file (".rtl");
2321 if (jump_opt_dump)
2322 clean_dump_file (".jump");
2323 if (addressof_dump)
2324 clean_dump_file (".addressof");
2325 if (cse_dump)
2326 clean_dump_file (".cse");
2327 if (loop_dump)
2328 clean_dump_file (".loop");
2329 if (cse2_dump)
2330 clean_dump_file (".cse2");
2331 if (branch_prob_dump)
2332 clean_dump_file (".bp");
2333 if (flow_dump)
2334 clean_dump_file (".flow");
2335 if (combine_dump)
2336 clean_dump_file (".combine");
2337 if (regmove_dump)
2338 clean_dump_file (".regmove");
2339 if (sched_dump)
2340 clean_dump_file (".sched");
2341 if (local_reg_dump)
2342 clean_dump_file (".lreg");
2343 if (global_reg_dump)
2344 clean_dump_file (".greg");
2345 if (sched2_dump)
2346 clean_dump_file (".sched2");
2347 if (jump2_opt_dump)
2348 clean_dump_file (".jump2");
2349 #ifdef DELAY_SLOTS
2350 if (dbr_sched_dump)
2351 clean_dump_file (".dbr");
2352 #endif
2353 #ifdef STACK_REGS
2354 if (stack_reg_dump)
2355 clean_dump_file (".stack");
2356 #endif
2357 #ifdef MACHINE_DEPENDENT_REORG
2358 if (mach_dep_reorg_dump)
2359 clean_dump_file (".mach");
2360 #endif
2362 /* Open assembler code output file. */
2364 if (! name_specified && asm_file_name == 0)
2365 asm_out_file = stdout;
2366 else
2368 int len = strlen (dump_base_name);
2369 register char *dumpname = (char *) xmalloc (len + 6);
2370 strcpy (dumpname, dump_base_name);
2371 strip_off_ending (dumpname, len);
2372 strcat (dumpname, ".s");
2373 if (asm_file_name == 0)
2375 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2376 strcpy (asm_file_name, dumpname);
2378 if (!strcmp (asm_file_name, "-"))
2379 asm_out_file = stdout;
2380 else
2381 asm_out_file = fopen (asm_file_name, "w");
2382 if (asm_out_file == 0)
2383 pfatal_with_name (asm_file_name);
2386 #ifdef IO_BUFFER_SIZE
2387 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2388 _IOFBF, IO_BUFFER_SIZE);
2389 #endif
2391 input_filename = name;
2393 /* Put an entry on the input file stack for the main input file. */
2394 input_file_stack
2395 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2396 input_file_stack->next = 0;
2397 input_file_stack->name = input_filename;
2399 /* Gross. Gross. lang_init is (I think) the first callback into
2400 the language front end, and is thus the first opportunity to
2401 have the selected language override the default value for any
2402 -f option.
2404 So the default value for flag_exceptions is 2 (uninitialized).
2405 If we encounter -fno-exceptions or -fexceptions, then flag_exceptions
2406 will be set to zero or one respectively.
2408 flag_exceptions can also be set by lang_init to something other
2409 than the default "uninitialized" value of 2.
2411 After lang_init, if the value is still 2, then we default to
2412 -fno-exceptions (value will be reset to zero).
2414 When our EH mechanism is low enough overhead that we can enable
2415 it by default for languages other than C++, then all this braindamage
2416 will go away. */
2418 /* Perform language-specific initialization.
2419 This may set main_input_filename. */
2420 lang_init ();
2422 if (flag_exceptions == 2)
2423 flag_exceptions = 0;
2425 /* If the input doesn't start with a #line, use the input name
2426 as the official input file name. */
2427 if (main_input_filename == 0)
2428 main_input_filename = name;
2430 ASM_FILE_START (asm_out_file);
2432 #ifdef ASM_COMMENT_START
2433 if (flag_verbose_asm)
2435 /* Print the list of options in effect. */
2436 print_version (asm_out_file, ASM_COMMENT_START);
2437 print_switch_values (asm_out_file, 0, MAX_LINE,
2438 ASM_COMMENT_START, " ", "\n");
2439 /* Add a blank line here so it appears in assembler output but not
2440 screen output. */
2441 fprintf (asm_out_file, "\n");
2443 #endif
2445 /* Output something to inform GDB that this compilation was by GCC. */
2446 #ifndef ASM_IDENTIFY_GCC
2447 fprintf (asm_out_file, "gcc2_compiled.:\n");
2448 #else
2449 ASM_IDENTIFY_GCC (asm_out_file);
2450 #endif
2452 /* Output something to identify which front-end produced this file. */
2453 #ifdef ASM_IDENTIFY_LANGUAGE
2454 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2455 #endif
2457 #ifndef ASM_OUTPUT_SECTION_NAME
2458 if (flag_function_sections)
2460 warning ("-ffunction-sections not supported for this target.");
2461 flag_function_sections = 0;
2463 #endif
2465 if (flag_function_sections
2466 && (profile_flag || profile_block_flag))
2468 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2469 flag_function_sections = 0;
2472 if (flag_function_sections && write_symbols != NO_DEBUG)
2473 warning ("-ffunction-sections may affect debugging on some targets.");
2475 /* ??? Note: There used to be a conditional here
2476 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2477 This was to guarantee separation between gcc_compiled. and
2478 the first function, for the sake of dbx on Suns.
2479 However, having the extra zero here confused the Emacs
2480 code for unexec, and might confuse other programs too.
2481 Therefore, I took out that change.
2482 In future versions we should find another way to solve
2483 that dbx problem. -- rms, 23 May 93. */
2485 /* Don't let the first function fall at the same address
2486 as gcc_compiled., if profiling. */
2487 if (profile_flag || profile_block_flag)
2488 assemble_zeros (UNITS_PER_WORD);
2490 /* If dbx symbol table desired, initialize writing it
2491 and output the predefined types. */
2492 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2493 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2494 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2495 getdecls ()));
2496 #endif
2497 #ifdef SDB_DEBUGGING_INFO
2498 if (write_symbols == SDB_DEBUG)
2499 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2500 getdecls ()));
2501 #endif
2502 #ifdef DWARF_DEBUGGING_INFO
2503 if (write_symbols == DWARF_DEBUG)
2504 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2505 #endif
2506 #ifdef DWARF2_UNWIND_INFO
2507 if (dwarf2out_do_frame ())
2508 dwarf2out_frame_init ();
2509 #endif
2510 #ifdef DWARF2_DEBUGGING_INFO
2511 if (write_symbols == DWARF2_DEBUG)
2512 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2513 #endif
2515 /* Initialize yet another pass. */
2517 init_final (main_input_filename);
2518 init_branch_prob (dump_base_name);
2520 start_time = get_run_time ();
2522 /* Call the parser, which parses the entire file
2523 (calling rest_of_compilation for each function). */
2525 if (yyparse () != 0)
2527 if (errorcount == 0)
2528 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2530 /* In case there were missing closebraces,
2531 get us back to the global binding level. */
2532 while (! global_bindings_p ())
2533 poplevel (0, 0, 0);
2536 output_func_start_profiler ();
2538 /* Compilation is now finished except for writing
2539 what's left of the symbol table output. */
2541 parse_time += get_run_time () - start_time;
2543 parse_time -= integration_time;
2544 parse_time -= varconst_time;
2546 globals = getdecls ();
2548 /* Really define vars that have had only a tentative definition.
2549 Really output inline functions that must actually be callable
2550 and have not been output so far. */
2553 int len = list_length (globals);
2554 tree *vec = (tree *) alloca (sizeof (tree) * len);
2555 int i;
2556 tree decl;
2557 int reconsider = 1;
2559 /* Process the decls in reverse order--earliest first.
2560 Put them into VEC from back to front, then take out from front. */
2562 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2563 vec[len - i - 1] = decl;
2565 for (i = 0; i < len; i++)
2567 decl = vec[i];
2569 /* We're not deferring this any longer. */
2570 DECL_DEFER_OUTPUT (decl) = 0;
2572 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2573 && incomplete_decl_finalize_hook != 0)
2574 (*incomplete_decl_finalize_hook) (decl);
2577 /* Now emit any global variables or functions that we have been putting
2578 off. We need to loop in case one of the things emitted here
2579 references another one which comes earlier in the list. */
2580 while (reconsider)
2582 reconsider = 0;
2583 for (i = 0; i < len; i++)
2585 decl = vec[i];
2587 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2588 continue;
2590 /* Don't write out static consts, unless we still need them.
2592 We also keep static consts if not optimizing (for debugging),
2593 unless the user specified -fno-keep-static-consts.
2594 ??? They might be better written into the debug information.
2595 This is possible when using DWARF.
2597 A language processor that wants static constants to be always
2598 written out (even if it is not used) is responsible for
2599 calling rest_of_decl_compilation itself. E.g. the C front-end
2600 calls rest_of_decl_compilation from finish_decl.
2601 One motivation for this is that is conventional in some
2602 environments to write things like:
2603 static const char rcsid[] = "... version string ...";
2604 intending to force the string to be in the executable.
2606 A language processor that would prefer to have unneeded
2607 static constants "optimized away" would just defer writing
2608 them out until here. E.g. C++ does this, because static
2609 constants are often defined in header files.
2611 ??? A tempting alternative (for both C and C++) would be
2612 to force a constant to be written if and only if it is
2613 defined in a main file, as opposed to an include file. */
2615 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2616 && (! TREE_READONLY (decl)
2617 || TREE_PUBLIC (decl)
2618 || (!optimize && flag_keep_static_consts)
2619 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2621 reconsider = 1;
2622 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2625 if (TREE_CODE (decl) == FUNCTION_DECL
2626 && DECL_INITIAL (decl) != 0
2627 && DECL_SAVED_INSNS (decl) != 0
2628 && (flag_keep_inline_functions
2629 || TREE_PUBLIC (decl)
2630 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2632 reconsider = 1;
2633 temporary_allocation ();
2634 output_inline_function (decl);
2635 permanent_allocation (1);
2640 /* Now that all possible functions have been output, we can dump
2641 the exception table. */
2643 output_exception_table ();
2645 for (i = 0; i < len; i++)
2647 decl = vec[i];
2649 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2650 && ! TREE_ASM_WRITTEN (decl))
2651 /* Cancel the RTL for this decl so that, if debugging info
2652 output for global variables is still to come,
2653 this one will be omitted. */
2654 DECL_RTL (decl) = NULL;
2656 /* Warn about any function
2657 declared static but not defined.
2658 We don't warn about variables,
2659 because many programs have static variables
2660 that exist only to get some text into the object file. */
2661 if (TREE_CODE (decl) == FUNCTION_DECL
2662 && (warn_unused
2663 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2664 && DECL_INITIAL (decl) == 0
2665 && DECL_EXTERNAL (decl)
2666 && ! DECL_ARTIFICIAL (decl)
2667 && ! TREE_PUBLIC (decl))
2669 pedwarn_with_decl (decl,
2670 "`%s' declared `static' but never defined");
2671 /* This symbol is effectively an "extern" declaration now. */
2672 TREE_PUBLIC (decl) = 1;
2673 assemble_external (decl);
2676 /* Warn about static fns or vars defined but not used,
2677 but not about inline functions or static consts
2678 since defining those in header files is normal practice. */
2679 if (warn_unused
2680 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2681 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2682 && ! DECL_IN_SYSTEM_HEADER (decl)
2683 && ! DECL_EXTERNAL (decl)
2684 && ! TREE_PUBLIC (decl)
2685 && ! TREE_USED (decl)
2686 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2687 /* The TREE_USED bit for file-scope decls
2688 is kept in the identifier, to handle multiple
2689 external decls in different scopes. */
2690 && ! TREE_USED (DECL_NAME (decl)))
2691 warning_with_decl (decl, "`%s' defined but not used");
2693 #ifdef SDB_DEBUGGING_INFO
2694 /* The COFF linker can move initialized global vars to the end.
2695 And that can screw up the symbol ordering.
2696 By putting the symbols in that order to begin with,
2697 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2698 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2699 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2700 && ! DECL_EXTERNAL (decl)
2701 && DECL_RTL (decl) != 0)
2702 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2704 /* Output COFF information for non-global
2705 file-scope initialized variables. */
2706 if (write_symbols == SDB_DEBUG
2707 && TREE_CODE (decl) == VAR_DECL
2708 && DECL_INITIAL (decl)
2709 && ! DECL_EXTERNAL (decl)
2710 && DECL_RTL (decl) != 0
2711 && GET_CODE (DECL_RTL (decl)) == MEM)
2712 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2713 #endif /* SDB_DEBUGGING_INFO */
2714 #ifdef DWARF_DEBUGGING_INFO
2715 /* Output DWARF information for file-scope tentative data object
2716 declarations, file-scope (extern) function declarations (which
2717 had no corresponding body) and file-scope tagged type declarations
2718 and definitions which have not yet been forced out. */
2720 if (write_symbols == DWARF_DEBUG
2721 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2722 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2723 #endif
2724 #ifdef DWARF2_DEBUGGING_INFO
2725 /* Output DWARF2 information for file-scope tentative data object
2726 declarations, file-scope (extern) function declarations (which
2727 had no corresponding body) and file-scope tagged type declarations
2728 and definitions which have not yet been forced out. */
2730 if (write_symbols == DWARF2_DEBUG
2731 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2732 TIMEVAR (symout_time, dwarf2out_decl (decl));
2733 #endif
2737 /* Write out any pending weak symbol declarations. */
2739 weak_finish ();
2741 /* Do dbx symbols */
2742 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2743 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2744 TIMEVAR (symout_time,
2746 dbxout_finish (asm_out_file, main_input_filename);
2748 #endif
2750 #ifdef DWARF_DEBUGGING_INFO
2751 if (write_symbols == DWARF_DEBUG)
2752 TIMEVAR (symout_time,
2754 dwarfout_finish ();
2756 #endif
2758 #ifdef DWARF2_UNWIND_INFO
2759 if (dwarf2out_do_frame ())
2760 dwarf2out_frame_finish ();
2761 #endif
2763 #ifdef DWARF2_DEBUGGING_INFO
2764 if (write_symbols == DWARF2_DEBUG)
2765 TIMEVAR (symout_time,
2767 dwarf2out_finish ();
2769 #endif
2771 /* Output some stuff at end of file if nec. */
2773 end_final (dump_base_name);
2775 if (branch_prob_dump)
2776 open_dump_file (".bp", NULL);
2778 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
2780 if (branch_prob_dump)
2781 close_dump_file (NULL, NULL_RTX);
2783 #ifdef ASM_FILE_END
2784 ASM_FILE_END (asm_out_file);
2785 #endif
2787 /* Language-specific end of compilation actions. */
2789 lang_finish ();
2791 /* Close the dump files. */
2793 if (flag_gen_aux_info)
2795 fclose (aux_info_file);
2796 if (errorcount)
2797 unlink (aux_info_file_name);
2800 if (combine_dump)
2802 open_dump_file (".combine", NULL);
2803 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
2804 close_dump_file (NULL, NULL_RTX);
2807 /* Close non-debugging input and output files. Take special care to note
2808 whether fclose returns an error, since the pages might still be on the
2809 buffer chain while the file is open. */
2811 #if USE_CPPLIB
2812 finish_parse ();
2813 #else
2814 fclose (finput);
2815 #endif
2816 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2817 fatal_io_error (asm_file_name);
2819 /* Print the times. */
2821 if (! quiet_flag)
2823 fprintf (stderr,"\n");
2824 print_time ("parse", parse_time);
2826 print_time ("integration", integration_time);
2827 print_time ("jump", jump_time);
2828 print_time ("cse", cse_time);
2829 print_time ("loop", loop_time);
2830 print_time ("cse2", cse2_time);
2831 print_time ("branch-prob", branch_prob_time);
2832 print_time ("flow", flow_time);
2833 print_time ("combine", combine_time);
2834 print_time ("regmove", regmove_time);
2835 print_time ("sched", sched_time);
2836 print_time ("local-alloc", local_alloc_time);
2837 print_time ("global-alloc", global_alloc_time);
2838 print_time ("sched2", sched2_time);
2839 #ifdef DELAY_SLOTS
2840 print_time ("dbranch", dbr_sched_time);
2841 #endif
2842 print_time ("shorten-branch", shorten_branch_time);
2843 print_time ("stack-reg", stack_reg_time);
2844 print_time ("final", final_time);
2845 print_time ("varconst", varconst_time);
2846 print_time ("symout", symout_time);
2847 print_time ("dump", dump_time);
2851 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2852 and TYPE_DECL nodes.
2854 This does nothing for local (non-static) variables.
2855 Otherwise, it sets up the RTL and outputs any assembler code
2856 (label definition, storage allocation and initialization).
2858 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2859 the assembler symbol name to be used. TOP_LEVEL is nonzero
2860 if this declaration is not within a function. */
2862 void
2863 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2864 tree decl;
2865 char *asmspec;
2866 int top_level;
2867 int at_end;
2869 /* Declarations of variables, and of functions defined elsewhere. */
2871 /* The most obvious approach, to put an #ifndef around where
2872 this macro is used, doesn't work since it's inside a macro call. */
2873 #ifndef ASM_FINISH_DECLARE_OBJECT
2874 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2875 #endif
2877 /* Forward declarations for nested functions are not "external",
2878 but we need to treat them as if they were. */
2879 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2880 || TREE_CODE (decl) == FUNCTION_DECL)
2881 TIMEVAR (varconst_time,
2883 make_decl_rtl (decl, asmspec, top_level);
2884 /* Initialized extern variable exists to be replaced
2885 with its value, or represents something that will be
2886 output in another file. */
2887 if (! (TREE_CODE (decl) == VAR_DECL
2888 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2889 && DECL_INITIAL (decl) != 0
2890 && DECL_INITIAL (decl) != error_mark_node))
2891 /* Don't output anything
2892 when a tentative file-scope definition is seen.
2893 But at end of compilation, do output code for them. */
2894 if (! (! at_end && top_level
2895 && (DECL_INITIAL (decl) == 0
2896 || DECL_INITIAL (decl) == error_mark_node)))
2897 assemble_variable (decl, top_level, at_end, 0);
2898 if (decl == last_assemble_variable_decl)
2900 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2901 top_level, at_end);
2904 else if (DECL_REGISTER (decl) && asmspec != 0)
2906 if (decode_reg_name (asmspec) >= 0)
2908 DECL_RTL (decl) = 0;
2909 make_decl_rtl (decl, asmspec, top_level);
2911 else
2912 error ("invalid register name `%s' for register variable", asmspec);
2914 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2915 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2916 && TREE_CODE (decl) == TYPE_DECL)
2917 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2918 #endif
2919 #ifdef SDB_DEBUGGING_INFO
2920 else if (write_symbols == SDB_DEBUG && top_level
2921 && TREE_CODE (decl) == TYPE_DECL)
2922 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2923 #endif
2926 /* Called after finishing a record, union or enumeral type. */
2928 void
2929 rest_of_type_compilation (type, toplev)
2930 tree type;
2931 int toplev;
2933 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2934 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2935 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2936 #endif
2937 #ifdef SDB_DEBUGGING_INFO
2938 if (write_symbols == SDB_DEBUG)
2939 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2940 #endif
2943 /* This is called from finish_function (within yyparse)
2944 after each top-level definition is parsed.
2945 It is supposed to compile that function or variable
2946 and output the assembler code for it.
2947 After we return, the tree storage is freed. */
2949 void
2950 rest_of_compilation (decl)
2951 tree decl;
2953 register rtx insns;
2954 int start_time = get_run_time ();
2955 int tem;
2956 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2957 to be restored after we finish compiling the function
2958 (for use when compiling inline calls to this function). */
2959 tree saved_block_tree = 0;
2960 /* Likewise, for DECL_ARGUMENTS. */
2961 tree saved_arguments = 0;
2962 int failure = 0;
2964 /* If we are reconsidering an inline function
2965 at the end of compilation, skip the stuff for making it inline. */
2967 if (DECL_SAVED_INSNS (decl) == 0)
2969 int inlinable = 0;
2970 char *lose;
2972 /* If requested, consider whether to make this function inline. */
2973 if (DECL_INLINE (decl) || flag_inline_functions)
2974 TIMEVAR (integration_time,
2976 lose = function_cannot_inline_p (decl);
2977 if (lose || ! optimize)
2979 if (warn_inline && DECL_INLINE (decl))
2980 warning_with_decl (decl, lose);
2981 DECL_ABSTRACT_ORIGIN (decl) = 0;
2982 /* Don't really compile an extern inline function.
2983 If we can't make it inline, pretend
2984 it was only declared. */
2985 if (DECL_EXTERNAL (decl))
2987 DECL_INITIAL (decl) = 0;
2988 goto exit_rest_of_compilation;
2991 else
2992 /* ??? Note that this has the effect of making it look
2993 like "inline" was specified for a function if we choose
2994 to inline it. This isn't quite right, but it's
2995 probably not worth the trouble to fix. */
2996 inlinable = DECL_INLINE (decl) = 1;
2999 insns = get_insns ();
3001 /* Dump the rtl code if we are dumping rtl. */
3003 if (rtl_dump)
3005 open_dump_file (".rtl", decl_printable_name (decl, 2));
3007 if (DECL_SAVED_INSNS (decl))
3008 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3010 close_dump_file (print_rtl, insns);
3013 /* If we can, defer compiling inlines until EOF.
3014 save_for_inline_copying can be extremely expensive. */
3015 if (inlinable && ! decl_function_context (decl))
3016 DECL_DEFER_OUTPUT (decl) = 1;
3018 /* If function is inline, and we don't yet know whether to
3019 compile it by itself, defer decision till end of compilation.
3020 finish_compilation will call rest_of_compilation again
3021 for those functions that need to be output. Also defer those
3022 functions that we are supposed to defer. We cannot defer
3023 functions containing nested functions since the nested function
3024 data is in our non-saved obstack. */
3026 /* If this is a nested inline, remove ADDRESSOF now so we can
3027 finish compiling ourselves. Otherwise, wait until EOF.
3028 We have to do this because the purge_addressof transformation
3029 changes the DECL_RTL for many variables, which confuses integrate. */
3030 if (inlinable)
3032 if (decl_function_context (decl))
3033 purge_addressof (insns);
3034 else
3035 DECL_DEFER_OUTPUT (decl) = 1;
3038 if (! current_function_contains_functions
3039 && (DECL_DEFER_OUTPUT (decl)
3040 || (DECL_INLINE (decl)
3041 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3042 && ! flag_keep_inline_functions)
3043 || DECL_EXTERNAL (decl)))))
3045 DECL_DEFER_OUTPUT (decl) = 1;
3047 /* If -Wreturn-type, we have to do a bit of compilation.
3048 However, if we just fall through we will call
3049 save_for_inline_copying() which results in excessive
3050 memory use. Instead, we just want to call
3051 jump_optimize() to figure out whether or not we can fall
3052 off the end of the function; we do the minimum amount of
3053 work necessary to make that safe. And, we set optimize
3054 to zero to keep jump_optimize from working too hard. */
3055 if (warn_return_type)
3057 int saved_optimize = optimize;
3058 optimize = 0;
3059 find_exception_handler_labels ();
3060 jump_optimize (get_insns(), 0, 0, 0);
3061 optimize = saved_optimize;
3064 #ifdef DWARF_DEBUGGING_INFO
3065 /* Generate the DWARF info for the "abstract" instance
3066 of a function which we may later generate inlined and/or
3067 out-of-line instances of. */
3068 if (write_symbols == DWARF_DEBUG)
3070 set_decl_abstract_flags (decl, 1);
3071 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3072 set_decl_abstract_flags (decl, 0);
3074 #endif
3075 #ifdef DWARF2_DEBUGGING_INFO
3076 /* Generate the DWARF2 info for the "abstract" instance
3077 of a function which we may later generate inlined and/or
3078 out-of-line instances of. */
3079 if (write_symbols == DWARF2_DEBUG)
3081 set_decl_abstract_flags (decl, 1);
3082 TIMEVAR (symout_time, dwarf2out_decl (decl));
3083 set_decl_abstract_flags (decl, 0);
3085 #endif
3086 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3087 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3088 goto exit_rest_of_compilation;
3091 /* If we have to compile the function now, save its rtl and subdecls
3092 so that its compilation will not affect what others get. */
3093 if (inlinable || DECL_DEFER_OUTPUT (decl))
3095 #ifdef DWARF_DEBUGGING_INFO
3096 /* Generate the DWARF info for the "abstract" instance of
3097 a function which we will generate an out-of-line instance
3098 of almost immediately (and which we may also later generate
3099 various inlined instances of). */
3100 if (write_symbols == DWARF_DEBUG)
3102 set_decl_abstract_flags (decl, 1);
3103 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3104 set_decl_abstract_flags (decl, 0);
3106 #endif
3107 #ifdef DWARF2_DEBUGGING_INFO
3108 /* Generate the DWARF2 info for the "abstract" instance of
3109 a function which we will generate an out-of-line instance
3110 of almost immediately (and which we may also later generate
3111 various inlined instances of). */
3112 if (write_symbols == DWARF2_DEBUG)
3114 set_decl_abstract_flags (decl, 1);
3115 TIMEVAR (symout_time, dwarf2out_decl (decl));
3116 set_decl_abstract_flags (decl, 0);
3118 #endif
3119 saved_block_tree = DECL_INITIAL (decl);
3120 saved_arguments = DECL_ARGUMENTS (decl);
3121 TIMEVAR (integration_time, save_for_inline_copying (decl));
3122 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3125 /* If specified extern inline but we aren't inlining it, we are
3126 done. */
3127 if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
3128 goto exit_rest_of_compilation;
3131 if (! DECL_DEFER_OUTPUT (decl))
3132 TREE_ASM_WRITTEN (decl) = 1;
3134 /* Now that integrate will no longer see our rtl, we need not distinguish
3135 between the return value of this function and the return value of called
3136 functions. */
3137 rtx_equal_function_value_matters = 0;
3139 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3140 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3142 goto exit_rest_of_compilation;
3145 /* Emit code to get eh context, if needed. */
3146 emit_eh_context ();
3148 #ifdef FINALIZE_PIC
3149 /* If we are doing position-independent code generation, now
3150 is the time to output special prologues and epilogues.
3151 We do not want to do this earlier, because it just clutters
3152 up inline functions with meaningless insns. */
3153 if (flag_pic)
3154 FINALIZE_PIC;
3155 #endif
3157 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3158 Note that that may have been done above, in save_for_inline_copying.
3159 The call to resume_temporary_allocation near the end of this function
3160 goes back to the usual state of affairs. This must be done after
3161 we've built up any unwinders for exception handling, and done
3162 the FINALIZE_PIC work, if necessary. */
3164 rtl_in_current_obstack ();
3166 insns = get_insns ();
3168 /* Copy any shared structure that should not be shared. */
3170 unshare_all_rtl (insns);
3172 #ifdef SETJMP_VIA_SAVE_AREA
3173 /* This must be performed before virutal register instantiation. */
3174 if (current_function_calls_alloca)
3175 optimize_save_area_alloca (insns);
3176 #endif
3178 /* Instantiate all virtual registers. */
3180 instantiate_virtual_regs (current_function_decl, get_insns ());
3182 /* See if we have allocated stack slots that are not directly addressable.
3183 If so, scan all the insns and create explicit address computation
3184 for all references to such slots. */
3185 /* fixup_stack_slots (); */
3187 /* Find all the EH handlers. */
3188 find_exception_handler_labels ();
3190 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3191 are initialized and to compute whether control can drop off the end
3192 of the function. */
3193 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3194 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3196 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3197 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3198 goto exit_rest_of_compilation;
3200 /* Dump rtl code after jump, if we are doing that. */
3202 if (jump_opt_dump)
3203 dump_rtl (".jump", decl, print_rtl, insns);
3205 /* Perform common subexpression elimination.
3206 Nonzero value from `cse_main' means that jumps were simplified
3207 and some code may now be unreachable, so do
3208 jump optimization again. */
3210 if (optimize > 0)
3212 if (cse_dump)
3213 open_dump_file (".cse", decl_printable_name (decl, 2));
3215 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3217 if (flag_thread_jumps)
3218 /* Hacks by tiemann & kenner. */
3219 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3221 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3222 0, rtl_dump_file));
3223 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
3225 if (tem || optimize > 1)
3226 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3228 /* Dump rtl code after cse, if we are doing that. */
3230 if (cse_dump)
3231 close_dump_file (print_rtl, insns);
3234 purge_addressof (insns);
3235 reg_scan (insns, max_reg_num (), 1);
3237 if (addressof_dump)
3238 dump_rtl (".addressof", decl, print_rtl, insns);
3240 /* Move constant computations out of loops. */
3242 if (optimize > 0)
3244 if (loop_dump)
3245 open_dump_file (".loop", decl_printable_name (decl, 2));
3247 TIMEVAR
3248 (loop_time,
3250 if (flag_rerun_loop_opt)
3252 /* We only want to perform unrolling once. */
3254 loop_optimize (insns, rtl_dump_file, 0);
3256 /* The regscan pass may not be necessary, but let's
3257 be safe until we can prove otherwise. */
3258 reg_scan (insns, max_reg_num (), 1);
3260 loop_optimize (insns, rtl_dump_file, flag_unroll_loops);
3263 /* Dump rtl code after loop opt, if we are doing that. */
3265 if (loop_dump)
3266 close_dump_file (print_rtl, insns);
3269 if (optimize > 0)
3271 if (cse2_dump)
3272 open_dump_file (".cse2", decl_printable_name (decl, 2));
3274 if (flag_rerun_cse_after_loop)
3276 /* Running another jump optimization pass before the second
3277 cse pass sometimes simplifies the RTL enough to allow
3278 the second CSE pass to do a better job. Jump_optimize can change
3279 max_reg_num so we must rerun reg_scan afterwards.
3280 ??? Rework to not call reg_scan so often. */
3281 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3282 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3284 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3285 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3286 1, rtl_dump_file));
3287 if (tem)
3288 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3291 if (flag_thread_jumps)
3293 /* This pass of jump threading straightens out code
3294 that was kinked by loop optimization. */
3295 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3296 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3299 /* Dump rtl code after cse, if we are doing that. */
3301 if (cse2_dump)
3302 close_dump_file (print_rtl, insns);
3305 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3307 if (branch_prob_dump)
3308 open_dump_file (".bp", decl_printable_name (decl, 2));
3310 TIMEVAR
3311 (branch_prob_time,
3313 branch_prob (insns, rtl_dump_file);
3316 if (branch_prob_dump)
3317 close_dump_file (print_rtl, insns);
3320 /* We are no longer anticipating cse in this function, at least. */
3322 cse_not_expected = 1;
3324 /* Now we choose between stupid (pcc-like) register allocation
3325 (if we got the -noreg switch and not -opt)
3326 and smart register allocation. */
3328 if (optimize > 0) /* Stupid allocation probably won't work */
3329 obey_regdecls = 0; /* if optimizations being done. */
3331 regclass_init ();
3333 /* Print function header into flow dump now
3334 because doing the flow analysis makes some of the dump. */
3336 if (flow_dump)
3337 open_dump_file (".flow", decl_printable_name (decl, 2));
3339 if (obey_regdecls)
3341 TIMEVAR (flow_time,
3343 regclass (insns, max_reg_num ());
3344 stupid_life_analysis (insns, max_reg_num (),
3345 rtl_dump_file);
3348 else
3350 /* Do control and data flow analysis,
3351 and write some of the results to dump file. */
3353 TIMEVAR
3354 (flow_time,
3356 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
3357 life_analysis (insns, max_reg_num (), rtl_dump_file);
3360 if (warn_uninitialized)
3362 uninitialized_vars_warning (DECL_INITIAL (decl));
3363 setjmp_args_warning ();
3367 /* Dump rtl after flow analysis. */
3369 if (flow_dump)
3370 close_dump_file (print_rtl_with_bb, insns);
3372 /* If -opt, try combining insns through substitution. */
3374 if (optimize > 0)
3376 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3378 /* Dump rtl code after insn combination. */
3380 if (combine_dump)
3381 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
3384 /* Register allocation pre-pass, to reduce number of moves
3385 necessary for two-address machines. */
3386 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3388 if (regmove_dump)
3389 open_dump_file (".regmove", decl_printable_name (decl, 2));
3391 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
3392 rtl_dump_file));
3394 if (regmove_dump)
3395 close_dump_file (print_rtl_with_bb, insns);
3398 /* Print function header into sched dump now
3399 because doing the sched analysis makes some of the dump. */
3401 if (optimize > 0 && flag_schedule_insns)
3403 if (sched_dump)
3404 open_dump_file (".sched", decl_printable_name (decl, 2));
3406 /* Do control and data sched analysis,
3407 and write some of the results to dump file. */
3409 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
3411 /* Dump rtl after instruction scheduling. */
3413 if (sched_dump)
3414 close_dump_file (print_rtl_with_bb, insns);
3417 /* Unless we did stupid register allocation,
3418 allocate pseudo-regs that are used only within 1 basic block. */
3420 if (!obey_regdecls)
3421 TIMEVAR (local_alloc_time,
3423 regclass (insns, max_reg_num ());
3424 local_alloc ();
3427 /* Dump rtl code after allocating regs within basic blocks. */
3429 if (local_reg_dump)
3431 open_dump_file (".lreg", decl_printable_name (decl, 2));
3433 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
3434 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
3436 close_dump_file (print_rtl_with_bb, insns);
3439 if (global_reg_dump)
3440 open_dump_file (".greg", decl_printable_name (decl, 2));
3442 /* Save the last label number used so far, so reorg can tell
3443 when it's safe to kill spill regs. */
3444 max_label_num_after_reload = max_label_num ();
3446 /* Unless we did stupid register allocation,
3447 allocate remaining pseudo-regs, then do the reload pass
3448 fixing up any insns that are invalid. */
3450 TIMEVAR (global_alloc_time,
3452 if (!obey_regdecls)
3453 failure = global_alloc (rtl_dump_file);
3454 else
3455 failure = reload (insns, 0, rtl_dump_file);
3458 if (global_reg_dump)
3460 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
3461 close_dump_file (print_rtl_with_bb, insns);
3464 if (failure)
3465 goto exit_rest_of_compilation;
3467 reload_completed = 1;
3469 /* Do a very simple CSE pass over just the hard registers. */
3470 if (optimize > 0)
3471 reload_cse_regs (insns);
3473 /* On some machines, the prologue and epilogue code, or parts thereof,
3474 can be represented as RTL. Doing so lets us schedule insns between
3475 it and the rest of the code and also allows delayed branch
3476 scheduling to operate in the epilogue. */
3478 thread_prologue_and_epilogue_insns (insns);
3480 if (optimize > 0 && flag_schedule_insns_after_reload)
3482 if (sched2_dump)
3483 open_dump_file (".sched2", decl_printable_name (decl, 2));
3485 /* Do control and data sched analysis again,
3486 and write some more of the results to dump file. */
3488 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
3490 /* Dump rtl after post-reorder instruction scheduling. */
3492 if (sched2_dump)
3493 close_dump_file (print_rtl_with_bb, insns);
3496 #ifdef LEAF_REGISTERS
3497 leaf_function = 0;
3498 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3499 leaf_function = 1;
3500 #endif
3502 /* One more attempt to remove jumps to .+1
3503 left by dead-store-elimination.
3504 Also do cross-jumping this time
3505 and delete no-op move insns. */
3507 if (optimize > 0)
3509 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3511 /* Dump rtl code after jump, if we are doing that. */
3513 if (jump2_opt_dump)
3514 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
3517 /* If a machine dependent reorganization is needed, call it. */
3518 #ifdef MACHINE_DEPENDENT_REORG
3519 MACHINE_DEPENDENT_REORG (insns);
3521 if (mach_dep_reorg_dump)
3522 dump_rtl (".mach", decl, print_rtl_with_bb, insns);
3523 #endif
3525 /* If a scheduling pass for delayed branches is to be done,
3526 call the scheduling code. */
3528 #ifdef DELAY_SLOTS
3529 if (optimize > 0 && flag_delayed_branch)
3531 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
3533 if (dbr_sched_dump)
3534 dump_rtl (".dbr", decl, print_rtl_with_bb, insns);
3536 #endif
3538 /* Shorten branches. */
3539 TIMEVAR (shorten_branch_time,
3541 shorten_branches (get_insns ());
3544 #ifdef STACK_REGS
3545 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
3547 if (stack_reg_dump)
3548 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
3549 #endif
3551 /* Now turn the rtl into assembler code. */
3553 TIMEVAR (final_time,
3555 rtx x;
3556 char *fnname;
3558 /* Get the function's name, as described by its RTL.
3559 This may be different from the DECL_NAME name used
3560 in the source file. */
3562 x = DECL_RTL (decl);
3563 if (GET_CODE (x) != MEM)
3564 abort ();
3565 x = XEXP (x, 0);
3566 if (GET_CODE (x) != SYMBOL_REF)
3567 abort ();
3568 fnname = XSTR (x, 0);
3570 assemble_start_function (decl, fnname);
3571 final_start_function (insns, asm_out_file, optimize);
3572 final (insns, asm_out_file, optimize, 0);
3573 final_end_function (insns, asm_out_file, optimize);
3574 assemble_end_function (decl, fnname);
3575 fflush (asm_out_file);
3577 /* Release all memory held by regsets now */
3578 regset_release_memory ();
3581 /* Write DBX symbols if requested */
3583 /* Note that for those inline functions where we don't initially
3584 know for certain that we will be generating an out-of-line copy,
3585 the first invocation of this routine (rest_of_compilation) will
3586 skip over this code by doing a `goto exit_rest_of_compilation;'.
3587 Later on, finish_compilation will call rest_of_compilation again
3588 for those inline functions that need to have out-of-line copies
3589 generated. During that call, we *will* be routed past here. */
3591 #ifdef DBX_DEBUGGING_INFO
3592 if (write_symbols == DBX_DEBUG)
3593 TIMEVAR (symout_time, dbxout_function (decl));
3594 #endif
3596 #ifdef DWARF_DEBUGGING_INFO
3597 if (write_symbols == DWARF_DEBUG)
3598 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3599 #endif
3601 #ifdef DWARF2_DEBUGGING_INFO
3602 if (write_symbols == DWARF2_DEBUG)
3603 TIMEVAR (symout_time, dwarf2out_decl (decl));
3604 #endif
3606 exit_rest_of_compilation:
3608 /* In case the function was not output,
3609 don't leave any temporary anonymous types
3610 queued up for sdb output. */
3611 #ifdef SDB_DEBUGGING_INFO
3612 if (write_symbols == SDB_DEBUG)
3613 sdbout_types (NULL_TREE);
3614 #endif
3616 /* Put back the tree of subblocks and list of arguments
3617 from before we copied them.
3618 Code generation and the output of debugging info may have modified
3619 the copy, but the original is unchanged. */
3621 if (saved_block_tree != 0)
3623 DECL_INITIAL (decl) = saved_block_tree;
3624 DECL_ARGUMENTS (decl) = saved_arguments;
3625 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3628 reload_completed = 0;
3630 /* Clear out the insn_length contents now that they are no longer valid. */
3631 init_insn_lengths ();
3633 /* Clear out the real_constant_chain before some of the rtx's
3634 it runs through become garbage. */
3636 clear_const_double_mem ();
3638 /* Cancel the effect of rtl_in_current_obstack. */
3640 resume_temporary_allocation ();
3642 /* Show no temporary slots allocated. */
3644 init_temp_slots ();
3646 /* The parsing time is all the time spent in yyparse
3647 *except* what is spent in this function. */
3649 parse_time -= get_run_time () - start_time;
3652 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3653 Exit code is 35 if can't open files, 34 if fatal error,
3654 33 if had nonfatal errors, else success. */
3657 main (argc, argv, envp)
3658 int argc;
3659 char **argv;
3660 char **envp;
3662 register int i;
3663 char *filename = 0;
3664 int flag_print_mem = 0;
3665 int version_flag = 0;
3666 char *p;
3668 /* save in case md file wants to emit args as a comment. */
3669 save_argc = argc;
3670 save_argv = argv;
3672 p = argv[0] + strlen (argv[0]);
3673 while (p != argv[0] && p[-1] != '/'
3674 #ifdef DIR_SEPARATOR
3675 && p[-1] != DIR_SEPARATOR
3676 #endif
3678 --p;
3679 progname = p;
3681 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
3682 /* Get rid of any avoidable limit on stack size. */
3684 struct rlimit rlim;
3686 /* Set the stack limit huge so that alloca does not fail. */
3687 getrlimit (RLIMIT_STACK, &rlim);
3688 rlim.rlim_cur = rlim.rlim_max;
3689 setrlimit (RLIMIT_STACK, &rlim);
3691 #endif
3693 signal (SIGFPE, float_signal);
3695 #ifdef SIGPIPE
3696 signal (SIGPIPE, pipe_closed);
3697 #endif
3699 decl_printable_name = decl_name;
3700 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3702 /* Initialize whether `char' is signed. */
3703 flag_signed_char = DEFAULT_SIGNED_CHAR;
3704 #ifdef DEFAULT_SHORT_ENUMS
3705 /* Initialize how much space enums occupy, by default. */
3706 flag_short_enums = DEFAULT_SHORT_ENUMS;
3707 #endif
3709 /* Scan to see what optimization level has been specified. That will
3710 determine the default value of many flags. */
3711 for (i = 1; i < argc; i++)
3713 if (!strcmp (argv[i], "-O"))
3715 optimize = 1;
3717 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3719 /* Handle -Os, -O2, -O3, -O69, ... */
3720 char *p = &argv[i][2];
3721 int c;
3723 if ((p[0] == 's') && (p[1] == 0))
3724 optimize_size = 1;
3725 else
3727 while ((c = *p++))
3728 if (! (c >= '0' && c <= '9'))
3729 break;
3730 if (c == 0)
3731 optimize = atoi (&argv[i][2]);
3736 /* Optimizing for size forces optimize to be no less than 2. */
3737 if (optimize_size && (optimize < 2))
3738 optimize = 2;
3740 obey_regdecls = (optimize == 0);
3742 if (optimize >= 1)
3744 flag_defer_pop = 1;
3745 flag_thread_jumps = 1;
3746 #ifdef DELAY_SLOTS
3747 flag_delayed_branch = 1;
3748 #endif
3749 #ifdef CAN_DEBUG_WITHOUT_FP
3750 flag_omit_frame_pointer = 1;
3751 #endif
3754 if (optimize >= 2)
3756 flag_cse_follow_jumps = 1;
3757 flag_cse_skip_blocks = 1;
3758 flag_expensive_optimizations = 1;
3759 flag_strength_reduce = 1;
3760 flag_rerun_cse_after_loop = 1;
3761 flag_rerun_loop_opt = 1;
3762 flag_caller_saves = 1;
3763 flag_force_mem = 1;
3764 #ifdef INSN_SCHEDULING
3765 flag_schedule_insns = 1;
3766 flag_schedule_insns_after_reload = 1;
3767 #endif
3768 flag_regmove = 1;
3771 if (optimize >= 3)
3773 flag_inline_functions = 1;
3776 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
3777 modify it. */
3778 target_flags = 0;
3779 set_target_switch ("");
3781 #ifdef OPTIMIZATION_OPTIONS
3782 /* Allow default optimizations to be specified on a per-machine basis. */
3783 OPTIMIZATION_OPTIONS (optimize, optimize_size);
3784 #endif
3786 /* Initialize register usage now so switches may override. */
3787 init_reg_sets ();
3789 for (i = 1; i < argc; i++)
3791 size_t j;
3792 /* If this is a language-specific option,
3793 decode it in a language-specific way. */
3794 for (j = 0; lang_options[j] != 0; j++)
3795 if (!strncmp (argv[i], lang_options[j],
3796 strlen (lang_options[j])))
3797 break;
3798 if (lang_options[j] != 0)
3799 /* If the option is valid for *some* language,
3800 treat it as valid even if this language doesn't understand it. */
3801 lang_decode_option (argv[i]);
3802 else if (argv[i][0] == '-' && argv[i][1] != 0)
3804 register char *str = argv[i] + 1;
3805 if (str[0] == 'Y')
3806 str++;
3808 if (str[0] == 'm')
3809 set_target_switch (&str[1]);
3810 else if (!strcmp (str, "dumpbase"))
3812 dump_base_name = argv[++i];
3814 else if (str[0] == 'd')
3816 register char *p = &str[1];
3817 while (*p)
3818 switch (*p++)
3820 case 'a':
3821 branch_prob_dump = 1;
3822 combine_dump = 1;
3823 #ifdef DELAY_SLOTS
3824 dbr_sched_dump = 1;
3825 #endif
3826 flow_dump = 1;
3827 global_reg_dump = 1;
3828 jump_opt_dump = 1;
3829 addressof_dump = 1;
3830 jump2_opt_dump = 1;
3831 local_reg_dump = 1;
3832 loop_dump = 1;
3833 regmove_dump = 1;
3834 rtl_dump = 1;
3835 cse_dump = 1, cse2_dump = 1;
3836 sched_dump = 1;
3837 sched2_dump = 1;
3838 #ifdef STACK_REGS
3839 stack_reg_dump = 1;
3840 #endif
3841 #ifdef MACHINE_DEPENDENT_REORG
3842 mach_dep_reorg_dump = 1;
3843 #endif
3844 break;
3845 case 'b':
3846 branch_prob_dump = 1;
3847 break;
3848 #ifdef STACK_REGS
3849 case 'k':
3850 stack_reg_dump = 1;
3851 break;
3852 #endif
3853 case 'c':
3854 combine_dump = 1;
3855 break;
3856 #ifdef DELAY_SLOTS
3857 case 'd':
3858 dbr_sched_dump = 1;
3859 break;
3860 #endif
3861 case 'f':
3862 flow_dump = 1;
3863 break;
3864 case 'g':
3865 global_reg_dump = 1;
3866 break;
3867 case 'j':
3868 jump_opt_dump = 1;
3869 break;
3870 case 'D':
3871 addressof_dump = 1;
3872 break;
3873 case 'J':
3874 jump2_opt_dump = 1;
3875 break;
3876 case 'l':
3877 local_reg_dump = 1;
3878 break;
3879 case 'L':
3880 loop_dump = 1;
3881 break;
3882 case 'm':
3883 flag_print_mem = 1;
3884 break;
3885 #ifdef MACHINE_DEPENDENT_REORG
3886 case 'M':
3887 mach_dep_reorg_dump = 1;
3888 break;
3889 #endif
3890 case 'p':
3891 flag_print_asm_name = 1;
3892 break;
3893 case 'r':
3894 rtl_dump = 1;
3895 break;
3896 case 's':
3897 cse_dump = 1;
3898 break;
3899 case 't':
3900 cse2_dump = 1;
3901 break;
3902 case 'N':
3903 regmove_dump = 1;
3904 break;
3905 case 'S':
3906 sched_dump = 1;
3907 break;
3908 case 'R':
3909 sched2_dump = 1;
3910 break;
3911 case 'y':
3912 set_yydebug (1);
3913 break;
3914 case 'x':
3915 rtl_dump_and_exit = 1;
3916 break;
3917 case 'A':
3918 flag_debug_asm = 1;
3919 break;
3920 default:
3921 warning ("unrecognised gcc debugging option: %c", p[-1]);
3922 break;
3925 else if (str[0] == 'f')
3927 register char *p = &str[1];
3928 int found = 0;
3930 /* Some kind of -f option.
3931 P's value is the option sans `-f'.
3932 Search for it in the table of options. */
3934 for (j = 0;
3935 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3936 j++)
3938 if (!strcmp (p, f_options[j].string))
3940 *f_options[j].variable = f_options[j].on_value;
3941 /* A goto here would be cleaner,
3942 but breaks the vax pcc. */
3943 found = 1;
3945 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3946 && ! strcmp (p+3, f_options[j].string))
3948 *f_options[j].variable = ! f_options[j].on_value;
3949 found = 1;
3953 if (found)
3955 #ifdef HAIFA
3956 #ifdef INSN_SCHEDULING
3957 else if (!strncmp (p, "sched-verbose-",14))
3958 fix_sched_param("verbose",&p[14]);
3959 else if (!strncmp (p, "sched-max-",10))
3960 fix_sched_param("max",&p[10]);
3961 else if (!strncmp (p, "sched-inter-max-b-",18))
3962 fix_sched_param("interblock-max-blocks",&p[18]);
3963 else if (!strncmp (p, "sched-inter-max-i-",18))
3964 fix_sched_param("interblock-max-insns",&p[18]);
3965 #endif
3966 #endif /* HAIFA */
3967 else if (!strncmp (p, "fixed-", 6))
3968 fix_register (&p[6], 1, 1);
3969 else if (!strncmp (p, "call-used-", 10))
3970 fix_register (&p[10], 0, 1);
3971 else if (!strncmp (p, "call-saved-", 11))
3972 fix_register (&p[11], 0, 0);
3973 else
3974 error ("Invalid option `%s'", argv[i]);
3976 else if (str[0] == 'O')
3978 register char *p = str+1;
3979 if (*p == 's')
3980 p++;
3981 else
3982 while (*p && *p >= '0' && *p <= '9')
3983 p++;
3984 if (*p == '\0')
3986 else
3987 error ("Invalid option `%s'", argv[i]);
3989 else if (!strcmp (str, "pedantic"))
3990 pedantic = 1;
3991 else if (!strcmp (str, "pedantic-errors"))
3992 flag_pedantic_errors = pedantic = 1;
3993 else if (!strcmp (str, "quiet"))
3994 quiet_flag = 1;
3995 else if (!strcmp (str, "version"))
3996 version_flag = 1;
3997 else if (!strcmp (str, "w"))
3998 inhibit_warnings = 1;
3999 else if (!strcmp (str, "W"))
4001 extra_warnings = 1;
4002 /* We save the value of warn_uninitialized, since if they put
4003 -Wuninitialized on the command line, we need to generate a
4004 warning about not using it without also specifying -O. */
4005 if (warn_uninitialized != 1)
4006 warn_uninitialized = 2;
4008 else if (str[0] == 'W')
4010 register char *p = &str[1];
4011 int found = 0;
4013 /* Some kind of -W option.
4014 P's value is the option sans `-W'.
4015 Search for it in the table of options. */
4017 for (j = 0;
4018 !found && j < sizeof (W_options) / sizeof (W_options[0]);
4019 j++)
4021 if (!strcmp (p, W_options[j].string))
4023 *W_options[j].variable = W_options[j].on_value;
4024 /* A goto here would be cleaner,
4025 but breaks the vax pcc. */
4026 found = 1;
4028 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4029 && ! strcmp (p+3, W_options[j].string))
4031 *W_options[j].variable = ! W_options[j].on_value;
4032 found = 1;
4036 if (found)
4038 else if (!strncmp (p, "id-clash-", 9))
4040 char *endp = p + 9;
4042 while (*endp)
4044 if (*endp >= '0' && *endp <= '9')
4045 endp++;
4046 else
4048 error ("Invalid option `%s'", argv[i]);
4049 goto id_clash_lose;
4052 warn_id_clash = 1;
4053 id_clash_len = atoi (str + 10);
4054 id_clash_lose: ;
4056 else if (!strncmp (p, "larger-than-", 12))
4058 char *endp = p + 12;
4060 while (*endp)
4062 if (*endp >= '0' && *endp <= '9')
4063 endp++;
4064 else
4066 error ("Invalid option `%s'", argv[i]);
4067 goto larger_than_lose;
4070 warn_larger_than = 1;
4071 larger_than_size = atoi (str + 13);
4072 larger_than_lose: ;
4074 else
4075 error ("Invalid option `%s'", argv[i]);
4077 else if (!strcmp (str, "p"))
4079 profile_flag = 1;
4081 else if (!strcmp (str, "a"))
4083 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4084 warning ("`-a' option (basic block profile) not supported");
4085 #else
4086 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4087 #endif
4089 else if (!strcmp (str, "ax"))
4091 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4092 warning ("`-ax' option (jump profiling) not supported");
4093 #else
4094 profile_block_flag = (!profile_block_flag
4095 || profile_block_flag == 2) ? 2 : 3;
4096 #endif
4098 else if (str[0] == 'g')
4100 unsigned len;
4101 unsigned level;
4102 /* A lot of code assumes write_symbols == NO_DEBUG if the
4103 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4104 of what debugging type has been selected). This records the
4105 selected type. It is an error to specify more than one
4106 debugging type. */
4107 static enum debug_info_type selected_debug_type = NO_DEBUG;
4108 /* Non-zero if debugging format has been explicitly set.
4109 -g and -ggdb don't explicitly set the debugging format so
4110 -gdwarf -g3 is equivalent to -gdwarf3. */
4111 static int type_explicitly_set_p = 0;
4112 /* Table of supported debugging formats. */
4113 static struct {
4114 char *arg;
4115 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
4116 constant expression, we use NO_DEBUG in its place. */
4117 enum debug_info_type debug_type;
4118 int use_extensions_p;
4119 } *da, debug_args[] = {
4120 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS },
4121 { "ggdb", NO_DEBUG, 1 },
4122 #ifdef DBX_DEBUGGING_INFO
4123 { "gstabs", DBX_DEBUG, 0 },
4124 { "gstabs+", DBX_DEBUG, 1 },
4125 #endif
4126 #ifdef DWARF_DEBUGGING_INFO
4127 { "gdwarf", DWARF_DEBUG, 0 },
4128 { "gdwarf+", DWARF_DEBUG, 1 },
4129 #endif
4130 #ifdef DWARF2_DEBUGGING_INFO
4131 { "gdwarf-2", DWARF2_DEBUG, 0 },
4132 #endif
4133 #ifdef XCOFF_DEBUGGING_INFO
4134 { "gxcoff", XCOFF_DEBUG, 0 },
4135 { "gxcoff+", XCOFF_DEBUG, 1 },
4136 #endif
4137 #ifdef SDB_DEBUGGING_INFO
4138 { "gcoff", SDB_DEBUG, 0 },
4139 #endif
4140 { 0, 0, 0 }
4142 /* Indexed by enum debug_info_type. */
4143 static char *debug_type_names[] = {
4144 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4147 /* Look up STR in the table. */
4148 for (da = debug_args; da->arg; da++)
4150 if (! strncmp (str, da->arg, strlen (da->arg)))
4152 enum debug_info_type type = da->debug_type;
4153 char *p, *q;
4155 p = str + strlen (da->arg);
4156 if (*p && (*p < '0' || *p > '9'))
4157 continue;
4158 len = p - str;
4159 q = p;
4160 while (*q && (*q >= '0' && *q <= '9'))
4161 q++;
4162 if (*p)
4164 level = atoi (p);
4165 if (len > 1 && !strncmp (str, "gdwarf", len))
4167 error ("use -gdwarf -g%d for DWARF v1, level %d",
4168 level, level);
4169 if (level == 2)
4170 error ("use -gdwarf-2 for DWARF v2");
4173 else
4174 level = 2; /* default debugging info level */
4175 if (*q || level > 3)
4177 warning ("invalid debug level specification in option: `-%s'",
4178 str);
4179 /* ??? This error message is incorrect in the case of
4180 -g4 -g. */
4181 warning ("no debugging information will be generated");
4182 level = 0;
4185 if (type == NO_DEBUG)
4187 type = PREFERRED_DEBUGGING_TYPE;
4188 if (len > 1 && strncmp (str, "ggdb", len) == 0)
4190 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4191 type = DWARF2_DEBUG;
4192 #else
4193 #ifdef DBX_DEBUGGING_INFO
4194 type = DBX_DEBUG;
4195 #endif
4196 #endif
4200 if (type == NO_DEBUG)
4201 warning ("`-%s' not supported by this configuration of GCC",
4202 str);
4204 /* Does it conflict with an already selected type? */
4205 if (type_explicitly_set_p
4206 /* -g/-ggdb don't conflict with anything */
4207 && da->debug_type != NO_DEBUG
4208 && type != selected_debug_type)
4209 warning ("`-%s' ignored, conflicts with `-g%s'",
4210 str, debug_type_names[(int) selected_debug_type]);
4211 else
4213 /* If the format has already been set, -g/-ggdb
4214 only change the debug level. */
4215 if (type_explicitly_set_p
4216 && da->debug_type == NO_DEBUG)
4217 ; /* don't change debugging type */
4218 else
4220 selected_debug_type = type;
4221 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4223 write_symbols = (level == 0
4224 ? NO_DEBUG
4225 : selected_debug_type);
4226 use_gnu_debug_info_extensions = da->use_extensions_p;
4227 debug_info_level = (enum debug_info_level) level;
4229 break;
4232 if (! da->arg)
4233 warning ("`-%s' not supported by this configuration of GCC",
4234 str);
4236 else if (!strcmp (str, "o"))
4238 asm_file_name = argv[++i];
4240 else if (str[0] == 'G')
4242 g_switch_set = TRUE;
4243 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
4245 else if (!strncmp (str, "aux-info", 8))
4247 flag_gen_aux_info = 1;
4248 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
4250 else
4251 error ("Invalid option `%s'", argv[i]);
4253 else if (argv[i][0] == '+')
4254 error ("Invalid option `%s'", argv[i]);
4255 else
4256 filename = argv[i];
4259 /* Checker uses the frame pointer. */
4260 if (flag_check_memory_usage)
4261 flag_omit_frame_pointer = 0;
4263 if (optimize == 0)
4265 /* Inlining does not work if not optimizing,
4266 so force it not to be done. */
4267 flag_no_inline = 1;
4268 warn_inline = 0;
4270 /* The c_decode_option and lang_decode_option functions set
4271 this to `2' if -Wall is used, so we can avoid giving out
4272 lots of errors for people who don't realize what -Wall does. */
4273 if (warn_uninitialized == 1)
4274 warning ("-Wuninitialized is not supported without -O");
4277 #ifdef OVERRIDE_OPTIONS
4278 /* Some machines may reject certain combinations of options. */
4279 OVERRIDE_OPTIONS;
4280 #endif
4282 if (exceptions_via_longjmp == 2)
4284 #ifdef DWARF2_UNWIND_INFO
4285 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4286 #else
4287 exceptions_via_longjmp = 1;
4288 #endif
4291 if (profile_block_flag == 3)
4293 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4294 profile_block_flag = 2;
4297 /* Unrolling all loops implies that standard loop unrolling must also
4298 be done. */
4299 if (flag_unroll_all_loops)
4300 flag_unroll_loops = 1;
4301 /* Loop unrolling requires that strength_reduction be on also. Silently
4302 turn on strength reduction here if it isn't already on. Also, the loop
4303 unrolling code assumes that cse will be run after loop, so that must
4304 be turned on also. */
4305 if (flag_unroll_loops)
4307 flag_strength_reduce = 1;
4308 flag_rerun_cse_after_loop = 1;
4311 /* Warn about options that are not supported on this machine. */
4312 #ifndef INSN_SCHEDULING
4313 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4314 warning ("instruction scheduling not supported on this target machine");
4315 #endif
4316 #ifndef DELAY_SLOTS
4317 if (flag_delayed_branch)
4318 warning ("this target machine does not have delayed branches");
4319 #endif
4321 /* If we are in verbose mode, write out the version and maybe all the
4322 option flags in use. */
4323 if (version_flag)
4325 print_version (stderr, "");
4326 if (! quiet_flag)
4327 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4330 compile_file (filename);
4332 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4333 if (flag_print_mem)
4335 char *lim = (char *) sbrk (0);
4337 fprintf (stderr, "Data size %d.\n",
4338 lim - (char *) &environ);
4339 fflush (stderr);
4341 #ifndef __MSDOS__
4342 #ifdef USG
4343 system ("ps -l 1>&2");
4344 #else /* not USG */
4345 system ("ps v");
4346 #endif /* not USG */
4347 #endif
4349 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4351 if (errorcount)
4352 exit (FATAL_EXIT_CODE);
4353 if (sorrycount)
4354 exit (FATAL_EXIT_CODE);
4355 exit (SUCCESS_EXIT_CODE);
4356 return 0;
4359 /* Decode -m switches. */
4361 /* Here is a table, controlled by the tm.h file, listing each -m switch
4362 and which bits in `target_switches' it should set or clear.
4363 If VALUE is positive, it is bits to set.
4364 If VALUE is negative, -VALUE is bits to clear.
4365 (The sign bit is not used so there is no confusion.) */
4367 struct {char *name; int value;} target_switches []
4368 = TARGET_SWITCHES;
4370 /* This table is similar, but allows the switch to have a value. */
4372 #ifdef TARGET_OPTIONS
4373 struct {char *prefix; char ** variable;} target_options []
4374 = TARGET_OPTIONS;
4375 #endif
4377 /* Decode the switch -mNAME. */
4379 void
4380 set_target_switch (name)
4381 char *name;
4383 register size_t j;
4384 int valid = 0;
4386 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4387 if (!strcmp (target_switches[j].name, name))
4389 if (target_switches[j].value < 0)
4390 target_flags &= ~-target_switches[j].value;
4391 else
4392 target_flags |= target_switches[j].value;
4393 valid = 1;
4396 #ifdef TARGET_OPTIONS
4397 if (!valid)
4398 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4400 int len = strlen (target_options[j].prefix);
4401 if (!strncmp (target_options[j].prefix, name, len))
4403 *target_options[j].variable = name + len;
4404 valid = 1;
4407 #endif
4409 if (!valid)
4410 error ("Invalid option `%s'", name);
4413 /* Print version information to FILE.
4414 Each line begins with INDENT (for the case where FILE is the
4415 assembler output file). */
4417 void
4418 print_version (file, indent)
4419 FILE *file;
4420 char *indent;
4422 fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4423 language_string, version_string);
4424 fprintf (file, " (%s)", TARGET_NAME);
4425 #ifdef __GNUC__
4426 #ifndef __VERSION__
4427 #define __VERSION__ "[unknown]"
4428 #endif
4429 fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4430 #else
4431 fprintf (file, " compiled by CC.\n");
4432 #endif
4435 /* Print an option value and return the adjusted position in the line.
4436 ??? We don't handle error returns from fprintf (disk full); presumably
4437 other code will catch a disk full though. */
4440 print_single_switch (file, pos, max, indent, sep, term, type, name)
4441 FILE *file;
4442 int pos, max;
4443 char *indent, *sep, *term, *type, *name;
4445 /* The ultrix fprintf returns 0 on success, so compute the result we want
4446 here since we need it for the following test. */
4447 int len = strlen (sep) + strlen (type) + strlen (name);
4449 if (pos != 0
4450 && pos + len > max)
4452 fprintf (file, "%s", term);
4453 pos = 0;
4455 if (pos == 0)
4457 fprintf (file, "%s", indent);
4458 pos = strlen (indent);
4460 fprintf (file, "%s%s%s", sep, type, name);
4461 pos += len;
4462 return pos;
4465 /* Print active target switches to FILE.
4466 POS is the current cursor position and MAX is the size of a "line".
4467 Each line begins with INDENT and ends with TERM.
4468 Each switch is separated from the next by SEP. */
4470 void
4471 print_switch_values (file, pos, max, indent, sep, term)
4472 FILE *file;
4473 int pos, max;
4474 char *indent, *sep, *term;
4476 size_t j;
4477 char **p;
4479 /* Print the options as passed. */
4481 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4482 "options passed: ", "");
4484 for (p = &save_argv[1]; *p != NULL; p++)
4485 if (**p == '-')
4487 /* Ignore these. */
4488 if (strcmp (*p, "-o") == 0)
4490 if (p[1] != NULL)
4491 p++;
4492 continue;
4494 if (strcmp (*p, "-quiet") == 0)
4495 continue;
4496 if (strcmp (*p, "-version") == 0)
4497 continue;
4498 if ((*p)[1] == 'd')
4499 continue;
4501 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4503 if (pos > 0)
4504 fprintf (file, "%s", term);
4506 /* Print the -f and -m options that have been enabled.
4507 We don't handle language specific options but printing argv
4508 should suffice. */
4510 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4511 "options enabled: ", "");
4513 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4514 if (*f_options[j].variable == f_options[j].on_value)
4515 pos = print_single_switch (file, pos, max, indent, sep, term,
4516 "-f", f_options[j].string);
4518 /* Print target specific options. */
4520 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4521 if (target_switches[j].name[0] != '\0'
4522 && target_switches[j].value > 0
4523 && ((target_switches[j].value & target_flags)
4524 == target_switches[j].value))
4526 pos = print_single_switch (file, pos, max, indent, sep, term,
4527 "-m", target_switches[j].name);
4530 #ifdef TARGET_OPTIONS
4531 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4532 if (*target_options[j].variable != NULL)
4534 char prefix[256];
4535 sprintf (prefix, "-m%s", target_options[j].prefix);
4536 pos = print_single_switch (file, pos, max, indent, sep, term,
4537 prefix, *target_options[j].variable);
4539 #endif
4541 fprintf (file, "%s", term);
4544 /* Record the beginning of a new source file, named FILENAME. */
4546 void
4547 debug_start_source_file (filename)
4548 register char *filename;
4550 #ifdef DBX_DEBUGGING_INFO
4551 if (write_symbols == DBX_DEBUG)
4552 dbxout_start_new_source_file (filename);
4553 #endif
4554 #ifdef DWARF_DEBUGGING_INFO
4555 if (debug_info_level == DINFO_LEVEL_VERBOSE
4556 && write_symbols == DWARF_DEBUG)
4557 dwarfout_start_new_source_file (filename);
4558 #endif /* DWARF_DEBUGGING_INFO */
4559 #ifdef DWARF2_DEBUGGING_INFO
4560 if (debug_info_level == DINFO_LEVEL_VERBOSE
4561 && write_symbols == DWARF2_DEBUG)
4562 dwarf2out_start_source_file (filename);
4563 #endif /* DWARF2_DEBUGGING_INFO */
4564 #ifdef SDB_DEBUGGING_INFO
4565 if (write_symbols == SDB_DEBUG)
4566 sdbout_start_new_source_file (filename);
4567 #endif
4570 /* Record the resumption of a source file. LINENO is the line number in
4571 the source file we are returning to. */
4573 void
4574 debug_end_source_file (lineno)
4575 register unsigned lineno;
4577 #ifdef DBX_DEBUGGING_INFO
4578 if (write_symbols == DBX_DEBUG)
4579 dbxout_resume_previous_source_file ();
4580 #endif
4581 #ifdef DWARF_DEBUGGING_INFO
4582 if (debug_info_level == DINFO_LEVEL_VERBOSE
4583 && write_symbols == DWARF_DEBUG)
4584 dwarfout_resume_previous_source_file (lineno);
4585 #endif /* DWARF_DEBUGGING_INFO */
4586 #ifdef DWARF2_DEBUGGING_INFO
4587 if (debug_info_level == DINFO_LEVEL_VERBOSE
4588 && write_symbols == DWARF2_DEBUG)
4589 dwarf2out_end_source_file ();
4590 #endif /* DWARF2_DEBUGGING_INFO */
4591 #ifdef SDB_DEBUGGING_INFO
4592 if (write_symbols == SDB_DEBUG)
4593 sdbout_resume_previous_source_file ();
4594 #endif
4597 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4598 the tail part of the directive line, i.e. the part which is past the
4599 initial whitespace, #, whitespace, directive-name, whitespace part. */
4601 void
4602 debug_define (lineno, buffer)
4603 register unsigned lineno;
4604 register char *buffer;
4606 #ifdef DWARF_DEBUGGING_INFO
4607 if (debug_info_level == DINFO_LEVEL_VERBOSE
4608 && write_symbols == DWARF_DEBUG)
4609 dwarfout_define (lineno, buffer);
4610 #endif /* DWARF_DEBUGGING_INFO */
4611 #ifdef DWARF2_DEBUGGING_INFO
4612 if (debug_info_level == DINFO_LEVEL_VERBOSE
4613 && write_symbols == DWARF2_DEBUG)
4614 dwarf2out_define (lineno, buffer);
4615 #endif /* DWARF2_DEBUGGING_INFO */
4618 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4619 the tail part of the directive line, i.e. the part which is past the
4620 initial whitespace, #, whitespace, directive-name, whitespace part. */
4622 void
4623 debug_undef (lineno, buffer)
4624 register unsigned lineno;
4625 register char *buffer;
4627 #ifdef DWARF_DEBUGGING_INFO
4628 if (debug_info_level == DINFO_LEVEL_VERBOSE
4629 && write_symbols == DWARF_DEBUG)
4630 dwarfout_undef (lineno, buffer);
4631 #endif /* DWARF_DEBUGGING_INFO */
4632 #ifdef DWARF2_DEBUGGING_INFO
4633 if (debug_info_level == DINFO_LEVEL_VERBOSE
4634 && write_symbols == DWARF2_DEBUG)
4635 dwarf2out_undef (lineno, buffer);
4636 #endif /* DWARF2_DEBUGGING_INFO */