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)
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. */
35 #include <sys/types.h>
42 #include <sys/param.h>
43 /* This is for hpux. It is a real screw. They should change hpux. */
45 #include <sys/times.h>
46 #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
47 #undef FFS /* Some systems define this in param.h. */
51 #include <sys/resource.h>
58 /* #include "c-tree.h" */
61 #include "insn-attr.h"
64 #ifdef XCOFF_DEBUGGING_INFO
72 /* The extra parameters substantially improve the I/O performance. */
74 vms_fopen (fname, type)
78 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
79 fixed arguments, which matches ANSI's specification but not VAXCRTL's
80 pre-ANSI implementation. This hack circumvents the mismatch problem. */
81 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
84 return (*vmslib_fopen) (fname, type, "mbc=32",
85 "deq=64", "fop=tef", "shr=nil");
87 return (*vmslib_fopen) (fname, type, "mbc=32");
89 #define fopen vms_fopen
92 #ifndef DEFAULT_GDB_EXTENSIONS
93 #define DEFAULT_GDB_EXTENSIONS 1
96 extern int rtx_equal_function_value_matters;
98 #if ! (defined (VMS) || defined (OS2))
99 extern char **environ;
101 extern char *version_string, *language_string;
103 /* Carry information from ASM_DECLARE_OBJECT_NAME
104 to ASM_FINISH_DECLARE_OBJECT. */
106 extern int size_directive_output;
107 extern tree last_assemble_variable_decl;
109 extern void init_lex ();
110 extern void init_decl_processing ();
111 extern void init_obstacks ();
112 extern void init_tree_codes ();
113 extern void init_rtl ();
114 extern void init_regs ();
115 extern void init_optabs ();
116 extern void init_stmt ();
117 extern void init_reg_sets ();
118 extern void dump_flow_info ();
119 extern void dump_sched_info ();
120 extern void dump_local_alloc ();
122 void rest_of_decl_compilation ();
123 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
124 void error_with_decl PVPROTO((tree decl, char *s, ...));
125 void error_for_asm PVPROTO((rtx insn, char *s, ...));
126 void error PVPROTO((char *s, ...));
127 void fatal PVPROTO((char *s, ...));
128 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
129 void warning_with_decl PVPROTO((tree decl, char *s, ...));
130 void warning_for_asm PVPROTO((rtx insn, char *s, ...));
131 void warning PVPROTO((char *s, ...));
132 void pedwarn PVPROTO((char *s, ...));
133 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
134 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
135 void sorry PVPROTO((char *s, ...));
136 void really_sorry PVPROTO((char *s, ...));
141 void set_target_switch ();
142 static void print_switch_values ();
143 static char *decl_name ();
145 /* Name of program invoked, sans directories. */
149 /* Copy of arguments to main. */
153 /* Name of current original source file (what was input to cpp).
154 This comes from each #-command in the actual input. */
156 char *input_filename;
158 /* Name of top-level original source file (what was input to cpp).
159 This comes from the #-command at the beginning of the actual input.
160 If there isn't any there, then this is the cc1 input file name. */
162 char *main_input_filename;
164 /* Stream for reading from the input file. */
168 /* Current line number in real source file. */
172 /* Stack of currently pending input files. */
174 struct file_stack *input_file_stack;
176 /* Incremented on each change to input_file_stack. */
177 int input_file_stack_tick;
179 /* FUNCTION_DECL for function now being parsed or compiled. */
181 extern tree current_function_decl;
183 /* Name to use as base of names for dump output files. */
185 char *dump_base_name;
187 /* Bit flags that specify the machine subtype we are compiling for.
188 Bits are tested using macros TARGET_... defined in the tm.h file
189 and set by `-m...' switches. Must be defined in rtlanal.c. */
191 extern int target_flags;
193 /* Flags saying which kinds of debugging dump have been requested. */
196 int rtl_dump_and_exit = 0;
197 int jump_opt_dump = 0;
202 int combine_dump = 0;
204 int local_reg_dump = 0;
205 int global_reg_dump = 0;
207 int jump2_opt_dump = 0;
208 int dbr_sched_dump = 0;
209 int flag_print_asm_name = 0;
210 int stack_reg_dump = 0;
212 /* Name for output file of assembly code, specified with -o. */
216 /* Value of the -G xx switch, and whether it was passed or not. */
220 /* Type(s) of debugging information we are producing (if any).
221 See flags.h for the definitions of the different possible
222 types of debugging information. */
223 enum debug_info_type write_symbols = NO_DEBUG;
225 /* Level of debugging information we are producing. See flags.h
226 for the definitions of the different possible levels. */
227 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
229 /* Nonzero means use GNU-only extensions in the generated symbolic
230 debugging information. */
231 /* Currently, this only has an effect when write_symbols is set to
232 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
233 int use_gnu_debug_info_extensions = 0;
235 /* Nonzero means do optimizations. -O.
236 Particular numeric values stand for particular amounts of optimization;
237 thus, -O2 stores 2 here. However, the optimizations beyond the basic
238 ones are not controlled directly by this variable. Instead, they are
239 controlled by individual `flag_...' variables that are defaulted
240 based on this variable. */
244 /* Number of error messages and warning messages so far. */
247 int warningcount = 0;
250 /* Flag to output bytecode instead of native assembler */
251 int output_bytecode = 0;
253 /* Pointer to function to compute the name to use to print a declaration. */
255 char *(*decl_printable_name) ();
257 /* Pointer to function to compute rtl for a language-specific tree code. */
259 struct rtx_def *(*lang_expand_expr) ();
261 /* Pointer to function to finish handling an incomplete decl at the
262 end of compilation. */
264 void (*incomplete_decl_finalize_hook) () = 0;
266 /* Pointer to function for interim exception handling implementation.
267 This interface will change, and it is only here until a better interface
270 void (*interim_eh_hook) PROTO((tree));
272 /* Nonzero if generating code to do profiling. */
274 int profile_flag = 0;
276 /* Nonzero if generating code to do profiling on a line-by-line basis. */
278 int profile_block_flag;
280 /* Nonzero for -pedantic switch: warn about anything
281 that standard spec forbids. */
285 /* Temporarily suppress certain warnings.
286 This is set while reading code from a system header file. */
288 int in_system_header = 0;
290 /* Nonzero means do stupid register allocation.
291 Currently, this is 1 if `optimize' is 0. */
293 int obey_regdecls = 0;
295 /* Don't print functions as they are compiled and don't print
296 times taken by the various passes. -quiet. */
302 /* Nonzero means `char' should be signed. */
304 int flag_signed_char;
306 /* Nonzero means give an enum type only as many bytes as it needs. */
308 int flag_short_enums;
310 /* Nonzero for -fcaller-saves: allocate values in regs that need to
311 be saved across function calls, if that produces overall better code.
312 Optional now, so people can test it. */
314 #ifdef DEFAULT_CALLER_SAVES
315 int flag_caller_saves = 1;
317 int flag_caller_saves = 0;
320 /* Nonzero if structures and unions should be returned in memory.
322 This should only be defined if compatibility with another compiler or
323 with an ABI is needed, because it results in slower code. */
325 #ifndef DEFAULT_PCC_STRUCT_RETURN
326 #define DEFAULT_PCC_STRUCT_RETURN 1
329 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
331 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
333 /* Nonzero for -fforce-mem: load memory value into a register
334 before arithmetic on it. This makes better cse but slower compilation. */
336 int flag_force_mem = 0;
338 /* Nonzero for -fforce-addr: load memory address into a register before
339 reference to memory. This makes better cse but slower compilation. */
341 int flag_force_addr = 0;
343 /* Nonzero for -fdefer-pop: don't pop args after each function call;
344 instead save them up to pop many calls' args with one insns. */
346 int flag_defer_pop = 0;
348 /* Nonzero for -ffloat-store: don't allocate floats and doubles
349 in extended-precision registers. */
351 int flag_float_store = 0;
353 /* Nonzero for -fcse-follow-jumps:
354 have cse follow jumps to do a more extensive job. */
356 int flag_cse_follow_jumps;
358 /* Nonzero for -fcse-skip-blocks:
359 have cse follow a branch around a block. */
360 int flag_cse_skip_blocks;
362 /* Nonzero for -fexpensive-optimizations:
363 perform miscellaneous relatively-expensive optimizations. */
364 int flag_expensive_optimizations;
366 /* Nonzero for -fthread-jumps:
367 have jump optimize output of loop. */
369 int flag_thread_jumps;
371 /* Nonzero enables strength-reduction in loop.c. */
373 int flag_strength_reduce = 0;
375 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
376 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
377 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
380 int flag_unroll_loops;
382 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
383 This is generally not a win. */
385 int flag_unroll_all_loops;
387 /* Nonzero for -fwritable-strings:
388 store string constants in data segment and don't uniquize them. */
390 int flag_writable_strings = 0;
392 /* Nonzero means don't put addresses of constant functions in registers.
393 Used for compiling the Unix kernel, where strange substitutions are
394 done on the assembly output. */
396 int flag_no_function_cse = 0;
398 /* Nonzero for -fomit-frame-pointer:
399 don't make a frame pointer in simple functions that don't require one. */
401 int flag_omit_frame_pointer = 0;
403 /* Nonzero to inhibit use of define_optimization peephole opts. */
405 int flag_no_peephole = 0;
407 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
408 operations in the interest of optimization. For example it allows
409 GCC to assume arguments to sqrt are nonnegative numbers, allowing
410 faster code for sqrt to be generated. */
412 int flag_fast_math = 0;
414 /* Nonzero means all references through pointers are volatile. */
418 /* Nonzero means treat all global and extern variables as global. */
420 int flag_volatile_global;
422 /* Nonzero means just do syntax checking; don't output anything. */
424 int flag_syntax_only = 0;
426 /* Nonzero means to rerun cse after loop optimization. This increases
427 compilation time about 20% and picks up a few more common expressions. */
429 static int flag_rerun_cse_after_loop;
431 /* Nonzero for -finline-functions: ok to inline functions that look like
432 good inline candidates. */
434 int flag_inline_functions;
436 /* Nonzero for -fkeep-inline-functions: even if we make a function
437 go inline everywhere, keep its definition around for debugging
440 int flag_keep_inline_functions;
442 /* Nonzero means that functions will not be inlined. */
446 /* Nonzero means we should be saving declaration info into a .X file. */
448 int flag_gen_aux_info = 0;
450 /* Specified name of aux-info file. */
452 static char *aux_info_file_name;
454 /* Nonzero means make the text shared if supported. */
456 int flag_shared_data;
458 /* Nonzero means schedule into delayed branch slots if supported. */
460 int flag_delayed_branch;
462 /* Nonzero means to run cleanups after CALL_EXPRs. */
464 int flag_short_temps;
466 /* Nonzero if we are compiling pure (sharable) code.
467 Value is 1 if we are doing reasonable (i.e. simple
468 offset into offset table) pic. Value is 2 if we can
469 only perform register offsets. */
473 /* Nonzero means place uninitialized global data in the bss section. */
477 /* Nonzero means pretend it is OK to examine bits of target floats,
478 even if that isn't true. The resulting code will have incorrect constants,
479 but the same series of instructions that the native compiler would make. */
481 int flag_pretend_float;
483 /* Nonzero means change certain warnings into errors.
484 Usually these are warnings about failure to conform to some standard. */
486 int flag_pedantic_errors = 0;
488 /* flag_schedule_insns means schedule insns within basic blocks (before
490 flag_schedule_insns_after_reload means schedule insns after
493 int flag_schedule_insns = 0;
494 int flag_schedule_insns_after_reload = 0;
496 /* -finhibit-size-directive inhibits output of .size for ELF.
497 This is used only for compiling crtstuff.c,
498 and it may be extended to other effects
499 needed for crtstuff.c on other systems. */
500 int flag_inhibit_size_directive = 0;
502 /* -fverbose-asm causes extra commentary information to be produced in
503 the generated assembly code (to make it more readable). This option
504 is generally only of use to those who actually need to read the
505 generated assembly code (perhaps while debugging the compiler itself). */
507 int flag_verbose_asm = 0;
509 /* -fgnu-linker specifies use of the GNU linker for initializations.
510 (Or, more generally, a linker that handles initializations.)
511 -fno-gnu-linker says that collect2 will be used. */
513 int flag_gnu_linker = 0;
515 int flag_gnu_linker = 1;
518 /* Table of language-independent -f options.
519 STRING is the option name. VARIABLE is the address of the variable.
520 ON_VALUE is the value to store in VARIABLE
521 if `-fSTRING' is seen as an option.
522 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
524 struct { char *string; int *variable; int on_value;} f_options[] =
526 {"float-store", &flag_float_store, 1},
527 {"volatile", &flag_volatile, 1},
528 {"volatile-global", &flag_volatile_global, 1},
529 {"defer-pop", &flag_defer_pop, 1},
530 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
531 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
532 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
533 {"expensive-optimizations", &flag_expensive_optimizations, 1},
534 {"thread-jumps", &flag_thread_jumps, 1},
535 {"strength-reduce", &flag_strength_reduce, 1},
536 {"unroll-loops", &flag_unroll_loops, 1},
537 {"unroll-all-loops", &flag_unroll_all_loops, 1},
538 {"writable-strings", &flag_writable_strings, 1},
539 {"peephole", &flag_no_peephole, 0},
540 {"force-mem", &flag_force_mem, 1},
541 {"force-addr", &flag_force_addr, 1},
542 {"function-cse", &flag_no_function_cse, 0},
543 {"inline-functions", &flag_inline_functions, 1},
544 {"keep-inline-functions", &flag_keep_inline_functions, 1},
545 {"inline", &flag_no_inline, 0},
546 {"syntax-only", &flag_syntax_only, 1},
547 {"shared-data", &flag_shared_data, 1},
548 {"caller-saves", &flag_caller_saves, 1},
549 {"pcc-struct-return", &flag_pcc_struct_return, 1},
550 {"reg-struct-return", &flag_pcc_struct_return, 0},
551 {"delayed-branch", &flag_delayed_branch, 1},
552 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
553 {"pretend-float", &flag_pretend_float, 1},
554 {"schedule-insns", &flag_schedule_insns, 1},
555 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
556 {"pic", &flag_pic, 1},
557 {"PIC", &flag_pic, 2},
558 {"fast-math", &flag_fast_math, 1},
559 {"common", &flag_no_common, 0},
560 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
561 {"verbose-asm", &flag_verbose_asm, 1},
562 {"gnu-linker", &flag_gnu_linker, 1},
563 {"bytecode", &output_bytecode, 1}
566 /* Table of language-specific options. */
568 char *lang_options[] =
571 "-fallow-single-precision",
573 "-fsigned-bitfields",
574 "-funsigned-bitfields",
575 "-fno-signed-bitfields",
576 "-fno-unsigned-bitfields",
580 "-fno-unsigned-char",
592 "-fno-cond-mismatch",
593 "-fdollars-in-identifiers",
594 "-fno-dollars-in-identifiers",
603 "-Wbad-function-cast",
604 "-Wno-bad-function-cast",
608 "-Wno-char-subscripts",
622 "-Wno-missing-braces",
623 "-Wmissing-declarations",
624 "-Wno-missing-declarations",
625 "-Wmissing-prototypes",
626 "-Wno-missing-prototypes",
628 "-Wno-nested-externs",
632 "-Wno-pointer-arith",
634 "-Wno-redundant-decls",
635 "-Wstrict-prototypes",
636 "-Wno-strict-prototypes",
642 "-Wno-write-strings",
644 /* These are for C++. */
645 "-+e0", /* gcc.c tacks the `-' on the front. */
649 "-fno-access-control",
652 "-falt-external-templates",
653 "-fno-alt-external-templates",
654 "-fansi-overloading",
655 "-fno-ansi-overloading",
659 "-fno-conserve-space",
661 "-fno-default-inline",
664 "-felide-constructors",
665 "-fno-elide-constructors",
667 "-fno-enum-int-equiv",
668 "-fexternal-templates",
669 "-fno-external-templates",
672 "-fhandle-exceptions",
673 "-fno-handle-exceptions",
674 "-fhandle-signatures",
675 "-fno-handle-signatures",
678 "-fimplement-inlines",
679 "-fno-implement-inlines",
680 "-fimplicit-templates",
681 "-fno-implicit-templates",
685 "-fno-memoize-lookups",
687 "-fno-nonnull-objects",
689 "-fno-save-memoized",
694 "-fstrict-prototype",
695 "-fno-strict-prototype",
696 "-fthis-is-variable",
697 "-fno-this-is-variable",
699 "-fno-vtable-thunks",
705 "-Woverloaded-virtual",
706 "-Wno-overloaded-virtual",
709 "-Wtemplate-debugging",
710 "-Wno-template-debugging",
711 "-Wctor-dtor-privacy",
712 "-Wno-ctor-dtor-privacy",
713 "-Wnon-virtual-dtor",
714 "-Wno-non-virtual-dtor",
716 "-Wno-extern-inline",
722 /* these are for obj c */
734 /* This is for GNAT and is temporary. */
739 /* Options controlling warnings */
741 /* Don't print warning messages. -w. */
743 int inhibit_warnings = 0;
745 /* Print various extra warnings. -W. */
747 int extra_warnings = 0;
749 /* Treat warnings as errors. -Werror. */
751 int warnings_are_errors = 0;
753 /* Nonzero to warn about unused local variables. */
757 /* Nonzero to warn about variables used before they are initialized. */
759 int warn_uninitialized;
761 /* Nonzero means warn about all declarations which shadow others. */
765 /* Warn if a switch on an enum fails to have a case for every enum value. */
769 /* Nonzero means warn about function definitions that default the return type
770 or that use a null return and have a return-type other than void. */
772 int warn_return_type;
774 /* Nonzero means warn about pointer casts that increase the required
775 alignment of the target type (and might therefore lead to a crash
776 due to a misaligned access). */
780 /* Nonzero means warn about any identifiers that match in the first N
781 characters. The value N is in `id_clash_len'. */
784 unsigned id_clash_len;
786 /* Nonzero means warn about any objects definitions whose size is larger
787 than N bytes. Also want about function definitions whose returned
788 values are larger than N bytes. The value N is in `larger_than_size'. */
790 int warn_larger_than;
791 unsigned larger_than_size;
793 /* Nonzero means warn if inline function is too large. */
797 /* Warn if a function returns an aggregate,
798 since there are often incompatible calling conventions for doing this. */
800 int warn_aggregate_return;
802 /* Likewise for -W. */
804 struct { char *string; int *variable; int on_value;} W_options[] =
806 {"unused", &warn_unused, 1},
807 {"error", &warnings_are_errors, 1},
808 {"shadow", &warn_shadow, 1},
809 {"switch", &warn_switch, 1},
810 {"aggregate-return", &warn_aggregate_return, 1},
811 {"cast-align", &warn_cast_align, 1},
812 {"uninitialized", &warn_uninitialized, 1},
813 {"inline", &warn_inline, 1}
816 /* Output files for assembler code (real compiler output)
817 and debugging dumps. */
822 FILE *jump_opt_dump_file;
824 FILE *loop_dump_file;
825 FILE *cse2_dump_file;
826 FILE *flow_dump_file;
827 FILE *combine_dump_file;
828 FILE *sched_dump_file;
829 FILE *local_reg_dump_file;
830 FILE *global_reg_dump_file;
831 FILE *sched2_dump_file;
832 FILE *jump2_opt_dump_file;
833 FILE *dbr_sched_dump_file;
834 FILE *stack_reg_dump_file;
836 /* Time accumulators, to count the total time spent in various passes. */
840 int integration_time;
848 int local_alloc_time;
849 int global_alloc_time;
852 int shorten_branch_time;
858 /* Return time used so far, in microseconds. */
870 struct rusage rusage;
875 int proc_system_time;
877 int child_system_time;
887 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
890 getrusage (0, &rusage);
891 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
892 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
895 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
901 #define TIMEVAR(VAR, BODY) \
902 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
905 print_time (str, total)
910 "time in %s: %d.%06d\n",
911 str, total / 1000000, total % 1000000);
914 /* Count an error or warning. Return 1 if the message should be printed. */
917 count_error (warningp)
920 if (warningp && inhibit_warnings)
923 if (warningp && !warnings_are_errors)
927 static int warning_message = 0;
929 if (warningp && !warning_message)
931 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
940 /* Print a fatal error message. NAME is the text.
941 Also include a system error message based on `errno'. */
944 pfatal_with_name (name)
947 fprintf (stderr, "%s: ", progname);
953 fatal_io_error (name)
956 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
960 /* Called to give a better error message for a bad insn rather than
961 just calling abort(). */
964 fatal_insn (message, insn)
968 if (!output_bytecode)
974 fflush (asm_out_file);
976 fflush (aux_info_file);
978 fflush (rtl_dump_file);
979 if (jump_opt_dump_file)
980 fflush (jump_opt_dump_file);
982 fflush (cse_dump_file);
984 fflush (loop_dump_file);
986 fflush (cse2_dump_file);
988 fflush (flow_dump_file);
989 if (combine_dump_file)
990 fflush (combine_dump_file);
992 fflush (sched_dump_file);
993 if (local_reg_dump_file)
994 fflush (local_reg_dump_file);
995 if (global_reg_dump_file)
996 fflush (global_reg_dump_file);
997 if (sched2_dump_file)
998 fflush (sched2_dump_file);
999 if (jump2_opt_dump_file)
1000 fflush (jump2_opt_dump_file);
1001 if (dbr_sched_dump_file)
1002 fflush (dbr_sched_dump_file);
1003 if (stack_reg_dump_file)
1004 fflush (stack_reg_dump_file);
1008 /* Called to give a better error message when we don't have an insn to match
1009 what we are looking for or if the insn's constraints aren't satisfied,
1010 rather than just calling abort(). */
1013 fatal_insn_not_found (insn)
1016 if (INSN_CODE (insn) < 0)
1017 fatal_insn ("internal error--unrecognizable insn:", insn);
1019 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1022 /* This is the default decl_printable_name function. */
1025 decl_name (decl, kind)
1029 return IDENTIFIER_POINTER (DECL_NAME (decl));
1032 /* This is the default interim_eh_hook function. */
1035 interim_eh (finalization)
1038 /* Don't do anything by default. */
1041 static int need_error_newline;
1043 /* Function of last error message;
1044 more generally, function such that if next error message is in it
1045 then we don't have to mention the function name. */
1046 static tree last_error_function = NULL;
1048 /* Used to detect when input_file_stack has changed since last described. */
1049 static int last_error_tick;
1051 /* Called when the start of a function definition is parsed,
1052 this function prints on stderr the name of the function. */
1055 announce_function (decl)
1061 if (rtl_dump_and_exit)
1062 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1064 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
1066 need_error_newline = 1;
1067 last_error_function = current_function_decl;
1071 /* Prints out, if necessary, the name of the current function
1072 which caused an error. Called from all error and warning functions. */
1075 report_error_function (file)
1078 struct file_stack *p;
1080 if (need_error_newline)
1082 fprintf (stderr, "\n");
1083 need_error_newline = 0;
1086 if (last_error_function != current_function_decl)
1088 char *kind = "function";
1089 if (current_function_decl != 0
1090 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1094 fprintf (stderr, "%s: ", file);
1096 if (current_function_decl == NULL)
1097 fprintf (stderr, "At top level:\n");
1100 char *name = (*decl_printable_name) (current_function_decl, &kind);
1101 fprintf (stderr, "In %s `%s':\n", kind, name);
1104 last_error_function = current_function_decl;
1106 if (input_file_stack && input_file_stack->next != 0
1107 && input_file_stack_tick != last_error_tick)
1109 fprintf (stderr, "In file included");
1110 for (p = input_file_stack->next; p; p = p->next)
1112 fprintf (stderr, " from %s:%d", p->name, p->line);
1114 fprintf (stderr, ",\n ");
1116 fprintf (stderr, ":\n");
1117 last_error_tick = input_file_stack_tick;
1121 /* Print a message. */
1124 vmessage (prefix, s, ap)
1130 fprintf (stderr, "%s: ", prefix);
1133 vfprintf (stderr, s, ap);
1136 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1137 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1138 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1139 fprintf (stderr, s, v1, v2, v3);
1144 /* Print a message relevant to line LINE of file FILE. */
1147 v_message_with_file_and_line (file, line, prefix, s, ap)
1155 fprintf (stderr, "%s:%d: ", file, line);
1157 fprintf (stderr, "%s: ", progname);
1159 vmessage (prefix, s, ap);
1160 fputc ('\n', stderr);
1163 /* Print a message relevant to the given DECL. */
1166 v_message_with_decl (decl, prefix, s, ap)
1174 fprintf (stderr, "%s:%d: ",
1175 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1178 fprintf (stderr, "%s: ", prefix);
1180 /* Do magic to get around lack of varargs support for insertion
1181 of arguments into existing list. We know that the decl is first;
1182 we ass_u_me that it will be printed with "%s". */
1184 for (p = s; *p; ++p)
1188 if (*(p + 1) == '%')
1195 if (p > s) /* Print the left-hand substring. */
1197 char fmt[sizeof "%.255s"];
1200 if (width > 255L) width = 255L; /* arbitrary */
1201 sprintf (fmt, "%%.%lds", width);
1202 fprintf (stderr, fmt, s);
1205 if (*p == '%') /* Print the name. */
1207 char *n = (DECL_NAME (decl)
1208 ? (*decl_printable_name) (decl, &junk)
1214 if (isalpha (*(p - 1) & 0xFF))
1219 if (*p) /* Print the rest of the message. */
1220 vmessage ((char *)NULL, p, ap);
1222 fputc ('\n', stderr);
1225 /* Figure file and line of the given INSN. */
1228 file_and_line_for_asm (insn, pfile, pline)
1233 rtx body = PATTERN (insn);
1236 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1237 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1238 asmop = SET_SRC (body);
1239 else if (GET_CODE (body) == ASM_OPERANDS)
1241 else if (GET_CODE (body) == PARALLEL
1242 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1243 asmop = SET_SRC (XVECEXP (body, 0, 0));
1244 else if (GET_CODE (body) == PARALLEL
1245 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1246 asmop = XVECEXP (body, 0, 0);
1252 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1253 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1257 *pfile = input_filename;
1262 /* Report an error at line LINE of file FILE. */
1265 v_error_with_file_and_line (file, line, s, ap)
1272 report_error_function (file);
1273 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1277 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1289 file = va_arg (ap, char *);
1290 line = va_arg (ap, int);
1291 s = va_arg (ap, char *);
1294 v_error_with_file_and_line (file, line, s, ap);
1298 /* Report an error at the declaration DECL.
1299 S is a format string which uses %s to substitute the declaration
1300 name; subsequent substitutions are a la printf. */
1303 v_error_with_decl (decl, s, ap)
1309 report_error_function (DECL_SOURCE_FILE (decl));
1310 v_message_with_decl (decl, (char *)NULL, s, ap);
1314 error_with_decl VPROTO((tree decl, char *s, ...))
1325 decl = va_arg (ap, tree);
1326 s = va_arg (ap, char *);
1329 v_error_with_decl (decl, s, ap);
1333 /* Report an error at the line number of the insn INSN.
1334 This is used only when INSN is an `asm' with operands,
1335 and each ASM_OPERANDS records its own source file and line. */
1338 v_error_for_asm (insn, s, ap)
1347 file_and_line_for_asm (insn, &file, &line);
1348 report_error_function (file);
1349 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1353 error_for_asm VPROTO((rtx insn, char *s, ...))
1364 insn = va_arg (ap, rtx);
1365 s = va_arg (ap, char *);
1368 v_error_for_asm (insn, s, ap);
1372 /* Report an error at the current line number. */
1379 v_error_with_file_and_line (input_filename, lineno, s, ap);
1383 error VPROTO((char *s, ...))
1393 s = va_arg (ap, char *);
1400 /* Report a fatal error at the current line number. */
1412 fatal VPROTO((char *s, ...))
1422 s = va_arg (ap, char *);
1429 /* Report a warning at line LINE of file FILE. */
1432 v_warning_with_file_and_line (file, line, s, ap)
1438 if (count_error (1))
1440 report_error_function (file);
1441 v_message_with_file_and_line (file, line, "warning", s, ap);
1446 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1458 file = va_arg (ap, char *);
1459 line = va_arg (ap, int);
1460 s = va_arg (ap, char *);
1463 v_warning_with_file_and_line (file, line, s, ap);
1467 /* Report a warning at the declaration DECL.
1468 S is a format string which uses %s to substitute the declaration
1469 name; subsequent substitutions are a la printf. */
1472 v_warning_with_decl (decl, s, ap)
1477 if (count_error (1))
1479 report_error_function (DECL_SOURCE_FILE (decl));
1480 v_message_with_decl (decl, "warning", s, ap);
1485 warning_with_decl VPROTO((tree decl, char *s, ...))
1496 decl = va_arg (ap, tree);
1497 s = va_arg (ap, char *);
1500 v_warning_with_decl (decl, s, ap);
1504 /* Report a warning at the line number of the insn INSN.
1505 This is used only when INSN is an `asm' with operands,
1506 and each ASM_OPERANDS records its own source file and line. */
1509 v_warning_for_asm (insn, s, ap)
1514 if (count_error (1))
1519 file_and_line_for_asm (insn, &file, &line);
1520 report_error_function (file);
1521 v_message_with_file_and_line (file, line, "warning", s, ap);
1526 warning_for_asm VPROTO((rtx insn, char *s, ...))
1537 insn = va_arg (ap, rtx);
1538 s = va_arg (ap, char *);
1541 v_warning_for_asm (insn, s, ap);
1545 /* Report a warning at the current line number. */
1552 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1556 warning VPROTO((char *s, ...))
1566 s = va_arg (ap, char *);
1573 /* These functions issue either warnings or errors depending on
1574 -pedantic-errors. */
1581 if (flag_pedantic_errors)
1588 pedwarn VPROTO((char *s, ...))
1598 s = va_arg (ap, char *);
1606 v_pedwarn_with_decl (decl, s, ap)
1611 /* We don't want -pedantic-errors to cause the compilation to fail from
1612 "errors" in system header files. Sometimes fixincludes can't fix what's
1613 broken (eg: unsigned char bitfields - fixing it may change the alignment
1614 which will cause programs to mysteriously fail because the C library
1615 or kernel uses the original layout). There's no point in issuing a
1616 warning either, it's just unnecessary noise. */
1618 if (! DECL_IN_SYSTEM_HEADER (decl))
1620 if (flag_pedantic_errors)
1621 v_error_with_decl (decl, s, ap);
1623 v_warning_with_decl (decl, s, ap);
1628 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1639 decl = va_arg (ap, tree);
1640 s = va_arg (ap, char *);
1643 v_pedwarn_with_decl (decl, s, ap);
1648 v_pedwarn_with_file_and_line (file, line, s, ap)
1654 if (flag_pedantic_errors)
1655 v_error_with_file_and_line (file, line, s, ap);
1657 v_warning_with_file_and_line (file, line, s, ap);
1661 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1673 file = va_arg (ap, char *);
1674 line = va_arg (ap, int);
1675 s = va_arg (ap, char *);
1678 v_pedwarn_with_file_and_line (file, line, s, ap);
1682 /* Apologize for not implementing some feature. */
1691 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1693 fprintf (stderr, "%s: ", progname);
1694 vmessage ("sorry, not implemented", s, ap);
1695 fputc ('\n', stderr);
1699 sorry VPROTO((char *s, ...))
1709 s = va_arg (ap, char *);
1716 /* Apologize for not implementing some feature, then quit. */
1719 v_really_sorry (s, ap)
1725 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1727 fprintf (stderr, "%s: ", progname);
1728 vmessage ("sorry, not implemented", s, ap);
1729 fatal (" (fatal)\n");
1733 really_sorry VPROTO((char *s, ...))
1743 s = va_arg (ap, char *);
1746 v_really_sorry (s, ap);
1750 /* More 'friendly' abort that prints the line and file.
1751 config.h can #define abort fancy_abort if you like that sort of thing.
1753 I don't think this is actually a good idea.
1754 Other sorts of crashes will look a certain way.
1755 It is a good thing if crashes from calling abort look the same way.
1761 fatal ("internal gcc abort");
1764 /* This calls abort and is used to avoid problems when abort if a macro.
1765 It is used when we need to pass the address of abort. */
1773 /* When `malloc.c' is compiled with `rcheck' defined,
1774 it calls this function to report clobberage. */
1782 /* Same as `malloc' but report error if no memory available. */
1788 register char *value = (char *) malloc (size);
1790 fatal ("virtual memory exhausted");
1794 /* Same as `realloc' but report error if no memory available. */
1797 xrealloc (ptr, size)
1801 char *result = (char *) realloc (ptr, size);
1803 fatal ("virtual memory exhausted");
1807 /* Return the logarithm of X, base 2, considering X unsigned,
1808 if X is a power of 2. Otherwise, returns -1.
1810 This should be used via the `exact_log2' macro. */
1814 register unsigned HOST_WIDE_INT x;
1816 register int log = 0;
1817 /* Test for 0 or a power of 2. */
1818 if (x == 0 || x != (x & -x))
1820 while ((x >>= 1) != 0)
1825 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1826 If X is 0, return -1.
1828 This should be used via the floor_log2 macro. */
1832 register unsigned HOST_WIDE_INT x;
1834 register int log = -1;
1842 jmp_buf float_handler;
1844 /* Specify where to longjmp to when a floating arithmetic error happens.
1845 If HANDLER is 0, it means don't handle the errors any more. */
1848 set_float_handler (handler)
1851 float_handled = (handler != 0);
1853 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1856 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1857 error happens, pushing the previous specification into OLD_HANDLER.
1858 Return an indication of whether there was a previous handler in effect. */
1861 push_float_handler (handler, old_handler)
1862 jmp_buf handler, old_handler;
1864 int was_handled = float_handled;
1868 bcopy ((char *) float_handler, (char *) old_handler,
1869 sizeof (float_handler));
1871 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1875 /* Restore the previous specification of whether and where to longjmp to
1876 when a floating arithmetic error happens. */
1879 pop_float_handler (handled, handler)
1883 float_handled = handled;
1885 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1888 /* Signals actually come here. */
1891 float_signal (signo)
1892 /* If this is missing, some compilers complain. */
1895 if (float_handled == 0)
1897 #if defined (USG) || defined (hpux)
1898 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1901 signal (SIGFPE, float_signal);
1902 longjmp (float_handler, 1);
1905 /* Handler for SIGPIPE. */
1909 /* If this is missing, some compilers complain. */
1912 fatal ("output pipe has been closed");
1915 /* Strip off a legitimate source ending from the input string NAME of
1919 strip_off_ending (name, len)
1923 if (len > 2 && ! strcmp (".c", name + len - 2))
1925 else if (len > 2 && ! strcmp (".m", name + len - 2))
1927 else if (len > 2 && ! strcmp (".i", name + len - 2))
1929 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1931 else if (len > 3 && ! strcmp (".co", name + len - 3))
1933 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1935 else if (len > 2 && ! strcmp (".C", name + len - 2))
1937 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1939 else if (len > 4 && ! strcmp (".cpp", name + len - 4))
1941 else if (len > 2 && ! strcmp (".f", name + len - 2))
1943 /* Ada will use extensions like .ada, .adb, and .ads, so just test
1945 else if (len > 4 && ! strncmp (".ad", name + len - 4, 3))
1947 else if (len > 4 && ! strcmp (".atr", name + len - 4))
1951 /* Output a quoted string. */
1953 output_quoted_string (asm_file, string)
1959 putc ('\"', asm_file);
1960 while ((c = *string++) != 0)
1962 if (c == '\"' || c == '\\')
1963 putc ('\\', asm_file);
1966 putc ('\"', asm_file);
1969 /* Output a file name in the form wanted by System V. */
1972 output_file_directive (asm_file, input_name)
1976 int len = strlen (input_name);
1977 char *na = input_name + len;
1979 /* NA gets INPUT_NAME sans directory names. */
1980 while (na > input_name)
1987 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1988 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1990 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1991 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1993 fprintf (asm_file, "\t.file\t");
1994 output_quoted_string (asm_file, na);
1995 fputc ('\n', asm_file);
2000 /* Routine to build language identifier for object file. */
2002 output_lang_identify (asm_out_file)
2005 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2006 char *s = (char *) alloca (len);
2007 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2008 ASM_OUTPUT_LABEL (asm_out_file, s);
2011 /* Routine to open a dump file. */
2013 open_dump_file (base_name, suffix)
2018 char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1);
2020 strcpy (dumpname, base_name);
2021 strcat (dumpname, suffix);
2022 f = fopen (dumpname, "w");
2024 pfatal_with_name (dumpname);
2028 /* Compile an entire file of output from cpp, named NAME.
2029 Write a file of assembly output and various debugging dumps. */
2038 int name_specified = name != 0;
2040 if (dump_base_name == 0)
2041 dump_base_name = name ? name : "gccdump";
2045 integration_time = 0;
2053 local_alloc_time = 0;
2054 global_alloc_time = 0;
2057 shorten_branch_time = 0;
2063 /* Open input file. */
2065 if (name == 0 || !strcmp (name, "-"))
2071 finput = fopen (name, "r");
2073 pfatal_with_name (name);
2075 #ifdef IO_BUFFER_SIZE
2076 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2079 /* Initialize data in various passes. */
2084 /* Some of these really don't need to be called when generating bytecode,
2085 but the options would have to be parsed first to know that. -bson */
2087 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2088 || debug_info_level == DINFO_LEVEL_VERBOSE);
2090 init_decl_processing ();
2098 if (flag_caller_saves)
2099 init_caller_save ();
2101 /* If auxiliary info generation is desired, open the output file.
2102 This goes in the same directory as the source file--unlike
2103 all the other output files. */
2104 if (flag_gen_aux_info)
2106 aux_info_file = fopen (aux_info_file_name, "w");
2107 if (aux_info_file == 0)
2108 pfatal_with_name (aux_info_file_name);
2111 /* If rtl dump desired, open the output file. */
2113 rtl_dump_file = open_dump_file (dump_base_name, ".rtl");
2115 /* If jump_opt dump desired, open the output file. */
2117 jump_opt_dump_file = open_dump_file (dump_base_name, ".jump");
2119 /* If cse dump desired, open the output file. */
2121 cse_dump_file = open_dump_file (dump_base_name, ".cse");
2123 /* If loop dump desired, open the output file. */
2125 loop_dump_file = open_dump_file (dump_base_name, ".loop");
2127 /* If cse2 dump desired, open the output file. */
2129 cse2_dump_file = open_dump_file (dump_base_name, ".cse2");
2131 /* If flow dump desired, open the output file. */
2133 flow_dump_file = open_dump_file (dump_base_name, ".flow");
2135 /* If combine dump desired, open the output file. */
2137 combine_dump_file = open_dump_file (dump_base_name, ".combine");
2139 /* If scheduling dump desired, open the output file. */
2141 sched_dump_file = open_dump_file (dump_base_name, ".sched");
2143 /* If local_reg dump desired, open the output file. */
2145 local_reg_dump_file = open_dump_file (dump_base_name, ".lreg");
2147 /* If global_reg dump desired, open the output file. */
2148 if (global_reg_dump)
2149 global_reg_dump_file = open_dump_file (dump_base_name, ".greg");
2151 /* If 2nd scheduling dump desired, open the output file. */
2153 sched2_dump_file = open_dump_file (dump_base_name, ".sched2");
2155 /* If jump2_opt dump desired, open the output file. */
2157 jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2");
2159 /* If dbr_sched dump desired, open the output file. */
2161 dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr");
2165 /* If stack_reg dump desired, open the output file. */
2167 stack_reg_dump_file = open_dump_file (dump_base_name, ".stack");
2171 /* Open assembler code output file. */
2173 if (! name_specified && asm_file_name == 0)
2174 asm_out_file = stdout;
2177 int len = strlen (dump_base_name);
2178 register char *dumpname = (char *) xmalloc (len + 6);
2179 strcpy (dumpname, dump_base_name);
2180 strip_off_ending (dumpname, len);
2181 strcat (dumpname, ".s");
2182 if (asm_file_name == 0)
2184 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2185 strcpy (asm_file_name, dumpname);
2187 if (!strcmp (asm_file_name, "-"))
2188 asm_out_file = stdout;
2190 asm_out_file = fopen (asm_file_name, "w");
2191 if (asm_out_file == 0)
2192 pfatal_with_name (asm_file_name);
2195 #ifdef IO_BUFFER_SIZE
2196 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2197 _IOFBF, IO_BUFFER_SIZE);
2200 input_filename = name;
2202 /* Perform language-specific initialization.
2203 This may set main_input_filename. */
2206 /* If the input doesn't start with a #line, use the input name
2207 as the official input file name. */
2208 if (main_input_filename == 0)
2209 main_input_filename = name;
2211 /* Put an entry on the input file stack for the main input file. */
2213 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2214 input_file_stack->next = 0;
2215 input_file_stack->name = input_filename;
2217 if (!output_bytecode)
2219 ASM_FILE_START (asm_out_file);
2222 /* Output something to inform GDB that this compilation was by GCC. Also
2223 serves to tell GDB file consists of bytecodes. */
2224 if (output_bytecode)
2225 fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
2228 #ifndef ASM_IDENTIFY_GCC
2229 fprintf (asm_out_file, "gcc2_compiled.:\n");
2231 ASM_IDENTIFY_GCC (asm_out_file);
2235 /* Output something to identify which front-end produced this file. */
2236 #ifdef ASM_IDENTIFY_LANGUAGE
2237 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2240 if (output_bytecode)
2242 if (profile_flag || profile_block_flag)
2243 error ("profiling not supported in bytecode compilation");
2247 /* ??? Note: There used to be a conditional here
2248 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2249 This was to guarantee separation between gcc_compiled. and
2250 the first function, for the sake of dbx on Suns.
2251 However, having the extra zero here confused the Emacs
2252 code for unexec, and might confuse other programs too.
2253 Therefore, I took out that change.
2254 In future versions we should find another way to solve
2255 that dbx problem. -- rms, 23 May 93. */
2257 /* Don't let the first function fall at the same address
2258 as gcc_compiled., if profiling. */
2259 if (profile_flag || profile_block_flag)
2260 assemble_zeros (UNITS_PER_WORD);
2263 /* If dbx symbol table desired, initialize writing it
2264 and output the predefined types. */
2265 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2266 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2267 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2270 #ifdef SDB_DEBUGGING_INFO
2271 if (write_symbols == SDB_DEBUG)
2272 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2275 #ifdef DWARF_DEBUGGING_INFO
2276 if (write_symbols == DWARF_DEBUG)
2277 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2280 /* Initialize yet another pass. */
2282 if (!output_bytecode)
2283 init_final (main_input_filename);
2285 start_time = get_run_time ();
2287 /* Call the parser, which parses the entire file
2288 (calling rest_of_compilation for each function). */
2290 if (yyparse () != 0)
2292 if (errorcount == 0)
2293 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2295 /* In case there were missing closebraces,
2296 get us back to the global binding level. */
2297 while (! global_bindings_p ())
2301 /* Compilation is now finished except for writing
2302 what's left of the symbol table output. */
2304 parse_time += get_run_time () - start_time;
2306 parse_time -= integration_time;
2307 parse_time -= varconst_time;
2309 globals = getdecls ();
2311 /* Really define vars that have had only a tentative definition.
2312 Really output inline functions that must actually be callable
2313 and have not been output so far. */
2316 int len = list_length (globals);
2317 tree *vec = (tree *) alloca (sizeof (tree) * len);
2322 /* Process the decls in reverse order--earliest first.
2323 Put them into VEC from back to front, then take out from front. */
2325 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2326 vec[len - i - 1] = decl;
2328 for (i = 0; i < len; i++)
2332 /* We're not deferring this any longer. */
2333 DECL_DEFER_OUTPUT (decl) = 0;
2335 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2336 && incomplete_decl_finalize_hook != 0)
2337 (*incomplete_decl_finalize_hook) (decl);
2340 /* Now emit any global variables or functions that we have been putting
2341 off. We need to loop in case one of the things emitted here
2342 references another one which comes earlier in the list. */
2346 for (i = 0; i < len; i++)
2350 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2353 /* Don't write out static consts, unless we still need them.
2355 We also keep static consts if not optimizing (for debugging).
2356 ??? They might be better written into the debug information.
2357 This is possible when using DWARF.
2359 A language processor that wants static constants to be always
2360 written out (even if it is not used) is responsible for
2361 calling rest_of_decl_compilation itself. E.g. the C front-end
2362 calls rest_of_decl_compilation from finish_decl.
2363 One motivation for this is that is conventional in some
2364 environments to write things like:
2365 static const char rcsid[] = "... version string ...";
2366 intending to force the string to be in the executable.
2368 A language processor that would prefer to have unneeded
2369 static constants "optimized away" would just defer writing
2370 them out until here. E.g. C++ does this, because static
2371 constants are often defined in header files.
2373 ??? A tempting alternative (for both C and C++) would be
2374 to force a constant to be written if and only if it is
2375 defined in a main file, as opposed to an include file. */
2377 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2378 && (! TREE_READONLY (decl)
2379 || TREE_PUBLIC (decl)
2381 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2384 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2387 if (TREE_CODE (decl) == FUNCTION_DECL
2388 && DECL_INITIAL (decl) != 0
2389 && DECL_SAVED_INSNS (decl) != 0
2390 && (flag_keep_inline_functions
2391 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2394 temporary_allocation ();
2395 output_inline_function (decl);
2396 permanent_allocation (1);
2401 for (i = 0; i < len; i++)
2405 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2406 && ! TREE_ASM_WRITTEN (decl))
2407 /* Cancel the RTL for this decl so that, if debugging info
2408 output for global variables is still to come,
2409 this one will be omitted. */
2410 DECL_RTL (decl) = NULL;
2412 /* Warn about any function
2413 declared static but not defined.
2414 We don't warn about variables,
2415 because many programs have static variables
2416 that exist only to get some text into the object file. */
2417 if (TREE_CODE (decl) == FUNCTION_DECL
2419 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2420 && DECL_INITIAL (decl) == 0
2421 && DECL_EXTERNAL (decl)
2422 && ! TREE_PUBLIC (decl))
2424 pedwarn_with_decl (decl,
2425 "`%s' declared `static' but never defined");
2426 /* This symbol is effectively an "extern" declaration now. */
2427 TREE_PUBLIC (decl) = 1;
2428 assemble_external (decl);
2431 /* Warn about static fns or vars defined but not used,
2432 but not about inline functions or static consts
2433 since defining those in header files is normal practice. */
2435 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2436 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2437 && ! DECL_IN_SYSTEM_HEADER (decl)
2438 && ! DECL_EXTERNAL (decl)
2439 && ! TREE_PUBLIC (decl)
2440 && ! TREE_USED (decl)
2441 && ! DECL_REGISTER (decl)
2442 /* The TREE_USED bit for file-scope decls
2443 is kept in the identifier, to handle multiple
2444 external decls in different scopes. */
2445 && ! TREE_USED (DECL_NAME (decl)))
2446 warning_with_decl (decl, "`%s' defined but not used");
2448 #ifdef SDB_DEBUGGING_INFO
2449 /* The COFF linker can move initialized global vars to the end.
2450 And that can screw up the symbol ordering.
2451 By putting the symbols in that order to begin with,
2452 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2453 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2454 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2455 && ! DECL_EXTERNAL (decl)
2456 && DECL_RTL (decl) != 0)
2457 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2459 /* Output COFF information for non-global
2460 file-scope initialized variables. */
2461 if (write_symbols == SDB_DEBUG
2462 && TREE_CODE (decl) == VAR_DECL
2463 && DECL_INITIAL (decl)
2464 && ! DECL_EXTERNAL (decl)
2465 && DECL_RTL (decl) != 0
2466 && GET_CODE (DECL_RTL (decl)) == MEM)
2467 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2468 #endif /* SDB_DEBUGGING_INFO */
2469 #ifdef DWARF_DEBUGGING_INFO
2470 /* Output DWARF information for file-scope tentative data object
2471 declarations, file-scope (extern) function declarations (which
2472 had no corresponding body) and file-scope tagged type declarations
2473 and definitions which have not yet been forced out. */
2475 if (write_symbols == DWARF_DEBUG
2476 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2477 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2482 /* Do dbx symbols */
2483 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2484 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2485 TIMEVAR (symout_time,
2487 dbxout_finish (asm_out_file, main_input_filename);
2491 #ifdef DWARF_DEBUGGING_INFO
2492 if (write_symbols == DWARF_DEBUG)
2493 TIMEVAR (symout_time,
2499 /* Output some stuff at end of file if nec. */
2501 if (!output_bytecode)
2503 end_final (main_input_filename);
2506 ASM_FILE_END (asm_out_file);
2510 /* Language-specific end of compilation actions. */
2514 if (output_bytecode)
2515 bc_write_file (asm_out_file);
2517 /* Close the dump files. */
2519 if (flag_gen_aux_info)
2521 fclose (aux_info_file);
2523 unlink (aux_info_file_name);
2527 fclose (rtl_dump_file);
2530 fclose (jump_opt_dump_file);
2533 fclose (cse_dump_file);
2536 fclose (loop_dump_file);
2539 fclose (cse2_dump_file);
2542 fclose (flow_dump_file);
2546 dump_combine_total_stats (combine_dump_file);
2547 fclose (combine_dump_file);
2551 fclose (sched_dump_file);
2554 fclose (local_reg_dump_file);
2556 if (global_reg_dump)
2557 fclose (global_reg_dump_file);
2560 fclose (sched2_dump_file);
2563 fclose (jump2_opt_dump_file);
2566 fclose (dbr_sched_dump_file);
2570 fclose (stack_reg_dump_file);
2573 /* Close non-debugging input and output files. Take special care to note
2574 whether fclose returns an error, since the pages might still be on the
2575 buffer chain while the file is open. */
2578 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2579 fatal_io_error (asm_file_name);
2581 /* Print the times. */
2585 fprintf (stderr,"\n");
2586 print_time ("parse", parse_time);
2588 if (!output_bytecode)
2590 print_time ("integration", integration_time);
2591 print_time ("jump", jump_time);
2592 print_time ("cse", cse_time);
2593 print_time ("loop", loop_time);
2594 print_time ("cse2", cse2_time);
2595 print_time ("flow", flow_time);
2596 print_time ("combine", combine_time);
2597 print_time ("sched", sched_time);
2598 print_time ("local-alloc", local_alloc_time);
2599 print_time ("global-alloc", global_alloc_time);
2600 print_time ("sched2", sched2_time);
2601 print_time ("dbranch", dbr_sched_time);
2602 print_time ("shorten-branch", shorten_branch_time);
2603 print_time ("stack-reg", stack_reg_time);
2604 print_time ("final", final_time);
2605 print_time ("varconst", varconst_time);
2606 print_time ("symout", symout_time);
2607 print_time ("dump", dump_time);
2612 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2613 and TYPE_DECL nodes.
2615 This does nothing for local (non-static) variables.
2616 Otherwise, it sets up the RTL and outputs any assembler code
2617 (label definition, storage allocation and initialization).
2619 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2620 the assembler symbol name to be used. TOP_LEVEL is nonzero
2621 if this declaration is not within a function. */
2624 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2630 /* Declarations of variables, and of functions defined elsewhere. */
2632 /* The most obvious approach, to put an #ifndef around where
2633 this macro is used, doesn't work since it's inside a macro call. */
2634 #ifndef ASM_FINISH_DECLARE_OBJECT
2635 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2638 /* Forward declarations for nested functions are not "external",
2639 but we need to treat them as if they were. */
2640 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2641 || TREE_CODE (decl) == FUNCTION_DECL)
2642 TIMEVAR (varconst_time,
2644 make_decl_rtl (decl, asmspec, top_level);
2645 /* Initialized extern variable exists to be replaced
2646 with its value, or represents something that will be
2647 output in another file. */
2648 if (! (TREE_CODE (decl) == VAR_DECL
2649 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2650 && DECL_INITIAL (decl) != 0
2651 && DECL_INITIAL (decl) != error_mark_node))
2652 /* Don't output anything
2653 when a tentative file-scope definition is seen.
2654 But at end of compilation, do output code for them. */
2655 if (! (! at_end && top_level
2656 && (DECL_INITIAL (decl) == 0
2657 || DECL_INITIAL (decl) == error_mark_node)))
2658 assemble_variable (decl, top_level, at_end, 0);
2659 if (decl == last_assemble_variable_decl)
2661 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2665 else if (DECL_REGISTER (decl) && asmspec != 0)
2667 if (decode_reg_name (asmspec) >= 0)
2669 DECL_RTL (decl) = 0;
2670 make_decl_rtl (decl, asmspec, top_level);
2673 error ("invalid register name `%s' for register variable", asmspec);
2675 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2676 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2677 && TREE_CODE (decl) == TYPE_DECL)
2678 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2680 #ifdef SDB_DEBUGGING_INFO
2681 else if (write_symbols == SDB_DEBUG && top_level
2682 && TREE_CODE (decl) == TYPE_DECL)
2683 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2687 /* Called after finishing a record, union or enumeral type. */
2690 rest_of_type_compilation (type, toplev)
2694 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2695 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2696 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2698 #ifdef SDB_DEBUGGING_INFO
2699 if (write_symbols == SDB_DEBUG)
2700 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2704 /* This is called from finish_function (within yyparse)
2705 after each top-level definition is parsed.
2706 It is supposed to compile that function or variable
2707 and output the assembler code for it.
2708 After we return, the tree storage is freed. */
2711 rest_of_compilation (decl)
2715 int start_time = get_run_time ();
2717 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2718 to be restored after we finish compiling the function
2719 (for use when compiling inline calls to this function). */
2720 tree saved_block_tree = 0;
2721 /* Likewise, for DECL_ARGUMENTS. */
2722 tree saved_arguments = 0;
2725 if (output_bytecode)
2728 /* If we are reconsidering an inline function
2729 at the end of compilation, skip the stuff for making it inline. */
2731 if (DECL_SAVED_INSNS (decl) == 0)
2733 int specd = DECL_INLINE (decl);
2736 /* If requested, consider whether to make this function inline. */
2737 if (specd || flag_inline_functions)
2738 TIMEVAR (integration_time,
2740 lose = function_cannot_inline_p (decl);
2741 /* If not optimzing, then make sure the DECL_INLINE
2743 if (lose || ! optimize)
2745 if (warn_inline && specd)
2746 warning_with_decl (decl, lose);
2747 DECL_INLINE (decl) = 0;
2748 DECL_ABSTRACT_ORIGIN (decl) = 0;
2749 /* Don't really compile an extern inline function.
2750 If we can't make it inline, pretend
2751 it was only declared. */
2752 if (DECL_EXTERNAL (decl))
2754 DECL_INITIAL (decl) = 0;
2755 goto exit_rest_of_compilation;
2759 DECL_INLINE (decl) = 1;
2762 insns = get_insns ();
2764 /* Dump the rtl code if we are dumping rtl. */
2769 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2770 IDENTIFIER_POINTER (DECL_NAME (decl)));
2771 if (DECL_SAVED_INSNS (decl))
2772 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2773 print_rtl (rtl_dump_file, insns);
2774 fflush (rtl_dump_file);
2777 /* If function is inline, and we don't yet know whether to
2778 compile it by itself, defer decision till end of compilation.
2779 finish_compilation will call rest_of_compilation again
2780 for those functions that need to be output. Also defer those
2781 functions that we are supposed to defer. */
2783 if (DECL_DEFER_OUTPUT (decl)
2784 || (DECL_INLINE (decl)
2785 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2786 && ! flag_keep_inline_functions)
2787 || DECL_EXTERNAL (decl))))
2789 #ifdef DWARF_DEBUGGING_INFO
2790 /* Generate the DWARF info for the "abstract" instance
2791 of a function which we may later generate inlined and/or
2792 out-of-line instances of. */
2793 if (write_symbols == DWARF_DEBUG)
2795 set_decl_abstract_flags (decl, 1);
2796 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2797 set_decl_abstract_flags (decl, 0);
2800 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2801 goto exit_rest_of_compilation;
2804 /* If we have to compile the function now, save its rtl and subdecls
2805 so that its compilation will not affect what others get. */
2806 if (DECL_INLINE (decl))
2808 #ifdef DWARF_DEBUGGING_INFO
2809 /* Generate the DWARF info for the "abstract" instance of
2810 a function which we will generate an out-of-line instance
2811 of almost immediately (and which we may also later generate
2812 various inlined instances of). */
2813 if (write_symbols == DWARF_DEBUG)
2815 set_decl_abstract_flags (decl, 1);
2816 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2817 set_decl_abstract_flags (decl, 0);
2820 saved_block_tree = DECL_INITIAL (decl);
2821 saved_arguments = DECL_ARGUMENTS (decl);
2822 TIMEVAR (integration_time, save_for_inline_copying (decl));
2825 /* If specified extern inline but we aren't inlining it, we are
2827 if (specd && DECL_EXTERNAL (decl))
2828 goto exit_rest_of_compilation;
2831 TREE_ASM_WRITTEN (decl) = 1;
2833 /* Now that integrate will no longer see our rtl, we need not distinguish
2834 between the return value of this function and the return value of called
2836 rtx_equal_function_value_matters = 0;
2838 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2839 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2841 goto exit_rest_of_compilation;
2844 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2845 Note that that may have been done above, in save_for_inline_copying.
2846 The call to resume_temporary_allocation near the end of this function
2847 goes back to the usual state of affairs. */
2849 rtl_in_current_obstack ();
2852 /* If we are doing position-independent code generation, now
2853 is the time to output special prologues and epilogues.
2854 We do not want to do this earlier, because it just clutters
2855 up inline functions with meaningless insns. */
2860 insns = get_insns ();
2862 /* Copy any shared structure that should not be shared. */
2864 unshare_all_rtl (insns);
2866 /* Instantiate all virtual registers. */
2868 instantiate_virtual_regs (current_function_decl, get_insns ());
2870 /* See if we have allocated stack slots that are not directly addressable.
2871 If so, scan all the insns and create explicit address computation
2872 for all references to such slots. */
2873 /* fixup_stack_slots (); */
2875 /* Do jump optimization the first time, if -opt.
2876 Also do it if -W, but in that case it doesn't change the rtl code,
2877 it only computes whether control can drop off the end of the function. */
2879 if (optimize > 0 || extra_warnings || warn_return_type
2880 /* If function is `noreturn', we should warn if it tries to return. */
2881 || TREE_THIS_VOLATILE (decl))
2883 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2884 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2887 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2888 if (rtl_dump_and_exit || flag_syntax_only)
2889 goto exit_rest_of_compilation;
2891 /* Dump rtl code after jump, if we are doing that. */
2896 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2897 IDENTIFIER_POINTER (DECL_NAME (decl)));
2898 print_rtl (jump_opt_dump_file, insns);
2899 fflush (jump_opt_dump_file);
2902 /* Perform common subexpression elimination.
2903 Nonzero value from `cse_main' means that jumps were simplified
2904 and some code may now be unreachable, so do
2905 jump optimization again. */
2910 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2911 IDENTIFIER_POINTER (DECL_NAME (decl)));
2916 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2918 if (flag_thread_jumps)
2919 /* Hacks by tiemann & kenner. */
2920 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
2922 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2924 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2926 if (tem || optimize > 1)
2927 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2930 /* Dump rtl code after cse, if we are doing that. */
2935 print_rtl (cse_dump_file, insns);
2936 fflush (cse_dump_file);
2942 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2943 IDENTIFIER_POINTER (DECL_NAME (decl)));
2946 /* Move constant computations out of loops. */
2952 loop_optimize (insns, loop_dump_file);
2956 /* Dump rtl code after loop opt, if we are doing that. */
2961 print_rtl (loop_dump_file, insns);
2962 fflush (loop_dump_file);
2968 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2969 IDENTIFIER_POINTER (DECL_NAME (decl)));
2972 if (optimize > 0 && flag_rerun_cse_after_loop)
2974 /* Running another jump optimization pass before the second
2975 cse pass sometimes simplifies the RTL enough to allow
2976 the second CSE pass to do a better job. Jump_optimize can change
2977 max_reg_num so we must rerun reg_scan afterwards.
2978 ??? Rework to not call reg_scan so often. */
2979 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2980 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2982 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2983 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2984 1, cse2_dump_file));
2986 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2989 if (optimize > 0 && flag_thread_jumps)
2990 /* This pass of jump threading straightens out code
2991 that was kinked by loop optimization. */
2992 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2994 /* Dump rtl code after cse, if we are doing that. */
2999 print_rtl (cse2_dump_file, insns);
3000 fflush (cse2_dump_file);
3003 /* We are no longer anticipating cse in this function, at least. */
3005 cse_not_expected = 1;
3007 /* Now we choose between stupid (pcc-like) register allocation
3008 (if we got the -noreg switch and not -opt)
3009 and smart register allocation. */
3011 if (optimize > 0) /* Stupid allocation probably won't work */
3012 obey_regdecls = 0; /* if optimizations being done. */
3016 /* Print function header into flow dump now
3017 because doing the flow analysis makes some of the dump. */
3022 fprintf (flow_dump_file, "\n;; Function %s\n\n",
3023 IDENTIFIER_POINTER (DECL_NAME (decl)));
3030 regclass (insns, max_reg_num ());
3031 stupid_life_analysis (insns, max_reg_num (),
3037 /* Do control and data flow analysis,
3038 and write some of the results to dump file. */
3040 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
3042 if (warn_uninitialized)
3044 uninitialized_vars_warning (DECL_INITIAL (decl));
3045 setjmp_args_warning ();
3049 /* Dump rtl after flow analysis. */
3054 print_rtl (flow_dump_file, insns);
3055 fflush (flow_dump_file);
3058 /* If -opt, try combining insns through substitution. */
3061 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3063 /* Dump rtl code after insn combination. */
3068 fprintf (combine_dump_file, "\n;; Function %s\n\n",
3069 IDENTIFIER_POINTER (DECL_NAME (decl)));
3070 dump_combine_stats (combine_dump_file);
3071 print_rtl (combine_dump_file, insns);
3072 fflush (combine_dump_file);
3075 /* Print function header into sched dump now
3076 because doing the sched analysis makes some of the dump. */
3081 fprintf (sched_dump_file, "\n;; Function %s\n\n",
3082 IDENTIFIER_POINTER (DECL_NAME (decl)));
3085 if (optimize > 0 && flag_schedule_insns)
3087 /* Do control and data sched analysis,
3088 and write some of the results to dump file. */
3090 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
3093 /* Dump rtl after instruction scheduling. */
3098 print_rtl (sched_dump_file, insns);
3099 fflush (sched_dump_file);
3102 /* Unless we did stupid register allocation,
3103 allocate pseudo-regs that are used only within 1 basic block. */
3106 TIMEVAR (local_alloc_time,
3108 regclass (insns, max_reg_num ());
3112 /* Dump rtl code after allocating regs within basic blocks. */
3117 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
3118 IDENTIFIER_POINTER (DECL_NAME (decl)));
3119 dump_flow_info (local_reg_dump_file);
3120 dump_local_alloc (local_reg_dump_file);
3121 print_rtl (local_reg_dump_file, insns);
3122 fflush (local_reg_dump_file);
3125 if (global_reg_dump)
3127 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
3128 IDENTIFIER_POINTER (DECL_NAME (decl))));
3130 /* Unless we did stupid register allocation,
3131 allocate remaining pseudo-regs, then do the reload pass
3132 fixing up any insns that are invalid. */
3134 TIMEVAR (global_alloc_time,
3137 failure = global_alloc (global_reg_dump_file);
3139 failure = reload (insns, 0, global_reg_dump_file);
3142 if (global_reg_dump)
3145 dump_global_regs (global_reg_dump_file);
3146 print_rtl (global_reg_dump_file, insns);
3147 fflush (global_reg_dump_file);
3151 goto exit_rest_of_compilation;
3153 reload_completed = 1;
3155 /* On some machines, the prologue and epilogue code, or parts thereof,
3156 can be represented as RTL. Doing so lets us schedule insns between
3157 it and the rest of the code and also allows delayed branch
3158 scheduling to operate in the epilogue. */
3160 thread_prologue_and_epilogue_insns (insns);
3162 if (optimize > 0 && flag_schedule_insns_after_reload)
3167 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
3168 IDENTIFIER_POINTER (DECL_NAME (decl)));
3171 /* Do control and data sched analysis again,
3172 and write some more of the results to dump file. */
3174 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
3176 /* Dump rtl after post-reorder instruction scheduling. */
3181 print_rtl (sched2_dump_file, insns);
3182 fflush (sched2_dump_file);
3186 #ifdef LEAF_REGISTERS
3188 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3192 /* One more attempt to remove jumps to .+1
3193 left by dead-store-elimination.
3194 Also do cross-jumping this time
3195 and delete no-op move insns. */
3199 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3202 /* Dump rtl code after jump, if we are doing that. */
3207 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
3208 IDENTIFIER_POINTER (DECL_NAME (decl)));
3209 print_rtl (jump2_opt_dump_file, insns);
3210 fflush (jump2_opt_dump_file);
3213 /* If a machine dependent reorganization is needed, call it. */
3214 #ifdef MACHINE_DEPENDENT_REORG
3215 MACHINE_DEPENDENT_REORG (insns);
3218 /* If a scheduling pass for delayed branches is to be done,
3219 call the scheduling code. */
3222 if (optimize > 0 && flag_delayed_branch)
3224 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3229 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
3230 IDENTIFIER_POINTER (DECL_NAME (decl)));
3231 print_rtl (dbr_sched_dump_file, insns);
3232 fflush (dbr_sched_dump_file);
3239 /* Shorten branches. */
3240 TIMEVAR (shorten_branch_time,
3242 shorten_branches (get_insns ());
3246 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3251 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
3252 IDENTIFIER_POINTER (DECL_NAME (decl)));
3253 print_rtl (stack_reg_dump_file, insns);
3254 fflush (stack_reg_dump_file);
3259 /* Now turn the rtl into assembler code. */
3261 TIMEVAR (final_time,
3266 /* Get the function's name, as described by its RTL.
3267 This may be different from the DECL_NAME name used
3268 in the source file. */
3270 x = DECL_RTL (decl);
3271 if (GET_CODE (x) != MEM)
3274 if (GET_CODE (x) != SYMBOL_REF)
3276 fnname = XSTR (x, 0);
3278 assemble_start_function (decl, fnname);
3279 final_start_function (insns, asm_out_file, optimize);
3280 final (insns, asm_out_file, optimize, 0);
3281 final_end_function (insns, asm_out_file, optimize);
3282 assemble_end_function (decl, fnname);
3283 fflush (asm_out_file);
3286 /* Write DBX symbols if requested */
3288 /* Note that for those inline functions where we don't initially
3289 know for certain that we will be generating an out-of-line copy,
3290 the first invocation of this routine (rest_of_compilation) will
3291 skip over this code by doing a `goto exit_rest_of_compilation;'.
3292 Later on, finish_compilation will call rest_of_compilation again
3293 for those inline functions that need to have out-of-line copies
3294 generated. During that call, we *will* be routed past here. */
3296 #ifdef DBX_DEBUGGING_INFO
3297 if (write_symbols == DBX_DEBUG)
3298 TIMEVAR (symout_time, dbxout_function (decl));
3301 #ifdef DWARF_DEBUGGING_INFO
3302 if (write_symbols == DWARF_DEBUG)
3303 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3306 exit_rest_of_compilation:
3308 /* In case the function was not output,
3309 don't leave any temporary anonymous types
3310 queued up for sdb output. */
3311 #ifdef SDB_DEBUGGING_INFO
3312 if (write_symbols == SDB_DEBUG)
3313 sdbout_types (NULL_TREE);
3316 /* Put back the tree of subblocks and list of arguments
3317 from before we copied them.
3318 Code generation and the output of debugging info may have modified
3319 the copy, but the original is unchanged. */
3321 if (saved_block_tree != 0)
3322 DECL_INITIAL (decl) = saved_block_tree;
3323 if (saved_arguments != 0)
3324 DECL_ARGUMENTS (decl) = saved_arguments;
3326 reload_completed = 0;
3328 /* Clear out the real_constant_chain before some of the rtx's
3329 it runs through become garbage. */
3331 clear_const_double_mem ();
3333 /* Cancel the effect of rtl_in_current_obstack. */
3335 resume_temporary_allocation ();
3337 /* The parsing time is all the time spent in yyparse
3338 *except* what is spent in this function. */
3340 parse_time -= get_run_time () - start_time;
3343 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3344 Exit code is 35 if can't open files, 34 if fatal error,
3345 33 if had nonfatal errors, else success. */
3348 main (argc, argv, envp)
3355 int flag_print_mem = 0;
3356 int version_flag = 0;
3359 /* save in case md file wants to emit args as a comment. */
3363 p = argv[0] + strlen (argv[0]);
3364 while (p != argv[0] && p[-1] != '/') --p;
3368 /* Get rid of any avoidable limit on stack size. */
3372 /* Set the stack limit huge so that alloca does not fail. */
3373 getrlimit (RLIMIT_STACK, &rlim);
3374 rlim.rlim_cur = rlim.rlim_max;
3375 setrlimit (RLIMIT_STACK, &rlim);
3377 #endif /* RLIMIT_STACK */
3379 signal (SIGFPE, float_signal);
3382 signal (SIGPIPE, pipe_closed);
3385 decl_printable_name = decl_name;
3386 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3387 interim_eh_hook = interim_eh;
3389 /* Initialize whether `char' is signed. */
3390 flag_signed_char = DEFAULT_SIGNED_CHAR;
3391 #ifdef DEFAULT_SHORT_ENUMS
3392 /* Initialize how much space enums occupy, by default. */
3393 flag_short_enums = DEFAULT_SHORT_ENUMS;
3396 /* Scan to see what optimization level has been specified. That will
3397 determine the default value of many flags. */
3398 for (i = 1; i < argc; i++)
3400 if (!strcmp (argv[i], "-O"))
3404 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3406 /* Handle -O2, -O3, -O69, ... */
3407 char *p = &argv[i][2];
3411 if (! (c >= '0' && c <= '9'))
3414 optimize = atoi (&argv[i][2]);
3418 obey_regdecls = (optimize == 0);
3428 flag_thread_jumps = 1;
3430 flag_delayed_branch = 1;
3432 #ifdef CAN_DEBUG_WITHOUT_FP
3433 flag_omit_frame_pointer = 1;
3439 flag_cse_follow_jumps = 1;
3440 flag_cse_skip_blocks = 1;
3441 flag_expensive_optimizations = 1;
3442 flag_strength_reduce = 1;
3443 flag_rerun_cse_after_loop = 1;
3444 flag_caller_saves = 1;
3445 #ifdef INSN_SCHEDULING
3446 flag_schedule_insns = 1;
3447 flag_schedule_insns_after_reload = 1;
3453 flag_inline_functions = 1;
3456 #ifdef OPTIMIZATION_OPTIONS
3457 /* Allow default optimizations to be specified on a per-machine basis. */
3458 OPTIMIZATION_OPTIONS (optimize);
3461 /* Initialize register usage now so switches may override. */
3465 set_target_switch ("");
3467 for (i = 1; i < argc; i++)
3470 /* If this is a language-specific option,
3471 decode it in a language-specific way. */
3472 for (j = 0; lang_options[j] != 0; j++)
3473 if (!strncmp (argv[i], lang_options[j],
3474 strlen (lang_options[j])))
3476 if (lang_options[j] != 0)
3477 /* If the option is valid for *some* language,
3478 treat it as valid even if this language doesn't understand it. */
3479 lang_decode_option (argv[i]);
3480 else if (argv[i][0] == '-' && argv[i][1] != 0)
3482 register char *str = argv[i] + 1;
3487 set_target_switch (&str[1]);
3488 else if (!strcmp (str, "dumpbase"))
3490 dump_base_name = argv[++i];
3492 else if (str[0] == 'd')
3494 register char *p = &str[1];
3502 global_reg_dump = 1;
3508 cse_dump = 1, cse2_dump = 1;
3526 global_reg_dump = 1;
3544 flag_print_asm_name = 1;
3566 rtl_dump_and_exit = 1;
3570 else if (str[0] == 'f')
3572 register char *p = &str[1];
3575 /* Some kind of -f option.
3576 P's value is the option sans `-f'.
3577 Search for it in the table of options. */
3580 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3583 if (!strcmp (p, f_options[j].string))
3585 *f_options[j].variable = f_options[j].on_value;
3586 /* A goto here would be cleaner,
3587 but breaks the vax pcc. */
3590 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3591 && ! strcmp (p+3, f_options[j].string))
3593 *f_options[j].variable = ! f_options[j].on_value;
3600 else if (!strncmp (p, "fixed-", 6))
3601 fix_register (&p[6], 1, 1);
3602 else if (!strncmp (p, "call-used-", 10))
3603 fix_register (&p[10], 0, 1);
3604 else if (!strncmp (p, "call-saved-", 11))
3605 fix_register (&p[11], 0, 0);
3607 error ("Invalid option `%s'", argv[i]);
3609 else if (str[0] == 'O')
3611 register char *p = str+1;
3612 while (*p && *p >= '0' && *p <= '9')
3617 error ("Invalid option `%s'", argv[i]);
3619 else if (!strcmp (str, "pedantic"))
3621 else if (!strcmp (str, "pedantic-errors"))
3622 flag_pedantic_errors = pedantic = 1;
3623 else if (!strcmp (str, "quiet"))
3625 else if (!strcmp (str, "version"))
3627 else if (!strcmp (str, "w"))
3628 inhibit_warnings = 1;
3629 else if (!strcmp (str, "W"))
3632 /* We save the value of warn_uninitialized, since if they put
3633 -Wuninitialized on the command line, we need to generate a
3634 warning about not using it without also specifying -O. */
3635 if (warn_uninitialized != 1)
3636 warn_uninitialized = 2;
3638 else if (str[0] == 'W')
3640 register char *p = &str[1];
3643 /* Some kind of -W option.
3644 P's value is the option sans `-W'.
3645 Search for it in the table of options. */
3648 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3651 if (!strcmp (p, W_options[j].string))
3653 *W_options[j].variable = W_options[j].on_value;
3654 /* A goto here would be cleaner,
3655 but breaks the vax pcc. */
3658 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3659 && ! strcmp (p+3, W_options[j].string))
3661 *W_options[j].variable = ! W_options[j].on_value;
3668 else if (!strncmp (p, "id-clash-", 9))
3674 if (*endp >= '0' && *endp <= '9')
3678 error ("Invalid option `%s'", argv[i]);
3683 id_clash_len = atoi (str + 10);
3686 else if (!strncmp (p, "larger-than-", 12))
3688 char *endp = p + 12;
3692 if (*endp >= '0' && *endp <= '9')
3696 error ("Invalid option `%s'", argv[i]);
3697 goto larger_than_lose;
3700 warn_larger_than = 1;
3701 larger_than_size = atoi (str + 13);
3705 error ("Invalid option `%s'", argv[i]);
3707 else if (!strcmp (str, "p"))
3709 if (!output_bytecode)
3712 error ("profiling not supported in bytecode compilation");
3714 else if (!strcmp (str, "a"))
3716 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3717 warning ("`-a' option (basic block profile) not supported");
3719 profile_block_flag = 1;
3722 else if (str[0] == 'g')
3729 while (*p && (*p < '0' || *p > '9'))
3733 while (*q && (*q >= '0' && *q <= '9'))
3738 level = 2; /* default debugging info level */
3739 if (*q || level > 3)
3741 warning ("invalid debug level specification in option: `-%s'",
3743 warning ("no debugging information will be generated");
3747 /* If more than one debugging type is supported,
3748 you must define PREFERRED_DEBUGGING_TYPE
3749 to choose a format in a system-dependent way. */
3750 /* This is one long line cause VAXC can't handle a \-newline. */
3751 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3752 #ifdef PREFERRED_DEBUGGING_TYPE
3753 if (!strncmp (str, "ggdb", len))
3754 write_symbols = PREFERRED_DEBUGGING_TYPE;
3755 #else /* no PREFERRED_DEBUGGING_TYPE */
3756 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3757 #endif /* no PREFERRED_DEBUGGING_TYPE */
3758 #endif /* More than one debugger format enabled. */
3759 #ifdef DBX_DEBUGGING_INFO
3760 if (write_symbols != NO_DEBUG)
3762 else if (!strncmp (str, "ggdb", len))
3763 write_symbols = DBX_DEBUG;
3764 else if (!strncmp (str, "gstabs", len))
3765 write_symbols = DBX_DEBUG;
3766 else if (!strncmp (str, "gstabs+", len))
3767 write_symbols = DBX_DEBUG;
3769 /* Always enable extensions for -ggdb or -gstabs+,
3770 always disable for -gstabs.
3771 For plain -g, use system-specific default. */
3772 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3774 use_gnu_debug_info_extensions = 1;
3775 else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
3777 use_gnu_debug_info_extensions = 1;
3778 else if (write_symbols == DBX_DEBUG
3779 && !strncmp (str, "gstabs", len) && len >= 2)
3780 use_gnu_debug_info_extensions = 0;
3782 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3783 #endif /* DBX_DEBUGGING_INFO */
3784 #ifdef DWARF_DEBUGGING_INFO
3785 if (write_symbols != NO_DEBUG)
3787 else if (!strncmp (str, "g", len))
3788 write_symbols = DWARF_DEBUG;
3789 else if (!strncmp (str, "ggdb", len))
3790 write_symbols = DWARF_DEBUG;
3791 else if (!strncmp (str, "gdwarf", len))
3792 write_symbols = DWARF_DEBUG;
3794 /* Always enable extensions for -ggdb or -gdwarf+,
3795 always disable for -gdwarf.
3796 For plain -g, use system-specific default. */
3797 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3799 use_gnu_debug_info_extensions = 1;
3800 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3801 use_gnu_debug_info_extensions = 1;
3802 else if (write_symbols == DWARF_DEBUG
3803 && !strncmp (str, "gdwarf", len) && len >= 2)
3804 use_gnu_debug_info_extensions = 0;
3806 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3808 #ifdef SDB_DEBUGGING_INFO
3809 if (write_symbols != NO_DEBUG)
3811 else if (!strncmp (str, "g", len))
3812 write_symbols = SDB_DEBUG;
3813 else if (!strncmp (str, "gdb", len))
3814 write_symbols = SDB_DEBUG;
3815 else if (!strncmp (str, "gcoff", len))
3816 write_symbols = SDB_DEBUG;
3817 #endif /* SDB_DEBUGGING_INFO */
3818 #ifdef XCOFF_DEBUGGING_INFO
3819 if (write_symbols != NO_DEBUG)
3821 else if (!strncmp (str, "g", len))
3822 write_symbols = XCOFF_DEBUG;
3823 else if (!strncmp (str, "ggdb", len))
3824 write_symbols = XCOFF_DEBUG;
3825 else if (!strncmp (str, "gxcoff", len))
3826 write_symbols = XCOFF_DEBUG;
3828 /* Always enable extensions for -ggdb or -gxcoff+,
3829 always disable for -gxcoff.
3830 For plain -g, use system-specific default. */
3831 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3833 use_gnu_debug_info_extensions = 1;
3834 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3835 use_gnu_debug_info_extensions = 1;
3836 else if (write_symbols == XCOFF_DEBUG
3837 && !strncmp (str, "gxcoff", len) && len >= 2)
3838 use_gnu_debug_info_extensions = 0;
3840 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3842 if (write_symbols == NO_DEBUG)
3843 warning ("`-%s' option not supported on this version of GCC", str);
3844 else if (level == 0)
3845 write_symbols = NO_DEBUG;
3847 debug_info_level = (enum debug_info_level) level;
3849 else if (!strcmp (str, "o"))
3851 asm_file_name = argv[++i];
3853 else if (str[0] == 'G')
3855 g_switch_set = TRUE;
3856 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3858 else if (!strncmp (str, "aux-info", 8))
3860 flag_gen_aux_info = 1;
3861 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3864 error ("Invalid option `%s'", argv[i]);
3866 else if (argv[i][0] == '+')
3867 error ("Invalid option `%s'", argv[i]);
3872 /* Initialize for bytecode output. A good idea to do this as soon as
3873 possible after the "-f" options have been parsed. */
3874 if (output_bytecode)
3876 #ifndef TARGET_SUPPORTS_BYTECODE
3877 /* Just die with a fatal error if not supported */
3878 fatal ("-fbytecode not supporter for this target");
3886 /* Inlining does not work if not optimizing,
3887 so force it not to be done. */
3891 /* The c_decode_option and lang_decode_option functions set
3892 this to `2' if -Wall is used, so we can avoid giving out
3893 lots of errors for people who don't realize what -Wall does. */
3894 if (warn_uninitialized == 1)
3895 warning ("-Wuninitialized is not supported without -O");
3898 #if defined(DWARF_DEBUGGING_INFO)
3899 if (write_symbols == DWARF_DEBUG
3900 && strcmp (language_string, "GNU C++") == 0)
3902 warning ("-g option not supported for C++ on SVR4 systems");
3903 write_symbols = NO_DEBUG;
3905 #endif /* defined(DWARF_DEBUGGING_INFO) */
3907 #ifdef OVERRIDE_OPTIONS
3908 /* Some machines may reject certain combinations of options. */
3912 /* Unrolling all loops implies that standard loop unrolling must also
3914 if (flag_unroll_all_loops)
3915 flag_unroll_loops = 1;
3916 /* Loop unrolling requires that strength_reduction be on also. Silently
3917 turn on strength reduction here if it isn't already on. Also, the loop
3918 unrolling code assumes that cse will be run after loop, so that must
3919 be turned on also. */
3920 if (flag_unroll_loops)
3922 flag_strength_reduce = 1;
3923 flag_rerun_cse_after_loop = 1;
3926 /* Warn about options that are not supported on this machine. */
3927 #ifndef INSN_SCHEDULING
3928 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3929 warning ("instruction scheduling not supported on this target machine");
3932 if (flag_delayed_branch)
3933 warning ("this target machine does not have delayed branches");
3936 /* If we are in verbose mode, write out the version and maybe all the
3937 option flags in use. */
3940 fprintf (stderr, "%s version %s", language_string, version_string);
3941 #ifdef TARGET_VERSION
3946 #define __VERSION__ "[unknown]"
3948 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3950 fprintf (stderr, " compiled by CC.\n");
3953 print_switch_values ();
3956 compile_file (filename);
3958 #if !defined(OS2) && !defined(VMS) && !defined(WINNT)
3964 char *lim = (char *) sbrk (0);
3966 fprintf (stderr, "Data size %d.\n",
3967 lim - (char *) &environ);
3971 system ("ps -l 1>&2");
3974 #endif /* not USG */
3976 #endif /* not OS2 and not VMS and not WINNT */
3979 exit (FATAL_EXIT_CODE);
3981 exit (FATAL_EXIT_CODE);
3982 exit (SUCCESS_EXIT_CODE);
3986 /* Decode -m switches. */
3988 /* Here is a table, controlled by the tm.h file, listing each -m switch
3989 and which bits in `target_switches' it should set or clear.
3990 If VALUE is positive, it is bits to set.
3991 If VALUE is negative, -VALUE is bits to clear.
3992 (The sign bit is not used so there is no confusion.) */
3994 struct {char *name; int value;} target_switches []
3997 /* This table is similar, but allows the switch to have a value. */
3999 #ifdef TARGET_OPTIONS
4000 struct {char *prefix; char ** variable;} target_options []
4004 /* Decode the switch -mNAME. */
4007 set_target_switch (name)
4013 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4014 if (!strcmp (target_switches[j].name, name))
4016 if (target_switches[j].value < 0)
4017 target_flags &= ~-target_switches[j].value;
4019 target_flags |= target_switches[j].value;
4023 #ifdef TARGET_OPTIONS
4025 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4027 int len = strlen (target_options[j].prefix);
4028 if (!strncmp (target_options[j].prefix, name, len))
4030 *target_options[j].variable = name + len;
4037 error ("Invalid option `%s'", name);
4040 /* Variable used for communication between the following two routines. */
4042 static int line_position;
4044 /* Print an option value and adjust the position in the line. */
4047 print_single_switch (type, name)
4050 fprintf (stderr, " %s%s", type, name);
4052 line_position += strlen (type) + strlen (name) + 1;
4054 if (line_position > 65)
4056 fprintf (stderr, "\n\t");
4061 /* Print default target switches for -version. */
4064 print_switch_values ()
4068 fprintf (stderr, "enabled:");
4071 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4072 if (*f_options[j].variable == f_options[j].on_value)
4073 print_single_switch ("-f", f_options[j].string);
4075 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
4076 if (*W_options[j].variable == W_options[j].on_value)
4077 print_single_switch ("-W", W_options[j].string);
4079 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4080 if (target_switches[j].name[0] != '\0'
4081 && target_switches[j].value > 0
4082 && ((target_switches[j].value & target_flags)
4083 == target_switches[j].value))
4084 print_single_switch ("-m", target_switches[j].name);
4086 fprintf (stderr, "\n");