1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 1988, 1989, 1992 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. */
27 #include <sys/types.h>
36 #include <sys/param.h>
37 /* This is for hpux. It is a real screw. They should change hpux. */
39 #include <sys/times.h>
40 #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
41 #undef FFS /* Some systems define this in param.h. */
45 #include <sys/resource.h>
51 /* #include "c-tree.h" */
54 #include "insn-attr.h"
56 #ifdef XCOFF_DEBUGGING_INFO
61 /* The extra parameters substantially improve the I/O performance. */
63 VMS_fopen (fname, type)
67 if (strcmp (type, "w") == 0)
68 return fopen (fname, type, "mbc=16", "deq=64", "fop=tef", "shr=nil");
69 return fopen (fname, type, "mbc=16");
71 #define fopen VMS_fopen
74 #ifndef DEFAULT_GDB_EXTENSIONS
75 #define DEFAULT_GDB_EXTENSIONS 1
78 extern int rtx_equal_function_value_matters;
80 #if ! (defined (VMS) || defined (OS2))
81 extern char **environ;
83 extern char *version_string, *language_string;
85 extern void init_lex ();
86 extern void init_decl_processing ();
87 extern void init_obstacks ();
88 extern void init_tree_codes ();
89 extern void init_rtl ();
90 extern void init_optabs ();
91 extern void init_stmt ();
92 extern void init_reg_sets ();
93 extern void dump_flow_info ();
94 extern void dump_sched_info ();
95 extern void dump_local_alloc ();
97 void rest_of_decl_compilation ();
99 void error_with_file_and_line ();
104 void set_target_switch ();
105 static void print_switch_values ();
106 static char *decl_name ();
108 /* Name of program invoked, sans directories. */
112 /* Copy of arguments to main. */
116 /* Name of current original source file (what was input to cpp).
117 This comes from each #-command in the actual input. */
119 char *input_filename;
121 /* Name of top-level original source file (what was input to cpp).
122 This comes from the #-command at the beginning of the actual input.
123 If there isn't any there, then this is the cc1 input file name. */
125 char *main_input_filename;
127 /* Stream for reading from the input file. */
131 /* Current line number in real source file. */
135 /* Stack of currently pending input files. */
137 struct file_stack *input_file_stack;
139 /* Incremented on each change to input_file_stack. */
140 int input_file_stack_tick;
142 /* FUNCTION_DECL for function now being parsed or compiled. */
144 extern tree current_function_decl;
146 /* Name to use as base of names for dump output files. */
148 char *dump_base_name;
150 /* Bit flags that specify the machine subtype we are compiling for.
151 Bits are tested using macros TARGET_... defined in the tm.h file
152 and set by `-m...' switches. Must be defined in rtlanal.c. */
154 extern int target_flags;
156 /* Flags saying which kinds of debugging dump have been requested. */
159 int rtl_dump_and_exit = 0;
160 int jump_opt_dump = 0;
165 int combine_dump = 0;
167 int local_reg_dump = 0;
168 int global_reg_dump = 0;
170 int jump2_opt_dump = 0;
171 int dbr_sched_dump = 0;
172 int flag_print_asm_name = 0;
173 int stack_reg_dump = 0;
175 /* Name for output file of assembly code, specified with -o. */
179 /* Value of the -G xx switch, and whether it was passed or not. */
183 /* Type(s) of debugging information we are producing (if any).
184 See flags.h for the definitions of the different possible
185 types of debugging information. */
186 enum debug_info_type write_symbols = NO_DEBUG;
188 /* Level of debugging information we are producing. See flags.h
189 for the definitions of the different possible levels. */
190 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
192 /* Nonzero means use GNU-only extensions in the generated symbolic
193 debugging information. */
194 /* Currently, this only has an effect when write_symbols is set to
195 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
196 int use_gnu_debug_info_extensions = 0;
198 /* Nonzero means do optimizations. -O.
199 Particular numeric values stand for particular amounts of optimization;
200 thus, -O2 stores 2 here. However, the optimizations beyond the basic
201 ones are not controlled directly by this variable. Instead, they are
202 controlled by individual `flag_...' variables that are defaulted
203 based on this variable. */
207 /* Number of error messages and warning messages so far. */
210 int warningcount = 0;
213 /* Pointer to function to compute the name to use to print a declaration. */
215 char *(*decl_printable_name) ();
217 /* Pointer to function to compute rtl for a language-specific tree code. */
219 struct rtx_def *(*lang_expand_expr) ();
221 /* Pointer to function to finish handling an incomplete decl at the
222 end of compilation. */
224 void (*incomplete_decl_finalize_hook) () = 0;
226 /* Nonzero if generating code to do profiling. */
228 int profile_flag = 0;
230 /* Nonzero if generating code to do profiling on a line-by-line basis. */
232 int profile_block_flag;
234 /* Nonzero for -pedantic switch: warn about anything
235 that standard spec forbids. */
239 /* Temporarily suppress certain warnings.
240 This is set while reading code from a system header file. */
242 int in_system_header = 0;
244 /* Nonzero means do stupid register allocation.
245 Currently, this is 1 if `optimize' is 0. */
247 int obey_regdecls = 0;
249 /* Don't print functions as they are compiled and don't print
250 times taken by the various passes. -quiet. */
256 /* Nonzero means `char' should be signed. */
258 int flag_signed_char;
260 /* Nonzero means give an enum type only as many bytes as it needs. */
262 int flag_short_enums;
264 /* Nonzero for -fcaller-saves: allocate values in regs that need to
265 be saved across function calls, if that produces overall better code.
266 Optional now, so people can test it. */
268 #ifdef DEFAULT_CALLER_SAVES
269 int flag_caller_saves = 1;
271 int flag_caller_saves = 0;
274 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
276 int flag_pcc_struct_return = 0;
278 /* Nonzero for -fforce-mem: load memory value into a register
279 before arithmetic on it. This makes better cse but slower compilation. */
281 int flag_force_mem = 0;
283 /* Nonzero for -fforce-addr: load memory address into a register before
284 reference to memory. This makes better cse but slower compilation. */
286 int flag_force_addr = 0;
288 /* Nonzero for -fdefer-pop: don't pop args after each function call;
289 instead save them up to pop many calls' args with one insns. */
291 int flag_defer_pop = 1;
293 /* Nonzero for -ffloat-store: don't allocate floats and doubles
294 in extended-precision registers. */
296 int flag_float_store = 0;
298 /* Nonzero for -fcse-follow-jumps:
299 have cse follow jumps to do a more extensive job. */
301 int flag_cse_follow_jumps;
303 /* Nonzero for -fcse-skip-blocks:
304 have cse follow a branch around a block. */
305 int flag_cse_skip_blocks;
307 /* Nonzero for -fexpensive-optimizations:
308 perform miscellaneous relatively-expensive optimizations. */
309 int flag_expensive_optimizations;
311 /* Nonzero for -fthread-jumps:
312 have jump optimize output of loop. */
314 int flag_thread_jumps;
316 /* Nonzero enables strength-reduction in loop.c. */
318 int flag_strength_reduce = 0;
320 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
321 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
322 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
325 int flag_unroll_loops;
327 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
328 This is generally not a win. */
330 int flag_unroll_all_loops;
332 /* Nonzero for -fwritable-strings:
333 store string constants in data segment and don't uniquize them. */
335 int flag_writable_strings = 0;
337 /* Nonzero means don't put addresses of constant functions in registers.
338 Used for compiling the Unix kernel, where strange substitutions are
339 done on the assembly output. */
341 int flag_no_function_cse = 0;
343 /* Nonzero for -fomit-frame-pointer:
344 don't make a frame pointer in simple functions that don't require one. */
346 int flag_omit_frame_pointer = 0;
348 /* Nonzero to inhibit use of define_optimization peephole opts. */
350 int flag_no_peephole = 0;
352 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
353 operations in the interest of optimization. For example it allows
354 GCC to assume arguments to sqrt are nonnegative numbers, allowing
355 faster code for sqrt to be generated. */
357 int flag_fast_math = 0;
359 /* Nonzero means all references through pointers are volatile. */
363 /* Nonzero means treat all global and extern variables as global. */
365 int flag_volatile_global;
367 /* Nonzero means just do syntax checking; don't output anything. */
369 int flag_syntax_only = 0;
371 /* Nonzero means to rerun cse after loop optimization. This increases
372 compilation time about 20% and picks up a few more common expressions. */
374 static int flag_rerun_cse_after_loop;
376 /* Nonzero for -finline-functions: ok to inline functions that look like
377 good inline candidates. */
379 int flag_inline_functions;
381 /* Nonzero for -fkeep-inline-functions: even if we make a function
382 go inline everywhere, keep its definition around for debugging
385 int flag_keep_inline_functions;
387 /* Nonzero means that functions declared `inline' will be treated
388 as `static'. Prevents generation of zillions of copies of unused
389 static inline functions; instead, `inlines' are written out
390 only when actually used. Used in conjunction with -g. Also
391 does the right thing with #pragma interface. */
395 /* Nonzero means we should be saving declaration info into a .X file. */
397 int flag_gen_aux_info = 0;
399 /* Specified name of aux-info file. */
401 static char *aux_info_file_name;
403 /* Nonzero means make the text shared if supported. */
405 int flag_shared_data;
407 /* Nonzero means schedule into delayed branch slots if supported. */
409 int flag_delayed_branch;
411 /* Nonzero if we are compiling pure (sharable) code.
412 Value is 1 if we are doing reasonable (i.e. simple
413 offset into offset table) pic. Value is 2 if we can
414 only perform register offsets. */
418 /* Nonzero means place uninitialized global data in the bss section. */
422 /* Nonzero means pretend it is OK to examine bits of target floats,
423 even if that isn't true. The resulting code will have incorrect constants,
424 but the same series of instructions that the native compiler would make. */
426 int flag_pretend_float;
428 /* Nonzero means change certain warnings into errors.
429 Usually these are warnings about failure to conform to some standard. */
431 int flag_pedantic_errors = 0;
433 /* flag_schedule_insns means schedule insns within basic blocks (before
435 flag_schedule_insns_after_reload means schedule insns after
438 int flag_schedule_insns = 0;
439 int flag_schedule_insns_after_reload = 0;
441 /* -finhibit-size-directive inhibits output of .size for ELF.
442 This is used only for compiling crtstuff.c,
443 and it may be extended to other effects
444 needed for crtstuff.c on other systems. */
445 int flag_inhibit_size_directive = 0;
447 /* -fverbose-asm causes extra commentary information to be produced in
448 the generated assembly code (to make it more readable). This option
449 is generally only of use to those who actually need to read the
450 generated assembly code (perhaps while debugging the compiler itself). */
452 int flag_verbose_asm = 0;
454 /* -fgnu-linker specifies use of the GNU linker for initializations.
455 (Or, more generally, a linker that handles initializations.)
456 -fno-gnu-linker says that collect2 will be used. */
458 int flag_gnu_linker = 0;
460 int flag_gnu_linker = 1;
463 /* Table of language-independent -f options.
464 STRING is the option name. VARIABLE is the address of the variable.
465 ON_VALUE is the value to store in VARIABLE
466 if `-fSTRING' is seen as an option.
467 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
469 struct { char *string; int *variable; int on_value;} f_options[] =
471 {"float-store", &flag_float_store, 1},
472 {"volatile", &flag_volatile, 1},
473 {"volatile-global", &flag_volatile_global, 1},
474 {"defer-pop", &flag_defer_pop, 1},
475 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
476 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
477 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
478 {"expensive-optimizations", &flag_expensive_optimizations, 1},
479 {"thread-jumps", &flag_thread_jumps, 1},
480 {"strength-reduce", &flag_strength_reduce, 1},
481 {"unroll-loops", &flag_unroll_loops, 1},
482 {"unroll-all-loops", &flag_unroll_all_loops, 1},
483 {"writable-strings", &flag_writable_strings, 1},
484 {"peephole", &flag_no_peephole, 0},
485 {"force-mem", &flag_force_mem, 1},
486 {"force-addr", &flag_force_addr, 1},
487 {"function-cse", &flag_no_function_cse, 0},
488 {"inline-functions", &flag_inline_functions, 1},
489 {"keep-inline-functions", &flag_keep_inline_functions, 1},
490 {"inline", &flag_no_inline, 0},
491 {"syntax-only", &flag_syntax_only, 1},
492 {"shared-data", &flag_shared_data, 1},
493 {"caller-saves", &flag_caller_saves, 1},
494 {"pcc-struct-return", &flag_pcc_struct_return, 1},
495 {"delayed-branch", &flag_delayed_branch, 1},
496 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
497 {"pretend-float", &flag_pretend_float, 1},
498 {"schedule-insns", &flag_schedule_insns, 1},
499 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
500 {"pic", &flag_pic, 1},
501 {"PIC", &flag_pic, 2},
502 {"fast-math", &flag_fast_math, 1},
503 {"common", &flag_no_common, 0},
504 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
505 {"verbose-asm", &flag_verbose_asm, 1},
506 {"gnu-linker", &flag_gnu_linker, 1}
509 /* Table of language-specific options. */
511 char *lang_options[] =
520 "-fno-unsigned-char",
521 "-fsigned-bitfields",
522 "-funsigned-bitfields",
523 "-fno-signed-bitfields",
524 "-fno-unsigned-bitfields",
528 "-fno-cond-mismatch",
541 "-Wno-write-strings",
545 "-Wno-pointer-arith",
546 "-Wstrict-prototypes",
547 "-Wno-strict-prototypes",
548 "-Wmissing-prototypes",
549 "-Wno-missing-prototypes",
551 "-Wno-redundant-decls",
553 "-Wno-nested-externs",
559 "-Wno-char-subscripts",
574 /* These are for C++. */
575 "-+e0", /* gcc.c tacks the `-' on the front. */
579 "-fno-save-memoized",
588 "-fthis-is-variable",
589 "-fno-this-is-variable",
590 "-fstrict-prototype",
591 "-fno-strict-prototype",
595 "-fno-memoize-lookups",
596 "-felide-constructors",
597 "-fno-elide-constructors",
600 "-fhandle-exceptions",
601 "-fno-handle-exceptions",
603 "-fno-ansi-exceptions",
604 "-fspring-exceptions",
605 "-fno-spring-exceptions",
607 "-fno-default-inline",
609 "-fno-enum-int-equiv",
615 "-fno-nonnull-objects",
619 "-Woverloaded-virtual",
620 "-Wno-overloaded-virtual",
623 "-Wtemplate-debugging",
624 "-Wno-template-debugging",
626 /* these are for obj c */
634 /* Options controlling warnings */
636 /* Don't print warning messages. -w. */
638 int inhibit_warnings = 0;
640 /* Print various extra warnings. -W. */
642 int extra_warnings = 0;
644 /* Treat warnings as errors. -Werror. */
646 int warnings_are_errors = 0;
648 /* Nonzero to warn about unused local variables. */
652 /* Nonzero to warn about variables used before they are initialized. */
654 int warn_uninitialized;
656 /* Nonzero means warn about all declarations which shadow others. */
660 /* Warn if a switch on an enum fails to have a case for every enum value. */
664 /* Nonzero means warn about function definitions that default the return type
665 or that use a null return and have a return-type other than void. */
667 int warn_return_type;
669 /* Nonzero means warn about pointer casts that increase the required
670 alignment of the target type (and might therefore lead to a crash
671 due to a misaligned access). */
675 /* Nonzero means warn about any identifiers that match in the first N
676 characters. The value N is in `id_clash_len'. */
681 /* Nonzero means warn if inline function is too large. */
685 /* Warn if a function returns an aggregate,
686 since there are often incompatible calling conventions for doing this. */
688 int warn_aggregate_return;
690 /* Likewise for -W. */
692 struct { char *string; int *variable; int on_value;} W_options[] =
694 {"unused", &warn_unused, 1},
695 {"error", &warnings_are_errors, 1},
696 {"shadow", &warn_shadow, 1},
697 {"switch", &warn_switch, 1},
698 {"aggregate-return", &warn_aggregate_return, 1},
699 {"cast-align", &warn_cast_align, 1},
700 {"uninitialized", &warn_uninitialized, 1},
701 {"inline", &warn_inline, 1}
704 /* Output files for assembler code (real compiler output)
705 and debugging dumps. */
710 FILE *jump_opt_dump_file;
712 FILE *loop_dump_file;
713 FILE *cse2_dump_file;
714 FILE *flow_dump_file;
715 FILE *combine_dump_file;
716 FILE *sched_dump_file;
717 FILE *local_reg_dump_file;
718 FILE *global_reg_dump_file;
719 FILE *sched2_dump_file;
720 FILE *jump2_opt_dump_file;
721 FILE *dbr_sched_dump_file;
722 FILE *stack_reg_dump_file;
724 /* Time accumulators, to count the total time spent in various passes. */
728 int integration_time;
736 int local_alloc_time;
737 int global_alloc_time;
740 int shorten_branch_time;
746 /* Return time used so far, in microseconds. */
755 struct rusage rusage;
760 int proc_system_time;
762 int child_system_time;
772 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
775 getrusage (0, &rusage);
776 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
777 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
780 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
785 #define TIMEVAR(VAR, BODY) \
786 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
789 print_time (str, total)
794 "time in %s: %d.%06d\n",
795 str, total / 1000000, total % 1000000);
798 /* Count an error or warning. Return 1 if the message should be printed. */
801 count_error (warningp)
804 if (warningp && inhibit_warnings)
807 if (warningp && !warnings_are_errors)
811 static int warning_message = 0;
813 if (warningp && !warning_message)
815 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
824 /* Print a fatal error message. NAME is the text.
825 Also include a system error message based on `errno'. */
828 pfatal_with_name (name)
831 fprintf (stderr, "%s: ", progname);
837 fatal_io_error (name)
840 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
853 /* Called to give a better error message when we don't have an insn to match
854 what we are looking for or if the insn's constraints aren't satisfied,
855 rather than just calling abort(). */
858 fatal_insn_not_found (insn)
861 if (INSN_CODE (insn) < 0)
862 error ("internal error--unrecognizable insn:", 0);
864 error ("internal error--insn does not satisfy its constraints:", 0);
867 fflush (asm_out_file);
869 fflush (aux_info_file);
871 fflush (rtl_dump_file);
872 if (jump_opt_dump_file)
873 fflush (jump_opt_dump_file);
875 fflush (cse_dump_file);
877 fflush (loop_dump_file);
879 fflush (cse2_dump_file);
881 fflush (flow_dump_file);
882 if (combine_dump_file)
883 fflush (combine_dump_file);
885 fflush (sched_dump_file);
886 if (local_reg_dump_file)
887 fflush (local_reg_dump_file);
888 if (global_reg_dump_file)
889 fflush (global_reg_dump_file);
890 if (sched2_dump_file)
891 fflush (sched2_dump_file);
892 if (jump2_opt_dump_file)
893 fflush (jump2_opt_dump_file);
894 if (dbr_sched_dump_file)
895 fflush (dbr_sched_dump_file);
896 if (stack_reg_dump_file)
897 fflush (stack_reg_dump_file);
901 /* This is the default decl_printable_name function. */
904 decl_name (decl, kind)
908 return IDENTIFIER_POINTER (DECL_NAME (decl));
911 static int need_error_newline;
913 /* Function of last error message;
914 more generally, function such that if next error message is in it
915 then we don't have to mention the function name. */
916 static tree last_error_function = NULL;
918 /* Used to detect when input_file_stack has changed since last described. */
919 static int last_error_tick;
921 /* Called when the start of a function definition is parsed,
922 this function prints on stderr the name of the function. */
925 announce_function (decl)
931 if (rtl_dump_and_exit)
932 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
934 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
936 need_error_newline = 1;
937 last_error_function = current_function_decl;
941 /* Prints out, if necessary, the name of the current function
942 which caused an error. Called from all error and warning functions. */
945 report_error_function (file)
948 struct file_stack *p;
950 if (need_error_newline)
952 fprintf (stderr, "\n");
953 need_error_newline = 0;
956 if (last_error_function != current_function_decl)
958 char *kind = "function";
959 if (current_function_decl != 0
960 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
964 fprintf (stderr, "%s: ", file);
966 if (current_function_decl == NULL)
967 fprintf (stderr, "At top level:\n");
970 char *name = (*decl_printable_name) (current_function_decl, &kind);
971 fprintf (stderr, "In %s `%s':\n", kind, name);
974 last_error_function = current_function_decl;
976 if (input_file_stack && input_file_stack->next != 0
977 && input_file_stack_tick != last_error_tick)
979 fprintf (stderr, "In file included");
980 for (p = input_file_stack->next; p; p = p->next)
982 fprintf (stderr, " from %s:%d", p->name, p->line);
984 fprintf (stderr, ",");
986 fprintf (stderr, ":\n");
987 last_error_tick = input_file_stack_tick;
991 /* Report an error at the current line number.
992 S is a string and V and V2 are args for `printf'. We use HOST_WIDE_INT
993 as the type for these args assuming it is wide enough to hold a
994 pointer. This isn't terribly portable, but is the best we can do
995 without vprintf universally available. */
1000 HOST_WIDE_INT v; /* Also used as pointer */
1001 HOST_WIDE_INT v2; /* Also used as pointer */
1003 error_with_file_and_line (input_filename, lineno, s, v, v2);
1006 /* Report an error at line LINE of file FILE.
1007 S and V are a string and an arg for `printf'. */
1010 error_with_file_and_line (file, line, s, v, v2)
1019 report_error_function (file);
1022 fprintf (stderr, "%s:%d: ", file, line);
1024 fprintf (stderr, "%s: ", progname);
1025 fprintf (stderr, s, v, v2);
1026 fprintf (stderr, "\n");
1029 /* Report an error at the declaration DECL.
1030 S and V are a string and an arg which uses %s to substitute
1031 the declaration name. */
1034 error_with_decl (decl, s, v)
1042 report_error_function (DECL_SOURCE_FILE (decl));
1044 fprintf (stderr, "%s:%d: ",
1045 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1047 if (DECL_NAME (decl))
1048 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1050 fprintf (stderr, s, "((anonymous))", v);
1051 fprintf (stderr, "\n");
1054 /* Report an error at the line number of the insn INSN.
1055 S and V are a string and an arg for `printf'.
1056 This is used only when INSN is an `asm' with operands,
1057 and each ASM_OPERANDS records its own source file and line. */
1060 error_for_asm (insn, s, v, v2)
1063 HOST_WIDE_INT v; /* Also used as pointer */
1064 HOST_WIDE_INT v2; /* Also used as pointer */
1068 rtx body = PATTERN (insn);
1071 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1072 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1073 asmop = SET_SRC (body);
1074 else if (GET_CODE (body) == ASM_OPERANDS)
1076 else if (GET_CODE (body) == PARALLEL
1077 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1078 asmop = SET_SRC (XVECEXP (body, 0, 0));
1079 else if (GET_CODE (body) == PARALLEL
1080 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1081 asmop = XVECEXP (body, 0, 0);
1083 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1084 line = ASM_OPERANDS_SOURCE_LINE (asmop);
1086 error_with_file_and_line (filename, line, s, v, v2);
1089 /* Report a warning at line LINE.
1090 S and V are a string and an arg for `printf'. */
1093 warning_with_file_and_line (file, line, s, v, v2, v3)
1097 HOST_WIDE_INT v, v2, v3;
1099 if (count_error (1) == 0)
1102 report_error_function (file);
1105 fprintf (stderr, "%s:%d: ", file, line);
1107 fprintf (stderr, "%s: ", progname);
1109 fprintf (stderr, "warning: ");
1110 fprintf (stderr, s, v, v2, v3);
1111 fprintf (stderr, "\n");
1114 /* Report a warning at the current line number.
1115 S and V are a string and an arg for `printf'. */
1118 warning (s, v, v2, v3)
1120 HOST_WIDE_INT v, v2, v3; /* Also used as pointer */
1122 warning_with_file_and_line (input_filename, lineno, s, v, v2, v3);
1125 /* Report a warning at the declaration DECL.
1126 S is string which uses %s to substitute the declaration name.
1127 V is a second parameter that S can refer to. */
1130 warning_with_decl (decl, s, v)
1137 if (count_error (1) == 0)
1140 report_error_function (DECL_SOURCE_FILE (decl));
1142 fprintf (stderr, "%s:%d: ",
1143 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1145 fprintf (stderr, "warning: ");
1146 if (DECL_NAME (decl))
1147 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1149 fprintf (stderr, s, "((anonymous))", v);
1150 fprintf (stderr, "\n");
1153 /* Report a warning at the line number of the insn INSN.
1154 S and V are a string and an arg for `printf'.
1155 This is used only when INSN is an `asm' with operands,
1156 and each ASM_OPERANDS records its own source file and line. */
1159 warning_for_asm (insn, s, v, v2)
1162 HOST_WIDE_INT v; /* Also used as pointer */
1163 HOST_WIDE_INT v2; /* Also used as pointer */
1167 rtx body = PATTERN (insn);
1170 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1171 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1172 asmop = SET_SRC (body);
1173 else if (GET_CODE (body) == ASM_OPERANDS)
1175 else if (GET_CODE (body) == PARALLEL
1176 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1177 asmop = SET_SRC (XVECEXP (body, 0, 0));
1178 else if (GET_CODE (body) == PARALLEL
1179 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1180 asmop = XVECEXP (body, 0, 0);
1182 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1183 line = ASM_OPERANDS_SOURCE_LINE (asmop);
1185 warning_with_file_and_line (filename, line, s, v, v2);
1188 /* These functions issue either warnings or errors depending on
1189 -pedantic-errors. */
1194 HOST_WIDE_INT v; /* Also used as pointer */
1197 if (flag_pedantic_errors)
1204 pedwarn_with_decl (decl, s, v)
1209 if (flag_pedantic_errors)
1210 error_with_decl (decl, s, v);
1212 warning_with_decl (decl, s, v);
1216 pedwarn_with_file_and_line (file, line, s, v, v2)
1223 if (flag_pedantic_errors)
1224 error_with_file_and_line (file, line, s, v, v2);
1226 warning_with_file_and_line (file, line, s, v, v2);
1229 /* Apologize for not implementing some feature.
1230 S, V, and V2 are a string and args for `printf'. */
1235 HOST_WIDE_INT v, v2;
1239 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1241 fprintf (stderr, "%s: ", progname);
1243 fprintf (stderr, "sorry, not implemented: ");
1244 fprintf (stderr, s, v, v2);
1245 fprintf (stderr, "\n");
1248 /* Apologize for not implementing some feature, then quit.
1249 S, V, and V2 are a string and args for `printf'. */
1252 really_sorry (s, v, v2)
1254 HOST_WIDE_INT v, v2;
1257 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1259 fprintf (stderr, "%s: ", progname);
1261 fprintf (stderr, "sorry, not implemented: ");
1262 fprintf (stderr, s, v, v2);
1263 fatal (" (fatal)\n");
1266 /* More 'friendly' abort that prints the line and file.
1267 config.h can #define abort fancy_abort if you like that sort of thing.
1269 I don't think this is actually a good idea.
1270 Other sorts of crashes will look a certain way.
1271 It is a good thing if crashes from calling abort look the same way.
1277 fatal ("internal gcc abort");
1280 /* This calls abort and is used to avoid problems when abort if a macro.
1281 It is used when we need to pass the address of abort. */
1289 /* When `malloc.c' is compiled with `rcheck' defined,
1290 it calls this function to report clobberage. */
1298 /* Same as `malloc' but report error if no memory available. */
1304 register char *value = (char *) malloc (size);
1306 fatal ("virtual memory exhausted");
1310 /* Same as `realloc' but report error if no memory available. */
1313 xrealloc (ptr, size)
1317 char *result = (char *) realloc (ptr, size);
1319 fatal ("virtual memory exhausted");
1323 /* Return the logarithm of X, base 2, considering X unsigned,
1324 if X is a power of 2. Otherwise, returns -1.
1326 This should be used via the `exact_log2' macro. */
1330 register unsigned HOST_WIDE_INT x;
1332 register int log = 0;
1333 /* Test for 0 or a power of 2. */
1334 if (x == 0 || x != (x & -x))
1336 while ((x >>= 1) != 0)
1341 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1342 If X is 0, return -1.
1344 This should be used via the floor_log2 macro. */
1348 register unsigned HOST_WIDE_INT x;
1350 register int log = -1;
1358 jmp_buf float_handler;
1360 /* Specify where to longjmp to when a floating arithmetic error happens.
1361 If HANDLER is 0, it means don't handle the errors any more. */
1364 set_float_handler (handler)
1367 float_handled = (handler != 0);
1369 bcopy (handler, float_handler, sizeof (float_handler));
1372 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1373 error happens, pushing the previous specification into OLD_HANDLER.
1374 Return an indication of whether there was a previous handler in effect. */
1377 push_float_handler (handler, old_handler)
1378 jmp_buf handler, old_handler;
1380 int was_handled = float_handled;
1384 bcopy (float_handler, old_handler, sizeof (float_handler));
1385 bcopy (handler, float_handler, sizeof (float_handler));
1389 /* Restore the previous specification of whether and where to longjmp to
1390 when a floating arithmetic error happens. */
1393 pop_float_handler (handled, handler)
1397 float_handled = handled;
1399 bcopy (handler, float_handler, sizeof (float_handler));
1402 /* Signals actually come here. */
1405 float_signal (signo)
1406 /* If this is missing, some compilers complain. */
1409 if (float_handled == 0)
1411 #if defined (USG) || defined (hpux)
1412 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1415 signal (SIGFPE, float_signal);
1416 longjmp (float_handler, 1);
1419 /* Handler for SIGPIPE. */
1423 /* If this is missing, some compilers complain. */
1426 fatal ("output pipe has been closed");
1429 /* Strip off a legitimate source ending from the input string NAME of
1433 strip_off_ending (name, len)
1437 if (len > 2 && ! strcmp (".c", name + len - 2))
1439 else if (len > 2 && ! strcmp (".m", name + len - 2))
1441 else if (len > 2 && ! strcmp (".i", name + len - 2))
1443 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1445 else if (len > 3 && ! strcmp (".co", name + len - 3))
1447 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1449 else if (len > 2 && ! strcmp (".C", name + len - 2))
1451 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1453 else if (len > 2 && ! strcmp (".f", name + len - 2))
1455 else if (len > 4 && ! strcmp (".ada", name + len - 4))
1459 /* Output a file name in the form wanted by System V. */
1462 output_file_directive (asm_file, input_name)
1466 int len = strlen (input_name);
1467 char *na = input_name + len;
1469 /* NA gets INPUT_NAME sans directory names. */
1470 while (na > input_name)
1477 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1478 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1480 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1481 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1483 fprintf (asm_file, "\t.file\t\"%s\"\n", na);
1488 /* Compile an entire file of output from cpp, named NAME.
1489 Write a file of assembly output and various debugging dumps. */
1497 int dump_base_name_length;
1499 int name_specified = name != 0;
1501 if (dump_base_name == 0)
1502 dump_base_name = name ? name : "gccdump";
1503 dump_base_name_length = strlen (dump_base_name);
1507 integration_time = 0;
1515 local_alloc_time = 0;
1516 global_alloc_time = 0;
1519 shorten_branch_time = 0;
1525 /* Open input file. */
1527 if (name == 0 || !strcmp (name, "-"))
1533 finput = fopen (name, "r");
1535 pfatal_with_name (name);
1537 #ifdef IO_BUFFER_SIZE
1538 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
1541 /* Initialize data in various passes. */
1547 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
1548 || debug_info_level == DINFO_LEVEL_VERBOSE);
1549 init_decl_processing ();
1557 if (flag_caller_saves)
1558 init_caller_save ();
1560 /* If auxiliary info generation is desired, open the output file.
1561 This goes in the same directory as the source file--unlike
1562 all the other output files. */
1563 if (flag_gen_aux_info)
1565 aux_info_file = fopen (aux_info_file_name, "w");
1566 if (aux_info_file == 0)
1567 pfatal_with_name (aux_info_file_name);
1570 /* If rtl dump desired, open the output file. */
1573 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1574 strcpy (dumpname, dump_base_name);
1575 strcat (dumpname, ".rtl");
1576 rtl_dump_file = fopen (dumpname, "w");
1577 if (rtl_dump_file == 0)
1578 pfatal_with_name (dumpname);
1581 /* If jump_opt dump desired, open the output file. */
1584 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1585 strcpy (dumpname, dump_base_name);
1586 strcat (dumpname, ".jump");
1587 jump_opt_dump_file = fopen (dumpname, "w");
1588 if (jump_opt_dump_file == 0)
1589 pfatal_with_name (dumpname);
1592 /* If cse dump desired, open the output file. */
1595 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1596 strcpy (dumpname, dump_base_name);
1597 strcat (dumpname, ".cse");
1598 cse_dump_file = fopen (dumpname, "w");
1599 if (cse_dump_file == 0)
1600 pfatal_with_name (dumpname);
1603 /* If loop dump desired, open the output file. */
1606 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1607 strcpy (dumpname, dump_base_name);
1608 strcat (dumpname, ".loop");
1609 loop_dump_file = fopen (dumpname, "w");
1610 if (loop_dump_file == 0)
1611 pfatal_with_name (dumpname);
1614 /* If cse2 dump desired, open the output file. */
1617 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1618 strcpy (dumpname, dump_base_name);
1619 strcat (dumpname, ".cse2");
1620 cse2_dump_file = fopen (dumpname, "w");
1621 if (cse2_dump_file == 0)
1622 pfatal_with_name (dumpname);
1625 /* If flow dump desired, open the output file. */
1628 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1629 strcpy (dumpname, dump_base_name);
1630 strcat (dumpname, ".flow");
1631 flow_dump_file = fopen (dumpname, "w");
1632 if (flow_dump_file == 0)
1633 pfatal_with_name (dumpname);
1636 /* If combine dump desired, open the output file. */
1639 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1640 strcpy (dumpname, dump_base_name);
1641 strcat (dumpname, ".combine");
1642 combine_dump_file = fopen (dumpname, "w");
1643 if (combine_dump_file == 0)
1644 pfatal_with_name (dumpname);
1647 /* If scheduling dump desired, open the output file. */
1650 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1651 strcpy (dumpname, dump_base_name);
1652 strcat (dumpname, ".sched");
1653 sched_dump_file = fopen (dumpname, "w");
1654 if (sched_dump_file == 0)
1655 pfatal_with_name (dumpname);
1658 /* If local_reg dump desired, open the output file. */
1661 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1662 strcpy (dumpname, dump_base_name);
1663 strcat (dumpname, ".lreg");
1664 local_reg_dump_file = fopen (dumpname, "w");
1665 if (local_reg_dump_file == 0)
1666 pfatal_with_name (dumpname);
1669 /* If global_reg dump desired, open the output file. */
1670 if (global_reg_dump)
1672 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1673 strcpy (dumpname, dump_base_name);
1674 strcat (dumpname, ".greg");
1675 global_reg_dump_file = fopen (dumpname, "w");
1676 if (global_reg_dump_file == 0)
1677 pfatal_with_name (dumpname);
1680 /* If 2nd scheduling dump desired, open the output file. */
1683 register char *dumpname = (char *) xmalloc (dump_base_name_length + 8);
1684 strcpy (dumpname, dump_base_name);
1685 strcat (dumpname, ".sched2");
1686 sched2_dump_file = fopen (dumpname, "w");
1687 if (sched2_dump_file == 0)
1688 pfatal_with_name (dumpname);
1691 /* If jump2_opt dump desired, open the output file. */
1694 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1695 strcpy (dumpname, dump_base_name);
1696 strcat (dumpname, ".jump2");
1697 jump2_opt_dump_file = fopen (dumpname, "w");
1698 if (jump2_opt_dump_file == 0)
1699 pfatal_with_name (dumpname);
1702 /* If dbr_sched dump desired, open the output file. */
1705 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1706 strcpy (dumpname, dump_base_name);
1707 strcat (dumpname, ".dbr");
1708 dbr_sched_dump_file = fopen (dumpname, "w");
1709 if (dbr_sched_dump_file == 0)
1710 pfatal_with_name (dumpname);
1715 /* If stack_reg dump desired, open the output file. */
1718 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1719 strcpy (dumpname, dump_base_name);
1720 strcat (dumpname, ".stack");
1721 stack_reg_dump_file = fopen (dumpname, "w");
1722 if (stack_reg_dump_file == 0)
1723 pfatal_with_name (dumpname);
1728 /* Open assembler code output file. */
1730 if (! name_specified && asm_file_name == 0)
1731 asm_out_file = stdout;
1734 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1735 int len = strlen (dump_base_name);
1736 strcpy (dumpname, dump_base_name);
1737 strip_off_ending (dumpname, len);
1738 strcat (dumpname, ".s");
1739 if (asm_file_name == 0)
1741 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
1742 strcpy (asm_file_name, dumpname);
1744 if (!strcmp (asm_file_name, "-"))
1745 asm_out_file = stdout;
1747 asm_out_file = fopen (asm_file_name, "w");
1748 if (asm_out_file == 0)
1749 pfatal_with_name (asm_file_name);
1752 #ifdef IO_BUFFER_SIZE
1753 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
1754 _IOFBF, IO_BUFFER_SIZE);
1757 input_filename = name;
1759 /* Perform language-specific initialization.
1760 This may set main_input_filename. */
1763 /* If the input doesn't start with a #line, use the input name
1764 as the official input file name. */
1765 if (main_input_filename == 0)
1766 main_input_filename = name;
1768 /* Put an entry on the input file stack for the main input file. */
1770 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
1771 input_file_stack->next = 0;
1772 input_file_stack->name = input_filename;
1774 ASM_FILE_START (asm_out_file);
1776 /* Output something to inform GDB that this compilation was by GCC. */
1777 #ifndef ASM_IDENTIFY_GCC
1778 fprintf (asm_out_file, "gcc2_compiled.:\n");
1780 ASM_IDENTIFY_GCC (asm_out_file);
1782 /* Don't let the first function fall at the same address
1783 as gcc_compiled., if profiling. */
1784 if (profile_flag || profile_block_flag)
1785 assemble_zeros (UNITS_PER_WORD);
1787 /* If dbx symbol table desired, initialize writing it
1788 and output the predefined types. */
1789 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1790 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1791 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
1794 #ifdef SDB_DEBUGGING_INFO
1795 if (write_symbols == SDB_DEBUG)
1796 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
1799 #ifdef DWARF_DEBUGGING_INFO
1800 if (write_symbols == DWARF_DEBUG)
1801 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
1804 /* Initialize yet another pass. */
1806 init_final (main_input_filename);
1808 start_time = get_run_time ();
1810 /* Call the parser, which parses the entire file
1811 (calling rest_of_compilation for each function). */
1813 if (yyparse () != 0)
1814 if (errorcount == 0)
1815 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
1817 /* Compilation is now finished except for writing
1818 what's left of the symbol table output. */
1820 parse_time += get_run_time () - start_time;
1822 parse_time -= integration_time;
1823 parse_time -= varconst_time;
1825 globals = getdecls ();
1827 /* Really define vars that have had only a tentative definition.
1828 Really output inline functions that must actually be callable
1829 and have not been output so far. */
1832 int len = list_length (globals);
1833 tree *vec = (tree *) alloca (sizeof (tree) * len);
1837 /* Process the decls in reverse order--earliest first.
1838 Put them into VEC from back to front, then take out from front. */
1840 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
1841 vec[len - i - 1] = decl;
1843 for (i = 0; i < len; i++)
1846 if (DECL_SIZE (decl) == 0)
1847 (*incomplete_decl_finalize_hook) (decl);
1849 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1850 && ! TREE_ASM_WRITTEN (decl))
1852 /* Don't write out static consts, unless we used them.
1853 (This used to write them out only if the address was
1854 taken, but that was wrong; if the variable was simply
1855 referred to, it still needs to exist or else it will
1856 be undefined in the linker.) */
1857 if (! TREE_READONLY (decl)
1858 || TREE_PUBLIC (decl)
1860 || TREE_ADDRESSABLE (decl)
1861 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1862 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1864 /* Cancel the RTL for this decl so that, if debugging info
1865 output for global variables is still to come,
1866 this one will be omitted. */
1867 DECL_RTL (decl) = NULL;
1870 if (TREE_CODE (decl) == FUNCTION_DECL
1871 && ! TREE_ASM_WRITTEN (decl)
1872 && DECL_INITIAL (decl) != 0
1873 && (TREE_ADDRESSABLE (decl)
1874 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1875 && ! DECL_EXTERNAL (decl))
1876 output_inline_function (decl);
1878 /* Warn about any function
1879 declared static but not defined.
1880 We don't warn about variables,
1881 because many programs have static variables
1882 that exist only to get some text into the object file. */
1885 || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))))
1886 && TREE_CODE (decl) == FUNCTION_DECL
1887 && DECL_INITIAL (decl) == 0
1888 && DECL_EXTERNAL (decl)
1889 && ! TREE_PUBLIC (decl))
1891 pedwarn_with_decl (decl,
1892 "`%s' declared `static' but never defined");
1893 /* This symbol is effectively an "extern" declaration now. */
1894 TREE_PUBLIC (decl) = 1;
1895 assemble_external (decl);
1898 /* Warn about static fns or vars defined but not used,
1899 but not about inline functions
1900 since unused inline statics is normal practice. */
1902 && (TREE_CODE (decl) == FUNCTION_DECL
1903 || TREE_CODE (decl) == VAR_DECL)
1904 && ! DECL_IN_SYSTEM_HEADER (decl)
1905 && ! DECL_EXTERNAL (decl)
1906 && ! TREE_PUBLIC (decl)
1907 && ! TREE_USED (decl)
1908 && ! DECL_INLINE (decl)
1909 && ! DECL_REGISTER (decl)
1910 /* The TREE_USED bit for file-scope decls
1911 is kept in the identifier, to handle multiple
1912 external decls in different scopes. */
1913 && ! TREE_USED (DECL_NAME (decl)))
1914 warning_with_decl (decl, "`%s' defined but not used");
1916 #ifdef SDB_DEBUGGING_INFO
1917 /* The COFF linker can move initialized global vars to the end.
1918 And that can screw up the symbol ordering.
1919 By putting the symbols in that order to begin with,
1920 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1921 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
1922 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
1923 && DECL_RTL (decl) != 0)
1924 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1926 /* Output COFF information for non-global
1927 file-scope initialized variables. */
1928 if (write_symbols == SDB_DEBUG
1929 && TREE_CODE (decl) == VAR_DECL
1930 && DECL_INITIAL (decl)
1931 && DECL_RTL (decl) != 0
1932 && GET_CODE (DECL_RTL (decl)) == MEM)
1933 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
1934 #endif /* SDB_DEBUGGING_INFO */
1935 #ifdef DWARF_DEBUGGING_INFO
1936 /* Output DWARF information for file-scope tentative data object
1937 declarations, file-scope (extern) function declarations (which
1938 had no corresponding body) and file-scope tagged type declarations
1939 and definitions which have not yet been forced out. */
1941 if (write_symbols == DWARF_DEBUG
1942 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1943 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
1948 /* Do dbx symbols */
1949 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1950 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1951 TIMEVAR (symout_time,
1953 dbxout_finish (asm_out_file, main_input_filename);
1957 #ifdef DWARF_DEBUGGING_INFO
1958 if (write_symbols == DWARF_DEBUG)
1959 TIMEVAR (symout_time,
1965 /* Output some stuff at end of file if nec. */
1967 end_final (main_input_filename);
1970 ASM_FILE_END (asm_out_file);
1973 after_finish_compilation:
1975 /* Language-specific end of compilation actions. */
1979 /* Close the dump files. */
1981 if (flag_gen_aux_info)
1983 fclose (aux_info_file);
1985 unlink (aux_info_file_name);
1989 fclose (rtl_dump_file);
1992 fclose (jump_opt_dump_file);
1995 fclose (cse_dump_file);
1998 fclose (loop_dump_file);
2001 fclose (cse2_dump_file);
2004 fclose (flow_dump_file);
2008 dump_combine_total_stats (combine_dump_file);
2009 fclose (combine_dump_file);
2013 fclose (sched_dump_file);
2016 fclose (local_reg_dump_file);
2018 if (global_reg_dump)
2019 fclose (global_reg_dump_file);
2022 fclose (sched2_dump_file);
2025 fclose (jump2_opt_dump_file);
2028 fclose (dbr_sched_dump_file);
2032 fclose (stack_reg_dump_file);
2035 /* Close non-debugging input and output files. Take special care to note
2036 whether fclose returns an error, since the pages might still be on the
2037 buffer chain while the file is open. */
2040 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2041 fatal_io_error (asm_file_name);
2043 /* Print the times. */
2047 fprintf (stderr,"\n");
2048 print_time ("parse", parse_time);
2049 print_time ("integration", integration_time);
2050 print_time ("jump", jump_time);
2051 print_time ("cse", cse_time);
2052 print_time ("loop", loop_time);
2053 print_time ("cse2", cse2_time);
2054 print_time ("flow", flow_time);
2055 print_time ("combine", combine_time);
2056 print_time ("sched", sched_time);
2057 print_time ("local-alloc", local_alloc_time);
2058 print_time ("global-alloc", global_alloc_time);
2059 print_time ("sched2", sched2_time);
2060 print_time ("dbranch", dbr_sched_time);
2061 print_time ("shorten-branch", shorten_branch_time);
2062 print_time ("stack-reg", stack_reg_time);
2063 print_time ("final", final_time);
2064 print_time ("varconst", varconst_time);
2065 print_time ("symout", symout_time);
2066 print_time ("dump", dump_time);
2070 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2071 and TYPE_DECL nodes.
2073 This does nothing for local (non-static) variables.
2074 Otherwise, it sets up the RTL and outputs any assembler code
2075 (label definition, storage allocation and initialization).
2077 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2078 the assembler symbol name to be used. TOP_LEVEL is nonzero
2079 if this declaration is not within a function. */
2082 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2088 /* Declarations of variables, and of functions defined elsewhere. */
2090 /* Forward declarations for nested functions are not "external",
2091 but we need to treat them as if they were. */
2092 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2093 || TREE_CODE (decl) == FUNCTION_DECL)
2094 TIMEVAR (varconst_time,
2096 make_decl_rtl (decl, asmspec, top_level);
2097 /* For a user-invisible decl that should be replaced
2098 by its value when used, don't output anything. */
2099 if (! (TREE_CODE (decl) == VAR_DECL
2100 && DECL_IGNORED_P (decl) && TREE_READONLY (decl)
2101 && DECL_INITIAL (decl) != 0))
2102 /* Don't output anything
2103 when a tentative file-scope definition is seen.
2104 But at end of compilation, do output code for them. */
2105 if (! (! at_end && top_level
2106 && (DECL_INITIAL (decl) == 0
2107 || DECL_INITIAL (decl) == error_mark_node
2108 || DECL_IGNORED_P (decl))))
2109 assemble_variable (decl, top_level, at_end);
2111 else if (DECL_REGISTER (decl) && asmspec != 0)
2113 if (decode_reg_name (asmspec) >= 0)
2115 DECL_RTL (decl) = 0;
2116 make_decl_rtl (decl, asmspec, top_level);
2119 error ("invalid register name `%s' for register variable", asmspec);
2121 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2122 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2123 && TREE_CODE (decl) == TYPE_DECL)
2124 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2126 #ifdef SDB_DEBUGGING_INFO
2127 else if (write_symbols == SDB_DEBUG && top_level
2128 && TREE_CODE (decl) == TYPE_DECL)
2129 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2133 /* Called after finishing a record, union or enumeral type. */
2136 rest_of_type_compilation (type, toplev)
2140 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2141 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2142 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2144 #ifdef SDB_DEBUGGING_INFO
2145 if (write_symbols == SDB_DEBUG)
2146 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2150 /* This is called from finish_function (within yyparse)
2151 after each top-level definition is parsed.
2152 It is supposed to compile that function or variable
2153 and output the assembler code for it.
2154 After we return, the tree storage is freed. */
2157 rest_of_compilation (decl)
2161 int start_time = get_run_time ();
2163 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2164 to be restored after we finish compiling the function
2165 (for use when compiling inline calls to this function). */
2166 tree saved_block_tree = 0;
2167 /* Likewise, for DECL_ARGUMENTS. */
2168 tree saved_arguments = 0;
2171 /* If we are reconsidering an inline function
2172 at the end of compilation, skip the stuff for making it inline. */
2174 if (DECL_SAVED_INSNS (decl) == 0)
2176 int specd = DECL_INLINE (decl);
2179 /* If requested, consider whether to make this function inline. */
2180 if (specd || flag_inline_functions)
2181 TIMEVAR (integration_time,
2183 lose = function_cannot_inline_p (decl);
2186 if (warn_inline && specd)
2187 warning_with_decl (decl, lose);
2188 DECL_INLINE (decl) = 0;
2191 DECL_INLINE (decl) = 1;
2194 insns = get_insns ();
2196 /* Dump the rtl code if we are dumping rtl. */
2201 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2202 IDENTIFIER_POINTER (DECL_NAME (decl)));
2203 if (DECL_SAVED_INSNS (decl))
2204 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2205 print_rtl (rtl_dump_file, insns);
2206 fflush (rtl_dump_file);
2209 /* If function is inline, and we don't yet know whether to
2210 compile it by itself, defer decision till end of compilation.
2211 finish_compilation will call rest_of_compilation again
2212 for those functions that need to be output. */
2214 if (DECL_INLINE (decl)
2215 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2216 && ! flag_keep_inline_functions)
2217 || DECL_EXTERNAL (decl)))
2219 #ifdef DWARF_DEBUGGING_INFO
2220 /* Generate the DWARF info for the "abstract" instance
2221 of a function which we may later generate inlined and/or
2222 out-of-line instances of. */
2223 if (write_symbols == DWARF_DEBUG)
2225 set_decl_abstract_flags (decl, 1);
2226 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2227 set_decl_abstract_flags (decl, 0);
2230 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2231 goto exit_rest_of_compilation;
2234 /* If we have to compile the function now, save its rtl and subdecls
2235 so that its compilation will not affect what others get. */
2236 if (DECL_INLINE (decl))
2238 #ifdef DWARF_DEBUGGING_INFO
2239 /* Generate the DWARF info for the "abstract" instance of
2240 a function which we will generate an out-of-line instance
2241 of almost immediately (and which we may also later generate
2242 various inlined instances of). */
2243 if (write_symbols == DWARF_DEBUG)
2245 set_decl_abstract_flags (decl, 1);
2246 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2247 set_decl_abstract_flags (decl, 0);
2250 saved_block_tree = DECL_INITIAL (decl);
2251 saved_arguments = DECL_ARGUMENTS (decl);
2252 TIMEVAR (integration_time, save_for_inline_copying (decl));
2256 TREE_ASM_WRITTEN (decl) = 1;
2258 /* Now that integrate will no longer see our rtl, we need not distinguish
2259 between the return value of this function and the return value of called
2261 rtx_equal_function_value_matters = 0;
2263 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2264 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2266 goto exit_rest_of_compilation;
2269 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2270 Note that that may have been done above, in save_for_inline_copying.
2271 The call to resume_temporary_allocation near the end of this function
2272 goes back to the usual state of affairs. */
2274 rtl_in_current_obstack ();
2277 /* If we are doing position-independent code generation, now
2278 is the time to output special prologues and epilogues.
2279 We do not want to do this earlier, because it just clutters
2280 up inline functions with meaningless insns. */
2285 insns = get_insns ();
2287 /* Copy any shared structure that should not be shared. */
2289 unshare_all_rtl (insns);
2291 /* Instantiate all virtual registers. */
2293 instantiate_virtual_regs (current_function_decl, get_insns ());
2295 /* See if we have allocated stack slots that are not directly addressable.
2296 If so, scan all the insns and create explicit address computation
2297 for all references to such slots. */
2298 /* fixup_stack_slots (); */
2300 /* Do jump optimization the first time, if -opt.
2301 Also do it if -W, but in that case it doesn't change the rtl code,
2302 it only computes whether control can drop off the end of the function. */
2304 if (optimize > 0 || extra_warnings || warn_return_type
2305 /* If function is `volatile', we should warn if it tries to return. */
2306 || TREE_THIS_VOLATILE (decl))
2308 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2309 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2312 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2313 if (rtl_dump_and_exit || flag_syntax_only)
2314 goto exit_rest_of_compilation;
2316 /* Dump rtl code after jump, if we are doing that. */
2321 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2322 IDENTIFIER_POINTER (DECL_NAME (decl)));
2323 print_rtl (jump_opt_dump_file, insns);
2324 fflush (jump_opt_dump_file);
2327 /* Perform common subexpression elimination.
2328 Nonzero value from `cse_main' means that jumps were simplified
2329 and some code may now be unreachable, so do
2330 jump optimization again. */
2335 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2336 IDENTIFIER_POINTER (DECL_NAME (decl)));
2341 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2343 if (flag_thread_jumps)
2344 /* Hacks by tiemann & kenner. */
2345 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2347 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2349 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2352 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2355 /* Dump rtl code after cse, if we are doing that. */
2360 print_rtl (cse_dump_file, insns);
2361 fflush (cse_dump_file);
2367 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2368 IDENTIFIER_POINTER (DECL_NAME (decl)));
2371 /* Move constant computations out of loops. */
2377 loop_optimize (insns, loop_dump_file);
2381 /* Dump rtl code after loop opt, if we are doing that. */
2386 print_rtl (loop_dump_file, insns);
2387 fflush (loop_dump_file);
2393 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2394 IDENTIFIER_POINTER (DECL_NAME (decl)));
2397 if (optimize > 0 && flag_rerun_cse_after_loop)
2399 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2401 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2402 1, cse2_dump_file));
2404 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2407 if (optimize > 0 && flag_thread_jumps)
2408 /* This pass of jump threading straightens out code
2409 that was kinked by loop optimization. */
2410 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2412 /* Dump rtl code after cse, if we are doing that. */
2417 print_rtl (cse2_dump_file, insns);
2418 fflush (cse2_dump_file);
2421 /* We are no longer anticipating cse in this function, at least. */
2423 cse_not_expected = 1;
2425 /* Now we choose between stupid (pcc-like) register allocation
2426 (if we got the -noreg switch and not -opt)
2427 and smart register allocation. */
2429 if (optimize > 0) /* Stupid allocation probably won't work */
2430 obey_regdecls = 0; /* if optimizations being done. */
2434 /* Print function header into flow dump now
2435 because doing the flow analysis makes some of the dump. */
2440 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2441 IDENTIFIER_POINTER (DECL_NAME (decl)));
2448 regclass (insns, max_reg_num ());
2449 stupid_life_analysis (insns, max_reg_num (),
2455 /* Do control and data flow analysis,
2456 and write some of the results to dump file. */
2458 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2460 if (warn_uninitialized)
2462 uninitialized_vars_warning (DECL_INITIAL (decl));
2463 setjmp_args_warning ();
2467 /* Dump rtl after flow analysis. */
2472 print_rtl (flow_dump_file, insns);
2473 fflush (flow_dump_file);
2476 /* If -opt, try combining insns through substitution. */
2479 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2481 /* Dump rtl code after insn combination. */
2486 fprintf (combine_dump_file, "\n;; Function %s\n\n",
2487 IDENTIFIER_POINTER (DECL_NAME (decl)));
2488 dump_combine_stats (combine_dump_file);
2489 print_rtl (combine_dump_file, insns);
2490 fflush (combine_dump_file);
2493 /* Print function header into sched dump now
2494 because doing the sched analysis makes some of the dump. */
2499 fprintf (sched_dump_file, "\n;; Function %s\n\n",
2500 IDENTIFIER_POINTER (DECL_NAME (decl)));
2503 if (optimize > 0 && flag_schedule_insns)
2505 /* Do control and data sched analysis,
2506 and write some of the results to dump file. */
2508 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
2511 /* Dump rtl after instruction scheduling. */
2516 print_rtl (sched_dump_file, insns);
2517 fflush (sched_dump_file);
2520 /* Unless we did stupid register allocation,
2521 allocate pseudo-regs that are used only within 1 basic block. */
2524 TIMEVAR (local_alloc_time,
2526 regclass (insns, max_reg_num ());
2530 /* Dump rtl code after allocating regs within basic blocks. */
2535 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
2536 IDENTIFIER_POINTER (DECL_NAME (decl)));
2537 dump_flow_info (local_reg_dump_file);
2538 dump_local_alloc (local_reg_dump_file);
2539 print_rtl (local_reg_dump_file, insns);
2540 fflush (local_reg_dump_file);
2543 if (global_reg_dump)
2545 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
2546 IDENTIFIER_POINTER (DECL_NAME (decl))));
2548 /* Unless we did stupid register allocation,
2549 allocate remaining pseudo-regs, then do the reload pass
2550 fixing up any insns that are invalid. */
2552 TIMEVAR (global_alloc_time,
2555 failure = global_alloc (global_reg_dump_file);
2557 failure = reload (insns, 0, global_reg_dump_file);
2560 if (global_reg_dump)
2563 dump_global_regs (global_reg_dump_file);
2564 print_rtl (global_reg_dump_file, insns);
2565 fflush (global_reg_dump_file);
2569 goto exit_rest_of_compilation;
2571 reload_completed = 1;
2573 /* On some machines, the prologue and epilogue code, or parts thereof,
2574 can be represented as RTL. Doing so lets us schedule insns between
2575 it and the rest of the code and also allows delayed branch
2576 scheduling to operate in the epilogue. */
2578 thread_prologue_and_epilogue_insns (insns);
2580 if (optimize > 0 && flag_schedule_insns_after_reload)
2585 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
2586 IDENTIFIER_POINTER (DECL_NAME (decl)));
2589 /* Do control and data sched analysis again,
2590 and write some more of the results to dump file. */
2592 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
2594 /* Dump rtl after post-reorder instruction scheduling. */
2599 print_rtl (sched2_dump_file, insns);
2600 fflush (sched2_dump_file);
2604 #ifdef LEAF_REGISTERS
2606 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
2610 /* One more attempt to remove jumps to .+1
2611 left by dead-store-elimination.
2612 Also do cross-jumping this time
2613 and delete no-op move insns. */
2617 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
2620 /* Dump rtl code after jump, if we are doing that. */
2625 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
2626 IDENTIFIER_POINTER (DECL_NAME (decl)));
2627 print_rtl (jump2_opt_dump_file, insns);
2628 fflush (jump2_opt_dump_file);
2631 /* If a scheduling pass for delayed branches is to be done,
2632 call the scheduling code. */
2635 if (optimize > 0 && flag_delayed_branch)
2637 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
2642 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
2643 IDENTIFIER_POINTER (DECL_NAME (decl)));
2644 print_rtl (dbr_sched_dump_file, insns);
2645 fflush (dbr_sched_dump_file);
2652 /* Shorten branches. */
2653 TIMEVAR (shorten_branch_time,
2655 shorten_branches (get_insns ());
2659 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
2664 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
2665 IDENTIFIER_POINTER (DECL_NAME (decl)));
2666 print_rtl (stack_reg_dump_file, insns);
2667 fflush (stack_reg_dump_file);
2672 /* Now turn the rtl into assembler code. */
2674 TIMEVAR (final_time,
2679 /* Get the function's name, as described by its RTL.
2680 This may be different from the DECL_NAME name used
2681 in the source file. */
2683 x = DECL_RTL (decl);
2684 if (GET_CODE (x) != MEM)
2687 if (GET_CODE (x) != SYMBOL_REF)
2689 fnname = XSTR (x, 0);
2691 assemble_start_function (decl, fnname);
2692 final_start_function (insns, asm_out_file, optimize);
2693 final (insns, asm_out_file, optimize, 0);
2694 final_end_function (insns, asm_out_file, optimize);
2695 assemble_end_function (decl, fnname);
2696 fflush (asm_out_file);
2699 /* Write DBX symbols if requested */
2701 /* Note that for those inline functions where we don't initially
2702 know for certain that we will be generating an out-of-line copy,
2703 the first invocation of this routine (rest_of_compilation) will
2704 skip over this code by doing a `goto exit_rest_of_compilation;'.
2705 Later on, finish_compilation will call rest_of_compilation again
2706 for those inline functions that need to have out-of-line copies
2707 generated. During that call, we *will* be routed past here. */
2709 #ifdef DBX_DEBUGGING_INFO
2710 if (write_symbols == DBX_DEBUG)
2711 TIMEVAR (symout_time, dbxout_function (decl));
2714 #ifdef DWARF_DEBUGGING_INFO
2715 if (write_symbols == DWARF_DEBUG)
2716 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2719 exit_rest_of_compilation:
2721 /* In case the function was not output,
2722 don't leave any temporary anonymous types
2723 queued up for sdb output. */
2724 #ifdef SDB_DEBUGGING_INFO
2725 if (write_symbols == SDB_DEBUG)
2726 sdbout_types (NULL_TREE);
2729 /* Put back the tree of subblocks and list of arguments
2730 from before we copied them.
2731 Code generation and the output of debugging info may have modified
2732 the copy, but the original is unchanged. */
2734 if (saved_block_tree != 0)
2735 DECL_INITIAL (decl) = saved_block_tree;
2736 if (saved_arguments != 0)
2737 DECL_ARGUMENTS (decl) = saved_arguments;
2739 reload_completed = 0;
2741 /* Clear out the real_constant_chain before some of the rtx's
2742 it runs through become garbage. */
2744 clear_const_double_mem ();
2746 /* Cancel the effect of rtl_in_current_obstack. */
2748 resume_temporary_allocation ();
2750 /* The parsing time is all the time spent in yyparse
2751 *except* what is spent in this function. */
2753 parse_time -= get_run_time () - start_time;
2756 /* Entry point of cc1/c++. Decode command args, then call compile_file.
2757 Exit code is 35 if can't open files, 34 if fatal error,
2758 33 if had nonfatal errors, else success. */
2761 main (argc, argv, envp)
2768 int flag_print_mem = 0;
2769 int version_flag = 0;
2772 /* save in case md file wants to emit args as a comment. */
2776 p = argv[0] + strlen (argv[0]);
2777 while (p != argv[0] && p[-1] != '/') --p;
2781 /* Get rid of any avoidable limit on stack size. */
2785 /* Set the stack limit huge so that alloca does not fail. */
2786 getrlimit (RLIMIT_STACK, &rlim);
2787 rlim.rlim_cur = rlim.rlim_max;
2788 setrlimit (RLIMIT_STACK, &rlim);
2790 #endif /* RLIMIT_STACK */
2792 signal (SIGFPE, float_signal);
2794 signal (SIGPIPE, pipe_closed);
2796 decl_printable_name = decl_name;
2797 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
2799 /* Initialize whether `char' is signed. */
2800 flag_signed_char = DEFAULT_SIGNED_CHAR;
2801 #ifdef DEFAULT_SHORT_ENUMS
2802 /* Initialize how much space enums occupy, by default. */
2803 flag_short_enums = DEFAULT_SHORT_ENUMS;
2806 /* Scan to see what optimization level has been specified. That will
2807 determine the default value of many flags. */
2808 for (i = 1; i < argc; i++)
2810 if (!strcmp (argv[i], "-O"))
2814 else if (argv[i][0] == '-' && argv[i][1] == 'O')
2816 /* Handle -O2, -O3, -O69, ... */
2817 char *p = &argv[i][2];
2821 if (! (c >= '0' && c <= '9'))
2824 optimize = atoi (&argv[i][2]);
2828 obey_regdecls = (optimize == 0);
2837 flag_thread_jumps = 1;
2839 flag_delayed_branch = 1;
2845 flag_cse_follow_jumps = 1;
2846 flag_cse_skip_blocks = 1;
2847 flag_expensive_optimizations = 1;
2848 flag_strength_reduce = 1;
2849 flag_rerun_cse_after_loop = 1;
2850 flag_caller_saves = 1;
2851 #ifdef INSN_SCHEDULING
2852 flag_schedule_insns = 1;
2853 flag_schedule_insns_after_reload = 1;
2857 #ifdef OPTIMIZATION_OPTIONS
2858 /* Allow default optimizations to be specified on a per-machine basis. */
2859 OPTIMIZATION_OPTIONS (optimize);
2862 /* Initialize register usage now so switches may override. */
2866 set_target_switch ("");
2868 for (i = 1; i < argc; i++)
2871 /* If this is a language-specific option,
2872 decode it in a language-specific way. */
2873 for (j = 0; lang_options[j] != 0; j++)
2874 if (!strncmp (argv[i], lang_options[j],
2875 strlen (lang_options[j])))
2877 if (lang_options[j] != 0)
2878 /* If the option is valid for *some* language,
2879 treat it as valid even if this language doesn't understand it. */
2880 lang_decode_option (argv[i]);
2881 else if (argv[i][0] == '-' && argv[i][1] != 0)
2883 register char *str = argv[i] + 1;
2888 set_target_switch (&str[1]);
2889 else if (!strcmp (str, "dumpbase"))
2891 dump_base_name = argv[++i];
2893 else if (str[0] == 'd')
2895 register char *p = &str[1];
2903 global_reg_dump = 1;
2909 cse_dump = 1, cse2_dump = 1;
2927 global_reg_dump = 1;
2945 flag_print_asm_name = 1;
2967 rtl_dump_and_exit = 1;
2971 else if (str[0] == 'f')
2973 register char *p = &str[1];
2976 /* Some kind of -f option.
2977 P's value is the option sans `-f'.
2978 Search for it in the table of options. */
2981 !found && j < sizeof (f_options) / sizeof (f_options[0]);
2984 if (!strcmp (p, f_options[j].string))
2986 *f_options[j].variable = f_options[j].on_value;
2987 /* A goto here would be cleaner,
2988 but breaks the vax pcc. */
2991 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
2992 && ! strcmp (p+3, f_options[j].string))
2994 *f_options[j].variable = ! f_options[j].on_value;
3001 else if (!strncmp (p, "fixed-", 6))
3002 fix_register (&p[6], 1, 1);
3003 else if (!strncmp (p, "call-used-", 10))
3004 fix_register (&p[10], 0, 1);
3005 else if (!strncmp (p, "call-saved-", 11))
3006 fix_register (&p[11], 0, 0);
3008 error ("Invalid option `%s'", argv[i]);
3010 else if (str[0] == 'O')
3012 register char *p = str+1;
3013 while (*p && *p >= '0' && *p <= '9')
3018 error ("Invalid option `%s'", argv[i]);
3020 else if (!strcmp (str, "pedantic"))
3022 else if (!strcmp (str, "pedantic-errors"))
3023 flag_pedantic_errors = pedantic = 1;
3024 else if (!strcmp (str, "quiet"))
3026 else if (!strcmp (str, "version"))
3028 else if (!strcmp (str, "w"))
3029 inhibit_warnings = 1;
3030 else if (!strcmp (str, "W"))
3033 warn_uninitialized = 1;
3035 else if (str[0] == 'W')
3037 register char *p = &str[1];
3040 /* Some kind of -W option.
3041 P's value is the option sans `-W'.
3042 Search for it in the table of options. */
3045 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3048 if (!strcmp (p, W_options[j].string))
3050 *W_options[j].variable = W_options[j].on_value;
3051 /* A goto here would be cleaner,
3052 but breaks the vax pcc. */
3055 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3056 && ! strcmp (p+3, W_options[j].string))
3058 *W_options[j].variable = ! W_options[j].on_value;
3065 else if (!strncmp (p, "id-clash-", 9))
3071 if (*endp >= '0' && *endp <= '9')
3075 error ("Invalid option `%s'", argv[i]);
3080 id_clash_len = atoi (str + 10);
3084 error ("Invalid option `%s'", argv[i]);
3086 else if (!strcmp (str, "p"))
3088 else if (!strcmp (str, "a"))
3090 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3091 warning ("`-a' option (basic block profile) not supported");
3093 profile_block_flag = 1;
3096 else if (str[0] == 'g')
3103 while (*p && (*p < '0' || *p > '9'))
3107 while (*q && (*q >= '0' && *q <= '9'))
3112 level = 2; /* default debugging info level */
3113 if (*q || level > 3)
3115 warning ("invalid debug level specification in option: `-%s'",
3117 warning ("no debugging information will be generated");
3121 /* If more than one debugging type is supported,
3122 you must define PREFERRED_DEBUGGING_TYPE
3123 to choose a format in a system-dependent way. */
3124 /* This is one long line cause VAXC can't handle a \-newline. */
3125 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3126 #ifdef PREFERRED_DEBUGGING_TYPE
3127 if (!strncmp (str, "ggdb", len))
3128 write_symbols = PREFERRED_DEBUGGING_TYPE;
3129 #else /* no PREFERRED_DEBUGGING_TYPE */
3130 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3131 #endif /* no PREFERRED_DEBUGGING_TYPE */
3132 #endif /* More than one debugger format enabled. */
3133 #ifdef DBX_DEBUGGING_INFO
3134 if (write_symbols != NO_DEBUG)
3136 else if (!strncmp (str, "ggdb", len))
3137 write_symbols = DBX_DEBUG;
3138 else if (!strncmp (str, "gstabs", len))
3139 write_symbols = DBX_DEBUG;
3140 else if (!strncmp (str, "gstabs+", len))
3141 write_symbols = DBX_DEBUG;
3143 /* Always enable extensions for -ggdb or -gstabs+,
3144 always disable for -gstabs.
3145 For plain -g, use system-specific default. */
3146 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3148 use_gnu_debug_info_extensions = 1;
3149 else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
3151 use_gnu_debug_info_extensions = 1;
3152 else if (write_symbols == DBX_DEBUG
3153 && !strncmp (str, "gstabs", len) && len >= 2)
3154 use_gnu_debug_info_extensions = 0;
3156 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3157 #endif /* DBX_DEBUGGING_INFO */
3158 #ifdef DWARF_DEBUGGING_INFO
3159 if (write_symbols != NO_DEBUG)
3161 else if (!strncmp (str, "g", len))
3162 write_symbols = DWARF_DEBUG;
3163 else if (!strncmp (str, "ggdb", len))
3164 write_symbols = DWARF_DEBUG;
3165 else if (!strncmp (str, "gdwarf", len))
3166 write_symbols = DWARF_DEBUG;
3168 /* Always enable extensions for -ggdb or -gdwarf+,
3169 always disable for -gdwarf.
3170 For plain -g, use system-specific default. */
3171 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3173 use_gnu_debug_info_extensions = 1;
3174 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3175 use_gnu_debug_info_extensions = 1;
3176 else if (write_symbols == DWARF_DEBUG
3177 && !strncmp (str, "gdwarf", len) && len >= 2)
3178 use_gnu_debug_info_extensions = 0;
3180 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3182 #ifdef SDB_DEBUGGING_INFO
3183 if (write_symbols != NO_DEBUG)
3185 else if (!strncmp (str, "g", len))
3186 write_symbols = SDB_DEBUG;
3187 else if (!strncmp (str, "gdb", len))
3188 write_symbols = SDB_DEBUG;
3189 else if (!strncmp (str, "gcoff", len))
3190 write_symbols = SDB_DEBUG;
3191 #endif /* SDB_DEBUGGING_INFO */
3192 #ifdef XCOFF_DEBUGGING_INFO
3193 if (write_symbols != NO_DEBUG)
3195 else if (!strncmp (str, "g", len))
3196 write_symbols = XCOFF_DEBUG;
3197 else if (!strncmp (str, "ggdb", len))
3198 write_symbols = XCOFF_DEBUG;
3199 else if (!strncmp (str, "gxcoff", len))
3200 write_symbols = XCOFF_DEBUG;
3202 /* Always enable extensions for -ggdb or -gxcoff+,
3203 always disable for -gxcoff.
3204 For plain -g, use system-specific default. */
3205 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3207 use_gnu_debug_info_extensions = 1;
3208 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3209 use_gnu_debug_info_extensions = 1;
3210 else if (write_symbols == XCOFF_DEBUG
3211 && !strncmp (str, "gxcoff", len) && len >= 2)
3212 use_gnu_debug_info_extensions = 0;
3214 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3216 if (write_symbols == NO_DEBUG)
3217 warning ("`-%s' option not supported on this version of GCC", str);
3218 else if (level == 0)
3219 write_symbols = NO_DEBUG;
3221 debug_info_level = (enum debug_info_level) level;
3223 else if (!strcmp (str, "o"))
3225 asm_file_name = argv[++i];
3227 else if (str[0] == 'G')
3229 g_switch_set = TRUE;
3230 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3232 else if (!strncmp (str, "aux-info", 8))
3234 flag_gen_aux_info = 1;
3235 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3238 error ("Invalid option `%s'", argv[i]);
3240 else if (argv[i][0] == '+')
3241 error ("Invalid option `%s'", argv[i]);
3248 /* Inlining does not work if not optimizing,
3249 so force it not to be done. */
3253 /* The c_decode_option and lang_decode_option functions set
3254 this to `2' if -Wall is used, so we can avoid giving out
3255 lots of errors for people who don't realize what -Wall does. */
3256 if (warn_uninitialized == 1)
3257 warning ("-Wuninitialized is not supported without -O");
3260 #ifdef OVERRIDE_OPTIONS
3261 /* Some machines may reject certain combinations of options. */
3265 /* Unrolling all loops implies that standard loop unrolling must also
3267 if (flag_unroll_all_loops)
3268 flag_unroll_loops = 1;
3269 /* Loop unrolling requires that strength_reduction be on also. Silently
3270 turn on strength reduction here if it isn't already on. Also, the loop
3271 unrolling code assumes that cse will be run after loop, so that must
3272 be turned on also. */
3273 if (flag_unroll_loops)
3275 flag_strength_reduce = 1;
3276 flag_rerun_cse_after_loop = 1;
3279 /* Warn about options that are not supported on this machine. */
3280 #ifndef INSN_SCHEDULING
3281 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3282 warning ("instruction scheduling not supported on this target machine");
3285 if (flag_delayed_branch)
3286 warning ("this target machine does not have delayed branches");
3289 /* If we are in verbose mode, write out the version and maybe all the
3290 option flags in use. */
3293 fprintf (stderr, "%s version %s", language_string, version_string);
3294 #ifdef TARGET_VERSION
3299 #define __VERSION__ "[unknown]"
3301 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3303 fprintf (stderr, " compiled by CC.\n");
3306 print_switch_values ();
3309 /* Now that register usage is specified, convert it to HARD_REG_SETs. */
3312 compile_file (filename);
3318 char *lim = (char *) sbrk (0);
3320 fprintf (stderr, "Data size %d.\n",
3321 lim - (char *) &environ);
3325 system ("ps -l 1>&2");
3328 #endif /* not USG */
3330 #endif /* not VMS */
3331 #endif /* not OS2 */
3334 exit (FATAL_EXIT_CODE);
3336 exit (FATAL_EXIT_CODE);
3337 exit (SUCCESS_EXIT_CODE);
3341 /* Decode -m switches. */
3343 /* Here is a table, controlled by the tm.h file, listing each -m switch
3344 and which bits in `target_switches' it should set or clear.
3345 If VALUE is positive, it is bits to set.
3346 If VALUE is negative, -VALUE is bits to clear.
3347 (The sign bit is not used so there is no confusion.) */
3349 struct {char *name; int value;} target_switches []
3352 /* This table is similar, but allows the switch to have a value. */
3354 #ifdef TARGET_OPTIONS
3355 struct {char *prefix; char ** variable;} target_options []
3359 /* Decode the switch -mNAME. */
3362 set_target_switch (name)
3368 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3369 if (!strcmp (target_switches[j].name, name))
3371 if (target_switches[j].value < 0)
3372 target_flags &= ~-target_switches[j].value;
3374 target_flags |= target_switches[j].value;
3378 #ifdef TARGET_OPTIONS
3380 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3382 int len = strlen (target_options[j].prefix);
3383 if (!strncmp (target_options[j].prefix, name, len))
3385 *target_options[j].variable = name + len;
3392 error ("Invalid option `%s'", name);
3395 /* Variable used for communication between the following two routines. */
3397 static int line_position;
3399 /* Print an option value and adjust the position in the line. */
3402 print_single_switch (type, name)
3405 fprintf (stderr, " %s%s", type, name);
3407 line_position += strlen (type) + strlen (name) + 1;
3409 if (line_position > 65)
3411 fprintf (stderr, "\n\t");
3416 /* Print default target switches for -version. */
3419 print_switch_values ()
3423 fprintf (stderr, "enabled:");
3426 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3427 if (*f_options[j].variable == f_options[j].on_value)
3428 print_single_switch ("-f", f_options[j].string);
3430 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
3431 if (*W_options[j].variable == W_options[j].on_value)
3432 print_single_switch ("-W", W_options[j].string);
3434 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3435 if (target_switches[j].name[0] != '\0'
3436 && target_switches[j].value > 0
3437 && ((target_switches[j].value & target_flags)
3438 == target_switches[j].value))
3439 print_single_switch ("-m", target_switches[j].name);
3441 fprintf (stderr, "\n");