(distribute_notes, case REG_DEAD): If a call uses a
[official-gcc.git] / gcc / toplev.c
blobf73a60adb070e4d50f3d53d963977a9219e46e61
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92, 93, 1994 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. */
21 /* This is the top level of cc1/c++.
22 It parses command args, opens files, invokes the various passes
23 in the proper order, and counts the time used by each.
24 Error messages and low-level interface to malloc also handled here. */
26 #include "config.h"
27 #ifdef __STDC__
28 #include <stdarg.h>
29 #else
30 #include <varargs.h>
31 #endif
32 #include <stdio.h>
33 #include <signal.h>
34 #include <setjmp.h>
35 #include <sys/types.h>
36 #include <ctype.h>
37 #include <sys/stat.h>
39 #ifdef USG
40 #undef FLOAT
41 #include <sys/param.h>
42 /* This is for hpux. It is a real screw. They should change hpux. */
43 #undef FLOAT
44 #include <sys/times.h>
45 #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
46 #undef FFS /* Some systems define this in param.h. */
47 #else
48 #ifndef VMS
49 #include <sys/time.h>
50 #include <sys/resource.h>
51 #endif
52 #endif
54 #include "input.h"
55 #include "tree.h"
56 /* #include "c-tree.h" */
57 #include "rtl.h"
58 #include "flags.h"
59 #include "insn-attr.h"
60 #include "defaults.h"
62 #ifdef XCOFF_DEBUGGING_INFO
63 #include "xcoffout.h"
64 #endif
66 #include "bytecode.h"
67 #include "bc-emit.h"
69 #ifdef VMS
70 /* The extra parameters substantially improve the I/O performance. */
71 static FILE *
72 VMS_fopen (fname, type)
73 char * fname;
74 char * type;
76 if (strcmp (type, "w") == 0)
77 return fopen (fname, type, "mbc=16", "deq=64", "fop=tef", "shr=nil");
78 return fopen (fname, type, "mbc=16");
80 #define fopen VMS_fopen
81 #endif
83 #ifndef DEFAULT_GDB_EXTENSIONS
84 #define DEFAULT_GDB_EXTENSIONS 1
85 #endif
87 extern int rtx_equal_function_value_matters;
89 #if ! (defined (VMS) || defined (OS2))
90 extern char **environ;
91 #endif
92 extern char *version_string, *language_string;
94 /* Carry information from ASM_DECLARE_OBJECT_NAME
95 to ASM_FINISH_DECLARE_OBJECT. */
97 extern int size_directive_output;
98 extern tree last_assemble_variable_decl;
100 extern void init_lex ();
101 extern void init_decl_processing ();
102 extern void init_obstacks ();
103 extern void init_tree_codes ();
104 extern void init_rtl ();
105 extern void init_regs ();
106 extern void init_optabs ();
107 extern void init_stmt ();
108 extern void init_reg_sets ();
109 extern void dump_flow_info ();
110 extern void dump_sched_info ();
111 extern void dump_local_alloc ();
113 void rest_of_decl_compilation ();
114 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
115 void error_with_decl PVPROTO((tree decl, char *s, ...));
116 void error_for_asm PVPROTO((rtx insn, char *s, ...));
117 void error PVPROTO((char *s, ...));
118 void fatal PVPROTO((char *s, ...));
119 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
120 void warning_with_decl PVPROTO((tree decl, char *s, ...));
121 void warning_for_asm PVPROTO((rtx insn, char *s, ...));
122 void warning PVPROTO((char *s, ...));
123 void pedwarn PVPROTO((char *s, ...));
124 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
125 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
126 void sorry PVPROTO((char *s, ...));
127 void really_sorry PVPROTO((char *s, ...));
128 void fancy_abort ();
129 #ifndef abort
130 void abort ();
131 #endif
132 void set_target_switch ();
133 static void print_switch_values ();
134 static char *decl_name ();
136 /* Name of program invoked, sans directories. */
138 char *progname;
140 /* Copy of arguments to main. */
141 int save_argc;
142 char **save_argv;
144 /* Name of current original source file (what was input to cpp).
145 This comes from each #-command in the actual input. */
147 char *input_filename;
149 /* Name of top-level original source file (what was input to cpp).
150 This comes from the #-command at the beginning of the actual input.
151 If there isn't any there, then this is the cc1 input file name. */
153 char *main_input_filename;
155 /* Stream for reading from the input file. */
157 FILE *finput;
159 /* Current line number in real source file. */
161 int lineno;
163 /* Stack of currently pending input files. */
165 struct file_stack *input_file_stack;
167 /* Incremented on each change to input_file_stack. */
168 int input_file_stack_tick;
170 /* FUNCTION_DECL for function now being parsed or compiled. */
172 extern tree current_function_decl;
174 /* Name to use as base of names for dump output files. */
176 char *dump_base_name;
178 /* Bit flags that specify the machine subtype we are compiling for.
179 Bits are tested using macros TARGET_... defined in the tm.h file
180 and set by `-m...' switches. Must be defined in rtlanal.c. */
182 extern int target_flags;
184 /* Flags saying which kinds of debugging dump have been requested. */
186 int rtl_dump = 0;
187 int rtl_dump_and_exit = 0;
188 int jump_opt_dump = 0;
189 int cse_dump = 0;
190 int loop_dump = 0;
191 int cse2_dump = 0;
192 int flow_dump = 0;
193 int combine_dump = 0;
194 int sched_dump = 0;
195 int local_reg_dump = 0;
196 int global_reg_dump = 0;
197 int sched2_dump = 0;
198 int jump2_opt_dump = 0;
199 int dbr_sched_dump = 0;
200 int flag_print_asm_name = 0;
201 int stack_reg_dump = 0;
203 /* Name for output file of assembly code, specified with -o. */
205 char *asm_file_name;
207 /* Value of the -G xx switch, and whether it was passed or not. */
208 int g_switch_value;
209 int g_switch_set;
211 /* Type(s) of debugging information we are producing (if any).
212 See flags.h for the definitions of the different possible
213 types of debugging information. */
214 enum debug_info_type write_symbols = NO_DEBUG;
216 /* Level of debugging information we are producing. See flags.h
217 for the definitions of the different possible levels. */
218 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
220 /* Nonzero means use GNU-only extensions in the generated symbolic
221 debugging information. */
222 /* Currently, this only has an effect when write_symbols is set to
223 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
224 int use_gnu_debug_info_extensions = 0;
226 /* Nonzero means do optimizations. -O.
227 Particular numeric values stand for particular amounts of optimization;
228 thus, -O2 stores 2 here. However, the optimizations beyond the basic
229 ones are not controlled directly by this variable. Instead, they are
230 controlled by individual `flag_...' variables that are defaulted
231 based on this variable. */
233 int optimize = 0;
235 /* Number of error messages and warning messages so far. */
237 int errorcount = 0;
238 int warningcount = 0;
239 int sorrycount = 0;
241 /* Flag to output bytecode instead of native assembler */
242 int output_bytecode = 0;
244 /* Pointer to function to compute the name to use to print a declaration. */
246 char *(*decl_printable_name) ();
248 /* Pointer to function to compute rtl for a language-specific tree code. */
250 struct rtx_def *(*lang_expand_expr) ();
252 /* Pointer to function to finish handling an incomplete decl at the
253 end of compilation. */
255 void (*incomplete_decl_finalize_hook) () = 0;
257 /* Nonzero if generating code to do profiling. */
259 int profile_flag = 0;
261 /* Nonzero if generating code to do profiling on a line-by-line basis. */
263 int profile_block_flag;
265 /* Nonzero for -pedantic switch: warn about anything
266 that standard spec forbids. */
268 int pedantic = 0;
270 /* Temporarily suppress certain warnings.
271 This is set while reading code from a system header file. */
273 int in_system_header = 0;
275 /* Nonzero means do stupid register allocation.
276 Currently, this is 1 if `optimize' is 0. */
278 int obey_regdecls = 0;
280 /* Don't print functions as they are compiled and don't print
281 times taken by the various passes. -quiet. */
283 int quiet_flag = 0;
285 /* -f flags. */
287 /* Nonzero means `char' should be signed. */
289 int flag_signed_char;
291 /* Nonzero means give an enum type only as many bytes as it needs. */
293 int flag_short_enums;
295 /* Nonzero for -fcaller-saves: allocate values in regs that need to
296 be saved across function calls, if that produces overall better code.
297 Optional now, so people can test it. */
299 #ifdef DEFAULT_CALLER_SAVES
300 int flag_caller_saves = 1;
301 #else
302 int flag_caller_saves = 0;
303 #endif
305 /* Nonzero if structures and unions should be returned in memory.
307 This should only be defined if compatibility with another compiler or
308 with an ABI is needed, because it results in slower code. */
310 #ifndef DEFAULT_PCC_STRUCT_RETURN
311 #define DEFAULT_PCC_STRUCT_RETURN 1
312 #endif
314 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
316 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
318 /* Nonzero for -fforce-mem: load memory value into a register
319 before arithmetic on it. This makes better cse but slower compilation. */
321 int flag_force_mem = 0;
323 /* Nonzero for -fforce-addr: load memory address into a register before
324 reference to memory. This makes better cse but slower compilation. */
326 int flag_force_addr = 0;
328 /* Nonzero for -fdefer-pop: don't pop args after each function call;
329 instead save them up to pop many calls' args with one insns. */
331 int flag_defer_pop = 0;
333 /* Nonzero for -ffloat-store: don't allocate floats and doubles
334 in extended-precision registers. */
336 int flag_float_store = 0;
338 /* Nonzero for -fcse-follow-jumps:
339 have cse follow jumps to do a more extensive job. */
341 int flag_cse_follow_jumps;
343 /* Nonzero for -fcse-skip-blocks:
344 have cse follow a branch around a block. */
345 int flag_cse_skip_blocks;
347 /* Nonzero for -fexpensive-optimizations:
348 perform miscellaneous relatively-expensive optimizations. */
349 int flag_expensive_optimizations;
351 /* Nonzero for -fthread-jumps:
352 have jump optimize output of loop. */
354 int flag_thread_jumps;
356 /* Nonzero enables strength-reduction in loop.c. */
358 int flag_strength_reduce = 0;
360 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
361 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
362 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
363 unrolled. */
365 int flag_unroll_loops;
367 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
368 This is generally not a win. */
370 int flag_unroll_all_loops;
372 /* Nonzero for -fwritable-strings:
373 store string constants in data segment and don't uniquize them. */
375 int flag_writable_strings = 0;
377 /* Nonzero means don't put addresses of constant functions in registers.
378 Used for compiling the Unix kernel, where strange substitutions are
379 done on the assembly output. */
381 int flag_no_function_cse = 0;
383 /* Nonzero for -fomit-frame-pointer:
384 don't make a frame pointer in simple functions that don't require one. */
386 int flag_omit_frame_pointer = 0;
388 /* Nonzero to inhibit use of define_optimization peephole opts. */
390 int flag_no_peephole = 0;
392 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
393 operations in the interest of optimization. For example it allows
394 GCC to assume arguments to sqrt are nonnegative numbers, allowing
395 faster code for sqrt to be generated. */
397 int flag_fast_math = 0;
399 /* Nonzero means all references through pointers are volatile. */
401 int flag_volatile;
403 /* Nonzero means treat all global and extern variables as global. */
405 int flag_volatile_global;
407 /* Nonzero means just do syntax checking; don't output anything. */
409 int flag_syntax_only = 0;
411 /* Nonzero means to rerun cse after loop optimization. This increases
412 compilation time about 20% and picks up a few more common expressions. */
414 static int flag_rerun_cse_after_loop;
416 /* Nonzero for -finline-functions: ok to inline functions that look like
417 good inline candidates. */
419 int flag_inline_functions;
421 /* Nonzero for -fkeep-inline-functions: even if we make a function
422 go inline everywhere, keep its definition around for debugging
423 purposes. */
425 int flag_keep_inline_functions;
427 /* Nonzero means that functions declared `inline' will be treated
428 as `static'. Prevents generation of zillions of copies of unused
429 static inline functions; instead, `inlines' are written out
430 only when actually used. Used in conjunction with -g. Also
431 does the right thing with #pragma interface. */
433 int flag_no_inline;
435 /* Nonzero means we should be saving declaration info into a .X file. */
437 int flag_gen_aux_info = 0;
439 /* Specified name of aux-info file. */
441 static char *aux_info_file_name;
443 /* Nonzero means make the text shared if supported. */
445 int flag_shared_data;
447 /* Nonzero means schedule into delayed branch slots if supported. */
449 int flag_delayed_branch;
451 /* Nonzero means to run cleanups after CALL_EXPRs. */
453 int flag_short_temps;
455 /* Nonzero if we are compiling pure (sharable) code.
456 Value is 1 if we are doing reasonable (i.e. simple
457 offset into offset table) pic. Value is 2 if we can
458 only perform register offsets. */
460 int flag_pic;
462 /* Nonzero means place uninitialized global data in the bss section. */
464 int flag_no_common;
466 /* Nonzero means pretend it is OK to examine bits of target floats,
467 even if that isn't true. The resulting code will have incorrect constants,
468 but the same series of instructions that the native compiler would make. */
470 int flag_pretend_float;
472 /* Nonzero means change certain warnings into errors.
473 Usually these are warnings about failure to conform to some standard. */
475 int flag_pedantic_errors = 0;
477 /* flag_schedule_insns means schedule insns within basic blocks (before
478 local_alloc).
479 flag_schedule_insns_after_reload means schedule insns after
480 global_alloc. */
482 int flag_schedule_insns = 0;
483 int flag_schedule_insns_after_reload = 0;
485 /* -finhibit-size-directive inhibits output of .size for ELF.
486 This is used only for compiling crtstuff.c,
487 and it may be extended to other effects
488 needed for crtstuff.c on other systems. */
489 int flag_inhibit_size_directive = 0;
491 /* -fverbose-asm causes extra commentary information to be produced in
492 the generated assembly code (to make it more readable). This option
493 is generally only of use to those who actually need to read the
494 generated assembly code (perhaps while debugging the compiler itself). */
496 int flag_verbose_asm = 0;
498 /* -fgnu-linker specifies use of the GNU linker for initializations.
499 (Or, more generally, a linker that handles initializations.)
500 -fno-gnu-linker says that collect2 will be used. */
501 #ifdef USE_COLLECT2
502 int flag_gnu_linker = 0;
503 #else
504 int flag_gnu_linker = 1;
505 #endif
507 /* Table of language-independent -f options.
508 STRING is the option name. VARIABLE is the address of the variable.
509 ON_VALUE is the value to store in VARIABLE
510 if `-fSTRING' is seen as an option.
511 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
513 struct { char *string; int *variable; int on_value;} f_options[] =
515 {"float-store", &flag_float_store, 1},
516 {"volatile", &flag_volatile, 1},
517 {"volatile-global", &flag_volatile_global, 1},
518 {"defer-pop", &flag_defer_pop, 1},
519 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
520 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
521 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
522 {"expensive-optimizations", &flag_expensive_optimizations, 1},
523 {"thread-jumps", &flag_thread_jumps, 1},
524 {"strength-reduce", &flag_strength_reduce, 1},
525 {"unroll-loops", &flag_unroll_loops, 1},
526 {"unroll-all-loops", &flag_unroll_all_loops, 1},
527 {"writable-strings", &flag_writable_strings, 1},
528 {"peephole", &flag_no_peephole, 0},
529 {"force-mem", &flag_force_mem, 1},
530 {"force-addr", &flag_force_addr, 1},
531 {"function-cse", &flag_no_function_cse, 0},
532 {"inline-functions", &flag_inline_functions, 1},
533 {"keep-inline-functions", &flag_keep_inline_functions, 1},
534 {"inline", &flag_no_inline, 0},
535 {"syntax-only", &flag_syntax_only, 1},
536 {"shared-data", &flag_shared_data, 1},
537 {"caller-saves", &flag_caller_saves, 1},
538 {"pcc-struct-return", &flag_pcc_struct_return, 1},
539 {"reg-struct-return", &flag_pcc_struct_return, 0},
540 {"delayed-branch", &flag_delayed_branch, 1},
541 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
542 {"pretend-float", &flag_pretend_float, 1},
543 {"schedule-insns", &flag_schedule_insns, 1},
544 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
545 {"pic", &flag_pic, 1},
546 {"PIC", &flag_pic, 2},
547 {"fast-math", &flag_fast_math, 1},
548 {"common", &flag_no_common, 0},
549 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
550 {"verbose-asm", &flag_verbose_asm, 1},
551 {"gnu-linker", &flag_gnu_linker, 1},
552 {"bytecode", &output_bytecode, 1}
555 /* Table of language-specific options. */
557 char *lang_options[] =
559 "-ansi",
560 "-fallow-single-precision",
562 "-fsigned-bitfields",
563 "-funsigned-bitfields",
564 "-fno-signed-bitfields",
565 "-fno-unsigned-bitfields",
566 "-fsigned-char",
567 "-funsigned-char",
568 "-fno-signed-char",
569 "-fno-unsigned-char",
571 "-ftraditional",
572 "-traditional",
573 "-fnotraditional",
574 "-fno-traditional",
576 "-fasm",
577 "-fno-asm",
578 "-fbuiltin",
579 "-fno-builtin",
580 "-fcond-mismatch",
581 "-fno-cond-mismatch",
582 "-fdollars-in-identifiers",
583 "-fno-dollars-in-identifiers",
584 "-fident",
585 "-fno-ident",
586 "-fshort-double",
587 "-fno-short-double",
588 "-fshort-enums",
589 "-fno-short-enums",
591 "-Wall",
592 "-Wbad-function-cast",
593 "-Wno-bad-function-cast",
594 "-Wcast-qual",
595 "-Wno-cast-qual",
596 "-Wchar-subscripts",
597 "-Wno-char-subscripts",
598 "-Wcomment",
599 "-Wno-comment",
600 "-Wcomments",
601 "-Wno-comments",
602 "-Wconversion",
603 "-Wno-conversion",
604 "-Wformat",
605 "-Wno-format",
606 "-Wimport",
607 "-Wno-import",
608 "-Wimplicit",
609 "-Wno-implicit",
610 "-Wmissing-braces",
611 "-Wno-missing-braces",
612 "-Wmissing-declarations",
613 "-Wno-missing-declarations",
614 "-Wmissing-prototypes",
615 "-Wno-missing-prototypes",
616 "-Wnested-externs",
617 "-Wno-nested-externs",
618 "-Wparentheses",
619 "-Wno-parentheses",
620 "-Wpointer-arith",
621 "-Wno-pointer-arith",
622 "-Wredundant-decls",
623 "-Wno-redundant-decls",
624 "-Wstrict-prototypes",
625 "-Wno-strict-prototypes",
626 "-Wtraditional",
627 "-Wno-traditional",
628 "-Wtrigraphs",
629 "-Wno-trigraphs",
630 "-Wwrite-strings",
631 "-Wno-write-strings",
633 /* These are for C++. */
634 "-+e0", /* gcc.c tacks the `-' on the front. */
635 "-+e1",
636 "-+e2",
637 "-fall-virtual",
638 "-fno-all-virtual",
639 "-falt-external-templates",
640 "-fno-alt-external-templates",
641 "-fansi-overloading",
642 "-fno-ansi-overloading",
643 "-fcadillac",
644 "-fno-cadillac",
645 "-fconserve-space",
646 "-fno-conserve-space",
647 "-fdefault-inline",
648 "-fno-default-inline",
649 "-fdossier",
650 "-fno-dossier",
651 "-felide-constructors",
652 "-fno-elide-constructors",
653 "-fenum-int-equiv",
654 "-fno-enum-int-equiv",
655 "-fexternal-templates",
656 "-fno-external-templates",
657 "-fgc",
658 "-fno-gc",
659 "-fhandle-exceptions",
660 "-fno-handle-exceptions",
661 "-fhandle-signatures",
662 "-fno-handle-signatures",
663 "-fhuge-objects",
664 "-fno-huge-objects",
665 "-fimplement-inlines",
666 "-fno-implement-inlines",
667 "-fimplicit-templates",
668 "-fno-implicit-templates",
669 "-flabels-ok",
670 "-fno-labels-ok",
671 "-fmemoize-lookups",
672 "-fno-memoize-lookups",
673 "-fnonnull-objects",
674 "-fno-nonnull-objects",
675 "-fsave-memoized",
676 "-fno-save-memoized",
677 "-fshort-temps",
678 "-fno-short-temps",
679 "-fstats",
680 "-fno-stats",
681 "-fstrict-prototype",
682 "-fno-strict-prototype",
683 "-fthis-is-variable",
684 "-fno-this-is-variable",
685 "-fvtable-thunks",
686 "-fno-vtable-thunks",
687 "-fxref",
688 "-fno-xref",
690 "-Wreturn-type",
691 "-Wno-return-type",
692 "-Woverloaded-virtual",
693 "-Wno-overloaded-virtual",
694 "-Wenum-clash",
695 "-Wno-enum-clash",
696 "-Wtemplate-debugging",
697 "-Wno-template-debugging",
698 "-Wctor-dtor-privacy",
699 "-Wno-ctor-dtor-privacy",
700 "-Wextern-inline",
701 "-Wno-extern-inline",
703 /* these are for obj c */
704 "-lang-objc",
705 "-gen-decls",
706 "-fgnu-runtime",
707 "-fno-gnu-runtime",
708 "-fnext-runtime",
709 "-fno-next-runtime",
710 "-Wselector",
711 "-Wno-selector",
712 "-Wprotocol",
713 "-Wno-protocol",
715 /* This is for GNAT and is temporary. */
716 "-gnat",
720 /* Options controlling warnings */
722 /* Don't print warning messages. -w. */
724 int inhibit_warnings = 0;
726 /* Print various extra warnings. -W. */
728 int extra_warnings = 0;
730 /* Treat warnings as errors. -Werror. */
732 int warnings_are_errors = 0;
734 /* Nonzero to warn about unused local variables. */
736 int warn_unused;
738 /* Nonzero to warn about variables used before they are initialized. */
740 int warn_uninitialized;
742 /* Nonzero means warn about all declarations which shadow others. */
744 int warn_shadow;
746 /* Warn if a switch on an enum fails to have a case for every enum value. */
748 int warn_switch;
750 /* Nonzero means warn about function definitions that default the return type
751 or that use a null return and have a return-type other than void. */
753 int warn_return_type;
755 /* Nonzero means warn about pointer casts that increase the required
756 alignment of the target type (and might therefore lead to a crash
757 due to a misaligned access). */
759 int warn_cast_align;
761 /* Nonzero means warn about any identifiers that match in the first N
762 characters. The value N is in `id_clash_len'. */
764 int warn_id_clash;
765 unsigned id_clash_len;
767 /* Nonzero means warn about any objects definitions whose size is larger
768 than N bytes. Also want about function definitions whose returned
769 values are larger than N bytes. The value N is in `larger_than_size'. */
771 int warn_larger_than;
772 unsigned larger_than_size;
774 /* Nonzero means warn if inline function is too large. */
776 int warn_inline;
778 /* Warn if a function returns an aggregate,
779 since there are often incompatible calling conventions for doing this. */
781 int warn_aggregate_return;
783 /* Likewise for -W. */
785 struct { char *string; int *variable; int on_value;} W_options[] =
787 {"unused", &warn_unused, 1},
788 {"error", &warnings_are_errors, 1},
789 {"shadow", &warn_shadow, 1},
790 {"switch", &warn_switch, 1},
791 {"aggregate-return", &warn_aggregate_return, 1},
792 {"cast-align", &warn_cast_align, 1},
793 {"uninitialized", &warn_uninitialized, 1},
794 {"inline", &warn_inline, 1}
797 /* Output files for assembler code (real compiler output)
798 and debugging dumps. */
800 FILE *asm_out_file;
801 FILE *aux_info_file;
802 FILE *rtl_dump_file;
803 FILE *jump_opt_dump_file;
804 FILE *cse_dump_file;
805 FILE *loop_dump_file;
806 FILE *cse2_dump_file;
807 FILE *flow_dump_file;
808 FILE *combine_dump_file;
809 FILE *sched_dump_file;
810 FILE *local_reg_dump_file;
811 FILE *global_reg_dump_file;
812 FILE *sched2_dump_file;
813 FILE *jump2_opt_dump_file;
814 FILE *dbr_sched_dump_file;
815 FILE *stack_reg_dump_file;
817 /* Time accumulators, to count the total time spent in various passes. */
819 int parse_time;
820 int varconst_time;
821 int integration_time;
822 int jump_time;
823 int cse_time;
824 int loop_time;
825 int cse2_time;
826 int flow_time;
827 int combine_time;
828 int sched_time;
829 int local_alloc_time;
830 int global_alloc_time;
831 int sched2_time;
832 int dbr_sched_time;
833 int shorten_branch_time;
834 int stack_reg_time;
835 int final_time;
836 int symout_time;
837 int dump_time;
839 /* Return time used so far, in microseconds. */
842 get_run_time ()
844 #ifdef USG
845 struct tms tms;
846 #else
847 #ifndef VMS
848 struct rusage rusage;
849 #else /* VMS */
850 struct
852 int proc_user_time;
853 int proc_system_time;
854 int child_user_time;
855 int child_system_time;
856 } vms_times;
857 #endif
858 #endif
860 if (quiet_flag)
861 return 0;
863 #ifdef USG
864 times (&tms);
865 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
866 #else
867 #ifndef VMS
868 getrusage (0, &rusage);
869 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
870 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
871 #else /* VMS */
872 times (&vms_times);
873 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
874 #endif
875 #endif
878 #define TIMEVAR(VAR, BODY) \
879 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
881 void
882 print_time (str, total)
883 char *str;
884 int total;
886 fprintf (stderr,
887 "time in %s: %d.%06d\n",
888 str, total / 1000000, total % 1000000);
891 /* Count an error or warning. Return 1 if the message should be printed. */
894 count_error (warningp)
895 int warningp;
897 if (warningp && inhibit_warnings)
898 return 0;
900 if (warningp && !warnings_are_errors)
901 warningcount++;
902 else
904 static int warning_message = 0;
906 if (warningp && !warning_message)
908 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
909 warning_message = 1;
911 errorcount++;
914 return 1;
917 /* Print a fatal error message. NAME is the text.
918 Also include a system error message based on `errno'. */
920 void
921 pfatal_with_name (name)
922 char *name;
924 fprintf (stderr, "%s: ", progname);
925 perror (name);
926 exit (35);
929 void
930 fatal_io_error (name)
931 char *name;
933 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
934 exit (35);
937 /* Called to give a better error message when we don't have an insn to match
938 what we are looking for or if the insn's constraints aren't satisfied,
939 rather than just calling abort(). */
941 void
942 fatal_insn_not_found (insn)
943 rtx insn;
945 if (!output_bytecode)
947 if (INSN_CODE (insn) < 0)
948 error ("internal error--unrecognizable insn:");
949 else
950 error ("internal error--insn does not satisfy its constraints:");
951 debug_rtx (insn);
953 if (asm_out_file)
954 fflush (asm_out_file);
955 if (aux_info_file)
956 fflush (aux_info_file);
957 if (rtl_dump_file)
958 fflush (rtl_dump_file);
959 if (jump_opt_dump_file)
960 fflush (jump_opt_dump_file);
961 if (cse_dump_file)
962 fflush (cse_dump_file);
963 if (loop_dump_file)
964 fflush (loop_dump_file);
965 if (cse2_dump_file)
966 fflush (cse2_dump_file);
967 if (flow_dump_file)
968 fflush (flow_dump_file);
969 if (combine_dump_file)
970 fflush (combine_dump_file);
971 if (sched_dump_file)
972 fflush (sched_dump_file);
973 if (local_reg_dump_file)
974 fflush (local_reg_dump_file);
975 if (global_reg_dump_file)
976 fflush (global_reg_dump_file);
977 if (sched2_dump_file)
978 fflush (sched2_dump_file);
979 if (jump2_opt_dump_file)
980 fflush (jump2_opt_dump_file);
981 if (dbr_sched_dump_file)
982 fflush (dbr_sched_dump_file);
983 if (stack_reg_dump_file)
984 fflush (stack_reg_dump_file);
985 abort ();
988 /* This is the default decl_printable_name function. */
990 static char *
991 decl_name (decl, kind)
992 tree decl;
993 char **kind;
995 return IDENTIFIER_POINTER (DECL_NAME (decl));
998 static int need_error_newline;
1000 /* Function of last error message;
1001 more generally, function such that if next error message is in it
1002 then we don't have to mention the function name. */
1003 static tree last_error_function = NULL;
1005 /* Used to detect when input_file_stack has changed since last described. */
1006 static int last_error_tick;
1008 /* Called when the start of a function definition is parsed,
1009 this function prints on stderr the name of the function. */
1011 void
1012 announce_function (decl)
1013 tree decl;
1015 if (! quiet_flag)
1017 char *junk;
1018 if (rtl_dump_and_exit)
1019 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1020 else
1021 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
1022 fflush (stderr);
1023 need_error_newline = 1;
1024 last_error_function = current_function_decl;
1028 /* Prints out, if necessary, the name of the current function
1029 which caused an error. Called from all error and warning functions. */
1031 void
1032 report_error_function (file)
1033 char *file;
1035 struct file_stack *p;
1037 if (need_error_newline)
1039 fprintf (stderr, "\n");
1040 need_error_newline = 0;
1043 if (last_error_function != current_function_decl)
1045 char *kind = "function";
1046 if (current_function_decl != 0
1047 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1048 kind = "method";
1050 if (file)
1051 fprintf (stderr, "%s: ", file);
1053 if (current_function_decl == NULL)
1054 fprintf (stderr, "At top level:\n");
1055 else
1057 char *name = (*decl_printable_name) (current_function_decl, &kind);
1058 fprintf (stderr, "In %s `%s':\n", kind, name);
1061 last_error_function = current_function_decl;
1063 if (input_file_stack && input_file_stack->next != 0
1064 && input_file_stack_tick != last_error_tick)
1066 fprintf (stderr, "In file included");
1067 for (p = input_file_stack->next; p; p = p->next)
1069 fprintf (stderr, " from %s:%d", p->name, p->line);
1070 if (p->next)
1071 fprintf (stderr, ",\n ");
1073 fprintf (stderr, ":\n");
1074 last_error_tick = input_file_stack_tick;
1078 /* Print a message. */
1080 static void
1081 vmessage (prefix, s, ap)
1082 char *prefix;
1083 char *s;
1084 va_list ap;
1086 if (prefix)
1087 fprintf (stderr, "%s: ", prefix);
1089 #ifdef HAVE_VPRINTF
1090 vfprintf (stderr, s, ap);
1091 #else
1093 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1094 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1095 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1096 fprintf (stderr, s, v1, v2, v3);
1098 #endif
1101 /* Print a message relevant to line LINE of file FILE. */
1103 static void
1104 v_message_with_file_and_line (file, line, prefix, s, ap)
1105 char *file;
1106 int line;
1107 char *prefix;
1108 char *s;
1109 va_list ap;
1111 if (file)
1112 fprintf (stderr, "%s:%d: ", file, line);
1113 else
1114 fprintf (stderr, "%s: ", progname);
1116 vmessage (prefix, s, ap);
1117 fputc ('\n', stderr);
1120 /* Print a message relevant to the given DECL. */
1122 static void
1123 v_message_with_decl (decl, prefix, s, ap)
1124 tree decl;
1125 char *prefix;
1126 char *s;
1127 va_list ap;
1129 char *n, *p, *junk;
1131 fprintf (stderr, "%s:%d: ",
1132 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1134 if (prefix)
1135 fprintf (stderr, "%s: ", prefix);
1137 /* Do magic to get around lack of varargs support for insertion
1138 of arguments into existing list. We know that the decl is first;
1139 we ass_u_me that it will be printed with "%s". */
1141 for (p = s; *p; ++p)
1143 if (*p == '%')
1145 if (*(p + 1) == '%')
1146 ++p;
1147 else
1148 break;
1152 if (p > s)
1153 fwrite (s, p - s, 1, stderr);
1155 if (*p == '%')
1157 char *n = (DECL_NAME (decl)
1158 ? (*decl_printable_name) (decl, &junk)
1159 : "((anonymous))");
1160 fputs (n, stderr);
1161 while (*p)
1163 ++p;
1164 if (isalpha (*(p - 1) & 0xFF))
1165 break;
1169 if (*p)
1170 vmessage ((char *)NULL, p, ap);
1172 fputc ('\n', stderr);
1175 /* Figure file and line of the given INSN. */
1177 static void
1178 file_and_line_for_asm (insn, pfile, pline)
1179 rtx insn;
1180 char **pfile;
1181 int *pline;
1183 rtx body = PATTERN (insn);
1184 rtx asmop;
1186 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1187 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1188 asmop = SET_SRC (body);
1189 else if (GET_CODE (body) == ASM_OPERANDS)
1190 asmop = body;
1191 else if (GET_CODE (body) == PARALLEL
1192 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1193 asmop = SET_SRC (XVECEXP (body, 0, 0));
1194 else if (GET_CODE (body) == PARALLEL
1195 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1196 asmop = XVECEXP (body, 0, 0);
1197 else
1198 asmop = NULL;
1200 if (asmop)
1202 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1203 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1205 else
1207 *pfile = input_filename;
1208 *pline = lineno;
1212 /* Report an error at line LINE of file FILE. */
1214 static void
1215 v_error_with_file_and_line (file, line, s, ap)
1216 char *file;
1217 int line;
1218 char *s;
1219 va_list ap;
1221 count_error (0);
1222 report_error_function (file);
1223 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1226 void
1227 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1229 #ifndef __STDC__
1230 char *file;
1231 int line;
1232 char *s;
1233 #endif
1234 va_list ap;
1236 VA_START (ap, s);
1238 #ifndef __STDC__
1239 file = va_arg (ap, char *);
1240 line = va_arg (ap, int);
1241 s = va_arg (ap, char *);
1242 #endif
1244 v_error_with_file_and_line (file, line, s, ap);
1245 va_end (ap);
1248 /* Report an error at the declaration DECL.
1249 S is a format string which uses %s to substitute the declaration
1250 name; subsequent substitutions are a la printf. */
1252 static void
1253 v_error_with_decl (decl, s, ap)
1254 tree decl;
1255 char *s;
1256 va_list ap;
1258 count_error (0);
1259 report_error_function (DECL_SOURCE_FILE (decl));
1260 v_message_with_decl (decl, (char *)NULL, s, ap);
1263 void
1264 error_with_decl VPROTO((tree decl, char *s, ...))
1266 #ifndef __STDC__
1267 tree decl;
1268 char *s;
1269 #endif
1270 va_list ap;
1272 VA_START (ap, s);
1274 #ifndef __STDC__
1275 decl = va_arg (ap, tree);
1276 s = va_arg (ap, char *);
1277 #endif
1279 v_error_with_decl (decl, s, ap);
1280 va_end (ap);
1283 /* Report an error at the line number of the insn INSN.
1284 This is used only when INSN is an `asm' with operands,
1285 and each ASM_OPERANDS records its own source file and line. */
1287 static void
1288 v_error_for_asm (insn, s, ap)
1289 rtx insn;
1290 char *s;
1291 va_list ap;
1293 char *file;
1294 int line;
1296 count_error (0);
1297 file_and_line_for_asm (insn, &file, &line);
1298 report_error_function (file);
1299 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1302 void
1303 error_for_asm VPROTO((rtx insn, char *s, ...))
1305 #ifndef __STDC__
1306 rtx insn;
1307 char *s;
1308 #endif
1309 va_list ap;
1311 VA_START (ap, s);
1313 #ifndef __STDC__
1314 insn = va_arg (ap, rtx);
1315 s = va_arg (ap, char *);
1316 #endif
1318 v_error_for_asm (insn, s, ap);
1319 va_end (ap);
1322 /* Report an error at the current line number. */
1324 static void
1325 verror (s, ap)
1326 char *s;
1327 va_list ap;
1329 v_error_with_file_and_line (input_filename, lineno, s, ap);
1332 void
1333 error VPROTO((char *s, ...))
1335 #ifndef __STDC__
1336 char *s;
1337 #endif
1338 va_list ap;
1340 VA_START (ap, s);
1342 #ifndef __STDC__
1343 s = va_arg (ap, char *);
1344 #endif
1346 verror (s, ap);
1347 va_end (ap);
1350 /* Report a fatal error at the current line number. */
1352 static void
1353 vfatal (s, ap)
1354 char *s;
1355 va_list ap;
1357 verror (s, ap);
1358 exit (34);
1361 void
1362 fatal VPROTO((char *s, ...))
1364 #ifndef __STDC__
1365 char *s;
1366 #endif
1367 va_list ap;
1369 VA_START (ap, s);
1371 #ifndef __STDC__
1372 s = va_arg (ap, char *);
1373 #endif
1375 vfatal (s, ap);
1376 va_end (ap);
1379 /* Report a warning at line LINE of file FILE. */
1381 static void
1382 v_warning_with_file_and_line (file, line, s, ap)
1383 char *file;
1384 int line;
1385 char *s;
1386 va_list ap;
1388 if (count_error (1))
1390 report_error_function (file);
1391 v_message_with_file_and_line (file, line, "warning", s, ap);
1395 void
1396 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1398 #ifndef __STDC__
1399 char *file;
1400 int line;
1401 char *s;
1402 #endif
1403 va_list ap;
1405 VA_START (ap, s);
1407 #ifndef __STDC__
1408 file = va_arg (ap, char *);
1409 line = va_arg (ap, int);
1410 s = va_arg (ap, char *);
1411 #endif
1413 v_warning_with_file_and_line (file, line, s, ap);
1414 va_end (ap);
1417 /* Report a warning at the declaration DECL.
1418 S is a format string which uses %s to substitute the declaration
1419 name; subsequent substitutions are a la printf. */
1421 static void
1422 v_warning_with_decl (decl, s, ap)
1423 tree decl;
1424 char *s;
1425 va_list ap;
1427 if (count_error (1))
1429 report_error_function (DECL_SOURCE_FILE (decl));
1430 v_message_with_decl (decl, "warning", s, ap);
1434 void
1435 warning_with_decl VPROTO((tree decl, char *s, ...))
1437 #ifndef __STDC__
1438 tree decl;
1439 char *s;
1440 #endif
1441 va_list ap;
1443 VA_START (ap, s);
1445 #ifndef __STDC__
1446 decl = va_arg (ap, tree);
1447 s = va_arg (ap, char *);
1448 #endif
1450 v_warning_with_decl (decl, s, ap);
1451 va_end (ap);
1454 /* Report a warning at the line number of the insn INSN.
1455 This is used only when INSN is an `asm' with operands,
1456 and each ASM_OPERANDS records its own source file and line. */
1458 static void
1459 v_warning_for_asm (insn, s, ap)
1460 rtx insn;
1461 char *s;
1462 va_list ap;
1464 if (count_error (1))
1466 char *file;
1467 int line;
1469 file_and_line_for_asm (insn, &file, &line);
1470 report_error_function (file);
1471 v_message_with_file_and_line (file, line, "warning", s, ap);
1475 void
1476 warning_for_asm VPROTO((rtx insn, char *s, ...))
1478 #ifndef __STDC__
1479 rtx insn;
1480 char *s;
1481 #endif
1482 va_list ap;
1484 VA_START (ap, s);
1486 #ifndef __STDC__
1487 insn = va_arg (ap, rtx);
1488 s = va_arg (ap, char *);
1489 #endif
1491 v_warning_for_asm (insn, s, ap);
1492 va_end (ap);
1495 /* Report a warning at the current line number. */
1497 static void
1498 vwarning (s, ap)
1499 char *s;
1500 va_list ap;
1502 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1505 void
1506 warning VPROTO((char *s, ...))
1508 #ifndef __STDC__
1509 char *s;
1510 #endif
1511 va_list ap;
1513 VA_START (ap, s);
1515 #ifndef __STDC__
1516 s = va_arg (ap, char *);
1517 #endif
1519 vwarning (s, ap);
1520 va_end (ap);
1523 /* These functions issue either warnings or errors depending on
1524 -pedantic-errors. */
1526 static void
1527 vpedwarn (s, ap)
1528 char *s;
1529 va_list ap;
1531 if (flag_pedantic_errors)
1532 verror (s, ap);
1533 else
1534 vwarning (s, ap);
1537 void
1538 pedwarn VPROTO((char *s, ...))
1540 #ifndef __STDC__
1541 char *s;
1542 #endif
1543 va_list ap;
1545 VA_START (ap, s);
1547 #ifndef __STDC__
1548 s = va_arg (ap, char *);
1549 #endif
1551 vpedwarn (s, ap);
1552 va_end (ap);
1555 static void
1556 v_pedwarn_with_decl (decl, s, ap)
1557 tree decl;
1558 char *s;
1559 va_list ap;
1561 /* We don't want -pedantic-errors to cause the compilation to fail from
1562 "errors" in system header files. Sometimes fixincludes can't fix what's
1563 broken (eg: unsigned char bitfields - fixing it may change the alignment
1564 which will cause programs to mysteriously fail because the C library
1565 or kernel uses the original layout). There's no point in issuing a
1566 warning either, it's just unnecessary noise. */
1568 if (! DECL_IN_SYSTEM_HEADER (decl))
1570 if (flag_pedantic_errors)
1571 v_error_with_decl (decl, s, ap);
1572 else
1573 v_warning_with_decl (decl, s, ap);
1577 void
1578 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1580 #ifndef __STDC__
1581 tree decl;
1582 char *s;
1583 #endif
1584 va_list ap;
1586 VA_START (ap, s);
1588 #ifndef __STDC__
1589 decl = va_arg (ap, tree);
1590 s = va_arg (ap, char *);
1591 #endif
1593 v_pedwarn_with_decl (decl, s, ap);
1594 va_end (ap);
1597 static void
1598 v_pedwarn_with_file_and_line (file, line, s, ap)
1599 char *file;
1600 int line;
1601 char *s;
1602 va_list ap;
1604 if (flag_pedantic_errors)
1605 v_error_with_file_and_line (file, line, s, ap);
1606 else
1607 v_warning_with_file_and_line (file, line, s, ap);
1610 void
1611 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1613 #ifndef __STDC__
1614 char *file;
1615 int line;
1616 char *s;
1617 #endif
1618 va_list ap;
1620 VA_START (ap, s);
1622 #ifndef __STDC__
1623 file = va_arg (ap, char *);
1624 line = va_arg (ap, int);
1625 s = va_arg (ap, char *);
1626 #endif
1628 v_pedwarn_with_file_and_line (file, line, s, ap);
1629 va_end (ap);
1632 /* Apologize for not implementing some feature. */
1634 static void
1635 vsorry (s, ap)
1636 char *s;
1637 va_list ap;
1639 sorrycount++;
1640 if (input_filename)
1641 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1642 else
1643 fprintf (stderr, "%s: ", progname);
1644 vmessage ("sorry, not implemented", s, ap);
1645 fputc ('\n', stderr);
1648 void
1649 sorry VPROTO((char *s, ...))
1651 #ifndef __STDC__
1652 char *s;
1653 #endif
1654 va_list ap;
1656 VA_START (ap, s);
1658 #ifndef __STDC__
1659 s = va_arg (ap, char *);
1660 #endif
1662 vsorry (s, ap);
1663 va_end (ap);
1666 /* Apologize for not implementing some feature, then quit. */
1668 static void
1669 v_really_sorry (s, ap)
1670 char *s;
1671 va_list ap;
1673 sorrycount++;
1674 if (input_filename)
1675 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1676 else
1677 fprintf (stderr, "%s: ", progname);
1678 vmessage ("sorry, not implemented", s, ap);
1679 fatal (" (fatal)\n");
1682 void
1683 really_sorry VPROTO((char *s, ...))
1685 #ifndef __STDC__
1686 char *s;
1687 #endif
1688 va_list ap;
1690 VA_START (ap, s);
1692 #ifndef __STDC__
1693 s = va_arg (ap, char *);
1694 #endif
1696 v_really_sorry (s, ap);
1697 va_end (ap);
1700 /* More 'friendly' abort that prints the line and file.
1701 config.h can #define abort fancy_abort if you like that sort of thing.
1703 I don't think this is actually a good idea.
1704 Other sorts of crashes will look a certain way.
1705 It is a good thing if crashes from calling abort look the same way.
1706 -- RMS */
1708 void
1709 fancy_abort ()
1711 fatal ("internal gcc abort");
1714 /* This calls abort and is used to avoid problems when abort if a macro.
1715 It is used when we need to pass the address of abort. */
1717 void
1718 do_abort ()
1720 abort ();
1723 /* When `malloc.c' is compiled with `rcheck' defined,
1724 it calls this function to report clobberage. */
1726 void
1727 botch (s)
1729 abort ();
1732 /* Same as `malloc' but report error if no memory available. */
1734 char *
1735 xmalloc (size)
1736 unsigned size;
1738 register char *value = (char *) malloc (size);
1739 if (value == 0)
1740 fatal ("virtual memory exhausted");
1741 return value;
1744 /* Same as `realloc' but report error if no memory available. */
1746 char *
1747 xrealloc (ptr, size)
1748 char *ptr;
1749 int size;
1751 char *result = (char *) realloc (ptr, size);
1752 if (!result)
1753 fatal ("virtual memory exhausted");
1754 return result;
1757 /* Return the logarithm of X, base 2, considering X unsigned,
1758 if X is a power of 2. Otherwise, returns -1.
1760 This should be used via the `exact_log2' macro. */
1763 exact_log2_wide (x)
1764 register unsigned HOST_WIDE_INT x;
1766 register int log = 0;
1767 /* Test for 0 or a power of 2. */
1768 if (x == 0 || x != (x & -x))
1769 return -1;
1770 while ((x >>= 1) != 0)
1771 log++;
1772 return log;
1775 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1776 If X is 0, return -1.
1778 This should be used via the floor_log2 macro. */
1781 floor_log2_wide (x)
1782 register unsigned HOST_WIDE_INT x;
1784 register int log = -1;
1785 while (x != 0)
1786 log++,
1787 x >>= 1;
1788 return log;
1791 int float_handled;
1792 jmp_buf float_handler;
1794 /* Specify where to longjmp to when a floating arithmetic error happens.
1795 If HANDLER is 0, it means don't handle the errors any more. */
1797 void
1798 set_float_handler (handler)
1799 jmp_buf handler;
1801 float_handled = (handler != 0);
1802 if (handler)
1803 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1806 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1807 error happens, pushing the previous specification into OLD_HANDLER.
1808 Return an indication of whether there was a previous handler in effect. */
1811 push_float_handler (handler, old_handler)
1812 jmp_buf handler, old_handler;
1814 int was_handled = float_handled;
1816 float_handled = 1;
1817 if (was_handled)
1818 bcopy ((char *) float_handler, (char *) old_handler,
1819 sizeof (float_handler));
1821 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1822 return was_handled;
1825 /* Restore the previous specification of whether and where to longjmp to
1826 when a floating arithmetic error happens. */
1828 void
1829 pop_float_handler (handled, handler)
1830 int handled;
1831 jmp_buf handler;
1833 float_handled = handled;
1834 if (handled)
1835 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1838 /* Signals actually come here. */
1840 static void
1841 float_signal (signo)
1842 /* If this is missing, some compilers complain. */
1843 int signo;
1845 if (float_handled == 0)
1846 abort ();
1847 #if defined (USG) || defined (hpux)
1848 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1849 #endif
1850 float_handled = 0;
1851 signal (SIGFPE, float_signal);
1852 longjmp (float_handler, 1);
1855 /* Handler for SIGPIPE. */
1857 static void
1858 pipe_closed (signo)
1859 /* If this is missing, some compilers complain. */
1860 int signo;
1862 fatal ("output pipe has been closed");
1865 /* Strip off a legitimate source ending from the input string NAME of
1866 length LEN. */
1868 void
1869 strip_off_ending (name, len)
1870 char *name;
1871 int len;
1873 if (len > 2 && ! strcmp (".c", name + len - 2))
1874 name[len - 2] = 0;
1875 else if (len > 2 && ! strcmp (".m", name + len - 2))
1876 name[len - 2] = 0;
1877 else if (len > 2 && ! strcmp (".i", name + len - 2))
1878 name[len - 2] = 0;
1879 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1880 name[len - 3] = 0;
1881 else if (len > 3 && ! strcmp (".co", name + len - 3))
1882 name[len - 3] = 0;
1883 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1884 name[len - 3] = 0;
1885 else if (len > 2 && ! strcmp (".C", name + len - 2))
1886 name[len - 2] = 0;
1887 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1888 name[len - 4] = 0;
1889 else if (len > 4 && ! strcmp (".cpp", name + len - 4))
1890 name[len - 4] = 0;
1891 else if (len > 2 && ! strcmp (".f", name + len - 2))
1892 name[len - 2] = 0;
1893 /* Ada will use extensions like .ada, .adb, and .ads, so just test
1894 for "ad". */
1895 else if (len > 4 && ! strncmp (".ad", name + len - 4, 3))
1896 name[len - 4] = 0;
1897 else if (len > 4 && ! strcmp (".atr", name + len - 4))
1898 name[len - 4] = 0;
1901 /* Output a quoted string. */
1902 void
1903 output_quoted_string (asm_file, string)
1904 FILE *asm_file;
1905 char *string;
1907 char c;
1909 putc ('\"', asm_file);
1910 while ((c = *string++) != 0)
1912 if (c == '\"' || c == '\\')
1913 putc ('\\', asm_file);
1914 putc (c, asm_file);
1916 putc ('\"', asm_file);
1919 /* Output a file name in the form wanted by System V. */
1921 void
1922 output_file_directive (asm_file, input_name)
1923 FILE *asm_file;
1924 char *input_name;
1926 int len = strlen (input_name);
1927 char *na = input_name + len;
1929 /* NA gets INPUT_NAME sans directory names. */
1930 while (na > input_name)
1932 if (na[-1] == '/')
1933 break;
1934 na--;
1937 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1938 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1939 #else
1940 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1941 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1942 #else
1943 fprintf (asm_file, "\t.file\t");
1944 output_quoted_string (asm_file, na);
1945 fputc ('\n', asm_file);
1946 #endif
1947 #endif
1950 /* Routine to build language identifier for object file. */
1951 static void
1952 output_lang_identify (asm_out_file)
1953 FILE *asm_out_file;
1955 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1956 char *s = (char *) alloca (len);
1957 sprintf (s, "__gnu_compiled_%s", lang_identify ());
1958 ASM_OUTPUT_LABEL (asm_out_file, s);
1961 /* Routine to open a dump file. */
1962 static FILE *
1963 open_dump_file (base_name, suffix)
1964 char *base_name;
1965 char *suffix;
1967 FILE *f;
1968 char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1);
1970 strcpy (dumpname, base_name);
1971 strcat (dumpname, suffix);
1972 f = fopen (dumpname, "w");
1973 if (f == 0)
1974 pfatal_with_name (dumpname);
1975 return f;
1978 /* Compile an entire file of output from cpp, named NAME.
1979 Write a file of assembly output and various debugging dumps. */
1981 static void
1982 compile_file (name)
1983 char *name;
1985 tree globals;
1986 int start_time;
1988 int name_specified = name != 0;
1990 if (dump_base_name == 0)
1991 dump_base_name = name ? name : "gccdump";
1993 parse_time = 0;
1994 varconst_time = 0;
1995 integration_time = 0;
1996 jump_time = 0;
1997 cse_time = 0;
1998 loop_time = 0;
1999 cse2_time = 0;
2000 flow_time = 0;
2001 combine_time = 0;
2002 sched_time = 0;
2003 local_alloc_time = 0;
2004 global_alloc_time = 0;
2005 sched2_time = 0;
2006 dbr_sched_time = 0;
2007 shorten_branch_time = 0;
2008 stack_reg_time = 0;
2009 final_time = 0;
2010 symout_time = 0;
2011 dump_time = 0;
2013 /* Open input file. */
2015 if (name == 0 || !strcmp (name, "-"))
2017 finput = stdin;
2018 name = "stdin";
2020 else
2021 finput = fopen (name, "r");
2022 if (finput == 0)
2023 pfatal_with_name (name);
2025 #ifdef IO_BUFFER_SIZE
2026 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2027 #endif
2029 /* Initialize data in various passes. */
2031 init_obstacks ();
2032 init_tree_codes ();
2033 init_lex ();
2034 /* Some of these really don't need to be called when generating bytecode,
2035 but the options would have to be parsed first to know that. -bson */
2036 init_rtl ();
2037 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2038 || debug_info_level == DINFO_LEVEL_VERBOSE);
2039 init_regs ();
2040 init_decl_processing ();
2041 init_optabs ();
2042 init_stmt ();
2043 init_expmed ();
2044 init_expr_once ();
2045 init_loop ();
2046 init_reload ();
2048 if (flag_caller_saves)
2049 init_caller_save ();
2051 /* If auxiliary info generation is desired, open the output file.
2052 This goes in the same directory as the source file--unlike
2053 all the other output files. */
2054 if (flag_gen_aux_info)
2056 aux_info_file = fopen (aux_info_file_name, "w");
2057 if (aux_info_file == 0)
2058 pfatal_with_name (aux_info_file_name);
2061 /* If rtl dump desired, open the output file. */
2062 if (rtl_dump)
2063 rtl_dump_file = open_dump_file (dump_base_name, ".rtl");
2065 /* If jump_opt dump desired, open the output file. */
2066 if (jump_opt_dump)
2067 jump_opt_dump_file = open_dump_file (dump_base_name, ".jump");
2069 /* If cse dump desired, open the output file. */
2070 if (cse_dump)
2071 cse_dump_file = open_dump_file (dump_base_name, ".cse");
2073 /* If loop dump desired, open the output file. */
2074 if (loop_dump)
2075 loop_dump_file = open_dump_file (dump_base_name, ".loop");
2077 /* If cse2 dump desired, open the output file. */
2078 if (cse2_dump)
2079 cse2_dump_file = open_dump_file (dump_base_name, ".cse2");
2081 /* If flow dump desired, open the output file. */
2082 if (flow_dump)
2083 flow_dump_file = open_dump_file (dump_base_name, ".flow");
2085 /* If combine dump desired, open the output file. */
2086 if (combine_dump)
2087 combine_dump_file = open_dump_file (dump_base_name, ".combine");
2089 /* If scheduling dump desired, open the output file. */
2090 if (sched_dump)
2091 sched_dump_file = open_dump_file (dump_base_name, ".sched");
2093 /* If local_reg dump desired, open the output file. */
2094 if (local_reg_dump)
2095 local_reg_dump_file = open_dump_file (dump_base_name, ".lreg");
2097 /* If global_reg dump desired, open the output file. */
2098 if (global_reg_dump)
2099 global_reg_dump_file = open_dump_file (dump_base_name, ".greg");
2101 /* If 2nd scheduling dump desired, open the output file. */
2102 if (sched2_dump)
2103 sched2_dump_file = open_dump_file (dump_base_name, ".sched2");
2105 /* If jump2_opt dump desired, open the output file. */
2106 if (jump2_opt_dump)
2107 jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2");
2109 /* If dbr_sched dump desired, open the output file. */
2110 if (dbr_sched_dump)
2111 dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr");
2113 #ifdef STACK_REGS
2115 /* If stack_reg dump desired, open the output file. */
2116 if (stack_reg_dump)
2117 stack_reg_dump_file = open_dump_file (dump_base_name, ".stack");
2119 #endif
2121 /* Open assembler code output file. */
2123 if (! name_specified && asm_file_name == 0)
2124 asm_out_file = stdout;
2125 else
2127 int len = strlen (dump_base_name);
2128 register char *dumpname = (char *) xmalloc (len + 6);
2129 strcpy (dumpname, dump_base_name);
2130 strip_off_ending (dumpname, len);
2131 strcat (dumpname, ".s");
2132 if (asm_file_name == 0)
2134 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2135 strcpy (asm_file_name, dumpname);
2137 if (!strcmp (asm_file_name, "-"))
2138 asm_out_file = stdout;
2139 else
2140 asm_out_file = fopen (asm_file_name, "w");
2141 if (asm_out_file == 0)
2142 pfatal_with_name (asm_file_name);
2145 #ifdef IO_BUFFER_SIZE
2146 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2147 _IOFBF, IO_BUFFER_SIZE);
2148 #endif
2150 input_filename = name;
2152 /* Perform language-specific initialization.
2153 This may set main_input_filename. */
2154 lang_init ();
2156 /* If the input doesn't start with a #line, use the input name
2157 as the official input file name. */
2158 if (main_input_filename == 0)
2159 main_input_filename = name;
2161 /* Put an entry on the input file stack for the main input file. */
2162 input_file_stack
2163 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2164 input_file_stack->next = 0;
2165 input_file_stack->name = input_filename;
2167 if (!output_bytecode)
2169 ASM_FILE_START (asm_out_file);
2172 /* Output something to inform GDB that this compilation was by GCC. Also
2173 serves to tell GDB file consists of bytecodes. */
2174 if (output_bytecode)
2175 fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
2176 else
2178 #ifndef ASM_IDENTIFY_GCC
2179 fprintf (asm_out_file, "gcc2_compiled.:\n");
2180 #else
2181 ASM_IDENTIFY_GCC (asm_out_file);
2182 #endif
2185 /* Output something to identify which front-end produced this file. */
2186 #ifdef ASM_IDENTIFY_LANGUAGE
2187 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2188 #endif
2190 if (output_bytecode)
2192 if (profile_flag || profile_block_flag)
2193 error ("profiling not supported in bytecode compilation");
2195 else
2197 /* ??? Note: There used to be a conditional here
2198 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2199 This was to guarantee separation between gcc_compiled. and
2200 the first function, for the sake of dbx on Suns.
2201 However, having the extra zero here confused the Emacs
2202 code for unexec, and might confuse other programs too.
2203 Therefore, I took out that change.
2204 In future versions we should find another way to solve
2205 that dbx problem. -- rms, 23 May 93. */
2207 /* Don't let the first function fall at the same address
2208 as gcc_compiled., if profiling. */
2209 if (profile_flag || profile_block_flag)
2210 assemble_zeros (UNITS_PER_WORD);
2213 /* If dbx symbol table desired, initialize writing it
2214 and output the predefined types. */
2215 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2216 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2217 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2218 getdecls ()));
2219 #endif
2220 #ifdef SDB_DEBUGGING_INFO
2221 if (write_symbols == SDB_DEBUG)
2222 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2223 getdecls ()));
2224 #endif
2225 #ifdef DWARF_DEBUGGING_INFO
2226 if (write_symbols == DWARF_DEBUG)
2227 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2228 #endif
2230 /* Initialize yet another pass. */
2232 if (!output_bytecode)
2233 init_final (main_input_filename);
2235 start_time = get_run_time ();
2237 /* Call the parser, which parses the entire file
2238 (calling rest_of_compilation for each function). */
2240 if (yyparse () != 0)
2242 if (errorcount == 0)
2243 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2245 /* In case there were missing closebraces,
2246 get us back to the global binding level. */
2247 while (! global_bindings_p ())
2248 poplevel (0, 0, 0);
2251 /* Compilation is now finished except for writing
2252 what's left of the symbol table output. */
2254 parse_time += get_run_time () - start_time;
2256 parse_time -= integration_time;
2257 parse_time -= varconst_time;
2259 globals = getdecls ();
2261 /* Really define vars that have had only a tentative definition.
2262 Really output inline functions that must actually be callable
2263 and have not been output so far. */
2266 int len = list_length (globals);
2267 tree *vec = (tree *) alloca (sizeof (tree) * len);
2268 int i;
2269 tree decl;
2271 /* Process the decls in reverse order--earliest first.
2272 Put them into VEC from back to front, then take out from front. */
2274 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2275 vec[len - i - 1] = decl;
2277 for (i = 0; i < len; i++)
2279 decl = vec[i];
2281 /* We're not deferring this any longer. */
2282 DECL_DEFER_OUTPUT (decl) = 0;
2284 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2285 && incomplete_decl_finalize_hook != 0)
2286 (*incomplete_decl_finalize_hook) (decl);
2288 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2289 && ! TREE_ASM_WRITTEN (decl))
2291 /* Don't write out static consts, unless we still need them.
2293 We also keep static consts if not optimizing (for debugging).
2294 ??? They might be better written into the debug information.
2295 This is possible when using DWARF.
2297 A language processor that wants static constants to be always
2298 written out (even if it is not used) is responsible for
2299 calling rest_of_decl_compilation itself. E.g. the C front-end
2300 calls rest_of_decl_compilation from finish_decl.
2301 One motivation for this is that is conventional in some
2302 environments to write things like:
2303 static const char rcsid[] = "... version string ...";
2304 intending to force the string to be in the executable.
2306 A language processor that would prefer to have unneeded
2307 static constants "optimized away" would just defer writing
2308 them out until here. E.g. C++ does this, because static
2309 constants are often defined in header files.
2311 ??? A tempting alternative (for both C and C++) would be
2312 to force a constant to be written if and only if it is
2313 defined in a main file, as opposed to an include file. */
2315 if (! TREE_READONLY (decl)
2316 || TREE_PUBLIC (decl)
2317 || !optimize
2318 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2319 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2320 else
2321 /* Cancel the RTL for this decl so that, if debugging info
2322 output for global variables is still to come,
2323 this one will be omitted. */
2324 DECL_RTL (decl) = NULL;
2327 if (TREE_CODE (decl) == FUNCTION_DECL
2328 && ! TREE_ASM_WRITTEN (decl)
2329 && DECL_INITIAL (decl) != 0
2330 && DECL_SAVED_INSNS (decl) != 0
2331 && (flag_keep_inline_functions
2332 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2333 && ! DECL_EXTERNAL (decl))
2335 temporary_allocation ();
2336 output_inline_function (decl);
2337 permanent_allocation (1);
2340 /* Warn about any function
2341 declared static but not defined.
2342 We don't warn about variables,
2343 because many programs have static variables
2344 that exist only to get some text into the object file. */
2345 if (TREE_CODE (decl) == FUNCTION_DECL
2346 && (warn_unused
2347 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2348 && DECL_INITIAL (decl) == 0
2349 && DECL_EXTERNAL (decl)
2350 && ! TREE_PUBLIC (decl))
2352 pedwarn_with_decl (decl,
2353 "`%s' declared `static' but never defined");
2354 /* This symbol is effectively an "extern" declaration now. */
2355 TREE_PUBLIC (decl) = 1;
2356 assemble_external (decl);
2359 /* Warn about static fns or vars defined but not used,
2360 but not about inline functions or static consts
2361 since defining those in header files is normal practice. */
2362 if (warn_unused
2363 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2364 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2365 && ! DECL_IN_SYSTEM_HEADER (decl)
2366 && ! DECL_EXTERNAL (decl)
2367 && ! TREE_PUBLIC (decl)
2368 && ! TREE_USED (decl)
2369 && ! DECL_REGISTER (decl)
2370 /* The TREE_USED bit for file-scope decls
2371 is kept in the identifier, to handle multiple
2372 external decls in different scopes. */
2373 && ! TREE_USED (DECL_NAME (decl)))
2374 warning_with_decl (decl, "`%s' defined but not used");
2376 #ifdef SDB_DEBUGGING_INFO
2377 /* The COFF linker can move initialized global vars to the end.
2378 And that can screw up the symbol ordering.
2379 By putting the symbols in that order to begin with,
2380 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2381 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2382 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2383 && ! DECL_EXTERNAL (decl)
2384 && DECL_RTL (decl) != 0)
2385 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2387 /* Output COFF information for non-global
2388 file-scope initialized variables. */
2389 if (write_symbols == SDB_DEBUG
2390 && TREE_CODE (decl) == VAR_DECL
2391 && DECL_INITIAL (decl)
2392 && ! DECL_EXTERNAL (decl)
2393 && DECL_RTL (decl) != 0
2394 && GET_CODE (DECL_RTL (decl)) == MEM)
2395 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2396 #endif /* SDB_DEBUGGING_INFO */
2397 #ifdef DWARF_DEBUGGING_INFO
2398 /* Output DWARF information for file-scope tentative data object
2399 declarations, file-scope (extern) function declarations (which
2400 had no corresponding body) and file-scope tagged type declarations
2401 and definitions which have not yet been forced out. */
2403 if (write_symbols == DWARF_DEBUG
2404 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2405 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2406 #endif
2410 /* Do dbx symbols */
2411 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2412 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2413 TIMEVAR (symout_time,
2415 dbxout_finish (asm_out_file, main_input_filename);
2417 #endif
2419 #ifdef DWARF_DEBUGGING_INFO
2420 if (write_symbols == DWARF_DEBUG)
2421 TIMEVAR (symout_time,
2423 dwarfout_finish ();
2425 #endif
2427 /* Output some stuff at end of file if nec. */
2429 if (!output_bytecode)
2431 end_final (main_input_filename);
2433 #ifdef ASM_FILE_END
2434 ASM_FILE_END (asm_out_file);
2435 #endif
2438 /* Language-specific end of compilation actions. */
2440 lang_finish ();
2442 if (output_bytecode)
2443 bc_write_file (asm_out_file);
2445 /* Close the dump files. */
2447 if (flag_gen_aux_info)
2449 fclose (aux_info_file);
2450 if (errorcount)
2451 unlink (aux_info_file_name);
2454 if (rtl_dump)
2455 fclose (rtl_dump_file);
2457 if (jump_opt_dump)
2458 fclose (jump_opt_dump_file);
2460 if (cse_dump)
2461 fclose (cse_dump_file);
2463 if (loop_dump)
2464 fclose (loop_dump_file);
2466 if (cse2_dump)
2467 fclose (cse2_dump_file);
2469 if (flow_dump)
2470 fclose (flow_dump_file);
2472 if (combine_dump)
2474 dump_combine_total_stats (combine_dump_file);
2475 fclose (combine_dump_file);
2478 if (sched_dump)
2479 fclose (sched_dump_file);
2481 if (local_reg_dump)
2482 fclose (local_reg_dump_file);
2484 if (global_reg_dump)
2485 fclose (global_reg_dump_file);
2487 if (sched2_dump)
2488 fclose (sched2_dump_file);
2490 if (jump2_opt_dump)
2491 fclose (jump2_opt_dump_file);
2493 if (dbr_sched_dump)
2494 fclose (dbr_sched_dump_file);
2496 #ifdef STACK_REGS
2497 if (stack_reg_dump)
2498 fclose (stack_reg_dump_file);
2499 #endif
2501 /* Close non-debugging input and output files. Take special care to note
2502 whether fclose returns an error, since the pages might still be on the
2503 buffer chain while the file is open. */
2505 fclose (finput);
2506 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2507 fatal_io_error (asm_file_name);
2509 /* Print the times. */
2511 if (! quiet_flag)
2513 fprintf (stderr,"\n");
2514 print_time ("parse", parse_time);
2516 if (!output_bytecode)
2518 print_time ("integration", integration_time);
2519 print_time ("jump", jump_time);
2520 print_time ("cse", cse_time);
2521 print_time ("loop", loop_time);
2522 print_time ("cse2", cse2_time);
2523 print_time ("flow", flow_time);
2524 print_time ("combine", combine_time);
2525 print_time ("sched", sched_time);
2526 print_time ("local-alloc", local_alloc_time);
2527 print_time ("global-alloc", global_alloc_time);
2528 print_time ("sched2", sched2_time);
2529 print_time ("dbranch", dbr_sched_time);
2530 print_time ("shorten-branch", shorten_branch_time);
2531 print_time ("stack-reg", stack_reg_time);
2532 print_time ("final", final_time);
2533 print_time ("varconst", varconst_time);
2534 print_time ("symout", symout_time);
2535 print_time ("dump", dump_time);
2540 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2541 and TYPE_DECL nodes.
2543 This does nothing for local (non-static) variables.
2544 Otherwise, it sets up the RTL and outputs any assembler code
2545 (label definition, storage allocation and initialization).
2547 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2548 the assembler symbol name to be used. TOP_LEVEL is nonzero
2549 if this declaration is not within a function. */
2551 void
2552 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2553 tree decl;
2554 char *asmspec;
2555 int top_level;
2556 int at_end;
2558 /* Declarations of variables, and of functions defined elsewhere. */
2560 /* The most obvious approach, to put an #ifndef around where
2561 this macro is used, doesn't work since it's inside a macro call. */
2562 #ifndef ASM_FINISH_DECLARE_OBJECT
2563 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2564 #endif
2566 /* Forward declarations for nested functions are not "external",
2567 but we need to treat them as if they were. */
2568 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2569 || TREE_CODE (decl) == FUNCTION_DECL)
2570 TIMEVAR (varconst_time,
2572 make_decl_rtl (decl, asmspec, top_level);
2573 /* Initialized extern variable exists to be replaced
2574 with its value, or represents something that will be
2575 output in another file. */
2576 if (! (TREE_CODE (decl) == VAR_DECL
2577 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2578 && DECL_INITIAL (decl) != 0
2579 && DECL_INITIAL (decl) != error_mark_node))
2580 /* Don't output anything
2581 when a tentative file-scope definition is seen.
2582 But at end of compilation, do output code for them. */
2583 if (! (! at_end && top_level
2584 && (DECL_INITIAL (decl) == 0
2585 || DECL_INITIAL (decl) == error_mark_node)))
2586 assemble_variable (decl, top_level, at_end, 0);
2587 if (decl == last_assemble_variable_decl)
2589 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2590 top_level, at_end);
2593 else if (DECL_REGISTER (decl) && asmspec != 0)
2595 if (decode_reg_name (asmspec) >= 0)
2597 DECL_RTL (decl) = 0;
2598 make_decl_rtl (decl, asmspec, top_level);
2600 else
2601 error ("invalid register name `%s' for register variable", asmspec);
2603 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2604 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2605 && TREE_CODE (decl) == TYPE_DECL)
2606 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2607 #endif
2608 #ifdef SDB_DEBUGGING_INFO
2609 else if (write_symbols == SDB_DEBUG && top_level
2610 && TREE_CODE (decl) == TYPE_DECL)
2611 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2612 #endif
2615 /* Called after finishing a record, union or enumeral type. */
2617 void
2618 rest_of_type_compilation (type, toplev)
2619 tree type;
2620 int toplev;
2622 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2623 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2624 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2625 #endif
2626 #ifdef SDB_DEBUGGING_INFO
2627 if (write_symbols == SDB_DEBUG)
2628 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2629 #endif
2632 /* This is called from finish_function (within yyparse)
2633 after each top-level definition is parsed.
2634 It is supposed to compile that function or variable
2635 and output the assembler code for it.
2636 After we return, the tree storage is freed. */
2638 void
2639 rest_of_compilation (decl)
2640 tree decl;
2642 register rtx insns;
2643 int start_time = get_run_time ();
2644 int tem;
2645 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2646 to be restored after we finish compiling the function
2647 (for use when compiling inline calls to this function). */
2648 tree saved_block_tree = 0;
2649 /* Likewise, for DECL_ARGUMENTS. */
2650 tree saved_arguments = 0;
2651 int failure = 0;
2653 if (output_bytecode)
2654 return;
2656 /* If we are reconsidering an inline function
2657 at the end of compilation, skip the stuff for making it inline. */
2659 if (DECL_SAVED_INSNS (decl) == 0)
2661 int specd = DECL_INLINE (decl);
2662 char *lose;
2664 /* If requested, consider whether to make this function inline. */
2665 if (specd || flag_inline_functions)
2666 TIMEVAR (integration_time,
2668 lose = function_cannot_inline_p (decl);
2669 /* If not optimzing, then make sure the DECL_INLINE
2670 bit is off. */
2671 if (lose || ! optimize)
2673 if (warn_inline && specd)
2674 warning_with_decl (decl, lose);
2675 DECL_INLINE (decl) = 0;
2676 /* Don't really compile an extern inline function.
2677 If we can't make it inline, pretend
2678 it was only declared. */
2679 if (DECL_EXTERNAL (decl))
2681 DECL_INITIAL (decl) = 0;
2682 goto exit_rest_of_compilation;
2685 else
2686 DECL_INLINE (decl) = 1;
2689 insns = get_insns ();
2691 /* Dump the rtl code if we are dumping rtl. */
2693 if (rtl_dump)
2694 TIMEVAR (dump_time,
2696 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2697 IDENTIFIER_POINTER (DECL_NAME (decl)));
2698 if (DECL_SAVED_INSNS (decl))
2699 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2700 print_rtl (rtl_dump_file, insns);
2701 fflush (rtl_dump_file);
2704 /* If function is inline, and we don't yet know whether to
2705 compile it by itself, defer decision till end of compilation.
2706 finish_compilation will call rest_of_compilation again
2707 for those functions that need to be output. Also defer those
2708 functions that were marked inline but weren't inlined; they
2709 may never be used. */
2711 if ((specd || DECL_INLINE (decl))
2712 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2713 && ! flag_keep_inline_functions)
2714 || DECL_DEFER_OUTPUT (decl)
2715 || DECL_EXTERNAL (decl)))
2717 #ifdef DWARF_DEBUGGING_INFO
2718 /* Generate the DWARF info for the "abstract" instance
2719 of a function which we may later generate inlined and/or
2720 out-of-line instances of. */
2721 if (write_symbols == DWARF_DEBUG)
2723 set_decl_abstract_flags (decl, 1);
2724 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2725 set_decl_abstract_flags (decl, 0);
2727 #endif
2728 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2729 goto exit_rest_of_compilation;
2732 /* If we have to compile the function now, save its rtl and subdecls
2733 so that its compilation will not affect what others get. */
2734 if (DECL_INLINE (decl))
2736 #ifdef DWARF_DEBUGGING_INFO
2737 /* Generate the DWARF info for the "abstract" instance of
2738 a function which we will generate an out-of-line instance
2739 of almost immediately (and which we may also later generate
2740 various inlined instances of). */
2741 if (write_symbols == DWARF_DEBUG)
2743 set_decl_abstract_flags (decl, 1);
2744 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2745 set_decl_abstract_flags (decl, 0);
2747 #endif
2748 saved_block_tree = DECL_INITIAL (decl);
2749 saved_arguments = DECL_ARGUMENTS (decl);
2750 TIMEVAR (integration_time, save_for_inline_copying (decl));
2754 if (DECL_DEFER_OUTPUT (decl))
2755 goto exit_rest_of_compilation;
2757 TREE_ASM_WRITTEN (decl) = 1;
2759 /* Now that integrate will no longer see our rtl, we need not distinguish
2760 between the return value of this function and the return value of called
2761 functions. */
2762 rtx_equal_function_value_matters = 0;
2764 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2765 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2767 goto exit_rest_of_compilation;
2770 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2771 Note that that may have been done above, in save_for_inline_copying.
2772 The call to resume_temporary_allocation near the end of this function
2773 goes back to the usual state of affairs. */
2775 rtl_in_current_obstack ();
2777 #ifdef FINALIZE_PIC
2778 /* If we are doing position-independent code generation, now
2779 is the time to output special prologues and epilogues.
2780 We do not want to do this earlier, because it just clutters
2781 up inline functions with meaningless insns. */
2782 if (flag_pic)
2783 FINALIZE_PIC;
2784 #endif
2786 insns = get_insns ();
2788 /* Copy any shared structure that should not be shared. */
2790 unshare_all_rtl (insns);
2792 /* Instantiate all virtual registers. */
2794 instantiate_virtual_regs (current_function_decl, get_insns ());
2796 /* See if we have allocated stack slots that are not directly addressable.
2797 If so, scan all the insns and create explicit address computation
2798 for all references to such slots. */
2799 /* fixup_stack_slots (); */
2801 /* Do jump optimization the first time, if -opt.
2802 Also do it if -W, but in that case it doesn't change the rtl code,
2803 it only computes whether control can drop off the end of the function. */
2805 if (optimize > 0 || extra_warnings || warn_return_type
2806 /* If function is `noreturn', we should warn if it tries to return. */
2807 || TREE_THIS_VOLATILE (decl))
2809 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2810 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2813 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2814 if (rtl_dump_and_exit || flag_syntax_only)
2815 goto exit_rest_of_compilation;
2817 /* Dump rtl code after jump, if we are doing that. */
2819 if (jump_opt_dump)
2820 TIMEVAR (dump_time,
2822 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2823 IDENTIFIER_POINTER (DECL_NAME (decl)));
2824 print_rtl (jump_opt_dump_file, insns);
2825 fflush (jump_opt_dump_file);
2828 /* Perform common subexpression elimination.
2829 Nonzero value from `cse_main' means that jumps were simplified
2830 and some code may now be unreachable, so do
2831 jump optimization again. */
2833 if (cse_dump)
2834 TIMEVAR (dump_time,
2836 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2837 IDENTIFIER_POINTER (DECL_NAME (decl)));
2840 if (optimize > 0)
2842 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2844 if (flag_thread_jumps)
2845 /* Hacks by tiemann & kenner. */
2846 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
2848 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2849 0, cse_dump_file));
2850 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2852 if (tem)
2853 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2856 /* Dump rtl code after cse, if we are doing that. */
2858 if (cse_dump)
2859 TIMEVAR (dump_time,
2861 print_rtl (cse_dump_file, insns);
2862 fflush (cse_dump_file);
2865 if (loop_dump)
2866 TIMEVAR (dump_time,
2868 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2869 IDENTIFIER_POINTER (DECL_NAME (decl)));
2872 /* Move constant computations out of loops. */
2874 if (optimize > 0)
2876 TIMEVAR (loop_time,
2878 loop_optimize (insns, loop_dump_file);
2882 /* Dump rtl code after loop opt, if we are doing that. */
2884 if (loop_dump)
2885 TIMEVAR (dump_time,
2887 print_rtl (loop_dump_file, insns);
2888 fflush (loop_dump_file);
2891 if (cse2_dump)
2892 TIMEVAR (dump_time,
2894 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2895 IDENTIFIER_POINTER (DECL_NAME (decl)));
2898 if (optimize > 0 && flag_rerun_cse_after_loop)
2900 /* Running another jump optimization pass before the second
2901 cse pass sometimes simplifies the RTL enough to allow
2902 the second CSE pass to do a better job. Jump_optimize can change
2903 max_reg_num so we must rerun reg_scan afterwards.
2904 ??? Rework to not call reg_scan so often. */
2905 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2906 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2908 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2909 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2910 1, cse2_dump_file));
2911 if (tem)
2912 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2915 if (optimize > 0 && flag_thread_jumps)
2916 /* This pass of jump threading straightens out code
2917 that was kinked by loop optimization. */
2918 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2920 /* Dump rtl code after cse, if we are doing that. */
2922 if (cse2_dump)
2923 TIMEVAR (dump_time,
2925 print_rtl (cse2_dump_file, insns);
2926 fflush (cse2_dump_file);
2929 /* We are no longer anticipating cse in this function, at least. */
2931 cse_not_expected = 1;
2933 /* Now we choose between stupid (pcc-like) register allocation
2934 (if we got the -noreg switch and not -opt)
2935 and smart register allocation. */
2937 if (optimize > 0) /* Stupid allocation probably won't work */
2938 obey_regdecls = 0; /* if optimizations being done. */
2940 regclass_init ();
2942 /* Print function header into flow dump now
2943 because doing the flow analysis makes some of the dump. */
2945 if (flow_dump)
2946 TIMEVAR (dump_time,
2948 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2949 IDENTIFIER_POINTER (DECL_NAME (decl)));
2952 if (obey_regdecls)
2954 TIMEVAR (flow_time,
2956 regclass (insns, max_reg_num ());
2957 stupid_life_analysis (insns, max_reg_num (),
2958 flow_dump_file);
2961 else
2963 /* Do control and data flow analysis,
2964 and write some of the results to dump file. */
2966 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2967 flow_dump_file));
2968 if (warn_uninitialized)
2970 uninitialized_vars_warning (DECL_INITIAL (decl));
2971 setjmp_args_warning ();
2975 /* Dump rtl after flow analysis. */
2977 if (flow_dump)
2978 TIMEVAR (dump_time,
2980 print_rtl (flow_dump_file, insns);
2981 fflush (flow_dump_file);
2984 /* If -opt, try combining insns through substitution. */
2986 if (optimize > 0)
2987 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2989 /* Dump rtl code after insn combination. */
2991 if (combine_dump)
2992 TIMEVAR (dump_time,
2994 fprintf (combine_dump_file, "\n;; Function %s\n\n",
2995 IDENTIFIER_POINTER (DECL_NAME (decl)));
2996 dump_combine_stats (combine_dump_file);
2997 print_rtl (combine_dump_file, insns);
2998 fflush (combine_dump_file);
3001 /* Print function header into sched dump now
3002 because doing the sched analysis makes some of the dump. */
3004 if (sched_dump)
3005 TIMEVAR (dump_time,
3007 fprintf (sched_dump_file, "\n;; Function %s\n\n",
3008 IDENTIFIER_POINTER (DECL_NAME (decl)));
3011 if (optimize > 0 && flag_schedule_insns)
3013 /* Do control and data sched analysis,
3014 and write some of the results to dump file. */
3016 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
3019 /* Dump rtl after instruction scheduling. */
3021 if (sched_dump)
3022 TIMEVAR (dump_time,
3024 print_rtl (sched_dump_file, insns);
3025 fflush (sched_dump_file);
3028 /* Unless we did stupid register allocation,
3029 allocate pseudo-regs that are used only within 1 basic block. */
3031 if (!obey_regdecls)
3032 TIMEVAR (local_alloc_time,
3034 regclass (insns, max_reg_num ());
3035 local_alloc ();
3038 /* Dump rtl code after allocating regs within basic blocks. */
3040 if (local_reg_dump)
3041 TIMEVAR (dump_time,
3043 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
3044 IDENTIFIER_POINTER (DECL_NAME (decl)));
3045 dump_flow_info (local_reg_dump_file);
3046 dump_local_alloc (local_reg_dump_file);
3047 print_rtl (local_reg_dump_file, insns);
3048 fflush (local_reg_dump_file);
3051 if (global_reg_dump)
3052 TIMEVAR (dump_time,
3053 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
3054 IDENTIFIER_POINTER (DECL_NAME (decl))));
3056 /* Unless we did stupid register allocation,
3057 allocate remaining pseudo-regs, then do the reload pass
3058 fixing up any insns that are invalid. */
3060 TIMEVAR (global_alloc_time,
3062 if (!obey_regdecls)
3063 failure = global_alloc (global_reg_dump_file);
3064 else
3065 failure = reload (insns, 0, global_reg_dump_file);
3068 if (global_reg_dump)
3069 TIMEVAR (dump_time,
3071 dump_global_regs (global_reg_dump_file);
3072 print_rtl (global_reg_dump_file, insns);
3073 fflush (global_reg_dump_file);
3076 if (failure)
3077 goto exit_rest_of_compilation;
3079 reload_completed = 1;
3081 /* On some machines, the prologue and epilogue code, or parts thereof,
3082 can be represented as RTL. Doing so lets us schedule insns between
3083 it and the rest of the code and also allows delayed branch
3084 scheduling to operate in the epilogue. */
3086 thread_prologue_and_epilogue_insns (insns);
3088 if (optimize > 0 && flag_schedule_insns_after_reload)
3090 if (sched2_dump)
3091 TIMEVAR (dump_time,
3093 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
3094 IDENTIFIER_POINTER (DECL_NAME (decl)));
3097 /* Do control and data sched analysis again,
3098 and write some more of the results to dump file. */
3100 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
3102 /* Dump rtl after post-reorder instruction scheduling. */
3104 if (sched2_dump)
3105 TIMEVAR (dump_time,
3107 print_rtl (sched2_dump_file, insns);
3108 fflush (sched2_dump_file);
3112 #ifdef LEAF_REGISTERS
3113 leaf_function = 0;
3114 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3115 leaf_function = 1;
3116 #endif
3118 /* One more attempt to remove jumps to .+1
3119 left by dead-store-elimination.
3120 Also do cross-jumping this time
3121 and delete no-op move insns. */
3123 if (optimize > 0)
3125 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3128 /* Dump rtl code after jump, if we are doing that. */
3130 if (jump2_opt_dump)
3131 TIMEVAR (dump_time,
3133 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
3134 IDENTIFIER_POINTER (DECL_NAME (decl)));
3135 print_rtl (jump2_opt_dump_file, insns);
3136 fflush (jump2_opt_dump_file);
3139 /* If a machine dependent reorganization is needed, call it. */
3140 #ifdef MACHINE_DEPENDENT_REORG
3141 MACHINE_DEPENDENT_REORG (insns);
3142 #endif
3144 /* If a scheduling pass for delayed branches is to be done,
3145 call the scheduling code. */
3147 #ifdef DELAY_SLOTS
3148 if (optimize > 0 && flag_delayed_branch)
3150 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3151 if (dbr_sched_dump)
3153 TIMEVAR (dump_time,
3155 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
3156 IDENTIFIER_POINTER (DECL_NAME (decl)));
3157 print_rtl (dbr_sched_dump_file, insns);
3158 fflush (dbr_sched_dump_file);
3162 #endif
3164 if (optimize > 0)
3165 /* Shorten branches. */
3166 TIMEVAR (shorten_branch_time,
3168 shorten_branches (get_insns ());
3171 #ifdef STACK_REGS
3172 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3173 if (stack_reg_dump)
3175 TIMEVAR (dump_time,
3177 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
3178 IDENTIFIER_POINTER (DECL_NAME (decl)));
3179 print_rtl (stack_reg_dump_file, insns);
3180 fflush (stack_reg_dump_file);
3183 #endif
3185 /* Now turn the rtl into assembler code. */
3187 TIMEVAR (final_time,
3189 rtx x;
3190 char *fnname;
3192 /* Get the function's name, as described by its RTL.
3193 This may be different from the DECL_NAME name used
3194 in the source file. */
3196 x = DECL_RTL (decl);
3197 if (GET_CODE (x) != MEM)
3198 abort ();
3199 x = XEXP (x, 0);
3200 if (GET_CODE (x) != SYMBOL_REF)
3201 abort ();
3202 fnname = XSTR (x, 0);
3204 assemble_start_function (decl, fnname);
3205 final_start_function (insns, asm_out_file, optimize);
3206 final (insns, asm_out_file, optimize, 0);
3207 final_end_function (insns, asm_out_file, optimize);
3208 assemble_end_function (decl, fnname);
3209 fflush (asm_out_file);
3212 /* Write DBX symbols if requested */
3214 /* Note that for those inline functions where we don't initially
3215 know for certain that we will be generating an out-of-line copy,
3216 the first invocation of this routine (rest_of_compilation) will
3217 skip over this code by doing a `goto exit_rest_of_compilation;'.
3218 Later on, finish_compilation will call rest_of_compilation again
3219 for those inline functions that need to have out-of-line copies
3220 generated. During that call, we *will* be routed past here. */
3222 #ifdef DBX_DEBUGGING_INFO
3223 if (write_symbols == DBX_DEBUG)
3224 TIMEVAR (symout_time, dbxout_function (decl));
3225 #endif
3227 #ifdef DWARF_DEBUGGING_INFO
3228 if (write_symbols == DWARF_DEBUG)
3229 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3230 #endif
3232 exit_rest_of_compilation:
3234 /* In case the function was not output,
3235 don't leave any temporary anonymous types
3236 queued up for sdb output. */
3237 #ifdef SDB_DEBUGGING_INFO
3238 if (write_symbols == SDB_DEBUG)
3239 sdbout_types (NULL_TREE);
3240 #endif
3242 /* Put back the tree of subblocks and list of arguments
3243 from before we copied them.
3244 Code generation and the output of debugging info may have modified
3245 the copy, but the original is unchanged. */
3247 if (saved_block_tree != 0)
3248 DECL_INITIAL (decl) = saved_block_tree;
3249 if (saved_arguments != 0)
3250 DECL_ARGUMENTS (decl) = saved_arguments;
3252 reload_completed = 0;
3254 /* Clear out the real_constant_chain before some of the rtx's
3255 it runs through become garbage. */
3257 clear_const_double_mem ();
3259 /* Cancel the effect of rtl_in_current_obstack. */
3261 resume_temporary_allocation ();
3263 /* The parsing time is all the time spent in yyparse
3264 *except* what is spent in this function. */
3266 parse_time -= get_run_time () - start_time;
3269 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3270 Exit code is 35 if can't open files, 34 if fatal error,
3271 33 if had nonfatal errors, else success. */
3274 main (argc, argv, envp)
3275 int argc;
3276 char **argv;
3277 char **envp;
3279 register int i;
3280 char *filename = 0;
3281 int flag_print_mem = 0;
3282 int version_flag = 0;
3283 char *p;
3285 /* save in case md file wants to emit args as a comment. */
3286 save_argc = argc;
3287 save_argv = argv;
3289 p = argv[0] + strlen (argv[0]);
3290 while (p != argv[0] && p[-1] != '/') --p;
3291 progname = p;
3293 #ifdef RLIMIT_STACK
3294 /* Get rid of any avoidable limit on stack size. */
3296 struct rlimit rlim;
3298 /* Set the stack limit huge so that alloca does not fail. */
3299 getrlimit (RLIMIT_STACK, &rlim);
3300 rlim.rlim_cur = rlim.rlim_max;
3301 setrlimit (RLIMIT_STACK, &rlim);
3303 #endif /* RLIMIT_STACK */
3305 signal (SIGFPE, float_signal);
3307 #ifdef SIGPIPE
3308 signal (SIGPIPE, pipe_closed);
3309 #endif
3311 decl_printable_name = decl_name;
3312 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3314 /* Initialize whether `char' is signed. */
3315 flag_signed_char = DEFAULT_SIGNED_CHAR;
3316 #ifdef DEFAULT_SHORT_ENUMS
3317 /* Initialize how much space enums occupy, by default. */
3318 flag_short_enums = DEFAULT_SHORT_ENUMS;
3319 #endif
3321 /* Scan to see what optimization level has been specified. That will
3322 determine the default value of many flags. */
3323 for (i = 1; i < argc; i++)
3325 if (!strcmp (argv[i], "-O"))
3327 optimize = 1;
3329 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3331 /* Handle -O2, -O3, -O69, ... */
3332 char *p = &argv[i][2];
3333 int c;
3335 while (c = *p++)
3336 if (! (c >= '0' && c <= '9'))
3337 break;
3338 if (c == 0)
3339 optimize = atoi (&argv[i][2]);
3343 obey_regdecls = (optimize == 0);
3344 if (optimize == 0)
3346 flag_no_inline = 1;
3347 warn_inline = 0;
3350 if (optimize >= 1)
3352 flag_defer_pop = 1;
3353 flag_thread_jumps = 1;
3354 #ifdef DELAY_SLOTS
3355 flag_delayed_branch = 1;
3356 #endif
3357 #ifdef CAN_DEBUG_WITHOUT_FP
3358 flag_omit_frame_pointer = 1;
3359 #endif
3362 if (optimize >= 2)
3364 flag_cse_follow_jumps = 1;
3365 flag_cse_skip_blocks = 1;
3366 flag_expensive_optimizations = 1;
3367 flag_strength_reduce = 1;
3368 flag_rerun_cse_after_loop = 1;
3369 flag_caller_saves = 1;
3370 #ifdef INSN_SCHEDULING
3371 flag_schedule_insns = 1;
3372 flag_schedule_insns_after_reload = 1;
3373 #endif
3376 if (optimize >= 3)
3378 flag_inline_functions = 1;
3381 #ifdef OPTIMIZATION_OPTIONS
3382 /* Allow default optimizations to be specified on a per-machine basis. */
3383 OPTIMIZATION_OPTIONS (optimize);
3384 #endif
3386 /* Initialize register usage now so switches may override. */
3387 init_reg_sets ();
3389 target_flags = 0;
3390 set_target_switch ("");
3392 for (i = 1; i < argc; i++)
3394 int j;
3395 /* If this is a language-specific option,
3396 decode it in a language-specific way. */
3397 for (j = 0; lang_options[j] != 0; j++)
3398 if (!strncmp (argv[i], lang_options[j],
3399 strlen (lang_options[j])))
3400 break;
3401 if (lang_options[j] != 0)
3402 /* If the option is valid for *some* language,
3403 treat it as valid even if this language doesn't understand it. */
3404 lang_decode_option (argv[i]);
3405 else if (argv[i][0] == '-' && argv[i][1] != 0)
3407 register char *str = argv[i] + 1;
3408 if (str[0] == 'Y')
3409 str++;
3411 if (str[0] == 'm')
3412 set_target_switch (&str[1]);
3413 else if (!strcmp (str, "dumpbase"))
3415 dump_base_name = argv[++i];
3417 else if (str[0] == 'd')
3419 register char *p = &str[1];
3420 while (*p)
3421 switch (*p++)
3423 case 'a':
3424 combine_dump = 1;
3425 dbr_sched_dump = 1;
3426 flow_dump = 1;
3427 global_reg_dump = 1;
3428 jump_opt_dump = 1;
3429 jump2_opt_dump = 1;
3430 local_reg_dump = 1;
3431 loop_dump = 1;
3432 rtl_dump = 1;
3433 cse_dump = 1, cse2_dump = 1;
3434 sched_dump = 1;
3435 sched2_dump = 1;
3436 stack_reg_dump = 1;
3437 break;
3438 case 'k':
3439 stack_reg_dump = 1;
3440 break;
3441 case 'c':
3442 combine_dump = 1;
3443 break;
3444 case 'd':
3445 dbr_sched_dump = 1;
3446 break;
3447 case 'f':
3448 flow_dump = 1;
3449 break;
3450 case 'g':
3451 global_reg_dump = 1;
3452 break;
3453 case 'j':
3454 jump_opt_dump = 1;
3455 break;
3456 case 'J':
3457 jump2_opt_dump = 1;
3458 break;
3459 case 'l':
3460 local_reg_dump = 1;
3461 break;
3462 case 'L':
3463 loop_dump = 1;
3464 break;
3465 case 'm':
3466 flag_print_mem = 1;
3467 break;
3468 case 'p':
3469 flag_print_asm_name = 1;
3470 break;
3471 case 'r':
3472 rtl_dump = 1;
3473 break;
3474 case 's':
3475 cse_dump = 1;
3476 break;
3477 case 't':
3478 cse2_dump = 1;
3479 break;
3480 case 'S':
3481 sched_dump = 1;
3482 break;
3483 case 'R':
3484 sched2_dump = 1;
3485 break;
3486 case 'y':
3487 set_yydebug (1);
3488 break;
3490 case 'x':
3491 rtl_dump_and_exit = 1;
3492 break;
3495 else if (str[0] == 'f')
3497 register char *p = &str[1];
3498 int found = 0;
3500 /* Some kind of -f option.
3501 P's value is the option sans `-f'.
3502 Search for it in the table of options. */
3504 for (j = 0;
3505 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3506 j++)
3508 if (!strcmp (p, f_options[j].string))
3510 *f_options[j].variable = f_options[j].on_value;
3511 /* A goto here would be cleaner,
3512 but breaks the vax pcc. */
3513 found = 1;
3515 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3516 && ! strcmp (p+3, f_options[j].string))
3518 *f_options[j].variable = ! f_options[j].on_value;
3519 found = 1;
3523 if (found)
3525 else if (!strncmp (p, "fixed-", 6))
3526 fix_register (&p[6], 1, 1);
3527 else if (!strncmp (p, "call-used-", 10))
3528 fix_register (&p[10], 0, 1);
3529 else if (!strncmp (p, "call-saved-", 11))
3530 fix_register (&p[11], 0, 0);
3531 else
3532 error ("Invalid option `%s'", argv[i]);
3534 else if (str[0] == 'O')
3536 register char *p = str+1;
3537 while (*p && *p >= '0' && *p <= '9')
3538 p++;
3539 if (*p == '\0')
3541 else
3542 error ("Invalid option `%s'", argv[i]);
3544 else if (!strcmp (str, "pedantic"))
3545 pedantic = 1;
3546 else if (!strcmp (str, "pedantic-errors"))
3547 flag_pedantic_errors = pedantic = 1;
3548 else if (!strcmp (str, "quiet"))
3549 quiet_flag = 1;
3550 else if (!strcmp (str, "version"))
3551 version_flag = 1;
3552 else if (!strcmp (str, "w"))
3553 inhibit_warnings = 1;
3554 else if (!strcmp (str, "W"))
3556 extra_warnings = 1;
3557 /* We save the value of warn_uninitialized, since if they put
3558 -Wuninitialized on the command line, we need to generate a
3559 warning about not using it without also specifying -O. */
3560 if (warn_uninitialized != 1)
3561 warn_uninitialized = 2;
3563 else if (str[0] == 'W')
3565 register char *p = &str[1];
3566 int found = 0;
3568 /* Some kind of -W option.
3569 P's value is the option sans `-W'.
3570 Search for it in the table of options. */
3572 for (j = 0;
3573 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3574 j++)
3576 if (!strcmp (p, W_options[j].string))
3578 *W_options[j].variable = W_options[j].on_value;
3579 /* A goto here would be cleaner,
3580 but breaks the vax pcc. */
3581 found = 1;
3583 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3584 && ! strcmp (p+3, W_options[j].string))
3586 *W_options[j].variable = ! W_options[j].on_value;
3587 found = 1;
3591 if (found)
3593 else if (!strncmp (p, "id-clash-", 9))
3595 char *endp = p + 9;
3597 while (*endp)
3599 if (*endp >= '0' && *endp <= '9')
3600 endp++;
3601 else
3603 error ("Invalid option `%s'", argv[i]);
3604 goto id_clash_lose;
3607 warn_id_clash = 1;
3608 id_clash_len = atoi (str + 10);
3609 id_clash_lose: ;
3611 else if (!strncmp (p, "larger-than-", 12))
3613 char *endp = p + 12;
3615 while (*endp)
3617 if (*endp >= '0' && *endp <= '9')
3618 endp++;
3619 else
3621 error ("Invalid option `%s'", argv[i]);
3622 goto larger_than_lose;
3625 warn_larger_than = 1;
3626 larger_than_size = atoi (str + 13);
3627 larger_than_lose: ;
3629 else
3630 error ("Invalid option `%s'", argv[i]);
3632 else if (!strcmp (str, "p"))
3634 if (!output_bytecode)
3635 profile_flag = 1;
3636 else
3637 error ("profiling not supported in bytecode compilation");
3639 else if (!strcmp (str, "a"))
3641 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3642 warning ("`-a' option (basic block profile) not supported");
3643 #else
3644 profile_block_flag = 1;
3645 #endif
3647 else if (str[0] == 'g')
3649 char *p = str + 1;
3650 char *q;
3651 unsigned len;
3652 unsigned level;
3654 while (*p && (*p < '0' || *p > '9'))
3655 p++;
3656 len = p - str;
3657 q = p;
3658 while (*q && (*q >= '0' && *q <= '9'))
3659 q++;
3660 if (*p)
3661 level = atoi (p);
3662 else
3663 level = 2; /* default debugging info level */
3664 if (*q || level > 3)
3666 warning ("invalid debug level specification in option: `-%s'",
3667 str);
3668 warning ("no debugging information will be generated");
3669 level = 0;
3672 /* If more than one debugging type is supported,
3673 you must define PREFERRED_DEBUGGING_TYPE
3674 to choose a format in a system-dependent way. */
3675 /* This is one long line cause VAXC can't handle a \-newline. */
3676 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3677 #ifdef PREFERRED_DEBUGGING_TYPE
3678 if (!strncmp (str, "ggdb", len))
3679 write_symbols = PREFERRED_DEBUGGING_TYPE;
3680 #else /* no PREFERRED_DEBUGGING_TYPE */
3681 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3682 #endif /* no PREFERRED_DEBUGGING_TYPE */
3683 #endif /* More than one debugger format enabled. */
3684 #ifdef DBX_DEBUGGING_INFO
3685 if (write_symbols != NO_DEBUG)
3687 else if (!strncmp (str, "ggdb", len))
3688 write_symbols = DBX_DEBUG;
3689 else if (!strncmp (str, "gstabs", len))
3690 write_symbols = DBX_DEBUG;
3691 else if (!strncmp (str, "gstabs+", len))
3692 write_symbols = DBX_DEBUG;
3694 /* Always enable extensions for -ggdb or -gstabs+,
3695 always disable for -gstabs.
3696 For plain -g, use system-specific default. */
3697 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3698 && len >= 2)
3699 use_gnu_debug_info_extensions = 1;
3700 else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
3701 && len >= 7)
3702 use_gnu_debug_info_extensions = 1;
3703 else if (write_symbols == DBX_DEBUG
3704 && !strncmp (str, "gstabs", len) && len >= 2)
3705 use_gnu_debug_info_extensions = 0;
3706 else
3707 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3708 #endif /* DBX_DEBUGGING_INFO */
3709 #ifdef DWARF_DEBUGGING_INFO
3710 if (write_symbols != NO_DEBUG)
3712 else if (!strncmp (str, "g", len))
3713 write_symbols = DWARF_DEBUG;
3714 else if (!strncmp (str, "ggdb", len))
3715 write_symbols = DWARF_DEBUG;
3716 else if (!strncmp (str, "gdwarf", len))
3717 write_symbols = DWARF_DEBUG;
3719 /* Always enable extensions for -ggdb or -gdwarf+,
3720 always disable for -gdwarf.
3721 For plain -g, use system-specific default. */
3722 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3723 && len >= 2)
3724 use_gnu_debug_info_extensions = 1;
3725 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3726 use_gnu_debug_info_extensions = 1;
3727 else if (write_symbols == DWARF_DEBUG
3728 && !strncmp (str, "gdwarf", len) && len >= 2)
3729 use_gnu_debug_info_extensions = 0;
3730 else
3731 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3732 #endif
3733 #ifdef SDB_DEBUGGING_INFO
3734 if (write_symbols != NO_DEBUG)
3736 else if (!strncmp (str, "g", len))
3737 write_symbols = SDB_DEBUG;
3738 else if (!strncmp (str, "gdb", len))
3739 write_symbols = SDB_DEBUG;
3740 else if (!strncmp (str, "gcoff", len))
3741 write_symbols = SDB_DEBUG;
3742 #endif /* SDB_DEBUGGING_INFO */
3743 #ifdef XCOFF_DEBUGGING_INFO
3744 if (write_symbols != NO_DEBUG)
3746 else if (!strncmp (str, "g", len))
3747 write_symbols = XCOFF_DEBUG;
3748 else if (!strncmp (str, "ggdb", len))
3749 write_symbols = XCOFF_DEBUG;
3750 else if (!strncmp (str, "gxcoff", len))
3751 write_symbols = XCOFF_DEBUG;
3753 /* Always enable extensions for -ggdb or -gxcoff+,
3754 always disable for -gxcoff.
3755 For plain -g, use system-specific default. */
3756 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3757 && len >= 2)
3758 use_gnu_debug_info_extensions = 1;
3759 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3760 use_gnu_debug_info_extensions = 1;
3761 else if (write_symbols == XCOFF_DEBUG
3762 && !strncmp (str, "gxcoff", len) && len >= 2)
3763 use_gnu_debug_info_extensions = 0;
3764 else
3765 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3766 #endif
3767 if (write_symbols == NO_DEBUG)
3768 warning ("`-%s' option not supported on this version of GCC", str);
3769 else if (level == 0)
3770 write_symbols = NO_DEBUG;
3771 else
3772 debug_info_level = (enum debug_info_level) level;
3774 else if (!strcmp (str, "o"))
3776 asm_file_name = argv[++i];
3778 else if (str[0] == 'G')
3780 g_switch_set = TRUE;
3781 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3783 else if (!strncmp (str, "aux-info", 8))
3785 flag_gen_aux_info = 1;
3786 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3788 else
3789 error ("Invalid option `%s'", argv[i]);
3791 else if (argv[i][0] == '+')
3792 error ("Invalid option `%s'", argv[i]);
3793 else
3794 filename = argv[i];
3797 /* Initialize for bytecode output. A good idea to do this as soon as
3798 possible after the "-f" options have been parsed. */
3799 if (output_bytecode)
3801 #ifndef TARGET_SUPPORTS_BYTECODE
3802 /* Just die with a fatal error if not supported */
3803 fatal ("-fbytecode not supporter for this target");
3804 #else
3805 bc_initialize ();
3806 #endif
3809 if (optimize == 0)
3811 /* Inlining does not work if not optimizing,
3812 so force it not to be done. */
3813 flag_no_inline = 1;
3814 warn_inline = 0;
3816 /* The c_decode_option and lang_decode_option functions set
3817 this to `2' if -Wall is used, so we can avoid giving out
3818 lots of errors for people who don't realize what -Wall does. */
3819 if (warn_uninitialized == 1)
3820 warning ("-Wuninitialized is not supported without -O");
3823 #if defined(DWARF_DEBUGGING_INFO)
3824 if (write_symbols == DWARF_DEBUG
3825 && strcmp (language_string, "GNU C++") == 0)
3827 warning ("-g option not supported for C++ on SVR4 systems");
3828 write_symbols = NO_DEBUG;
3830 #endif /* defined(DWARF_DEBUGGING_INFO) */
3832 #ifdef OVERRIDE_OPTIONS
3833 /* Some machines may reject certain combinations of options. */
3834 OVERRIDE_OPTIONS;
3835 #endif
3837 /* Unrolling all loops implies that standard loop unrolling must also
3838 be done. */
3839 if (flag_unroll_all_loops)
3840 flag_unroll_loops = 1;
3841 /* Loop unrolling requires that strength_reduction be on also. Silently
3842 turn on strength reduction here if it isn't already on. Also, the loop
3843 unrolling code assumes that cse will be run after loop, so that must
3844 be turned on also. */
3845 if (flag_unroll_loops)
3847 flag_strength_reduce = 1;
3848 flag_rerun_cse_after_loop = 1;
3851 /* Warn about options that are not supported on this machine. */
3852 #ifndef INSN_SCHEDULING
3853 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3854 warning ("instruction scheduling not supported on this target machine");
3855 #endif
3856 #ifndef DELAY_SLOTS
3857 if (flag_delayed_branch)
3858 warning ("this target machine does not have delayed branches");
3859 #endif
3861 /* If we are in verbose mode, write out the version and maybe all the
3862 option flags in use. */
3863 if (version_flag)
3865 fprintf (stderr, "%s version %s", language_string, version_string);
3866 #ifdef TARGET_VERSION
3867 TARGET_VERSION;
3868 #endif
3869 #ifdef __GNUC__
3870 #ifndef __VERSION__
3871 #define __VERSION__ "[unknown]"
3872 #endif
3873 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3874 #else
3875 fprintf (stderr, " compiled by CC.\n");
3876 #endif
3877 if (! quiet_flag)
3878 print_switch_values ();
3881 compile_file (filename);
3883 #ifndef OS2
3884 #ifndef VMS
3885 if (flag_print_mem)
3887 #ifdef __alpha
3888 char *sbrk ();
3889 #endif
3890 char *lim = (char *) sbrk (0);
3892 fprintf (stderr, "Data size %d.\n",
3893 lim - (char *) &environ);
3894 fflush (stderr);
3896 #ifdef USG
3897 system ("ps -l 1>&2");
3898 #else /* not USG */
3899 system ("ps v");
3900 #endif /* not USG */
3902 #endif /* not VMS */
3903 #endif /* not OS2 */
3905 if (errorcount)
3906 exit (FATAL_EXIT_CODE);
3907 if (sorrycount)
3908 exit (FATAL_EXIT_CODE);
3909 exit (SUCCESS_EXIT_CODE);
3910 return 34;
3913 /* Decode -m switches. */
3915 /* Here is a table, controlled by the tm.h file, listing each -m switch
3916 and which bits in `target_switches' it should set or clear.
3917 If VALUE is positive, it is bits to set.
3918 If VALUE is negative, -VALUE is bits to clear.
3919 (The sign bit is not used so there is no confusion.) */
3921 struct {char *name; int value;} target_switches []
3922 = TARGET_SWITCHES;
3924 /* This table is similar, but allows the switch to have a value. */
3926 #ifdef TARGET_OPTIONS
3927 struct {char *prefix; char ** variable;} target_options []
3928 = TARGET_OPTIONS;
3929 #endif
3931 /* Decode the switch -mNAME. */
3933 void
3934 set_target_switch (name)
3935 char *name;
3937 register int j;
3938 int valid = 0;
3940 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3941 if (!strcmp (target_switches[j].name, name))
3943 if (target_switches[j].value < 0)
3944 target_flags &= ~-target_switches[j].value;
3945 else
3946 target_flags |= target_switches[j].value;
3947 valid = 1;
3950 #ifdef TARGET_OPTIONS
3951 if (!valid)
3952 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3954 int len = strlen (target_options[j].prefix);
3955 if (!strncmp (target_options[j].prefix, name, len))
3957 *target_options[j].variable = name + len;
3958 valid = 1;
3961 #endif
3963 if (!valid)
3964 error ("Invalid option `%s'", name);
3967 /* Variable used for communication between the following two routines. */
3969 static int line_position;
3971 /* Print an option value and adjust the position in the line. */
3973 static void
3974 print_single_switch (type, name)
3975 char *type, *name;
3977 fprintf (stderr, " %s%s", type, name);
3979 line_position += strlen (type) + strlen (name) + 1;
3981 if (line_position > 65)
3983 fprintf (stderr, "\n\t");
3984 line_position = 8;
3988 /* Print default target switches for -version. */
3990 static void
3991 print_switch_values ()
3993 register int j;
3995 fprintf (stderr, "enabled:");
3996 line_position = 8;
3998 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3999 if (*f_options[j].variable == f_options[j].on_value)
4000 print_single_switch ("-f", f_options[j].string);
4002 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
4003 if (*W_options[j].variable == W_options[j].on_value)
4004 print_single_switch ("-W", W_options[j].string);
4006 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4007 if (target_switches[j].name[0] != '\0'
4008 && target_switches[j].value > 0
4009 && ((target_switches[j].value & target_flags)
4010 == target_switches[j].value))
4011 print_single_switch ("-m", target_switches[j].name);
4013 fprintf (stderr, "\n");