(decl_function_context): Handle QUAL_UNION_TYPE.
[official-gcc.git] / gcc / toplev.c
blobb080e19e280d8eaeb3c94277ff0550ebc9d70fa2
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-5, 1996 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 #include <stdio.h>
33 #include <signal.h>
34 #include <setjmp.h>
35 #include <sys/types.h>
36 #include <ctype.h>
37 #include <sys/stat.h>
39 #ifndef _WIN32
40 #ifdef USG
41 #undef FLOAT
42 #include <sys/param.h>
43 /* This is for hpux. It is a real screw. They should change hpux. */
44 #undef FLOAT
45 #include <sys/times.h>
46 #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
47 #undef FFS /* Some systems define this in param.h. */
48 #else
49 #ifndef VMS
50 #include <sys/time.h>
51 #include <sys/resource.h>
52 #endif
53 #endif
54 #endif
56 #include "input.h"
57 #include "tree.h"
58 #include "rtl.h"
59 #include "flags.h"
60 #include "insn-attr.h"
61 #include "defaults.h"
62 #include "output.h"
63 #include "bytecode.h"
64 #include "bc-emit.h"
65 #include "except.h"
67 #ifdef XCOFF_DEBUGGING_INFO
68 #include "xcoffout.h"
69 #endif
71 #ifdef VMS
72 /* The extra parameters substantially improve the I/O performance. */
73 static FILE *
74 vms_fopen (fname, type)
75 char * fname;
76 char * type;
78 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
79 fixed arguments, which matches ANSI's specification but not VAXCRTL's
80 pre-ANSI implementation. This hack circumvents the mismatch problem. */
81 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
83 if (*type == 'w')
84 return (*vmslib_fopen) (fname, type, "mbc=32",
85 "deq=64", "fop=tef", "shr=nil");
86 else
87 return (*vmslib_fopen) (fname, type, "mbc=32");
89 #define fopen vms_fopen
90 #endif /* VMS */
92 #ifndef DEFAULT_GDB_EXTENSIONS
93 #define DEFAULT_GDB_EXTENSIONS 1
94 #endif
96 /* If more than one debugging type is supported, you must define
97 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
99 This is one long line cause VAXC can't handle a \-newline. */
100 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
101 #ifndef PREFERRED_DEBUGGING_TYPE
102 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
103 #endif /* no PREFERRED_DEBUGGING_TYPE */
104 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
105 so the following code needn't care. */
106 #ifdef DBX_DEBUGGING_INFO
107 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
108 #endif
109 #ifdef SDB_DEBUGGING_INFO
110 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
111 #endif
112 #ifdef DWARF_DEBUGGING_INFO
113 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
114 #endif
115 #ifdef XCOFF_DEBUGGING_INFO
116 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
117 #endif
118 #endif /* More than one debugger format enabled. */
120 /* If still not defined, must have been because no debugging formats
121 are supported. */
122 #ifndef PREFERRED_DEBUGGING_TYPE
123 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
124 #endif
126 extern int rtx_equal_function_value_matters;
128 #if ! (defined (VMS) || defined (OS2))
129 extern char **environ;
130 #endif
131 extern char *version_string, *language_string;
133 /* Carry information from ASM_DECLARE_OBJECT_NAME
134 to ASM_FINISH_DECLARE_OBJECT. */
136 extern int size_directive_output;
137 extern tree last_assemble_variable_decl;
139 extern void init_lex ();
140 extern void init_decl_processing ();
141 extern void init_obstacks ();
142 extern void init_tree_codes ();
143 extern void init_rtl ();
144 extern void init_regs ();
145 extern void init_optabs ();
146 extern void init_stmt ();
147 extern void init_reg_sets ();
148 extern void dump_flow_info ();
149 extern void dump_sched_info ();
150 extern void dump_local_alloc ();
152 void rest_of_decl_compilation ();
153 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
154 void error_with_decl PVPROTO((tree decl, char *s, ...));
155 void error_for_asm PVPROTO((rtx insn, char *s, ...));
156 void error PVPROTO((char *s, ...));
157 void fatal PVPROTO((char *s, ...));
158 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
159 void warning_with_decl PVPROTO((tree decl, char *s, ...));
160 void warning_for_asm PVPROTO((rtx insn, char *s, ...));
161 void warning PVPROTO((char *s, ...));
162 void pedwarn PVPROTO((char *s, ...));
163 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
164 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
165 void sorry PVPROTO((char *s, ...));
166 void really_sorry PVPROTO((char *s, ...));
167 void fancy_abort ();
168 #ifndef abort
169 void abort ();
170 #endif
171 void set_target_switch ();
172 static char *decl_name ();
174 void print_version ();
175 int print_single_switch ();
176 void print_switch_values ();
177 /* Length of line when printing switch values. */
178 #define MAX_LINE 75
180 #ifdef __alpha
181 extern char *sbrk ();
182 #endif
184 /* Name of program invoked, sans directories. */
186 char *progname;
188 /* Copy of arguments to main. */
189 int save_argc;
190 char **save_argv;
192 /* Name of current original source file (what was input to cpp).
193 This comes from each #-command in the actual input. */
195 char *input_filename;
197 /* Name of top-level original source file (what was input to cpp).
198 This comes from the #-command at the beginning of the actual input.
199 If there isn't any there, then this is the cc1 input file name. */
201 char *main_input_filename;
203 /* Stream for reading from the input file. */
205 FILE *finput;
207 /* Current line number in real source file. */
209 int lineno;
211 /* Stack of currently pending input files. */
213 struct file_stack *input_file_stack;
215 /* Incremented on each change to input_file_stack. */
216 int input_file_stack_tick;
218 /* FUNCTION_DECL for function now being parsed or compiled. */
220 extern tree current_function_decl;
222 /* Name to use as base of names for dump output files. */
224 char *dump_base_name;
226 /* Bit flags that specify the machine subtype we are compiling for.
227 Bits are tested using macros TARGET_... defined in the tm.h file
228 and set by `-m...' switches. Must be defined in rtlanal.c. */
230 extern int target_flags;
232 /* Flags saying which kinds of debugging dump have been requested. */
234 int rtl_dump = 0;
235 int rtl_dump_and_exit = 0;
236 int jump_opt_dump = 0;
237 int cse_dump = 0;
238 int loop_dump = 0;
239 int cse2_dump = 0;
240 int flow_dump = 0;
241 int combine_dump = 0;
242 int sched_dump = 0;
243 int local_reg_dump = 0;
244 int global_reg_dump = 0;
245 int sched2_dump = 0;
246 int jump2_opt_dump = 0;
247 int dbr_sched_dump = 0;
248 int flag_print_asm_name = 0;
249 int stack_reg_dump = 0;
251 /* Name for output file of assembly code, specified with -o. */
253 char *asm_file_name;
255 /* Value of the -G xx switch, and whether it was passed or not. */
256 int g_switch_value;
257 int g_switch_set;
259 /* Type(s) of debugging information we are producing (if any).
260 See flags.h for the definitions of the different possible
261 types of debugging information. */
262 enum debug_info_type write_symbols = NO_DEBUG;
264 /* Level of debugging information we are producing. See flags.h
265 for the definitions of the different possible levels. */
266 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
268 /* Nonzero means use GNU-only extensions in the generated symbolic
269 debugging information. */
270 /* Currently, this only has an effect when write_symbols is set to
271 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
272 int use_gnu_debug_info_extensions = 0;
274 /* Nonzero means do optimizations. -O.
275 Particular numeric values stand for particular amounts of optimization;
276 thus, -O2 stores 2 here. However, the optimizations beyond the basic
277 ones are not controlled directly by this variable. Instead, they are
278 controlled by individual `flag_...' variables that are defaulted
279 based on this variable. */
281 int optimize = 0;
283 /* Number of error messages and warning messages so far. */
285 int errorcount = 0;
286 int warningcount = 0;
287 int sorrycount = 0;
289 /* Flag to output bytecode instead of native assembler */
290 int output_bytecode = 0;
292 /* Pointer to function to compute the name to use to print a declaration. */
294 char *(*decl_printable_name) ();
296 /* Pointer to function to compute rtl for a language-specific tree code. */
298 struct rtx_def *(*lang_expand_expr) ();
300 /* Pointer to function to finish handling an incomplete decl at the
301 end of compilation. */
303 void (*incomplete_decl_finalize_hook) () = 0;
305 /* Highest label number used at the end of reload. */
307 int max_label_num_after_reload;
309 /* Nonzero if generating code to do profiling. */
311 int profile_flag = 0;
313 /* Nonzero if generating code to do profiling on a line-by-line basis. */
315 int profile_block_flag;
317 /* Nonzero for -pedantic switch: warn about anything
318 that standard spec forbids. */
320 int pedantic = 0;
322 /* Temporarily suppress certain warnings.
323 This is set while reading code from a system header file. */
325 int in_system_header = 0;
327 /* Nonzero means do stupid register allocation.
328 Currently, this is 1 if `optimize' is 0. */
330 int obey_regdecls = 0;
332 /* Don't print functions as they are compiled and don't print
333 times taken by the various passes. -quiet. */
335 int quiet_flag = 0;
337 /* -f flags. */
339 /* Nonzero means `char' should be signed. */
341 int flag_signed_char;
343 /* Nonzero means give an enum type only as many bytes as it needs. */
345 int flag_short_enums;
347 /* Nonzero for -fcaller-saves: allocate values in regs that need to
348 be saved across function calls, if that produces overall better code.
349 Optional now, so people can test it. */
351 #ifdef DEFAULT_CALLER_SAVES
352 int flag_caller_saves = 1;
353 #else
354 int flag_caller_saves = 0;
355 #endif
357 /* Nonzero if structures and unions should be returned in memory.
359 This should only be defined if compatibility with another compiler or
360 with an ABI is needed, because it results in slower code. */
362 #ifndef DEFAULT_PCC_STRUCT_RETURN
363 #define DEFAULT_PCC_STRUCT_RETURN 1
364 #endif
366 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
368 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
370 /* Nonzero for -fforce-mem: load memory value into a register
371 before arithmetic on it. This makes better cse but slower compilation. */
373 int flag_force_mem = 0;
375 /* Nonzero for -fforce-addr: load memory address into a register before
376 reference to memory. This makes better cse but slower compilation. */
378 int flag_force_addr = 0;
380 /* Nonzero for -fdefer-pop: don't pop args after each function call;
381 instead save them up to pop many calls' args with one insns. */
383 int flag_defer_pop = 0;
385 /* Nonzero for -ffloat-store: don't allocate floats and doubles
386 in extended-precision registers. */
388 int flag_float_store = 0;
390 /* Nonzero for -fcse-follow-jumps:
391 have cse follow jumps to do a more extensive job. */
393 int flag_cse_follow_jumps;
395 /* Nonzero for -fcse-skip-blocks:
396 have cse follow a branch around a block. */
397 int flag_cse_skip_blocks;
399 /* Nonzero for -fexpensive-optimizations:
400 perform miscellaneous relatively-expensive optimizations. */
401 int flag_expensive_optimizations;
403 /* Nonzero for -fthread-jumps:
404 have jump optimize output of loop. */
406 int flag_thread_jumps;
408 /* Nonzero enables strength-reduction in loop.c. */
410 int flag_strength_reduce = 0;
412 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
413 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
414 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
415 unrolled. */
417 int flag_unroll_loops;
419 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
420 This is generally not a win. */
422 int flag_unroll_all_loops;
424 /* Nonzero for -fwritable-strings:
425 store string constants in data segment and don't uniquize them. */
427 int flag_writable_strings = 0;
429 /* Nonzero means don't put addresses of constant functions in registers.
430 Used for compiling the Unix kernel, where strange substitutions are
431 done on the assembly output. */
433 int flag_no_function_cse = 0;
435 /* Nonzero for -fomit-frame-pointer:
436 don't make a frame pointer in simple functions that don't require one. */
438 int flag_omit_frame_pointer = 0;
440 /* Nonzero means place each function into its own section on those platforms
441 which support arbitrary section names and unlimited numbers of sections. */
443 int flag_function_sections = 0;
445 /* Nonzero to inhibit use of define_optimization peephole opts. */
447 int flag_no_peephole = 0;
449 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
450 operations in the interest of optimization. For example it allows
451 GCC to assume arguments to sqrt are nonnegative numbers, allowing
452 faster code for sqrt to be generated. */
454 int flag_fast_math = 0;
456 /* Nonzero means all references through pointers are volatile. */
458 int flag_volatile;
460 /* Nonzero means treat all global and extern variables as global. */
462 int flag_volatile_global;
464 /* Nonzero means just do syntax checking; don't output anything. */
466 int flag_syntax_only = 0;
468 /* Nonzero means to rerun cse after loop optimization. This increases
469 compilation time about 20% and picks up a few more common expressions. */
471 static int flag_rerun_cse_after_loop;
473 /* Nonzero for -finline-functions: ok to inline functions that look like
474 good inline candidates. */
476 int flag_inline_functions;
478 /* Nonzero for -fkeep-inline-functions: even if we make a function
479 go inline everywhere, keep its definition around for debugging
480 purposes. */
482 int flag_keep_inline_functions;
484 /* Nonzero means that functions will not be inlined. */
486 int flag_no_inline;
488 /* Nonzero means that we should emit static const variables
489 regardless of whether or not optimization is turned on. */
491 int flag_keep_static_consts = 1;
493 /* Nonzero means we should be saving declaration info into a .X file. */
495 int flag_gen_aux_info = 0;
497 /* Specified name of aux-info file. */
499 static char *aux_info_file_name;
501 /* Nonzero means make the text shared if supported. */
503 int flag_shared_data;
505 /* Nonzero means schedule into delayed branch slots if supported. */
507 int flag_delayed_branch;
509 /* Nonzero means to run cleanups after CALL_EXPRs. */
511 int flag_short_temps;
513 /* Nonzero if we are compiling pure (sharable) code.
514 Value is 1 if we are doing reasonable (i.e. simple
515 offset into offset table) pic. Value is 2 if we can
516 only perform register offsets. */
518 int flag_pic;
520 /* Nonzero means generate extra code for exception handling and enable
521 exception handling. */
523 int flag_exceptions = 1;
525 /* Nonzero means don't place uninitialized global data in common storage
526 by default. */
528 int flag_no_common;
530 /* Nonzero means pretend it is OK to examine bits of target floats,
531 even if that isn't true. The resulting code will have incorrect constants,
532 but the same series of instructions that the native compiler would make. */
534 int flag_pretend_float;
536 /* Nonzero means change certain warnings into errors.
537 Usually these are warnings about failure to conform to some standard. */
539 int flag_pedantic_errors = 0;
541 /* flag_schedule_insns means schedule insns within basic blocks (before
542 local_alloc).
543 flag_schedule_insns_after_reload means schedule insns after
544 global_alloc. */
546 int flag_schedule_insns = 0;
547 int flag_schedule_insns_after_reload = 0;
549 /* -finhibit-size-directive inhibits output of .size for ELF.
550 This is used only for compiling crtstuff.c,
551 and it may be extended to other effects
552 needed for crtstuff.c on other systems. */
553 int flag_inhibit_size_directive = 0;
555 /* -fverbose-asm causes extra commentary information to be produced in
556 the generated assembly code (to make it more readable). This option
557 is generally only of use to those who actually need to read the
558 generated assembly code (perhaps while debugging the compiler itself).
559 -fverbose-asm is the default. -fno-verbose-asm causes the extra information
560 to be omitted and is useful when comparing two assembler files. */
562 int flag_verbose_asm = 1;
564 /* -dA causes debug commentary information to be produced in
565 the generated assembly code (to make it more readable). This option
566 is generally only of use to those who actually need to read the
567 generated assembly code (perhaps while debugging the compiler itself).
568 Currently, this switch is only used by dwarfout.c; however, it is intended
569 to be a catchall for printing debug information in the assembler file. */
571 int flag_debug_asm = 0;
573 /* -fgnu-linker specifies use of the GNU linker for initializations.
574 (Or, more generally, a linker that handles initializations.)
575 -fno-gnu-linker says that collect2 will be used. */
576 #ifdef USE_COLLECT2
577 int flag_gnu_linker = 0;
578 #else
579 int flag_gnu_linker = 1;
580 #endif
582 /* Tag all structures with __attribute__(packed) */
583 int flag_pack_struct = 0;
585 /* Table of language-independent -f options.
586 STRING is the option name. VARIABLE is the address of the variable.
587 ON_VALUE is the value to store in VARIABLE
588 if `-fSTRING' is seen as an option.
589 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
591 struct { char *string; int *variable; int on_value;} f_options[] =
593 {"float-store", &flag_float_store, 1},
594 {"volatile", &flag_volatile, 1},
595 {"volatile-global", &flag_volatile_global, 1},
596 {"defer-pop", &flag_defer_pop, 1},
597 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
598 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
599 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
600 {"expensive-optimizations", &flag_expensive_optimizations, 1},
601 {"thread-jumps", &flag_thread_jumps, 1},
602 {"strength-reduce", &flag_strength_reduce, 1},
603 {"unroll-loops", &flag_unroll_loops, 1},
604 {"unroll-all-loops", &flag_unroll_all_loops, 1},
605 {"writable-strings", &flag_writable_strings, 1},
606 {"peephole", &flag_no_peephole, 0},
607 {"force-mem", &flag_force_mem, 1},
608 {"force-addr", &flag_force_addr, 1},
609 {"function-cse", &flag_no_function_cse, 0},
610 {"inline-functions", &flag_inline_functions, 1},
611 {"keep-inline-functions", &flag_keep_inline_functions, 1},
612 {"inline", &flag_no_inline, 0},
613 {"keep-static-consts", &flag_keep_static_consts, 1},
614 {"syntax-only", &flag_syntax_only, 1},
615 {"shared-data", &flag_shared_data, 1},
616 {"caller-saves", &flag_caller_saves, 1},
617 {"pcc-struct-return", &flag_pcc_struct_return, 1},
618 {"reg-struct-return", &flag_pcc_struct_return, 0},
619 {"delayed-branch", &flag_delayed_branch, 1},
620 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
621 {"pretend-float", &flag_pretend_float, 1},
622 {"schedule-insns", &flag_schedule_insns, 1},
623 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
624 {"pic", &flag_pic, 1},
625 {"PIC", &flag_pic, 2},
626 {"exceptions", &flag_exceptions, 1},
627 {"fast-math", &flag_fast_math, 1},
628 {"common", &flag_no_common, 0},
629 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
630 {"function-sections", &flag_function_sections, 1},
631 {"verbose-asm", &flag_verbose_asm, 1},
632 {"gnu-linker", &flag_gnu_linker, 1},
633 {"pack-struct", &flag_pack_struct, 1},
634 {"bytecode", &output_bytecode, 1}
637 /* Table of language-specific options. */
639 char *lang_options[] =
641 "-ansi",
642 "-fallow-single-precision",
644 "-fsigned-bitfields",
645 "-funsigned-bitfields",
646 "-fno-signed-bitfields",
647 "-fno-unsigned-bitfields",
648 "-fsigned-char",
649 "-funsigned-char",
650 "-fno-signed-char",
651 "-fno-unsigned-char",
653 "-ftraditional",
654 "-traditional",
655 "-fnotraditional",
656 "-fno-traditional",
658 "-fasm",
659 "-fno-asm",
660 "-fbuiltin",
661 "-fno-builtin",
662 "-fcond-mismatch",
663 "-fno-cond-mismatch",
664 "-fdollars-in-identifiers",
665 "-fno-dollars-in-identifiers",
666 "-fident",
667 "-fno-ident",
668 "-fshort-double",
669 "-fno-short-double",
670 "-fshort-enums",
671 "-fno-short-enums",
673 "-Wall",
674 "-Wbad-function-cast",
675 "-Wno-bad-function-cast",
676 "-Wcast-qual",
677 "-Wno-cast-qual",
678 "-Wchar-subscripts",
679 "-Wno-char-subscripts",
680 "-Wcomment",
681 "-Wno-comment",
682 "-Wcomments",
683 "-Wno-comments",
684 "-Wconversion",
685 "-Wno-conversion",
686 "-Wformat",
687 "-Wno-format",
688 "-Wimport",
689 "-Wno-import",
690 "-Wimplicit",
691 "-Wno-implicit",
692 "-Wmissing-braces",
693 "-Wno-missing-braces",
694 "-Wmissing-declarations",
695 "-Wno-missing-declarations",
696 "-Wmissing-prototypes",
697 "-Wno-missing-prototypes",
698 "-Wnested-externs",
699 "-Wno-nested-externs",
700 "-Wparentheses",
701 "-Wno-parentheses",
702 "-Wpointer-arith",
703 "-Wno-pointer-arith",
704 "-Wredundant-decls",
705 "-Wno-redundant-decls",
706 "-Wsign-compare",
707 "-Wno-sign-compare",
708 "-Wstrict-prototypes",
709 "-Wno-strict-prototypes",
710 "-Wtraditional",
711 "-Wno-traditional",
712 "-Wtrigraphs",
713 "-Wno-trigraphs",
714 "-Wwrite-strings",
715 "-Wno-write-strings",
717 /* these are for obj c */
718 "-lang-objc",
719 "-gen-decls",
720 "-fgnu-runtime",
721 "-fno-gnu-runtime",
722 "-fnext-runtime",
723 "-fno-next-runtime",
724 "-Wselector",
725 "-Wno-selector",
726 "-Wprotocol",
727 "-Wno-protocol",
729 #include "options.h"
733 /* Options controlling warnings */
735 /* Don't print warning messages. -w. */
737 int inhibit_warnings = 0;
739 /* Print various extra warnings. -W. */
741 int extra_warnings = 0;
743 /* Treat warnings as errors. -Werror. */
745 int warnings_are_errors = 0;
747 /* Nonzero to warn about unused local variables. */
749 int warn_unused;
751 /* Nonzero to warn about variables used before they are initialized. */
753 int warn_uninitialized;
755 /* Nonzero means warn about all declarations which shadow others. */
757 int warn_shadow;
759 /* Warn if a switch on an enum fails to have a case for every enum value. */
761 int warn_switch;
763 /* Nonzero means warn about function definitions that default the return type
764 or that use a null return and have a return-type other than void. */
766 int warn_return_type;
768 /* Nonzero means warn about pointer casts that increase the required
769 alignment of the target type (and might therefore lead to a crash
770 due to a misaligned access). */
772 int warn_cast_align;
774 /* Nonzero means warn about any identifiers that match in the first N
775 characters. The value N is in `id_clash_len'. */
777 int warn_id_clash;
778 unsigned id_clash_len;
780 /* Nonzero means warn about any objects definitions whose size is larger
781 than N bytes. Also want about function definitions whose returned
782 values are larger than N bytes. The value N is in `larger_than_size'. */
784 int warn_larger_than;
785 unsigned larger_than_size;
787 /* Nonzero means warn if inline function is too large. */
789 int warn_inline;
791 /* Warn if a function returns an aggregate,
792 since there are often incompatible calling conventions for doing this. */
794 int warn_aggregate_return;
796 /* Likewise for -W. */
798 struct { char *string; int *variable; int on_value;} W_options[] =
800 {"unused", &warn_unused, 1},
801 {"error", &warnings_are_errors, 1},
802 {"shadow", &warn_shadow, 1},
803 {"switch", &warn_switch, 1},
804 {"aggregate-return", &warn_aggregate_return, 1},
805 {"cast-align", &warn_cast_align, 1},
806 {"uninitialized", &warn_uninitialized, 1},
807 {"inline", &warn_inline, 1}
810 /* Output files for assembler code (real compiler output)
811 and debugging dumps. */
813 FILE *asm_out_file;
814 FILE *aux_info_file;
815 FILE *rtl_dump_file;
816 FILE *jump_opt_dump_file;
817 FILE *cse_dump_file;
818 FILE *loop_dump_file;
819 FILE *cse2_dump_file;
820 FILE *flow_dump_file;
821 FILE *combine_dump_file;
822 FILE *sched_dump_file;
823 FILE *local_reg_dump_file;
824 FILE *global_reg_dump_file;
825 FILE *sched2_dump_file;
826 FILE *jump2_opt_dump_file;
827 FILE *dbr_sched_dump_file;
828 FILE *stack_reg_dump_file;
830 /* Time accumulators, to count the total time spent in various passes. */
832 int parse_time;
833 int varconst_time;
834 int integration_time;
835 int jump_time;
836 int cse_time;
837 int loop_time;
838 int cse2_time;
839 int flow_time;
840 int combine_time;
841 int sched_time;
842 int local_alloc_time;
843 int global_alloc_time;
844 int sched2_time;
845 int dbr_sched_time;
846 int shorten_branch_time;
847 int stack_reg_time;
848 int final_time;
849 int symout_time;
850 int dump_time;
852 /* Return time used so far, in microseconds. */
855 get_run_time ()
857 #ifndef _WIN32
858 #ifdef USG
859 struct tms tms;
860 #else
861 #ifndef VMS
862 struct rusage rusage;
863 #else
864 struct
866 int proc_user_time;
867 int proc_system_time;
868 int child_user_time;
869 int child_system_time;
870 } vms_times;
871 #endif
872 #endif
873 #endif
875 if (quiet_flag)
876 return 0;
877 #ifdef _WIN32
878 if (clock() < 0)
879 return 0;
880 else
881 return (clock() * 1000);
882 #else /* not _WIN32 */
883 #ifdef USG
884 times (&tms);
885 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
886 #else
887 #ifndef VMS
888 getrusage (0, &rusage);
889 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
890 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
891 #else /* VMS */
892 times (&vms_times);
893 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
894 #endif
895 #endif
896 #endif
899 #define TIMEVAR(VAR, BODY) \
900 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
902 void
903 print_time (str, total)
904 char *str;
905 int total;
907 fprintf (stderr,
908 "time in %s: %d.%06d\n",
909 str, total / 1000000, total % 1000000);
912 /* Count an error or warning. Return 1 if the message should be printed. */
915 count_error (warningp)
916 int warningp;
918 if (warningp && inhibit_warnings)
919 return 0;
921 if (warningp && !warnings_are_errors)
922 warningcount++;
923 else
925 static int warning_message = 0;
927 if (warningp && !warning_message)
929 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
930 warning_message = 1;
932 errorcount++;
935 return 1;
938 /* Print a fatal error message. NAME is the text.
939 Also include a system error message based on `errno'. */
941 void
942 pfatal_with_name (name)
943 char *name;
945 fprintf (stderr, "%s: ", progname);
946 perror (name);
947 exit (FATAL_EXIT_CODE);
950 void
951 fatal_io_error (name)
952 char *name;
954 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
955 exit (FATAL_EXIT_CODE);
958 /* Called to give a better error message for a bad insn rather than
959 just calling abort(). */
961 void
962 fatal_insn (message, insn)
963 char *message;
964 rtx insn;
966 if (!output_bytecode)
968 error (message);
969 debug_rtx (insn);
971 if (asm_out_file)
972 fflush (asm_out_file);
973 if (aux_info_file)
974 fflush (aux_info_file);
975 if (rtl_dump_file)
976 fflush (rtl_dump_file);
977 if (jump_opt_dump_file)
978 fflush (jump_opt_dump_file);
979 if (cse_dump_file)
980 fflush (cse_dump_file);
981 if (loop_dump_file)
982 fflush (loop_dump_file);
983 if (cse2_dump_file)
984 fflush (cse2_dump_file);
985 if (flow_dump_file)
986 fflush (flow_dump_file);
987 if (combine_dump_file)
988 fflush (combine_dump_file);
989 if (sched_dump_file)
990 fflush (sched_dump_file);
991 if (local_reg_dump_file)
992 fflush (local_reg_dump_file);
993 if (global_reg_dump_file)
994 fflush (global_reg_dump_file);
995 if (sched2_dump_file)
996 fflush (sched2_dump_file);
997 if (jump2_opt_dump_file)
998 fflush (jump2_opt_dump_file);
999 if (dbr_sched_dump_file)
1000 fflush (dbr_sched_dump_file);
1001 if (stack_reg_dump_file)
1002 fflush (stack_reg_dump_file);
1003 fflush (stdout);
1004 fflush (stderr);
1005 abort ();
1008 /* Called to give a better error message when we don't have an insn to match
1009 what we are looking for or if the insn's constraints aren't satisfied,
1010 rather than just calling abort(). */
1012 void
1013 fatal_insn_not_found (insn)
1014 rtx insn;
1016 if (INSN_CODE (insn) < 0)
1017 fatal_insn ("internal error--unrecognizable insn:", insn);
1018 else
1019 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1022 /* This is the default decl_printable_name function. */
1024 static char *
1025 decl_name (decl, kind)
1026 tree decl;
1027 char **kind;
1029 return IDENTIFIER_POINTER (DECL_NAME (decl));
1032 static int need_error_newline;
1034 /* Function of last error message;
1035 more generally, function such that if next error message is in it
1036 then we don't have to mention the function name. */
1037 static tree last_error_function = NULL;
1039 /* Used to detect when input_file_stack has changed since last described. */
1040 static int last_error_tick;
1042 /* Called when the start of a function definition is parsed,
1043 this function prints on stderr the name of the function. */
1045 void
1046 announce_function (decl)
1047 tree decl;
1049 if (! quiet_flag)
1051 char *junk;
1052 if (rtl_dump_and_exit)
1053 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1054 else
1055 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
1056 fflush (stderr);
1057 need_error_newline = 1;
1058 last_error_function = current_function_decl;
1062 /* The default function to print out name of current function that caused
1063 an error. */
1065 void
1066 default_print_error_function (file)
1067 char *file;
1069 if (last_error_function != current_function_decl)
1071 char *kind = "function";
1072 if (current_function_decl != 0
1073 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1074 kind = "method";
1076 if (file)
1077 fprintf (stderr, "%s: ", file);
1079 if (current_function_decl == NULL)
1080 fprintf (stderr, "At top level:\n");
1081 else
1083 char *name = (*decl_printable_name) (current_function_decl, &kind);
1084 fprintf (stderr, "In %s `%s':\n", kind, name);
1087 last_error_function = current_function_decl;
1091 /* Called by report_error_function to print out function name.
1092 * Default may be overridden by language front-ends. */
1094 void (*print_error_function) PROTO((char *)) = default_print_error_function;
1096 /* Prints out, if necessary, the name of the current function
1097 that caused an error. Called from all error and warning functions. */
1099 void
1100 report_error_function (file)
1101 char *file;
1103 struct file_stack *p;
1105 if (need_error_newline)
1107 fprintf (stderr, "\n");
1108 need_error_newline = 0;
1111 (*print_error_function) (file);
1113 if (input_file_stack && input_file_stack->next != 0
1114 && input_file_stack_tick != last_error_tick
1115 && file == input_filename)
1117 fprintf (stderr, "In file included");
1118 for (p = input_file_stack->next; p; p = p->next)
1120 fprintf (stderr, " from %s:%d", p->name, p->line);
1121 if (p->next)
1122 fprintf (stderr, ",\n ");
1124 fprintf (stderr, ":\n");
1125 last_error_tick = input_file_stack_tick;
1129 /* Print a message. */
1131 static void
1132 vmessage (prefix, s, ap)
1133 char *prefix;
1134 char *s;
1135 va_list ap;
1137 if (prefix)
1138 fprintf (stderr, "%s: ", prefix);
1140 #ifdef HAVE_VPRINTF
1141 vfprintf (stderr, s, ap);
1142 #else
1144 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1145 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1146 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1147 HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT);
1148 fprintf (stderr, s, v1, v2, v3, v4);
1150 #endif
1153 /* Print a message relevant to line LINE of file FILE. */
1155 static void
1156 v_message_with_file_and_line (file, line, prefix, s, ap)
1157 char *file;
1158 int line;
1159 char *prefix;
1160 char *s;
1161 va_list ap;
1163 if (file)
1164 fprintf (stderr, "%s:%d: ", file, line);
1165 else
1166 fprintf (stderr, "%s: ", progname);
1168 vmessage (prefix, s, ap);
1169 fputc ('\n', stderr);
1172 /* Print a message relevant to the given DECL. */
1174 static void
1175 v_message_with_decl (decl, prefix, s, ap)
1176 tree decl;
1177 char *prefix;
1178 char *s;
1179 va_list ap;
1181 char *n, *p, *junk;
1183 fprintf (stderr, "%s:%d: ",
1184 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1186 if (prefix)
1187 fprintf (stderr, "%s: ", prefix);
1189 /* Do magic to get around lack of varargs support for insertion
1190 of arguments into existing list. We know that the decl is first;
1191 we ass_u_me that it will be printed with "%s". */
1193 for (p = s; *p; ++p)
1195 if (*p == '%')
1197 if (*(p + 1) == '%')
1198 ++p;
1199 else
1200 break;
1204 if (p > s) /* Print the left-hand substring. */
1206 char fmt[sizeof "%.255s"];
1207 long width = p - s;
1209 if (width > 255L) width = 255L; /* arbitrary */
1210 sprintf (fmt, "%%.%lds", width);
1211 fprintf (stderr, fmt, s);
1214 if (*p == '%') /* Print the name. */
1216 char *n = (DECL_NAME (decl)
1217 ? (*decl_printable_name) (decl, &junk)
1218 : "((anonymous))");
1219 fputs (n, stderr);
1220 while (*p)
1222 ++p;
1223 if (isalpha (*(p - 1) & 0xFF))
1224 break;
1228 if (*p) /* Print the rest of the message. */
1229 vmessage ((char *)NULL, p, ap);
1231 fputc ('\n', stderr);
1234 /* Figure file and line of the given INSN. */
1236 static void
1237 file_and_line_for_asm (insn, pfile, pline)
1238 rtx insn;
1239 char **pfile;
1240 int *pline;
1242 rtx body = PATTERN (insn);
1243 rtx asmop;
1245 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1246 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1247 asmop = SET_SRC (body);
1248 else if (GET_CODE (body) == ASM_OPERANDS)
1249 asmop = body;
1250 else if (GET_CODE (body) == PARALLEL
1251 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1252 asmop = SET_SRC (XVECEXP (body, 0, 0));
1253 else if (GET_CODE (body) == PARALLEL
1254 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1255 asmop = XVECEXP (body, 0, 0);
1256 else
1257 asmop = NULL;
1259 if (asmop)
1261 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1262 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1264 else
1266 *pfile = input_filename;
1267 *pline = lineno;
1271 /* Report an error at line LINE of file FILE. */
1273 static void
1274 v_error_with_file_and_line (file, line, s, ap)
1275 char *file;
1276 int line;
1277 char *s;
1278 va_list ap;
1280 count_error (0);
1281 report_error_function (file);
1282 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1285 void
1286 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1288 #ifndef __STDC__
1289 char *file;
1290 int line;
1291 char *s;
1292 #endif
1293 va_list ap;
1295 VA_START (ap, s);
1297 #ifndef __STDC__
1298 file = va_arg (ap, char *);
1299 line = va_arg (ap, int);
1300 s = va_arg (ap, char *);
1301 #endif
1303 v_error_with_file_and_line (file, line, s, ap);
1304 va_end (ap);
1307 /* Report an error at the declaration DECL.
1308 S is a format string which uses %s to substitute the declaration
1309 name; subsequent substitutions are a la printf. */
1311 static void
1312 v_error_with_decl (decl, s, ap)
1313 tree decl;
1314 char *s;
1315 va_list ap;
1317 count_error (0);
1318 report_error_function (DECL_SOURCE_FILE (decl));
1319 v_message_with_decl (decl, (char *)NULL, s, ap);
1322 void
1323 error_with_decl VPROTO((tree decl, char *s, ...))
1325 #ifndef __STDC__
1326 tree decl;
1327 char *s;
1328 #endif
1329 va_list ap;
1331 VA_START (ap, s);
1333 #ifndef __STDC__
1334 decl = va_arg (ap, tree);
1335 s = va_arg (ap, char *);
1336 #endif
1338 v_error_with_decl (decl, s, ap);
1339 va_end (ap);
1342 /* Report an error at the line number of the insn INSN.
1343 This is used only when INSN is an `asm' with operands,
1344 and each ASM_OPERANDS records its own source file and line. */
1346 static void
1347 v_error_for_asm (insn, s, ap)
1348 rtx insn;
1349 char *s;
1350 va_list ap;
1352 char *file;
1353 int line;
1355 count_error (0);
1356 file_and_line_for_asm (insn, &file, &line);
1357 report_error_function (file);
1358 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1361 void
1362 error_for_asm VPROTO((rtx insn, char *s, ...))
1364 #ifndef __STDC__
1365 rtx insn;
1366 char *s;
1367 #endif
1368 va_list ap;
1370 VA_START (ap, s);
1372 #ifndef __STDC__
1373 insn = va_arg (ap, rtx);
1374 s = va_arg (ap, char *);
1375 #endif
1377 v_error_for_asm (insn, s, ap);
1378 va_end (ap);
1381 /* Report an error at the current line number. */
1383 static void
1384 verror (s, ap)
1385 char *s;
1386 va_list ap;
1388 v_error_with_file_and_line (input_filename, lineno, s, ap);
1391 void
1392 error VPROTO((char *s, ...))
1394 #ifndef __STDC__
1395 char *s;
1396 #endif
1397 va_list ap;
1399 VA_START (ap, s);
1401 #ifndef __STDC__
1402 s = va_arg (ap, char *);
1403 #endif
1405 verror (s, ap);
1406 va_end (ap);
1409 /* Report a fatal error at the current line number. */
1411 static void
1412 vfatal (s, ap)
1413 char *s;
1414 va_list ap;
1416 verror (s, ap);
1417 exit (FATAL_EXIT_CODE);
1420 void
1421 fatal VPROTO((char *s, ...))
1423 #ifndef __STDC__
1424 char *s;
1425 #endif
1426 va_list ap;
1428 VA_START (ap, s);
1430 #ifndef __STDC__
1431 s = va_arg (ap, char *);
1432 #endif
1434 vfatal (s, ap);
1435 va_end (ap);
1438 /* Report a warning at line LINE of file FILE. */
1440 static void
1441 v_warning_with_file_and_line (file, line, s, ap)
1442 char *file;
1443 int line;
1444 char *s;
1445 va_list ap;
1447 if (count_error (1))
1449 report_error_function (file);
1450 v_message_with_file_and_line (file, line, "warning", s, ap);
1454 void
1455 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1457 #ifndef __STDC__
1458 char *file;
1459 int line;
1460 char *s;
1461 #endif
1462 va_list ap;
1464 VA_START (ap, s);
1466 #ifndef __STDC__
1467 file = va_arg (ap, char *);
1468 line = va_arg (ap, int);
1469 s = va_arg (ap, char *);
1470 #endif
1472 v_warning_with_file_and_line (file, line, s, ap);
1473 va_end (ap);
1476 /* Report a warning at the declaration DECL.
1477 S is a format string which uses %s to substitute the declaration
1478 name; subsequent substitutions are a la printf. */
1480 static void
1481 v_warning_with_decl (decl, s, ap)
1482 tree decl;
1483 char *s;
1484 va_list ap;
1486 if (count_error (1))
1488 report_error_function (DECL_SOURCE_FILE (decl));
1489 v_message_with_decl (decl, "warning", s, ap);
1493 void
1494 warning_with_decl VPROTO((tree decl, char *s, ...))
1496 #ifndef __STDC__
1497 tree decl;
1498 char *s;
1499 #endif
1500 va_list ap;
1502 VA_START (ap, s);
1504 #ifndef __STDC__
1505 decl = va_arg (ap, tree);
1506 s = va_arg (ap, char *);
1507 #endif
1509 v_warning_with_decl (decl, s, ap);
1510 va_end (ap);
1513 /* Report a warning at the line number of the insn INSN.
1514 This is used only when INSN is an `asm' with operands,
1515 and each ASM_OPERANDS records its own source file and line. */
1517 static void
1518 v_warning_for_asm (insn, s, ap)
1519 rtx insn;
1520 char *s;
1521 va_list ap;
1523 if (count_error (1))
1525 char *file;
1526 int line;
1528 file_and_line_for_asm (insn, &file, &line);
1529 report_error_function (file);
1530 v_message_with_file_and_line (file, line, "warning", s, ap);
1534 void
1535 warning_for_asm VPROTO((rtx insn, char *s, ...))
1537 #ifndef __STDC__
1538 rtx insn;
1539 char *s;
1540 #endif
1541 va_list ap;
1543 VA_START (ap, s);
1545 #ifndef __STDC__
1546 insn = va_arg (ap, rtx);
1547 s = va_arg (ap, char *);
1548 #endif
1550 v_warning_for_asm (insn, s, ap);
1551 va_end (ap);
1554 /* Report a warning at the current line number. */
1556 static void
1557 vwarning (s, ap)
1558 char *s;
1559 va_list ap;
1561 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1564 void
1565 warning VPROTO((char *s, ...))
1567 #ifndef __STDC__
1568 char *s;
1569 #endif
1570 va_list ap;
1572 VA_START (ap, s);
1574 #ifndef __STDC__
1575 s = va_arg (ap, char *);
1576 #endif
1578 vwarning (s, ap);
1579 va_end (ap);
1582 /* These functions issue either warnings or errors depending on
1583 -pedantic-errors. */
1585 static void
1586 vpedwarn (s, ap)
1587 char *s;
1588 va_list ap;
1590 if (flag_pedantic_errors)
1591 verror (s, ap);
1592 else
1593 vwarning (s, ap);
1596 void
1597 pedwarn VPROTO((char *s, ...))
1599 #ifndef __STDC__
1600 char *s;
1601 #endif
1602 va_list ap;
1604 VA_START (ap, s);
1606 #ifndef __STDC__
1607 s = va_arg (ap, char *);
1608 #endif
1610 vpedwarn (s, ap);
1611 va_end (ap);
1614 static void
1615 v_pedwarn_with_decl (decl, s, ap)
1616 tree decl;
1617 char *s;
1618 va_list ap;
1620 /* We don't want -pedantic-errors to cause the compilation to fail from
1621 "errors" in system header files. Sometimes fixincludes can't fix what's
1622 broken (eg: unsigned char bitfields - fixing it may change the alignment
1623 which will cause programs to mysteriously fail because the C library
1624 or kernel uses the original layout). There's no point in issuing a
1625 warning either, it's just unnecessary noise. */
1627 if (! DECL_IN_SYSTEM_HEADER (decl))
1629 if (flag_pedantic_errors)
1630 v_error_with_decl (decl, s, ap);
1631 else
1632 v_warning_with_decl (decl, s, ap);
1636 void
1637 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1639 #ifndef __STDC__
1640 tree decl;
1641 char *s;
1642 #endif
1643 va_list ap;
1645 VA_START (ap, s);
1647 #ifndef __STDC__
1648 decl = va_arg (ap, tree);
1649 s = va_arg (ap, char *);
1650 #endif
1652 v_pedwarn_with_decl (decl, s, ap);
1653 va_end (ap);
1656 static void
1657 v_pedwarn_with_file_and_line (file, line, s, ap)
1658 char *file;
1659 int line;
1660 char *s;
1661 va_list ap;
1663 if (flag_pedantic_errors)
1664 v_error_with_file_and_line (file, line, s, ap);
1665 else
1666 v_warning_with_file_and_line (file, line, s, ap);
1669 void
1670 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1672 #ifndef __STDC__
1673 char *file;
1674 int line;
1675 char *s;
1676 #endif
1677 va_list ap;
1679 VA_START (ap, s);
1681 #ifndef __STDC__
1682 file = va_arg (ap, char *);
1683 line = va_arg (ap, int);
1684 s = va_arg (ap, char *);
1685 #endif
1687 v_pedwarn_with_file_and_line (file, line, s, ap);
1688 va_end (ap);
1691 /* Apologize for not implementing some feature. */
1693 static void
1694 vsorry (s, ap)
1695 char *s;
1696 va_list ap;
1698 sorrycount++;
1699 if (input_filename)
1700 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1701 else
1702 fprintf (stderr, "%s: ", progname);
1703 vmessage ("sorry, not implemented", s, ap);
1704 fputc ('\n', stderr);
1707 void
1708 sorry VPROTO((char *s, ...))
1710 #ifndef __STDC__
1711 char *s;
1712 #endif
1713 va_list ap;
1715 VA_START (ap, s);
1717 #ifndef __STDC__
1718 s = va_arg (ap, char *);
1719 #endif
1721 vsorry (s, ap);
1722 va_end (ap);
1725 /* Apologize for not implementing some feature, then quit. */
1727 static void
1728 v_really_sorry (s, ap)
1729 char *s;
1730 va_list ap;
1732 sorrycount++;
1733 if (input_filename)
1734 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1735 else
1736 fprintf (stderr, "%s: ", progname);
1737 vmessage ("sorry, not implemented", s, ap);
1738 fatal (" (fatal)\n");
1741 void
1742 really_sorry VPROTO((char *s, ...))
1744 #ifndef __STDC__
1745 char *s;
1746 #endif
1747 va_list ap;
1749 VA_START (ap, s);
1751 #ifndef __STDC__
1752 s = va_arg (ap, char *);
1753 #endif
1755 v_really_sorry (s, ap);
1756 va_end (ap);
1759 /* More 'friendly' abort that prints the line and file.
1760 config.h can #define abort fancy_abort if you like that sort of thing.
1762 I don't think this is actually a good idea.
1763 Other sorts of crashes will look a certain way.
1764 It is a good thing if crashes from calling abort look the same way.
1765 -- RMS */
1767 void
1768 fancy_abort ()
1770 fatal ("internal gcc abort");
1773 /* This calls abort and is used to avoid problems when abort if a macro.
1774 It is used when we need to pass the address of abort. */
1776 void
1777 do_abort ()
1779 abort ();
1782 /* When `malloc.c' is compiled with `rcheck' defined,
1783 it calls this function to report clobberage. */
1785 void
1786 botch (s)
1788 abort ();
1791 /* Same as `malloc' but report error if no memory available. */
1793 char *
1794 xmalloc (size)
1795 unsigned size;
1797 register char *value = (char *) malloc (size);
1798 if (value == 0)
1799 fatal ("virtual memory exhausted");
1800 return value;
1803 /* Same as `realloc' but report error if no memory available. */
1805 char *
1806 xrealloc (ptr, size)
1807 char *ptr;
1808 int size;
1810 char *result = (char *) realloc (ptr, size);
1811 if (!result)
1812 fatal ("virtual memory exhausted");
1813 return result;
1816 /* Same as `strdup' but report error if no memory available. */
1818 char *
1819 xstrdup (s)
1820 register char *s;
1822 register char *result = (char *) malloc (strlen (s) + 1);
1824 if (! result)
1825 fatal ("virtual memory exhausted");
1826 strcpy (result, s);
1827 return result;
1830 /* Return the logarithm of X, base 2, considering X unsigned,
1831 if X is a power of 2. Otherwise, returns -1.
1833 This should be used via the `exact_log2' macro. */
1836 exact_log2_wide (x)
1837 register unsigned HOST_WIDE_INT x;
1839 register int log = 0;
1840 /* Test for 0 or a power of 2. */
1841 if (x == 0 || x != (x & -x))
1842 return -1;
1843 while ((x >>= 1) != 0)
1844 log++;
1845 return log;
1848 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1849 If X is 0, return -1.
1851 This should be used via the floor_log2 macro. */
1854 floor_log2_wide (x)
1855 register unsigned HOST_WIDE_INT x;
1857 register int log = -1;
1858 while (x != 0)
1859 log++,
1860 x >>= 1;
1861 return log;
1864 int float_handled;
1865 jmp_buf float_handler;
1867 /* Specify where to longjmp to when a floating arithmetic error happens.
1868 If HANDLER is 0, it means don't handle the errors any more. */
1870 void
1871 set_float_handler (handler)
1872 jmp_buf handler;
1874 float_handled = (handler != 0);
1875 if (handler)
1876 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1879 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1880 error happens, pushing the previous specification into OLD_HANDLER.
1881 Return an indication of whether there was a previous handler in effect. */
1884 push_float_handler (handler, old_handler)
1885 jmp_buf handler, old_handler;
1887 int was_handled = float_handled;
1889 float_handled = 1;
1890 if (was_handled)
1891 bcopy ((char *) float_handler, (char *) old_handler,
1892 sizeof (float_handler));
1894 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1895 return was_handled;
1898 /* Restore the previous specification of whether and where to longjmp to
1899 when a floating arithmetic error happens. */
1901 void
1902 pop_float_handler (handled, handler)
1903 int handled;
1904 jmp_buf handler;
1906 float_handled = handled;
1907 if (handled)
1908 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1911 /* Signals actually come here. */
1913 static void
1914 float_signal (signo)
1915 /* If this is missing, some compilers complain. */
1916 int signo;
1918 if (float_handled == 0)
1919 abort ();
1920 #if defined (USG) || defined (hpux)
1921 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1922 #endif
1923 float_handled = 0;
1924 signal (SIGFPE, float_signal);
1925 longjmp (float_handler, 1);
1928 /* Handler for SIGPIPE. */
1930 static void
1931 pipe_closed (signo)
1932 /* If this is missing, some compilers complain. */
1933 int signo;
1935 fatal ("output pipe has been closed");
1938 /* Strip off a legitimate source ending from the input string NAME of
1939 length LEN. Rather than having to know the names used by all of
1940 our front ends, we strip off an ending of a period followed by one,
1941 two, or three characters. */
1943 void
1944 strip_off_ending (name, len)
1945 char *name;
1946 int len;
1948 if (len > 2 && name[len - 2] == '.')
1949 name[len - 2] = '\0';
1950 else if (len > 3 && name[len - 3] == '.')
1951 name[len - 3] = '\0';
1952 else if (len > 4 && name[len - 4] == '.')
1953 name[len - 4] = '\0';
1956 /* Output a quoted string. */
1958 void
1959 output_quoted_string (asm_file, string)
1960 FILE *asm_file;
1961 char *string;
1963 char c;
1965 putc ('\"', asm_file);
1966 while ((c = *string++) != 0)
1968 if (c == '\"' || c == '\\')
1969 putc ('\\', asm_file);
1970 putc (c, asm_file);
1972 putc ('\"', asm_file);
1975 /* Output a file name in the form wanted by System V. */
1977 void
1978 output_file_directive (asm_file, input_name)
1979 FILE *asm_file;
1980 char *input_name;
1982 int len = strlen (input_name);
1983 char *na = input_name + len;
1985 /* NA gets INPUT_NAME sans directory names. */
1986 while (na > input_name)
1988 if (na[-1] == '/')
1989 break;
1990 na--;
1993 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1994 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1995 #else
1996 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1997 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1998 #else
1999 fprintf (asm_file, "\t.file\t");
2000 output_quoted_string (asm_file, na);
2001 fputc ('\n', asm_file);
2002 #endif
2003 #endif
2006 /* Routine to build language identifier for object file. */
2008 static void
2009 output_lang_identify (asm_out_file)
2010 FILE *asm_out_file;
2012 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2013 char *s = (char *) alloca (len);
2014 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2015 ASM_OUTPUT_LABEL (asm_out_file, s);
2018 /* Routine to open a dump file. */
2020 static FILE *
2021 open_dump_file (base_name, suffix)
2022 char *base_name;
2023 char *suffix;
2025 FILE *f;
2026 char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1);
2028 strcpy (dumpname, base_name);
2029 strcat (dumpname, suffix);
2030 f = fopen (dumpname, "w");
2031 if (f == 0)
2032 pfatal_with_name (dumpname);
2033 return f;
2036 /* Compile an entire file of output from cpp, named NAME.
2037 Write a file of assembly output and various debugging dumps. */
2039 static void
2040 compile_file (name)
2041 char *name;
2043 tree globals;
2044 int start_time;
2046 int name_specified = name != 0;
2048 if (dump_base_name == 0)
2049 dump_base_name = name ? name : "gccdump";
2051 parse_time = 0;
2052 varconst_time = 0;
2053 integration_time = 0;
2054 jump_time = 0;
2055 cse_time = 0;
2056 loop_time = 0;
2057 cse2_time = 0;
2058 flow_time = 0;
2059 combine_time = 0;
2060 sched_time = 0;
2061 local_alloc_time = 0;
2062 global_alloc_time = 0;
2063 sched2_time = 0;
2064 dbr_sched_time = 0;
2065 shorten_branch_time = 0;
2066 stack_reg_time = 0;
2067 final_time = 0;
2068 symout_time = 0;
2069 dump_time = 0;
2071 /* Open input file. */
2073 if (name == 0 || !strcmp (name, "-"))
2075 finput = stdin;
2076 name = "stdin";
2078 else
2079 finput = fopen (name, "r");
2080 if (finput == 0)
2081 pfatal_with_name (name);
2083 #ifdef IO_BUFFER_SIZE
2084 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2085 #endif
2087 /* Initialize data in various passes. */
2089 init_obstacks ();
2090 init_tree_codes ();
2091 init_lex ();
2092 /* Some of these really don't need to be called when generating bytecode,
2093 but the options would have to be parsed first to know that. -bson */
2094 init_rtl ();
2095 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2096 || debug_info_level == DINFO_LEVEL_VERBOSE);
2097 init_regs ();
2098 init_decl_processing ();
2099 init_optabs ();
2100 init_stmt ();
2101 init_expmed ();
2102 init_expr_once ();
2103 init_loop ();
2104 init_reload ();
2106 if (flag_caller_saves)
2107 init_caller_save ();
2109 /* If auxiliary info generation is desired, open the output file.
2110 This goes in the same directory as the source file--unlike
2111 all the other output files. */
2112 if (flag_gen_aux_info)
2114 aux_info_file = fopen (aux_info_file_name, "w");
2115 if (aux_info_file == 0)
2116 pfatal_with_name (aux_info_file_name);
2119 /* If rtl dump desired, open the output file. */
2120 if (rtl_dump)
2121 rtl_dump_file = open_dump_file (dump_base_name, ".rtl");
2123 /* If jump_opt dump desired, open the output file. */
2124 if (jump_opt_dump)
2125 jump_opt_dump_file = open_dump_file (dump_base_name, ".jump");
2127 /* If cse dump desired, open the output file. */
2128 if (cse_dump)
2129 cse_dump_file = open_dump_file (dump_base_name, ".cse");
2131 /* If loop dump desired, open the output file. */
2132 if (loop_dump)
2133 loop_dump_file = open_dump_file (dump_base_name, ".loop");
2135 /* If cse2 dump desired, open the output file. */
2136 if (cse2_dump)
2137 cse2_dump_file = open_dump_file (dump_base_name, ".cse2");
2139 /* If flow dump desired, open the output file. */
2140 if (flow_dump)
2141 flow_dump_file = open_dump_file (dump_base_name, ".flow");
2143 /* If combine dump desired, open the output file. */
2144 if (combine_dump)
2145 combine_dump_file = open_dump_file (dump_base_name, ".combine");
2147 /* If scheduling dump desired, open the output file. */
2148 if (sched_dump)
2149 sched_dump_file = open_dump_file (dump_base_name, ".sched");
2151 /* If local_reg dump desired, open the output file. */
2152 if (local_reg_dump)
2153 local_reg_dump_file = open_dump_file (dump_base_name, ".lreg");
2155 /* If global_reg dump desired, open the output file. */
2156 if (global_reg_dump)
2157 global_reg_dump_file = open_dump_file (dump_base_name, ".greg");
2159 /* If 2nd scheduling dump desired, open the output file. */
2160 if (sched2_dump)
2161 sched2_dump_file = open_dump_file (dump_base_name, ".sched2");
2163 /* If jump2_opt dump desired, open the output file. */
2164 if (jump2_opt_dump)
2165 jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2");
2167 /* If dbr_sched dump desired, open the output file. */
2168 if (dbr_sched_dump)
2169 dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr");
2171 #ifdef STACK_REGS
2173 /* If stack_reg dump desired, open the output file. */
2174 if (stack_reg_dump)
2175 stack_reg_dump_file = open_dump_file (dump_base_name, ".stack");
2177 #endif
2179 /* Open assembler code output file. */
2181 if (! name_specified && asm_file_name == 0)
2182 asm_out_file = stdout;
2183 else
2185 int len = strlen (dump_base_name);
2186 register char *dumpname = (char *) xmalloc (len + 6);
2187 strcpy (dumpname, dump_base_name);
2188 strip_off_ending (dumpname, len);
2189 strcat (dumpname, ".s");
2190 if (asm_file_name == 0)
2192 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2193 strcpy (asm_file_name, dumpname);
2195 if (!strcmp (asm_file_name, "-"))
2196 asm_out_file = stdout;
2197 else
2198 asm_out_file = fopen (asm_file_name, "w");
2199 if (asm_out_file == 0)
2200 pfatal_with_name (asm_file_name);
2203 #ifdef IO_BUFFER_SIZE
2204 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2205 _IOFBF, IO_BUFFER_SIZE);
2206 #endif
2208 input_filename = name;
2210 /* Put an entry on the input file stack for the main input file. */
2211 input_file_stack
2212 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2213 input_file_stack->next = 0;
2214 input_file_stack->name = input_filename;
2216 /* Perform language-specific initialization.
2217 This may set main_input_filename. */
2218 lang_init ();
2220 /* If the input doesn't start with a #line, use the input name
2221 as the official input file name. */
2222 if (main_input_filename == 0)
2223 main_input_filename = name;
2225 if (!output_bytecode)
2227 ASM_FILE_START (asm_out_file);
2229 #ifdef ASM_COMMENT_START
2230 if (flag_verbose_asm)
2232 /* Print the list of options in effect. */
2233 print_version (asm_out_file, ASM_COMMENT_START);
2234 print_switch_values (asm_out_file, 0, MAX_LINE,
2235 ASM_COMMENT_START, " ", "\n");
2236 /* Add a blank line here so it appears in assembler output but not
2237 screen output. */
2238 fprintf (asm_out_file, "\n");
2240 #endif
2243 /* Output something to inform GDB that this compilation was by GCC. Also
2244 serves to tell GDB file consists of bytecodes. */
2245 if (output_bytecode)
2246 fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
2247 else
2249 #ifndef ASM_IDENTIFY_GCC
2250 fprintf (asm_out_file, "gcc2_compiled.:\n");
2251 #else
2252 ASM_IDENTIFY_GCC (asm_out_file);
2253 #endif
2256 /* Output something to identify which front-end produced this file. */
2257 #ifdef ASM_IDENTIFY_LANGUAGE
2258 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2259 #endif
2261 #ifndef ASM_OUTPUT_SECTION_NAME
2262 if (flag_function_sections)
2264 warning ("-ffunction-sections not supported for this target.");
2265 flag_function_sections = 0;
2267 #endif
2269 if (flag_function_sections
2270 && (profile_flag || profile_block_flag))
2272 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2273 flag_function_sections = 0;
2276 if (flag_function_sections && write_symbols != NO_DEBUG)
2277 warning ("-ffunction-sections may affect debugging on some targets.");
2279 if (output_bytecode)
2281 if (profile_flag || profile_block_flag)
2282 error ("profiling not supported in bytecode compilation");
2284 else
2286 /* ??? Note: There used to be a conditional here
2287 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2288 This was to guarantee separation between gcc_compiled. and
2289 the first function, for the sake of dbx on Suns.
2290 However, having the extra zero here confused the Emacs
2291 code for unexec, and might confuse other programs too.
2292 Therefore, I took out that change.
2293 In future versions we should find another way to solve
2294 that dbx problem. -- rms, 23 May 93. */
2296 /* Don't let the first function fall at the same address
2297 as gcc_compiled., if profiling. */
2298 if (profile_flag || profile_block_flag)
2299 assemble_zeros (UNITS_PER_WORD);
2302 /* If dbx symbol table desired, initialize writing it
2303 and output the predefined types. */
2304 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2305 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2306 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2307 getdecls ()));
2308 #endif
2309 #ifdef SDB_DEBUGGING_INFO
2310 if (write_symbols == SDB_DEBUG)
2311 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2312 getdecls ()));
2313 #endif
2314 #ifdef DWARF_DEBUGGING_INFO
2315 if (write_symbols == DWARF_DEBUG)
2316 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2317 #endif
2319 /* Initialize yet another pass. */
2321 if (!output_bytecode)
2322 init_final (main_input_filename);
2324 start_time = get_run_time ();
2326 /* Call the parser, which parses the entire file
2327 (calling rest_of_compilation for each function). */
2329 if (yyparse () != 0)
2331 if (errorcount == 0)
2332 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2334 /* In case there were missing closebraces,
2335 get us back to the global binding level. */
2336 while (! global_bindings_p ())
2337 poplevel (0, 0, 0);
2340 /* Compilation is now finished except for writing
2341 what's left of the symbol table output. */
2343 parse_time += get_run_time () - start_time;
2345 parse_time -= integration_time;
2346 parse_time -= varconst_time;
2348 globals = getdecls ();
2350 /* Really define vars that have had only a tentative definition.
2351 Really output inline functions that must actually be callable
2352 and have not been output so far. */
2355 int len = list_length (globals);
2356 tree *vec = (tree *) alloca (sizeof (tree) * len);
2357 int i;
2358 tree decl;
2359 int reconsider = 1;
2361 /* Process the decls in reverse order--earliest first.
2362 Put them into VEC from back to front, then take out from front. */
2364 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2365 vec[len - i - 1] = decl;
2367 for (i = 0; i < len; i++)
2369 decl = vec[i];
2371 /* We're not deferring this any longer. */
2372 DECL_DEFER_OUTPUT (decl) = 0;
2374 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2375 && incomplete_decl_finalize_hook != 0)
2376 (*incomplete_decl_finalize_hook) (decl);
2379 /* Now emit any global variables or functions that we have been putting
2380 off. We need to loop in case one of the things emitted here
2381 references another one which comes earlier in the list. */
2382 while (reconsider)
2384 reconsider = 0;
2385 for (i = 0; i < len; i++)
2387 decl = vec[i];
2389 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2390 continue;
2392 /* Don't write out static consts, unless we still need them.
2394 We also keep static consts if not optimizing (for debugging),
2395 unless the user specified -fno-keep-static-consts.
2396 ??? They might be better written into the debug information.
2397 This is possible when using DWARF.
2399 A language processor that wants static constants to be always
2400 written out (even if it is not used) is responsible for
2401 calling rest_of_decl_compilation itself. E.g. the C front-end
2402 calls rest_of_decl_compilation from finish_decl.
2403 One motivation for this is that is conventional in some
2404 environments to write things like:
2405 static const char rcsid[] = "... version string ...";
2406 intending to force the string to be in the executable.
2408 A language processor that would prefer to have unneeded
2409 static constants "optimized away" would just defer writing
2410 them out until here. E.g. C++ does this, because static
2411 constants are often defined in header files.
2413 ??? A tempting alternative (for both C and C++) would be
2414 to force a constant to be written if and only if it is
2415 defined in a main file, as opposed to an include file. */
2417 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2418 && (! TREE_READONLY (decl)
2419 || TREE_PUBLIC (decl)
2420 || (!optimize && flag_keep_static_consts)
2421 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2423 reconsider = 1;
2424 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2427 if (TREE_CODE (decl) == FUNCTION_DECL
2428 && DECL_INITIAL (decl) != 0
2429 && DECL_SAVED_INSNS (decl) != 0
2430 && (flag_keep_inline_functions
2431 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2433 reconsider = 1;
2434 temporary_allocation ();
2435 output_inline_function (decl);
2436 permanent_allocation (1);
2441 /* Now that all possible functions have been output, we can dump
2442 the exception table. */
2444 if (exception_table_p ())
2445 output_exception_table ();
2447 for (i = 0; i < len; i++)
2449 decl = vec[i];
2451 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2452 && ! TREE_ASM_WRITTEN (decl))
2453 /* Cancel the RTL for this decl so that, if debugging info
2454 output for global variables is still to come,
2455 this one will be omitted. */
2456 DECL_RTL (decl) = NULL;
2458 /* Warn about any function
2459 declared static but not defined.
2460 We don't warn about variables,
2461 because many programs have static variables
2462 that exist only to get some text into the object file. */
2463 if (TREE_CODE (decl) == FUNCTION_DECL
2464 && (warn_unused
2465 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2466 && DECL_INITIAL (decl) == 0
2467 && DECL_EXTERNAL (decl)
2468 && ! DECL_ARTIFICIAL (decl)
2469 && ! TREE_PUBLIC (decl))
2471 pedwarn_with_decl (decl,
2472 "`%s' declared `static' but never defined");
2473 /* This symbol is effectively an "extern" declaration now. */
2474 TREE_PUBLIC (decl) = 1;
2475 assemble_external (decl);
2478 /* Warn about static fns or vars defined but not used,
2479 but not about inline functions or static consts
2480 since defining those in header files is normal practice. */
2481 if (warn_unused
2482 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2483 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2484 && ! DECL_IN_SYSTEM_HEADER (decl)
2485 && ! DECL_EXTERNAL (decl)
2486 && ! TREE_PUBLIC (decl)
2487 && ! TREE_USED (decl)
2488 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2489 /* The TREE_USED bit for file-scope decls
2490 is kept in the identifier, to handle multiple
2491 external decls in different scopes. */
2492 && ! TREE_USED (DECL_NAME (decl)))
2493 warning_with_decl (decl, "`%s' defined but not used");
2495 #ifdef SDB_DEBUGGING_INFO
2496 /* The COFF linker can move initialized global vars to the end.
2497 And that can screw up the symbol ordering.
2498 By putting the symbols in that order to begin with,
2499 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2500 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2501 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2502 && ! DECL_EXTERNAL (decl)
2503 && DECL_RTL (decl) != 0)
2504 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2506 /* Output COFF information for non-global
2507 file-scope initialized variables. */
2508 if (write_symbols == SDB_DEBUG
2509 && TREE_CODE (decl) == VAR_DECL
2510 && DECL_INITIAL (decl)
2511 && ! DECL_EXTERNAL (decl)
2512 && DECL_RTL (decl) != 0
2513 && GET_CODE (DECL_RTL (decl)) == MEM)
2514 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2515 #endif /* SDB_DEBUGGING_INFO */
2516 #ifdef DWARF_DEBUGGING_INFO
2517 /* Output DWARF information for file-scope tentative data object
2518 declarations, file-scope (extern) function declarations (which
2519 had no corresponding body) and file-scope tagged type declarations
2520 and definitions which have not yet been forced out. */
2522 if (write_symbols == DWARF_DEBUG
2523 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2524 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2525 #endif
2529 /* Write out any pending weak symbol declarations. */
2531 weak_finish ();
2533 /* Do dbx symbols */
2534 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2535 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2536 TIMEVAR (symout_time,
2538 dbxout_finish (asm_out_file, main_input_filename);
2540 #endif
2542 #ifdef DWARF_DEBUGGING_INFO
2543 if (write_symbols == DWARF_DEBUG)
2544 TIMEVAR (symout_time,
2546 dwarfout_finish ();
2548 #endif
2550 /* Output some stuff at end of file if nec. */
2552 if (!output_bytecode)
2554 end_final (main_input_filename);
2556 #ifdef ASM_FILE_END
2557 ASM_FILE_END (asm_out_file);
2558 #endif
2561 /* Language-specific end of compilation actions. */
2563 lang_finish ();
2565 if (output_bytecode)
2566 bc_write_file (asm_out_file);
2568 /* Close the dump files. */
2570 if (flag_gen_aux_info)
2572 fclose (aux_info_file);
2573 if (errorcount)
2574 unlink (aux_info_file_name);
2577 if (rtl_dump)
2578 fclose (rtl_dump_file);
2580 if (jump_opt_dump)
2581 fclose (jump_opt_dump_file);
2583 if (cse_dump)
2584 fclose (cse_dump_file);
2586 if (loop_dump)
2587 fclose (loop_dump_file);
2589 if (cse2_dump)
2590 fclose (cse2_dump_file);
2592 if (flow_dump)
2593 fclose (flow_dump_file);
2595 if (combine_dump)
2597 dump_combine_total_stats (combine_dump_file);
2598 fclose (combine_dump_file);
2601 if (sched_dump)
2602 fclose (sched_dump_file);
2604 if (local_reg_dump)
2605 fclose (local_reg_dump_file);
2607 if (global_reg_dump)
2608 fclose (global_reg_dump_file);
2610 if (sched2_dump)
2611 fclose (sched2_dump_file);
2613 if (jump2_opt_dump)
2614 fclose (jump2_opt_dump_file);
2616 if (dbr_sched_dump)
2617 fclose (dbr_sched_dump_file);
2619 #ifdef STACK_REGS
2620 if (stack_reg_dump)
2621 fclose (stack_reg_dump_file);
2622 #endif
2624 /* Close non-debugging input and output files. Take special care to note
2625 whether fclose returns an error, since the pages might still be on the
2626 buffer chain while the file is open. */
2628 fclose (finput);
2629 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2630 fatal_io_error (asm_file_name);
2632 /* Print the times. */
2634 if (! quiet_flag)
2636 fprintf (stderr,"\n");
2637 print_time ("parse", parse_time);
2639 if (!output_bytecode)
2641 print_time ("integration", integration_time);
2642 print_time ("jump", jump_time);
2643 print_time ("cse", cse_time);
2644 print_time ("loop", loop_time);
2645 print_time ("cse2", cse2_time);
2646 print_time ("flow", flow_time);
2647 print_time ("combine", combine_time);
2648 print_time ("sched", sched_time);
2649 print_time ("local-alloc", local_alloc_time);
2650 print_time ("global-alloc", global_alloc_time);
2651 print_time ("sched2", sched2_time);
2652 print_time ("dbranch", dbr_sched_time);
2653 print_time ("shorten-branch", shorten_branch_time);
2654 print_time ("stack-reg", stack_reg_time);
2655 print_time ("final", final_time);
2656 print_time ("varconst", varconst_time);
2657 print_time ("symout", symout_time);
2658 print_time ("dump", dump_time);
2663 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2664 and TYPE_DECL nodes.
2666 This does nothing for local (non-static) variables.
2667 Otherwise, it sets up the RTL and outputs any assembler code
2668 (label definition, storage allocation and initialization).
2670 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2671 the assembler symbol name to be used. TOP_LEVEL is nonzero
2672 if this declaration is not within a function. */
2674 void
2675 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2676 tree decl;
2677 char *asmspec;
2678 int top_level;
2679 int at_end;
2681 /* Declarations of variables, and of functions defined elsewhere. */
2683 /* The most obvious approach, to put an #ifndef around where
2684 this macro is used, doesn't work since it's inside a macro call. */
2685 #ifndef ASM_FINISH_DECLARE_OBJECT
2686 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2687 #endif
2689 /* Forward declarations for nested functions are not "external",
2690 but we need to treat them as if they were. */
2691 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2692 || TREE_CODE (decl) == FUNCTION_DECL)
2693 TIMEVAR (varconst_time,
2695 make_decl_rtl (decl, asmspec, top_level);
2696 /* Initialized extern variable exists to be replaced
2697 with its value, or represents something that will be
2698 output in another file. */
2699 if (! (TREE_CODE (decl) == VAR_DECL
2700 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2701 && DECL_INITIAL (decl) != 0
2702 && DECL_INITIAL (decl) != error_mark_node))
2703 /* Don't output anything
2704 when a tentative file-scope definition is seen.
2705 But at end of compilation, do output code for them. */
2706 if (! (! at_end && top_level
2707 && (DECL_INITIAL (decl) == 0
2708 || DECL_INITIAL (decl) == error_mark_node)))
2709 assemble_variable (decl, top_level, at_end, 0);
2710 if (!output_bytecode
2711 && decl == last_assemble_variable_decl)
2713 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2714 top_level, at_end);
2717 else if (DECL_REGISTER (decl) && asmspec != 0)
2719 if (decode_reg_name (asmspec) >= 0)
2721 DECL_RTL (decl) = 0;
2722 make_decl_rtl (decl, asmspec, top_level);
2724 else
2725 error ("invalid register name `%s' for register variable", asmspec);
2727 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2728 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2729 && TREE_CODE (decl) == TYPE_DECL)
2730 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2731 #endif
2732 #ifdef SDB_DEBUGGING_INFO
2733 else if (write_symbols == SDB_DEBUG && top_level
2734 && TREE_CODE (decl) == TYPE_DECL)
2735 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2736 #endif
2739 /* Called after finishing a record, union or enumeral type. */
2741 void
2742 rest_of_type_compilation (type, toplev)
2743 tree type;
2744 int toplev;
2746 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2747 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2748 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2749 #endif
2750 #ifdef SDB_DEBUGGING_INFO
2751 if (write_symbols == SDB_DEBUG)
2752 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2753 #endif
2754 #ifdef DWARF_DEBUGGING_INFO
2755 /* If this is a file-scope type or a class-scope type
2756 for which the containing class has already been completed, write it
2757 out now to avoid ordering headaches with member functions. */
2758 if (write_symbols == DWARF_DEBUG
2759 && (TYPE_CONTEXT (type) == NULL_TREE
2760 || TREE_ASM_WRITTEN (TYPE_CONTEXT (type))))
2761 TIMEVAR (symout_time, dwarfout_file_scope_decl (TYPE_STUB_DECL (type), 0));
2762 #endif
2765 /* This is called from finish_function (within yyparse)
2766 after each top-level definition is parsed.
2767 It is supposed to compile that function or variable
2768 and output the assembler code for it.
2769 After we return, the tree storage is freed. */
2771 void
2772 rest_of_compilation (decl)
2773 tree decl;
2775 register rtx insns;
2776 int start_time = get_run_time ();
2777 int tem;
2778 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2779 to be restored after we finish compiling the function
2780 (for use when compiling inline calls to this function). */
2781 tree saved_block_tree = 0;
2782 /* Likewise, for DECL_ARGUMENTS. */
2783 tree saved_arguments = 0;
2784 int failure = 0;
2786 if (output_bytecode)
2787 return;
2789 /* If we are reconsidering an inline function
2790 at the end of compilation, skip the stuff for making it inline. */
2792 if (DECL_SAVED_INSNS (decl) == 0)
2794 int inlineable = 0;
2795 char *lose;
2797 /* If requested, consider whether to make this function inline. */
2798 if (DECL_INLINE (decl) || flag_inline_functions)
2799 TIMEVAR (integration_time,
2801 lose = function_cannot_inline_p (decl);
2802 if (lose || ! optimize)
2804 if (warn_inline && DECL_INLINE (decl))
2805 warning_with_decl (decl, lose);
2806 DECL_ABSTRACT_ORIGIN (decl) = 0;
2807 /* Don't really compile an extern inline function.
2808 If we can't make it inline, pretend
2809 it was only declared. */
2810 if (DECL_EXTERNAL (decl))
2812 DECL_INITIAL (decl) = 0;
2813 goto exit_rest_of_compilation;
2816 else
2817 /* ??? Note that this has the effect of making it look
2818 like "inline" was specified for a function if we choose
2819 to inline it. This isn't quite right, but it's
2820 probably not worth the trouble to fix. */
2821 inlineable = DECL_INLINE (decl) = 1;
2824 insns = get_insns ();
2826 /* Dump the rtl code if we are dumping rtl. */
2828 if (rtl_dump)
2829 TIMEVAR (dump_time,
2831 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2832 IDENTIFIER_POINTER (DECL_NAME (decl)));
2833 if (DECL_SAVED_INSNS (decl))
2834 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2835 print_rtl (rtl_dump_file, insns);
2836 fflush (rtl_dump_file);
2839 /* If function is inline, and we don't yet know whether to
2840 compile it by itself, defer decision till end of compilation.
2841 finish_compilation will call rest_of_compilation again
2842 for those functions that need to be output. Also defer those
2843 functions that we are supposed to defer. We cannot defer
2844 functions containing nested functions since the nested function
2845 data is in our non-saved obstack. */
2847 if (! current_function_contains_functions
2848 && (DECL_DEFER_OUTPUT (decl)
2849 || (DECL_INLINE (decl)
2850 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2851 && ! flag_keep_inline_functions)
2852 || DECL_EXTERNAL (decl)))))
2854 DECL_DEFER_OUTPUT (decl) = 1;
2856 /* If -Wreturn-type, we have to do a bit of compilation. */
2857 if (! warn_return_type)
2859 #ifdef DWARF_DEBUGGING_INFO
2860 /* Generate the DWARF info for the "abstract" instance
2861 of a function which we may later generate inlined and/or
2862 out-of-line instances of. */
2863 if (write_symbols == DWARF_DEBUG)
2865 set_decl_abstract_flags (decl, 1);
2866 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2867 set_decl_abstract_flags (decl, 0);
2869 #endif
2870 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2871 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
2872 goto exit_rest_of_compilation;
2876 /* If we have to compile the function now, save its rtl and subdecls
2877 so that its compilation will not affect what others get. */
2878 if (inlineable || DECL_DEFER_OUTPUT (decl))
2880 #ifdef DWARF_DEBUGGING_INFO
2881 /* Generate the DWARF info for the "abstract" instance of
2882 a function which we will generate an out-of-line instance
2883 of almost immediately (and which we may also later generate
2884 various inlined instances of). */
2885 if (write_symbols == DWARF_DEBUG)
2887 set_decl_abstract_flags (decl, 1);
2888 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2889 set_decl_abstract_flags (decl, 0);
2891 #endif
2892 saved_block_tree = DECL_INITIAL (decl);
2893 saved_arguments = DECL_ARGUMENTS (decl);
2894 TIMEVAR (integration_time, save_for_inline_copying (decl));
2895 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
2898 /* If specified extern inline but we aren't inlining it, we are
2899 done. */
2900 if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
2901 goto exit_rest_of_compilation;
2904 if (! DECL_DEFER_OUTPUT (decl))
2905 TREE_ASM_WRITTEN (decl) = 1;
2907 /* Now that integrate will no longer see our rtl, we need not distinguish
2908 between the return value of this function and the return value of called
2909 functions. */
2910 rtx_equal_function_value_matters = 0;
2912 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2913 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2915 goto exit_rest_of_compilation;
2918 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2919 Note that that may have been done above, in save_for_inline_copying.
2920 The call to resume_temporary_allocation near the end of this function
2921 goes back to the usual state of affairs. */
2923 rtl_in_current_obstack ();
2925 #ifdef FINALIZE_PIC
2926 /* If we are doing position-independent code generation, now
2927 is the time to output special prologues and epilogues.
2928 We do not want to do this earlier, because it just clutters
2929 up inline functions with meaningless insns. */
2930 if (flag_pic)
2931 FINALIZE_PIC;
2932 #endif
2934 /* Add an unwinder for exception handling, if needed. */
2935 emit_unwinder ();
2937 insns = get_insns ();
2939 /* Copy any shared structure that should not be shared. */
2941 unshare_all_rtl (insns);
2943 /* Instantiate all virtual registers. */
2945 instantiate_virtual_regs (current_function_decl, get_insns ());
2947 /* See if we have allocated stack slots that are not directly addressable.
2948 If so, scan all the insns and create explicit address computation
2949 for all references to such slots. */
2950 /* fixup_stack_slots (); */
2952 /* Find all the EH handlers. */
2953 find_exception_handler_labels ();
2955 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2956 are initialized and to compute whether control can drop off the end
2957 of the function. */
2958 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2959 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2961 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2962 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2963 goto exit_rest_of_compilation;
2965 /* Dump rtl code after jump, if we are doing that. */
2967 if (jump_opt_dump)
2968 TIMEVAR (dump_time,
2970 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2971 IDENTIFIER_POINTER (DECL_NAME (decl)));
2972 print_rtl (jump_opt_dump_file, insns);
2973 fflush (jump_opt_dump_file);
2976 /* Perform common subexpression elimination.
2977 Nonzero value from `cse_main' means that jumps were simplified
2978 and some code may now be unreachable, so do
2979 jump optimization again. */
2981 if (cse_dump)
2982 TIMEVAR (dump_time,
2984 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2985 IDENTIFIER_POINTER (DECL_NAME (decl)));
2988 if (optimize > 0)
2990 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2992 if (flag_thread_jumps)
2993 /* Hacks by tiemann & kenner. */
2994 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
2996 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2997 0, cse_dump_file));
2998 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
3000 if (tem || optimize > 1)
3001 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3004 /* Dump rtl code after cse, if we are doing that. */
3006 if (cse_dump)
3007 TIMEVAR (dump_time,
3009 print_rtl (cse_dump_file, insns);
3010 fflush (cse_dump_file);
3013 if (loop_dump)
3014 TIMEVAR (dump_time,
3016 fprintf (loop_dump_file, "\n;; Function %s\n\n",
3017 IDENTIFIER_POINTER (DECL_NAME (decl)));
3020 /* Move constant computations out of loops. */
3022 if (optimize > 0)
3024 TIMEVAR (loop_time,
3026 loop_optimize (insns, loop_dump_file);
3030 /* Dump rtl code after loop opt, if we are doing that. */
3032 if (loop_dump)
3033 TIMEVAR (dump_time,
3035 print_rtl (loop_dump_file, insns);
3036 fflush (loop_dump_file);
3039 if (cse2_dump)
3040 TIMEVAR (dump_time,
3042 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
3043 IDENTIFIER_POINTER (DECL_NAME (decl)));
3046 if (optimize > 0 && flag_rerun_cse_after_loop)
3048 /* Running another jump optimization pass before the second
3049 cse pass sometimes simplifies the RTL enough to allow
3050 the second CSE pass to do a better job. Jump_optimize can change
3051 max_reg_num so we must rerun reg_scan afterwards.
3052 ??? Rework to not call reg_scan so often. */
3053 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3054 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3056 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3057 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3058 1, cse2_dump_file));
3059 if (tem)
3060 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3063 if (optimize > 0 && flag_thread_jumps)
3064 /* This pass of jump threading straightens out code
3065 that was kinked by loop optimization. */
3066 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3068 /* Dump rtl code after cse, if we are doing that. */
3070 if (cse2_dump)
3071 TIMEVAR (dump_time,
3073 print_rtl (cse2_dump_file, insns);
3074 fflush (cse2_dump_file);
3077 /* We are no longer anticipating cse in this function, at least. */
3079 cse_not_expected = 1;
3081 /* Now we choose between stupid (pcc-like) register allocation
3082 (if we got the -noreg switch and not -opt)
3083 and smart register allocation. */
3085 if (optimize > 0) /* Stupid allocation probably won't work */
3086 obey_regdecls = 0; /* if optimizations being done. */
3088 regclass_init ();
3090 /* Print function header into flow dump now
3091 because doing the flow analysis makes some of the dump. */
3093 if (flow_dump)
3094 TIMEVAR (dump_time,
3096 fprintf (flow_dump_file, "\n;; Function %s\n\n",
3097 IDENTIFIER_POINTER (DECL_NAME (decl)));
3100 if (obey_regdecls)
3102 TIMEVAR (flow_time,
3104 regclass (insns, max_reg_num ());
3105 stupid_life_analysis (insns, max_reg_num (),
3106 flow_dump_file);
3109 else
3111 /* Do control and data flow analysis,
3112 and write some of the results to dump file. */
3114 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
3115 flow_dump_file));
3116 if (warn_uninitialized)
3118 uninitialized_vars_warning (DECL_INITIAL (decl));
3119 setjmp_args_warning ();
3123 /* Dump rtl after flow analysis. */
3125 if (flow_dump)
3126 TIMEVAR (dump_time,
3128 print_rtl (flow_dump_file, insns);
3129 fflush (flow_dump_file);
3132 /* If -opt, try combining insns through substitution. */
3134 if (optimize > 0)
3135 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3137 /* Dump rtl code after insn combination. */
3139 if (combine_dump)
3140 TIMEVAR (dump_time,
3142 fprintf (combine_dump_file, "\n;; Function %s\n\n",
3143 IDENTIFIER_POINTER (DECL_NAME (decl)));
3144 dump_combine_stats (combine_dump_file);
3145 print_rtl (combine_dump_file, insns);
3146 fflush (combine_dump_file);
3149 /* Print function header into sched dump now
3150 because doing the sched analysis makes some of the dump. */
3152 if (sched_dump)
3153 TIMEVAR (dump_time,
3155 fprintf (sched_dump_file, "\n;; Function %s\n\n",
3156 IDENTIFIER_POINTER (DECL_NAME (decl)));
3159 if (optimize > 0 && flag_schedule_insns)
3161 /* Do control and data sched analysis,
3162 and write some of the results to dump file. */
3164 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
3167 /* Dump rtl after instruction scheduling. */
3169 if (sched_dump)
3170 TIMEVAR (dump_time,
3172 print_rtl (sched_dump_file, insns);
3173 fflush (sched_dump_file);
3176 /* Unless we did stupid register allocation,
3177 allocate pseudo-regs that are used only within 1 basic block. */
3179 if (!obey_regdecls)
3180 TIMEVAR (local_alloc_time,
3182 regclass (insns, max_reg_num ());
3183 local_alloc ();
3186 /* Dump rtl code after allocating regs within basic blocks. */
3188 if (local_reg_dump)
3189 TIMEVAR (dump_time,
3191 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
3192 IDENTIFIER_POINTER (DECL_NAME (decl)));
3193 dump_flow_info (local_reg_dump_file);
3194 dump_local_alloc (local_reg_dump_file);
3195 print_rtl (local_reg_dump_file, insns);
3196 fflush (local_reg_dump_file);
3199 if (global_reg_dump)
3200 TIMEVAR (dump_time,
3201 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
3202 IDENTIFIER_POINTER (DECL_NAME (decl))));
3204 /* Save the last label number used so far, so reorg can tell
3205 when it's safe to kill spill regs. */
3206 max_label_num_after_reload = max_label_num ();
3208 /* Unless we did stupid register allocation,
3209 allocate remaining pseudo-regs, then do the reload pass
3210 fixing up any insns that are invalid. */
3212 TIMEVAR (global_alloc_time,
3214 if (!obey_regdecls)
3215 failure = global_alloc (global_reg_dump_file);
3216 else
3217 failure = reload (insns, 0, global_reg_dump_file);
3220 if (global_reg_dump)
3221 TIMEVAR (dump_time,
3223 dump_global_regs (global_reg_dump_file);
3224 print_rtl (global_reg_dump_file, insns);
3225 fflush (global_reg_dump_file);
3228 if (failure)
3229 goto exit_rest_of_compilation;
3231 reload_completed = 1;
3233 /* On some machines, the prologue and epilogue code, or parts thereof,
3234 can be represented as RTL. Doing so lets us schedule insns between
3235 it and the rest of the code and also allows delayed branch
3236 scheduling to operate in the epilogue. */
3238 thread_prologue_and_epilogue_insns (insns);
3240 if (optimize > 0 && flag_schedule_insns_after_reload)
3242 if (sched2_dump)
3243 TIMEVAR (dump_time,
3245 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
3246 IDENTIFIER_POINTER (DECL_NAME (decl)));
3249 /* Do control and data sched analysis again,
3250 and write some more of the results to dump file. */
3252 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
3254 /* Dump rtl after post-reorder instruction scheduling. */
3256 if (sched2_dump)
3257 TIMEVAR (dump_time,
3259 print_rtl (sched2_dump_file, insns);
3260 fflush (sched2_dump_file);
3264 #ifdef LEAF_REGISTERS
3265 leaf_function = 0;
3266 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3267 leaf_function = 1;
3268 #endif
3270 /* One more attempt to remove jumps to .+1
3271 left by dead-store-elimination.
3272 Also do cross-jumping this time
3273 and delete no-op move insns. */
3275 if (optimize > 0)
3277 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3280 /* Dump rtl code after jump, if we are doing that. */
3282 if (jump2_opt_dump)
3283 TIMEVAR (dump_time,
3285 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
3286 IDENTIFIER_POINTER (DECL_NAME (decl)));
3287 print_rtl (jump2_opt_dump_file, insns);
3288 fflush (jump2_opt_dump_file);
3291 /* If a machine dependent reorganization is needed, call it. */
3292 #ifdef MACHINE_DEPENDENT_REORG
3293 MACHINE_DEPENDENT_REORG (insns);
3294 #endif
3296 /* If a scheduling pass for delayed branches is to be done,
3297 call the scheduling code. */
3299 #ifdef DELAY_SLOTS
3300 if (optimize > 0 && flag_delayed_branch)
3302 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3303 if (dbr_sched_dump)
3305 TIMEVAR (dump_time,
3307 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
3308 IDENTIFIER_POINTER (DECL_NAME (decl)));
3309 print_rtl (dbr_sched_dump_file, insns);
3310 fflush (dbr_sched_dump_file);
3314 #endif
3316 /* Shorten branches. */
3317 TIMEVAR (shorten_branch_time,
3319 shorten_branches (get_insns ());
3322 #ifdef STACK_REGS
3323 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3324 if (stack_reg_dump)
3326 TIMEVAR (dump_time,
3328 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
3329 IDENTIFIER_POINTER (DECL_NAME (decl)));
3330 print_rtl (stack_reg_dump_file, insns);
3331 fflush (stack_reg_dump_file);
3334 #endif
3336 /* Now turn the rtl into assembler code. */
3338 TIMEVAR (final_time,
3340 rtx x;
3341 char *fnname;
3343 /* Get the function's name, as described by its RTL.
3344 This may be different from the DECL_NAME name used
3345 in the source file. */
3347 x = DECL_RTL (decl);
3348 if (GET_CODE (x) != MEM)
3349 abort ();
3350 x = XEXP (x, 0);
3351 if (GET_CODE (x) != SYMBOL_REF)
3352 abort ();
3353 fnname = XSTR (x, 0);
3355 assemble_start_function (decl, fnname);
3356 final_start_function (insns, asm_out_file, optimize);
3357 final (insns, asm_out_file, optimize, 0);
3358 final_end_function (insns, asm_out_file, optimize);
3359 assemble_end_function (decl, fnname);
3360 fflush (asm_out_file);
3363 /* Write DBX symbols if requested */
3365 /* Note that for those inline functions where we don't initially
3366 know for certain that we will be generating an out-of-line copy,
3367 the first invocation of this routine (rest_of_compilation) will
3368 skip over this code by doing a `goto exit_rest_of_compilation;'.
3369 Later on, finish_compilation will call rest_of_compilation again
3370 for those inline functions that need to have out-of-line copies
3371 generated. During that call, we *will* be routed past here. */
3373 #ifdef DBX_DEBUGGING_INFO
3374 if (write_symbols == DBX_DEBUG)
3375 TIMEVAR (symout_time, dbxout_function (decl));
3376 #endif
3378 #ifdef DWARF_DEBUGGING_INFO
3379 if (write_symbols == DWARF_DEBUG)
3380 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3381 #endif
3383 exit_rest_of_compilation:
3385 /* In case the function was not output,
3386 don't leave any temporary anonymous types
3387 queued up for sdb output. */
3388 #ifdef SDB_DEBUGGING_INFO
3389 if (write_symbols == SDB_DEBUG)
3390 sdbout_types (NULL_TREE);
3391 #endif
3393 /* Put back the tree of subblocks and list of arguments
3394 from before we copied them.
3395 Code generation and the output of debugging info may have modified
3396 the copy, but the original is unchanged. */
3398 if (saved_block_tree != 0)
3400 DECL_INITIAL (decl) = saved_block_tree;
3401 DECL_ARGUMENTS (decl) = saved_arguments;
3402 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3405 reload_completed = 0;
3407 /* Clear out the insn_length contents now that they are no longer valid. */
3408 init_insn_lengths ();
3410 /* Clear out the real_constant_chain before some of the rtx's
3411 it runs through become garbage. */
3413 clear_const_double_mem ();
3415 /* Cancel the effect of rtl_in_current_obstack. */
3417 resume_temporary_allocation ();
3419 /* Show no temporary slots allocated. */
3421 init_temp_slots ();
3423 /* The parsing time is all the time spent in yyparse
3424 *except* what is spent in this function. */
3426 parse_time -= get_run_time () - start_time;
3429 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3430 Exit code is 35 if can't open files, 34 if fatal error,
3431 33 if had nonfatal errors, else success. */
3434 main (argc, argv, envp)
3435 int argc;
3436 char **argv;
3437 char **envp;
3439 register int i;
3440 char *filename = 0;
3441 int flag_print_mem = 0;
3442 int version_flag = 0;
3443 char *p;
3445 /* save in case md file wants to emit args as a comment. */
3446 save_argc = argc;
3447 save_argv = argv;
3449 p = argv[0] + strlen (argv[0]);
3450 while (p != argv[0] && p[-1] != '/'
3451 #ifdef DIR_SEPARATOR
3452 && p[-1] != DIR_SEPARATOR
3453 #endif
3455 --p;
3456 progname = p;
3458 #ifdef RLIMIT_STACK
3459 /* Get rid of any avoidable limit on stack size. */
3461 struct rlimit rlim;
3463 /* Set the stack limit huge so that alloca does not fail. */
3464 getrlimit (RLIMIT_STACK, &rlim);
3465 rlim.rlim_cur = rlim.rlim_max;
3466 setrlimit (RLIMIT_STACK, &rlim);
3468 #endif /* RLIMIT_STACK */
3470 signal (SIGFPE, float_signal);
3472 #ifdef SIGPIPE
3473 signal (SIGPIPE, pipe_closed);
3474 #endif
3476 decl_printable_name = decl_name;
3477 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3479 /* Initialize whether `char' is signed. */
3480 flag_signed_char = DEFAULT_SIGNED_CHAR;
3481 #ifdef DEFAULT_SHORT_ENUMS
3482 /* Initialize how much space enums occupy, by default. */
3483 flag_short_enums = DEFAULT_SHORT_ENUMS;
3484 #endif
3486 /* Scan to see what optimization level has been specified. That will
3487 determine the default value of many flags. */
3488 for (i = 1; i < argc; i++)
3490 if (!strcmp (argv[i], "-O"))
3492 optimize = 1;
3494 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3496 /* Handle -O2, -O3, -O69, ... */
3497 char *p = &argv[i][2];
3498 int c;
3500 while (c = *p++)
3501 if (! (c >= '0' && c <= '9'))
3502 break;
3503 if (c == 0)
3504 optimize = atoi (&argv[i][2]);
3508 obey_regdecls = (optimize == 0);
3509 if (optimize == 0)
3511 flag_no_inline = 1;
3512 warn_inline = 0;
3515 if (optimize >= 1)
3517 flag_defer_pop = 1;
3518 flag_thread_jumps = 1;
3519 #ifdef DELAY_SLOTS
3520 flag_delayed_branch = 1;
3521 #endif
3522 #ifdef CAN_DEBUG_WITHOUT_FP
3523 flag_omit_frame_pointer = 1;
3524 #endif
3527 if (optimize >= 2)
3529 flag_cse_follow_jumps = 1;
3530 flag_cse_skip_blocks = 1;
3531 flag_expensive_optimizations = 1;
3532 flag_strength_reduce = 1;
3533 flag_rerun_cse_after_loop = 1;
3534 flag_caller_saves = 1;
3535 flag_force_mem = 1;
3536 #ifdef INSN_SCHEDULING
3537 flag_schedule_insns = 1;
3538 flag_schedule_insns_after_reload = 1;
3539 #endif
3542 if (optimize >= 3)
3544 flag_inline_functions = 1;
3547 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
3548 modify it. */
3549 target_flags = 0;
3550 set_target_switch ("");
3552 #ifdef OPTIMIZATION_OPTIONS
3553 /* Allow default optimizations to be specified on a per-machine basis. */
3554 OPTIMIZATION_OPTIONS (optimize);
3555 #endif
3557 /* Initialize register usage now so switches may override. */
3558 init_reg_sets ();
3560 for (i = 1; i < argc; i++)
3562 int j;
3563 /* If this is a language-specific option,
3564 decode it in a language-specific way. */
3565 for (j = 0; lang_options[j] != 0; j++)
3566 if (!strncmp (argv[i], lang_options[j],
3567 strlen (lang_options[j])))
3568 break;
3569 if (lang_options[j] != 0)
3570 /* If the option is valid for *some* language,
3571 treat it as valid even if this language doesn't understand it. */
3572 lang_decode_option (argv[i]);
3573 else if (argv[i][0] == '-' && argv[i][1] != 0)
3575 register char *str = argv[i] + 1;
3576 if (str[0] == 'Y')
3577 str++;
3579 if (str[0] == 'm')
3580 set_target_switch (&str[1]);
3581 else if (!strcmp (str, "dumpbase"))
3583 dump_base_name = argv[++i];
3585 else if (str[0] == 'd')
3587 register char *p = &str[1];
3588 while (*p)
3589 switch (*p++)
3591 case 'a':
3592 combine_dump = 1;
3593 dbr_sched_dump = 1;
3594 flow_dump = 1;
3595 global_reg_dump = 1;
3596 jump_opt_dump = 1;
3597 jump2_opt_dump = 1;
3598 local_reg_dump = 1;
3599 loop_dump = 1;
3600 rtl_dump = 1;
3601 cse_dump = 1, cse2_dump = 1;
3602 sched_dump = 1;
3603 sched2_dump = 1;
3604 stack_reg_dump = 1;
3605 break;
3606 case 'k':
3607 stack_reg_dump = 1;
3608 break;
3609 case 'c':
3610 combine_dump = 1;
3611 break;
3612 case 'd':
3613 dbr_sched_dump = 1;
3614 break;
3615 case 'f':
3616 flow_dump = 1;
3617 break;
3618 case 'g':
3619 global_reg_dump = 1;
3620 break;
3621 case 'j':
3622 jump_opt_dump = 1;
3623 break;
3624 case 'J':
3625 jump2_opt_dump = 1;
3626 break;
3627 case 'l':
3628 local_reg_dump = 1;
3629 break;
3630 case 'L':
3631 loop_dump = 1;
3632 break;
3633 case 'm':
3634 flag_print_mem = 1;
3635 break;
3636 case 'p':
3637 flag_print_asm_name = 1;
3638 break;
3639 case 'r':
3640 rtl_dump = 1;
3641 break;
3642 case 's':
3643 cse_dump = 1;
3644 break;
3645 case 't':
3646 cse2_dump = 1;
3647 break;
3648 case 'S':
3649 sched_dump = 1;
3650 break;
3651 case 'R':
3652 sched2_dump = 1;
3653 break;
3654 case 'y':
3655 set_yydebug (1);
3656 break;
3657 case 'x':
3658 rtl_dump_and_exit = 1;
3659 break;
3660 case 'A':
3661 flag_debug_asm = 1;
3662 break;
3665 else if (str[0] == 'f')
3667 register char *p = &str[1];
3668 int found = 0;
3670 /* Some kind of -f option.
3671 P's value is the option sans `-f'.
3672 Search for it in the table of options. */
3674 for (j = 0;
3675 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3676 j++)
3678 if (!strcmp (p, f_options[j].string))
3680 *f_options[j].variable = f_options[j].on_value;
3681 /* A goto here would be cleaner,
3682 but breaks the vax pcc. */
3683 found = 1;
3685 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3686 && ! strcmp (p+3, f_options[j].string))
3688 *f_options[j].variable = ! f_options[j].on_value;
3689 found = 1;
3693 if (found)
3695 else if (!strncmp (p, "fixed-", 6))
3696 fix_register (&p[6], 1, 1);
3697 else if (!strncmp (p, "call-used-", 10))
3698 fix_register (&p[10], 0, 1);
3699 else if (!strncmp (p, "call-saved-", 11))
3700 fix_register (&p[11], 0, 0);
3701 else
3702 error ("Invalid option `%s'", argv[i]);
3704 else if (str[0] == 'O')
3706 register char *p = str+1;
3707 while (*p && *p >= '0' && *p <= '9')
3708 p++;
3709 if (*p == '\0')
3711 else
3712 error ("Invalid option `%s'", argv[i]);
3714 else if (!strcmp (str, "pedantic"))
3715 pedantic = 1;
3716 else if (!strcmp (str, "pedantic-errors"))
3717 flag_pedantic_errors = pedantic = 1;
3718 else if (!strcmp (str, "quiet"))
3719 quiet_flag = 1;
3720 else if (!strcmp (str, "version"))
3721 version_flag = 1;
3722 else if (!strcmp (str, "w"))
3723 inhibit_warnings = 1;
3724 else if (!strcmp (str, "W"))
3726 extra_warnings = 1;
3727 /* We save the value of warn_uninitialized, since if they put
3728 -Wuninitialized on the command line, we need to generate a
3729 warning about not using it without also specifying -O. */
3730 if (warn_uninitialized != 1)
3731 warn_uninitialized = 2;
3733 else if (str[0] == 'W')
3735 register char *p = &str[1];
3736 int found = 0;
3738 /* Some kind of -W option.
3739 P's value is the option sans `-W'.
3740 Search for it in the table of options. */
3742 for (j = 0;
3743 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3744 j++)
3746 if (!strcmp (p, W_options[j].string))
3748 *W_options[j].variable = W_options[j].on_value;
3749 /* A goto here would be cleaner,
3750 but breaks the vax pcc. */
3751 found = 1;
3753 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3754 && ! strcmp (p+3, W_options[j].string))
3756 *W_options[j].variable = ! W_options[j].on_value;
3757 found = 1;
3761 if (found)
3763 else if (!strncmp (p, "id-clash-", 9))
3765 char *endp = p + 9;
3767 while (*endp)
3769 if (*endp >= '0' && *endp <= '9')
3770 endp++;
3771 else
3773 error ("Invalid option `%s'", argv[i]);
3774 goto id_clash_lose;
3777 warn_id_clash = 1;
3778 id_clash_len = atoi (str + 10);
3779 id_clash_lose: ;
3781 else if (!strncmp (p, "larger-than-", 12))
3783 char *endp = p + 12;
3785 while (*endp)
3787 if (*endp >= '0' && *endp <= '9')
3788 endp++;
3789 else
3791 error ("Invalid option `%s'", argv[i]);
3792 goto larger_than_lose;
3795 warn_larger_than = 1;
3796 larger_than_size = atoi (str + 13);
3797 larger_than_lose: ;
3799 else
3800 error ("Invalid option `%s'", argv[i]);
3802 else if (!strcmp (str, "p"))
3804 profile_flag = 1;
3806 else if (!strcmp (str, "a"))
3808 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3809 warning ("`-a' option (basic block profile) not supported");
3810 #else
3811 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
3812 #endif
3814 else if (!strcmp (str, "ax"))
3816 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3817 warning ("`-ax' option (jump profiling) not supported");
3818 #else
3819 profile_block_flag = (!profile_block_flag
3820 || profile_block_flag == 2) ? 2 : 3;
3821 #endif
3823 else if (str[0] == 'g')
3825 char *p = str + 1;
3826 char *q;
3827 unsigned len;
3828 unsigned level;
3829 /* A lot of code assumes write_symbols == NO_DEBUG if the
3830 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
3831 of what debugging type has been selected). This records the
3832 selected type. It is an error to specify more than one
3833 debugging type. */
3834 static enum debug_info_type selected_debug_type = NO_DEBUG;
3835 /* Non-zero if debugging format has been explicitly set.
3836 -g and -ggdb don't explicitly set the debugging format so
3837 -gdwarf -g3 is equivalent to -gdwarf3. */
3838 static int type_explicitly_set_p = 0;
3839 /* Table of supported debugging formats. */
3840 static struct {
3841 char *arg;
3842 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
3843 constant expression, we use NO_DEBUG in its place. */
3844 enum debug_info_type debug_type;
3845 int use_extensions_p;
3846 } *da, debug_args[] = {
3847 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS },
3848 { "ggdb", NO_DEBUG, 1 },
3849 #ifdef DBX_DEBUGGING_INFO
3850 { "gstabs", DBX_DEBUG, 0 },
3851 { "gstabs+", DBX_DEBUG, 1 },
3852 #endif
3853 #ifdef DWARF_DEBUGGING_INFO
3854 { "gdwarf", DWARF_DEBUG, 0 },
3855 { "gdwarf+", DWARF_DEBUG, 1 },
3856 #endif
3857 #ifdef XCOFF_DEBUGGING_INFO
3858 { "gxcoff", XCOFF_DEBUG, 0 },
3859 { "gxcoff+", XCOFF_DEBUG, 1 },
3860 #endif
3861 #ifdef SDB_DEBUGGING_INFO
3862 { "gcoff", SDB_DEBUG, 0 },
3863 #endif
3864 { 0, 0, 0 }
3866 /* Indexed by enum debug_info_type. */
3867 static char *debug_type_names[] = {
3868 "none", "stabs", "coff", "dwarf", "xcoff"
3871 while (*p && (*p < '0' || *p > '9'))
3872 p++;
3873 len = p - str;
3874 q = p;
3875 while (*q && (*q >= '0' && *q <= '9'))
3876 q++;
3877 if (*p)
3878 level = atoi (p);
3879 else
3880 level = 2; /* default debugging info level */
3881 if (*q || level > 3)
3883 warning ("invalid debug level specification in option: `-%s'",
3884 str);
3885 /* ??? This error message is incorrect in the case of
3886 -g4 -g. */
3887 warning ("no debugging information will be generated");
3888 level = 0;
3891 /* Look up STR in the table. */
3892 for (da = debug_args; da->arg; da++)
3894 if (! strncmp (str, da->arg, len))
3896 enum debug_info_type type = da->debug_type;
3897 /* ??? A few targets use STR and LEN in the
3898 definition of PREFERRED_DEBUGGING_TYPE! */
3899 if (type == NO_DEBUG)
3900 type = PREFERRED_DEBUGGING_TYPE;
3902 /* Does it conflict with an already selected type? */
3903 if (type_explicitly_set_p
3904 /* -g/-ggdb don't conflict with anything */
3905 && da->debug_type != NO_DEBUG
3906 && type != selected_debug_type)
3907 warning ("`-%s' ignored, conflicts with `-g%s'",
3908 str, debug_type_names[(int) selected_debug_type]);
3909 else
3911 /* If the format has already been set, -g/-ggdb
3912 only change the debug level. */
3913 if (type_explicitly_set_p
3914 && da->debug_type == NO_DEBUG)
3915 ; /* don't change debugging type */
3916 else
3918 selected_debug_type = type;
3919 type_explicitly_set_p = da->debug_type != NO_DEBUG;
3921 write_symbols = (level == 0
3922 ? NO_DEBUG
3923 : selected_debug_type);
3924 use_gnu_debug_info_extensions = da->use_extensions_p;
3925 debug_info_level = (enum debug_info_level) level;
3927 break;
3930 if (! da->arg)
3931 warning ("`-%s' not supported by this configuration of GCC",
3932 str);
3934 else if (!strcmp (str, "o"))
3936 asm_file_name = argv[++i];
3938 else if (str[0] == 'G')
3940 g_switch_set = TRUE;
3941 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3943 else if (!strncmp (str, "aux-info", 8))
3945 flag_gen_aux_info = 1;
3946 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3948 else
3949 error ("Invalid option `%s'", argv[i]);
3951 else if (argv[i][0] == '+')
3952 error ("Invalid option `%s'", argv[i]);
3953 else
3954 filename = argv[i];
3957 /* Initialize for bytecode output. A good idea to do this as soon as
3958 possible after the "-f" options have been parsed. */
3959 if (output_bytecode)
3961 #ifndef TARGET_SUPPORTS_BYTECODE
3962 /* Just die with a fatal error if not supported */
3963 fatal ("-fbytecode not supported for this target");
3964 #else
3965 bc_initialize ();
3966 #endif
3969 if (optimize == 0)
3971 /* Inlining does not work if not optimizing,
3972 so force it not to be done. */
3973 flag_no_inline = 1;
3974 warn_inline = 0;
3976 /* The c_decode_option and lang_decode_option functions set
3977 this to `2' if -Wall is used, so we can avoid giving out
3978 lots of errors for people who don't realize what -Wall does. */
3979 if (warn_uninitialized == 1)
3980 warning ("-Wuninitialized is not supported without -O");
3983 #ifdef OVERRIDE_OPTIONS
3984 /* Some machines may reject certain combinations of options. */
3985 OVERRIDE_OPTIONS;
3986 #endif
3988 if (profile_block_flag == 3)
3990 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
3991 profile_block_flag = 2;
3994 /* Unrolling all loops implies that standard loop unrolling must also
3995 be done. */
3996 if (flag_unroll_all_loops)
3997 flag_unroll_loops = 1;
3998 /* Loop unrolling requires that strength_reduction be on also. Silently
3999 turn on strength reduction here if it isn't already on. Also, the loop
4000 unrolling code assumes that cse will be run after loop, so that must
4001 be turned on also. */
4002 if (flag_unroll_loops)
4004 flag_strength_reduce = 1;
4005 flag_rerun_cse_after_loop = 1;
4008 /* Warn about options that are not supported on this machine. */
4009 #ifndef INSN_SCHEDULING
4010 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4011 warning ("instruction scheduling not supported on this target machine");
4012 #endif
4013 #ifndef DELAY_SLOTS
4014 if (flag_delayed_branch)
4015 warning ("this target machine does not have delayed branches");
4016 #endif
4018 /* If we are in verbose mode, write out the version and maybe all the
4019 option flags in use. */
4020 if (version_flag)
4022 print_version (stderr, "");
4023 if (! quiet_flag)
4024 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4027 compile_file (filename);
4029 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4030 if (flag_print_mem)
4032 char *lim = (char *) sbrk (0);
4034 fprintf (stderr, "Data size %d.\n",
4035 lim - (char *) &environ);
4036 fflush (stderr);
4038 #ifdef USG
4039 system ("ps -l 1>&2");
4040 #else /* not USG */
4041 system ("ps v");
4042 #endif /* not USG */
4044 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4046 if (errorcount)
4047 exit (FATAL_EXIT_CODE);
4048 if (sorrycount)
4049 exit (FATAL_EXIT_CODE);
4050 exit (SUCCESS_EXIT_CODE);
4051 return 0;
4054 /* Decode -m switches. */
4056 /* Here is a table, controlled by the tm.h file, listing each -m switch
4057 and which bits in `target_switches' it should set or clear.
4058 If VALUE is positive, it is bits to set.
4059 If VALUE is negative, -VALUE is bits to clear.
4060 (The sign bit is not used so there is no confusion.) */
4062 struct {char *name; int value;} target_switches []
4063 = TARGET_SWITCHES;
4065 /* This table is similar, but allows the switch to have a value. */
4067 #ifdef TARGET_OPTIONS
4068 struct {char *prefix; char ** variable;} target_options []
4069 = TARGET_OPTIONS;
4070 #endif
4072 /* Decode the switch -mNAME. */
4074 void
4075 set_target_switch (name)
4076 char *name;
4078 register int j;
4079 int valid = 0;
4081 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4082 if (!strcmp (target_switches[j].name, name))
4084 if (target_switches[j].value < 0)
4085 target_flags &= ~-target_switches[j].value;
4086 else
4087 target_flags |= target_switches[j].value;
4088 valid = 1;
4091 #ifdef TARGET_OPTIONS
4092 if (!valid)
4093 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4095 int len = strlen (target_options[j].prefix);
4096 if (!strncmp (target_options[j].prefix, name, len))
4098 *target_options[j].variable = name + len;
4099 valid = 1;
4102 #endif
4104 if (!valid)
4105 error ("Invalid option `%s'", name);
4108 /* Print version information to FILE.
4109 Each line begins with INDENT (for the case where FILE is the
4110 assembler output file). */
4112 void
4113 print_version (file, indent)
4114 FILE *file;
4115 char *indent;
4117 fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4118 language_string, version_string);
4119 fprintf (file, " (%s)", TARGET_NAME);
4120 #ifdef __GNUC__
4121 #ifndef __VERSION__
4122 #define __VERSION__ "[unknown]"
4123 #endif
4124 fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4125 #else
4126 fprintf (file, " compiled by CC.\n");
4127 #endif
4130 /* Print an option value and return the adjusted position in the line.
4131 ??? We don't handle error returns from fprintf (disk full); presumably
4132 other code will catch a disk full though. */
4135 print_single_switch (file, pos, max, indent, sep, term, type, name)
4136 FILE *file;
4137 int pos, max;
4138 char *indent, *sep, *term, *type, *name;
4140 /* The ultrix fprintf returns 0 on success, so compute the result we want
4141 here since we need it for the following test. */
4142 int len = strlen (sep) + strlen (type) + strlen (name);
4144 if (pos != 0
4145 && pos + len > max)
4147 fprintf (file, "%s", term);
4148 pos = 0;
4150 if (pos == 0)
4152 fprintf (file, "%s", indent);
4153 pos = strlen (indent);
4155 fprintf (file, "%s%s%s", sep, type, name);
4156 pos += len;
4157 return pos;
4160 /* Print active target switches to FILE.
4161 POS is the current cursor position and MAX is the size of a "line".
4162 Each line begins with INDENT and ends with TERM.
4163 Each switch is separated from the next by SEP. */
4165 void
4166 print_switch_values (file, pos, max, indent, sep, term)
4167 FILE *file;
4168 int pos, max;
4169 char *indent, *sep, *term;
4171 int j, flags;
4172 char **p;
4174 /* Print the options as passed. */
4176 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4177 "options passed: ", "");
4179 for (p = &save_argv[1]; *p != NULL; p++)
4180 if (**p == '-')
4182 /* Ignore these. */
4183 if (strcmp (*p, "-o") == 0)
4185 if (p[1] != NULL)
4186 p++;
4187 continue;
4189 if (strcmp (*p, "-quiet") == 0)
4190 continue;
4191 if (strcmp (*p, "-version") == 0)
4192 continue;
4193 if ((*p)[1] == 'd')
4194 continue;
4196 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4198 if (pos > 0)
4199 fprintf (file, "%s", term);
4201 /* Print the -f and -m options that have been enabled.
4202 We don't handle language specific options but printing argv
4203 should suffice. */
4205 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4206 "options enabled: ", "");
4208 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4209 if (*f_options[j].variable == f_options[j].on_value)
4210 pos = print_single_switch (file, pos, max, indent, sep, term,
4211 "-f", f_options[j].string);
4213 /* Print target specific options. */
4215 flags = target_flags;
4216 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4217 if (target_switches[j].name[0] != '\0'
4218 && target_switches[j].value > 0
4219 && ((target_switches[j].value & target_flags)
4220 == target_switches[j].value))
4222 pos = print_single_switch (file, pos, max, indent, sep, term,
4223 "-m", target_switches[j].name);
4224 flags &= ~ target_switches[j].value;
4227 #ifdef TARGET_OPTIONS
4228 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4229 if (*target_options[j].variable != NULL)
4231 char prefix[256];
4232 sprintf (prefix, "-m%s", target_options[j].prefix);
4233 pos = print_single_switch (file, pos, max, indent, sep, term,
4234 prefix, *target_options[j].variable);
4236 #endif
4238 fprintf (file, "%s", term);