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))
1890 pedwarn_with_decl (decl, "`%s' declared `static' but never defined");
1891 /* Warn about static fns or vars defined but not used,
1892 but not about inline functions
1893 since unused inline statics is normal practice. */
1895 && (TREE_CODE (decl) == FUNCTION_DECL
1896 || TREE_CODE (decl) == VAR_DECL)
1897 && ! DECL_IN_SYSTEM_HEADER (decl)
1898 && ! DECL_EXTERNAL (decl)
1899 && ! TREE_PUBLIC (decl)
1900 && ! TREE_USED (decl)
1901 && ! DECL_INLINE (decl)
1902 && ! DECL_REGISTER (decl)
1903 /* The TREE_USED bit for file-scope decls
1904 is kept in the identifier, to handle multiple
1905 external decls in different scopes. */
1906 && ! TREE_USED (DECL_NAME (decl)))
1907 warning_with_decl (decl, "`%s' defined but not used");
1909 #ifdef SDB_DEBUGGING_INFO
1910 /* The COFF linker can move initialized global vars to the end.
1911 And that can screw up the symbol ordering.
1912 By putting the symbols in that order to begin with,
1913 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1914 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
1915 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
1916 && DECL_RTL (decl) != 0)
1917 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1919 /* Output COFF information for non-global
1920 file-scope initialized variables. */
1921 if (write_symbols == SDB_DEBUG
1922 && TREE_CODE (decl) == VAR_DECL
1923 && DECL_INITIAL (decl)
1924 && DECL_RTL (decl) != 0
1925 && GET_CODE (DECL_RTL (decl)) == MEM)
1926 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
1927 #endif /* SDB_DEBUGGING_INFO */
1928 #ifdef DWARF_DEBUGGING_INFO
1929 /* Output DWARF information for file-scope tentative data object
1930 declarations, file-scope (extern) function declarations (which
1931 had no corresponding body) and file-scope tagged type declarations
1932 and definitions which have not yet been forced out. */
1934 if (write_symbols == DWARF_DEBUG
1935 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1936 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
1941 /* Do dbx symbols */
1942 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1943 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1944 TIMEVAR (symout_time,
1946 dbxout_finish (asm_out_file, main_input_filename);
1950 #ifdef DWARF_DEBUGGING_INFO
1951 if (write_symbols == DWARF_DEBUG)
1952 TIMEVAR (symout_time,
1958 /* Output some stuff at end of file if nec. */
1960 end_final (main_input_filename);
1963 ASM_FILE_END (asm_out_file);
1966 after_finish_compilation:
1968 /* Language-specific end of compilation actions. */
1972 /* Close the dump files. */
1974 if (flag_gen_aux_info)
1976 fclose (aux_info_file);
1978 unlink (aux_info_file_name);
1982 fclose (rtl_dump_file);
1985 fclose (jump_opt_dump_file);
1988 fclose (cse_dump_file);
1991 fclose (loop_dump_file);
1994 fclose (cse2_dump_file);
1997 fclose (flow_dump_file);
2001 dump_combine_total_stats (combine_dump_file);
2002 fclose (combine_dump_file);
2006 fclose (sched_dump_file);
2009 fclose (local_reg_dump_file);
2011 if (global_reg_dump)
2012 fclose (global_reg_dump_file);
2015 fclose (sched2_dump_file);
2018 fclose (jump2_opt_dump_file);
2021 fclose (dbr_sched_dump_file);
2025 fclose (stack_reg_dump_file);
2028 /* Close non-debugging input and output files. Take special care to note
2029 whether fclose returns an error, since the pages might still be on the
2030 buffer chain while the file is open. */
2033 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2034 fatal_io_error (asm_file_name);
2036 /* Print the times. */
2040 fprintf (stderr,"\n");
2041 print_time ("parse", parse_time);
2042 print_time ("integration", integration_time);
2043 print_time ("jump", jump_time);
2044 print_time ("cse", cse_time);
2045 print_time ("loop", loop_time);
2046 print_time ("cse2", cse2_time);
2047 print_time ("flow", flow_time);
2048 print_time ("combine", combine_time);
2049 print_time ("sched", sched_time);
2050 print_time ("local-alloc", local_alloc_time);
2051 print_time ("global-alloc", global_alloc_time);
2052 print_time ("sched2", sched2_time);
2053 print_time ("dbranch", dbr_sched_time);
2054 print_time ("shorten-branch", shorten_branch_time);
2055 print_time ("stack-reg", stack_reg_time);
2056 print_time ("final", final_time);
2057 print_time ("varconst", varconst_time);
2058 print_time ("symout", symout_time);
2059 print_time ("dump", dump_time);
2063 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2064 and TYPE_DECL nodes.
2066 This does nothing for local (non-static) variables.
2067 Otherwise, it sets up the RTL and outputs any assembler code
2068 (label definition, storage allocation and initialization).
2070 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2071 the assembler symbol name to be used. TOP_LEVEL is nonzero
2072 if this declaration is not within a function. */
2075 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2081 /* Declarations of variables, and of functions defined elsewhere. */
2083 /* Forward declarations for nested functions are not "external",
2084 but we need to treat them as if they were. */
2085 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2086 || TREE_CODE (decl) == FUNCTION_DECL)
2087 TIMEVAR (varconst_time,
2089 make_decl_rtl (decl, asmspec, top_level);
2090 /* For a user-invisible decl that should be replaced
2091 by its value when used, don't output anything. */
2092 if (! (TREE_CODE (decl) == VAR_DECL
2093 && DECL_IGNORED_P (decl) && TREE_READONLY (decl)
2094 && DECL_INITIAL (decl) != 0))
2095 /* Don't output anything
2096 when a tentative file-scope definition is seen.
2097 But at end of compilation, do output code for them. */
2098 if (! (! at_end && top_level
2099 && (DECL_INITIAL (decl) == 0
2100 || DECL_INITIAL (decl) == error_mark_node
2101 || DECL_IGNORED_P (decl))))
2102 assemble_variable (decl, top_level, at_end);
2104 else if (DECL_REGISTER (decl) && asmspec != 0)
2106 if (decode_reg_name (asmspec) >= 0)
2108 DECL_RTL (decl) = 0;
2109 make_decl_rtl (decl, asmspec, top_level);
2112 error ("invalid register name `%s' for register variable", asmspec);
2114 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2115 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2116 && TREE_CODE (decl) == TYPE_DECL)
2117 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2119 #ifdef SDB_DEBUGGING_INFO
2120 else if (write_symbols == SDB_DEBUG && top_level
2121 && TREE_CODE (decl) == TYPE_DECL)
2122 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2126 /* Called after finishing a record, union or enumeral type. */
2129 rest_of_type_compilation (type, toplev)
2133 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2134 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2135 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2137 #ifdef SDB_DEBUGGING_INFO
2138 if (write_symbols == SDB_DEBUG)
2139 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2143 /* This is called from finish_function (within yyparse)
2144 after each top-level definition is parsed.
2145 It is supposed to compile that function or variable
2146 and output the assembler code for it.
2147 After we return, the tree storage is freed. */
2150 rest_of_compilation (decl)
2154 int start_time = get_run_time ();
2156 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2157 to be restored after we finish compiling the function
2158 (for use when compiling inline calls to this function). */
2159 tree saved_block_tree = 0;
2160 /* Likewise, for DECL_ARGUMENTS. */
2161 tree saved_arguments = 0;
2164 /* If we are reconsidering an inline function
2165 at the end of compilation, skip the stuff for making it inline. */
2167 if (DECL_SAVED_INSNS (decl) == 0)
2169 int specd = DECL_INLINE (decl);
2172 /* If requested, consider whether to make this function inline. */
2173 if (specd || flag_inline_functions)
2174 TIMEVAR (integration_time,
2176 lose = function_cannot_inline_p (decl);
2179 if (warn_inline && specd)
2180 warning_with_decl (decl, lose);
2181 DECL_INLINE (decl) = 0;
2184 DECL_INLINE (decl) = 1;
2187 insns = get_insns ();
2189 /* Dump the rtl code if we are dumping rtl. */
2194 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2195 IDENTIFIER_POINTER (DECL_NAME (decl)));
2196 if (DECL_SAVED_INSNS (decl))
2197 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2198 print_rtl (rtl_dump_file, insns);
2199 fflush (rtl_dump_file);
2202 /* If function is inline, and we don't yet know whether to
2203 compile it by itself, defer decision till end of compilation.
2204 finish_compilation will call rest_of_compilation again
2205 for those functions that need to be output. */
2207 if (DECL_INLINE (decl)
2208 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2209 && ! flag_keep_inline_functions)
2210 || DECL_EXTERNAL (decl)))
2212 #ifdef DWARF_DEBUGGING_INFO
2213 /* Generate the DWARF info for the "abstract" instance
2214 of a function which we may later generate inlined and/or
2215 out-of-line instances of. */
2216 if (write_symbols == DWARF_DEBUG)
2218 set_decl_abstract_flags (decl, 1);
2219 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2220 set_decl_abstract_flags (decl, 0);
2223 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2224 goto exit_rest_of_compilation;
2227 /* If we have to compile the function now, save its rtl and subdecls
2228 so that its compilation will not affect what others get. */
2229 if (DECL_INLINE (decl))
2231 #ifdef DWARF_DEBUGGING_INFO
2232 /* Generate the DWARF info for the "abstract" instance of
2233 a function which we will generate an out-of-line instance
2234 of almost immediately (and which we may also later generate
2235 various inlined instances of). */
2236 if (write_symbols == DWARF_DEBUG)
2238 set_decl_abstract_flags (decl, 1);
2239 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2240 set_decl_abstract_flags (decl, 0);
2243 saved_block_tree = DECL_INITIAL (decl);
2244 saved_arguments = DECL_ARGUMENTS (decl);
2245 TIMEVAR (integration_time, save_for_inline_copying (decl));
2249 TREE_ASM_WRITTEN (decl) = 1;
2251 /* Now that integrate will no longer see our rtl, we need not distinguish
2252 between the return value of this function and the return value of called
2254 rtx_equal_function_value_matters = 0;
2256 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2257 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2259 goto exit_rest_of_compilation;
2262 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2263 Note that that may have been done above, in save_for_inline_copying.
2264 The call to resume_temporary_allocation near the end of this function
2265 goes back to the usual state of affairs. */
2267 rtl_in_current_obstack ();
2270 /* If we are doing position-independent code generation, now
2271 is the time to output special prologues and epilogues.
2272 We do not want to do this earlier, because it just clutters
2273 up inline functions with meaningless insns. */
2278 insns = get_insns ();
2280 /* Copy any shared structure that should not be shared. */
2282 unshare_all_rtl (insns);
2284 /* Instantiate all virtual registers. */
2286 instantiate_virtual_regs (current_function_decl, get_insns ());
2288 /* See if we have allocated stack slots that are not directly addressable.
2289 If so, scan all the insns and create explicit address computation
2290 for all references to such slots. */
2291 /* fixup_stack_slots (); */
2293 /* Do jump optimization the first time, if -opt.
2294 Also do it if -W, but in that case it doesn't change the rtl code,
2295 it only computes whether control can drop off the end of the function. */
2297 if (optimize > 0 || extra_warnings || warn_return_type
2298 /* If function is `volatile', we should warn if it tries to return. */
2299 || TREE_THIS_VOLATILE (decl))
2301 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2302 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2305 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2306 if (rtl_dump_and_exit || flag_syntax_only)
2307 goto exit_rest_of_compilation;
2309 /* Dump rtl code after jump, if we are doing that. */
2314 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2315 IDENTIFIER_POINTER (DECL_NAME (decl)));
2316 print_rtl (jump_opt_dump_file, insns);
2317 fflush (jump_opt_dump_file);
2320 /* Perform common subexpression elimination.
2321 Nonzero value from `cse_main' means that jumps were simplified
2322 and some code may now be unreachable, so do
2323 jump optimization again. */
2328 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2329 IDENTIFIER_POINTER (DECL_NAME (decl)));
2334 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2336 if (flag_thread_jumps)
2337 /* Hacks by tiemann & kenner. */
2338 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2340 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2342 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2345 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2348 /* Dump rtl code after cse, if we are doing that. */
2353 print_rtl (cse_dump_file, insns);
2354 fflush (cse_dump_file);
2360 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2361 IDENTIFIER_POINTER (DECL_NAME (decl)));
2364 /* Move constant computations out of loops. */
2370 loop_optimize (insns, loop_dump_file);
2374 /* Dump rtl code after loop opt, if we are doing that. */
2379 print_rtl (loop_dump_file, insns);
2380 fflush (loop_dump_file);
2386 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2387 IDENTIFIER_POINTER (DECL_NAME (decl)));
2390 if (optimize > 0 && flag_rerun_cse_after_loop)
2392 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2394 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2395 1, cse2_dump_file));
2397 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2400 if (optimize > 0 && flag_thread_jumps)
2401 /* This pass of jump threading straightens out code
2402 that was kinked by loop optimization. */
2403 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2405 /* Dump rtl code after cse, if we are doing that. */
2410 print_rtl (cse2_dump_file, insns);
2411 fflush (cse2_dump_file);
2414 /* We are no longer anticipating cse in this function, at least. */
2416 cse_not_expected = 1;
2418 /* Now we choose between stupid (pcc-like) register allocation
2419 (if we got the -noreg switch and not -opt)
2420 and smart register allocation. */
2422 if (optimize > 0) /* Stupid allocation probably won't work */
2423 obey_regdecls = 0; /* if optimizations being done. */
2427 /* Print function header into flow dump now
2428 because doing the flow analysis makes some of the dump. */
2433 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2434 IDENTIFIER_POINTER (DECL_NAME (decl)));
2441 regclass (insns, max_reg_num ());
2442 stupid_life_analysis (insns, max_reg_num (),
2448 /* Do control and data flow analysis,
2449 and write some of the results to dump file. */
2451 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2453 if (warn_uninitialized)
2455 uninitialized_vars_warning (DECL_INITIAL (decl));
2456 setjmp_args_warning ();
2460 /* Dump rtl after flow analysis. */
2465 print_rtl (flow_dump_file, insns);
2466 fflush (flow_dump_file);
2469 /* If -opt, try combining insns through substitution. */
2472 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2474 /* Dump rtl code after insn combination. */
2479 fprintf (combine_dump_file, "\n;; Function %s\n\n",
2480 IDENTIFIER_POINTER (DECL_NAME (decl)));
2481 dump_combine_stats (combine_dump_file);
2482 print_rtl (combine_dump_file, insns);
2483 fflush (combine_dump_file);
2486 /* Print function header into sched dump now
2487 because doing the sched analysis makes some of the dump. */
2492 fprintf (sched_dump_file, "\n;; Function %s\n\n",
2493 IDENTIFIER_POINTER (DECL_NAME (decl)));
2496 if (optimize > 0 && flag_schedule_insns)
2498 /* Do control and data sched analysis,
2499 and write some of the results to dump file. */
2501 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
2504 /* Dump rtl after instruction scheduling. */
2509 print_rtl (sched_dump_file, insns);
2510 fflush (sched_dump_file);
2513 /* Unless we did stupid register allocation,
2514 allocate pseudo-regs that are used only within 1 basic block. */
2517 TIMEVAR (local_alloc_time,
2519 regclass (insns, max_reg_num ());
2523 /* Dump rtl code after allocating regs within basic blocks. */
2528 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
2529 IDENTIFIER_POINTER (DECL_NAME (decl)));
2530 dump_flow_info (local_reg_dump_file);
2531 dump_local_alloc (local_reg_dump_file);
2532 print_rtl (local_reg_dump_file, insns);
2533 fflush (local_reg_dump_file);
2536 if (global_reg_dump)
2538 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
2539 IDENTIFIER_POINTER (DECL_NAME (decl))));
2541 /* Unless we did stupid register allocation,
2542 allocate remaining pseudo-regs, then do the reload pass
2543 fixing up any insns that are invalid. */
2545 TIMEVAR (global_alloc_time,
2548 failure = global_alloc (global_reg_dump_file);
2550 failure = reload (insns, 0, global_reg_dump_file);
2553 if (global_reg_dump)
2556 dump_global_regs (global_reg_dump_file);
2557 print_rtl (global_reg_dump_file, insns);
2558 fflush (global_reg_dump_file);
2562 goto exit_rest_of_compilation;
2564 reload_completed = 1;
2566 /* On some machines, the prologue and epilogue code, or parts thereof,
2567 can be represented as RTL. Doing so lets us schedule insns between
2568 it and the rest of the code and also allows delayed branch
2569 scheduling to operate in the epilogue. */
2571 thread_prologue_and_epilogue_insns (insns);
2573 if (optimize > 0 && flag_schedule_insns_after_reload)
2578 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
2579 IDENTIFIER_POINTER (DECL_NAME (decl)));
2582 /* Do control and data sched analysis again,
2583 and write some more of the results to dump file. */
2585 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
2587 /* Dump rtl after post-reorder instruction scheduling. */
2592 print_rtl (sched2_dump_file, insns);
2593 fflush (sched2_dump_file);
2597 #ifdef LEAF_REGISTERS
2599 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
2603 /* One more attempt to remove jumps to .+1
2604 left by dead-store-elimination.
2605 Also do cross-jumping this time
2606 and delete no-op move insns. */
2610 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
2613 /* Dump rtl code after jump, if we are doing that. */
2618 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
2619 IDENTIFIER_POINTER (DECL_NAME (decl)));
2620 print_rtl (jump2_opt_dump_file, insns);
2621 fflush (jump2_opt_dump_file);
2624 /* If a scheduling pass for delayed branches is to be done,
2625 call the scheduling code. */
2628 if (optimize > 0 && flag_delayed_branch)
2630 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
2635 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
2636 IDENTIFIER_POINTER (DECL_NAME (decl)));
2637 print_rtl (dbr_sched_dump_file, insns);
2638 fflush (dbr_sched_dump_file);
2645 /* Shorten branches. */
2646 TIMEVAR (shorten_branch_time,
2648 shorten_branches (get_insns ());
2652 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
2657 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
2658 IDENTIFIER_POINTER (DECL_NAME (decl)));
2659 print_rtl (stack_reg_dump_file, insns);
2660 fflush (stack_reg_dump_file);
2665 /* Now turn the rtl into assembler code. */
2667 TIMEVAR (final_time,
2672 /* Get the function's name, as described by its RTL.
2673 This may be different from the DECL_NAME name used
2674 in the source file. */
2676 x = DECL_RTL (decl);
2677 if (GET_CODE (x) != MEM)
2680 if (GET_CODE (x) != SYMBOL_REF)
2682 fnname = XSTR (x, 0);
2684 assemble_start_function (decl, fnname);
2685 final_start_function (insns, asm_out_file, optimize);
2686 final (insns, asm_out_file, optimize, 0);
2687 final_end_function (insns, asm_out_file, optimize);
2688 assemble_end_function (decl, fnname);
2689 fflush (asm_out_file);
2692 /* Write DBX symbols if requested */
2694 /* Note that for those inline functions where we don't initially
2695 know for certain that we will be generating an out-of-line copy,
2696 the first invocation of this routine (rest_of_compilation) will
2697 skip over this code by doing a `goto exit_rest_of_compilation;'.
2698 Later on, finish_compilation will call rest_of_compilation again
2699 for those inline functions that need to have out-of-line copies
2700 generated. During that call, we *will* be routed past here. */
2702 #ifdef DBX_DEBUGGING_INFO
2703 if (write_symbols == DBX_DEBUG)
2704 TIMEVAR (symout_time, dbxout_function (decl));
2707 #ifdef DWARF_DEBUGGING_INFO
2708 if (write_symbols == DWARF_DEBUG)
2709 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2712 exit_rest_of_compilation:
2714 /* In case the function was not output,
2715 don't leave any temporary anonymous types
2716 queued up for sdb output. */
2717 #ifdef SDB_DEBUGGING_INFO
2718 if (write_symbols == SDB_DEBUG)
2719 sdbout_types (NULL_TREE);
2722 /* Put back the tree of subblocks and list of arguments
2723 from before we copied them.
2724 Code generation and the output of debugging info may have modified
2725 the copy, but the original is unchanged. */
2727 if (saved_block_tree != 0)
2728 DECL_INITIAL (decl) = saved_block_tree;
2729 if (saved_arguments != 0)
2730 DECL_ARGUMENTS (decl) = saved_arguments;
2732 reload_completed = 0;
2734 /* Clear out the real_constant_chain before some of the rtx's
2735 it runs through become garbage. */
2737 clear_const_double_mem ();
2739 /* Cancel the effect of rtl_in_current_obstack. */
2741 resume_temporary_allocation ();
2743 /* The parsing time is all the time spent in yyparse
2744 *except* what is spent in this function. */
2746 parse_time -= get_run_time () - start_time;
2749 /* Entry point of cc1/c++. Decode command args, then call compile_file.
2750 Exit code is 35 if can't open files, 34 if fatal error,
2751 33 if had nonfatal errors, else success. */
2754 main (argc, argv, envp)
2761 int flag_print_mem = 0;
2762 int version_flag = 0;
2765 /* save in case md file wants to emit args as a comment. */
2769 p = argv[0] + strlen (argv[0]);
2770 while (p != argv[0] && p[-1] != '/') --p;
2774 /* Get rid of any avoidable limit on stack size. */
2778 /* Set the stack limit huge so that alloca does not fail. */
2779 getrlimit (RLIMIT_STACK, &rlim);
2780 rlim.rlim_cur = rlim.rlim_max;
2781 setrlimit (RLIMIT_STACK, &rlim);
2783 #endif /* RLIMIT_STACK */
2785 signal (SIGFPE, float_signal);
2787 signal (SIGPIPE, pipe_closed);
2789 decl_printable_name = decl_name;
2790 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
2792 /* Initialize whether `char' is signed. */
2793 flag_signed_char = DEFAULT_SIGNED_CHAR;
2794 #ifdef DEFAULT_SHORT_ENUMS
2795 /* Initialize how much space enums occupy, by default. */
2796 flag_short_enums = DEFAULT_SHORT_ENUMS;
2799 /* Scan to see what optimization level has been specified. That will
2800 determine the default value of many flags. */
2801 for (i = 1; i < argc; i++)
2803 if (!strcmp (argv[i], "-O"))
2807 else if (argv[i][0] == '-' && argv[i][1] == 'O')
2809 /* Handle -O2, -O3, -O69, ... */
2810 char *p = &argv[i][2];
2814 if (! (c >= '0' && c <= '9'))
2817 optimize = atoi (&argv[i][2]);
2821 obey_regdecls = (optimize == 0);
2830 flag_thread_jumps = 1;
2832 flag_delayed_branch = 1;
2838 flag_cse_follow_jumps = 1;
2839 flag_cse_skip_blocks = 1;
2840 flag_expensive_optimizations = 1;
2841 flag_strength_reduce = 1;
2842 flag_rerun_cse_after_loop = 1;
2843 flag_caller_saves = 1;
2844 #ifdef INSN_SCHEDULING
2845 flag_schedule_insns = 1;
2846 flag_schedule_insns_after_reload = 1;
2850 #ifdef OPTIMIZATION_OPTIONS
2851 /* Allow default optimizations to be specified on a per-machine basis. */
2852 OPTIMIZATION_OPTIONS (optimize);
2855 /* Initialize register usage now so switches may override. */
2859 set_target_switch ("");
2861 for (i = 1; i < argc; i++)
2864 /* If this is a language-specific option,
2865 decode it in a language-specific way. */
2866 for (j = 0; lang_options[j] != 0; j++)
2867 if (!strncmp (argv[i], lang_options[j],
2868 strlen (lang_options[j])))
2870 if (lang_options[j] != 0)
2871 /* If the option is valid for *some* language,
2872 treat it as valid even if this language doesn't understand it. */
2873 lang_decode_option (argv[i]);
2874 else if (argv[i][0] == '-' && argv[i][1] != 0)
2876 register char *str = argv[i] + 1;
2881 set_target_switch (&str[1]);
2882 else if (!strcmp (str, "dumpbase"))
2884 dump_base_name = argv[++i];
2886 else if (str[0] == 'd')
2888 register char *p = &str[1];
2896 global_reg_dump = 1;
2902 cse_dump = 1, cse2_dump = 1;
2920 global_reg_dump = 1;
2938 flag_print_asm_name = 1;
2960 rtl_dump_and_exit = 1;
2964 else if (str[0] == 'f')
2966 register char *p = &str[1];
2969 /* Some kind of -f option.
2970 P's value is the option sans `-f'.
2971 Search for it in the table of options. */
2974 !found && j < sizeof (f_options) / sizeof (f_options[0]);
2977 if (!strcmp (p, f_options[j].string))
2979 *f_options[j].variable = f_options[j].on_value;
2980 /* A goto here would be cleaner,
2981 but breaks the vax pcc. */
2984 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
2985 && ! strcmp (p+3, f_options[j].string))
2987 *f_options[j].variable = ! f_options[j].on_value;
2994 else if (!strncmp (p, "fixed-", 6))
2995 fix_register (&p[6], 1, 1);
2996 else if (!strncmp (p, "call-used-", 10))
2997 fix_register (&p[10], 0, 1);
2998 else if (!strncmp (p, "call-saved-", 11))
2999 fix_register (&p[11], 0, 0);
3001 error ("Invalid option `%s'", argv[i]);
3003 else if (str[0] == 'O')
3005 register char *p = str+1;
3006 while (*p && *p >= '0' && *p <= '9')
3011 error ("Invalid option `%s'", argv[i]);
3013 else if (!strcmp (str, "pedantic"))
3015 else if (!strcmp (str, "pedantic-errors"))
3016 flag_pedantic_errors = pedantic = 1;
3017 else if (!strcmp (str, "quiet"))
3019 else if (!strcmp (str, "version"))
3021 else if (!strcmp (str, "w"))
3022 inhibit_warnings = 1;
3023 else if (!strcmp (str, "W"))
3026 warn_uninitialized = 1;
3028 else if (str[0] == 'W')
3030 register char *p = &str[1];
3033 /* Some kind of -W option.
3034 P's value is the option sans `-W'.
3035 Search for it in the table of options. */
3038 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3041 if (!strcmp (p, W_options[j].string))
3043 *W_options[j].variable = W_options[j].on_value;
3044 /* A goto here would be cleaner,
3045 but breaks the vax pcc. */
3048 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3049 && ! strcmp (p+3, W_options[j].string))
3051 *W_options[j].variable = ! W_options[j].on_value;
3058 else if (!strncmp (p, "id-clash-", 9))
3064 if (*endp >= '0' && *endp <= '9')
3068 error ("Invalid option `%s'", argv[i]);
3073 id_clash_len = atoi (str + 10);
3077 error ("Invalid option `%s'", argv[i]);
3079 else if (!strcmp (str, "p"))
3081 else if (!strcmp (str, "a"))
3083 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3084 warning ("`-a' option (basic block profile) not supported");
3086 profile_block_flag = 1;
3089 else if (str[0] == 'g')
3096 while (*p && (*p < '0' || *p > '9'))
3100 while (*q && (*q >= '0' && *q <= '9'))
3105 level = 2; /* default debugging info level */
3106 if (*q || level > 3)
3108 warning ("invalid debug level specification in option: `-%s'",
3110 warning ("no debugging information will be generated");
3114 /* If more than one debugging type is supported,
3115 you must define PREFERRED_DEBUGGING_TYPE
3116 to choose a format in a system-dependent way. */
3117 /* This is one long line cause VAXC can't handle a \-newline. */
3118 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3119 #ifdef PREFERRED_DEBUGGING_TYPE
3120 if (!strncmp (str, "ggdb", len))
3121 write_symbols = PREFERRED_DEBUGGING_TYPE;
3122 #else /* no PREFERRED_DEBUGGING_TYPE */
3123 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3124 #endif /* no PREFERRED_DEBUGGING_TYPE */
3125 #endif /* More than one debugger format enabled. */
3126 #ifdef DBX_DEBUGGING_INFO
3127 if (write_symbols != NO_DEBUG)
3129 else if (!strncmp (str, "ggdb", len))
3130 write_symbols = DBX_DEBUG;
3131 else if (!strncmp (str, "gstabs", len))
3132 write_symbols = DBX_DEBUG;
3133 else if (!strncmp (str, "gstabs+", len))
3134 write_symbols = DBX_DEBUG;
3136 /* Always enable extensions for -ggdb or -gstabs+,
3137 always disable for -gstabs.
3138 For plain -g, use system-specific default. */
3139 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3141 use_gnu_debug_info_extensions = 1;
3142 else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
3144 use_gnu_debug_info_extensions = 1;
3145 else if (write_symbols == DBX_DEBUG
3146 && !strncmp (str, "gstabs", len) && len >= 2)
3147 use_gnu_debug_info_extensions = 0;
3149 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3150 #endif /* DBX_DEBUGGING_INFO */
3151 #ifdef DWARF_DEBUGGING_INFO
3152 if (write_symbols != NO_DEBUG)
3154 else if (!strncmp (str, "g", len))
3155 write_symbols = DWARF_DEBUG;
3156 else if (!strncmp (str, "ggdb", len))
3157 write_symbols = DWARF_DEBUG;
3158 else if (!strncmp (str, "gdwarf", len))
3159 write_symbols = DWARF_DEBUG;
3161 /* Always enable extensions for -ggdb or -gdwarf+,
3162 always disable for -gdwarf.
3163 For plain -g, use system-specific default. */
3164 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3166 use_gnu_debug_info_extensions = 1;
3167 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3168 use_gnu_debug_info_extensions = 1;
3169 else if (write_symbols == DWARF_DEBUG
3170 && !strncmp (str, "gdwarf", len) && len >= 2)
3171 use_gnu_debug_info_extensions = 0;
3173 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3175 #ifdef SDB_DEBUGGING_INFO
3176 if (write_symbols != NO_DEBUG)
3178 else if (!strncmp (str, "g", len))
3179 write_symbols = SDB_DEBUG;
3180 else if (!strncmp (str, "gdb", len))
3181 write_symbols = SDB_DEBUG;
3182 else if (!strncmp (str, "gcoff", len))
3183 write_symbols = SDB_DEBUG;
3184 #endif /* SDB_DEBUGGING_INFO */
3185 #ifdef XCOFF_DEBUGGING_INFO
3186 if (write_symbols != NO_DEBUG)
3188 else if (!strncmp (str, "g", len))
3189 write_symbols = XCOFF_DEBUG;
3190 else if (!strncmp (str, "ggdb", len))
3191 write_symbols = XCOFF_DEBUG;
3192 else if (!strncmp (str, "gxcoff", len))
3193 write_symbols = XCOFF_DEBUG;
3195 /* Always enable extensions for -ggdb or -gxcoff+,
3196 always disable for -gxcoff.
3197 For plain -g, use system-specific default. */
3198 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3200 use_gnu_debug_info_extensions = 1;
3201 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3202 use_gnu_debug_info_extensions = 1;
3203 else if (write_symbols == XCOFF_DEBUG
3204 && !strncmp (str, "gxcoff", len) && len >= 2)
3205 use_gnu_debug_info_extensions = 0;
3207 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3209 if (write_symbols == NO_DEBUG)
3210 warning ("`-%s' option not supported on this version of GCC", str);
3211 else if (level == 0)
3212 write_symbols = NO_DEBUG;
3214 debug_info_level = (enum debug_info_level) level;
3216 else if (!strcmp (str, "o"))
3218 asm_file_name = argv[++i];
3220 else if (str[0] == 'G')
3222 g_switch_set = TRUE;
3223 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3225 else if (!strncmp (str, "aux-info", 8))
3227 flag_gen_aux_info = 1;
3228 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3231 error ("Invalid option `%s'", argv[i]);
3233 else if (argv[i][0] == '+')
3234 error ("Invalid option `%s'", argv[i]);
3241 /* Inlining does not work if not optimizing,
3242 so force it not to be done. */
3246 /* The c_decode_option and lang_decode_option functions set
3247 this to `2' if -Wall is used, so we can avoid giving out
3248 lots of errors for people who don't realize what -Wall does. */
3249 if (warn_uninitialized == 1)
3250 warning ("-Wuninitialized is not supported without -O");
3253 #ifdef OVERRIDE_OPTIONS
3254 /* Some machines may reject certain combinations of options. */
3258 /* Unrolling all loops implies that standard loop unrolling must also
3260 if (flag_unroll_all_loops)
3261 flag_unroll_loops = 1;
3262 /* Loop unrolling requires that strength_reduction be on also. Silently
3263 turn on strength reduction here if it isn't already on. Also, the loop
3264 unrolling code assumes that cse will be run after loop, so that must
3265 be turned on also. */
3266 if (flag_unroll_loops)
3268 flag_strength_reduce = 1;
3269 flag_rerun_cse_after_loop = 1;
3272 /* Warn about options that are not supported on this machine. */
3273 #ifndef INSN_SCHEDULING
3274 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3275 warning ("instruction scheduling not supported on this target machine");
3278 if (flag_delayed_branch)
3279 warning ("this target machine does not have delayed branches");
3282 /* If we are in verbose mode, write out the version and maybe all the
3283 option flags in use. */
3286 fprintf (stderr, "%s version %s", language_string, version_string);
3287 #ifdef TARGET_VERSION
3292 #define __VERSION__ "[unknown]"
3294 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3296 fprintf (stderr, " compiled by CC.\n");
3299 print_switch_values ();
3302 /* Now that register usage is specified, convert it to HARD_REG_SETs. */
3305 compile_file (filename);
3311 char *lim = (char *) sbrk (0);
3313 fprintf (stderr, "Data size %d.\n",
3314 lim - (char *) &environ);
3318 system ("ps -l 1>&2");
3321 #endif /* not USG */
3323 #endif /* not VMS */
3324 #endif /* not OS2 */
3327 exit (FATAL_EXIT_CODE);
3329 exit (FATAL_EXIT_CODE);
3330 exit (SUCCESS_EXIT_CODE);
3334 /* Decode -m switches. */
3336 /* Here is a table, controlled by the tm.h file, listing each -m switch
3337 and which bits in `target_switches' it should set or clear.
3338 If VALUE is positive, it is bits to set.
3339 If VALUE is negative, -VALUE is bits to clear.
3340 (The sign bit is not used so there is no confusion.) */
3342 struct {char *name; int value;} target_switches []
3345 /* This table is similar, but allows the switch to have a value. */
3347 #ifdef TARGET_OPTIONS
3348 struct {char *prefix; char ** variable;} target_options []
3352 /* Decode the switch -mNAME. */
3355 set_target_switch (name)
3361 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3362 if (!strcmp (target_switches[j].name, name))
3364 if (target_switches[j].value < 0)
3365 target_flags &= ~-target_switches[j].value;
3367 target_flags |= target_switches[j].value;
3371 #ifdef TARGET_OPTIONS
3373 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3375 int len = strlen (target_options[j].prefix);
3376 if (!strncmp (target_options[j].prefix, name, len))
3378 *target_options[j].variable = name + len;
3385 error ("Invalid option `%s'", name);
3388 /* Variable used for communication between the following two routines. */
3390 static int line_position;
3392 /* Print an option value and adjust the position in the line. */
3395 print_single_switch (type, name)
3398 fprintf (stderr, " %s%s", type, name);
3400 line_position += strlen (type) + strlen (name) + 1;
3402 if (line_position > 65)
3404 fprintf (stderr, "\n\t");
3409 /* Print default target switches for -version. */
3412 print_switch_values ()
3416 fprintf (stderr, "enabled:");
3419 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3420 if (*f_options[j].variable == f_options[j].on_value)
3421 print_single_switch ("-f", f_options[j].string);
3423 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
3424 if (*W_options[j].variable == W_options[j].on_value)
3425 print_single_switch ("-W", W_options[j].string);
3427 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3428 if (target_switches[j].name[0] != '\0'
3429 && target_switches[j].value > 0
3430 && ((target_switches[j].value & target_flags)
3431 == target_switches[j].value))
3432 print_single_switch ("-m", target_switches[j].name);
3434 fprintf (stderr, "\n");