1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-5, 1996 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This is the top level of cc1/c++.
22 It parses command args, opens files, invokes the various passes
23 in the proper order, and counts the time used by each.
24 Error messages and low-level interface to malloc also handled here. */
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>
60 #include "insn-attr.h"
66 #ifdef XCOFF_DEBUGGING_INFO
71 /* The extra parameters substantially improve the I/O performance. */
73 vms_fopen (fname, type)
77 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
78 fixed arguments, which matches ANSI's specification but not VAXCRTL's
79 pre-ANSI implementation. This hack circumvents the mismatch problem. */
80 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
83 return (*vmslib_fopen) (fname, type, "mbc=32",
84 "deq=64", "fop=tef", "shr=nil");
86 return (*vmslib_fopen) (fname, type, "mbc=32");
88 #define fopen vms_fopen
91 #ifndef DEFAULT_GDB_EXTENSIONS
92 #define DEFAULT_GDB_EXTENSIONS 1
95 extern int rtx_equal_function_value_matters;
97 #if ! (defined (VMS) || defined (OS2))
98 extern char **environ;
100 extern char *version_string, *language_string;
102 /* Carry information from ASM_DECLARE_OBJECT_NAME
103 to ASM_FINISH_DECLARE_OBJECT. */
105 extern int size_directive_output;
106 extern tree last_assemble_variable_decl;
108 extern void init_lex ();
109 extern void init_decl_processing ();
110 extern void init_obstacks ();
111 extern void init_tree_codes ();
112 extern void init_rtl ();
113 extern void init_regs ();
114 extern void init_optabs ();
115 extern void init_stmt ();
116 extern void init_reg_sets ();
117 extern void dump_flow_info ();
118 extern void dump_sched_info ();
119 extern void dump_local_alloc ();
121 void rest_of_decl_compilation ();
122 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
123 void error_with_decl PVPROTO((tree decl, char *s, ...));
124 void error_for_asm PVPROTO((rtx insn, char *s, ...));
125 void error PVPROTO((char *s, ...));
126 void fatal PVPROTO((char *s, ...));
127 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
128 void warning_with_decl PVPROTO((tree decl, char *s, ...));
129 void warning_for_asm PVPROTO((rtx insn, char *s, ...));
130 void warning PVPROTO((char *s, ...));
131 void pedwarn PVPROTO((char *s, ...));
132 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
133 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
134 void sorry PVPROTO((char *s, ...));
135 void really_sorry PVPROTO((char *s, ...));
140 void set_target_switch ();
141 static void print_switch_values ();
142 static char *decl_name ();
145 extern char *sbrk ();
148 /* Name of program invoked, sans directories. */
152 /* Copy of arguments to main. */
156 /* Name of current original source file (what was input to cpp).
157 This comes from each #-command in the actual input. */
159 char *input_filename;
161 /* Name of top-level original source file (what was input to cpp).
162 This comes from the #-command at the beginning of the actual input.
163 If there isn't any there, then this is the cc1 input file name. */
165 char *main_input_filename;
167 /* Stream for reading from the input file. */
171 /* Current line number in real source file. */
175 /* Stack of currently pending input files. */
177 struct file_stack *input_file_stack;
179 /* Incremented on each change to input_file_stack. */
180 int input_file_stack_tick;
182 /* FUNCTION_DECL for function now being parsed or compiled. */
184 extern tree current_function_decl;
186 /* Name to use as base of names for dump output files. */
188 char *dump_base_name;
190 /* Bit flags that specify the machine subtype we are compiling for.
191 Bits are tested using macros TARGET_... defined in the tm.h file
192 and set by `-m...' switches. Must be defined in rtlanal.c. */
194 extern int target_flags;
196 /* Flags saying which kinds of debugging dump have been requested. */
199 int rtl_dump_and_exit = 0;
200 int jump_opt_dump = 0;
205 int combine_dump = 0;
207 int local_reg_dump = 0;
208 int global_reg_dump = 0;
210 int jump2_opt_dump = 0;
211 int dbr_sched_dump = 0;
212 int flag_print_asm_name = 0;
213 int stack_reg_dump = 0;
215 /* Name for output file of assembly code, specified with -o. */
219 /* Value of the -G xx switch, and whether it was passed or not. */
223 /* Type(s) of debugging information we are producing (if any).
224 See flags.h for the definitions of the different possible
225 types of debugging information. */
226 enum debug_info_type write_symbols = NO_DEBUG;
228 /* Level of debugging information we are producing. See flags.h
229 for the definitions of the different possible levels. */
230 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
232 /* Nonzero means use GNU-only extensions in the generated symbolic
233 debugging information. */
234 /* Currently, this only has an effect when write_symbols is set to
235 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
236 int use_gnu_debug_info_extensions = 0;
238 /* Nonzero means do optimizations. -O.
239 Particular numeric values stand for particular amounts of optimization;
240 thus, -O2 stores 2 here. However, the optimizations beyond the basic
241 ones are not controlled directly by this variable. Instead, they are
242 controlled by individual `flag_...' variables that are defaulted
243 based on this variable. */
247 /* Number of error messages and warning messages so far. */
250 int warningcount = 0;
253 /* Flag to output bytecode instead of native assembler */
254 int output_bytecode = 0;
256 /* Pointer to function to compute the name to use to print a declaration. */
258 char *(*decl_printable_name) ();
260 /* Pointer to function to compute rtl for a language-specific tree code. */
262 struct rtx_def *(*lang_expand_expr) ();
264 /* Pointer to function to finish handling an incomplete decl at the
265 end of compilation. */
267 void (*incomplete_decl_finalize_hook) () = 0;
269 /* Pointer to function for interim exception handling implementation.
270 This interface will change, and it is only here until a better interface
273 void (*interim_eh_hook) PROTO((tree));
275 /* Highest label number used at the end of reload. */
277 int max_label_num_after_reload;
279 /* Nonzero if generating code to do profiling. */
281 int profile_flag = 0;
283 /* Nonzero if generating code to do profiling on a line-by-line basis. */
285 int profile_block_flag;
287 /* Nonzero for -pedantic switch: warn about anything
288 that standard spec forbids. */
292 /* Temporarily suppress certain warnings.
293 This is set while reading code from a system header file. */
295 int in_system_header = 0;
297 /* Nonzero means do stupid register allocation.
298 Currently, this is 1 if `optimize' is 0. */
300 int obey_regdecls = 0;
302 /* Don't print functions as they are compiled and don't print
303 times taken by the various passes. -quiet. */
309 /* Nonzero means `char' should be signed. */
311 int flag_signed_char;
313 /* Nonzero means give an enum type only as many bytes as it needs. */
315 int flag_short_enums;
317 /* Nonzero for -fcaller-saves: allocate values in regs that need to
318 be saved across function calls, if that produces overall better code.
319 Optional now, so people can test it. */
321 #ifdef DEFAULT_CALLER_SAVES
322 int flag_caller_saves = 1;
324 int flag_caller_saves = 0;
327 /* Nonzero if structures and unions should be returned in memory.
329 This should only be defined if compatibility with another compiler or
330 with an ABI is needed, because it results in slower code. */
332 #ifndef DEFAULT_PCC_STRUCT_RETURN
333 #define DEFAULT_PCC_STRUCT_RETURN 1
336 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
338 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
340 /* Nonzero for -fforce-mem: load memory value into a register
341 before arithmetic on it. This makes better cse but slower compilation. */
343 int flag_force_mem = 0;
345 /* Nonzero for -fforce-addr: load memory address into a register before
346 reference to memory. This makes better cse but slower compilation. */
348 int flag_force_addr = 0;
350 /* Nonzero for -fdefer-pop: don't pop args after each function call;
351 instead save them up to pop many calls' args with one insns. */
353 int flag_defer_pop = 0;
355 /* Nonzero for -ffloat-store: don't allocate floats and doubles
356 in extended-precision registers. */
358 int flag_float_store = 0;
360 /* Nonzero for -fcse-follow-jumps:
361 have cse follow jumps to do a more extensive job. */
363 int flag_cse_follow_jumps;
365 /* Nonzero for -fcse-skip-blocks:
366 have cse follow a branch around a block. */
367 int flag_cse_skip_blocks;
369 /* Nonzero for -fexpensive-optimizations:
370 perform miscellaneous relatively-expensive optimizations. */
371 int flag_expensive_optimizations;
373 /* Nonzero for -fthread-jumps:
374 have jump optimize output of loop. */
376 int flag_thread_jumps;
378 /* Nonzero enables strength-reduction in loop.c. */
380 int flag_strength_reduce = 0;
382 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
383 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
384 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
387 int flag_unroll_loops;
389 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
390 This is generally not a win. */
392 int flag_unroll_all_loops;
394 /* Nonzero for -fwritable-strings:
395 store string constants in data segment and don't uniquize them. */
397 int flag_writable_strings = 0;
399 /* Nonzero means don't put addresses of constant functions in registers.
400 Used for compiling the Unix kernel, where strange substitutions are
401 done on the assembly output. */
403 int flag_no_function_cse = 0;
405 /* Nonzero for -fomit-frame-pointer:
406 don't make a frame pointer in simple functions that don't require one. */
408 int flag_omit_frame_pointer = 0;
410 /* Nonzero means place each function into its own section on those platforms
411 which support arbitrary section names and unlimited numbers of sections. */
413 int flag_function_sections = 0;
415 /* Nonzero to inhibit use of define_optimization peephole opts. */
417 int flag_no_peephole = 0;
419 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
420 operations in the interest of optimization. For example it allows
421 GCC to assume arguments to sqrt are nonnegative numbers, allowing
422 faster code for sqrt to be generated. */
424 int flag_fast_math = 0;
426 /* Nonzero means all references through pointers are volatile. */
430 /* Nonzero means treat all global and extern variables as global. */
432 int flag_volatile_global;
434 /* Nonzero means just do syntax checking; don't output anything. */
436 int flag_syntax_only = 0;
438 /* Nonzero means to rerun cse after loop optimization. This increases
439 compilation time about 20% and picks up a few more common expressions. */
441 static int flag_rerun_cse_after_loop;
443 /* Nonzero for -finline-functions: ok to inline functions that look like
444 good inline candidates. */
446 int flag_inline_functions;
448 /* Nonzero for -fkeep-inline-functions: even if we make a function
449 go inline everywhere, keep its definition around for debugging
452 int flag_keep_inline_functions;
454 /* Nonzero means that functions will not be inlined. */
458 /* Nonzero means we should be saving declaration info into a .X file. */
460 int flag_gen_aux_info = 0;
462 /* Specified name of aux-info file. */
464 static char *aux_info_file_name;
466 /* Nonzero means make the text shared if supported. */
468 int flag_shared_data;
470 /* Nonzero means schedule into delayed branch slots if supported. */
472 int flag_delayed_branch;
474 /* Nonzero means to run cleanups after CALL_EXPRs. */
476 int flag_short_temps;
478 /* Nonzero if we are compiling pure (sharable) code.
479 Value is 1 if we are doing reasonable (i.e. simple
480 offset into offset table) pic. Value is 2 if we can
481 only perform register offsets. */
485 /* Nonzero means don't place uninitialized global data in common storage
490 /* Nonzero means pretend it is OK to examine bits of target floats,
491 even if that isn't true. The resulting code will have incorrect constants,
492 but the same series of instructions that the native compiler would make. */
494 int flag_pretend_float;
496 /* Nonzero means change certain warnings into errors.
497 Usually these are warnings about failure to conform to some standard. */
499 int flag_pedantic_errors = 0;
501 /* flag_schedule_insns means schedule insns within basic blocks (before
503 flag_schedule_insns_after_reload means schedule insns after
506 int flag_schedule_insns = 0;
507 int flag_schedule_insns_after_reload = 0;
509 /* -finhibit-size-directive inhibits output of .size for ELF.
510 This is used only for compiling crtstuff.c,
511 and it may be extended to other effects
512 needed for crtstuff.c on other systems. */
513 int flag_inhibit_size_directive = 0;
515 /* -fverbose-asm causes extra commentary information to be produced in
516 the generated assembly code (to make it more readable). This option
517 is generally only of use to those who actually need to read the
518 generated assembly code (perhaps while debugging the compiler itself). */
520 int flag_verbose_asm = 0;
522 /* -fgnu-linker specifies use of the GNU linker for initializations.
523 (Or, more generally, a linker that handles initializations.)
524 -fno-gnu-linker says that collect2 will be used. */
526 int flag_gnu_linker = 0;
528 int flag_gnu_linker = 1;
531 /* Tag all structures with __attribute__(packed) */
532 int flag_pack_struct = 0;
534 /* Table of language-independent -f options.
535 STRING is the option name. VARIABLE is the address of the variable.
536 ON_VALUE is the value to store in VARIABLE
537 if `-fSTRING' is seen as an option.
538 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
540 struct { char *string; int *variable; int on_value;} f_options[] =
542 {"float-store", &flag_float_store, 1},
543 {"volatile", &flag_volatile, 1},
544 {"volatile-global", &flag_volatile_global, 1},
545 {"defer-pop", &flag_defer_pop, 1},
546 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
547 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
548 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
549 {"expensive-optimizations", &flag_expensive_optimizations, 1},
550 {"thread-jumps", &flag_thread_jumps, 1},
551 {"strength-reduce", &flag_strength_reduce, 1},
552 {"unroll-loops", &flag_unroll_loops, 1},
553 {"unroll-all-loops", &flag_unroll_all_loops, 1},
554 {"writable-strings", &flag_writable_strings, 1},
555 {"peephole", &flag_no_peephole, 0},
556 {"force-mem", &flag_force_mem, 1},
557 {"force-addr", &flag_force_addr, 1},
558 {"function-cse", &flag_no_function_cse, 0},
559 {"inline-functions", &flag_inline_functions, 1},
560 {"keep-inline-functions", &flag_keep_inline_functions, 1},
561 {"inline", &flag_no_inline, 0},
562 {"syntax-only", &flag_syntax_only, 1},
563 {"shared-data", &flag_shared_data, 1},
564 {"caller-saves", &flag_caller_saves, 1},
565 {"pcc-struct-return", &flag_pcc_struct_return, 1},
566 {"reg-struct-return", &flag_pcc_struct_return, 0},
567 {"delayed-branch", &flag_delayed_branch, 1},
568 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
569 {"pretend-float", &flag_pretend_float, 1},
570 {"schedule-insns", &flag_schedule_insns, 1},
571 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
572 {"pic", &flag_pic, 1},
573 {"PIC", &flag_pic, 2},
574 {"fast-math", &flag_fast_math, 1},
575 {"common", &flag_no_common, 0},
576 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
577 {"function-sections", &flag_function_sections, 1},
578 {"verbose-asm", &flag_verbose_asm, 1},
579 {"gnu-linker", &flag_gnu_linker, 1},
580 {"pack-struct", &flag_pack_struct, 1},
581 {"bytecode", &output_bytecode, 1}
584 /* Table of language-specific options. */
586 char *lang_options[] =
589 "-fallow-single-precision",
591 "-fsigned-bitfields",
592 "-funsigned-bitfields",
593 "-fno-signed-bitfields",
594 "-fno-unsigned-bitfields",
598 "-fno-unsigned-char",
610 "-fno-cond-mismatch",
611 "-fdollars-in-identifiers",
612 "-fno-dollars-in-identifiers",
621 "-Wbad-function-cast",
622 "-Wno-bad-function-cast",
626 "-Wno-char-subscripts",
640 "-Wno-missing-braces",
641 "-Wmissing-declarations",
642 "-Wno-missing-declarations",
643 "-Wmissing-prototypes",
644 "-Wno-missing-prototypes",
646 "-Wno-nested-externs",
650 "-Wno-pointer-arith",
652 "-Wno-redundant-decls",
655 "-Wstrict-prototypes",
656 "-Wno-strict-prototypes",
662 "-Wno-write-strings",
664 /* these are for obj c */
680 /* Options controlling warnings */
682 /* Don't print warning messages. -w. */
684 int inhibit_warnings = 0;
686 /* Print various extra warnings. -W. */
688 int extra_warnings = 0;
690 /* Treat warnings as errors. -Werror. */
692 int warnings_are_errors = 0;
694 /* Nonzero to warn about unused local variables. */
698 /* Nonzero to warn about variables used before they are initialized. */
700 int warn_uninitialized;
702 /* Nonzero means warn about all declarations which shadow others. */
706 /* Warn if a switch on an enum fails to have a case for every enum value. */
710 /* Nonzero means warn about function definitions that default the return type
711 or that use a null return and have a return-type other than void. */
713 int warn_return_type;
715 /* Nonzero means warn about pointer casts that increase the required
716 alignment of the target type (and might therefore lead to a crash
717 due to a misaligned access). */
721 /* Nonzero means warn about any identifiers that match in the first N
722 characters. The value N is in `id_clash_len'. */
725 unsigned id_clash_len;
727 /* Nonzero means warn about any objects definitions whose size is larger
728 than N bytes. Also want about function definitions whose returned
729 values are larger than N bytes. The value N is in `larger_than_size'. */
731 int warn_larger_than;
732 unsigned larger_than_size;
734 /* Nonzero means warn if inline function is too large. */
738 /* Warn if a function returns an aggregate,
739 since there are often incompatible calling conventions for doing this. */
741 int warn_aggregate_return;
743 /* Likewise for -W. */
745 struct { char *string; int *variable; int on_value;} W_options[] =
747 {"unused", &warn_unused, 1},
748 {"error", &warnings_are_errors, 1},
749 {"shadow", &warn_shadow, 1},
750 {"switch", &warn_switch, 1},
751 {"aggregate-return", &warn_aggregate_return, 1},
752 {"cast-align", &warn_cast_align, 1},
753 {"uninitialized", &warn_uninitialized, 1},
754 {"inline", &warn_inline, 1}
757 /* Output files for assembler code (real compiler output)
758 and debugging dumps. */
763 FILE *jump_opt_dump_file;
765 FILE *loop_dump_file;
766 FILE *cse2_dump_file;
767 FILE *flow_dump_file;
768 FILE *combine_dump_file;
769 FILE *sched_dump_file;
770 FILE *local_reg_dump_file;
771 FILE *global_reg_dump_file;
772 FILE *sched2_dump_file;
773 FILE *jump2_opt_dump_file;
774 FILE *dbr_sched_dump_file;
775 FILE *stack_reg_dump_file;
777 /* Time accumulators, to count the total time spent in various passes. */
781 int integration_time;
789 int local_alloc_time;
790 int global_alloc_time;
793 int shorten_branch_time;
799 /* Return time used so far, in microseconds. */
809 struct rusage rusage;
814 int proc_system_time;
816 int child_system_time;
828 return (clock() * 1000);
829 #else /* not _WIN32 */
832 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
835 getrusage (0, &rusage);
836 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
837 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
840 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
846 #define TIMEVAR(VAR, BODY) \
847 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
850 print_time (str, total)
855 "time in %s: %d.%06d\n",
856 str, total / 1000000, total % 1000000);
859 /* Count an error or warning. Return 1 if the message should be printed. */
862 count_error (warningp)
865 if (warningp && inhibit_warnings)
868 if (warningp && !warnings_are_errors)
872 static int warning_message = 0;
874 if (warningp && !warning_message)
876 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
885 /* Print a fatal error message. NAME is the text.
886 Also include a system error message based on `errno'. */
889 pfatal_with_name (name)
892 fprintf (stderr, "%s: ", progname);
894 exit (FATAL_EXIT_CODE);
898 fatal_io_error (name)
901 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
902 exit (FATAL_EXIT_CODE);
905 /* Called to give a better error message for a bad insn rather than
906 just calling abort(). */
909 fatal_insn (message, insn)
913 if (!output_bytecode)
919 fflush (asm_out_file);
921 fflush (aux_info_file);
923 fflush (rtl_dump_file);
924 if (jump_opt_dump_file)
925 fflush (jump_opt_dump_file);
927 fflush (cse_dump_file);
929 fflush (loop_dump_file);
931 fflush (cse2_dump_file);
933 fflush (flow_dump_file);
934 if (combine_dump_file)
935 fflush (combine_dump_file);
937 fflush (sched_dump_file);
938 if (local_reg_dump_file)
939 fflush (local_reg_dump_file);
940 if (global_reg_dump_file)
941 fflush (global_reg_dump_file);
942 if (sched2_dump_file)
943 fflush (sched2_dump_file);
944 if (jump2_opt_dump_file)
945 fflush (jump2_opt_dump_file);
946 if (dbr_sched_dump_file)
947 fflush (dbr_sched_dump_file);
948 if (stack_reg_dump_file)
949 fflush (stack_reg_dump_file);
955 /* Called to give a better error message when we don't have an insn to match
956 what we are looking for or if the insn's constraints aren't satisfied,
957 rather than just calling abort(). */
960 fatal_insn_not_found (insn)
963 if (INSN_CODE (insn) < 0)
964 fatal_insn ("internal error--unrecognizable insn:", insn);
966 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
969 /* This is the default decl_printable_name function. */
972 decl_name (decl, kind)
976 return IDENTIFIER_POINTER (DECL_NAME (decl));
979 /* This is the default interim_eh_hook function. */
982 interim_eh (finalization)
985 /* Don't do anything by default. */
988 static int need_error_newline;
990 /* Function of last error message;
991 more generally, function such that if next error message is in it
992 then we don't have to mention the function name. */
993 static tree last_error_function = NULL;
995 /* Used to detect when input_file_stack has changed since last described. */
996 static int last_error_tick;
998 /* Called when the start of a function definition is parsed,
999 this function prints on stderr the name of the function. */
1002 announce_function (decl)
1008 if (rtl_dump_and_exit)
1009 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1011 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
1013 need_error_newline = 1;
1014 last_error_function = current_function_decl;
1018 /* The default function to print out name of current function that caused
1022 default_print_error_function (file)
1025 if (last_error_function != current_function_decl)
1027 char *kind = "function";
1028 if (current_function_decl != 0
1029 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1033 fprintf (stderr, "%s: ", file);
1035 if (current_function_decl == NULL)
1036 fprintf (stderr, "At top level:\n");
1039 char *name = (*decl_printable_name) (current_function_decl, &kind);
1040 fprintf (stderr, "In %s `%s':\n", kind, name);
1043 last_error_function = current_function_decl;
1047 /* Called by report_error_function to print out function name.
1048 * Default may be overridden by language front-ends. */
1050 void (*print_error_function) PROTO((char*)) = default_print_error_function;
1052 /* Prints out, if necessary, the name of the current function
1053 that caused an error. Called from all error and warning functions. */
1056 report_error_function (file)
1059 struct file_stack *p;
1061 if (need_error_newline)
1063 fprintf (stderr, "\n");
1064 need_error_newline = 0;
1067 (*print_error_function) (file);
1069 if (input_file_stack && input_file_stack->next != 0
1070 && input_file_stack_tick != last_error_tick
1071 && file == input_filename)
1073 fprintf (stderr, "In file included");
1074 for (p = input_file_stack->next; p; p = p->next)
1076 fprintf (stderr, " from %s:%d", p->name, p->line);
1078 fprintf (stderr, ",\n ");
1080 fprintf (stderr, ":\n");
1081 last_error_tick = input_file_stack_tick;
1085 /* Print a message. */
1088 vmessage (prefix, s, ap)
1094 fprintf (stderr, "%s: ", prefix);
1097 vfprintf (stderr, s, ap);
1100 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1101 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1102 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1103 HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT);
1104 fprintf (stderr, s, v1, v2, v3, v4);
1109 /* Print a message relevant to line LINE of file FILE. */
1112 v_message_with_file_and_line (file, line, prefix, s, ap)
1120 fprintf (stderr, "%s:%d: ", file, line);
1122 fprintf (stderr, "%s: ", progname);
1124 vmessage (prefix, s, ap);
1125 fputc ('\n', stderr);
1128 /* Print a message relevant to the given DECL. */
1131 v_message_with_decl (decl, prefix, s, ap)
1139 fprintf (stderr, "%s:%d: ",
1140 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1143 fprintf (stderr, "%s: ", prefix);
1145 /* Do magic to get around lack of varargs support for insertion
1146 of arguments into existing list. We know that the decl is first;
1147 we ass_u_me that it will be printed with "%s". */
1149 for (p = s; *p; ++p)
1153 if (*(p + 1) == '%')
1160 if (p > s) /* Print the left-hand substring. */
1162 char fmt[sizeof "%.255s"];
1165 if (width > 255L) width = 255L; /* arbitrary */
1166 sprintf (fmt, "%%.%lds", width);
1167 fprintf (stderr, fmt, s);
1170 if (*p == '%') /* Print the name. */
1172 char *n = (DECL_NAME (decl)
1173 ? (*decl_printable_name) (decl, &junk)
1179 if (isalpha (*(p - 1) & 0xFF))
1184 if (*p) /* Print the rest of the message. */
1185 vmessage ((char *)NULL, p, ap);
1187 fputc ('\n', stderr);
1190 /* Figure file and line of the given INSN. */
1193 file_and_line_for_asm (insn, pfile, pline)
1198 rtx body = PATTERN (insn);
1201 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1202 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1203 asmop = SET_SRC (body);
1204 else if (GET_CODE (body) == ASM_OPERANDS)
1206 else if (GET_CODE (body) == PARALLEL
1207 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1208 asmop = SET_SRC (XVECEXP (body, 0, 0));
1209 else if (GET_CODE (body) == PARALLEL
1210 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1211 asmop = XVECEXP (body, 0, 0);
1217 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1218 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1222 *pfile = input_filename;
1227 /* Report an error at line LINE of file FILE. */
1230 v_error_with_file_and_line (file, line, s, ap)
1237 report_error_function (file);
1238 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1242 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1254 file = va_arg (ap, char *);
1255 line = va_arg (ap, int);
1256 s = va_arg (ap, char *);
1259 v_error_with_file_and_line (file, line, s, ap);
1263 /* Report an error at the declaration DECL.
1264 S is a format string which uses %s to substitute the declaration
1265 name; subsequent substitutions are a la printf. */
1268 v_error_with_decl (decl, s, ap)
1274 report_error_function (DECL_SOURCE_FILE (decl));
1275 v_message_with_decl (decl, (char *)NULL, s, ap);
1279 error_with_decl VPROTO((tree decl, char *s, ...))
1290 decl = va_arg (ap, tree);
1291 s = va_arg (ap, char *);
1294 v_error_with_decl (decl, s, ap);
1298 /* Report an error at the line number of the insn INSN.
1299 This is used only when INSN is an `asm' with operands,
1300 and each ASM_OPERANDS records its own source file and line. */
1303 v_error_for_asm (insn, s, ap)
1312 file_and_line_for_asm (insn, &file, &line);
1313 report_error_function (file);
1314 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1318 error_for_asm VPROTO((rtx insn, char *s, ...))
1329 insn = va_arg (ap, rtx);
1330 s = va_arg (ap, char *);
1333 v_error_for_asm (insn, s, ap);
1337 /* Report an error at the current line number. */
1344 v_error_with_file_and_line (input_filename, lineno, s, ap);
1348 error VPROTO((char *s, ...))
1358 s = va_arg (ap, char *);
1365 /* Report a fatal error at the current line number. */
1373 exit (FATAL_EXIT_CODE);
1377 fatal VPROTO((char *s, ...))
1387 s = va_arg (ap, char *);
1394 /* Report a warning at line LINE of file FILE. */
1397 v_warning_with_file_and_line (file, line, s, ap)
1403 if (count_error (1))
1405 report_error_function (file);
1406 v_message_with_file_and_line (file, line, "warning", s, ap);
1411 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1423 file = va_arg (ap, char *);
1424 line = va_arg (ap, int);
1425 s = va_arg (ap, char *);
1428 v_warning_with_file_and_line (file, line, s, ap);
1432 /* Report a warning at the declaration DECL.
1433 S is a format string which uses %s to substitute the declaration
1434 name; subsequent substitutions are a la printf. */
1437 v_warning_with_decl (decl, s, ap)
1442 if (count_error (1))
1444 report_error_function (DECL_SOURCE_FILE (decl));
1445 v_message_with_decl (decl, "warning", s, ap);
1450 warning_with_decl VPROTO((tree decl, char *s, ...))
1461 decl = va_arg (ap, tree);
1462 s = va_arg (ap, char *);
1465 v_warning_with_decl (decl, s, ap);
1469 /* Report a warning at the line number of the insn INSN.
1470 This is used only when INSN is an `asm' with operands,
1471 and each ASM_OPERANDS records its own source file and line. */
1474 v_warning_for_asm (insn, s, ap)
1479 if (count_error (1))
1484 file_and_line_for_asm (insn, &file, &line);
1485 report_error_function (file);
1486 v_message_with_file_and_line (file, line, "warning", s, ap);
1491 warning_for_asm VPROTO((rtx insn, char *s, ...))
1502 insn = va_arg (ap, rtx);
1503 s = va_arg (ap, char *);
1506 v_warning_for_asm (insn, s, ap);
1510 /* Report a warning at the current line number. */
1517 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1521 warning VPROTO((char *s, ...))
1531 s = va_arg (ap, char *);
1538 /* These functions issue either warnings or errors depending on
1539 -pedantic-errors. */
1546 if (flag_pedantic_errors)
1553 pedwarn VPROTO((char *s, ...))
1563 s = va_arg (ap, char *);
1571 v_pedwarn_with_decl (decl, s, ap)
1576 /* We don't want -pedantic-errors to cause the compilation to fail from
1577 "errors" in system header files. Sometimes fixincludes can't fix what's
1578 broken (eg: unsigned char bitfields - fixing it may change the alignment
1579 which will cause programs to mysteriously fail because the C library
1580 or kernel uses the original layout). There's no point in issuing a
1581 warning either, it's just unnecessary noise. */
1583 if (! DECL_IN_SYSTEM_HEADER (decl))
1585 if (flag_pedantic_errors)
1586 v_error_with_decl (decl, s, ap);
1588 v_warning_with_decl (decl, s, ap);
1593 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1604 decl = va_arg (ap, tree);
1605 s = va_arg (ap, char *);
1608 v_pedwarn_with_decl (decl, s, ap);
1613 v_pedwarn_with_file_and_line (file, line, s, ap)
1619 if (flag_pedantic_errors)
1620 v_error_with_file_and_line (file, line, s, ap);
1622 v_warning_with_file_and_line (file, line, s, ap);
1626 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1638 file = va_arg (ap, char *);
1639 line = va_arg (ap, int);
1640 s = va_arg (ap, char *);
1643 v_pedwarn_with_file_and_line (file, line, s, ap);
1647 /* Apologize for not implementing some feature. */
1656 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1658 fprintf (stderr, "%s: ", progname);
1659 vmessage ("sorry, not implemented", s, ap);
1660 fputc ('\n', stderr);
1664 sorry VPROTO((char *s, ...))
1674 s = va_arg (ap, char *);
1681 /* Apologize for not implementing some feature, then quit. */
1684 v_really_sorry (s, ap)
1690 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1692 fprintf (stderr, "%s: ", progname);
1693 vmessage ("sorry, not implemented", s, ap);
1694 fatal (" (fatal)\n");
1698 really_sorry VPROTO((char *s, ...))
1708 s = va_arg (ap, char *);
1711 v_really_sorry (s, ap);
1715 /* More 'friendly' abort that prints the line and file.
1716 config.h can #define abort fancy_abort if you like that sort of thing.
1718 I don't think this is actually a good idea.
1719 Other sorts of crashes will look a certain way.
1720 It is a good thing if crashes from calling abort look the same way.
1726 fatal ("internal gcc abort");
1729 /* This calls abort and is used to avoid problems when abort if a macro.
1730 It is used when we need to pass the address of abort. */
1738 /* When `malloc.c' is compiled with `rcheck' defined,
1739 it calls this function to report clobberage. */
1747 /* Same as `malloc' but report error if no memory available. */
1753 register char *value = (char *) malloc (size);
1755 fatal ("virtual memory exhausted");
1759 /* Same as `realloc' but report error if no memory available. */
1762 xrealloc (ptr, size)
1766 char *result = (char *) realloc (ptr, size);
1768 fatal ("virtual memory exhausted");
1772 /* Same as `strdup' but report error if no memory available. */
1778 register char *result = (char *) malloc (strlen (s) + 1);
1781 fatal ("virtual memory exhausted");
1786 /* Return the logarithm of X, base 2, considering X unsigned,
1787 if X is a power of 2. Otherwise, returns -1.
1789 This should be used via the `exact_log2' macro. */
1793 register unsigned HOST_WIDE_INT x;
1795 register int log = 0;
1796 /* Test for 0 or a power of 2. */
1797 if (x == 0 || x != (x & -x))
1799 while ((x >>= 1) != 0)
1804 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1805 If X is 0, return -1.
1807 This should be used via the floor_log2 macro. */
1811 register unsigned HOST_WIDE_INT x;
1813 register int log = -1;
1821 jmp_buf float_handler;
1823 /* Specify where to longjmp to when a floating arithmetic error happens.
1824 If HANDLER is 0, it means don't handle the errors any more. */
1827 set_float_handler (handler)
1830 float_handled = (handler != 0);
1832 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1835 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1836 error happens, pushing the previous specification into OLD_HANDLER.
1837 Return an indication of whether there was a previous handler in effect. */
1840 push_float_handler (handler, old_handler)
1841 jmp_buf handler, old_handler;
1843 int was_handled = float_handled;
1847 bcopy ((char *) float_handler, (char *) old_handler,
1848 sizeof (float_handler));
1850 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1854 /* Restore the previous specification of whether and where to longjmp to
1855 when a floating arithmetic error happens. */
1858 pop_float_handler (handled, handler)
1862 float_handled = handled;
1864 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1867 /* Signals actually come here. */
1870 float_signal (signo)
1871 /* If this is missing, some compilers complain. */
1874 if (float_handled == 0)
1876 #if defined (USG) || defined (hpux)
1877 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1880 signal (SIGFPE, float_signal);
1881 longjmp (float_handler, 1);
1884 /* Handler for SIGPIPE. */
1888 /* If this is missing, some compilers complain. */
1891 fatal ("output pipe has been closed");
1894 /* Strip off a legitimate source ending from the input string NAME of
1895 length LEN. Rather than having to know the names used by all of
1896 our front ends, we strip off an ending of a period followed by one,
1897 two, or three characters. */
1900 strip_off_ending (name, len)
1904 if (len > 2 && name[len - 2] == '.')
1905 name[len - 2] = '\0';
1906 else if (len > 3 && name[len - 3] == '.')
1907 name[len - 3] = '\0';
1908 else if (len > 4 && name[len - 4] == '.')
1909 name[len - 4] = '\0';
1912 /* Output a quoted string. */
1914 output_quoted_string (asm_file, string)
1920 putc ('\"', asm_file);
1921 while ((c = *string++) != 0)
1923 if (c == '\"' || c == '\\')
1924 putc ('\\', asm_file);
1927 putc ('\"', asm_file);
1930 /* Output a file name in the form wanted by System V. */
1933 output_file_directive (asm_file, input_name)
1937 int len = strlen (input_name);
1938 char *na = input_name + len;
1940 /* NA gets INPUT_NAME sans directory names. */
1941 while (na > input_name)
1948 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1949 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1951 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1952 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1954 fprintf (asm_file, "\t.file\t");
1955 output_quoted_string (asm_file, na);
1956 fputc ('\n', asm_file);
1961 /* Routine to build language identifier for object file. */
1963 output_lang_identify (asm_out_file)
1966 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1967 char *s = (char *) alloca (len);
1968 sprintf (s, "__gnu_compiled_%s", lang_identify ());
1969 ASM_OUTPUT_LABEL (asm_out_file, s);
1972 /* Routine to open a dump file. */
1974 open_dump_file (base_name, suffix)
1979 char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1);
1981 strcpy (dumpname, base_name);
1982 strcat (dumpname, suffix);
1983 f = fopen (dumpname, "w");
1985 pfatal_with_name (dumpname);
1989 /* Compile an entire file of output from cpp, named NAME.
1990 Write a file of assembly output and various debugging dumps. */
1999 int name_specified = name != 0;
2001 if (dump_base_name == 0)
2002 dump_base_name = name ? name : "gccdump";
2006 integration_time = 0;
2014 local_alloc_time = 0;
2015 global_alloc_time = 0;
2018 shorten_branch_time = 0;
2024 /* Open input file. */
2026 if (name == 0 || !strcmp (name, "-"))
2032 finput = fopen (name, "r");
2034 pfatal_with_name (name);
2036 #ifdef IO_BUFFER_SIZE
2037 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2040 /* Initialize data in various passes. */
2045 /* Some of these really don't need to be called when generating bytecode,
2046 but the options would have to be parsed first to know that. -bson */
2048 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2049 || debug_info_level == DINFO_LEVEL_VERBOSE);
2051 init_decl_processing ();
2059 if (flag_caller_saves)
2060 init_caller_save ();
2062 /* If auxiliary info generation is desired, open the output file.
2063 This goes in the same directory as the source file--unlike
2064 all the other output files. */
2065 if (flag_gen_aux_info)
2067 aux_info_file = fopen (aux_info_file_name, "w");
2068 if (aux_info_file == 0)
2069 pfatal_with_name (aux_info_file_name);
2072 /* If rtl dump desired, open the output file. */
2074 rtl_dump_file = open_dump_file (dump_base_name, ".rtl");
2076 /* If jump_opt dump desired, open the output file. */
2078 jump_opt_dump_file = open_dump_file (dump_base_name, ".jump");
2080 /* If cse dump desired, open the output file. */
2082 cse_dump_file = open_dump_file (dump_base_name, ".cse");
2084 /* If loop dump desired, open the output file. */
2086 loop_dump_file = open_dump_file (dump_base_name, ".loop");
2088 /* If cse2 dump desired, open the output file. */
2090 cse2_dump_file = open_dump_file (dump_base_name, ".cse2");
2092 /* If flow dump desired, open the output file. */
2094 flow_dump_file = open_dump_file (dump_base_name, ".flow");
2096 /* If combine dump desired, open the output file. */
2098 combine_dump_file = open_dump_file (dump_base_name, ".combine");
2100 /* If scheduling dump desired, open the output file. */
2102 sched_dump_file = open_dump_file (dump_base_name, ".sched");
2104 /* If local_reg dump desired, open the output file. */
2106 local_reg_dump_file = open_dump_file (dump_base_name, ".lreg");
2108 /* If global_reg dump desired, open the output file. */
2109 if (global_reg_dump)
2110 global_reg_dump_file = open_dump_file (dump_base_name, ".greg");
2112 /* If 2nd scheduling dump desired, open the output file. */
2114 sched2_dump_file = open_dump_file (dump_base_name, ".sched2");
2116 /* If jump2_opt dump desired, open the output file. */
2118 jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2");
2120 /* If dbr_sched dump desired, open the output file. */
2122 dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr");
2126 /* If stack_reg dump desired, open the output file. */
2128 stack_reg_dump_file = open_dump_file (dump_base_name, ".stack");
2132 /* Open assembler code output file. */
2134 if (! name_specified && asm_file_name == 0)
2135 asm_out_file = stdout;
2138 int len = strlen (dump_base_name);
2139 register char *dumpname = (char *) xmalloc (len + 6);
2140 strcpy (dumpname, dump_base_name);
2141 strip_off_ending (dumpname, len);
2142 strcat (dumpname, ".s");
2143 if (asm_file_name == 0)
2145 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2146 strcpy (asm_file_name, dumpname);
2148 if (!strcmp (asm_file_name, "-"))
2149 asm_out_file = stdout;
2151 asm_out_file = fopen (asm_file_name, "w");
2152 if (asm_out_file == 0)
2153 pfatal_with_name (asm_file_name);
2156 #ifdef IO_BUFFER_SIZE
2157 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2158 _IOFBF, IO_BUFFER_SIZE);
2161 input_filename = name;
2163 /* Put an entry on the input file stack for the main input file. */
2165 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2166 input_file_stack->next = 0;
2167 input_file_stack->name = input_filename;
2169 /* Perform language-specific initialization.
2170 This may set main_input_filename. */
2173 /* If the input doesn't start with a #line, use the input name
2174 as the official input file name. */
2175 if (main_input_filename == 0)
2176 main_input_filename = name;
2178 if (!output_bytecode)
2180 ASM_FILE_START (asm_out_file);
2183 /* Output something to inform GDB that this compilation was by GCC. Also
2184 serves to tell GDB file consists of bytecodes. */
2185 if (output_bytecode)
2186 fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
2189 #ifndef ASM_IDENTIFY_GCC
2190 fprintf (asm_out_file, "gcc2_compiled.:\n");
2192 ASM_IDENTIFY_GCC (asm_out_file);
2196 /* Output something to identify which front-end produced this file. */
2197 #ifdef ASM_IDENTIFY_LANGUAGE
2198 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2201 #ifndef ASM_OUTPUT_SECTION_NAME
2202 if (flag_function_sections)
2204 warning ("-ffunction-sections not supported for this target.");
2205 flag_function_sections = 0;
2209 if (flag_function_sections
2210 && (profile_flag || profile_block_flag))
2212 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2213 flag_function_sections = 0;
2216 if (flag_function_sections && write_symbols != NO_DEBUG)
2217 warning ("-ffunction-sections may affect debugging on some targets.");
2219 if (output_bytecode)
2221 if (profile_flag || profile_block_flag)
2222 error ("profiling not supported in bytecode compilation");
2226 /* ??? Note: There used to be a conditional here
2227 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2228 This was to guarantee separation between gcc_compiled. and
2229 the first function, for the sake of dbx on Suns.
2230 However, having the extra zero here confused the Emacs
2231 code for unexec, and might confuse other programs too.
2232 Therefore, I took out that change.
2233 In future versions we should find another way to solve
2234 that dbx problem. -- rms, 23 May 93. */
2236 /* Don't let the first function fall at the same address
2237 as gcc_compiled., if profiling. */
2238 if (profile_flag || profile_block_flag)
2239 assemble_zeros (UNITS_PER_WORD);
2242 /* If dbx symbol table desired, initialize writing it
2243 and output the predefined types. */
2244 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2245 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2246 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2249 #ifdef SDB_DEBUGGING_INFO
2250 if (write_symbols == SDB_DEBUG)
2251 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2254 #ifdef DWARF_DEBUGGING_INFO
2255 if (write_symbols == DWARF_DEBUG)
2256 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2259 /* Initialize yet another pass. */
2261 if (!output_bytecode)
2262 init_final (main_input_filename);
2264 start_time = get_run_time ();
2266 /* Call the parser, which parses the entire file
2267 (calling rest_of_compilation for each function). */
2269 if (yyparse () != 0)
2271 if (errorcount == 0)
2272 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2274 /* In case there were missing closebraces,
2275 get us back to the global binding level. */
2276 while (! global_bindings_p ())
2280 /* Compilation is now finished except for writing
2281 what's left of the symbol table output. */
2283 parse_time += get_run_time () - start_time;
2285 parse_time -= integration_time;
2286 parse_time -= varconst_time;
2288 globals = getdecls ();
2290 /* Really define vars that have had only a tentative definition.
2291 Really output inline functions that must actually be callable
2292 and have not been output so far. */
2295 int len = list_length (globals);
2296 tree *vec = (tree *) alloca (sizeof (tree) * len);
2301 /* Process the decls in reverse order--earliest first.
2302 Put them into VEC from back to front, then take out from front. */
2304 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2305 vec[len - i - 1] = decl;
2307 for (i = 0; i < len; i++)
2311 /* We're not deferring this any longer. */
2312 DECL_DEFER_OUTPUT (decl) = 0;
2314 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2315 && incomplete_decl_finalize_hook != 0)
2316 (*incomplete_decl_finalize_hook) (decl);
2319 /* Now emit any global variables or functions that we have been putting
2320 off. We need to loop in case one of the things emitted here
2321 references another one which comes earlier in the list. */
2325 for (i = 0; i < len; i++)
2329 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2332 /* Don't write out static consts, unless we still need them.
2334 We also keep static consts if not optimizing (for debugging).
2335 ??? They might be better written into the debug information.
2336 This is possible when using DWARF.
2338 A language processor that wants static constants to be always
2339 written out (even if it is not used) is responsible for
2340 calling rest_of_decl_compilation itself. E.g. the C front-end
2341 calls rest_of_decl_compilation from finish_decl.
2342 One motivation for this is that is conventional in some
2343 environments to write things like:
2344 static const char rcsid[] = "... version string ...";
2345 intending to force the string to be in the executable.
2347 A language processor that would prefer to have unneeded
2348 static constants "optimized away" would just defer writing
2349 them out until here. E.g. C++ does this, because static
2350 constants are often defined in header files.
2352 ??? A tempting alternative (for both C and C++) would be
2353 to force a constant to be written if and only if it is
2354 defined in a main file, as opposed to an include file. */
2356 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2357 && (! TREE_READONLY (decl)
2358 || TREE_PUBLIC (decl)
2360 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2363 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2366 if (TREE_CODE (decl) == FUNCTION_DECL
2367 && DECL_INITIAL (decl) != 0
2368 && DECL_SAVED_INSNS (decl) != 0
2369 && (flag_keep_inline_functions
2370 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2373 temporary_allocation ();
2374 output_inline_function (decl);
2375 permanent_allocation (1);
2380 for (i = 0; i < len; i++)
2384 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2385 && ! TREE_ASM_WRITTEN (decl))
2386 /* Cancel the RTL for this decl so that, if debugging info
2387 output for global variables is still to come,
2388 this one will be omitted. */
2389 DECL_RTL (decl) = NULL;
2391 /* Warn about any function
2392 declared static but not defined.
2393 We don't warn about variables,
2394 because many programs have static variables
2395 that exist only to get some text into the object file. */
2396 if (TREE_CODE (decl) == FUNCTION_DECL
2398 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2399 && DECL_INITIAL (decl) == 0
2400 && DECL_EXTERNAL (decl)
2401 && ! TREE_PUBLIC (decl))
2403 pedwarn_with_decl (decl,
2404 "`%s' declared `static' but never defined");
2405 /* This symbol is effectively an "extern" declaration now. */
2406 TREE_PUBLIC (decl) = 1;
2407 assemble_external (decl);
2410 /* Warn about static fns or vars defined but not used,
2411 but not about inline functions or static consts
2412 since defining those in header files is normal practice. */
2414 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2415 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2416 && ! DECL_IN_SYSTEM_HEADER (decl)
2417 && ! DECL_EXTERNAL (decl)
2418 && ! TREE_PUBLIC (decl)
2419 && ! TREE_USED (decl)
2420 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2421 /* The TREE_USED bit for file-scope decls
2422 is kept in the identifier, to handle multiple
2423 external decls in different scopes. */
2424 && ! TREE_USED (DECL_NAME (decl)))
2425 warning_with_decl (decl, "`%s' defined but not used");
2427 #ifdef SDB_DEBUGGING_INFO
2428 /* The COFF linker can move initialized global vars to the end.
2429 And that can screw up the symbol ordering.
2430 By putting the symbols in that order to begin with,
2431 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2432 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2433 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2434 && ! DECL_EXTERNAL (decl)
2435 && DECL_RTL (decl) != 0)
2436 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2438 /* Output COFF information for non-global
2439 file-scope initialized variables. */
2440 if (write_symbols == SDB_DEBUG
2441 && TREE_CODE (decl) == VAR_DECL
2442 && DECL_INITIAL (decl)
2443 && ! DECL_EXTERNAL (decl)
2444 && DECL_RTL (decl) != 0
2445 && GET_CODE (DECL_RTL (decl)) == MEM)
2446 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2447 #endif /* SDB_DEBUGGING_INFO */
2448 #ifdef DWARF_DEBUGGING_INFO
2449 /* Output DWARF information for file-scope tentative data object
2450 declarations, file-scope (extern) function declarations (which
2451 had no corresponding body) and file-scope tagged type declarations
2452 and definitions which have not yet been forced out. */
2454 if (write_symbols == DWARF_DEBUG
2455 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2456 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2461 /* Write out any pending weak symbol declarations. */
2465 /* Do dbx symbols */
2466 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2467 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2468 TIMEVAR (symout_time,
2470 dbxout_finish (asm_out_file, main_input_filename);
2474 #ifdef DWARF_DEBUGGING_INFO
2475 if (write_symbols == DWARF_DEBUG)
2476 TIMEVAR (symout_time,
2482 /* Output some stuff at end of file if nec. */
2484 if (!output_bytecode)
2486 end_final (main_input_filename);
2489 ASM_FILE_END (asm_out_file);
2493 /* Language-specific end of compilation actions. */
2497 if (output_bytecode)
2498 bc_write_file (asm_out_file);
2500 /* Close the dump files. */
2502 if (flag_gen_aux_info)
2504 fclose (aux_info_file);
2506 unlink (aux_info_file_name);
2510 fclose (rtl_dump_file);
2513 fclose (jump_opt_dump_file);
2516 fclose (cse_dump_file);
2519 fclose (loop_dump_file);
2522 fclose (cse2_dump_file);
2525 fclose (flow_dump_file);
2529 dump_combine_total_stats (combine_dump_file);
2530 fclose (combine_dump_file);
2534 fclose (sched_dump_file);
2537 fclose (local_reg_dump_file);
2539 if (global_reg_dump)
2540 fclose (global_reg_dump_file);
2543 fclose (sched2_dump_file);
2546 fclose (jump2_opt_dump_file);
2549 fclose (dbr_sched_dump_file);
2553 fclose (stack_reg_dump_file);
2556 /* Close non-debugging input and output files. Take special care to note
2557 whether fclose returns an error, since the pages might still be on the
2558 buffer chain while the file is open. */
2561 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2562 fatal_io_error (asm_file_name);
2564 /* Print the times. */
2568 fprintf (stderr,"\n");
2569 print_time ("parse", parse_time);
2571 if (!output_bytecode)
2573 print_time ("integration", integration_time);
2574 print_time ("jump", jump_time);
2575 print_time ("cse", cse_time);
2576 print_time ("loop", loop_time);
2577 print_time ("cse2", cse2_time);
2578 print_time ("flow", flow_time);
2579 print_time ("combine", combine_time);
2580 print_time ("sched", sched_time);
2581 print_time ("local-alloc", local_alloc_time);
2582 print_time ("global-alloc", global_alloc_time);
2583 print_time ("sched2", sched2_time);
2584 print_time ("dbranch", dbr_sched_time);
2585 print_time ("shorten-branch", shorten_branch_time);
2586 print_time ("stack-reg", stack_reg_time);
2587 print_time ("final", final_time);
2588 print_time ("varconst", varconst_time);
2589 print_time ("symout", symout_time);
2590 print_time ("dump", dump_time);
2595 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2596 and TYPE_DECL nodes.
2598 This does nothing for local (non-static) variables.
2599 Otherwise, it sets up the RTL and outputs any assembler code
2600 (label definition, storage allocation and initialization).
2602 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2603 the assembler symbol name to be used. TOP_LEVEL is nonzero
2604 if this declaration is not within a function. */
2607 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2613 /* Declarations of variables, and of functions defined elsewhere. */
2615 /* The most obvious approach, to put an #ifndef around where
2616 this macro is used, doesn't work since it's inside a macro call. */
2617 #ifndef ASM_FINISH_DECLARE_OBJECT
2618 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2621 /* Forward declarations for nested functions are not "external",
2622 but we need to treat them as if they were. */
2623 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2624 || TREE_CODE (decl) == FUNCTION_DECL)
2625 TIMEVAR (varconst_time,
2627 make_decl_rtl (decl, asmspec, top_level);
2628 /* Initialized extern variable exists to be replaced
2629 with its value, or represents something that will be
2630 output in another file. */
2631 if (! (TREE_CODE (decl) == VAR_DECL
2632 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2633 && DECL_INITIAL (decl) != 0
2634 && DECL_INITIAL (decl) != error_mark_node))
2635 /* Don't output anything
2636 when a tentative file-scope definition is seen.
2637 But at end of compilation, do output code for them. */
2638 if (! (! at_end && top_level
2639 && (DECL_INITIAL (decl) == 0
2640 || DECL_INITIAL (decl) == error_mark_node)))
2641 assemble_variable (decl, top_level, at_end, 0);
2642 if (decl == last_assemble_variable_decl)
2644 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2648 else if (DECL_REGISTER (decl) && asmspec != 0)
2650 if (decode_reg_name (asmspec) >= 0)
2652 DECL_RTL (decl) = 0;
2653 make_decl_rtl (decl, asmspec, top_level);
2656 error ("invalid register name `%s' for register variable", asmspec);
2658 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2659 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2660 && TREE_CODE (decl) == TYPE_DECL)
2661 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2663 #ifdef SDB_DEBUGGING_INFO
2664 else if (write_symbols == SDB_DEBUG && top_level
2665 && TREE_CODE (decl) == TYPE_DECL)
2666 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2670 /* Called after finishing a record, union or enumeral type. */
2673 rest_of_type_compilation (type, toplev)
2677 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2678 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2679 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2681 #ifdef SDB_DEBUGGING_INFO
2682 if (write_symbols == SDB_DEBUG)
2683 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2687 /* This is called from finish_function (within yyparse)
2688 after each top-level definition is parsed.
2689 It is supposed to compile that function or variable
2690 and output the assembler code for it.
2691 After we return, the tree storage is freed. */
2694 rest_of_compilation (decl)
2698 int start_time = get_run_time ();
2700 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2701 to be restored after we finish compiling the function
2702 (for use when compiling inline calls to this function). */
2703 tree saved_block_tree = 0;
2704 /* Likewise, for DECL_ARGUMENTS. */
2705 tree saved_arguments = 0;
2708 if (output_bytecode)
2711 /* If we are reconsidering an inline function
2712 at the end of compilation, skip the stuff for making it inline. */
2714 if (DECL_SAVED_INSNS (decl) == 0)
2719 /* If requested, consider whether to make this function inline. */
2720 if (DECL_INLINE (decl) || flag_inline_functions)
2721 TIMEVAR (integration_time,
2723 lose = function_cannot_inline_p (decl);
2724 if (lose || ! optimize)
2726 if (warn_inline && DECL_INLINE (decl))
2727 warning_with_decl (decl, lose);
2728 DECL_ABSTRACT_ORIGIN (decl) = 0;
2729 /* Don't really compile an extern inline function.
2730 If we can't make it inline, pretend
2731 it was only declared. */
2732 if (DECL_EXTERNAL (decl))
2734 DECL_INITIAL (decl) = 0;
2735 goto exit_rest_of_compilation;
2739 /* ??? Note that this has the effect of making it look
2740 like "inline" was specified for a function if we choose
2741 to inline it. This isn't quite right, but it's
2742 probably not worth the trouble to fix. */
2743 inlineable = DECL_INLINE (decl) = 1;
2746 insns = get_insns ();
2748 /* Dump the rtl code if we are dumping rtl. */
2753 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2754 IDENTIFIER_POINTER (DECL_NAME (decl)));
2755 if (DECL_SAVED_INSNS (decl))
2756 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2757 print_rtl (rtl_dump_file, insns);
2758 fflush (rtl_dump_file);
2761 /* If function is inline, and we don't yet know whether to
2762 compile it by itself, defer decision till end of compilation.
2763 finish_compilation will call rest_of_compilation again
2764 for those functions that need to be output. Also defer those
2765 functions that we are supposed to defer. We cannot defer
2766 functions containing nested functions since the nested function
2767 data is in our non-saved obstack. */
2769 if (! current_function_contains_functions
2770 && (DECL_DEFER_OUTPUT (decl)
2771 || (DECL_INLINE (decl)
2772 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2773 && ! flag_keep_inline_functions)
2774 || DECL_EXTERNAL (decl)))))
2776 DECL_DEFER_OUTPUT (decl) = 1;
2778 /* If -Wreturn-type, we have to do a bit of compilation. */
2779 if (! warn_return_type)
2781 #ifdef DWARF_DEBUGGING_INFO
2782 /* Generate the DWARF info for the "abstract" instance
2783 of a function which we may later generate inlined and/or
2784 out-of-line instances of. */
2785 if (write_symbols == DWARF_DEBUG)
2787 set_decl_abstract_flags (decl, 1);
2788 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2789 set_decl_abstract_flags (decl, 0);
2792 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2793 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
2794 goto exit_rest_of_compilation;
2798 /* If we have to compile the function now, save its rtl and subdecls
2799 so that its compilation will not affect what others get. */
2800 if (inlineable || DECL_DEFER_OUTPUT (decl))
2802 #ifdef DWARF_DEBUGGING_INFO
2803 /* Generate the DWARF info for the "abstract" instance of
2804 a function which we will generate an out-of-line instance
2805 of almost immediately (and which we may also later generate
2806 various inlined instances of). */
2807 if (write_symbols == DWARF_DEBUG)
2809 set_decl_abstract_flags (decl, 1);
2810 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2811 set_decl_abstract_flags (decl, 0);
2814 saved_block_tree = DECL_INITIAL (decl);
2815 saved_arguments = DECL_ARGUMENTS (decl);
2816 TIMEVAR (integration_time, save_for_inline_copying (decl));
2817 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
2820 /* If specified extern inline but we aren't inlining it, we are
2822 if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
2823 goto exit_rest_of_compilation;
2826 if (! DECL_DEFER_OUTPUT (decl))
2827 TREE_ASM_WRITTEN (decl) = 1;
2829 /* Now that integrate will no longer see our rtl, we need not distinguish
2830 between the return value of this function and the return value of called
2832 rtx_equal_function_value_matters = 0;
2834 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2835 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2837 goto exit_rest_of_compilation;
2840 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2841 Note that that may have been done above, in save_for_inline_copying.
2842 The call to resume_temporary_allocation near the end of this function
2843 goes back to the usual state of affairs. */
2845 rtl_in_current_obstack ();
2848 /* If we are doing position-independent code generation, now
2849 is the time to output special prologues and epilogues.
2850 We do not want to do this earlier, because it just clutters
2851 up inline functions with meaningless insns. */
2856 insns = get_insns ();
2858 /* Copy any shared structure that should not be shared. */
2860 unshare_all_rtl (insns);
2862 /* Instantiate all virtual registers. */
2864 instantiate_virtual_regs (current_function_decl, get_insns ());
2866 /* See if we have allocated stack slots that are not directly addressable.
2867 If so, scan all the insns and create explicit address computation
2868 for all references to such slots. */
2869 /* fixup_stack_slots (); */
2871 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2872 are initialized and to compute whether control can drop off the end
2874 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2875 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2877 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2878 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2879 goto exit_rest_of_compilation;
2881 /* Dump rtl code after jump, if we are doing that. */
2886 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2887 IDENTIFIER_POINTER (DECL_NAME (decl)));
2888 print_rtl (jump_opt_dump_file, insns);
2889 fflush (jump_opt_dump_file);
2892 /* Perform common subexpression elimination.
2893 Nonzero value from `cse_main' means that jumps were simplified
2894 and some code may now be unreachable, so do
2895 jump optimization again. */
2900 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2901 IDENTIFIER_POINTER (DECL_NAME (decl)));
2906 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2908 if (flag_thread_jumps)
2909 /* Hacks by tiemann & kenner. */
2910 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
2912 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2914 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2916 if (tem || optimize > 1)
2917 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2920 /* Dump rtl code after cse, if we are doing that. */
2925 print_rtl (cse_dump_file, insns);
2926 fflush (cse_dump_file);
2932 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2933 IDENTIFIER_POINTER (DECL_NAME (decl)));
2936 /* Move constant computations out of loops. */
2942 loop_optimize (insns, loop_dump_file);
2946 /* Dump rtl code after loop opt, if we are doing that. */
2951 print_rtl (loop_dump_file, insns);
2952 fflush (loop_dump_file);
2958 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2959 IDENTIFIER_POINTER (DECL_NAME (decl)));
2962 if (optimize > 0 && flag_rerun_cse_after_loop)
2964 /* Running another jump optimization pass before the second
2965 cse pass sometimes simplifies the RTL enough to allow
2966 the second CSE pass to do a better job. Jump_optimize can change
2967 max_reg_num so we must rerun reg_scan afterwards.
2968 ??? Rework to not call reg_scan so often. */
2969 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2970 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2972 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2973 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2974 1, cse2_dump_file));
2976 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2979 if (optimize > 0 && flag_thread_jumps)
2980 /* This pass of jump threading straightens out code
2981 that was kinked by loop optimization. */
2982 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2984 /* Dump rtl code after cse, if we are doing that. */
2989 print_rtl (cse2_dump_file, insns);
2990 fflush (cse2_dump_file);
2993 /* We are no longer anticipating cse in this function, at least. */
2995 cse_not_expected = 1;
2997 /* Now we choose between stupid (pcc-like) register allocation
2998 (if we got the -noreg switch and not -opt)
2999 and smart register allocation. */
3001 if (optimize > 0) /* Stupid allocation probably won't work */
3002 obey_regdecls = 0; /* if optimizations being done. */
3006 /* Print function header into flow dump now
3007 because doing the flow analysis makes some of the dump. */
3012 fprintf (flow_dump_file, "\n;; Function %s\n\n",
3013 IDENTIFIER_POINTER (DECL_NAME (decl)));
3020 regclass (insns, max_reg_num ());
3021 stupid_life_analysis (insns, max_reg_num (),
3027 /* Do control and data flow analysis,
3028 and write some of the results to dump file. */
3030 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
3032 if (warn_uninitialized)
3034 uninitialized_vars_warning (DECL_INITIAL (decl));
3035 setjmp_args_warning ();
3039 /* Dump rtl after flow analysis. */
3044 print_rtl (flow_dump_file, insns);
3045 fflush (flow_dump_file);
3048 /* If -opt, try combining insns through substitution. */
3051 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3053 /* Dump rtl code after insn combination. */
3058 fprintf (combine_dump_file, "\n;; Function %s\n\n",
3059 IDENTIFIER_POINTER (DECL_NAME (decl)));
3060 dump_combine_stats (combine_dump_file);
3061 print_rtl (combine_dump_file, insns);
3062 fflush (combine_dump_file);
3065 /* Print function header into sched dump now
3066 because doing the sched analysis makes some of the dump. */
3071 fprintf (sched_dump_file, "\n;; Function %s\n\n",
3072 IDENTIFIER_POINTER (DECL_NAME (decl)));
3075 if (optimize > 0 && flag_schedule_insns)
3077 /* Do control and data sched analysis,
3078 and write some of the results to dump file. */
3080 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
3083 /* Dump rtl after instruction scheduling. */
3088 print_rtl (sched_dump_file, insns);
3089 fflush (sched_dump_file);
3092 /* Unless we did stupid register allocation,
3093 allocate pseudo-regs that are used only within 1 basic block. */
3096 TIMEVAR (local_alloc_time,
3098 regclass (insns, max_reg_num ());
3102 /* Dump rtl code after allocating regs within basic blocks. */
3107 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
3108 IDENTIFIER_POINTER (DECL_NAME (decl)));
3109 dump_flow_info (local_reg_dump_file);
3110 dump_local_alloc (local_reg_dump_file);
3111 print_rtl (local_reg_dump_file, insns);
3112 fflush (local_reg_dump_file);
3115 if (global_reg_dump)
3117 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
3118 IDENTIFIER_POINTER (DECL_NAME (decl))));
3120 /* Save the last label number used so far, so reorg can tell
3121 when it's safe to kill spill regs. */
3122 max_label_num_after_reload = max_label_num ();
3124 /* Unless we did stupid register allocation,
3125 allocate remaining pseudo-regs, then do the reload pass
3126 fixing up any insns that are invalid. */
3128 TIMEVAR (global_alloc_time,
3131 failure = global_alloc (global_reg_dump_file);
3133 failure = reload (insns, 0, global_reg_dump_file);
3136 if (global_reg_dump)
3139 dump_global_regs (global_reg_dump_file);
3140 print_rtl (global_reg_dump_file, insns);
3141 fflush (global_reg_dump_file);
3145 goto exit_rest_of_compilation;
3147 reload_completed = 1;
3149 /* On some machines, the prologue and epilogue code, or parts thereof,
3150 can be represented as RTL. Doing so lets us schedule insns between
3151 it and the rest of the code and also allows delayed branch
3152 scheduling to operate in the epilogue. */
3154 thread_prologue_and_epilogue_insns (insns);
3156 if (optimize > 0 && flag_schedule_insns_after_reload)
3161 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
3162 IDENTIFIER_POINTER (DECL_NAME (decl)));
3165 /* Do control and data sched analysis again,
3166 and write some more of the results to dump file. */
3168 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
3170 /* Dump rtl after post-reorder instruction scheduling. */
3175 print_rtl (sched2_dump_file, insns);
3176 fflush (sched2_dump_file);
3180 #ifdef LEAF_REGISTERS
3182 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3186 /* One more attempt to remove jumps to .+1
3187 left by dead-store-elimination.
3188 Also do cross-jumping this time
3189 and delete no-op move insns. */
3193 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3196 /* Dump rtl code after jump, if we are doing that. */
3201 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
3202 IDENTIFIER_POINTER (DECL_NAME (decl)));
3203 print_rtl (jump2_opt_dump_file, insns);
3204 fflush (jump2_opt_dump_file);
3207 /* If a machine dependent reorganization is needed, call it. */
3208 #ifdef MACHINE_DEPENDENT_REORG
3209 MACHINE_DEPENDENT_REORG (insns);
3212 /* If a scheduling pass for delayed branches is to be done,
3213 call the scheduling code. */
3216 if (optimize > 0 && flag_delayed_branch)
3218 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3223 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
3224 IDENTIFIER_POINTER (DECL_NAME (decl)));
3225 print_rtl (dbr_sched_dump_file, insns);
3226 fflush (dbr_sched_dump_file);
3232 /* Shorten branches. */
3233 TIMEVAR (shorten_branch_time,
3235 shorten_branches (get_insns ());
3239 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3244 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
3245 IDENTIFIER_POINTER (DECL_NAME (decl)));
3246 print_rtl (stack_reg_dump_file, insns);
3247 fflush (stack_reg_dump_file);
3252 /* Now turn the rtl into assembler code. */
3254 TIMEVAR (final_time,
3259 /* Get the function's name, as described by its RTL.
3260 This may be different from the DECL_NAME name used
3261 in the source file. */
3263 x = DECL_RTL (decl);
3264 if (GET_CODE (x) != MEM)
3267 if (GET_CODE (x) != SYMBOL_REF)
3269 fnname = XSTR (x, 0);
3271 assemble_start_function (decl, fnname);
3272 final_start_function (insns, asm_out_file, optimize);
3273 final (insns, asm_out_file, optimize, 0);
3274 final_end_function (insns, asm_out_file, optimize);
3275 assemble_end_function (decl, fnname);
3276 fflush (asm_out_file);
3279 /* Write DBX symbols if requested */
3281 /* Note that for those inline functions where we don't initially
3282 know for certain that we will be generating an out-of-line copy,
3283 the first invocation of this routine (rest_of_compilation) will
3284 skip over this code by doing a `goto exit_rest_of_compilation;'.
3285 Later on, finish_compilation will call rest_of_compilation again
3286 for those inline functions that need to have out-of-line copies
3287 generated. During that call, we *will* be routed past here. */
3289 #ifdef DBX_DEBUGGING_INFO
3290 if (write_symbols == DBX_DEBUG)
3291 TIMEVAR (symout_time, dbxout_function (decl));
3294 #ifdef DWARF_DEBUGGING_INFO
3295 if (write_symbols == DWARF_DEBUG)
3296 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3299 exit_rest_of_compilation:
3301 /* In case the function was not output,
3302 don't leave any temporary anonymous types
3303 queued up for sdb output. */
3304 #ifdef SDB_DEBUGGING_INFO
3305 if (write_symbols == SDB_DEBUG)
3306 sdbout_types (NULL_TREE);
3309 /* Put back the tree of subblocks and list of arguments
3310 from before we copied them.
3311 Code generation and the output of debugging info may have modified
3312 the copy, but the original is unchanged. */
3314 if (saved_block_tree != 0)
3315 DECL_INITIAL (decl) = saved_block_tree;
3316 if (saved_arguments != 0)
3317 DECL_ARGUMENTS (decl) = saved_arguments;
3319 reload_completed = 0;
3321 /* Clear out the insn_length contents now that they are no longer valid. */
3322 init_insn_lengths ();
3324 /* Clear out the real_constant_chain before some of the rtx's
3325 it runs through become garbage. */
3327 clear_const_double_mem ();
3329 /* Cancel the effect of rtl_in_current_obstack. */
3331 resume_temporary_allocation ();
3333 /* Show no temporary slots allocated. */
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] != '/'
3365 #ifdef DIR_SEPARATOR
3366 && p[-1] != DIR_SEPARATOR
3373 /* Get rid of any avoidable limit on stack size. */
3377 /* Set the stack limit huge so that alloca does not fail. */
3378 getrlimit (RLIMIT_STACK, &rlim);
3379 rlim.rlim_cur = rlim.rlim_max;
3380 setrlimit (RLIMIT_STACK, &rlim);
3382 #endif /* RLIMIT_STACK */
3384 signal (SIGFPE, float_signal);
3387 signal (SIGPIPE, pipe_closed);
3390 decl_printable_name = decl_name;
3391 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3392 interim_eh_hook = interim_eh;
3394 /* Initialize whether `char' is signed. */
3395 flag_signed_char = DEFAULT_SIGNED_CHAR;
3396 #ifdef DEFAULT_SHORT_ENUMS
3397 /* Initialize how much space enums occupy, by default. */
3398 flag_short_enums = DEFAULT_SHORT_ENUMS;
3401 /* Scan to see what optimization level has been specified. That will
3402 determine the default value of many flags. */
3403 for (i = 1; i < argc; i++)
3405 if (!strcmp (argv[i], "-O"))
3409 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3411 /* Handle -O2, -O3, -O69, ... */
3412 char *p = &argv[i][2];
3416 if (! (c >= '0' && c <= '9'))
3419 optimize = atoi (&argv[i][2]);
3423 obey_regdecls = (optimize == 0);
3433 flag_thread_jumps = 1;
3435 flag_delayed_branch = 1;
3437 #ifdef CAN_DEBUG_WITHOUT_FP
3438 flag_omit_frame_pointer = 1;
3444 flag_cse_follow_jumps = 1;
3445 flag_cse_skip_blocks = 1;
3446 flag_expensive_optimizations = 1;
3447 flag_strength_reduce = 1;
3448 flag_rerun_cse_after_loop = 1;
3449 flag_caller_saves = 1;
3451 #ifdef INSN_SCHEDULING
3452 flag_schedule_insns = 1;
3453 flag_schedule_insns_after_reload = 1;
3459 flag_inline_functions = 1;
3462 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
3465 set_target_switch ("");
3467 #ifdef OPTIMIZATION_OPTIONS
3468 /* Allow default optimizations to be specified on a per-machine basis. */
3469 OPTIMIZATION_OPTIONS (optimize);
3472 /* Initialize register usage now so switches may override. */
3475 for (i = 1; i < argc; i++)
3478 /* If this is a language-specific option,
3479 decode it in a language-specific way. */
3480 for (j = 0; lang_options[j] != 0; j++)
3481 if (!strncmp (argv[i], lang_options[j],
3482 strlen (lang_options[j])))
3484 if (lang_options[j] != 0)
3485 /* If the option is valid for *some* language,
3486 treat it as valid even if this language doesn't understand it. */
3487 lang_decode_option (argv[i]);
3488 else if (argv[i][0] == '-' && argv[i][1] != 0)
3490 register char *str = argv[i] + 1;
3495 set_target_switch (&str[1]);
3496 else if (!strcmp (str, "dumpbase"))
3498 dump_base_name = argv[++i];
3500 else if (str[0] == 'd')
3502 register char *p = &str[1];
3510 global_reg_dump = 1;
3516 cse_dump = 1, cse2_dump = 1;
3534 global_reg_dump = 1;
3552 flag_print_asm_name = 1;
3574 rtl_dump_and_exit = 1;
3578 else if (str[0] == 'f')
3580 register char *p = &str[1];
3583 /* Some kind of -f option.
3584 P's value is the option sans `-f'.
3585 Search for it in the table of options. */
3588 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3591 if (!strcmp (p, f_options[j].string))
3593 *f_options[j].variable = f_options[j].on_value;
3594 /* A goto here would be cleaner,
3595 but breaks the vax pcc. */
3598 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3599 && ! strcmp (p+3, f_options[j].string))
3601 *f_options[j].variable = ! f_options[j].on_value;
3608 else if (!strncmp (p, "fixed-", 6))
3609 fix_register (&p[6], 1, 1);
3610 else if (!strncmp (p, "call-used-", 10))
3611 fix_register (&p[10], 0, 1);
3612 else if (!strncmp (p, "call-saved-", 11))
3613 fix_register (&p[11], 0, 0);
3615 error ("Invalid option `%s'", argv[i]);
3617 else if (str[0] == 'O')
3619 register char *p = str+1;
3620 while (*p && *p >= '0' && *p <= '9')
3625 error ("Invalid option `%s'", argv[i]);
3627 else if (!strcmp (str, "pedantic"))
3629 else if (!strcmp (str, "pedantic-errors"))
3630 flag_pedantic_errors = pedantic = 1;
3631 else if (!strcmp (str, "quiet"))
3633 else if (!strcmp (str, "version"))
3635 else if (!strcmp (str, "w"))
3636 inhibit_warnings = 1;
3637 else if (!strcmp (str, "W"))
3640 /* We save the value of warn_uninitialized, since if they put
3641 -Wuninitialized on the command line, we need to generate a
3642 warning about not using it without also specifying -O. */
3643 if (warn_uninitialized != 1)
3644 warn_uninitialized = 2;
3646 else if (str[0] == 'W')
3648 register char *p = &str[1];
3651 /* Some kind of -W option.
3652 P's value is the option sans `-W'.
3653 Search for it in the table of options. */
3656 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3659 if (!strcmp (p, W_options[j].string))
3661 *W_options[j].variable = W_options[j].on_value;
3662 /* A goto here would be cleaner,
3663 but breaks the vax pcc. */
3666 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3667 && ! strcmp (p+3, W_options[j].string))
3669 *W_options[j].variable = ! W_options[j].on_value;
3676 else if (!strncmp (p, "id-clash-", 9))
3682 if (*endp >= '0' && *endp <= '9')
3686 error ("Invalid option `%s'", argv[i]);
3691 id_clash_len = atoi (str + 10);
3694 else if (!strncmp (p, "larger-than-", 12))
3696 char *endp = p + 12;
3700 if (*endp >= '0' && *endp <= '9')
3704 error ("Invalid option `%s'", argv[i]);
3705 goto larger_than_lose;
3708 warn_larger_than = 1;
3709 larger_than_size = atoi (str + 13);
3713 error ("Invalid option `%s'", argv[i]);
3715 else if (!strcmp (str, "p"))
3719 else if (!strcmp (str, "a"))
3721 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3722 warning ("`-a' option (basic block profile) not supported");
3724 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
3727 else if (!strcmp (str, "ax"))
3729 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3730 warning ("`-ax' option (jump profiling) not supported");
3732 profile_block_flag = (!profile_block_flag
3733 || profile_block_flag == 2) ? 2 : 3;
3736 else if (str[0] == 'g')
3743 while (*p && (*p < '0' || *p > '9'))
3747 while (*q && (*q >= '0' && *q <= '9'))
3752 level = 2; /* default debugging info level */
3753 if (*q || level > 3)
3755 warning ("invalid debug level specification in option: `-%s'",
3757 warning ("no debugging information will be generated");
3761 /* If more than one debugging type is supported,
3762 you must define PREFERRED_DEBUGGING_TYPE
3763 to choose a format in a system-dependent way. */
3764 /* This is one long line cause VAXC can't handle a \-newline. */
3765 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3766 #ifdef PREFERRED_DEBUGGING_TYPE
3767 if (!strncmp (str, "ggdb", len))
3768 write_symbols = PREFERRED_DEBUGGING_TYPE;
3769 #else /* no PREFERRED_DEBUGGING_TYPE */
3770 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3771 #endif /* no PREFERRED_DEBUGGING_TYPE */
3772 #endif /* More than one debugger format enabled. */
3773 #ifdef DBX_DEBUGGING_INFO
3774 if (write_symbols != NO_DEBUG)
3776 else if (!strncmp (str, "ggdb", len))
3777 write_symbols = DBX_DEBUG;
3778 else if (!strncmp (str, "gstabs", len))
3779 write_symbols = DBX_DEBUG;
3780 else if (!strncmp (str, "gstabs+", len))
3781 write_symbols = DBX_DEBUG;
3783 /* Always enable extensions for -ggdb or -gstabs+,
3784 always disable for -gstabs.
3785 For plain -g, use system-specific default. */
3786 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3788 use_gnu_debug_info_extensions = 1;
3789 else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
3791 use_gnu_debug_info_extensions = 1;
3792 else if (write_symbols == DBX_DEBUG
3793 && !strncmp (str, "gstabs", len) && len >= 2)
3794 use_gnu_debug_info_extensions = 0;
3796 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3797 #endif /* DBX_DEBUGGING_INFO */
3798 #ifdef DWARF_DEBUGGING_INFO
3799 if (write_symbols != NO_DEBUG)
3801 else if (!strncmp (str, "g", len))
3802 write_symbols = DWARF_DEBUG;
3803 else if (!strncmp (str, "ggdb", len))
3804 write_symbols = DWARF_DEBUG;
3805 else if (!strncmp (str, "gdwarf", len))
3806 write_symbols = DWARF_DEBUG;
3808 /* Always enable extensions for -ggdb or -gdwarf+,
3809 always disable for -gdwarf.
3810 For plain -g, use system-specific default. */
3811 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3813 use_gnu_debug_info_extensions = 1;
3814 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3815 use_gnu_debug_info_extensions = 1;
3816 else if (write_symbols == DWARF_DEBUG
3817 && !strncmp (str, "gdwarf", len) && len >= 2)
3818 use_gnu_debug_info_extensions = 0;
3820 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3822 #ifdef SDB_DEBUGGING_INFO
3823 if (write_symbols != NO_DEBUG)
3825 else if (!strncmp (str, "g", len))
3826 write_symbols = SDB_DEBUG;
3827 else if (!strncmp (str, "gdb", len))
3828 write_symbols = SDB_DEBUG;
3829 else if (!strncmp (str, "gcoff", len))
3830 write_symbols = SDB_DEBUG;
3831 #endif /* SDB_DEBUGGING_INFO */
3832 #ifdef XCOFF_DEBUGGING_INFO
3833 if (write_symbols != NO_DEBUG)
3835 else if (!strncmp (str, "g", len))
3836 write_symbols = XCOFF_DEBUG;
3837 else if (!strncmp (str, "ggdb", len))
3838 write_symbols = XCOFF_DEBUG;
3839 else if (!strncmp (str, "gxcoff", len))
3840 write_symbols = XCOFF_DEBUG;
3842 /* Always enable extensions for -ggdb or -gxcoff+,
3843 always disable for -gxcoff.
3844 For plain -g, use system-specific default. */
3845 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3847 use_gnu_debug_info_extensions = 1;
3848 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3849 use_gnu_debug_info_extensions = 1;
3850 else if (write_symbols == XCOFF_DEBUG
3851 && !strncmp (str, "gxcoff", len) && len >= 2)
3852 use_gnu_debug_info_extensions = 0;
3854 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3856 if (write_symbols == NO_DEBUG)
3857 warning ("`-%s' not supported by this configuration of GCC",
3859 else if (level == 0)
3860 write_symbols = NO_DEBUG;
3862 debug_info_level = (enum debug_info_level) level;
3864 else if (!strcmp (str, "o"))
3866 asm_file_name = argv[++i];
3868 else if (str[0] == 'G')
3870 g_switch_set = TRUE;
3871 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3873 else if (!strncmp (str, "aux-info", 8))
3875 flag_gen_aux_info = 1;
3876 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3879 error ("Invalid option `%s'", argv[i]);
3881 else if (argv[i][0] == '+')
3882 error ("Invalid option `%s'", argv[i]);
3887 /* Initialize for bytecode output. A good idea to do this as soon as
3888 possible after the "-f" options have been parsed. */
3889 if (output_bytecode)
3891 #ifndef TARGET_SUPPORTS_BYTECODE
3892 /* Just die with a fatal error if not supported */
3893 fatal ("-fbytecode not supporter for this target");
3901 /* Inlining does not work if not optimizing,
3902 so force it not to be done. */
3906 /* The c_decode_option and lang_decode_option functions set
3907 this to `2' if -Wall is used, so we can avoid giving out
3908 lots of errors for people who don't realize what -Wall does. */
3909 if (warn_uninitialized == 1)
3910 warning ("-Wuninitialized is not supported without -O");
3913 #if defined(DWARF_DEBUGGING_INFO)
3914 if (write_symbols == DWARF_DEBUG
3915 && strcmp (language_string, "GNU C++") == 0)
3917 warning ("-g option not supported for C++ on systems using the DWARF debugging format");
3918 write_symbols = NO_DEBUG;
3920 #endif /* defined(DWARF_DEBUGGING_INFO) */
3922 #ifdef OVERRIDE_OPTIONS
3923 /* Some machines may reject certain combinations of options. */
3927 if (profile_block_flag == 3)
3929 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
3930 profile_block_flag = 2;
3933 /* Unrolling all loops implies that standard loop unrolling must also
3935 if (flag_unroll_all_loops)
3936 flag_unroll_loops = 1;
3937 /* Loop unrolling requires that strength_reduction be on also. Silently
3938 turn on strength reduction here if it isn't already on. Also, the loop
3939 unrolling code assumes that cse will be run after loop, so that must
3940 be turned on also. */
3941 if (flag_unroll_loops)
3943 flag_strength_reduce = 1;
3944 flag_rerun_cse_after_loop = 1;
3947 /* Warn about options that are not supported on this machine. */
3948 #ifndef INSN_SCHEDULING
3949 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3950 warning ("instruction scheduling not supported on this target machine");
3953 if (flag_delayed_branch)
3954 warning ("this target machine does not have delayed branches");
3957 /* If we are in verbose mode, write out the version and maybe all the
3958 option flags in use. */
3961 fprintf (stderr, "%s version %s", language_string, version_string);
3962 #ifdef TARGET_VERSION
3967 #define __VERSION__ "[unknown]"
3969 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3971 fprintf (stderr, " compiled by CC.\n");
3974 print_switch_values ();
3977 compile_file (filename);
3979 #if !defined(OS2) && !defined(VMS) && !defined(_WIN32)
3982 char *lim = (char *) sbrk (0);
3984 fprintf (stderr, "Data size %d.\n",
3985 lim - (char *) &environ);
3989 system ("ps -l 1>&2");
3992 #endif /* not USG */
3994 #endif /* not OS2 and not VMS and not _WIN32 */
3997 exit (FATAL_EXIT_CODE);
3999 exit (FATAL_EXIT_CODE);
4000 exit (SUCCESS_EXIT_CODE);
4004 /* Decode -m switches. */
4006 /* Here is a table, controlled by the tm.h file, listing each -m switch
4007 and which bits in `target_switches' it should set or clear.
4008 If VALUE is positive, it is bits to set.
4009 If VALUE is negative, -VALUE is bits to clear.
4010 (The sign bit is not used so there is no confusion.) */
4012 struct {char *name; int value;} target_switches []
4015 /* This table is similar, but allows the switch to have a value. */
4017 #ifdef TARGET_OPTIONS
4018 struct {char *prefix; char ** variable;} target_options []
4022 /* Decode the switch -mNAME. */
4025 set_target_switch (name)
4031 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4032 if (!strcmp (target_switches[j].name, name))
4034 if (target_switches[j].value < 0)
4035 target_flags &= ~-target_switches[j].value;
4037 target_flags |= target_switches[j].value;
4041 #ifdef TARGET_OPTIONS
4043 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4045 int len = strlen (target_options[j].prefix);
4046 if (!strncmp (target_options[j].prefix, name, len))
4048 *target_options[j].variable = name + len;
4055 error ("Invalid option `%s'", name);
4058 /* Variable used for communication between the following two routines. */
4060 static int line_position;
4062 /* Print an option value and adjust the position in the line. */
4065 print_single_switch (type, name)
4068 fprintf (stderr, " %s%s", type, name);
4070 line_position += strlen (type) + strlen (name) + 1;
4072 if (line_position > 65)
4074 fprintf (stderr, "\n\t");
4079 /* Print default target switches for -version. */
4082 print_switch_values ()
4086 fprintf (stderr, "enabled:");
4089 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4090 if (*f_options[j].variable == f_options[j].on_value)
4091 print_single_switch ("-f", f_options[j].string);
4093 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
4094 if (*W_options[j].variable == W_options[j].on_value)
4095 print_single_switch ("-W", W_options[j].string);
4097 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4098 if (target_switches[j].name[0] != '\0'
4099 && target_switches[j].value > 0
4100 && ((target_switches[j].value & target_flags)
4101 == target_switches[j].value))
4102 print_single_switch ("-m", target_switches[j].name);
4104 fprintf (stderr, "\n");