(expand_value_return): Make function static.
[official-gcc.git] / gcc / toplev.c
blob0316d5a209dd52df267460ff449a62fbf91c8575
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92, 93, 94, 1995 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* THESE ARE FOR FORTRAN. */
21 "-fversion",
22 "-ff90",
23 "-fno-f90",
24 "-fautomatic",
25 "-fno-automatic",
26 "-fdollar-ok",
27 "-fno-dollar-ok",
28 "-ff2c",
29 "-fno-f2c",
30 "-ff2c-library",
31 "-fno-f2c-library",
32 "-ffree-form",
33 "-fno-free-form",
34 "-ffixed-form",
35 "-fno-fixed-form",
36 "-fpedantic",
37 "-fno-pedantic",
38 "-fvxt-not-f90",
39 "-ff90-not-vxt",
40 "-fugly",
41 "-fno-ugly",
42 "-fdebug",
43 "-fno-debug",
44 "-fintrin-case-initcap",
45 "-fintrin-case-upper",
46 "-fintrin-case-lower",
47 "-fintrin-case-any",
48 "-fmatch-case-initcap",
49 "-fmatch-case-upper",
50 "-fmatch-case-lower",
51 "-fmatch-case-any",
52 "-fsource-case-upper",
53 "-fsource-case-upper",
54 "-fsource-case-lower",
55 "-fsource-case-preserve",
56 "-fsymbol-case-initcap",
57 "-fsymbol-case-upper",
58 "-fsymbol-case-lower",
59 "-fsymbol-case-any",
60 "-fcase-strict-upper",
61 "-fcase-strict-lower",
62 "-fcase-initcap",
63 "-fcase-upper",
64 "-fcase-lower",
65 "-fcase-preserve",
66 "-fdcp-intrinsics-delete",
67 "-fdcp-intrinsics-hide",
68 "-fdcp-intrinsics-disable",
69 "-fdcp-intrinsics-enable",
70 "-ff2c-intrinsics-delete",
71 "-ff2c-intrinsics-hide",
72 "-ff2c-intrinsics-disable",
73 "-ff2c-intrinsics-enable",
74 "-ff90-intrinsics-delete",
75 "-ff90-intrinsics-hide",
76 "-ff90-intrinsics-disable",
77 "-ff90-intrinsics-enable",
78 "-fmil-intrinsics-delete",
79 "-fmil-intrinsics-hide",
80 "-fmil-intrinsics-disable",
81 "-fmil-intrinsics-enable",
82 "-fvxt-intrinsics-delete",
83 "-fvxt-intrinsics-hide",
84 "-fvxt-intrinsics-disable",
85 "-fvxt-intrinsics-enable",
88 /* This is the top level of cc1/c++.
89 It parses command args, opens files, invokes the various passes
90 in the proper order, and counts the time used by each.
91 Error messages and low-level interface to malloc also handled here. */
93 #include "config.h"
94 #ifdef __STDC__
95 #include <stdarg.h>
96 #else
97 #include <varargs.h>
98 #endif
99 #include <stdio.h>
100 #include <signal.h>
101 #include <setjmp.h>
102 #include <sys/types.h>
103 #include <ctype.h>
104 #include <sys/stat.h>
106 #ifndef WINNT
107 #ifdef USG
108 #undef FLOAT
109 #include <sys/param.h>
110 /* This is for hpux. It is a real screw. They should change hpux. */
111 #undef FLOAT
112 #include <sys/times.h>
113 #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
114 #undef FFS /* Some systems define this in param.h. */
115 #else
116 #ifndef VMS
117 #include <sys/time.h>
118 #include <sys/resource.h>
119 #endif
120 #endif
121 #endif
123 #include "input.h"
124 #include "tree.h"
125 #include "rtl.h"
126 #include "flags.h"
127 #include "insn-attr.h"
128 #include "defaults.h"
129 #include "output.h"
130 #include "bytecode.h"
131 #include "bc-emit.h"
133 #ifdef XCOFF_DEBUGGING_INFO
134 #include "xcoffout.h"
135 #endif
137 #ifdef VMS
138 /* The extra parameters substantially improve the I/O performance. */
139 static FILE *
140 vms_fopen (fname, type)
141 char * fname;
142 char * type;
144 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
145 fixed arguments, which matches ANSI's specification but not VAXCRTL's
146 pre-ANSI implementation. This hack circumvents the mismatch problem. */
147 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
149 if (*type == 'w')
150 return (*vmslib_fopen) (fname, type, "mbc=32",
151 "deq=64", "fop=tef", "shr=nil");
152 else
153 return (*vmslib_fopen) (fname, type, "mbc=32");
155 #define fopen vms_fopen
156 #endif /* VMS */
158 #ifndef DEFAULT_GDB_EXTENSIONS
159 #define DEFAULT_GDB_EXTENSIONS 1
160 #endif
162 extern int rtx_equal_function_value_matters;
164 #if ! (defined (VMS) || defined (OS2))
165 extern char **environ;
166 #endif
167 extern char *version_string, *language_string;
169 /* Carry information from ASM_DECLARE_OBJECT_NAME
170 to ASM_FINISH_DECLARE_OBJECT. */
172 extern int size_directive_output;
173 extern tree last_assemble_variable_decl;
175 extern void init_lex ();
176 extern void init_decl_processing ();
177 extern void init_obstacks ();
178 extern void init_tree_codes ();
179 extern void init_rtl ();
180 extern void init_regs ();
181 extern void init_optabs ();
182 extern void init_stmt ();
183 extern void init_reg_sets ();
184 extern void dump_flow_info ();
185 extern void dump_sched_info ();
186 extern void dump_local_alloc ();
188 void rest_of_decl_compilation ();
189 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
190 void error_with_decl PVPROTO((tree decl, char *s, ...));
191 void error_for_asm PVPROTO((rtx insn, char *s, ...));
192 void error PVPROTO((char *s, ...));
193 void fatal PVPROTO((char *s, ...));
194 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
195 void warning_with_decl PVPROTO((tree decl, char *s, ...));
196 void warning_for_asm PVPROTO((rtx insn, char *s, ...));
197 void warning PVPROTO((char *s, ...));
198 void pedwarn PVPROTO((char *s, ...));
199 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
200 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
201 void sorry PVPROTO((char *s, ...));
202 void really_sorry PVPROTO((char *s, ...));
203 void fancy_abort ();
204 #ifndef abort
205 void abort ();
206 #endif
207 void set_target_switch ();
208 static void print_switch_values ();
209 static char *decl_name ();
211 /* Name of program invoked, sans directories. */
213 char *progname;
215 /* Copy of arguments to main. */
216 int save_argc;
217 char **save_argv;
219 /* Name of current original source file (what was input to cpp).
220 This comes from each #-command in the actual input. */
222 char *input_filename;
224 /* Name of top-level original source file (what was input to cpp).
225 This comes from the #-command at the beginning of the actual input.
226 If there isn't any there, then this is the cc1 input file name. */
228 char *main_input_filename;
230 /* Stream for reading from the input file. */
232 FILE *finput;
234 /* Current line number in real source file. */
236 int lineno;
238 /* Stack of currently pending input files. */
240 struct file_stack *input_file_stack;
242 /* Incremented on each change to input_file_stack. */
243 int input_file_stack_tick;
245 /* FUNCTION_DECL for function now being parsed or compiled. */
247 extern tree current_function_decl;
249 /* Name to use as base of names for dump output files. */
251 char *dump_base_name;
253 /* Bit flags that specify the machine subtype we are compiling for.
254 Bits are tested using macros TARGET_... defined in the tm.h file
255 and set by `-m...' switches. Must be defined in rtlanal.c. */
257 extern int target_flags;
259 /* Flags saying which kinds of debugging dump have been requested. */
261 int rtl_dump = 0;
262 int rtl_dump_and_exit = 0;
263 int jump_opt_dump = 0;
264 int cse_dump = 0;
265 int loop_dump = 0;
266 int cse2_dump = 0;
267 int flow_dump = 0;
268 int combine_dump = 0;
269 int sched_dump = 0;
270 int local_reg_dump = 0;
271 int global_reg_dump = 0;
272 int sched2_dump = 0;
273 int jump2_opt_dump = 0;
274 int dbr_sched_dump = 0;
275 int flag_print_asm_name = 0;
276 int stack_reg_dump = 0;
278 /* Name for output file of assembly code, specified with -o. */
280 char *asm_file_name;
282 /* Value of the -G xx switch, and whether it was passed or not. */
283 int g_switch_value;
284 int g_switch_set;
286 /* Type(s) of debugging information we are producing (if any).
287 See flags.h for the definitions of the different possible
288 types of debugging information. */
289 enum debug_info_type write_symbols = NO_DEBUG;
291 /* Level of debugging information we are producing. See flags.h
292 for the definitions of the different possible levels. */
293 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
295 /* Nonzero means use GNU-only extensions in the generated symbolic
296 debugging information. */
297 /* Currently, this only has an effect when write_symbols is set to
298 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
299 int use_gnu_debug_info_extensions = 0;
301 /* Nonzero means do optimizations. -O.
302 Particular numeric values stand for particular amounts of optimization;
303 thus, -O2 stores 2 here. However, the optimizations beyond the basic
304 ones are not controlled directly by this variable. Instead, they are
305 controlled by individual `flag_...' variables that are defaulted
306 based on this variable. */
308 int optimize = 0;
310 /* Number of error messages and warning messages so far. */
312 int errorcount = 0;
313 int warningcount = 0;
314 int sorrycount = 0;
316 /* Flag to output bytecode instead of native assembler */
317 int output_bytecode = 0;
319 /* Pointer to function to compute the name to use to print a declaration. */
321 char *(*decl_printable_name) ();
323 /* Pointer to function to compute rtl for a language-specific tree code. */
325 struct rtx_def *(*lang_expand_expr) ();
327 /* Pointer to function to finish handling an incomplete decl at the
328 end of compilation. */
330 void (*incomplete_decl_finalize_hook) () = 0;
332 /* Pointer to function for interim exception handling implementation.
333 This interface will change, and it is only here until a better interface
334 replaces it. */
336 void (*interim_eh_hook) PROTO((tree));
338 /* Nonzero if generating code to do profiling. */
340 int profile_flag = 0;
342 /* Nonzero if generating code to do profiling on a line-by-line basis. */
344 int profile_block_flag;
346 /* Nonzero for -pedantic switch: warn about anything
347 that standard spec forbids. */
349 int pedantic = 0;
351 /* Temporarily suppress certain warnings.
352 This is set while reading code from a system header file. */
354 int in_system_header = 0;
356 /* Nonzero means do stupid register allocation.
357 Currently, this is 1 if `optimize' is 0. */
359 int obey_regdecls = 0;
361 /* Don't print functions as they are compiled and don't print
362 times taken by the various passes. -quiet. */
364 int quiet_flag = 0;
366 /* -f flags. */
368 /* Nonzero means `char' should be signed. */
370 int flag_signed_char;
372 /* Nonzero means give an enum type only as many bytes as it needs. */
374 int flag_short_enums;
376 /* Nonzero for -fcaller-saves: allocate values in regs that need to
377 be saved across function calls, if that produces overall better code.
378 Optional now, so people can test it. */
380 #ifdef DEFAULT_CALLER_SAVES
381 int flag_caller_saves = 1;
382 #else
383 int flag_caller_saves = 0;
384 #endif
386 /* Nonzero if structures and unions should be returned in memory.
388 This should only be defined if compatibility with another compiler or
389 with an ABI is needed, because it results in slower code. */
391 #ifndef DEFAULT_PCC_STRUCT_RETURN
392 #define DEFAULT_PCC_STRUCT_RETURN 1
393 #endif
395 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
397 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
399 /* Nonzero for -fforce-mem: load memory value into a register
400 before arithmetic on it. This makes better cse but slower compilation. */
402 int flag_force_mem = 0;
404 /* Nonzero for -fforce-addr: load memory address into a register before
405 reference to memory. This makes better cse but slower compilation. */
407 int flag_force_addr = 0;
409 /* Nonzero for -fdefer-pop: don't pop args after each function call;
410 instead save them up to pop many calls' args with one insns. */
412 int flag_defer_pop = 0;
414 /* Nonzero for -ffloat-store: don't allocate floats and doubles
415 in extended-precision registers. */
417 int flag_float_store = 0;
419 /* Nonzero for -fcse-follow-jumps:
420 have cse follow jumps to do a more extensive job. */
422 int flag_cse_follow_jumps;
424 /* Nonzero for -fcse-skip-blocks:
425 have cse follow a branch around a block. */
426 int flag_cse_skip_blocks;
428 /* Nonzero for -fexpensive-optimizations:
429 perform miscellaneous relatively-expensive optimizations. */
430 int flag_expensive_optimizations;
432 /* Nonzero for -fthread-jumps:
433 have jump optimize output of loop. */
435 int flag_thread_jumps;
437 /* Nonzero enables strength-reduction in loop.c. */
439 int flag_strength_reduce = 0;
441 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
442 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
443 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
444 unrolled. */
446 int flag_unroll_loops;
448 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
449 This is generally not a win. */
451 int flag_unroll_all_loops;
453 /* Nonzero for -fwritable-strings:
454 store string constants in data segment and don't uniquize them. */
456 int flag_writable_strings = 0;
458 /* Nonzero means don't put addresses of constant functions in registers.
459 Used for compiling the Unix kernel, where strange substitutions are
460 done on the assembly output. */
462 int flag_no_function_cse = 0;
464 /* Nonzero for -fomit-frame-pointer:
465 don't make a frame pointer in simple functions that don't require one. */
467 int flag_omit_frame_pointer = 0;
469 /* Nonzero to inhibit use of define_optimization peephole opts. */
471 int flag_no_peephole = 0;
473 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
474 operations in the interest of optimization. For example it allows
475 GCC to assume arguments to sqrt are nonnegative numbers, allowing
476 faster code for sqrt to be generated. */
478 int flag_fast_math = 0;
480 /* Nonzero means all references through pointers are volatile. */
482 int flag_volatile;
484 /* Nonzero means treat all global and extern variables as global. */
486 int flag_volatile_global;
488 /* Nonzero means just do syntax checking; don't output anything. */
490 int flag_syntax_only = 0;
492 /* Nonzero means to rerun cse after loop optimization. This increases
493 compilation time about 20% and picks up a few more common expressions. */
495 static int flag_rerun_cse_after_loop;
497 /* Nonzero for -finline-functions: ok to inline functions that look like
498 good inline candidates. */
500 int flag_inline_functions;
502 /* Nonzero for -fkeep-inline-functions: even if we make a function
503 go inline everywhere, keep its definition around for debugging
504 purposes. */
506 int flag_keep_inline_functions;
508 /* Nonzero means that functions will not be inlined. */
510 int flag_no_inline;
512 /* Nonzero means we should be saving declaration info into a .X file. */
514 int flag_gen_aux_info = 0;
516 /* Specified name of aux-info file. */
518 static char *aux_info_file_name;
520 /* Nonzero means make the text shared if supported. */
522 int flag_shared_data;
524 /* Nonzero means schedule into delayed branch slots if supported. */
526 int flag_delayed_branch;
528 /* Nonzero means to run cleanups after CALL_EXPRs. */
530 int flag_short_temps;
532 /* Nonzero if we are compiling pure (sharable) code.
533 Value is 1 if we are doing reasonable (i.e. simple
534 offset into offset table) pic. Value is 2 if we can
535 only perform register offsets. */
537 int flag_pic;
539 /* Nonzero means place uninitialized global data in the bss section. */
541 int flag_no_common;
543 /* Nonzero means pretend it is OK to examine bits of target floats,
544 even if that isn't true. The resulting code will have incorrect constants,
545 but the same series of instructions that the native compiler would make. */
547 int flag_pretend_float;
549 /* Nonzero means change certain warnings into errors.
550 Usually these are warnings about failure to conform to some standard. */
552 int flag_pedantic_errors = 0;
554 /* flag_schedule_insns means schedule insns within basic blocks (before
555 local_alloc).
556 flag_schedule_insns_after_reload means schedule insns after
557 global_alloc. */
559 int flag_schedule_insns = 0;
560 int flag_schedule_insns_after_reload = 0;
562 /* -finhibit-size-directive inhibits output of .size for ELF.
563 This is used only for compiling crtstuff.c,
564 and it may be extended to other effects
565 needed for crtstuff.c on other systems. */
566 int flag_inhibit_size_directive = 0;
568 /* -fverbose-asm causes extra commentary information to be produced in
569 the generated assembly code (to make it more readable). This option
570 is generally only of use to those who actually need to read the
571 generated assembly code (perhaps while debugging the compiler itself). */
573 int flag_verbose_asm = 0;
575 /* -fgnu-linker specifies use of the GNU linker for initializations.
576 (Or, more generally, a linker that handles initializations.)
577 -fno-gnu-linker says that collect2 will be used. */
578 #ifdef USE_COLLECT2
579 int flag_gnu_linker = 0;
580 #else
581 int flag_gnu_linker = 1;
582 #endif
584 /* Table of language-independent -f options.
585 STRING is the option name. VARIABLE is the address of the variable.
586 ON_VALUE is the value to store in VARIABLE
587 if `-fSTRING' is seen as an option.
588 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
590 struct { char *string; int *variable; int on_value;} f_options[] =
592 {"float-store", &flag_float_store, 1},
593 {"volatile", &flag_volatile, 1},
594 {"volatile-global", &flag_volatile_global, 1},
595 {"defer-pop", &flag_defer_pop, 1},
596 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
597 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
598 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
599 {"expensive-optimizations", &flag_expensive_optimizations, 1},
600 {"thread-jumps", &flag_thread_jumps, 1},
601 {"strength-reduce", &flag_strength_reduce, 1},
602 {"unroll-loops", &flag_unroll_loops, 1},
603 {"unroll-all-loops", &flag_unroll_all_loops, 1},
604 {"writable-strings", &flag_writable_strings, 1},
605 {"peephole", &flag_no_peephole, 0},
606 {"force-mem", &flag_force_mem, 1},
607 {"force-addr", &flag_force_addr, 1},
608 {"function-cse", &flag_no_function_cse, 0},
609 {"inline-functions", &flag_inline_functions, 1},
610 {"keep-inline-functions", &flag_keep_inline_functions, 1},
611 {"inline", &flag_no_inline, 0},
612 {"syntax-only", &flag_syntax_only, 1},
613 {"shared-data", &flag_shared_data, 1},
614 {"caller-saves", &flag_caller_saves, 1},
615 {"pcc-struct-return", &flag_pcc_struct_return, 1},
616 {"reg-struct-return", &flag_pcc_struct_return, 0},
617 {"delayed-branch", &flag_delayed_branch, 1},
618 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
619 {"pretend-float", &flag_pretend_float, 1},
620 {"schedule-insns", &flag_schedule_insns, 1},
621 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
622 {"pic", &flag_pic, 1},
623 {"PIC", &flag_pic, 2},
624 {"fast-math", &flag_fast_math, 1},
625 {"common", &flag_no_common, 0},
626 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
627 {"verbose-asm", &flag_verbose_asm, 1},
628 {"gnu-linker", &flag_gnu_linker, 1},
629 {"bytecode", &output_bytecode, 1}
632 /* Table of language-specific options. */
634 char *lang_options[] =
636 "-ansi",
637 "-fallow-single-precision",
639 "-fsigned-bitfields",
640 "-funsigned-bitfields",
641 "-fno-signed-bitfields",
642 "-fno-unsigned-bitfields",
643 "-fsigned-char",
644 "-funsigned-char",
645 "-fno-signed-char",
646 "-fno-unsigned-char",
648 "-ftraditional",
649 "-traditional",
650 "-fnotraditional",
651 "-fno-traditional",
653 "-fasm",
654 "-fno-asm",
655 "-fbuiltin",
656 "-fno-builtin",
657 "-fcond-mismatch",
658 "-fno-cond-mismatch",
659 "-fdollars-in-identifiers",
660 "-fno-dollars-in-identifiers",
661 "-fident",
662 "-fno-ident",
663 "-fshort-double",
664 "-fno-short-double",
665 "-fshort-enums",
666 "-fno-short-enums",
668 "-Wall",
669 "-Wbad-function-cast",
670 "-Wno-bad-function-cast",
671 "-Wcast-qual",
672 "-Wno-cast-qual",
673 "-Wchar-subscripts",
674 "-Wno-char-subscripts",
675 "-Wcomment",
676 "-Wno-comment",
677 "-Wcomments",
678 "-Wno-comments",
679 "-Wconversion",
680 "-Wno-conversion",
681 "-Wformat",
682 "-Wno-format",
683 "-Wimport",
684 "-Wno-import",
685 "-Wimplicit",
686 "-Wno-implicit",
687 "-Wmissing-braces",
688 "-Wno-missing-braces",
689 "-Wmissing-declarations",
690 "-Wno-missing-declarations",
691 "-Wmissing-prototypes",
692 "-Wno-missing-prototypes",
693 "-Wnested-externs",
694 "-Wno-nested-externs",
695 "-Wparentheses",
696 "-Wno-parentheses",
697 "-Wpointer-arith",
698 "-Wno-pointer-arith",
699 "-Wredundant-decls",
700 "-Wno-redundant-decls",
701 "-Wstrict-prototypes",
702 "-Wno-strict-prototypes",
703 "-Wtraditional",
704 "-Wno-traditional",
705 "-Wtrigraphs",
706 "-Wno-trigraphs",
707 "-Wwrite-strings",
708 "-Wno-write-strings",
710 /* These are for C++. */
711 "-+e0", /* gcc.c tacks the `-' on the front. */
712 "-+e1",
713 "-+e2",
714 "-faccess-control",
715 "-fno-access-control",
716 "-fall-virtual",
717 "-fno-all-virtual",
718 "-falt-external-templates",
719 "-fno-alt-external-templates",
720 "-fansi-overloading",
721 "-fno-ansi-overloading",
722 "-fcadillac",
723 "-fno-cadillac",
724 "-fcheck-new",
725 "-fno-check-new",
726 "-fconserve-space",
727 "-fno-conserve-space",
728 "-fdefault-inline",
729 "-fno-default-inline",
730 "-frtti",
731 "-fno-rtti",
732 "-felide-constructors",
733 "-fno-elide-constructors",
734 "-fenum-int-equiv",
735 "-fno-enum-int-equiv",
736 "-fexternal-templates",
737 "-fno-external-templates",
738 "-fgc",
739 "-fno-gc",
740 "-fgnu-keywords",
741 "-fno-gnu-keywords",
742 "-fhandle-exceptions",
743 "-fno-handle-exceptions",
744 "-fhandle-signatures",
745 "-fno-handle-signatures",
746 "-fhuge-objects",
747 "-fno-huge-objects",
748 "-fimplement-inlines",
749 "-fno-implement-inlines",
750 "-fimplicit-templates",
751 "-fno-implicit-templates",
752 "-flabels-ok",
753 "-fno-labels-ok",
754 "-fmemoize-lookups",
755 "-fno-memoize-lookups",
756 "-fnonnull-objects",
757 "-fno-nonnull-objects",
758 "-foperator-names",
759 "-fno-operator-names",
760 "-fsave-memoized",
761 "-fno-save-memoized",
762 "-fshort-temps",
763 "-fno-short-temps",
764 "-fstats",
765 "-fno-stats",
766 "-fstrict-prototype",
767 "-fno-strict-prototype",
768 "-fthis-is-variable",
769 "-fno-this-is-variable",
770 "-fvtable-thunks",
771 "-fno-vtable-thunks",
772 "-fxref",
773 "-fno-xref",
775 "-Wreturn-type",
776 "-Wno-return-type",
777 "-Woverloaded-virtual",
778 "-Wno-overloaded-virtual",
779 "-Wenum-clash",
780 "-Wno-enum-clash",
781 "-Wtemplate-debugging",
782 "-Wno-template-debugging",
783 "-Wctor-dtor-privacy",
784 "-Wno-ctor-dtor-privacy",
785 "-Wnon-virtual-dtor",
786 "-Wno-non-virtual-dtor",
787 "-Wextern-inline",
788 "-Wno-extern-inline",
789 "-Wreorder",
790 "-Wno-reorder",
791 "-Wsynth",
792 "-Wno-synth",
794 /* these are for obj c */
795 "-lang-objc",
796 "-gen-decls",
797 "-fgnu-runtime",
798 "-fno-gnu-runtime",
799 "-fnext-runtime",
800 "-fno-next-runtime",
801 "-Wselector",
802 "-Wno-selector",
803 "-Wprotocol",
804 "-Wno-protocol",
806 /* This is for GNAT and is temporary. */
807 "-gnat",
811 /* Options controlling warnings */
813 /* Don't print warning messages. -w. */
815 int inhibit_warnings = 0;
817 /* Print various extra warnings. -W. */
819 int extra_warnings = 0;
821 /* Treat warnings as errors. -Werror. */
823 int warnings_are_errors = 0;
825 /* Nonzero to warn about unused local variables. */
827 int warn_unused;
829 /* Nonzero to warn about variables used before they are initialized. */
831 int warn_uninitialized;
833 /* Nonzero means warn about all declarations which shadow others. */
835 int warn_shadow;
837 /* Warn if a switch on an enum fails to have a case for every enum value. */
839 int warn_switch;
841 /* Nonzero means warn about function definitions that default the return type
842 or that use a null return and have a return-type other than void. */
844 int warn_return_type;
846 /* Nonzero means warn about pointer casts that increase the required
847 alignment of the target type (and might therefore lead to a crash
848 due to a misaligned access). */
850 int warn_cast_align;
852 /* Nonzero means warn about any identifiers that match in the first N
853 characters. The value N is in `id_clash_len'. */
855 int warn_id_clash;
856 unsigned id_clash_len;
858 /* Nonzero means warn about any objects definitions whose size is larger
859 than N bytes. Also want about function definitions whose returned
860 values are larger than N bytes. The value N is in `larger_than_size'. */
862 int warn_larger_than;
863 unsigned larger_than_size;
865 /* Nonzero means warn if inline function is too large. */
867 int warn_inline;
869 /* Warn if a function returns an aggregate,
870 since there are often incompatible calling conventions for doing this. */
872 int warn_aggregate_return;
874 /* Likewise for -W. */
876 struct { char *string; int *variable; int on_value;} W_options[] =
878 {"unused", &warn_unused, 1},
879 {"error", &warnings_are_errors, 1},
880 {"shadow", &warn_shadow, 1},
881 {"switch", &warn_switch, 1},
882 {"aggregate-return", &warn_aggregate_return, 1},
883 {"cast-align", &warn_cast_align, 1},
884 {"uninitialized", &warn_uninitialized, 1},
885 {"inline", &warn_inline, 1}
888 /* Output files for assembler code (real compiler output)
889 and debugging dumps. */
891 FILE *asm_out_file;
892 FILE *aux_info_file;
893 FILE *rtl_dump_file;
894 FILE *jump_opt_dump_file;
895 FILE *cse_dump_file;
896 FILE *loop_dump_file;
897 FILE *cse2_dump_file;
898 FILE *flow_dump_file;
899 FILE *combine_dump_file;
900 FILE *sched_dump_file;
901 FILE *local_reg_dump_file;
902 FILE *global_reg_dump_file;
903 FILE *sched2_dump_file;
904 FILE *jump2_opt_dump_file;
905 FILE *dbr_sched_dump_file;
906 FILE *stack_reg_dump_file;
908 /* Time accumulators, to count the total time spent in various passes. */
910 int parse_time;
911 int varconst_time;
912 int integration_time;
913 int jump_time;
914 int cse_time;
915 int loop_time;
916 int cse2_time;
917 int flow_time;
918 int combine_time;
919 int sched_time;
920 int local_alloc_time;
921 int global_alloc_time;
922 int sched2_time;
923 int dbr_sched_time;
924 int shorten_branch_time;
925 int stack_reg_time;
926 int final_time;
927 int symout_time;
928 int dump_time;
930 /* Return time used so far, in microseconds. */
933 get_run_time ()
935 #ifdef WINNT
936 return 0;
937 #else
938 #ifdef USG
939 struct tms tms;
940 #else
941 #ifndef VMS
942 struct rusage rusage;
943 #else /* VMS */
944 struct
946 int proc_user_time;
947 int proc_system_time;
948 int child_user_time;
949 int child_system_time;
950 } vms_times;
951 #endif
952 #endif
954 if (quiet_flag)
955 return 0;
957 #ifdef USG
958 times (&tms);
959 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
960 #else
961 #ifndef VMS
962 getrusage (0, &rusage);
963 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
964 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
965 #else /* VMS */
966 times (&vms_times);
967 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
968 #endif
969 #endif
970 #endif
973 #define TIMEVAR(VAR, BODY) \
974 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
976 void
977 print_time (str, total)
978 char *str;
979 int total;
981 fprintf (stderr,
982 "time in %s: %d.%06d\n",
983 str, total / 1000000, total % 1000000);
986 /* Count an error or warning. Return 1 if the message should be printed. */
989 count_error (warningp)
990 int warningp;
992 if (warningp && inhibit_warnings)
993 return 0;
995 if (warningp && !warnings_are_errors)
996 warningcount++;
997 else
999 static int warning_message = 0;
1001 if (warningp && !warning_message)
1003 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
1004 warning_message = 1;
1006 errorcount++;
1009 return 1;
1012 /* Print a fatal error message. NAME is the text.
1013 Also include a system error message based on `errno'. */
1015 void
1016 pfatal_with_name (name)
1017 char *name;
1019 fprintf (stderr, "%s: ", progname);
1020 perror (name);
1021 exit (35);
1024 void
1025 fatal_io_error (name)
1026 char *name;
1028 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
1029 exit (35);
1032 /* Called to give a better error message for a bad insn rather than
1033 just calling abort(). */
1035 void
1036 fatal_insn (message, insn)
1037 char *message;
1038 rtx insn;
1040 if (!output_bytecode)
1042 error (message);
1043 debug_rtx (insn);
1045 if (asm_out_file)
1046 fflush (asm_out_file);
1047 if (aux_info_file)
1048 fflush (aux_info_file);
1049 if (rtl_dump_file)
1050 fflush (rtl_dump_file);
1051 if (jump_opt_dump_file)
1052 fflush (jump_opt_dump_file);
1053 if (cse_dump_file)
1054 fflush (cse_dump_file);
1055 if (loop_dump_file)
1056 fflush (loop_dump_file);
1057 if (cse2_dump_file)
1058 fflush (cse2_dump_file);
1059 if (flow_dump_file)
1060 fflush (flow_dump_file);
1061 if (combine_dump_file)
1062 fflush (combine_dump_file);
1063 if (sched_dump_file)
1064 fflush (sched_dump_file);
1065 if (local_reg_dump_file)
1066 fflush (local_reg_dump_file);
1067 if (global_reg_dump_file)
1068 fflush (global_reg_dump_file);
1069 if (sched2_dump_file)
1070 fflush (sched2_dump_file);
1071 if (jump2_opt_dump_file)
1072 fflush (jump2_opt_dump_file);
1073 if (dbr_sched_dump_file)
1074 fflush (dbr_sched_dump_file);
1075 if (stack_reg_dump_file)
1076 fflush (stack_reg_dump_file);
1077 abort ();
1080 /* Called to give a better error message when we don't have an insn to match
1081 what we are looking for or if the insn's constraints aren't satisfied,
1082 rather than just calling abort(). */
1084 void
1085 fatal_insn_not_found (insn)
1086 rtx insn;
1088 if (INSN_CODE (insn) < 0)
1089 fatal_insn ("internal error--unrecognizable insn:", insn);
1090 else
1091 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1094 /* This is the default decl_printable_name function. */
1096 static char *
1097 decl_name (decl, kind)
1098 tree decl;
1099 char **kind;
1101 return IDENTIFIER_POINTER (DECL_NAME (decl));
1104 /* This is the default interim_eh_hook function. */
1106 void
1107 interim_eh (finalization)
1108 tree finalization;
1110 /* Don't do anything by default. */
1113 static int need_error_newline;
1115 /* Function of last error message;
1116 more generally, function such that if next error message is in it
1117 then we don't have to mention the function name. */
1118 static tree last_error_function = NULL;
1120 /* Used to detect when input_file_stack has changed since last described. */
1121 static int last_error_tick;
1123 /* Called when the start of a function definition is parsed,
1124 this function prints on stderr the name of the function. */
1126 void
1127 announce_function (decl)
1128 tree decl;
1130 if (! quiet_flag)
1132 char *junk;
1133 if (rtl_dump_and_exit)
1134 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1135 else
1136 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
1137 fflush (stderr);
1138 need_error_newline = 1;
1139 last_error_function = current_function_decl;
1143 /* Prints out, if necessary, the name of the current function
1144 which caused an error. Called from all error and warning functions. */
1146 void
1147 report_error_function (file)
1148 char *file;
1150 struct file_stack *p;
1152 if (need_error_newline)
1154 fprintf (stderr, "\n");
1155 need_error_newline = 0;
1158 if (last_error_function != current_function_decl)
1160 char *kind = "function";
1161 if (current_function_decl != 0
1162 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1163 kind = "method";
1165 if (file)
1166 fprintf (stderr, "%s: ", file);
1168 if (current_function_decl == NULL)
1169 fprintf (stderr, "At top level:\n");
1170 else
1172 char *name = (*decl_printable_name) (current_function_decl, &kind);
1173 fprintf (stderr, "In %s `%s':\n", kind, name);
1176 last_error_function = current_function_decl;
1178 if (input_file_stack && input_file_stack->next != 0
1179 && input_file_stack_tick != last_error_tick)
1181 fprintf (stderr, "In file included");
1182 for (p = input_file_stack->next; p; p = p->next)
1184 fprintf (stderr, " from %s:%d", p->name, p->line);
1185 if (p->next)
1186 fprintf (stderr, ",\n ");
1188 fprintf (stderr, ":\n");
1189 last_error_tick = input_file_stack_tick;
1193 /* Print a message. */
1195 static void
1196 vmessage (prefix, s, ap)
1197 char *prefix;
1198 char *s;
1199 va_list ap;
1201 if (prefix)
1202 fprintf (stderr, "%s: ", prefix);
1204 #ifdef HAVE_VPRINTF
1205 vfprintf (stderr, s, ap);
1206 #else
1208 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1209 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1210 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1211 fprintf (stderr, s, v1, v2, v3);
1213 #endif
1216 /* Print a message relevant to line LINE of file FILE. */
1218 static void
1219 v_message_with_file_and_line (file, line, prefix, s, ap)
1220 char *file;
1221 int line;
1222 char *prefix;
1223 char *s;
1224 va_list ap;
1226 if (file)
1227 fprintf (stderr, "%s:%d: ", file, line);
1228 else
1229 fprintf (stderr, "%s: ", progname);
1231 vmessage (prefix, s, ap);
1232 fputc ('\n', stderr);
1235 /* Print a message relevant to the given DECL. */
1237 static void
1238 v_message_with_decl (decl, prefix, s, ap)
1239 tree decl;
1240 char *prefix;
1241 char *s;
1242 va_list ap;
1244 char *n, *p, *junk;
1246 fprintf (stderr, "%s:%d: ",
1247 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1249 if (prefix)
1250 fprintf (stderr, "%s: ", prefix);
1252 /* Do magic to get around lack of varargs support for insertion
1253 of arguments into existing list. We know that the decl is first;
1254 we ass_u_me that it will be printed with "%s". */
1256 for (p = s; *p; ++p)
1258 if (*p == '%')
1260 if (*(p + 1) == '%')
1261 ++p;
1262 else
1263 break;
1267 if (p > s) /* Print the left-hand substring. */
1269 char fmt[sizeof "%.255s"];
1270 long width = p - s;
1272 if (width > 255L) width = 255L; /* arbitrary */
1273 sprintf (fmt, "%%.%lds", width);
1274 fprintf (stderr, fmt, s);
1277 if (*p == '%') /* Print the name. */
1279 char *n = (DECL_NAME (decl)
1280 ? (*decl_printable_name) (decl, &junk)
1281 : "((anonymous))");
1282 fputs (n, stderr);
1283 while (*p)
1285 ++p;
1286 if (isalpha (*(p - 1) & 0xFF))
1287 break;
1291 if (*p) /* Print the rest of the message. */
1292 vmessage ((char *)NULL, p, ap);
1294 fputc ('\n', stderr);
1297 /* Figure file and line of the given INSN. */
1299 static void
1300 file_and_line_for_asm (insn, pfile, pline)
1301 rtx insn;
1302 char **pfile;
1303 int *pline;
1305 rtx body = PATTERN (insn);
1306 rtx asmop;
1308 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1309 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1310 asmop = SET_SRC (body);
1311 else if (GET_CODE (body) == ASM_OPERANDS)
1312 asmop = body;
1313 else if (GET_CODE (body) == PARALLEL
1314 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1315 asmop = SET_SRC (XVECEXP (body, 0, 0));
1316 else if (GET_CODE (body) == PARALLEL
1317 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1318 asmop = XVECEXP (body, 0, 0);
1319 else
1320 asmop = NULL;
1322 if (asmop)
1324 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1325 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1327 else
1329 *pfile = input_filename;
1330 *pline = lineno;
1334 /* Report an error at line LINE of file FILE. */
1336 static void
1337 v_error_with_file_and_line (file, line, s, ap)
1338 char *file;
1339 int line;
1340 char *s;
1341 va_list ap;
1343 count_error (0);
1344 report_error_function (file);
1345 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1348 void
1349 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1351 #ifndef __STDC__
1352 char *file;
1353 int line;
1354 char *s;
1355 #endif
1356 va_list ap;
1358 VA_START (ap, s);
1360 #ifndef __STDC__
1361 file = va_arg (ap, char *);
1362 line = va_arg (ap, int);
1363 s = va_arg (ap, char *);
1364 #endif
1366 v_error_with_file_and_line (file, line, s, ap);
1367 va_end (ap);
1370 /* Report an error at the declaration DECL.
1371 S is a format string which uses %s to substitute the declaration
1372 name; subsequent substitutions are a la printf. */
1374 static void
1375 v_error_with_decl (decl, s, ap)
1376 tree decl;
1377 char *s;
1378 va_list ap;
1380 count_error (0);
1381 report_error_function (DECL_SOURCE_FILE (decl));
1382 v_message_with_decl (decl, (char *)NULL, s, ap);
1385 void
1386 error_with_decl VPROTO((tree decl, char *s, ...))
1388 #ifndef __STDC__
1389 tree decl;
1390 char *s;
1391 #endif
1392 va_list ap;
1394 VA_START (ap, s);
1396 #ifndef __STDC__
1397 decl = va_arg (ap, tree);
1398 s = va_arg (ap, char *);
1399 #endif
1401 v_error_with_decl (decl, s, ap);
1402 va_end (ap);
1405 /* Report an error at the line number of the insn INSN.
1406 This is used only when INSN is an `asm' with operands,
1407 and each ASM_OPERANDS records its own source file and line. */
1409 static void
1410 v_error_for_asm (insn, s, ap)
1411 rtx insn;
1412 char *s;
1413 va_list ap;
1415 char *file;
1416 int line;
1418 count_error (0);
1419 file_and_line_for_asm (insn, &file, &line);
1420 report_error_function (file);
1421 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1424 void
1425 error_for_asm VPROTO((rtx insn, char *s, ...))
1427 #ifndef __STDC__
1428 rtx insn;
1429 char *s;
1430 #endif
1431 va_list ap;
1433 VA_START (ap, s);
1435 #ifndef __STDC__
1436 insn = va_arg (ap, rtx);
1437 s = va_arg (ap, char *);
1438 #endif
1440 v_error_for_asm (insn, s, ap);
1441 va_end (ap);
1444 /* Report an error at the current line number. */
1446 static void
1447 verror (s, ap)
1448 char *s;
1449 va_list ap;
1451 v_error_with_file_and_line (input_filename, lineno, s, ap);
1454 void
1455 error VPROTO((char *s, ...))
1457 #ifndef __STDC__
1458 char *s;
1459 #endif
1460 va_list ap;
1462 VA_START (ap, s);
1464 #ifndef __STDC__
1465 s = va_arg (ap, char *);
1466 #endif
1468 verror (s, ap);
1469 va_end (ap);
1472 /* Report a fatal error at the current line number. */
1474 static void
1475 vfatal (s, ap)
1476 char *s;
1477 va_list ap;
1479 verror (s, ap);
1480 exit (34);
1483 void
1484 fatal VPROTO((char *s, ...))
1486 #ifndef __STDC__
1487 char *s;
1488 #endif
1489 va_list ap;
1491 VA_START (ap, s);
1493 #ifndef __STDC__
1494 s = va_arg (ap, char *);
1495 #endif
1497 vfatal (s, ap);
1498 va_end (ap);
1501 /* Report a warning at line LINE of file FILE. */
1503 static void
1504 v_warning_with_file_and_line (file, line, s, ap)
1505 char *file;
1506 int line;
1507 char *s;
1508 va_list ap;
1510 if (count_error (1))
1512 report_error_function (file);
1513 v_message_with_file_and_line (file, line, "warning", s, ap);
1517 void
1518 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1520 #ifndef __STDC__
1521 char *file;
1522 int line;
1523 char *s;
1524 #endif
1525 va_list ap;
1527 VA_START (ap, s);
1529 #ifndef __STDC__
1530 file = va_arg (ap, char *);
1531 line = va_arg (ap, int);
1532 s = va_arg (ap, char *);
1533 #endif
1535 v_warning_with_file_and_line (file, line, s, ap);
1536 va_end (ap);
1539 /* Report a warning at the declaration DECL.
1540 S is a format string which uses %s to substitute the declaration
1541 name; subsequent substitutions are a la printf. */
1543 static void
1544 v_warning_with_decl (decl, s, ap)
1545 tree decl;
1546 char *s;
1547 va_list ap;
1549 if (count_error (1))
1551 report_error_function (DECL_SOURCE_FILE (decl));
1552 v_message_with_decl (decl, "warning", s, ap);
1556 void
1557 warning_with_decl VPROTO((tree decl, char *s, ...))
1559 #ifndef __STDC__
1560 tree decl;
1561 char *s;
1562 #endif
1563 va_list ap;
1565 VA_START (ap, s);
1567 #ifndef __STDC__
1568 decl = va_arg (ap, tree);
1569 s = va_arg (ap, char *);
1570 #endif
1572 v_warning_with_decl (decl, s, ap);
1573 va_end (ap);
1576 /* Report a warning at the line number of the insn INSN.
1577 This is used only when INSN is an `asm' with operands,
1578 and each ASM_OPERANDS records its own source file and line. */
1580 static void
1581 v_warning_for_asm (insn, s, ap)
1582 rtx insn;
1583 char *s;
1584 va_list ap;
1586 if (count_error (1))
1588 char *file;
1589 int line;
1591 file_and_line_for_asm (insn, &file, &line);
1592 report_error_function (file);
1593 v_message_with_file_and_line (file, line, "warning", s, ap);
1597 void
1598 warning_for_asm VPROTO((rtx insn, char *s, ...))
1600 #ifndef __STDC__
1601 rtx insn;
1602 char *s;
1603 #endif
1604 va_list ap;
1606 VA_START (ap, s);
1608 #ifndef __STDC__
1609 insn = va_arg (ap, rtx);
1610 s = va_arg (ap, char *);
1611 #endif
1613 v_warning_for_asm (insn, s, ap);
1614 va_end (ap);
1617 /* Report a warning at the current line number. */
1619 static void
1620 vwarning (s, ap)
1621 char *s;
1622 va_list ap;
1624 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1627 void
1628 warning VPROTO((char *s, ...))
1630 #ifndef __STDC__
1631 char *s;
1632 #endif
1633 va_list ap;
1635 VA_START (ap, s);
1637 #ifndef __STDC__
1638 s = va_arg (ap, char *);
1639 #endif
1641 vwarning (s, ap);
1642 va_end (ap);
1645 /* These functions issue either warnings or errors depending on
1646 -pedantic-errors. */
1648 static void
1649 vpedwarn (s, ap)
1650 char *s;
1651 va_list ap;
1653 if (flag_pedantic_errors)
1654 verror (s, ap);
1655 else
1656 vwarning (s, ap);
1659 void
1660 pedwarn VPROTO((char *s, ...))
1662 #ifndef __STDC__
1663 char *s;
1664 #endif
1665 va_list ap;
1667 VA_START (ap, s);
1669 #ifndef __STDC__
1670 s = va_arg (ap, char *);
1671 #endif
1673 vpedwarn (s, ap);
1674 va_end (ap);
1677 static void
1678 v_pedwarn_with_decl (decl, s, ap)
1679 tree decl;
1680 char *s;
1681 va_list ap;
1683 /* We don't want -pedantic-errors to cause the compilation to fail from
1684 "errors" in system header files. Sometimes fixincludes can't fix what's
1685 broken (eg: unsigned char bitfields - fixing it may change the alignment
1686 which will cause programs to mysteriously fail because the C library
1687 or kernel uses the original layout). There's no point in issuing a
1688 warning either, it's just unnecessary noise. */
1690 if (! DECL_IN_SYSTEM_HEADER (decl))
1692 if (flag_pedantic_errors)
1693 v_error_with_decl (decl, s, ap);
1694 else
1695 v_warning_with_decl (decl, s, ap);
1699 void
1700 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1702 #ifndef __STDC__
1703 tree decl;
1704 char *s;
1705 #endif
1706 va_list ap;
1708 VA_START (ap, s);
1710 #ifndef __STDC__
1711 decl = va_arg (ap, tree);
1712 s = va_arg (ap, char *);
1713 #endif
1715 v_pedwarn_with_decl (decl, s, ap);
1716 va_end (ap);
1719 static void
1720 v_pedwarn_with_file_and_line (file, line, s, ap)
1721 char *file;
1722 int line;
1723 char *s;
1724 va_list ap;
1726 if (flag_pedantic_errors)
1727 v_error_with_file_and_line (file, line, s, ap);
1728 else
1729 v_warning_with_file_and_line (file, line, s, ap);
1732 void
1733 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1735 #ifndef __STDC__
1736 char *file;
1737 int line;
1738 char *s;
1739 #endif
1740 va_list ap;
1742 VA_START (ap, s);
1744 #ifndef __STDC__
1745 file = va_arg (ap, char *);
1746 line = va_arg (ap, int);
1747 s = va_arg (ap, char *);
1748 #endif
1750 v_pedwarn_with_file_and_line (file, line, s, ap);
1751 va_end (ap);
1754 /* Apologize for not implementing some feature. */
1756 static void
1757 vsorry (s, ap)
1758 char *s;
1759 va_list ap;
1761 sorrycount++;
1762 if (input_filename)
1763 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1764 else
1765 fprintf (stderr, "%s: ", progname);
1766 vmessage ("sorry, not implemented", s, ap);
1767 fputc ('\n', stderr);
1770 void
1771 sorry VPROTO((char *s, ...))
1773 #ifndef __STDC__
1774 char *s;
1775 #endif
1776 va_list ap;
1778 VA_START (ap, s);
1780 #ifndef __STDC__
1781 s = va_arg (ap, char *);
1782 #endif
1784 vsorry (s, ap);
1785 va_end (ap);
1788 /* Apologize for not implementing some feature, then quit. */
1790 static void
1791 v_really_sorry (s, ap)
1792 char *s;
1793 va_list ap;
1795 sorrycount++;
1796 if (input_filename)
1797 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1798 else
1799 fprintf (stderr, "%s: ", progname);
1800 vmessage ("sorry, not implemented", s, ap);
1801 fatal (" (fatal)\n");
1804 void
1805 really_sorry VPROTO((char *s, ...))
1807 #ifndef __STDC__
1808 char *s;
1809 #endif
1810 va_list ap;
1812 VA_START (ap, s);
1814 #ifndef __STDC__
1815 s = va_arg (ap, char *);
1816 #endif
1818 v_really_sorry (s, ap);
1819 va_end (ap);
1822 /* More 'friendly' abort that prints the line and file.
1823 config.h can #define abort fancy_abort if you like that sort of thing.
1825 I don't think this is actually a good idea.
1826 Other sorts of crashes will look a certain way.
1827 It is a good thing if crashes from calling abort look the same way.
1828 -- RMS */
1830 void
1831 fancy_abort ()
1833 fatal ("internal gcc abort");
1836 /* This calls abort and is used to avoid problems when abort if a macro.
1837 It is used when we need to pass the address of abort. */
1839 void
1840 do_abort ()
1842 abort ();
1845 /* When `malloc.c' is compiled with `rcheck' defined,
1846 it calls this function to report clobberage. */
1848 void
1849 botch (s)
1851 abort ();
1854 /* Same as `malloc' but report error if no memory available. */
1856 char *
1857 xmalloc (size)
1858 unsigned size;
1860 register char *value = (char *) malloc (size);
1861 if (value == 0)
1862 fatal ("virtual memory exhausted");
1863 return value;
1866 /* Same as `realloc' but report error if no memory available. */
1868 char *
1869 xrealloc (ptr, size)
1870 char *ptr;
1871 int size;
1873 char *result = (char *) realloc (ptr, size);
1874 if (!result)
1875 fatal ("virtual memory exhausted");
1876 return result;
1879 /* Return the logarithm of X, base 2, considering X unsigned,
1880 if X is a power of 2. Otherwise, returns -1.
1882 This should be used via the `exact_log2' macro. */
1885 exact_log2_wide (x)
1886 register unsigned HOST_WIDE_INT x;
1888 register int log = 0;
1889 /* Test for 0 or a power of 2. */
1890 if (x == 0 || x != (x & -x))
1891 return -1;
1892 while ((x >>= 1) != 0)
1893 log++;
1894 return log;
1897 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1898 If X is 0, return -1.
1900 This should be used via the floor_log2 macro. */
1903 floor_log2_wide (x)
1904 register unsigned HOST_WIDE_INT x;
1906 register int log = -1;
1907 while (x != 0)
1908 log++,
1909 x >>= 1;
1910 return log;
1913 int float_handled;
1914 jmp_buf float_handler;
1916 /* Specify where to longjmp to when a floating arithmetic error happens.
1917 If HANDLER is 0, it means don't handle the errors any more. */
1919 void
1920 set_float_handler (handler)
1921 jmp_buf handler;
1923 float_handled = (handler != 0);
1924 if (handler)
1925 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1928 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1929 error happens, pushing the previous specification into OLD_HANDLER.
1930 Return an indication of whether there was a previous handler in effect. */
1933 push_float_handler (handler, old_handler)
1934 jmp_buf handler, old_handler;
1936 int was_handled = float_handled;
1938 float_handled = 1;
1939 if (was_handled)
1940 bcopy ((char *) float_handler, (char *) old_handler,
1941 sizeof (float_handler));
1943 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1944 return was_handled;
1947 /* Restore the previous specification of whether and where to longjmp to
1948 when a floating arithmetic error happens. */
1950 void
1951 pop_float_handler (handled, handler)
1952 int handled;
1953 jmp_buf handler;
1955 float_handled = handled;
1956 if (handled)
1957 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1960 /* Signals actually come here. */
1962 static void
1963 float_signal (signo)
1964 /* If this is missing, some compilers complain. */
1965 int signo;
1967 if (float_handled == 0)
1968 abort ();
1969 #if defined (USG) || defined (hpux)
1970 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1971 #endif
1972 float_handled = 0;
1973 signal (SIGFPE, float_signal);
1974 longjmp (float_handler, 1);
1977 /* Handler for SIGPIPE. */
1979 static void
1980 pipe_closed (signo)
1981 /* If this is missing, some compilers complain. */
1982 int signo;
1984 fatal ("output pipe has been closed");
1987 /* Strip off a legitimate source ending from the input string NAME of
1988 length LEN. */
1990 void
1991 strip_off_ending (name, len)
1992 char *name;
1993 int len;
1995 if (len > 2 && ! strcmp (".c", name + len - 2))
1996 name[len - 2] = 0;
1997 else if (len > 2 && ! strcmp (".m", name + len - 2))
1998 name[len - 2] = 0;
1999 else if (len > 2 && ! strcmp (".i", name + len - 2))
2000 name[len - 2] = 0;
2001 else if (len > 3 && ! strcmp (".ii", name + len - 3))
2002 name[len - 3] = 0;
2003 else if (len > 3 && ! strcmp (".co", name + len - 3))
2004 name[len - 3] = 0;
2005 else if (len > 3 && ! strcmp (".cc", name + len - 3))
2006 name[len - 3] = 0;
2007 else if (len > 2 && ! strcmp (".C", name + len - 2))
2008 name[len - 2] = 0;
2009 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
2010 name[len - 4] = 0;
2011 else if (len > 4 && ! strcmp (".cpp", name + len - 4))
2012 name[len - 4] = 0;
2013 else if (len > 2 && ! strcmp (".f", name + len - 2))
2014 name[len - 2] = 0;
2015 /* Ada will use extensions like .ada, .adb, and .ads, so just test
2016 for "ad". */
2017 else if (len > 4 && ! strncmp (".ad", name + len - 4, 3))
2018 name[len - 4] = 0;
2019 else if (len > 4 && ! strcmp (".atr", name + len - 4))
2020 name[len - 4] = 0;
2023 /* Output a quoted string. */
2024 void
2025 output_quoted_string (asm_file, string)
2026 FILE *asm_file;
2027 char *string;
2029 char c;
2031 putc ('\"', asm_file);
2032 while ((c = *string++) != 0)
2034 if (c == '\"' || c == '\\')
2035 putc ('\\', asm_file);
2036 putc (c, asm_file);
2038 putc ('\"', asm_file);
2041 /* Output a file name in the form wanted by System V. */
2043 void
2044 output_file_directive (asm_file, input_name)
2045 FILE *asm_file;
2046 char *input_name;
2048 int len = strlen (input_name);
2049 char *na = input_name + len;
2051 /* NA gets INPUT_NAME sans directory names. */
2052 while (na > input_name)
2054 if (na[-1] == '/')
2055 break;
2056 na--;
2059 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2060 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2061 #else
2062 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2063 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2064 #else
2065 fprintf (asm_file, "\t.file\t");
2066 output_quoted_string (asm_file, na);
2067 fputc ('\n', asm_file);
2068 #endif
2069 #endif
2072 /* Routine to build language identifier for object file. */
2073 static void
2074 output_lang_identify (asm_out_file)
2075 FILE *asm_out_file;
2077 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2078 char *s = (char *) alloca (len);
2079 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2080 ASM_OUTPUT_LABEL (asm_out_file, s);
2083 /* Routine to open a dump file. */
2084 static FILE *
2085 open_dump_file (base_name, suffix)
2086 char *base_name;
2087 char *suffix;
2089 FILE *f;
2090 char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1);
2092 strcpy (dumpname, base_name);
2093 strcat (dumpname, suffix);
2094 f = fopen (dumpname, "w");
2095 if (f == 0)
2096 pfatal_with_name (dumpname);
2097 return f;
2100 /* Compile an entire file of output from cpp, named NAME.
2101 Write a file of assembly output and various debugging dumps. */
2103 static void
2104 compile_file (name)
2105 char *name;
2107 tree globals;
2108 int start_time;
2110 int name_specified = name != 0;
2112 if (dump_base_name == 0)
2113 dump_base_name = name ? name : "gccdump";
2115 parse_time = 0;
2116 varconst_time = 0;
2117 integration_time = 0;
2118 jump_time = 0;
2119 cse_time = 0;
2120 loop_time = 0;
2121 cse2_time = 0;
2122 flow_time = 0;
2123 combine_time = 0;
2124 sched_time = 0;
2125 local_alloc_time = 0;
2126 global_alloc_time = 0;
2127 sched2_time = 0;
2128 dbr_sched_time = 0;
2129 shorten_branch_time = 0;
2130 stack_reg_time = 0;
2131 final_time = 0;
2132 symout_time = 0;
2133 dump_time = 0;
2135 /* Open input file. */
2137 if (name == 0 || !strcmp (name, "-"))
2139 finput = stdin;
2140 name = "stdin";
2142 else
2143 finput = fopen (name, "r");
2144 if (finput == 0)
2145 pfatal_with_name (name);
2147 #ifdef IO_BUFFER_SIZE
2148 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2149 #endif
2151 /* Initialize data in various passes. */
2153 init_obstacks ();
2154 init_tree_codes ();
2155 init_lex ();
2156 /* Some of these really don't need to be called when generating bytecode,
2157 but the options would have to be parsed first to know that. -bson */
2158 init_rtl ();
2159 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2160 || debug_info_level == DINFO_LEVEL_VERBOSE);
2161 init_regs ();
2162 init_decl_processing ();
2163 init_optabs ();
2164 init_stmt ();
2165 init_expmed ();
2166 init_expr_once ();
2167 init_loop ();
2168 init_reload ();
2170 if (flag_caller_saves)
2171 init_caller_save ();
2173 /* If auxiliary info generation is desired, open the output file.
2174 This goes in the same directory as the source file--unlike
2175 all the other output files. */
2176 if (flag_gen_aux_info)
2178 aux_info_file = fopen (aux_info_file_name, "w");
2179 if (aux_info_file == 0)
2180 pfatal_with_name (aux_info_file_name);
2183 /* If rtl dump desired, open the output file. */
2184 if (rtl_dump)
2185 rtl_dump_file = open_dump_file (dump_base_name, ".rtl");
2187 /* If jump_opt dump desired, open the output file. */
2188 if (jump_opt_dump)
2189 jump_opt_dump_file = open_dump_file (dump_base_name, ".jump");
2191 /* If cse dump desired, open the output file. */
2192 if (cse_dump)
2193 cse_dump_file = open_dump_file (dump_base_name, ".cse");
2195 /* If loop dump desired, open the output file. */
2196 if (loop_dump)
2197 loop_dump_file = open_dump_file (dump_base_name, ".loop");
2199 /* If cse2 dump desired, open the output file. */
2200 if (cse2_dump)
2201 cse2_dump_file = open_dump_file (dump_base_name, ".cse2");
2203 /* If flow dump desired, open the output file. */
2204 if (flow_dump)
2205 flow_dump_file = open_dump_file (dump_base_name, ".flow");
2207 /* If combine dump desired, open the output file. */
2208 if (combine_dump)
2209 combine_dump_file = open_dump_file (dump_base_name, ".combine");
2211 /* If scheduling dump desired, open the output file. */
2212 if (sched_dump)
2213 sched_dump_file = open_dump_file (dump_base_name, ".sched");
2215 /* If local_reg dump desired, open the output file. */
2216 if (local_reg_dump)
2217 local_reg_dump_file = open_dump_file (dump_base_name, ".lreg");
2219 /* If global_reg dump desired, open the output file. */
2220 if (global_reg_dump)
2221 global_reg_dump_file = open_dump_file (dump_base_name, ".greg");
2223 /* If 2nd scheduling dump desired, open the output file. */
2224 if (sched2_dump)
2225 sched2_dump_file = open_dump_file (dump_base_name, ".sched2");
2227 /* If jump2_opt dump desired, open the output file. */
2228 if (jump2_opt_dump)
2229 jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2");
2231 /* If dbr_sched dump desired, open the output file. */
2232 if (dbr_sched_dump)
2233 dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr");
2235 #ifdef STACK_REGS
2237 /* If stack_reg dump desired, open the output file. */
2238 if (stack_reg_dump)
2239 stack_reg_dump_file = open_dump_file (dump_base_name, ".stack");
2241 #endif
2243 /* Open assembler code output file. */
2245 if (! name_specified && asm_file_name == 0)
2246 asm_out_file = stdout;
2247 else
2249 int len = strlen (dump_base_name);
2250 register char *dumpname = (char *) xmalloc (len + 6);
2251 strcpy (dumpname, dump_base_name);
2252 strip_off_ending (dumpname, len);
2253 strcat (dumpname, ".s");
2254 if (asm_file_name == 0)
2256 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2257 strcpy (asm_file_name, dumpname);
2259 if (!strcmp (asm_file_name, "-"))
2260 asm_out_file = stdout;
2261 else
2262 asm_out_file = fopen (asm_file_name, "w");
2263 if (asm_out_file == 0)
2264 pfatal_with_name (asm_file_name);
2267 #ifdef IO_BUFFER_SIZE
2268 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2269 _IOFBF, IO_BUFFER_SIZE);
2270 #endif
2272 input_filename = name;
2274 /* Put an entry on the input file stack for the main input file. */
2275 input_file_stack
2276 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2277 input_file_stack->next = 0;
2278 input_file_stack->name = input_filename;
2280 /* Perform language-specific initialization.
2281 This may set main_input_filename. */
2282 lang_init ();
2284 /* If the input doesn't start with a #line, use the input name
2285 as the official input file name. */
2286 if (main_input_filename == 0)
2287 main_input_filename = name;
2289 if (!output_bytecode)
2291 ASM_FILE_START (asm_out_file);
2294 /* Output something to inform GDB that this compilation was by GCC. Also
2295 serves to tell GDB file consists of bytecodes. */
2296 if (output_bytecode)
2297 fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
2298 else
2300 #ifndef ASM_IDENTIFY_GCC
2301 fprintf (asm_out_file, "gcc2_compiled.:\n");
2302 #else
2303 ASM_IDENTIFY_GCC (asm_out_file);
2304 #endif
2307 /* Output something to identify which front-end produced this file. */
2308 #ifdef ASM_IDENTIFY_LANGUAGE
2309 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2310 #endif
2312 if (output_bytecode)
2314 if (profile_flag || profile_block_flag)
2315 error ("profiling not supported in bytecode compilation");
2317 else
2319 /* ??? Note: There used to be a conditional here
2320 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2321 This was to guarantee separation between gcc_compiled. and
2322 the first function, for the sake of dbx on Suns.
2323 However, having the extra zero here confused the Emacs
2324 code for unexec, and might confuse other programs too.
2325 Therefore, I took out that change.
2326 In future versions we should find another way to solve
2327 that dbx problem. -- rms, 23 May 93. */
2329 /* Don't let the first function fall at the same address
2330 as gcc_compiled., if profiling. */
2331 if (profile_flag || profile_block_flag)
2332 assemble_zeros (UNITS_PER_WORD);
2335 /* If dbx symbol table desired, initialize writing it
2336 and output the predefined types. */
2337 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2338 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2339 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2340 getdecls ()));
2341 #endif
2342 #ifdef SDB_DEBUGGING_INFO
2343 if (write_symbols == SDB_DEBUG)
2344 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2345 getdecls ()));
2346 #endif
2347 #ifdef DWARF_DEBUGGING_INFO
2348 if (write_symbols == DWARF_DEBUG)
2349 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2350 #endif
2352 /* Initialize yet another pass. */
2354 if (!output_bytecode)
2355 init_final (main_input_filename);
2357 start_time = get_run_time ();
2359 /* Call the parser, which parses the entire file
2360 (calling rest_of_compilation for each function). */
2362 if (yyparse () != 0)
2364 if (errorcount == 0)
2365 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2367 /* In case there were missing closebraces,
2368 get us back to the global binding level. */
2369 while (! global_bindings_p ())
2370 poplevel (0, 0, 0);
2373 /* Compilation is now finished except for writing
2374 what's left of the symbol table output. */
2376 parse_time += get_run_time () - start_time;
2378 parse_time -= integration_time;
2379 parse_time -= varconst_time;
2381 globals = getdecls ();
2383 /* Really define vars that have had only a tentative definition.
2384 Really output inline functions that must actually be callable
2385 and have not been output so far. */
2388 int len = list_length (globals);
2389 tree *vec = (tree *) alloca (sizeof (tree) * len);
2390 int i;
2391 tree decl;
2392 int reconsider = 1;
2394 /* Process the decls in reverse order--earliest first.
2395 Put them into VEC from back to front, then take out from front. */
2397 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2398 vec[len - i - 1] = decl;
2400 for (i = 0; i < len; i++)
2402 decl = vec[i];
2404 /* We're not deferring this any longer. */
2405 DECL_DEFER_OUTPUT (decl) = 0;
2407 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2408 && incomplete_decl_finalize_hook != 0)
2409 (*incomplete_decl_finalize_hook) (decl);
2412 /* Now emit any global variables or functions that we have been putting
2413 off. We need to loop in case one of the things emitted here
2414 references another one which comes earlier in the list. */
2415 while (reconsider)
2417 reconsider = 0;
2418 for (i = 0; i < len; i++)
2420 decl = vec[i];
2422 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2423 continue;
2425 /* Don't write out static consts, unless we still need them.
2427 We also keep static consts if not optimizing (for debugging).
2428 ??? They might be better written into the debug information.
2429 This is possible when using DWARF.
2431 A language processor that wants static constants to be always
2432 written out (even if it is not used) is responsible for
2433 calling rest_of_decl_compilation itself. E.g. the C front-end
2434 calls rest_of_decl_compilation from finish_decl.
2435 One motivation for this is that is conventional in some
2436 environments to write things like:
2437 static const char rcsid[] = "... version string ...";
2438 intending to force the string to be in the executable.
2440 A language processor that would prefer to have unneeded
2441 static constants "optimized away" would just defer writing
2442 them out until here. E.g. C++ does this, because static
2443 constants are often defined in header files.
2445 ??? A tempting alternative (for both C and C++) would be
2446 to force a constant to be written if and only if it is
2447 defined in a main file, as opposed to an include file. */
2449 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2450 && (! TREE_READONLY (decl)
2451 || TREE_PUBLIC (decl)
2452 || !optimize
2453 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2455 reconsider = 1;
2456 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2459 if (TREE_CODE (decl) == FUNCTION_DECL
2460 && DECL_INITIAL (decl) != 0
2461 && DECL_SAVED_INSNS (decl) != 0
2462 && (flag_keep_inline_functions
2463 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2465 reconsider = 1;
2466 temporary_allocation ();
2467 output_inline_function (decl);
2468 permanent_allocation (1);
2473 for (i = 0; i < len; i++)
2475 decl = vec[i];
2477 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2478 && ! TREE_ASM_WRITTEN (decl))
2479 /* Cancel the RTL for this decl so that, if debugging info
2480 output for global variables is still to come,
2481 this one will be omitted. */
2482 DECL_RTL (decl) = NULL;
2484 /* Warn about any function
2485 declared static but not defined.
2486 We don't warn about variables,
2487 because many programs have static variables
2488 that exist only to get some text into the object file. */
2489 if (TREE_CODE (decl) == FUNCTION_DECL
2490 && (warn_unused
2491 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2492 && DECL_INITIAL (decl) == 0
2493 && DECL_EXTERNAL (decl)
2494 && ! TREE_PUBLIC (decl))
2496 pedwarn_with_decl (decl,
2497 "`%s' declared `static' but never defined");
2498 /* This symbol is effectively an "extern" declaration now. */
2499 TREE_PUBLIC (decl) = 1;
2500 assemble_external (decl);
2503 /* Warn about static fns or vars defined but not used,
2504 but not about inline functions or static consts
2505 since defining those in header files is normal practice. */
2506 if (warn_unused
2507 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2508 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2509 && ! DECL_IN_SYSTEM_HEADER (decl)
2510 && ! DECL_EXTERNAL (decl)
2511 && ! TREE_PUBLIC (decl)
2512 && ! TREE_USED (decl)
2513 && ! DECL_REGISTER (decl)
2514 /* The TREE_USED bit for file-scope decls
2515 is kept in the identifier, to handle multiple
2516 external decls in different scopes. */
2517 && ! TREE_USED (DECL_NAME (decl)))
2518 warning_with_decl (decl, "`%s' defined but not used");
2520 #ifdef SDB_DEBUGGING_INFO
2521 /* The COFF linker can move initialized global vars to the end.
2522 And that can screw up the symbol ordering.
2523 By putting the symbols in that order to begin with,
2524 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2525 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2526 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2527 && ! DECL_EXTERNAL (decl)
2528 && DECL_RTL (decl) != 0)
2529 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2531 /* Output COFF information for non-global
2532 file-scope initialized variables. */
2533 if (write_symbols == SDB_DEBUG
2534 && TREE_CODE (decl) == VAR_DECL
2535 && DECL_INITIAL (decl)
2536 && ! DECL_EXTERNAL (decl)
2537 && DECL_RTL (decl) != 0
2538 && GET_CODE (DECL_RTL (decl)) == MEM)
2539 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2540 #endif /* SDB_DEBUGGING_INFO */
2541 #ifdef DWARF_DEBUGGING_INFO
2542 /* Output DWARF information for file-scope tentative data object
2543 declarations, file-scope (extern) function declarations (which
2544 had no corresponding body) and file-scope tagged type declarations
2545 and definitions which have not yet been forced out. */
2547 if (write_symbols == DWARF_DEBUG
2548 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2549 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2550 #endif
2554 /* Do dbx symbols */
2555 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2556 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2557 TIMEVAR (symout_time,
2559 dbxout_finish (asm_out_file, main_input_filename);
2561 #endif
2563 #ifdef DWARF_DEBUGGING_INFO
2564 if (write_symbols == DWARF_DEBUG)
2565 TIMEVAR (symout_time,
2567 dwarfout_finish ();
2569 #endif
2571 /* Output some stuff at end of file if nec. */
2573 if (!output_bytecode)
2575 end_final (main_input_filename);
2577 #ifdef ASM_FILE_END
2578 ASM_FILE_END (asm_out_file);
2579 #endif
2582 /* Language-specific end of compilation actions. */
2584 lang_finish ();
2586 if (output_bytecode)
2587 bc_write_file (asm_out_file);
2589 /* Close the dump files. */
2591 if (flag_gen_aux_info)
2593 fclose (aux_info_file);
2594 if (errorcount)
2595 unlink (aux_info_file_name);
2598 if (rtl_dump)
2599 fclose (rtl_dump_file);
2601 if (jump_opt_dump)
2602 fclose (jump_opt_dump_file);
2604 if (cse_dump)
2605 fclose (cse_dump_file);
2607 if (loop_dump)
2608 fclose (loop_dump_file);
2610 if (cse2_dump)
2611 fclose (cse2_dump_file);
2613 if (flow_dump)
2614 fclose (flow_dump_file);
2616 if (combine_dump)
2618 dump_combine_total_stats (combine_dump_file);
2619 fclose (combine_dump_file);
2622 if (sched_dump)
2623 fclose (sched_dump_file);
2625 if (local_reg_dump)
2626 fclose (local_reg_dump_file);
2628 if (global_reg_dump)
2629 fclose (global_reg_dump_file);
2631 if (sched2_dump)
2632 fclose (sched2_dump_file);
2634 if (jump2_opt_dump)
2635 fclose (jump2_opt_dump_file);
2637 if (dbr_sched_dump)
2638 fclose (dbr_sched_dump_file);
2640 #ifdef STACK_REGS
2641 if (stack_reg_dump)
2642 fclose (stack_reg_dump_file);
2643 #endif
2645 /* Close non-debugging input and output files. Take special care to note
2646 whether fclose returns an error, since the pages might still be on the
2647 buffer chain while the file is open. */
2649 fclose (finput);
2650 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2651 fatal_io_error (asm_file_name);
2653 /* Print the times. */
2655 if (! quiet_flag)
2657 fprintf (stderr,"\n");
2658 print_time ("parse", parse_time);
2660 if (!output_bytecode)
2662 print_time ("integration", integration_time);
2663 print_time ("jump", jump_time);
2664 print_time ("cse", cse_time);
2665 print_time ("loop", loop_time);
2666 print_time ("cse2", cse2_time);
2667 print_time ("flow", flow_time);
2668 print_time ("combine", combine_time);
2669 print_time ("sched", sched_time);
2670 print_time ("local-alloc", local_alloc_time);
2671 print_time ("global-alloc", global_alloc_time);
2672 print_time ("sched2", sched2_time);
2673 print_time ("dbranch", dbr_sched_time);
2674 print_time ("shorten-branch", shorten_branch_time);
2675 print_time ("stack-reg", stack_reg_time);
2676 print_time ("final", final_time);
2677 print_time ("varconst", varconst_time);
2678 print_time ("symout", symout_time);
2679 print_time ("dump", dump_time);
2684 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2685 and TYPE_DECL nodes.
2687 This does nothing for local (non-static) variables.
2688 Otherwise, it sets up the RTL and outputs any assembler code
2689 (label definition, storage allocation and initialization).
2691 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2692 the assembler symbol name to be used. TOP_LEVEL is nonzero
2693 if this declaration is not within a function. */
2695 void
2696 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2697 tree decl;
2698 char *asmspec;
2699 int top_level;
2700 int at_end;
2702 /* Declarations of variables, and of functions defined elsewhere. */
2704 /* The most obvious approach, to put an #ifndef around where
2705 this macro is used, doesn't work since it's inside a macro call. */
2706 #ifndef ASM_FINISH_DECLARE_OBJECT
2707 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2708 #endif
2710 /* Forward declarations for nested functions are not "external",
2711 but we need to treat them as if they were. */
2712 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2713 || TREE_CODE (decl) == FUNCTION_DECL)
2714 TIMEVAR (varconst_time,
2716 make_decl_rtl (decl, asmspec, top_level);
2717 /* Initialized extern variable exists to be replaced
2718 with its value, or represents something that will be
2719 output in another file. */
2720 if (! (TREE_CODE (decl) == VAR_DECL
2721 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2722 && DECL_INITIAL (decl) != 0
2723 && DECL_INITIAL (decl) != error_mark_node))
2724 /* Don't output anything
2725 when a tentative file-scope definition is seen.
2726 But at end of compilation, do output code for them. */
2727 if (! (! at_end && top_level
2728 && (DECL_INITIAL (decl) == 0
2729 || DECL_INITIAL (decl) == error_mark_node)))
2730 assemble_variable (decl, top_level, at_end, 0);
2731 if (decl == last_assemble_variable_decl)
2733 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2734 top_level, at_end);
2737 else if (DECL_REGISTER (decl) && asmspec != 0)
2739 if (decode_reg_name (asmspec) >= 0)
2741 DECL_RTL (decl) = 0;
2742 make_decl_rtl (decl, asmspec, top_level);
2744 else
2745 error ("invalid register name `%s' for register variable", asmspec);
2747 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2748 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2749 && TREE_CODE (decl) == TYPE_DECL)
2750 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2751 #endif
2752 #ifdef SDB_DEBUGGING_INFO
2753 else if (write_symbols == SDB_DEBUG && top_level
2754 && TREE_CODE (decl) == TYPE_DECL)
2755 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2756 #endif
2759 /* Called after finishing a record, union or enumeral type. */
2761 void
2762 rest_of_type_compilation (type, toplev)
2763 tree type;
2764 int toplev;
2766 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2767 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2768 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2769 #endif
2770 #ifdef SDB_DEBUGGING_INFO
2771 if (write_symbols == SDB_DEBUG)
2772 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2773 #endif
2776 /* This is called from finish_function (within yyparse)
2777 after each top-level definition is parsed.
2778 It is supposed to compile that function or variable
2779 and output the assembler code for it.
2780 After we return, the tree storage is freed. */
2782 void
2783 rest_of_compilation (decl)
2784 tree decl;
2786 register rtx insns;
2787 int start_time = get_run_time ();
2788 int tem;
2789 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2790 to be restored after we finish compiling the function
2791 (for use when compiling inline calls to this function). */
2792 tree saved_block_tree = 0;
2793 /* Likewise, for DECL_ARGUMENTS. */
2794 tree saved_arguments = 0;
2795 int failure = 0;
2797 if (output_bytecode)
2798 return;
2800 /* If we are reconsidering an inline function
2801 at the end of compilation, skip the stuff for making it inline. */
2803 if (DECL_SAVED_INSNS (decl) == 0)
2805 int specd = DECL_INLINE (decl);
2806 char *lose;
2808 /* If requested, consider whether to make this function inline. */
2809 if (specd || flag_inline_functions)
2810 TIMEVAR (integration_time,
2812 lose = function_cannot_inline_p (decl);
2813 /* If not optimzing, then make sure the DECL_INLINE
2814 bit is off. */
2815 if (lose || ! optimize)
2817 if (warn_inline && specd)
2818 warning_with_decl (decl, lose);
2819 DECL_INLINE (decl) = 0;
2820 DECL_ABSTRACT_ORIGIN (decl) = 0;
2821 /* Don't really compile an extern inline function.
2822 If we can't make it inline, pretend
2823 it was only declared. */
2824 if (DECL_EXTERNAL (decl))
2826 DECL_INITIAL (decl) = 0;
2827 goto exit_rest_of_compilation;
2830 else
2831 DECL_INLINE (decl) = 1;
2834 insns = get_insns ();
2836 /* Dump the rtl code if we are dumping rtl. */
2838 if (rtl_dump)
2839 TIMEVAR (dump_time,
2841 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2842 IDENTIFIER_POINTER (DECL_NAME (decl)));
2843 if (DECL_SAVED_INSNS (decl))
2844 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2845 print_rtl (rtl_dump_file, insns);
2846 fflush (rtl_dump_file);
2849 /* If function is inline, and we don't yet know whether to
2850 compile it by itself, defer decision till end of compilation.
2851 finish_compilation will call rest_of_compilation again
2852 for those functions that need to be output. Also defer those
2853 functions that we are supposed to defer. */
2855 if (DECL_DEFER_OUTPUT (decl)
2856 || (DECL_INLINE (decl)
2857 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2858 && ! flag_keep_inline_functions)
2859 || DECL_EXTERNAL (decl))))
2861 #ifdef DWARF_DEBUGGING_INFO
2862 /* Generate the DWARF info for the "abstract" instance
2863 of a function which we may later generate inlined and/or
2864 out-of-line instances of. */
2865 if (write_symbols == DWARF_DEBUG)
2867 set_decl_abstract_flags (decl, 1);
2868 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2869 set_decl_abstract_flags (decl, 0);
2871 #endif
2872 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2873 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 (DECL_INLINE (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));
2897 /* If specified extern inline but we aren't inlining it, we are
2898 done. */
2899 if (specd && DECL_EXTERNAL (decl))
2900 goto exit_rest_of_compilation;
2903 TREE_ASM_WRITTEN (decl) = 1;
2905 /* Now that integrate will no longer see our rtl, we need not distinguish
2906 between the return value of this function and the return value of called
2907 functions. */
2908 rtx_equal_function_value_matters = 0;
2910 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2911 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2913 goto exit_rest_of_compilation;
2916 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2917 Note that that may have been done above, in save_for_inline_copying.
2918 The call to resume_temporary_allocation near the end of this function
2919 goes back to the usual state of affairs. */
2921 rtl_in_current_obstack ();
2923 #ifdef FINALIZE_PIC
2924 /* If we are doing position-independent code generation, now
2925 is the time to output special prologues and epilogues.
2926 We do not want to do this earlier, because it just clutters
2927 up inline functions with meaningless insns. */
2928 if (flag_pic)
2929 FINALIZE_PIC;
2930 #endif
2932 insns = get_insns ();
2934 /* Copy any shared structure that should not be shared. */
2936 unshare_all_rtl (insns);
2938 /* Instantiate all virtual registers. */
2940 instantiate_virtual_regs (current_function_decl, get_insns ());
2942 /* See if we have allocated stack slots that are not directly addressable.
2943 If so, scan all the insns and create explicit address computation
2944 for all references to such slots. */
2945 /* fixup_stack_slots (); */
2947 /* Do jump optimization the first time, if -opt.
2948 Also do it if -W, but in that case it doesn't change the rtl code,
2949 it only computes whether control can drop off the end of the function. */
2951 if (optimize > 0 || extra_warnings || warn_return_type
2952 /* If function is `noreturn', we should warn if it tries to return. */
2953 || TREE_THIS_VOLATILE (decl))
2955 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2956 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2959 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2960 if (rtl_dump_and_exit || flag_syntax_only)
2961 goto exit_rest_of_compilation;
2963 /* Dump rtl code after jump, if we are doing that. */
2965 if (jump_opt_dump)
2966 TIMEVAR (dump_time,
2968 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2969 IDENTIFIER_POINTER (DECL_NAME (decl)));
2970 print_rtl (jump_opt_dump_file, insns);
2971 fflush (jump_opt_dump_file);
2974 /* Perform common subexpression elimination.
2975 Nonzero value from `cse_main' means that jumps were simplified
2976 and some code may now be unreachable, so do
2977 jump optimization again. */
2979 if (cse_dump)
2980 TIMEVAR (dump_time,
2982 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2983 IDENTIFIER_POINTER (DECL_NAME (decl)));
2986 if (optimize > 0)
2988 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2990 if (flag_thread_jumps)
2991 /* Hacks by tiemann & kenner. */
2992 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
2994 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2995 0, cse_dump_file));
2996 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2998 if (tem || optimize > 1)
2999 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3002 /* Dump rtl code after cse, if we are doing that. */
3004 if (cse_dump)
3005 TIMEVAR (dump_time,
3007 print_rtl (cse_dump_file, insns);
3008 fflush (cse_dump_file);
3011 if (loop_dump)
3012 TIMEVAR (dump_time,
3014 fprintf (loop_dump_file, "\n;; Function %s\n\n",
3015 IDENTIFIER_POINTER (DECL_NAME (decl)));
3018 /* Move constant computations out of loops. */
3020 if (optimize > 0)
3022 TIMEVAR (loop_time,
3024 loop_optimize (insns, loop_dump_file);
3028 /* Dump rtl code after loop opt, if we are doing that. */
3030 if (loop_dump)
3031 TIMEVAR (dump_time,
3033 print_rtl (loop_dump_file, insns);
3034 fflush (loop_dump_file);
3037 if (cse2_dump)
3038 TIMEVAR (dump_time,
3040 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
3041 IDENTIFIER_POINTER (DECL_NAME (decl)));
3044 if (optimize > 0 && flag_rerun_cse_after_loop)
3046 /* Running another jump optimization pass before the second
3047 cse pass sometimes simplifies the RTL enough to allow
3048 the second CSE pass to do a better job. Jump_optimize can change
3049 max_reg_num so we must rerun reg_scan afterwards.
3050 ??? Rework to not call reg_scan so often. */
3051 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3052 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3054 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3055 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3056 1, cse2_dump_file));
3057 if (tem)
3058 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3061 if (optimize > 0 && flag_thread_jumps)
3062 /* This pass of jump threading straightens out code
3063 that was kinked by loop optimization. */
3064 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3066 /* Dump rtl code after cse, if we are doing that. */
3068 if (cse2_dump)
3069 TIMEVAR (dump_time,
3071 print_rtl (cse2_dump_file, insns);
3072 fflush (cse2_dump_file);
3075 /* We are no longer anticipating cse in this function, at least. */
3077 cse_not_expected = 1;
3079 /* Now we choose between stupid (pcc-like) register allocation
3080 (if we got the -noreg switch and not -opt)
3081 and smart register allocation. */
3083 if (optimize > 0) /* Stupid allocation probably won't work */
3084 obey_regdecls = 0; /* if optimizations being done. */
3086 regclass_init ();
3088 /* Print function header into flow dump now
3089 because doing the flow analysis makes some of the dump. */
3091 if (flow_dump)
3092 TIMEVAR (dump_time,
3094 fprintf (flow_dump_file, "\n;; Function %s\n\n",
3095 IDENTIFIER_POINTER (DECL_NAME (decl)));
3098 if (obey_regdecls)
3100 TIMEVAR (flow_time,
3102 regclass (insns, max_reg_num ());
3103 stupid_life_analysis (insns, max_reg_num (),
3104 flow_dump_file);
3107 else
3109 /* Do control and data flow analysis,
3110 and write some of the results to dump file. */
3112 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
3113 flow_dump_file));
3114 if (warn_uninitialized)
3116 uninitialized_vars_warning (DECL_INITIAL (decl));
3117 setjmp_args_warning ();
3121 /* Dump rtl after flow analysis. */
3123 if (flow_dump)
3124 TIMEVAR (dump_time,
3126 print_rtl (flow_dump_file, insns);
3127 fflush (flow_dump_file);
3130 /* If -opt, try combining insns through substitution. */
3132 if (optimize > 0)
3133 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3135 /* Dump rtl code after insn combination. */
3137 if (combine_dump)
3138 TIMEVAR (dump_time,
3140 fprintf (combine_dump_file, "\n;; Function %s\n\n",
3141 IDENTIFIER_POINTER (DECL_NAME (decl)));
3142 dump_combine_stats (combine_dump_file);
3143 print_rtl (combine_dump_file, insns);
3144 fflush (combine_dump_file);
3147 /* Print function header into sched dump now
3148 because doing the sched analysis makes some of the dump. */
3150 if (sched_dump)
3151 TIMEVAR (dump_time,
3153 fprintf (sched_dump_file, "\n;; Function %s\n\n",
3154 IDENTIFIER_POINTER (DECL_NAME (decl)));
3157 if (optimize > 0 && flag_schedule_insns)
3159 /* Do control and data sched analysis,
3160 and write some of the results to dump file. */
3162 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
3165 /* Dump rtl after instruction scheduling. */
3167 if (sched_dump)
3168 TIMEVAR (dump_time,
3170 print_rtl (sched_dump_file, insns);
3171 fflush (sched_dump_file);
3174 /* Unless we did stupid register allocation,
3175 allocate pseudo-regs that are used only within 1 basic block. */
3177 if (!obey_regdecls)
3178 TIMEVAR (local_alloc_time,
3180 regclass (insns, max_reg_num ());
3181 local_alloc ();
3184 /* Dump rtl code after allocating regs within basic blocks. */
3186 if (local_reg_dump)
3187 TIMEVAR (dump_time,
3189 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
3190 IDENTIFIER_POINTER (DECL_NAME (decl)));
3191 dump_flow_info (local_reg_dump_file);
3192 dump_local_alloc (local_reg_dump_file);
3193 print_rtl (local_reg_dump_file, insns);
3194 fflush (local_reg_dump_file);
3197 if (global_reg_dump)
3198 TIMEVAR (dump_time,
3199 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
3200 IDENTIFIER_POINTER (DECL_NAME (decl))));
3202 /* Unless we did stupid register allocation,
3203 allocate remaining pseudo-regs, then do the reload pass
3204 fixing up any insns that are invalid. */
3206 TIMEVAR (global_alloc_time,
3208 if (!obey_regdecls)
3209 failure = global_alloc (global_reg_dump_file);
3210 else
3211 failure = reload (insns, 0, global_reg_dump_file);
3214 if (global_reg_dump)
3215 TIMEVAR (dump_time,
3217 dump_global_regs (global_reg_dump_file);
3218 print_rtl (global_reg_dump_file, insns);
3219 fflush (global_reg_dump_file);
3222 if (failure)
3223 goto exit_rest_of_compilation;
3225 reload_completed = 1;
3227 /* On some machines, the prologue and epilogue code, or parts thereof,
3228 can be represented as RTL. Doing so lets us schedule insns between
3229 it and the rest of the code and also allows delayed branch
3230 scheduling to operate in the epilogue. */
3232 thread_prologue_and_epilogue_insns (insns);
3234 if (optimize > 0 && flag_schedule_insns_after_reload)
3236 if (sched2_dump)
3237 TIMEVAR (dump_time,
3239 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
3240 IDENTIFIER_POINTER (DECL_NAME (decl)));
3243 /* Do control and data sched analysis again,
3244 and write some more of the results to dump file. */
3246 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
3248 /* Dump rtl after post-reorder instruction scheduling. */
3250 if (sched2_dump)
3251 TIMEVAR (dump_time,
3253 print_rtl (sched2_dump_file, insns);
3254 fflush (sched2_dump_file);
3258 #ifdef LEAF_REGISTERS
3259 leaf_function = 0;
3260 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3261 leaf_function = 1;
3262 #endif
3264 /* One more attempt to remove jumps to .+1
3265 left by dead-store-elimination.
3266 Also do cross-jumping this time
3267 and delete no-op move insns. */
3269 if (optimize > 0)
3271 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3274 /* Dump rtl code after jump, if we are doing that. */
3276 if (jump2_opt_dump)
3277 TIMEVAR (dump_time,
3279 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
3280 IDENTIFIER_POINTER (DECL_NAME (decl)));
3281 print_rtl (jump2_opt_dump_file, insns);
3282 fflush (jump2_opt_dump_file);
3285 /* If a machine dependent reorganization is needed, call it. */
3286 #ifdef MACHINE_DEPENDENT_REORG
3287 MACHINE_DEPENDENT_REORG (insns);
3288 #endif
3290 /* If a scheduling pass for delayed branches is to be done,
3291 call the scheduling code. */
3293 #ifdef DELAY_SLOTS
3294 if (optimize > 0 && flag_delayed_branch)
3296 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3297 if (dbr_sched_dump)
3299 TIMEVAR (dump_time,
3301 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
3302 IDENTIFIER_POINTER (DECL_NAME (decl)));
3303 print_rtl (dbr_sched_dump_file, insns);
3304 fflush (dbr_sched_dump_file);
3308 #endif
3310 if (optimize > 0)
3311 /* Shorten branches. */
3312 TIMEVAR (shorten_branch_time,
3314 shorten_branches (get_insns ());
3317 #ifdef STACK_REGS
3318 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3319 if (stack_reg_dump)
3321 TIMEVAR (dump_time,
3323 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
3324 IDENTIFIER_POINTER (DECL_NAME (decl)));
3325 print_rtl (stack_reg_dump_file, insns);
3326 fflush (stack_reg_dump_file);
3329 #endif
3331 /* Now turn the rtl into assembler code. */
3333 TIMEVAR (final_time,
3335 rtx x;
3336 char *fnname;
3338 /* Get the function's name, as described by its RTL.
3339 This may be different from the DECL_NAME name used
3340 in the source file. */
3342 x = DECL_RTL (decl);
3343 if (GET_CODE (x) != MEM)
3344 abort ();
3345 x = XEXP (x, 0);
3346 if (GET_CODE (x) != SYMBOL_REF)
3347 abort ();
3348 fnname = XSTR (x, 0);
3350 assemble_start_function (decl, fnname);
3351 final_start_function (insns, asm_out_file, optimize);
3352 final (insns, asm_out_file, optimize, 0);
3353 final_end_function (insns, asm_out_file, optimize);
3354 assemble_end_function (decl, fnname);
3355 fflush (asm_out_file);
3358 /* Write DBX symbols if requested */
3360 /* Note that for those inline functions where we don't initially
3361 know for certain that we will be generating an out-of-line copy,
3362 the first invocation of this routine (rest_of_compilation) will
3363 skip over this code by doing a `goto exit_rest_of_compilation;'.
3364 Later on, finish_compilation will call rest_of_compilation again
3365 for those inline functions that need to have out-of-line copies
3366 generated. During that call, we *will* be routed past here. */
3368 #ifdef DBX_DEBUGGING_INFO
3369 if (write_symbols == DBX_DEBUG)
3370 TIMEVAR (symout_time, dbxout_function (decl));
3371 #endif
3373 #ifdef DWARF_DEBUGGING_INFO
3374 if (write_symbols == DWARF_DEBUG)
3375 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3376 #endif
3378 exit_rest_of_compilation:
3380 /* In case the function was not output,
3381 don't leave any temporary anonymous types
3382 queued up for sdb output. */
3383 #ifdef SDB_DEBUGGING_INFO
3384 if (write_symbols == SDB_DEBUG)
3385 sdbout_types (NULL_TREE);
3386 #endif
3388 /* Put back the tree of subblocks and list of arguments
3389 from before we copied them.
3390 Code generation and the output of debugging info may have modified
3391 the copy, but the original is unchanged. */
3393 if (saved_block_tree != 0)
3394 DECL_INITIAL (decl) = saved_block_tree;
3395 if (saved_arguments != 0)
3396 DECL_ARGUMENTS (decl) = saved_arguments;
3398 reload_completed = 0;
3400 /* Clear out the real_constant_chain before some of the rtx's
3401 it runs through become garbage. */
3403 clear_const_double_mem ();
3405 /* Cancel the effect of rtl_in_current_obstack. */
3407 resume_temporary_allocation ();
3409 /* The parsing time is all the time spent in yyparse
3410 *except* what is spent in this function. */
3412 parse_time -= get_run_time () - start_time;
3415 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3416 Exit code is 35 if can't open files, 34 if fatal error,
3417 33 if had nonfatal errors, else success. */
3420 main (argc, argv, envp)
3421 int argc;
3422 char **argv;
3423 char **envp;
3425 register int i;
3426 char *filename = 0;
3427 int flag_print_mem = 0;
3428 int version_flag = 0;
3429 char *p;
3431 /* save in case md file wants to emit args as a comment. */
3432 save_argc = argc;
3433 save_argv = argv;
3435 p = argv[0] + strlen (argv[0]);
3436 while (p != argv[0] && p[-1] != '/'
3437 #ifdef DIR_SEPARATOR
3438 && p[-1] != DIR_SEPARATOR
3439 #endif
3441 --p;
3442 progname = p;
3444 #ifdef RLIMIT_STACK
3445 /* Get rid of any avoidable limit on stack size. */
3447 struct rlimit rlim;
3449 /* Set the stack limit huge so that alloca does not fail. */
3450 getrlimit (RLIMIT_STACK, &rlim);
3451 rlim.rlim_cur = rlim.rlim_max;
3452 setrlimit (RLIMIT_STACK, &rlim);
3454 #endif /* RLIMIT_STACK */
3456 signal (SIGFPE, float_signal);
3458 #ifdef SIGPIPE
3459 signal (SIGPIPE, pipe_closed);
3460 #endif
3462 decl_printable_name = decl_name;
3463 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3464 interim_eh_hook = interim_eh;
3466 /* Initialize whether `char' is signed. */
3467 flag_signed_char = DEFAULT_SIGNED_CHAR;
3468 #ifdef DEFAULT_SHORT_ENUMS
3469 /* Initialize how much space enums occupy, by default. */
3470 flag_short_enums = DEFAULT_SHORT_ENUMS;
3471 #endif
3473 /* Scan to see what optimization level has been specified. That will
3474 determine the default value of many flags. */
3475 for (i = 1; i < argc; i++)
3477 if (!strcmp (argv[i], "-O"))
3479 optimize = 1;
3481 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3483 /* Handle -O2, -O3, -O69, ... */
3484 char *p = &argv[i][2];
3485 int c;
3487 while (c = *p++)
3488 if (! (c >= '0' && c <= '9'))
3489 break;
3490 if (c == 0)
3491 optimize = atoi (&argv[i][2]);
3495 obey_regdecls = (optimize == 0);
3496 if (optimize == 0)
3498 flag_no_inline = 1;
3499 warn_inline = 0;
3502 if (optimize >= 1)
3504 flag_defer_pop = 1;
3505 flag_thread_jumps = 1;
3506 #ifdef DELAY_SLOTS
3507 flag_delayed_branch = 1;
3508 #endif
3509 #ifdef CAN_DEBUG_WITHOUT_FP
3510 flag_omit_frame_pointer = 1;
3511 #endif
3514 if (optimize >= 2)
3516 flag_cse_follow_jumps = 1;
3517 flag_cse_skip_blocks = 1;
3518 flag_expensive_optimizations = 1;
3519 flag_strength_reduce = 1;
3520 flag_rerun_cse_after_loop = 1;
3521 flag_caller_saves = 1;
3522 #ifdef INSN_SCHEDULING
3523 flag_schedule_insns = 1;
3524 flag_schedule_insns_after_reload = 1;
3525 #endif
3528 if (optimize >= 3)
3530 flag_inline_functions = 1;
3533 #ifdef OPTIMIZATION_OPTIONS
3534 /* Allow default optimizations to be specified on a per-machine basis. */
3535 OPTIMIZATION_OPTIONS (optimize);
3536 #endif
3538 /* Initialize register usage now so switches may override. */
3539 init_reg_sets ();
3541 target_flags = 0;
3542 set_target_switch ("");
3544 for (i = 1; i < argc; i++)
3546 int j;
3547 /* If this is a language-specific option,
3548 decode it in a language-specific way. */
3549 for (j = 0; lang_options[j] != 0; j++)
3550 if (!strncmp (argv[i], lang_options[j],
3551 strlen (lang_options[j])))
3552 break;
3553 if (lang_options[j] != 0)
3554 /* If the option is valid for *some* language,
3555 treat it as valid even if this language doesn't understand it. */
3556 lang_decode_option (argv[i]);
3557 else if (argv[i][0] == '-' && argv[i][1] != 0)
3559 register char *str = argv[i] + 1;
3560 if (str[0] == 'Y')
3561 str++;
3563 if (str[0] == 'm')
3564 set_target_switch (&str[1]);
3565 else if (!strcmp (str, "dumpbase"))
3567 dump_base_name = argv[++i];
3569 else if (str[0] == 'd')
3571 register char *p = &str[1];
3572 while (*p)
3573 switch (*p++)
3575 case 'a':
3576 combine_dump = 1;
3577 dbr_sched_dump = 1;
3578 flow_dump = 1;
3579 global_reg_dump = 1;
3580 jump_opt_dump = 1;
3581 jump2_opt_dump = 1;
3582 local_reg_dump = 1;
3583 loop_dump = 1;
3584 rtl_dump = 1;
3585 cse_dump = 1, cse2_dump = 1;
3586 sched_dump = 1;
3587 sched2_dump = 1;
3588 stack_reg_dump = 1;
3589 break;
3590 case 'k':
3591 stack_reg_dump = 1;
3592 break;
3593 case 'c':
3594 combine_dump = 1;
3595 break;
3596 case 'd':
3597 dbr_sched_dump = 1;
3598 break;
3599 case 'f':
3600 flow_dump = 1;
3601 break;
3602 case 'g':
3603 global_reg_dump = 1;
3604 break;
3605 case 'j':
3606 jump_opt_dump = 1;
3607 break;
3608 case 'J':
3609 jump2_opt_dump = 1;
3610 break;
3611 case 'l':
3612 local_reg_dump = 1;
3613 break;
3614 case 'L':
3615 loop_dump = 1;
3616 break;
3617 case 'm':
3618 flag_print_mem = 1;
3619 break;
3620 case 'p':
3621 flag_print_asm_name = 1;
3622 break;
3623 case 'r':
3624 rtl_dump = 1;
3625 break;
3626 case 's':
3627 cse_dump = 1;
3628 break;
3629 case 't':
3630 cse2_dump = 1;
3631 break;
3632 case 'S':
3633 sched_dump = 1;
3634 break;
3635 case 'R':
3636 sched2_dump = 1;
3637 break;
3638 case 'y':
3639 set_yydebug (1);
3640 break;
3642 case 'x':
3643 rtl_dump_and_exit = 1;
3644 break;
3647 else if (str[0] == 'f')
3649 register char *p = &str[1];
3650 int found = 0;
3652 /* Some kind of -f option.
3653 P's value is the option sans `-f'.
3654 Search for it in the table of options. */
3656 for (j = 0;
3657 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3658 j++)
3660 if (!strcmp (p, f_options[j].string))
3662 *f_options[j].variable = f_options[j].on_value;
3663 /* A goto here would be cleaner,
3664 but breaks the vax pcc. */
3665 found = 1;
3667 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3668 && ! strcmp (p+3, f_options[j].string))
3670 *f_options[j].variable = ! f_options[j].on_value;
3671 found = 1;
3675 if (found)
3677 else if (!strncmp (p, "fixed-", 6))
3678 fix_register (&p[6], 1, 1);
3679 else if (!strncmp (p, "call-used-", 10))
3680 fix_register (&p[10], 0, 1);
3681 else if (!strncmp (p, "call-saved-", 11))
3682 fix_register (&p[11], 0, 0);
3683 else
3684 error ("Invalid option `%s'", argv[i]);
3686 else if (str[0] == 'O')
3688 register char *p = str+1;
3689 while (*p && *p >= '0' && *p <= '9')
3690 p++;
3691 if (*p == '\0')
3693 else
3694 error ("Invalid option `%s'", argv[i]);
3696 else if (!strcmp (str, "pedantic"))
3697 pedantic = 1;
3698 else if (!strcmp (str, "pedantic-errors"))
3699 flag_pedantic_errors = pedantic = 1;
3700 else if (!strcmp (str, "quiet"))
3701 quiet_flag = 1;
3702 else if (!strcmp (str, "version"))
3703 version_flag = 1;
3704 else if (!strcmp (str, "w"))
3705 inhibit_warnings = 1;
3706 else if (!strcmp (str, "W"))
3708 extra_warnings = 1;
3709 /* We save the value of warn_uninitialized, since if they put
3710 -Wuninitialized on the command line, we need to generate a
3711 warning about not using it without also specifying -O. */
3712 if (warn_uninitialized != 1)
3713 warn_uninitialized = 2;
3715 else if (str[0] == 'W')
3717 register char *p = &str[1];
3718 int found = 0;
3720 /* Some kind of -W option.
3721 P's value is the option sans `-W'.
3722 Search for it in the table of options. */
3724 for (j = 0;
3725 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3726 j++)
3728 if (!strcmp (p, W_options[j].string))
3730 *W_options[j].variable = W_options[j].on_value;
3731 /* A goto here would be cleaner,
3732 but breaks the vax pcc. */
3733 found = 1;
3735 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3736 && ! strcmp (p+3, W_options[j].string))
3738 *W_options[j].variable = ! W_options[j].on_value;
3739 found = 1;
3743 if (found)
3745 else if (!strncmp (p, "id-clash-", 9))
3747 char *endp = p + 9;
3749 while (*endp)
3751 if (*endp >= '0' && *endp <= '9')
3752 endp++;
3753 else
3755 error ("Invalid option `%s'", argv[i]);
3756 goto id_clash_lose;
3759 warn_id_clash = 1;
3760 id_clash_len = atoi (str + 10);
3761 id_clash_lose: ;
3763 else if (!strncmp (p, "larger-than-", 12))
3765 char *endp = p + 12;
3767 while (*endp)
3769 if (*endp >= '0' && *endp <= '9')
3770 endp++;
3771 else
3773 error ("Invalid option `%s'", argv[i]);
3774 goto larger_than_lose;
3777 warn_larger_than = 1;
3778 larger_than_size = atoi (str + 13);
3779 larger_than_lose: ;
3781 else
3782 error ("Invalid option `%s'", argv[i]);
3784 else if (!strcmp (str, "p"))
3786 if (!output_bytecode)
3787 profile_flag = 1;
3788 else
3789 error ("profiling not supported in bytecode compilation");
3791 else if (!strcmp (str, "a"))
3793 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3794 warning ("`-a' option (basic block profile) not supported");
3795 #else
3796 profile_block_flag = 1;
3797 #endif
3799 else if (str[0] == 'g')
3801 char *p = str + 1;
3802 char *q;
3803 unsigned len;
3804 unsigned level;
3806 while (*p && (*p < '0' || *p > '9'))
3807 p++;
3808 len = p - str;
3809 q = p;
3810 while (*q && (*q >= '0' && *q <= '9'))
3811 q++;
3812 if (*p)
3813 level = atoi (p);
3814 else
3815 level = 2; /* default debugging info level */
3816 if (*q || level > 3)
3818 warning ("invalid debug level specification in option: `-%s'",
3819 str);
3820 warning ("no debugging information will be generated");
3821 level = 0;
3824 /* If more than one debugging type is supported,
3825 you must define PREFERRED_DEBUGGING_TYPE
3826 to choose a format in a system-dependent way. */
3827 /* This is one long line cause VAXC can't handle a \-newline. */
3828 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3829 #ifdef PREFERRED_DEBUGGING_TYPE
3830 if (!strncmp (str, "ggdb", len))
3831 write_symbols = PREFERRED_DEBUGGING_TYPE;
3832 #else /* no PREFERRED_DEBUGGING_TYPE */
3833 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3834 #endif /* no PREFERRED_DEBUGGING_TYPE */
3835 #endif /* More than one debugger format enabled. */
3836 #ifdef DBX_DEBUGGING_INFO
3837 if (write_symbols != NO_DEBUG)
3839 else if (!strncmp (str, "ggdb", len))
3840 write_symbols = DBX_DEBUG;
3841 else if (!strncmp (str, "gstabs", len))
3842 write_symbols = DBX_DEBUG;
3843 else if (!strncmp (str, "gstabs+", len))
3844 write_symbols = DBX_DEBUG;
3846 /* Always enable extensions for -ggdb or -gstabs+,
3847 always disable for -gstabs.
3848 For plain -g, use system-specific default. */
3849 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3850 && len >= 2)
3851 use_gnu_debug_info_extensions = 1;
3852 else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
3853 && len >= 7)
3854 use_gnu_debug_info_extensions = 1;
3855 else if (write_symbols == DBX_DEBUG
3856 && !strncmp (str, "gstabs", len) && len >= 2)
3857 use_gnu_debug_info_extensions = 0;
3858 else
3859 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3860 #endif /* DBX_DEBUGGING_INFO */
3861 #ifdef DWARF_DEBUGGING_INFO
3862 if (write_symbols != NO_DEBUG)
3864 else if (!strncmp (str, "g", len))
3865 write_symbols = DWARF_DEBUG;
3866 else if (!strncmp (str, "ggdb", len))
3867 write_symbols = DWARF_DEBUG;
3868 else if (!strncmp (str, "gdwarf", len))
3869 write_symbols = DWARF_DEBUG;
3871 /* Always enable extensions for -ggdb or -gdwarf+,
3872 always disable for -gdwarf.
3873 For plain -g, use system-specific default. */
3874 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3875 && len >= 2)
3876 use_gnu_debug_info_extensions = 1;
3877 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3878 use_gnu_debug_info_extensions = 1;
3879 else if (write_symbols == DWARF_DEBUG
3880 && !strncmp (str, "gdwarf", len) && len >= 2)
3881 use_gnu_debug_info_extensions = 0;
3882 else
3883 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3884 #endif
3885 #ifdef SDB_DEBUGGING_INFO
3886 if (write_symbols != NO_DEBUG)
3888 else if (!strncmp (str, "g", len))
3889 write_symbols = SDB_DEBUG;
3890 else if (!strncmp (str, "gdb", len))
3891 write_symbols = SDB_DEBUG;
3892 else if (!strncmp (str, "gcoff", len))
3893 write_symbols = SDB_DEBUG;
3894 #endif /* SDB_DEBUGGING_INFO */
3895 #ifdef XCOFF_DEBUGGING_INFO
3896 if (write_symbols != NO_DEBUG)
3898 else if (!strncmp (str, "g", len))
3899 write_symbols = XCOFF_DEBUG;
3900 else if (!strncmp (str, "ggdb", len))
3901 write_symbols = XCOFF_DEBUG;
3902 else if (!strncmp (str, "gxcoff", len))
3903 write_symbols = XCOFF_DEBUG;
3905 /* Always enable extensions for -ggdb or -gxcoff+,
3906 always disable for -gxcoff.
3907 For plain -g, use system-specific default. */
3908 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3909 && len >= 2)
3910 use_gnu_debug_info_extensions = 1;
3911 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3912 use_gnu_debug_info_extensions = 1;
3913 else if (write_symbols == XCOFF_DEBUG
3914 && !strncmp (str, "gxcoff", len) && len >= 2)
3915 use_gnu_debug_info_extensions = 0;
3916 else
3917 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3918 #endif
3919 if (write_symbols == NO_DEBUG)
3920 warning ("`-%s' option not supported on this version of GCC", str);
3921 else if (level == 0)
3922 write_symbols = NO_DEBUG;
3923 else
3924 debug_info_level = (enum debug_info_level) level;
3926 else if (!strcmp (str, "o"))
3928 asm_file_name = argv[++i];
3930 else if (str[0] == 'G')
3932 g_switch_set = TRUE;
3933 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3935 else if (!strncmp (str, "aux-info", 8))
3937 flag_gen_aux_info = 1;
3938 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3940 else
3941 error ("Invalid option `%s'", argv[i]);
3943 else if (argv[i][0] == '+')
3944 error ("Invalid option `%s'", argv[i]);
3945 else
3946 filename = argv[i];
3949 /* Initialize for bytecode output. A good idea to do this as soon as
3950 possible after the "-f" options have been parsed. */
3951 if (output_bytecode)
3953 #ifndef TARGET_SUPPORTS_BYTECODE
3954 /* Just die with a fatal error if not supported */
3955 fatal ("-fbytecode not supporter for this target");
3956 #else
3957 bc_initialize ();
3958 #endif
3961 if (optimize == 0)
3963 /* Inlining does not work if not optimizing,
3964 so force it not to be done. */
3965 flag_no_inline = 1;
3966 warn_inline = 0;
3968 /* The c_decode_option and lang_decode_option functions set
3969 this to `2' if -Wall is used, so we can avoid giving out
3970 lots of errors for people who don't realize what -Wall does. */
3971 if (warn_uninitialized == 1)
3972 warning ("-Wuninitialized is not supported without -O");
3975 #if defined(DWARF_DEBUGGING_INFO)
3976 if (write_symbols == DWARF_DEBUG
3977 && strcmp (language_string, "GNU C++") == 0)
3979 warning ("-g option not supported for C++ on SVR4 systems");
3980 write_symbols = NO_DEBUG;
3982 #endif /* defined(DWARF_DEBUGGING_INFO) */
3984 #ifdef OVERRIDE_OPTIONS
3985 /* Some machines may reject certain combinations of options. */
3986 OVERRIDE_OPTIONS;
3987 #endif
3989 /* Unrolling all loops implies that standard loop unrolling must also
3990 be done. */
3991 if (flag_unroll_all_loops)
3992 flag_unroll_loops = 1;
3993 /* Loop unrolling requires that strength_reduction be on also. Silently
3994 turn on strength reduction here if it isn't already on. Also, the loop
3995 unrolling code assumes that cse will be run after loop, so that must
3996 be turned on also. */
3997 if (flag_unroll_loops)
3999 flag_strength_reduce = 1;
4000 flag_rerun_cse_after_loop = 1;
4003 /* Warn about options that are not supported on this machine. */
4004 #ifndef INSN_SCHEDULING
4005 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4006 warning ("instruction scheduling not supported on this target machine");
4007 #endif
4008 #ifndef DELAY_SLOTS
4009 if (flag_delayed_branch)
4010 warning ("this target machine does not have delayed branches");
4011 #endif
4013 /* If we are in verbose mode, write out the version and maybe all the
4014 option flags in use. */
4015 if (version_flag)
4017 fprintf (stderr, "%s version %s", language_string, version_string);
4018 #ifdef TARGET_VERSION
4019 TARGET_VERSION;
4020 #endif
4021 #ifdef __GNUC__
4022 #ifndef __VERSION__
4023 #define __VERSION__ "[unknown]"
4024 #endif
4025 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
4026 #else
4027 fprintf (stderr, " compiled by CC.\n");
4028 #endif
4029 if (! quiet_flag)
4030 print_switch_values ();
4033 compile_file (filename);
4035 #if !defined(OS2) && !defined(VMS) && !defined(WINNT)
4036 if (flag_print_mem)
4038 #ifdef __alpha
4039 char *sbrk ();
4040 #endif
4041 char *lim = (char *) sbrk (0);
4043 fprintf (stderr, "Data size %d.\n",
4044 lim - (char *) &environ);
4045 fflush (stderr);
4047 #ifdef USG
4048 system ("ps -l 1>&2");
4049 #else /* not USG */
4050 system ("ps v");
4051 #endif /* not USG */
4053 #endif /* not OS2 and not VMS and not WINNT */
4055 if (errorcount)
4056 exit (FATAL_EXIT_CODE);
4057 if (sorrycount)
4058 exit (FATAL_EXIT_CODE);
4059 exit (SUCCESS_EXIT_CODE);
4060 return 34;
4063 /* Decode -m switches. */
4065 /* Here is a table, controlled by the tm.h file, listing each -m switch
4066 and which bits in `target_switches' it should set or clear.
4067 If VALUE is positive, it is bits to set.
4068 If VALUE is negative, -VALUE is bits to clear.
4069 (The sign bit is not used so there is no confusion.) */
4071 struct {char *name; int value;} target_switches []
4072 = TARGET_SWITCHES;
4074 /* This table is similar, but allows the switch to have a value. */
4076 #ifdef TARGET_OPTIONS
4077 struct {char *prefix; char ** variable;} target_options []
4078 = TARGET_OPTIONS;
4079 #endif
4081 /* Decode the switch -mNAME. */
4083 void
4084 set_target_switch (name)
4085 char *name;
4087 register int j;
4088 int valid = 0;
4090 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4091 if (!strcmp (target_switches[j].name, name))
4093 if (target_switches[j].value < 0)
4094 target_flags &= ~-target_switches[j].value;
4095 else
4096 target_flags |= target_switches[j].value;
4097 valid = 1;
4100 #ifdef TARGET_OPTIONS
4101 if (!valid)
4102 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4104 int len = strlen (target_options[j].prefix);
4105 if (!strncmp (target_options[j].prefix, name, len))
4107 *target_options[j].variable = name + len;
4108 valid = 1;
4111 #endif
4113 if (!valid)
4114 error ("Invalid option `%s'", name);
4117 /* Variable used for communication between the following two routines. */
4119 static int line_position;
4121 /* Print an option value and adjust the position in the line. */
4123 static void
4124 print_single_switch (type, name)
4125 char *type, *name;
4127 fprintf (stderr, " %s%s", type, name);
4129 line_position += strlen (type) + strlen (name) + 1;
4131 if (line_position > 65)
4133 fprintf (stderr, "\n\t");
4134 line_position = 8;
4138 /* Print default target switches for -version. */
4140 static void
4141 print_switch_values ()
4143 register int j;
4145 fprintf (stderr, "enabled:");
4146 line_position = 8;
4148 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4149 if (*f_options[j].variable == f_options[j].on_value)
4150 print_single_switch ("-f", f_options[j].string);
4152 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
4153 if (*W_options[j].variable == W_options[j].on_value)
4154 print_single_switch ("-W", W_options[j].string);
4156 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4157 if (target_switches[j].name[0] != '\0'
4158 && target_switches[j].value > 0
4159 && ((target_switches[j].value & target_flags)
4160 == target_switches[j].value))
4161 print_single_switch ("-m", target_switches[j].name);
4163 fprintf (stderr, "\n");