(decl_attributes): If TREE_TYPE for the DECL is updated,
[official-gcc.git] / gcc / toplev.c
blobad440ae6023a4d3ce7c345dab85f24c2e30d6a8d
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 "-Wnon-virtual-dtor",
701 "-Wno-non-virtual-dtor",
702 "-Wextern-inline",
703 "-Wno-extern-inline",
705 /* these are for obj c */
706 "-lang-objc",
707 "-gen-decls",
708 "-fgnu-runtime",
709 "-fno-gnu-runtime",
710 "-fnext-runtime",
711 "-fno-next-runtime",
712 "-Wselector",
713 "-Wno-selector",
714 "-Wprotocol",
715 "-Wno-protocol",
717 /* This is for GNAT and is temporary. */
718 "-gnat",
722 /* Options controlling warnings */
724 /* Don't print warning messages. -w. */
726 int inhibit_warnings = 0;
728 /* Print various extra warnings. -W. */
730 int extra_warnings = 0;
732 /* Treat warnings as errors. -Werror. */
734 int warnings_are_errors = 0;
736 /* Nonzero to warn about unused local variables. */
738 int warn_unused;
740 /* Nonzero to warn about variables used before they are initialized. */
742 int warn_uninitialized;
744 /* Nonzero means warn about all declarations which shadow others. */
746 int warn_shadow;
748 /* Warn if a switch on an enum fails to have a case for every enum value. */
750 int warn_switch;
752 /* Nonzero means warn about function definitions that default the return type
753 or that use a null return and have a return-type other than void. */
755 int warn_return_type;
757 /* Nonzero means warn about pointer casts that increase the required
758 alignment of the target type (and might therefore lead to a crash
759 due to a misaligned access). */
761 int warn_cast_align;
763 /* Nonzero means warn about any identifiers that match in the first N
764 characters. The value N is in `id_clash_len'. */
766 int warn_id_clash;
767 unsigned id_clash_len;
769 /* Nonzero means warn about any objects definitions whose size is larger
770 than N bytes. Also want about function definitions whose returned
771 values are larger than N bytes. The value N is in `larger_than_size'. */
773 int warn_larger_than;
774 unsigned larger_than_size;
776 /* Nonzero means warn if inline function is too large. */
778 int warn_inline;
780 /* Warn if a function returns an aggregate,
781 since there are often incompatible calling conventions for doing this. */
783 int warn_aggregate_return;
785 /* Likewise for -W. */
787 struct { char *string; int *variable; int on_value;} W_options[] =
789 {"unused", &warn_unused, 1},
790 {"error", &warnings_are_errors, 1},
791 {"shadow", &warn_shadow, 1},
792 {"switch", &warn_switch, 1},
793 {"aggregate-return", &warn_aggregate_return, 1},
794 {"cast-align", &warn_cast_align, 1},
795 {"uninitialized", &warn_uninitialized, 1},
796 {"inline", &warn_inline, 1}
799 /* Output files for assembler code (real compiler output)
800 and debugging dumps. */
802 FILE *asm_out_file;
803 FILE *aux_info_file;
804 FILE *rtl_dump_file;
805 FILE *jump_opt_dump_file;
806 FILE *cse_dump_file;
807 FILE *loop_dump_file;
808 FILE *cse2_dump_file;
809 FILE *flow_dump_file;
810 FILE *combine_dump_file;
811 FILE *sched_dump_file;
812 FILE *local_reg_dump_file;
813 FILE *global_reg_dump_file;
814 FILE *sched2_dump_file;
815 FILE *jump2_opt_dump_file;
816 FILE *dbr_sched_dump_file;
817 FILE *stack_reg_dump_file;
819 /* Time accumulators, to count the total time spent in various passes. */
821 int parse_time;
822 int varconst_time;
823 int integration_time;
824 int jump_time;
825 int cse_time;
826 int loop_time;
827 int cse2_time;
828 int flow_time;
829 int combine_time;
830 int sched_time;
831 int local_alloc_time;
832 int global_alloc_time;
833 int sched2_time;
834 int dbr_sched_time;
835 int shorten_branch_time;
836 int stack_reg_time;
837 int final_time;
838 int symout_time;
839 int dump_time;
841 /* Return time used so far, in microseconds. */
844 get_run_time ()
846 #ifdef USG
847 struct tms tms;
848 #else
849 #ifndef VMS
850 struct rusage rusage;
851 #else /* VMS */
852 struct
854 int proc_user_time;
855 int proc_system_time;
856 int child_user_time;
857 int child_system_time;
858 } vms_times;
859 #endif
860 #endif
862 if (quiet_flag)
863 return 0;
865 #ifdef USG
866 times (&tms);
867 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
868 #else
869 #ifndef VMS
870 getrusage (0, &rusage);
871 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
872 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
873 #else /* VMS */
874 times (&vms_times);
875 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
876 #endif
877 #endif
880 #define TIMEVAR(VAR, BODY) \
881 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
883 void
884 print_time (str, total)
885 char *str;
886 int total;
888 fprintf (stderr,
889 "time in %s: %d.%06d\n",
890 str, total / 1000000, total % 1000000);
893 /* Count an error or warning. Return 1 if the message should be printed. */
896 count_error (warningp)
897 int warningp;
899 if (warningp && inhibit_warnings)
900 return 0;
902 if (warningp && !warnings_are_errors)
903 warningcount++;
904 else
906 static int warning_message = 0;
908 if (warningp && !warning_message)
910 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
911 warning_message = 1;
913 errorcount++;
916 return 1;
919 /* Print a fatal error message. NAME is the text.
920 Also include a system error message based on `errno'. */
922 void
923 pfatal_with_name (name)
924 char *name;
926 fprintf (stderr, "%s: ", progname);
927 perror (name);
928 exit (35);
931 void
932 fatal_io_error (name)
933 char *name;
935 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
936 exit (35);
939 /* Called to give a better error message when we don't have an insn to match
940 what we are looking for or if the insn's constraints aren't satisfied,
941 rather than just calling abort(). */
943 void
944 fatal_insn_not_found (insn)
945 rtx insn;
947 if (!output_bytecode)
949 if (INSN_CODE (insn) < 0)
950 error ("internal error--unrecognizable insn:");
951 else
952 error ("internal error--insn does not satisfy its constraints:");
953 debug_rtx (insn);
955 if (asm_out_file)
956 fflush (asm_out_file);
957 if (aux_info_file)
958 fflush (aux_info_file);
959 if (rtl_dump_file)
960 fflush (rtl_dump_file);
961 if (jump_opt_dump_file)
962 fflush (jump_opt_dump_file);
963 if (cse_dump_file)
964 fflush (cse_dump_file);
965 if (loop_dump_file)
966 fflush (loop_dump_file);
967 if (cse2_dump_file)
968 fflush (cse2_dump_file);
969 if (flow_dump_file)
970 fflush (flow_dump_file);
971 if (combine_dump_file)
972 fflush (combine_dump_file);
973 if (sched_dump_file)
974 fflush (sched_dump_file);
975 if (local_reg_dump_file)
976 fflush (local_reg_dump_file);
977 if (global_reg_dump_file)
978 fflush (global_reg_dump_file);
979 if (sched2_dump_file)
980 fflush (sched2_dump_file);
981 if (jump2_opt_dump_file)
982 fflush (jump2_opt_dump_file);
983 if (dbr_sched_dump_file)
984 fflush (dbr_sched_dump_file);
985 if (stack_reg_dump_file)
986 fflush (stack_reg_dump_file);
987 abort ();
990 /* This is the default decl_printable_name function. */
992 static char *
993 decl_name (decl, kind)
994 tree decl;
995 char **kind;
997 return IDENTIFIER_POINTER (DECL_NAME (decl));
1000 static int need_error_newline;
1002 /* Function of last error message;
1003 more generally, function such that if next error message is in it
1004 then we don't have to mention the function name. */
1005 static tree last_error_function = NULL;
1007 /* Used to detect when input_file_stack has changed since last described. */
1008 static int last_error_tick;
1010 /* Called when the start of a function definition is parsed,
1011 this function prints on stderr the name of the function. */
1013 void
1014 announce_function (decl)
1015 tree decl;
1017 if (! quiet_flag)
1019 char *junk;
1020 if (rtl_dump_and_exit)
1021 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1022 else
1023 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
1024 fflush (stderr);
1025 need_error_newline = 1;
1026 last_error_function = current_function_decl;
1030 /* Prints out, if necessary, the name of the current function
1031 which caused an error. Called from all error and warning functions. */
1033 void
1034 report_error_function (file)
1035 char *file;
1037 struct file_stack *p;
1039 if (need_error_newline)
1041 fprintf (stderr, "\n");
1042 need_error_newline = 0;
1045 if (last_error_function != current_function_decl)
1047 char *kind = "function";
1048 if (current_function_decl != 0
1049 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1050 kind = "method";
1052 if (file)
1053 fprintf (stderr, "%s: ", file);
1055 if (current_function_decl == NULL)
1056 fprintf (stderr, "At top level:\n");
1057 else
1059 char *name = (*decl_printable_name) (current_function_decl, &kind);
1060 fprintf (stderr, "In %s `%s':\n", kind, name);
1063 last_error_function = current_function_decl;
1065 if (input_file_stack && input_file_stack->next != 0
1066 && input_file_stack_tick != last_error_tick)
1068 fprintf (stderr, "In file included");
1069 for (p = input_file_stack->next; p; p = p->next)
1071 fprintf (stderr, " from %s:%d", p->name, p->line);
1072 if (p->next)
1073 fprintf (stderr, ",\n ");
1075 fprintf (stderr, ":\n");
1076 last_error_tick = input_file_stack_tick;
1080 /* Print a message. */
1082 static void
1083 vmessage (prefix, s, ap)
1084 char *prefix;
1085 char *s;
1086 va_list ap;
1088 if (prefix)
1089 fprintf (stderr, "%s: ", prefix);
1091 #ifdef HAVE_VPRINTF
1092 vfprintf (stderr, s, ap);
1093 #else
1095 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1096 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1097 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1098 fprintf (stderr, s, v1, v2, v3);
1100 #endif
1103 /* Print a message relevant to line LINE of file FILE. */
1105 static void
1106 v_message_with_file_and_line (file, line, prefix, s, ap)
1107 char *file;
1108 int line;
1109 char *prefix;
1110 char *s;
1111 va_list ap;
1113 if (file)
1114 fprintf (stderr, "%s:%d: ", file, line);
1115 else
1116 fprintf (stderr, "%s: ", progname);
1118 vmessage (prefix, s, ap);
1119 fputc ('\n', stderr);
1122 /* Print a message relevant to the given DECL. */
1124 static void
1125 v_message_with_decl (decl, prefix, s, ap)
1126 tree decl;
1127 char *prefix;
1128 char *s;
1129 va_list ap;
1131 char *n, *p, *junk;
1133 fprintf (stderr, "%s:%d: ",
1134 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1136 if (prefix)
1137 fprintf (stderr, "%s: ", prefix);
1139 /* Do magic to get around lack of varargs support for insertion
1140 of arguments into existing list. We know that the decl is first;
1141 we ass_u_me that it will be printed with "%s". */
1143 for (p = s; *p; ++p)
1145 if (*p == '%')
1147 if (*(p + 1) == '%')
1148 ++p;
1149 else
1150 break;
1154 if (p > s) /* Print the left-hand substring. */
1156 char fmt[sizeof "%.255s"];
1157 long width = p - s;
1159 if (width > 255L) width = 255L; /* arbitrary */
1160 sprintf (fmt, "%%.%lds", width);
1161 fprintf (stderr, fmt, s);
1164 if (*p == '%') /* Print the name. */
1166 char *n = (DECL_NAME (decl)
1167 ? (*decl_printable_name) (decl, &junk)
1168 : "((anonymous))");
1169 fputs (n, stderr);
1170 while (*p)
1172 ++p;
1173 if (isalpha (*(p - 1) & 0xFF))
1174 break;
1178 if (*p) /* Print the rest of the message. */
1179 vmessage ((char *)NULL, p, ap);
1181 fputc ('\n', stderr);
1184 /* Figure file and line of the given INSN. */
1186 static void
1187 file_and_line_for_asm (insn, pfile, pline)
1188 rtx insn;
1189 char **pfile;
1190 int *pline;
1192 rtx body = PATTERN (insn);
1193 rtx asmop;
1195 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1196 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1197 asmop = SET_SRC (body);
1198 else if (GET_CODE (body) == ASM_OPERANDS)
1199 asmop = body;
1200 else if (GET_CODE (body) == PARALLEL
1201 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1202 asmop = SET_SRC (XVECEXP (body, 0, 0));
1203 else if (GET_CODE (body) == PARALLEL
1204 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1205 asmop = XVECEXP (body, 0, 0);
1206 else
1207 asmop = NULL;
1209 if (asmop)
1211 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1212 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1214 else
1216 *pfile = input_filename;
1217 *pline = lineno;
1221 /* Report an error at line LINE of file FILE. */
1223 static void
1224 v_error_with_file_and_line (file, line, s, ap)
1225 char *file;
1226 int line;
1227 char *s;
1228 va_list ap;
1230 count_error (0);
1231 report_error_function (file);
1232 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1235 void
1236 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1238 #ifndef __STDC__
1239 char *file;
1240 int line;
1241 char *s;
1242 #endif
1243 va_list ap;
1245 VA_START (ap, s);
1247 #ifndef __STDC__
1248 file = va_arg (ap, char *);
1249 line = va_arg (ap, int);
1250 s = va_arg (ap, char *);
1251 #endif
1253 v_error_with_file_and_line (file, line, s, ap);
1254 va_end (ap);
1257 /* Report an error at the declaration DECL.
1258 S is a format string which uses %s to substitute the declaration
1259 name; subsequent substitutions are a la printf. */
1261 static void
1262 v_error_with_decl (decl, s, ap)
1263 tree decl;
1264 char *s;
1265 va_list ap;
1267 count_error (0);
1268 report_error_function (DECL_SOURCE_FILE (decl));
1269 v_message_with_decl (decl, (char *)NULL, s, ap);
1272 void
1273 error_with_decl VPROTO((tree decl, char *s, ...))
1275 #ifndef __STDC__
1276 tree decl;
1277 char *s;
1278 #endif
1279 va_list ap;
1281 VA_START (ap, s);
1283 #ifndef __STDC__
1284 decl = va_arg (ap, tree);
1285 s = va_arg (ap, char *);
1286 #endif
1288 v_error_with_decl (decl, s, ap);
1289 va_end (ap);
1292 /* Report an error at the line number of the insn INSN.
1293 This is used only when INSN is an `asm' with operands,
1294 and each ASM_OPERANDS records its own source file and line. */
1296 static void
1297 v_error_for_asm (insn, s, ap)
1298 rtx insn;
1299 char *s;
1300 va_list ap;
1302 char *file;
1303 int line;
1305 count_error (0);
1306 file_and_line_for_asm (insn, &file, &line);
1307 report_error_function (file);
1308 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1311 void
1312 error_for_asm VPROTO((rtx insn, char *s, ...))
1314 #ifndef __STDC__
1315 rtx insn;
1316 char *s;
1317 #endif
1318 va_list ap;
1320 VA_START (ap, s);
1322 #ifndef __STDC__
1323 insn = va_arg (ap, rtx);
1324 s = va_arg (ap, char *);
1325 #endif
1327 v_error_for_asm (insn, s, ap);
1328 va_end (ap);
1331 /* Report an error at the current line number. */
1333 static void
1334 verror (s, ap)
1335 char *s;
1336 va_list ap;
1338 v_error_with_file_and_line (input_filename, lineno, s, ap);
1341 void
1342 error VPROTO((char *s, ...))
1344 #ifndef __STDC__
1345 char *s;
1346 #endif
1347 va_list ap;
1349 VA_START (ap, s);
1351 #ifndef __STDC__
1352 s = va_arg (ap, char *);
1353 #endif
1355 verror (s, ap);
1356 va_end (ap);
1359 /* Report a fatal error at the current line number. */
1361 static void
1362 vfatal (s, ap)
1363 char *s;
1364 va_list ap;
1366 verror (s, ap);
1367 exit (34);
1370 void
1371 fatal VPROTO((char *s, ...))
1373 #ifndef __STDC__
1374 char *s;
1375 #endif
1376 va_list ap;
1378 VA_START (ap, s);
1380 #ifndef __STDC__
1381 s = va_arg (ap, char *);
1382 #endif
1384 vfatal (s, ap);
1385 va_end (ap);
1388 /* Report a warning at line LINE of file FILE. */
1390 static void
1391 v_warning_with_file_and_line (file, line, s, ap)
1392 char *file;
1393 int line;
1394 char *s;
1395 va_list ap;
1397 if (count_error (1))
1399 report_error_function (file);
1400 v_message_with_file_and_line (file, line, "warning", s, ap);
1404 void
1405 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1407 #ifndef __STDC__
1408 char *file;
1409 int line;
1410 char *s;
1411 #endif
1412 va_list ap;
1414 VA_START (ap, s);
1416 #ifndef __STDC__
1417 file = va_arg (ap, char *);
1418 line = va_arg (ap, int);
1419 s = va_arg (ap, char *);
1420 #endif
1422 v_warning_with_file_and_line (file, line, s, ap);
1423 va_end (ap);
1426 /* Report a warning at the declaration DECL.
1427 S is a format string which uses %s to substitute the declaration
1428 name; subsequent substitutions are a la printf. */
1430 static void
1431 v_warning_with_decl (decl, s, ap)
1432 tree decl;
1433 char *s;
1434 va_list ap;
1436 if (count_error (1))
1438 report_error_function (DECL_SOURCE_FILE (decl));
1439 v_message_with_decl (decl, "warning", s, ap);
1443 void
1444 warning_with_decl VPROTO((tree decl, char *s, ...))
1446 #ifndef __STDC__
1447 tree decl;
1448 char *s;
1449 #endif
1450 va_list ap;
1452 VA_START (ap, s);
1454 #ifndef __STDC__
1455 decl = va_arg (ap, tree);
1456 s = va_arg (ap, char *);
1457 #endif
1459 v_warning_with_decl (decl, s, ap);
1460 va_end (ap);
1463 /* Report a warning at the line number of the insn INSN.
1464 This is used only when INSN is an `asm' with operands,
1465 and each ASM_OPERANDS records its own source file and line. */
1467 static void
1468 v_warning_for_asm (insn, s, ap)
1469 rtx insn;
1470 char *s;
1471 va_list ap;
1473 if (count_error (1))
1475 char *file;
1476 int line;
1478 file_and_line_for_asm (insn, &file, &line);
1479 report_error_function (file);
1480 v_message_with_file_and_line (file, line, "warning", s, ap);
1484 void
1485 warning_for_asm VPROTO((rtx insn, char *s, ...))
1487 #ifndef __STDC__
1488 rtx insn;
1489 char *s;
1490 #endif
1491 va_list ap;
1493 VA_START (ap, s);
1495 #ifndef __STDC__
1496 insn = va_arg (ap, rtx);
1497 s = va_arg (ap, char *);
1498 #endif
1500 v_warning_for_asm (insn, s, ap);
1501 va_end (ap);
1504 /* Report a warning at the current line number. */
1506 static void
1507 vwarning (s, ap)
1508 char *s;
1509 va_list ap;
1511 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1514 void
1515 warning VPROTO((char *s, ...))
1517 #ifndef __STDC__
1518 char *s;
1519 #endif
1520 va_list ap;
1522 VA_START (ap, s);
1524 #ifndef __STDC__
1525 s = va_arg (ap, char *);
1526 #endif
1528 vwarning (s, ap);
1529 va_end (ap);
1532 /* These functions issue either warnings or errors depending on
1533 -pedantic-errors. */
1535 static void
1536 vpedwarn (s, ap)
1537 char *s;
1538 va_list ap;
1540 if (flag_pedantic_errors)
1541 verror (s, ap);
1542 else
1543 vwarning (s, ap);
1546 void
1547 pedwarn VPROTO((char *s, ...))
1549 #ifndef __STDC__
1550 char *s;
1551 #endif
1552 va_list ap;
1554 VA_START (ap, s);
1556 #ifndef __STDC__
1557 s = va_arg (ap, char *);
1558 #endif
1560 vpedwarn (s, ap);
1561 va_end (ap);
1564 static void
1565 v_pedwarn_with_decl (decl, s, ap)
1566 tree decl;
1567 char *s;
1568 va_list ap;
1570 /* We don't want -pedantic-errors to cause the compilation to fail from
1571 "errors" in system header files. Sometimes fixincludes can't fix what's
1572 broken (eg: unsigned char bitfields - fixing it may change the alignment
1573 which will cause programs to mysteriously fail because the C library
1574 or kernel uses the original layout). There's no point in issuing a
1575 warning either, it's just unnecessary noise. */
1577 if (! DECL_IN_SYSTEM_HEADER (decl))
1579 if (flag_pedantic_errors)
1580 v_error_with_decl (decl, s, ap);
1581 else
1582 v_warning_with_decl (decl, s, ap);
1586 void
1587 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1589 #ifndef __STDC__
1590 tree decl;
1591 char *s;
1592 #endif
1593 va_list ap;
1595 VA_START (ap, s);
1597 #ifndef __STDC__
1598 decl = va_arg (ap, tree);
1599 s = va_arg (ap, char *);
1600 #endif
1602 v_pedwarn_with_decl (decl, s, ap);
1603 va_end (ap);
1606 static void
1607 v_pedwarn_with_file_and_line (file, line, s, ap)
1608 char *file;
1609 int line;
1610 char *s;
1611 va_list ap;
1613 if (flag_pedantic_errors)
1614 v_error_with_file_and_line (file, line, s, ap);
1615 else
1616 v_warning_with_file_and_line (file, line, s, ap);
1619 void
1620 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1622 #ifndef __STDC__
1623 char *file;
1624 int line;
1625 char *s;
1626 #endif
1627 va_list ap;
1629 VA_START (ap, s);
1631 #ifndef __STDC__
1632 file = va_arg (ap, char *);
1633 line = va_arg (ap, int);
1634 s = va_arg (ap, char *);
1635 #endif
1637 v_pedwarn_with_file_and_line (file, line, s, ap);
1638 va_end (ap);
1641 /* Apologize for not implementing some feature. */
1643 static void
1644 vsorry (s, ap)
1645 char *s;
1646 va_list ap;
1648 sorrycount++;
1649 if (input_filename)
1650 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1651 else
1652 fprintf (stderr, "%s: ", progname);
1653 vmessage ("sorry, not implemented", s, ap);
1654 fputc ('\n', stderr);
1657 void
1658 sorry VPROTO((char *s, ...))
1660 #ifndef __STDC__
1661 char *s;
1662 #endif
1663 va_list ap;
1665 VA_START (ap, s);
1667 #ifndef __STDC__
1668 s = va_arg (ap, char *);
1669 #endif
1671 vsorry (s, ap);
1672 va_end (ap);
1675 /* Apologize for not implementing some feature, then quit. */
1677 static void
1678 v_really_sorry (s, ap)
1679 char *s;
1680 va_list ap;
1682 sorrycount++;
1683 if (input_filename)
1684 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1685 else
1686 fprintf (stderr, "%s: ", progname);
1687 vmessage ("sorry, not implemented", s, ap);
1688 fatal (" (fatal)\n");
1691 void
1692 really_sorry VPROTO((char *s, ...))
1694 #ifndef __STDC__
1695 char *s;
1696 #endif
1697 va_list ap;
1699 VA_START (ap, s);
1701 #ifndef __STDC__
1702 s = va_arg (ap, char *);
1703 #endif
1705 v_really_sorry (s, ap);
1706 va_end (ap);
1709 /* More 'friendly' abort that prints the line and file.
1710 config.h can #define abort fancy_abort if you like that sort of thing.
1712 I don't think this is actually a good idea.
1713 Other sorts of crashes will look a certain way.
1714 It is a good thing if crashes from calling abort look the same way.
1715 -- RMS */
1717 void
1718 fancy_abort ()
1720 fatal ("internal gcc abort");
1723 /* This calls abort and is used to avoid problems when abort if a macro.
1724 It is used when we need to pass the address of abort. */
1726 void
1727 do_abort ()
1729 abort ();
1732 /* When `malloc.c' is compiled with `rcheck' defined,
1733 it calls this function to report clobberage. */
1735 void
1736 botch (s)
1738 abort ();
1741 /* Same as `malloc' but report error if no memory available. */
1743 char *
1744 xmalloc (size)
1745 unsigned size;
1747 register char *value = (char *) malloc (size);
1748 if (value == 0)
1749 fatal ("virtual memory exhausted");
1750 return value;
1753 /* Same as `realloc' but report error if no memory available. */
1755 char *
1756 xrealloc (ptr, size)
1757 char *ptr;
1758 int size;
1760 char *result = (char *) realloc (ptr, size);
1761 if (!result)
1762 fatal ("virtual memory exhausted");
1763 return result;
1766 /* Return the logarithm of X, base 2, considering X unsigned,
1767 if X is a power of 2. Otherwise, returns -1.
1769 This should be used via the `exact_log2' macro. */
1772 exact_log2_wide (x)
1773 register unsigned HOST_WIDE_INT x;
1775 register int log = 0;
1776 /* Test for 0 or a power of 2. */
1777 if (x == 0 || x != (x & -x))
1778 return -1;
1779 while ((x >>= 1) != 0)
1780 log++;
1781 return log;
1784 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1785 If X is 0, return -1.
1787 This should be used via the floor_log2 macro. */
1790 floor_log2_wide (x)
1791 register unsigned HOST_WIDE_INT x;
1793 register int log = -1;
1794 while (x != 0)
1795 log++,
1796 x >>= 1;
1797 return log;
1800 int float_handled;
1801 jmp_buf float_handler;
1803 /* Specify where to longjmp to when a floating arithmetic error happens.
1804 If HANDLER is 0, it means don't handle the errors any more. */
1806 void
1807 set_float_handler (handler)
1808 jmp_buf handler;
1810 float_handled = (handler != 0);
1811 if (handler)
1812 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1815 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1816 error happens, pushing the previous specification into OLD_HANDLER.
1817 Return an indication of whether there was a previous handler in effect. */
1820 push_float_handler (handler, old_handler)
1821 jmp_buf handler, old_handler;
1823 int was_handled = float_handled;
1825 float_handled = 1;
1826 if (was_handled)
1827 bcopy ((char *) float_handler, (char *) old_handler,
1828 sizeof (float_handler));
1830 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1831 return was_handled;
1834 /* Restore the previous specification of whether and where to longjmp to
1835 when a floating arithmetic error happens. */
1837 void
1838 pop_float_handler (handled, handler)
1839 int handled;
1840 jmp_buf handler;
1842 float_handled = handled;
1843 if (handled)
1844 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1847 /* Signals actually come here. */
1849 static void
1850 float_signal (signo)
1851 /* If this is missing, some compilers complain. */
1852 int signo;
1854 if (float_handled == 0)
1855 abort ();
1856 #if defined (USG) || defined (hpux)
1857 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1858 #endif
1859 float_handled = 0;
1860 signal (SIGFPE, float_signal);
1861 longjmp (float_handler, 1);
1864 /* Handler for SIGPIPE. */
1866 static void
1867 pipe_closed (signo)
1868 /* If this is missing, some compilers complain. */
1869 int signo;
1871 fatal ("output pipe has been closed");
1874 /* Strip off a legitimate source ending from the input string NAME of
1875 length LEN. */
1877 void
1878 strip_off_ending (name, len)
1879 char *name;
1880 int len;
1882 if (len > 2 && ! strcmp (".c", name + len - 2))
1883 name[len - 2] = 0;
1884 else if (len > 2 && ! strcmp (".m", name + len - 2))
1885 name[len - 2] = 0;
1886 else if (len > 2 && ! strcmp (".i", name + len - 2))
1887 name[len - 2] = 0;
1888 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1889 name[len - 3] = 0;
1890 else if (len > 3 && ! strcmp (".co", name + len - 3))
1891 name[len - 3] = 0;
1892 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1893 name[len - 3] = 0;
1894 else if (len > 2 && ! strcmp (".C", name + len - 2))
1895 name[len - 2] = 0;
1896 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1897 name[len - 4] = 0;
1898 else if (len > 4 && ! strcmp (".cpp", name + len - 4))
1899 name[len - 4] = 0;
1900 else if (len > 2 && ! strcmp (".f", name + len - 2))
1901 name[len - 2] = 0;
1902 /* Ada will use extensions like .ada, .adb, and .ads, so just test
1903 for "ad". */
1904 else if (len > 4 && ! strncmp (".ad", name + len - 4, 3))
1905 name[len - 4] = 0;
1906 else if (len > 4 && ! strcmp (".atr", name + len - 4))
1907 name[len - 4] = 0;
1910 /* Output a quoted string. */
1911 void
1912 output_quoted_string (asm_file, string)
1913 FILE *asm_file;
1914 char *string;
1916 char c;
1918 putc ('\"', asm_file);
1919 while ((c = *string++) != 0)
1921 if (c == '\"' || c == '\\')
1922 putc ('\\', asm_file);
1923 putc (c, asm_file);
1925 putc ('\"', asm_file);
1928 /* Output a file name in the form wanted by System V. */
1930 void
1931 output_file_directive (asm_file, input_name)
1932 FILE *asm_file;
1933 char *input_name;
1935 int len = strlen (input_name);
1936 char *na = input_name + len;
1938 /* NA gets INPUT_NAME sans directory names. */
1939 while (na > input_name)
1941 if (na[-1] == '/')
1942 break;
1943 na--;
1946 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1947 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1948 #else
1949 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1950 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1951 #else
1952 fprintf (asm_file, "\t.file\t");
1953 output_quoted_string (asm_file, na);
1954 fputc ('\n', asm_file);
1955 #endif
1956 #endif
1959 /* Routine to build language identifier for object file. */
1960 static void
1961 output_lang_identify (asm_out_file)
1962 FILE *asm_out_file;
1964 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1965 char *s = (char *) alloca (len);
1966 sprintf (s, "__gnu_compiled_%s", lang_identify ());
1967 ASM_OUTPUT_LABEL (asm_out_file, s);
1970 /* Routine to open a dump file. */
1971 static FILE *
1972 open_dump_file (base_name, suffix)
1973 char *base_name;
1974 char *suffix;
1976 FILE *f;
1977 char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1);
1979 strcpy (dumpname, base_name);
1980 strcat (dumpname, suffix);
1981 f = fopen (dumpname, "w");
1982 if (f == 0)
1983 pfatal_with_name (dumpname);
1984 return f;
1987 /* Compile an entire file of output from cpp, named NAME.
1988 Write a file of assembly output and various debugging dumps. */
1990 static void
1991 compile_file (name)
1992 char *name;
1994 tree globals;
1995 int start_time;
1997 int name_specified = name != 0;
1999 if (dump_base_name == 0)
2000 dump_base_name = name ? name : "gccdump";
2002 parse_time = 0;
2003 varconst_time = 0;
2004 integration_time = 0;
2005 jump_time = 0;
2006 cse_time = 0;
2007 loop_time = 0;
2008 cse2_time = 0;
2009 flow_time = 0;
2010 combine_time = 0;
2011 sched_time = 0;
2012 local_alloc_time = 0;
2013 global_alloc_time = 0;
2014 sched2_time = 0;
2015 dbr_sched_time = 0;
2016 shorten_branch_time = 0;
2017 stack_reg_time = 0;
2018 final_time = 0;
2019 symout_time = 0;
2020 dump_time = 0;
2022 /* Open input file. */
2024 if (name == 0 || !strcmp (name, "-"))
2026 finput = stdin;
2027 name = "stdin";
2029 else
2030 finput = fopen (name, "r");
2031 if (finput == 0)
2032 pfatal_with_name (name);
2034 #ifdef IO_BUFFER_SIZE
2035 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2036 #endif
2038 /* Initialize data in various passes. */
2040 init_obstacks ();
2041 init_tree_codes ();
2042 init_lex ();
2043 /* Some of these really don't need to be called when generating bytecode,
2044 but the options would have to be parsed first to know that. -bson */
2045 init_rtl ();
2046 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2047 || debug_info_level == DINFO_LEVEL_VERBOSE);
2048 init_regs ();
2049 init_decl_processing ();
2050 init_optabs ();
2051 init_stmt ();
2052 init_expmed ();
2053 init_expr_once ();
2054 init_loop ();
2055 init_reload ();
2057 if (flag_caller_saves)
2058 init_caller_save ();
2060 /* If auxiliary info generation is desired, open the output file.
2061 This goes in the same directory as the source file--unlike
2062 all the other output files. */
2063 if (flag_gen_aux_info)
2065 aux_info_file = fopen (aux_info_file_name, "w");
2066 if (aux_info_file == 0)
2067 pfatal_with_name (aux_info_file_name);
2070 /* If rtl dump desired, open the output file. */
2071 if (rtl_dump)
2072 rtl_dump_file = open_dump_file (dump_base_name, ".rtl");
2074 /* If jump_opt dump desired, open the output file. */
2075 if (jump_opt_dump)
2076 jump_opt_dump_file = open_dump_file (dump_base_name, ".jump");
2078 /* If cse dump desired, open the output file. */
2079 if (cse_dump)
2080 cse_dump_file = open_dump_file (dump_base_name, ".cse");
2082 /* If loop dump desired, open the output file. */
2083 if (loop_dump)
2084 loop_dump_file = open_dump_file (dump_base_name, ".loop");
2086 /* If cse2 dump desired, open the output file. */
2087 if (cse2_dump)
2088 cse2_dump_file = open_dump_file (dump_base_name, ".cse2");
2090 /* If flow dump desired, open the output file. */
2091 if (flow_dump)
2092 flow_dump_file = open_dump_file (dump_base_name, ".flow");
2094 /* If combine dump desired, open the output file. */
2095 if (combine_dump)
2096 combine_dump_file = open_dump_file (dump_base_name, ".combine");
2098 /* If scheduling dump desired, open the output file. */
2099 if (sched_dump)
2100 sched_dump_file = open_dump_file (dump_base_name, ".sched");
2102 /* If local_reg dump desired, open the output file. */
2103 if (local_reg_dump)
2104 local_reg_dump_file = open_dump_file (dump_base_name, ".lreg");
2106 /* If global_reg dump desired, open the output file. */
2107 if (global_reg_dump)
2108 global_reg_dump_file = open_dump_file (dump_base_name, ".greg");
2110 /* If 2nd scheduling dump desired, open the output file. */
2111 if (sched2_dump)
2112 sched2_dump_file = open_dump_file (dump_base_name, ".sched2");
2114 /* If jump2_opt dump desired, open the output file. */
2115 if (jump2_opt_dump)
2116 jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2");
2118 /* If dbr_sched dump desired, open the output file. */
2119 if (dbr_sched_dump)
2120 dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr");
2122 #ifdef STACK_REGS
2124 /* If stack_reg dump desired, open the output file. */
2125 if (stack_reg_dump)
2126 stack_reg_dump_file = open_dump_file (dump_base_name, ".stack");
2128 #endif
2130 /* Open assembler code output file. */
2132 if (! name_specified && asm_file_name == 0)
2133 asm_out_file = stdout;
2134 else
2136 int len = strlen (dump_base_name);
2137 register char *dumpname = (char *) xmalloc (len + 6);
2138 strcpy (dumpname, dump_base_name);
2139 strip_off_ending (dumpname, len);
2140 strcat (dumpname, ".s");
2141 if (asm_file_name == 0)
2143 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2144 strcpy (asm_file_name, dumpname);
2146 if (!strcmp (asm_file_name, "-"))
2147 asm_out_file = stdout;
2148 else
2149 asm_out_file = fopen (asm_file_name, "w");
2150 if (asm_out_file == 0)
2151 pfatal_with_name (asm_file_name);
2154 #ifdef IO_BUFFER_SIZE
2155 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2156 _IOFBF, IO_BUFFER_SIZE);
2157 #endif
2159 input_filename = name;
2161 /* Perform language-specific initialization.
2162 This may set main_input_filename. */
2163 lang_init ();
2165 /* If the input doesn't start with a #line, use the input name
2166 as the official input file name. */
2167 if (main_input_filename == 0)
2168 main_input_filename = name;
2170 /* Put an entry on the input file stack for the main input file. */
2171 input_file_stack
2172 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2173 input_file_stack->next = 0;
2174 input_file_stack->name = input_filename;
2176 if (!output_bytecode)
2178 ASM_FILE_START (asm_out_file);
2181 /* Output something to inform GDB that this compilation was by GCC. Also
2182 serves to tell GDB file consists of bytecodes. */
2183 if (output_bytecode)
2184 fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
2185 else
2187 #ifndef ASM_IDENTIFY_GCC
2188 fprintf (asm_out_file, "gcc2_compiled.:\n");
2189 #else
2190 ASM_IDENTIFY_GCC (asm_out_file);
2191 #endif
2194 /* Output something to identify which front-end produced this file. */
2195 #ifdef ASM_IDENTIFY_LANGUAGE
2196 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2197 #endif
2199 if (output_bytecode)
2201 if (profile_flag || profile_block_flag)
2202 error ("profiling not supported in bytecode compilation");
2204 else
2206 /* ??? Note: There used to be a conditional here
2207 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2208 This was to guarantee separation between gcc_compiled. and
2209 the first function, for the sake of dbx on Suns.
2210 However, having the extra zero here confused the Emacs
2211 code for unexec, and might confuse other programs too.
2212 Therefore, I took out that change.
2213 In future versions we should find another way to solve
2214 that dbx problem. -- rms, 23 May 93. */
2216 /* Don't let the first function fall at the same address
2217 as gcc_compiled., if profiling. */
2218 if (profile_flag || profile_block_flag)
2219 assemble_zeros (UNITS_PER_WORD);
2222 /* If dbx symbol table desired, initialize writing it
2223 and output the predefined types. */
2224 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2225 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2226 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2227 getdecls ()));
2228 #endif
2229 #ifdef SDB_DEBUGGING_INFO
2230 if (write_symbols == SDB_DEBUG)
2231 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2232 getdecls ()));
2233 #endif
2234 #ifdef DWARF_DEBUGGING_INFO
2235 if (write_symbols == DWARF_DEBUG)
2236 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2237 #endif
2239 /* Initialize yet another pass. */
2241 if (!output_bytecode)
2242 init_final (main_input_filename);
2244 start_time = get_run_time ();
2246 /* Call the parser, which parses the entire file
2247 (calling rest_of_compilation for each function). */
2249 if (yyparse () != 0)
2251 if (errorcount == 0)
2252 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2254 /* In case there were missing closebraces,
2255 get us back to the global binding level. */
2256 while (! global_bindings_p ())
2257 poplevel (0, 0, 0);
2260 /* Compilation is now finished except for writing
2261 what's left of the symbol table output. */
2263 parse_time += get_run_time () - start_time;
2265 parse_time -= integration_time;
2266 parse_time -= varconst_time;
2268 globals = getdecls ();
2270 /* Really define vars that have had only a tentative definition.
2271 Really output inline functions that must actually be callable
2272 and have not been output so far. */
2275 int len = list_length (globals);
2276 tree *vec = (tree *) alloca (sizeof (tree) * len);
2277 int i;
2278 tree decl;
2279 int reconsider = 1;
2281 /* Process the decls in reverse order--earliest first.
2282 Put them into VEC from back to front, then take out from front. */
2284 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2285 vec[len - i - 1] = decl;
2287 for (i = 0; i < len; i++)
2289 decl = vec[i];
2291 /* We're not deferring this any longer. */
2292 DECL_DEFER_OUTPUT (decl) = 0;
2294 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2295 && incomplete_decl_finalize_hook != 0)
2296 (*incomplete_decl_finalize_hook) (decl);
2299 /* Now emit any global variables or functions that we have been putting
2300 off. We need to loop in case one of the things emitted here
2301 references another one which comes earlier in the list. */
2302 while (reconsider)
2304 reconsider = 0;
2305 for (i = 0; i < len; i++)
2307 decl = vec[i];
2309 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2310 continue;
2312 /* Don't write out static consts, unless we still need them.
2314 We also keep static consts if not optimizing (for debugging).
2315 ??? They might be better written into the debug information.
2316 This is possible when using DWARF.
2318 A language processor that wants static constants to be always
2319 written out (even if it is not used) is responsible for
2320 calling rest_of_decl_compilation itself. E.g. the C front-end
2321 calls rest_of_decl_compilation from finish_decl.
2322 One motivation for this is that is conventional in some
2323 environments to write things like:
2324 static const char rcsid[] = "... version string ...";
2325 intending to force the string to be in the executable.
2327 A language processor that would prefer to have unneeded
2328 static constants "optimized away" would just defer writing
2329 them out until here. E.g. C++ does this, because static
2330 constants are often defined in header files.
2332 ??? A tempting alternative (for both C and C++) would be
2333 to force a constant to be written if and only if it is
2334 defined in a main file, as opposed to an include file. */
2336 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2337 && (! TREE_READONLY (decl)
2338 || TREE_PUBLIC (decl)
2339 || !optimize
2340 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2342 reconsider = 1;
2343 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2346 if (TREE_CODE (decl) == FUNCTION_DECL
2347 && DECL_INITIAL (decl) != 0
2348 && DECL_SAVED_INSNS (decl) != 0
2349 && (flag_keep_inline_functions
2350 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2352 reconsider = 1;
2353 temporary_allocation ();
2354 output_inline_function (decl);
2355 permanent_allocation (1);
2360 for (i = 0; i < len; i++)
2362 decl = vec[i];
2364 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2365 && ! TREE_ASM_WRITTEN (decl))
2366 /* Cancel the RTL for this decl so that, if debugging info
2367 output for global variables is still to come,
2368 this one will be omitted. */
2369 DECL_RTL (decl) = NULL;
2371 /* Warn about any function
2372 declared static but not defined.
2373 We don't warn about variables,
2374 because many programs have static variables
2375 that exist only to get some text into the object file. */
2376 if (TREE_CODE (decl) == FUNCTION_DECL
2377 && (warn_unused
2378 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2379 && DECL_INITIAL (decl) == 0
2380 && DECL_EXTERNAL (decl)
2381 && ! TREE_PUBLIC (decl))
2383 pedwarn_with_decl (decl,
2384 "`%s' declared `static' but never defined");
2385 /* This symbol is effectively an "extern" declaration now. */
2386 TREE_PUBLIC (decl) = 1;
2387 assemble_external (decl);
2390 /* Warn about static fns or vars defined but not used,
2391 but not about inline functions or static consts
2392 since defining those in header files is normal practice. */
2393 if (warn_unused
2394 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2395 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2396 && ! DECL_IN_SYSTEM_HEADER (decl)
2397 && ! DECL_EXTERNAL (decl)
2398 && ! TREE_PUBLIC (decl)
2399 && ! TREE_USED (decl)
2400 && ! DECL_REGISTER (decl)
2401 /* The TREE_USED bit for file-scope decls
2402 is kept in the identifier, to handle multiple
2403 external decls in different scopes. */
2404 && ! TREE_USED (DECL_NAME (decl)))
2405 warning_with_decl (decl, "`%s' defined but not used");
2407 #ifdef SDB_DEBUGGING_INFO
2408 /* The COFF linker can move initialized global vars to the end.
2409 And that can screw up the symbol ordering.
2410 By putting the symbols in that order to begin with,
2411 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2412 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2413 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2414 && ! DECL_EXTERNAL (decl)
2415 && DECL_RTL (decl) != 0)
2416 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2418 /* Output COFF information for non-global
2419 file-scope initialized variables. */
2420 if (write_symbols == SDB_DEBUG
2421 && TREE_CODE (decl) == VAR_DECL
2422 && DECL_INITIAL (decl)
2423 && ! DECL_EXTERNAL (decl)
2424 && DECL_RTL (decl) != 0
2425 && GET_CODE (DECL_RTL (decl)) == MEM)
2426 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2427 #endif /* SDB_DEBUGGING_INFO */
2428 #ifdef DWARF_DEBUGGING_INFO
2429 /* Output DWARF information for file-scope tentative data object
2430 declarations, file-scope (extern) function declarations (which
2431 had no corresponding body) and file-scope tagged type declarations
2432 and definitions which have not yet been forced out. */
2434 if (write_symbols == DWARF_DEBUG
2435 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2436 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2437 #endif
2441 /* Do dbx symbols */
2442 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2443 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2444 TIMEVAR (symout_time,
2446 dbxout_finish (asm_out_file, main_input_filename);
2448 #endif
2450 #ifdef DWARF_DEBUGGING_INFO
2451 if (write_symbols == DWARF_DEBUG)
2452 TIMEVAR (symout_time,
2454 dwarfout_finish ();
2456 #endif
2458 /* Output some stuff at end of file if nec. */
2460 if (!output_bytecode)
2462 end_final (main_input_filename);
2464 #ifdef ASM_FILE_END
2465 ASM_FILE_END (asm_out_file);
2466 #endif
2469 /* Language-specific end of compilation actions. */
2471 lang_finish ();
2473 if (output_bytecode)
2474 bc_write_file (asm_out_file);
2476 /* Close the dump files. */
2478 if (flag_gen_aux_info)
2480 fclose (aux_info_file);
2481 if (errorcount)
2482 unlink (aux_info_file_name);
2485 if (rtl_dump)
2486 fclose (rtl_dump_file);
2488 if (jump_opt_dump)
2489 fclose (jump_opt_dump_file);
2491 if (cse_dump)
2492 fclose (cse_dump_file);
2494 if (loop_dump)
2495 fclose (loop_dump_file);
2497 if (cse2_dump)
2498 fclose (cse2_dump_file);
2500 if (flow_dump)
2501 fclose (flow_dump_file);
2503 if (combine_dump)
2505 dump_combine_total_stats (combine_dump_file);
2506 fclose (combine_dump_file);
2509 if (sched_dump)
2510 fclose (sched_dump_file);
2512 if (local_reg_dump)
2513 fclose (local_reg_dump_file);
2515 if (global_reg_dump)
2516 fclose (global_reg_dump_file);
2518 if (sched2_dump)
2519 fclose (sched2_dump_file);
2521 if (jump2_opt_dump)
2522 fclose (jump2_opt_dump_file);
2524 if (dbr_sched_dump)
2525 fclose (dbr_sched_dump_file);
2527 #ifdef STACK_REGS
2528 if (stack_reg_dump)
2529 fclose (stack_reg_dump_file);
2530 #endif
2532 /* Close non-debugging input and output files. Take special care to note
2533 whether fclose returns an error, since the pages might still be on the
2534 buffer chain while the file is open. */
2536 fclose (finput);
2537 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2538 fatal_io_error (asm_file_name);
2540 /* Print the times. */
2542 if (! quiet_flag)
2544 fprintf (stderr,"\n");
2545 print_time ("parse", parse_time);
2547 if (!output_bytecode)
2549 print_time ("integration", integration_time);
2550 print_time ("jump", jump_time);
2551 print_time ("cse", cse_time);
2552 print_time ("loop", loop_time);
2553 print_time ("cse2", cse2_time);
2554 print_time ("flow", flow_time);
2555 print_time ("combine", combine_time);
2556 print_time ("sched", sched_time);
2557 print_time ("local-alloc", local_alloc_time);
2558 print_time ("global-alloc", global_alloc_time);
2559 print_time ("sched2", sched2_time);
2560 print_time ("dbranch", dbr_sched_time);
2561 print_time ("shorten-branch", shorten_branch_time);
2562 print_time ("stack-reg", stack_reg_time);
2563 print_time ("final", final_time);
2564 print_time ("varconst", varconst_time);
2565 print_time ("symout", symout_time);
2566 print_time ("dump", dump_time);
2571 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2572 and TYPE_DECL nodes.
2574 This does nothing for local (non-static) variables.
2575 Otherwise, it sets up the RTL and outputs any assembler code
2576 (label definition, storage allocation and initialization).
2578 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2579 the assembler symbol name to be used. TOP_LEVEL is nonzero
2580 if this declaration is not within a function. */
2582 void
2583 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2584 tree decl;
2585 char *asmspec;
2586 int top_level;
2587 int at_end;
2589 /* Declarations of variables, and of functions defined elsewhere. */
2591 /* The most obvious approach, to put an #ifndef around where
2592 this macro is used, doesn't work since it's inside a macro call. */
2593 #ifndef ASM_FINISH_DECLARE_OBJECT
2594 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2595 #endif
2597 /* Forward declarations for nested functions are not "external",
2598 but we need to treat them as if they were. */
2599 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2600 || TREE_CODE (decl) == FUNCTION_DECL)
2601 TIMEVAR (varconst_time,
2603 make_decl_rtl (decl, asmspec, top_level);
2604 /* Initialized extern variable exists to be replaced
2605 with its value, or represents something that will be
2606 output in another file. */
2607 if (! (TREE_CODE (decl) == VAR_DECL
2608 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2609 && DECL_INITIAL (decl) != 0
2610 && DECL_INITIAL (decl) != error_mark_node))
2611 /* Don't output anything
2612 when a tentative file-scope definition is seen.
2613 But at end of compilation, do output code for them. */
2614 if (! (! at_end && top_level
2615 && (DECL_INITIAL (decl) == 0
2616 || DECL_INITIAL (decl) == error_mark_node)))
2617 assemble_variable (decl, top_level, at_end, 0);
2618 if (decl == last_assemble_variable_decl)
2620 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2621 top_level, at_end);
2624 else if (DECL_REGISTER (decl) && asmspec != 0)
2626 if (decode_reg_name (asmspec) >= 0)
2628 DECL_RTL (decl) = 0;
2629 make_decl_rtl (decl, asmspec, top_level);
2631 else
2632 error ("invalid register name `%s' for register variable", asmspec);
2634 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2635 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2636 && TREE_CODE (decl) == TYPE_DECL)
2637 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2638 #endif
2639 #ifdef SDB_DEBUGGING_INFO
2640 else if (write_symbols == SDB_DEBUG && top_level
2641 && TREE_CODE (decl) == TYPE_DECL)
2642 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2643 #endif
2646 /* Called after finishing a record, union or enumeral type. */
2648 void
2649 rest_of_type_compilation (type, toplev)
2650 tree type;
2651 int toplev;
2653 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2654 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2655 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2656 #endif
2657 #ifdef SDB_DEBUGGING_INFO
2658 if (write_symbols == SDB_DEBUG)
2659 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2660 #endif
2663 /* This is called from finish_function (within yyparse)
2664 after each top-level definition is parsed.
2665 It is supposed to compile that function or variable
2666 and output the assembler code for it.
2667 After we return, the tree storage is freed. */
2669 void
2670 rest_of_compilation (decl)
2671 tree decl;
2673 register rtx insns;
2674 int start_time = get_run_time ();
2675 int tem;
2676 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2677 to be restored after we finish compiling the function
2678 (for use when compiling inline calls to this function). */
2679 tree saved_block_tree = 0;
2680 /* Likewise, for DECL_ARGUMENTS. */
2681 tree saved_arguments = 0;
2682 int failure = 0;
2684 if (output_bytecode)
2685 return;
2687 /* If we are reconsidering an inline function
2688 at the end of compilation, skip the stuff for making it inline. */
2690 if (DECL_SAVED_INSNS (decl) == 0)
2692 int specd = DECL_INLINE (decl);
2693 char *lose;
2695 /* If requested, consider whether to make this function inline. */
2696 if (specd || flag_inline_functions)
2697 TIMEVAR (integration_time,
2699 lose = function_cannot_inline_p (decl);
2700 /* If not optimzing, then make sure the DECL_INLINE
2701 bit is off. */
2702 if (lose || ! optimize)
2704 if (warn_inline && specd)
2705 warning_with_decl (decl, lose);
2706 DECL_INLINE (decl) = 0;
2707 /* Don't really compile an extern inline function.
2708 If we can't make it inline, pretend
2709 it was only declared. */
2710 if (DECL_EXTERNAL (decl))
2712 DECL_INITIAL (decl) = 0;
2713 goto exit_rest_of_compilation;
2716 else
2717 DECL_INLINE (decl) = 1;
2720 insns = get_insns ();
2722 /* Dump the rtl code if we are dumping rtl. */
2724 if (rtl_dump)
2725 TIMEVAR (dump_time,
2727 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2728 IDENTIFIER_POINTER (DECL_NAME (decl)));
2729 if (DECL_SAVED_INSNS (decl))
2730 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2731 print_rtl (rtl_dump_file, insns);
2732 fflush (rtl_dump_file);
2735 /* If function is inline, and we don't yet know whether to
2736 compile it by itself, defer decision till end of compilation.
2737 finish_compilation will call rest_of_compilation again
2738 for those functions that need to be output. Also defer those
2739 functions that were marked inline but weren't inlined; they
2740 may never be used. */
2742 if ((specd || DECL_INLINE (decl))
2743 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2744 && ! flag_keep_inline_functions)
2745 || DECL_DEFER_OUTPUT (decl)
2746 || DECL_EXTERNAL (decl)))
2748 #ifdef DWARF_DEBUGGING_INFO
2749 /* Generate the DWARF info for the "abstract" instance
2750 of a function which we may later generate inlined and/or
2751 out-of-line instances of. */
2752 if (write_symbols == DWARF_DEBUG)
2754 set_decl_abstract_flags (decl, 1);
2755 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2756 set_decl_abstract_flags (decl, 0);
2758 #endif
2759 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2760 goto exit_rest_of_compilation;
2763 /* If we have to compile the function now, save its rtl and subdecls
2764 so that its compilation will not affect what others get. */
2765 if (DECL_INLINE (decl))
2767 #ifdef DWARF_DEBUGGING_INFO
2768 /* Generate the DWARF info for the "abstract" instance of
2769 a function which we will generate an out-of-line instance
2770 of almost immediately (and which we may also later generate
2771 various inlined instances of). */
2772 if (write_symbols == DWARF_DEBUG)
2774 set_decl_abstract_flags (decl, 1);
2775 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2776 set_decl_abstract_flags (decl, 0);
2778 #endif
2779 saved_block_tree = DECL_INITIAL (decl);
2780 saved_arguments = DECL_ARGUMENTS (decl);
2781 TIMEVAR (integration_time, save_for_inline_copying (decl));
2785 if (DECL_DEFER_OUTPUT (decl))
2786 goto exit_rest_of_compilation;
2788 TREE_ASM_WRITTEN (decl) = 1;
2790 /* Now that integrate will no longer see our rtl, we need not distinguish
2791 between the return value of this function and the return value of called
2792 functions. */
2793 rtx_equal_function_value_matters = 0;
2795 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2796 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2798 goto exit_rest_of_compilation;
2801 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2802 Note that that may have been done above, in save_for_inline_copying.
2803 The call to resume_temporary_allocation near the end of this function
2804 goes back to the usual state of affairs. */
2806 rtl_in_current_obstack ();
2808 #ifdef FINALIZE_PIC
2809 /* If we are doing position-independent code generation, now
2810 is the time to output special prologues and epilogues.
2811 We do not want to do this earlier, because it just clutters
2812 up inline functions with meaningless insns. */
2813 if (flag_pic)
2814 FINALIZE_PIC;
2815 #endif
2817 insns = get_insns ();
2819 /* Copy any shared structure that should not be shared. */
2821 unshare_all_rtl (insns);
2823 /* Instantiate all virtual registers. */
2825 instantiate_virtual_regs (current_function_decl, get_insns ());
2827 /* See if we have allocated stack slots that are not directly addressable.
2828 If so, scan all the insns and create explicit address computation
2829 for all references to such slots. */
2830 /* fixup_stack_slots (); */
2832 /* Do jump optimization the first time, if -opt.
2833 Also do it if -W, but in that case it doesn't change the rtl code,
2834 it only computes whether control can drop off the end of the function. */
2836 if (optimize > 0 || extra_warnings || warn_return_type
2837 /* If function is `noreturn', we should warn if it tries to return. */
2838 || TREE_THIS_VOLATILE (decl))
2840 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2841 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2844 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2845 if (rtl_dump_and_exit || flag_syntax_only)
2846 goto exit_rest_of_compilation;
2848 /* Dump rtl code after jump, if we are doing that. */
2850 if (jump_opt_dump)
2851 TIMEVAR (dump_time,
2853 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2854 IDENTIFIER_POINTER (DECL_NAME (decl)));
2855 print_rtl (jump_opt_dump_file, insns);
2856 fflush (jump_opt_dump_file);
2859 /* Perform common subexpression elimination.
2860 Nonzero value from `cse_main' means that jumps were simplified
2861 and some code may now be unreachable, so do
2862 jump optimization again. */
2864 if (cse_dump)
2865 TIMEVAR (dump_time,
2867 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2868 IDENTIFIER_POINTER (DECL_NAME (decl)));
2871 if (optimize > 0)
2873 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2875 if (flag_thread_jumps)
2876 /* Hacks by tiemann & kenner. */
2877 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
2879 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2880 0, cse_dump_file));
2881 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2883 if (tem)
2884 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2887 /* Dump rtl code after cse, if we are doing that. */
2889 if (cse_dump)
2890 TIMEVAR (dump_time,
2892 print_rtl (cse_dump_file, insns);
2893 fflush (cse_dump_file);
2896 if (loop_dump)
2897 TIMEVAR (dump_time,
2899 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2900 IDENTIFIER_POINTER (DECL_NAME (decl)));
2903 /* Move constant computations out of loops. */
2905 if (optimize > 0)
2907 TIMEVAR (loop_time,
2909 loop_optimize (insns, loop_dump_file);
2913 /* Dump rtl code after loop opt, if we are doing that. */
2915 if (loop_dump)
2916 TIMEVAR (dump_time,
2918 print_rtl (loop_dump_file, insns);
2919 fflush (loop_dump_file);
2922 if (cse2_dump)
2923 TIMEVAR (dump_time,
2925 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2926 IDENTIFIER_POINTER (DECL_NAME (decl)));
2929 if (optimize > 0 && flag_rerun_cse_after_loop)
2931 /* Running another jump optimization pass before the second
2932 cse pass sometimes simplifies the RTL enough to allow
2933 the second CSE pass to do a better job. Jump_optimize can change
2934 max_reg_num so we must rerun reg_scan afterwards.
2935 ??? Rework to not call reg_scan so often. */
2936 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2937 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2939 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2940 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2941 1, cse2_dump_file));
2942 if (tem)
2943 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2946 if (optimize > 0 && flag_thread_jumps)
2947 /* This pass of jump threading straightens out code
2948 that was kinked by loop optimization. */
2949 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2951 /* Dump rtl code after cse, if we are doing that. */
2953 if (cse2_dump)
2954 TIMEVAR (dump_time,
2956 print_rtl (cse2_dump_file, insns);
2957 fflush (cse2_dump_file);
2960 /* We are no longer anticipating cse in this function, at least. */
2962 cse_not_expected = 1;
2964 /* Now we choose between stupid (pcc-like) register allocation
2965 (if we got the -noreg switch and not -opt)
2966 and smart register allocation. */
2968 if (optimize > 0) /* Stupid allocation probably won't work */
2969 obey_regdecls = 0; /* if optimizations being done. */
2971 regclass_init ();
2973 /* Print function header into flow dump now
2974 because doing the flow analysis makes some of the dump. */
2976 if (flow_dump)
2977 TIMEVAR (dump_time,
2979 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2980 IDENTIFIER_POINTER (DECL_NAME (decl)));
2983 if (obey_regdecls)
2985 TIMEVAR (flow_time,
2987 regclass (insns, max_reg_num ());
2988 stupid_life_analysis (insns, max_reg_num (),
2989 flow_dump_file);
2992 else
2994 /* Do control and data flow analysis,
2995 and write some of the results to dump file. */
2997 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2998 flow_dump_file));
2999 if (warn_uninitialized)
3001 uninitialized_vars_warning (DECL_INITIAL (decl));
3002 setjmp_args_warning ();
3006 /* Dump rtl after flow analysis. */
3008 if (flow_dump)
3009 TIMEVAR (dump_time,
3011 print_rtl (flow_dump_file, insns);
3012 fflush (flow_dump_file);
3015 /* If -opt, try combining insns through substitution. */
3017 if (optimize > 0)
3018 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3020 /* Dump rtl code after insn combination. */
3022 if (combine_dump)
3023 TIMEVAR (dump_time,
3025 fprintf (combine_dump_file, "\n;; Function %s\n\n",
3026 IDENTIFIER_POINTER (DECL_NAME (decl)));
3027 dump_combine_stats (combine_dump_file);
3028 print_rtl (combine_dump_file, insns);
3029 fflush (combine_dump_file);
3032 /* Print function header into sched dump now
3033 because doing the sched analysis makes some of the dump. */
3035 if (sched_dump)
3036 TIMEVAR (dump_time,
3038 fprintf (sched_dump_file, "\n;; Function %s\n\n",
3039 IDENTIFIER_POINTER (DECL_NAME (decl)));
3042 if (optimize > 0 && flag_schedule_insns)
3044 /* Do control and data sched analysis,
3045 and write some of the results to dump file. */
3047 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
3050 /* Dump rtl after instruction scheduling. */
3052 if (sched_dump)
3053 TIMEVAR (dump_time,
3055 print_rtl (sched_dump_file, insns);
3056 fflush (sched_dump_file);
3059 /* Unless we did stupid register allocation,
3060 allocate pseudo-regs that are used only within 1 basic block. */
3062 if (!obey_regdecls)
3063 TIMEVAR (local_alloc_time,
3065 regclass (insns, max_reg_num ());
3066 local_alloc ();
3069 /* Dump rtl code after allocating regs within basic blocks. */
3071 if (local_reg_dump)
3072 TIMEVAR (dump_time,
3074 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
3075 IDENTIFIER_POINTER (DECL_NAME (decl)));
3076 dump_flow_info (local_reg_dump_file);
3077 dump_local_alloc (local_reg_dump_file);
3078 print_rtl (local_reg_dump_file, insns);
3079 fflush (local_reg_dump_file);
3082 if (global_reg_dump)
3083 TIMEVAR (dump_time,
3084 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
3085 IDENTIFIER_POINTER (DECL_NAME (decl))));
3087 /* Unless we did stupid register allocation,
3088 allocate remaining pseudo-regs, then do the reload pass
3089 fixing up any insns that are invalid. */
3091 TIMEVAR (global_alloc_time,
3093 if (!obey_regdecls)
3094 failure = global_alloc (global_reg_dump_file);
3095 else
3096 failure = reload (insns, 0, global_reg_dump_file);
3099 if (global_reg_dump)
3100 TIMEVAR (dump_time,
3102 dump_global_regs (global_reg_dump_file);
3103 print_rtl (global_reg_dump_file, insns);
3104 fflush (global_reg_dump_file);
3107 if (failure)
3108 goto exit_rest_of_compilation;
3110 reload_completed = 1;
3112 /* On some machines, the prologue and epilogue code, or parts thereof,
3113 can be represented as RTL. Doing so lets us schedule insns between
3114 it and the rest of the code and also allows delayed branch
3115 scheduling to operate in the epilogue. */
3117 thread_prologue_and_epilogue_insns (insns);
3119 if (optimize > 0 && flag_schedule_insns_after_reload)
3121 if (sched2_dump)
3122 TIMEVAR (dump_time,
3124 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
3125 IDENTIFIER_POINTER (DECL_NAME (decl)));
3128 /* Do control and data sched analysis again,
3129 and write some more of the results to dump file. */
3131 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
3133 /* Dump rtl after post-reorder instruction scheduling. */
3135 if (sched2_dump)
3136 TIMEVAR (dump_time,
3138 print_rtl (sched2_dump_file, insns);
3139 fflush (sched2_dump_file);
3143 #ifdef LEAF_REGISTERS
3144 leaf_function = 0;
3145 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3146 leaf_function = 1;
3147 #endif
3149 /* One more attempt to remove jumps to .+1
3150 left by dead-store-elimination.
3151 Also do cross-jumping this time
3152 and delete no-op move insns. */
3154 if (optimize > 0)
3156 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3159 /* Dump rtl code after jump, if we are doing that. */
3161 if (jump2_opt_dump)
3162 TIMEVAR (dump_time,
3164 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
3165 IDENTIFIER_POINTER (DECL_NAME (decl)));
3166 print_rtl (jump2_opt_dump_file, insns);
3167 fflush (jump2_opt_dump_file);
3170 /* If a machine dependent reorganization is needed, call it. */
3171 #ifdef MACHINE_DEPENDENT_REORG
3172 MACHINE_DEPENDENT_REORG (insns);
3173 #endif
3175 /* If a scheduling pass for delayed branches is to be done,
3176 call the scheduling code. */
3178 #ifdef DELAY_SLOTS
3179 if (optimize > 0 && flag_delayed_branch)
3181 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3182 if (dbr_sched_dump)
3184 TIMEVAR (dump_time,
3186 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
3187 IDENTIFIER_POINTER (DECL_NAME (decl)));
3188 print_rtl (dbr_sched_dump_file, insns);
3189 fflush (dbr_sched_dump_file);
3193 #endif
3195 if (optimize > 0)
3196 /* Shorten branches. */
3197 TIMEVAR (shorten_branch_time,
3199 shorten_branches (get_insns ());
3202 #ifdef STACK_REGS
3203 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3204 if (stack_reg_dump)
3206 TIMEVAR (dump_time,
3208 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
3209 IDENTIFIER_POINTER (DECL_NAME (decl)));
3210 print_rtl (stack_reg_dump_file, insns);
3211 fflush (stack_reg_dump_file);
3214 #endif
3216 /* Now turn the rtl into assembler code. */
3218 TIMEVAR (final_time,
3220 rtx x;
3221 char *fnname;
3223 /* Get the function's name, as described by its RTL.
3224 This may be different from the DECL_NAME name used
3225 in the source file. */
3227 x = DECL_RTL (decl);
3228 if (GET_CODE (x) != MEM)
3229 abort ();
3230 x = XEXP (x, 0);
3231 if (GET_CODE (x) != SYMBOL_REF)
3232 abort ();
3233 fnname = XSTR (x, 0);
3235 assemble_start_function (decl, fnname);
3236 final_start_function (insns, asm_out_file, optimize);
3237 final (insns, asm_out_file, optimize, 0);
3238 final_end_function (insns, asm_out_file, optimize);
3239 assemble_end_function (decl, fnname);
3240 fflush (asm_out_file);
3243 /* Write DBX symbols if requested */
3245 /* Note that for those inline functions where we don't initially
3246 know for certain that we will be generating an out-of-line copy,
3247 the first invocation of this routine (rest_of_compilation) will
3248 skip over this code by doing a `goto exit_rest_of_compilation;'.
3249 Later on, finish_compilation will call rest_of_compilation again
3250 for those inline functions that need to have out-of-line copies
3251 generated. During that call, we *will* be routed past here. */
3253 #ifdef DBX_DEBUGGING_INFO
3254 if (write_symbols == DBX_DEBUG)
3255 TIMEVAR (symout_time, dbxout_function (decl));
3256 #endif
3258 #ifdef DWARF_DEBUGGING_INFO
3259 if (write_symbols == DWARF_DEBUG)
3260 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3261 #endif
3263 exit_rest_of_compilation:
3265 /* In case the function was not output,
3266 don't leave any temporary anonymous types
3267 queued up for sdb output. */
3268 #ifdef SDB_DEBUGGING_INFO
3269 if (write_symbols == SDB_DEBUG)
3270 sdbout_types (NULL_TREE);
3271 #endif
3273 /* Put back the tree of subblocks and list of arguments
3274 from before we copied them.
3275 Code generation and the output of debugging info may have modified
3276 the copy, but the original is unchanged. */
3278 if (saved_block_tree != 0)
3279 DECL_INITIAL (decl) = saved_block_tree;
3280 if (saved_arguments != 0)
3281 DECL_ARGUMENTS (decl) = saved_arguments;
3283 reload_completed = 0;
3285 /* Clear out the real_constant_chain before some of the rtx's
3286 it runs through become garbage. */
3288 clear_const_double_mem ();
3290 /* Cancel the effect of rtl_in_current_obstack. */
3292 resume_temporary_allocation ();
3294 /* The parsing time is all the time spent in yyparse
3295 *except* what is spent in this function. */
3297 parse_time -= get_run_time () - start_time;
3300 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3301 Exit code is 35 if can't open files, 34 if fatal error,
3302 33 if had nonfatal errors, else success. */
3305 main (argc, argv, envp)
3306 int argc;
3307 char **argv;
3308 char **envp;
3310 register int i;
3311 char *filename = 0;
3312 int flag_print_mem = 0;
3313 int version_flag = 0;
3314 char *p;
3316 /* save in case md file wants to emit args as a comment. */
3317 save_argc = argc;
3318 save_argv = argv;
3320 p = argv[0] + strlen (argv[0]);
3321 while (p != argv[0] && p[-1] != '/') --p;
3322 progname = p;
3324 #ifdef RLIMIT_STACK
3325 /* Get rid of any avoidable limit on stack size. */
3327 struct rlimit rlim;
3329 /* Set the stack limit huge so that alloca does not fail. */
3330 getrlimit (RLIMIT_STACK, &rlim);
3331 rlim.rlim_cur = rlim.rlim_max;
3332 setrlimit (RLIMIT_STACK, &rlim);
3334 #endif /* RLIMIT_STACK */
3336 signal (SIGFPE, float_signal);
3338 #ifdef SIGPIPE
3339 signal (SIGPIPE, pipe_closed);
3340 #endif
3342 decl_printable_name = decl_name;
3343 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3345 /* Initialize whether `char' is signed. */
3346 flag_signed_char = DEFAULT_SIGNED_CHAR;
3347 #ifdef DEFAULT_SHORT_ENUMS
3348 /* Initialize how much space enums occupy, by default. */
3349 flag_short_enums = DEFAULT_SHORT_ENUMS;
3350 #endif
3352 /* Scan to see what optimization level has been specified. That will
3353 determine the default value of many flags. */
3354 for (i = 1; i < argc; i++)
3356 if (!strcmp (argv[i], "-O"))
3358 optimize = 1;
3360 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3362 /* Handle -O2, -O3, -O69, ... */
3363 char *p = &argv[i][2];
3364 int c;
3366 while (c = *p++)
3367 if (! (c >= '0' && c <= '9'))
3368 break;
3369 if (c == 0)
3370 optimize = atoi (&argv[i][2]);
3374 obey_regdecls = (optimize == 0);
3375 if (optimize == 0)
3377 flag_no_inline = 1;
3378 warn_inline = 0;
3381 if (optimize >= 1)
3383 flag_defer_pop = 1;
3384 flag_thread_jumps = 1;
3385 #ifdef DELAY_SLOTS
3386 flag_delayed_branch = 1;
3387 #endif
3388 #ifdef CAN_DEBUG_WITHOUT_FP
3389 flag_omit_frame_pointer = 1;
3390 #endif
3393 if (optimize >= 2)
3395 flag_cse_follow_jumps = 1;
3396 flag_cse_skip_blocks = 1;
3397 flag_expensive_optimizations = 1;
3398 flag_strength_reduce = 1;
3399 flag_rerun_cse_after_loop = 1;
3400 flag_caller_saves = 1;
3401 #ifdef INSN_SCHEDULING
3402 flag_schedule_insns = 1;
3403 flag_schedule_insns_after_reload = 1;
3404 #endif
3407 if (optimize >= 3)
3409 flag_inline_functions = 1;
3412 #ifdef OPTIMIZATION_OPTIONS
3413 /* Allow default optimizations to be specified on a per-machine basis. */
3414 OPTIMIZATION_OPTIONS (optimize);
3415 #endif
3417 /* Initialize register usage now so switches may override. */
3418 init_reg_sets ();
3420 target_flags = 0;
3421 set_target_switch ("");
3423 for (i = 1; i < argc; i++)
3425 int j;
3426 /* If this is a language-specific option,
3427 decode it in a language-specific way. */
3428 for (j = 0; lang_options[j] != 0; j++)
3429 if (!strncmp (argv[i], lang_options[j],
3430 strlen (lang_options[j])))
3431 break;
3432 if (lang_options[j] != 0)
3433 /* If the option is valid for *some* language,
3434 treat it as valid even if this language doesn't understand it. */
3435 lang_decode_option (argv[i]);
3436 else if (argv[i][0] == '-' && argv[i][1] != 0)
3438 register char *str = argv[i] + 1;
3439 if (str[0] == 'Y')
3440 str++;
3442 if (str[0] == 'm')
3443 set_target_switch (&str[1]);
3444 else if (!strcmp (str, "dumpbase"))
3446 dump_base_name = argv[++i];
3448 else if (str[0] == 'd')
3450 register char *p = &str[1];
3451 while (*p)
3452 switch (*p++)
3454 case 'a':
3455 combine_dump = 1;
3456 dbr_sched_dump = 1;
3457 flow_dump = 1;
3458 global_reg_dump = 1;
3459 jump_opt_dump = 1;
3460 jump2_opt_dump = 1;
3461 local_reg_dump = 1;
3462 loop_dump = 1;
3463 rtl_dump = 1;
3464 cse_dump = 1, cse2_dump = 1;
3465 sched_dump = 1;
3466 sched2_dump = 1;
3467 stack_reg_dump = 1;
3468 break;
3469 case 'k':
3470 stack_reg_dump = 1;
3471 break;
3472 case 'c':
3473 combine_dump = 1;
3474 break;
3475 case 'd':
3476 dbr_sched_dump = 1;
3477 break;
3478 case 'f':
3479 flow_dump = 1;
3480 break;
3481 case 'g':
3482 global_reg_dump = 1;
3483 break;
3484 case 'j':
3485 jump_opt_dump = 1;
3486 break;
3487 case 'J':
3488 jump2_opt_dump = 1;
3489 break;
3490 case 'l':
3491 local_reg_dump = 1;
3492 break;
3493 case 'L':
3494 loop_dump = 1;
3495 break;
3496 case 'm':
3497 flag_print_mem = 1;
3498 break;
3499 case 'p':
3500 flag_print_asm_name = 1;
3501 break;
3502 case 'r':
3503 rtl_dump = 1;
3504 break;
3505 case 's':
3506 cse_dump = 1;
3507 break;
3508 case 't':
3509 cse2_dump = 1;
3510 break;
3511 case 'S':
3512 sched_dump = 1;
3513 break;
3514 case 'R':
3515 sched2_dump = 1;
3516 break;
3517 case 'y':
3518 set_yydebug (1);
3519 break;
3521 case 'x':
3522 rtl_dump_and_exit = 1;
3523 break;
3526 else if (str[0] == 'f')
3528 register char *p = &str[1];
3529 int found = 0;
3531 /* Some kind of -f option.
3532 P's value is the option sans `-f'.
3533 Search for it in the table of options. */
3535 for (j = 0;
3536 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3537 j++)
3539 if (!strcmp (p, f_options[j].string))
3541 *f_options[j].variable = f_options[j].on_value;
3542 /* A goto here would be cleaner,
3543 but breaks the vax pcc. */
3544 found = 1;
3546 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3547 && ! strcmp (p+3, f_options[j].string))
3549 *f_options[j].variable = ! f_options[j].on_value;
3550 found = 1;
3554 if (found)
3556 else if (!strncmp (p, "fixed-", 6))
3557 fix_register (&p[6], 1, 1);
3558 else if (!strncmp (p, "call-used-", 10))
3559 fix_register (&p[10], 0, 1);
3560 else if (!strncmp (p, "call-saved-", 11))
3561 fix_register (&p[11], 0, 0);
3562 else
3563 error ("Invalid option `%s'", argv[i]);
3565 else if (str[0] == 'O')
3567 register char *p = str+1;
3568 while (*p && *p >= '0' && *p <= '9')
3569 p++;
3570 if (*p == '\0')
3572 else
3573 error ("Invalid option `%s'", argv[i]);
3575 else if (!strcmp (str, "pedantic"))
3576 pedantic = 1;
3577 else if (!strcmp (str, "pedantic-errors"))
3578 flag_pedantic_errors = pedantic = 1;
3579 else if (!strcmp (str, "quiet"))
3580 quiet_flag = 1;
3581 else if (!strcmp (str, "version"))
3582 version_flag = 1;
3583 else if (!strcmp (str, "w"))
3584 inhibit_warnings = 1;
3585 else if (!strcmp (str, "W"))
3587 extra_warnings = 1;
3588 /* We save the value of warn_uninitialized, since if they put
3589 -Wuninitialized on the command line, we need to generate a
3590 warning about not using it without also specifying -O. */
3591 if (warn_uninitialized != 1)
3592 warn_uninitialized = 2;
3594 else if (str[0] == 'W')
3596 register char *p = &str[1];
3597 int found = 0;
3599 /* Some kind of -W option.
3600 P's value is the option sans `-W'.
3601 Search for it in the table of options. */
3603 for (j = 0;
3604 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3605 j++)
3607 if (!strcmp (p, W_options[j].string))
3609 *W_options[j].variable = W_options[j].on_value;
3610 /* A goto here would be cleaner,
3611 but breaks the vax pcc. */
3612 found = 1;
3614 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3615 && ! strcmp (p+3, W_options[j].string))
3617 *W_options[j].variable = ! W_options[j].on_value;
3618 found = 1;
3622 if (found)
3624 else if (!strncmp (p, "id-clash-", 9))
3626 char *endp = p + 9;
3628 while (*endp)
3630 if (*endp >= '0' && *endp <= '9')
3631 endp++;
3632 else
3634 error ("Invalid option `%s'", argv[i]);
3635 goto id_clash_lose;
3638 warn_id_clash = 1;
3639 id_clash_len = atoi (str + 10);
3640 id_clash_lose: ;
3642 else if (!strncmp (p, "larger-than-", 12))
3644 char *endp = p + 12;
3646 while (*endp)
3648 if (*endp >= '0' && *endp <= '9')
3649 endp++;
3650 else
3652 error ("Invalid option `%s'", argv[i]);
3653 goto larger_than_lose;
3656 warn_larger_than = 1;
3657 larger_than_size = atoi (str + 13);
3658 larger_than_lose: ;
3660 else
3661 error ("Invalid option `%s'", argv[i]);
3663 else if (!strcmp (str, "p"))
3665 if (!output_bytecode)
3666 profile_flag = 1;
3667 else
3668 error ("profiling not supported in bytecode compilation");
3670 else if (!strcmp (str, "a"))
3672 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3673 warning ("`-a' option (basic block profile) not supported");
3674 #else
3675 profile_block_flag = 1;
3676 #endif
3678 else if (str[0] == 'g')
3680 char *p = str + 1;
3681 char *q;
3682 unsigned len;
3683 unsigned level;
3685 while (*p && (*p < '0' || *p > '9'))
3686 p++;
3687 len = p - str;
3688 q = p;
3689 while (*q && (*q >= '0' && *q <= '9'))
3690 q++;
3691 if (*p)
3692 level = atoi (p);
3693 else
3694 level = 2; /* default debugging info level */
3695 if (*q || level > 3)
3697 warning ("invalid debug level specification in option: `-%s'",
3698 str);
3699 warning ("no debugging information will be generated");
3700 level = 0;
3703 /* If more than one debugging type is supported,
3704 you must define PREFERRED_DEBUGGING_TYPE
3705 to choose a format in a system-dependent way. */
3706 /* This is one long line cause VAXC can't handle a \-newline. */
3707 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3708 #ifdef PREFERRED_DEBUGGING_TYPE
3709 if (!strncmp (str, "ggdb", len))
3710 write_symbols = PREFERRED_DEBUGGING_TYPE;
3711 #else /* no PREFERRED_DEBUGGING_TYPE */
3712 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3713 #endif /* no PREFERRED_DEBUGGING_TYPE */
3714 #endif /* More than one debugger format enabled. */
3715 #ifdef DBX_DEBUGGING_INFO
3716 if (write_symbols != NO_DEBUG)
3718 else if (!strncmp (str, "ggdb", len))
3719 write_symbols = DBX_DEBUG;
3720 else if (!strncmp (str, "gstabs", len))
3721 write_symbols = DBX_DEBUG;
3722 else if (!strncmp (str, "gstabs+", len))
3723 write_symbols = DBX_DEBUG;
3725 /* Always enable extensions for -ggdb or -gstabs+,
3726 always disable for -gstabs.
3727 For plain -g, use system-specific default. */
3728 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3729 && len >= 2)
3730 use_gnu_debug_info_extensions = 1;
3731 else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
3732 && len >= 7)
3733 use_gnu_debug_info_extensions = 1;
3734 else if (write_symbols == DBX_DEBUG
3735 && !strncmp (str, "gstabs", len) && len >= 2)
3736 use_gnu_debug_info_extensions = 0;
3737 else
3738 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3739 #endif /* DBX_DEBUGGING_INFO */
3740 #ifdef DWARF_DEBUGGING_INFO
3741 if (write_symbols != NO_DEBUG)
3743 else if (!strncmp (str, "g", len))
3744 write_symbols = DWARF_DEBUG;
3745 else if (!strncmp (str, "ggdb", len))
3746 write_symbols = DWARF_DEBUG;
3747 else if (!strncmp (str, "gdwarf", len))
3748 write_symbols = DWARF_DEBUG;
3750 /* Always enable extensions for -ggdb or -gdwarf+,
3751 always disable for -gdwarf.
3752 For plain -g, use system-specific default. */
3753 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3754 && len >= 2)
3755 use_gnu_debug_info_extensions = 1;
3756 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3757 use_gnu_debug_info_extensions = 1;
3758 else if (write_symbols == DWARF_DEBUG
3759 && !strncmp (str, "gdwarf", len) && len >= 2)
3760 use_gnu_debug_info_extensions = 0;
3761 else
3762 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3763 #endif
3764 #ifdef SDB_DEBUGGING_INFO
3765 if (write_symbols != NO_DEBUG)
3767 else if (!strncmp (str, "g", len))
3768 write_symbols = SDB_DEBUG;
3769 else if (!strncmp (str, "gdb", len))
3770 write_symbols = SDB_DEBUG;
3771 else if (!strncmp (str, "gcoff", len))
3772 write_symbols = SDB_DEBUG;
3773 #endif /* SDB_DEBUGGING_INFO */
3774 #ifdef XCOFF_DEBUGGING_INFO
3775 if (write_symbols != NO_DEBUG)
3777 else if (!strncmp (str, "g", len))
3778 write_symbols = XCOFF_DEBUG;
3779 else if (!strncmp (str, "ggdb", len))
3780 write_symbols = XCOFF_DEBUG;
3781 else if (!strncmp (str, "gxcoff", len))
3782 write_symbols = XCOFF_DEBUG;
3784 /* Always enable extensions for -ggdb or -gxcoff+,
3785 always disable for -gxcoff.
3786 For plain -g, use system-specific default. */
3787 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3788 && len >= 2)
3789 use_gnu_debug_info_extensions = 1;
3790 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3791 use_gnu_debug_info_extensions = 1;
3792 else if (write_symbols == XCOFF_DEBUG
3793 && !strncmp (str, "gxcoff", len) && len >= 2)
3794 use_gnu_debug_info_extensions = 0;
3795 else
3796 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3797 #endif
3798 if (write_symbols == NO_DEBUG)
3799 warning ("`-%s' option not supported on this version of GCC", str);
3800 else if (level == 0)
3801 write_symbols = NO_DEBUG;
3802 else
3803 debug_info_level = (enum debug_info_level) level;
3805 else if (!strcmp (str, "o"))
3807 asm_file_name = argv[++i];
3809 else if (str[0] == 'G')
3811 g_switch_set = TRUE;
3812 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3814 else if (!strncmp (str, "aux-info", 8))
3816 flag_gen_aux_info = 1;
3817 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3819 else
3820 error ("Invalid option `%s'", argv[i]);
3822 else if (argv[i][0] == '+')
3823 error ("Invalid option `%s'", argv[i]);
3824 else
3825 filename = argv[i];
3828 /* Initialize for bytecode output. A good idea to do this as soon as
3829 possible after the "-f" options have been parsed. */
3830 if (output_bytecode)
3832 #ifndef TARGET_SUPPORTS_BYTECODE
3833 /* Just die with a fatal error if not supported */
3834 fatal ("-fbytecode not supporter for this target");
3835 #else
3836 bc_initialize ();
3837 #endif
3840 if (optimize == 0)
3842 /* Inlining does not work if not optimizing,
3843 so force it not to be done. */
3844 flag_no_inline = 1;
3845 warn_inline = 0;
3847 /* The c_decode_option and lang_decode_option functions set
3848 this to `2' if -Wall is used, so we can avoid giving out
3849 lots of errors for people who don't realize what -Wall does. */
3850 if (warn_uninitialized == 1)
3851 warning ("-Wuninitialized is not supported without -O");
3854 #if defined(DWARF_DEBUGGING_INFO)
3855 if (write_symbols == DWARF_DEBUG
3856 && strcmp (language_string, "GNU C++") == 0)
3858 warning ("-g option not supported for C++ on SVR4 systems");
3859 write_symbols = NO_DEBUG;
3861 #endif /* defined(DWARF_DEBUGGING_INFO) */
3863 #ifdef OVERRIDE_OPTIONS
3864 /* Some machines may reject certain combinations of options. */
3865 OVERRIDE_OPTIONS;
3866 #endif
3868 /* Unrolling all loops implies that standard loop unrolling must also
3869 be done. */
3870 if (flag_unroll_all_loops)
3871 flag_unroll_loops = 1;
3872 /* Loop unrolling requires that strength_reduction be on also. Silently
3873 turn on strength reduction here if it isn't already on. Also, the loop
3874 unrolling code assumes that cse will be run after loop, so that must
3875 be turned on also. */
3876 if (flag_unroll_loops)
3878 flag_strength_reduce = 1;
3879 flag_rerun_cse_after_loop = 1;
3882 /* Warn about options that are not supported on this machine. */
3883 #ifndef INSN_SCHEDULING
3884 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3885 warning ("instruction scheduling not supported on this target machine");
3886 #endif
3887 #ifndef DELAY_SLOTS
3888 if (flag_delayed_branch)
3889 warning ("this target machine does not have delayed branches");
3890 #endif
3892 /* If we are in verbose mode, write out the version and maybe all the
3893 option flags in use. */
3894 if (version_flag)
3896 fprintf (stderr, "%s version %s", language_string, version_string);
3897 #ifdef TARGET_VERSION
3898 TARGET_VERSION;
3899 #endif
3900 #ifdef __GNUC__
3901 #ifndef __VERSION__
3902 #define __VERSION__ "[unknown]"
3903 #endif
3904 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3905 #else
3906 fprintf (stderr, " compiled by CC.\n");
3907 #endif
3908 if (! quiet_flag)
3909 print_switch_values ();
3912 compile_file (filename);
3914 #ifndef OS2
3915 #ifndef VMS
3916 if (flag_print_mem)
3918 #ifdef __alpha
3919 char *sbrk ();
3920 #endif
3921 char *lim = (char *) sbrk (0);
3923 fprintf (stderr, "Data size %d.\n",
3924 lim - (char *) &environ);
3925 fflush (stderr);
3927 #ifdef USG
3928 system ("ps -l 1>&2");
3929 #else /* not USG */
3930 system ("ps v");
3931 #endif /* not USG */
3933 #endif /* not VMS */
3934 #endif /* not OS2 */
3936 if (errorcount)
3937 exit (FATAL_EXIT_CODE);
3938 if (sorrycount)
3939 exit (FATAL_EXIT_CODE);
3940 exit (SUCCESS_EXIT_CODE);
3941 return 34;
3944 /* Decode -m switches. */
3946 /* Here is a table, controlled by the tm.h file, listing each -m switch
3947 and which bits in `target_switches' it should set or clear.
3948 If VALUE is positive, it is bits to set.
3949 If VALUE is negative, -VALUE is bits to clear.
3950 (The sign bit is not used so there is no confusion.) */
3952 struct {char *name; int value;} target_switches []
3953 = TARGET_SWITCHES;
3955 /* This table is similar, but allows the switch to have a value. */
3957 #ifdef TARGET_OPTIONS
3958 struct {char *prefix; char ** variable;} target_options []
3959 = TARGET_OPTIONS;
3960 #endif
3962 /* Decode the switch -mNAME. */
3964 void
3965 set_target_switch (name)
3966 char *name;
3968 register int j;
3969 int valid = 0;
3971 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3972 if (!strcmp (target_switches[j].name, name))
3974 if (target_switches[j].value < 0)
3975 target_flags &= ~-target_switches[j].value;
3976 else
3977 target_flags |= target_switches[j].value;
3978 valid = 1;
3981 #ifdef TARGET_OPTIONS
3982 if (!valid)
3983 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3985 int len = strlen (target_options[j].prefix);
3986 if (!strncmp (target_options[j].prefix, name, len))
3988 *target_options[j].variable = name + len;
3989 valid = 1;
3992 #endif
3994 if (!valid)
3995 error ("Invalid option `%s'", name);
3998 /* Variable used for communication between the following two routines. */
4000 static int line_position;
4002 /* Print an option value and adjust the position in the line. */
4004 static void
4005 print_single_switch (type, name)
4006 char *type, *name;
4008 fprintf (stderr, " %s%s", type, name);
4010 line_position += strlen (type) + strlen (name) + 1;
4012 if (line_position > 65)
4014 fprintf (stderr, "\n\t");
4015 line_position = 8;
4019 /* Print default target switches for -version. */
4021 static void
4022 print_switch_values ()
4024 register int j;
4026 fprintf (stderr, "enabled:");
4027 line_position = 8;
4029 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4030 if (*f_options[j].variable == f_options[j].on_value)
4031 print_single_switch ("-f", f_options[j].string);
4033 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
4034 if (*W_options[j].variable == W_options[j].on_value)
4035 print_single_switch ("-W", W_options[j].string);
4037 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4038 if (target_switches[j].name[0] != '\0'
4039 && target_switches[j].value > 0
4040 && ((target_switches[j].value & target_flags)
4041 == target_switches[j].value))
4042 print_single_switch ("-m", target_switches[j].name);
4044 fprintf (stderr, "\n");