1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92, 93, 1994 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* This is the top level of cc1/c++.
22 It parses command args, opens files, invokes the various passes
23 in the proper order, and counts the time used by each.
24 Error messages and low-level interface to malloc also handled here. */
31 #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"
57 #ifdef XCOFF_DEBUGGING_INFO
65 /* The extra parameters substantially improve the I/O performance. */
67 VMS_fopen (fname, type)
71 if (strcmp (type, "w") == 0)
72 return fopen (fname, type, "mbc=16", "deq=64", "fop=tef", "shr=nil");
73 return fopen (fname, type, "mbc=16");
75 #define fopen VMS_fopen
78 #ifndef DEFAULT_GDB_EXTENSIONS
79 #define DEFAULT_GDB_EXTENSIONS 1
82 extern int rtx_equal_function_value_matters;
84 #if ! (defined (VMS) || defined (OS2))
85 extern char **environ;
87 extern char *version_string, *language_string;
89 /* Carry information from ASM_DECLARE_OBJECT_NAME
90 to ASM_FINISH_DECLARE_OBJECT. */
92 extern int size_directive_output;
93 extern tree last_assemble_variable_decl;
95 extern void init_lex ();
96 extern void init_decl_processing ();
97 extern void init_obstacks ();
98 extern void init_tree_codes ();
99 extern void init_rtl ();
100 extern void init_optabs ();
101 extern void init_stmt ();
102 extern void init_reg_sets ();
103 extern void dump_flow_info ();
104 extern void dump_sched_info ();
105 extern void dump_local_alloc ();
107 void rest_of_decl_compilation ();
109 void error_with_file_and_line ();
114 void set_target_switch ();
115 static void print_switch_values ();
116 static char *decl_name ();
118 /* Name of program invoked, sans directories. */
122 /* Copy of arguments to main. */
126 /* Name of current original source file (what was input to cpp).
127 This comes from each #-command in the actual input. */
129 char *input_filename;
131 /* Name of top-level original source file (what was input to cpp).
132 This comes from the #-command at the beginning of the actual input.
133 If there isn't any there, then this is the cc1 input file name. */
135 char *main_input_filename;
137 /* Stream for reading from the input file. */
141 /* Current line number in real source file. */
145 /* Stack of currently pending input files. */
147 struct file_stack *input_file_stack;
149 /* Incremented on each change to input_file_stack. */
150 int input_file_stack_tick;
152 /* FUNCTION_DECL for function now being parsed or compiled. */
154 extern tree current_function_decl;
156 /* Name to use as base of names for dump output files. */
158 char *dump_base_name;
160 /* Bit flags that specify the machine subtype we are compiling for.
161 Bits are tested using macros TARGET_... defined in the tm.h file
162 and set by `-m...' switches. Must be defined in rtlanal.c. */
164 extern int target_flags;
166 /* Flags saying which kinds of debugging dump have been requested. */
169 int rtl_dump_and_exit = 0;
170 int jump_opt_dump = 0;
175 int combine_dump = 0;
177 int local_reg_dump = 0;
178 int global_reg_dump = 0;
180 int jump2_opt_dump = 0;
181 int dbr_sched_dump = 0;
182 int flag_print_asm_name = 0;
183 int stack_reg_dump = 0;
185 /* Name for output file of assembly code, specified with -o. */
189 /* Value of the -G xx switch, and whether it was passed or not. */
193 /* Type(s) of debugging information we are producing (if any).
194 See flags.h for the definitions of the different possible
195 types of debugging information. */
196 enum debug_info_type write_symbols = NO_DEBUG;
198 /* Level of debugging information we are producing. See flags.h
199 for the definitions of the different possible levels. */
200 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
202 /* Nonzero means use GNU-only extensions in the generated symbolic
203 debugging information. */
204 /* Currently, this only has an effect when write_symbols is set to
205 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
206 int use_gnu_debug_info_extensions = 0;
208 /* Nonzero means do optimizations. -O.
209 Particular numeric values stand for particular amounts of optimization;
210 thus, -O2 stores 2 here. However, the optimizations beyond the basic
211 ones are not controlled directly by this variable. Instead, they are
212 controlled by individual `flag_...' variables that are defaulted
213 based on this variable. */
217 /* Number of error messages and warning messages so far. */
220 int warningcount = 0;
223 /* Flag to output bytecode instead of native assembler */
224 int output_bytecode = 0;
226 /* Pointer to function to compute the name to use to print a declaration. */
228 char *(*decl_printable_name) ();
230 /* Pointer to function to compute rtl for a language-specific tree code. */
232 struct rtx_def *(*lang_expand_expr) ();
234 /* Pointer to function to finish handling an incomplete decl at the
235 end of compilation. */
237 void (*incomplete_decl_finalize_hook) () = 0;
239 /* Nonzero if generating code to do profiling. */
241 int profile_flag = 0;
243 /* Nonzero if generating code to do profiling on a line-by-line basis. */
245 int profile_block_flag;
247 /* Nonzero for -pedantic switch: warn about anything
248 that standard spec forbids. */
252 /* Temporarily suppress certain warnings.
253 This is set while reading code from a system header file. */
255 int in_system_header = 0;
257 /* Nonzero means do stupid register allocation.
258 Currently, this is 1 if `optimize' is 0. */
260 int obey_regdecls = 0;
262 /* Don't print functions as they are compiled and don't print
263 times taken by the various passes. -quiet. */
269 /* Nonzero means `char' should be signed. */
271 int flag_signed_char;
273 /* Nonzero means give an enum type only as many bytes as it needs. */
275 int flag_short_enums;
277 /* Nonzero for -fcaller-saves: allocate values in regs that need to
278 be saved across function calls, if that produces overall better code.
279 Optional now, so people can test it. */
281 #ifdef DEFAULT_CALLER_SAVES
282 int flag_caller_saves = 1;
284 int flag_caller_saves = 0;
287 /* Nonzero if structures and unions should be returned in memory.
289 This should only be defined if compatibility with another compiler or
290 with an ABI is needed, because it results in slower code. */
292 #ifndef DEFAULT_PCC_STRUCT_RETURN
293 #define DEFAULT_PCC_STRUCT_RETURN 1
296 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
298 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
300 /* Nonzero for -fforce-mem: load memory value into a register
301 before arithmetic on it. This makes better cse but slower compilation. */
303 int flag_force_mem = 0;
305 /* Nonzero for -fforce-addr: load memory address into a register before
306 reference to memory. This makes better cse but slower compilation. */
308 int flag_force_addr = 0;
310 /* Nonzero for -fdefer-pop: don't pop args after each function call;
311 instead save them up to pop many calls' args with one insns. */
313 int flag_defer_pop = 0;
315 /* Nonzero for -ffloat-store: don't allocate floats and doubles
316 in extended-precision registers. */
318 int flag_float_store = 0;
320 /* Nonzero for -fcse-follow-jumps:
321 have cse follow jumps to do a more extensive job. */
323 int flag_cse_follow_jumps;
325 /* Nonzero for -fcse-skip-blocks:
326 have cse follow a branch around a block. */
327 int flag_cse_skip_blocks;
329 /* Nonzero for -fexpensive-optimizations:
330 perform miscellaneous relatively-expensive optimizations. */
331 int flag_expensive_optimizations;
333 /* Nonzero for -fthread-jumps:
334 have jump optimize output of loop. */
336 int flag_thread_jumps;
338 /* Nonzero enables strength-reduction in loop.c. */
340 int flag_strength_reduce = 0;
342 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
343 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
344 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
347 int flag_unroll_loops;
349 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
350 This is generally not a win. */
352 int flag_unroll_all_loops;
354 /* Nonzero for -fwritable-strings:
355 store string constants in data segment and don't uniquize them. */
357 int flag_writable_strings = 0;
359 /* Nonzero means don't put addresses of constant functions in registers.
360 Used for compiling the Unix kernel, where strange substitutions are
361 done on the assembly output. */
363 int flag_no_function_cse = 0;
365 /* Nonzero for -fomit-frame-pointer:
366 don't make a frame pointer in simple functions that don't require one. */
368 int flag_omit_frame_pointer = 0;
370 /* Nonzero to inhibit use of define_optimization peephole opts. */
372 int flag_no_peephole = 0;
374 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
375 operations in the interest of optimization. For example it allows
376 GCC to assume arguments to sqrt are nonnegative numbers, allowing
377 faster code for sqrt to be generated. */
379 int flag_fast_math = 0;
381 /* Nonzero means all references through pointers are volatile. */
385 /* Nonzero means treat all global and extern variables as global. */
387 int flag_volatile_global;
389 /* Nonzero means just do syntax checking; don't output anything. */
391 int flag_syntax_only = 0;
393 /* Nonzero means to rerun cse after loop optimization. This increases
394 compilation time about 20% and picks up a few more common expressions. */
396 static int flag_rerun_cse_after_loop;
398 /* Nonzero for -finline-functions: ok to inline functions that look like
399 good inline candidates. */
401 int flag_inline_functions;
403 /* Nonzero for -fkeep-inline-functions: even if we make a function
404 go inline everywhere, keep its definition around for debugging
407 int flag_keep_inline_functions;
409 /* Nonzero means that functions declared `inline' will be treated
410 as `static'. Prevents generation of zillions of copies of unused
411 static inline functions; instead, `inlines' are written out
412 only when actually used. Used in conjunction with -g. Also
413 does the right thing with #pragma interface. */
417 /* Nonzero means we should be saving declaration info into a .X file. */
419 int flag_gen_aux_info = 0;
421 /* Specified name of aux-info file. */
423 static char *aux_info_file_name;
425 /* Nonzero means make the text shared if supported. */
427 int flag_shared_data;
429 /* Nonzero means schedule into delayed branch slots if supported. */
431 int flag_delayed_branch;
433 /* Nonzero if we are compiling pure (sharable) code.
434 Value is 1 if we are doing reasonable (i.e. simple
435 offset into offset table) pic. Value is 2 if we can
436 only perform register offsets. */
440 /* Nonzero means place uninitialized global data in the bss section. */
444 /* Nonzero means pretend it is OK to examine bits of target floats,
445 even if that isn't true. The resulting code will have incorrect constants,
446 but the same series of instructions that the native compiler would make. */
448 int flag_pretend_float;
450 /* Nonzero means change certain warnings into errors.
451 Usually these are warnings about failure to conform to some standard. */
453 int flag_pedantic_errors = 0;
455 /* flag_schedule_insns means schedule insns within basic blocks (before
457 flag_schedule_insns_after_reload means schedule insns after
460 int flag_schedule_insns = 0;
461 int flag_schedule_insns_after_reload = 0;
463 /* -finhibit-size-directive inhibits output of .size for ELF.
464 This is used only for compiling crtstuff.c,
465 and it may be extended to other effects
466 needed for crtstuff.c on other systems. */
467 int flag_inhibit_size_directive = 0;
469 /* -fverbose-asm causes extra commentary information to be produced in
470 the generated assembly code (to make it more readable). This option
471 is generally only of use to those who actually need to read the
472 generated assembly code (perhaps while debugging the compiler itself). */
474 int flag_verbose_asm = 0;
476 /* -fgnu-linker specifies use of the GNU linker for initializations.
477 (Or, more generally, a linker that handles initializations.)
478 -fno-gnu-linker says that collect2 will be used. */
480 int flag_gnu_linker = 0;
482 int flag_gnu_linker = 1;
485 /* Table of language-independent -f options.
486 STRING is the option name. VARIABLE is the address of the variable.
487 ON_VALUE is the value to store in VARIABLE
488 if `-fSTRING' is seen as an option.
489 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
491 struct { char *string; int *variable; int on_value;} f_options[] =
493 {"float-store", &flag_float_store, 1},
494 {"volatile", &flag_volatile, 1},
495 {"volatile-global", &flag_volatile_global, 1},
496 {"defer-pop", &flag_defer_pop, 1},
497 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
498 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
499 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
500 {"expensive-optimizations", &flag_expensive_optimizations, 1},
501 {"thread-jumps", &flag_thread_jumps, 1},
502 {"strength-reduce", &flag_strength_reduce, 1},
503 {"unroll-loops", &flag_unroll_loops, 1},
504 {"unroll-all-loops", &flag_unroll_all_loops, 1},
505 {"writable-strings", &flag_writable_strings, 1},
506 {"peephole", &flag_no_peephole, 0},
507 {"force-mem", &flag_force_mem, 1},
508 {"force-addr", &flag_force_addr, 1},
509 {"function-cse", &flag_no_function_cse, 0},
510 {"inline-functions", &flag_inline_functions, 1},
511 {"keep-inline-functions", &flag_keep_inline_functions, 1},
512 {"inline", &flag_no_inline, 0},
513 {"syntax-only", &flag_syntax_only, 1},
514 {"shared-data", &flag_shared_data, 1},
515 {"caller-saves", &flag_caller_saves, 1},
516 {"pcc-struct-return", &flag_pcc_struct_return, 1},
517 {"reg-struct-return", &flag_pcc_struct_return, 0},
518 {"delayed-branch", &flag_delayed_branch, 1},
519 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
520 {"pretend-float", &flag_pretend_float, 1},
521 {"schedule-insns", &flag_schedule_insns, 1},
522 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
523 {"pic", &flag_pic, 1},
524 {"PIC", &flag_pic, 2},
525 {"fast-math", &flag_fast_math, 1},
526 {"common", &flag_no_common, 0},
527 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
528 {"verbose-asm", &flag_verbose_asm, 1},
529 {"gnu-linker", &flag_gnu_linker, 1},
530 {"bytecode", &output_bytecode, 1}
533 /* Table of language-specific options. */
535 char *lang_options[] =
541 "-fallow-single-precision",
545 "-fno-unsigned-char",
546 "-fsigned-bitfields",
547 "-funsigned-bitfields",
548 "-fno-signed-bitfields",
549 "-fno-unsigned-bitfields",
553 "-fno-cond-mismatch",
562 "-fdollars-in-identifiers",
563 "-fno-dollars-in-identifiers",
568 "-Wno-write-strings",
572 "-Wno-pointer-arith",
573 "-Wstrict-prototypes",
574 "-Wno-strict-prototypes",
575 "-Wmissing-prototypes",
576 "-Wno-missing-prototypes",
578 "-Wno-redundant-decls",
580 "-Wno-nested-externs",
586 "-Wno-char-subscripts",
600 "-Wno-missing-braces",
603 /* These are for C++. */
604 "-+e0", /* gcc.c tacks the `-' on the front. */
608 "-fno-save-memoized",
617 "-fthis-is-variable",
618 "-fno-this-is-variable",
619 "-fstrict-prototype",
620 "-fno-strict-prototype",
624 "-fno-memoize-lookups",
625 "-felide-constructors",
626 "-fno-elide-constructors",
627 "-fhandle-exceptions",
628 "-fno-handle-exceptions",
630 "-fno-ansi-exceptions",
631 "-fspring-exceptions",
632 "-fno-spring-exceptions",
634 "-fno-default-inline",
636 "-fno-enum-int-equiv",
642 "-fno-nonnull-objects",
643 "-fimplement-inlines",
644 "-fno-implement-inlines",
645 "-fexternal-templates",
646 "-fno-external-templates",
647 "-fansi-overloading",
648 "-fno-ansi-overloading",
652 "-fno-conserve-space",
656 "-Woverloaded-virtual",
657 "-Wno-overloaded-virtual",
660 "-Wtemplate-debugging",
661 "-Wno-template-debugging",
662 "-Wctor-dtor-privacy",
663 "-Wno-ctor-dtor-privacy",
665 /* these are for obj c */
677 /* This is for GNAT and is temporary. */
682 /* Options controlling warnings */
684 /* Don't print warning messages. -w. */
686 int inhibit_warnings = 0;
688 /* Print various extra warnings. -W. */
690 int extra_warnings = 0;
692 /* Treat warnings as errors. -Werror. */
694 int warnings_are_errors = 0;
696 /* Nonzero to warn about unused local variables. */
700 /* Nonzero to warn about variables used before they are initialized. */
702 int warn_uninitialized;
704 /* Nonzero means warn about all declarations which shadow others. */
708 /* Warn if a switch on an enum fails to have a case for every enum value. */
712 /* Nonzero means warn about function definitions that default the return type
713 or that use a null return and have a return-type other than void. */
715 int warn_return_type;
717 /* Nonzero means warn about pointer casts that increase the required
718 alignment of the target type (and might therefore lead to a crash
719 due to a misaligned access). */
723 /* Nonzero means warn about any identifiers that match in the first N
724 characters. The value N is in `id_clash_len'. */
729 /* Nonzero means warn if inline function is too large. */
733 /* Warn if a function returns an aggregate,
734 since there are often incompatible calling conventions for doing this. */
736 int warn_aggregate_return;
738 /* Likewise for -W. */
740 struct { char *string; int *variable; int on_value;} W_options[] =
742 {"unused", &warn_unused, 1},
743 {"error", &warnings_are_errors, 1},
744 {"shadow", &warn_shadow, 1},
745 {"switch", &warn_switch, 1},
746 {"aggregate-return", &warn_aggregate_return, 1},
747 {"cast-align", &warn_cast_align, 1},
748 {"uninitialized", &warn_uninitialized, 1},
749 {"inline", &warn_inline, 1}
752 /* Output files for assembler code (real compiler output)
753 and debugging dumps. */
758 FILE *jump_opt_dump_file;
760 FILE *loop_dump_file;
761 FILE *cse2_dump_file;
762 FILE *flow_dump_file;
763 FILE *combine_dump_file;
764 FILE *sched_dump_file;
765 FILE *local_reg_dump_file;
766 FILE *global_reg_dump_file;
767 FILE *sched2_dump_file;
768 FILE *jump2_opt_dump_file;
769 FILE *dbr_sched_dump_file;
770 FILE *stack_reg_dump_file;
772 /* Time accumulators, to count the total time spent in various passes. */
776 int integration_time;
784 int local_alloc_time;
785 int global_alloc_time;
788 int shorten_branch_time;
794 /* Return time used so far, in microseconds. */
803 struct rusage rusage;
808 int proc_system_time;
810 int child_system_time;
820 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
823 getrusage (0, &rusage);
824 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
825 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
828 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
833 #define TIMEVAR(VAR, BODY) \
834 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
837 print_time (str, total)
842 "time in %s: %d.%06d\n",
843 str, total / 1000000, total % 1000000);
846 /* Count an error or warning. Return 1 if the message should be printed. */
849 count_error (warningp)
852 if (warningp && inhibit_warnings)
855 if (warningp && !warnings_are_errors)
859 static int warning_message = 0;
861 if (warningp && !warning_message)
863 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
872 /* Print a fatal error message. NAME is the text.
873 Also include a system error message based on `errno'. */
876 pfatal_with_name (name)
879 fprintf (stderr, "%s: ", progname);
885 fatal_io_error (name)
888 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
892 /* Called to give a better error message when we don't have an insn to match
893 what we are looking for or if the insn's constraints aren't satisfied,
894 rather than just calling abort(). */
897 fatal_insn_not_found (insn)
900 if (!output_bytecode)
902 if (INSN_CODE (insn) < 0)
903 error ("internal error--unrecognizable insn:");
905 error ("internal error--insn does not satisfy its constraints:");
909 fflush (asm_out_file);
911 fflush (aux_info_file);
913 fflush (rtl_dump_file);
914 if (jump_opt_dump_file)
915 fflush (jump_opt_dump_file);
917 fflush (cse_dump_file);
919 fflush (loop_dump_file);
921 fflush (cse2_dump_file);
923 fflush (flow_dump_file);
924 if (combine_dump_file)
925 fflush (combine_dump_file);
927 fflush (sched_dump_file);
928 if (local_reg_dump_file)
929 fflush (local_reg_dump_file);
930 if (global_reg_dump_file)
931 fflush (global_reg_dump_file);
932 if (sched2_dump_file)
933 fflush (sched2_dump_file);
934 if (jump2_opt_dump_file)
935 fflush (jump2_opt_dump_file);
936 if (dbr_sched_dump_file)
937 fflush (dbr_sched_dump_file);
938 if (stack_reg_dump_file)
939 fflush (stack_reg_dump_file);
943 /* This is the default decl_printable_name function. */
946 decl_name (decl, kind)
950 return IDENTIFIER_POINTER (DECL_NAME (decl));
953 static int need_error_newline;
955 /* Function of last error message;
956 more generally, function such that if next error message is in it
957 then we don't have to mention the function name. */
958 static tree last_error_function = NULL;
960 /* Used to detect when input_file_stack has changed since last described. */
961 static int last_error_tick;
963 /* Called when the start of a function definition is parsed,
964 this function prints on stderr the name of the function. */
967 announce_function (decl)
973 if (rtl_dump_and_exit)
974 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
976 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
978 need_error_newline = 1;
979 last_error_function = current_function_decl;
983 /* Prints out, if necessary, the name of the current function
984 which caused an error. Called from all error and warning functions. */
987 report_error_function (file)
990 struct file_stack *p;
992 if (need_error_newline)
994 fprintf (stderr, "\n");
995 need_error_newline = 0;
998 if (last_error_function != current_function_decl)
1000 char *kind = "function";
1001 if (current_function_decl != 0
1002 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1006 fprintf (stderr, "%s: ", file);
1008 if (current_function_decl == NULL)
1009 fprintf (stderr, "At top level:\n");
1012 char *name = (*decl_printable_name) (current_function_decl, &kind);
1013 fprintf (stderr, "In %s `%s':\n", kind, name);
1016 last_error_function = current_function_decl;
1018 if (input_file_stack && input_file_stack->next != 0
1019 && input_file_stack_tick != last_error_tick)
1021 fprintf (stderr, "In file included");
1022 for (p = input_file_stack->next; p; p = p->next)
1024 fprintf (stderr, " from %s:%d", p->name, p->line);
1026 fprintf (stderr, ",\n ");
1028 fprintf (stderr, ":\n");
1029 last_error_tick = input_file_stack_tick;
1033 /* Print a message. */
1036 vmessage (prefix, s, ap)
1042 fprintf (stderr, "%s: ", prefix);
1045 vfprintf (stderr, s, ap);
1048 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1049 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1050 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1051 fprintf (stderr, s, v1, v2, v3);
1056 /* Print a message relevant to line LINE of file FILE. */
1059 v_message_with_file_and_line (file, line, prefix, s, ap)
1067 fprintf (stderr, "%s:%d: ", file, line);
1069 fprintf (stderr, "%s: ", progname);
1071 vmessage (prefix, s, ap);
1072 fputc ('\n', stderr);
1075 /* Print a message relevant to the given DECL. */
1078 v_message_with_decl (decl, prefix, s, ap)
1086 fprintf (stderr, "%s:%d: ",
1087 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1090 fprintf (stderr, "%s: ", prefix);
1092 /* Do magic to get around lack of varargs support for insertion
1093 of arguments into existing list. We know that the decl is first;
1094 we ass_u_me that it will be printed with "%s". */
1096 for (p = s; *p; ++p)
1100 if (*(p + 1) == '%')
1108 fwrite (s, p - s, 1, stderr);
1112 char *n = (DECL_NAME (decl)
1113 ? (*decl_printable_name) (decl, &junk)
1119 if (isalpha (*(p - 1) & 0xFF))
1125 vmessage ((char *)NULL, p, ap);
1127 fputc ('\n', stderr);
1130 /* Figure file and line of the given INSN. */
1133 file_and_line_for_asm (insn, pfile, pline)
1138 rtx body = PATTERN (insn);
1141 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1142 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1143 asmop = SET_SRC (body);
1144 else if (GET_CODE (body) == ASM_OPERANDS)
1146 else if (GET_CODE (body) == PARALLEL
1147 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1148 asmop = SET_SRC (XVECEXP (body, 0, 0));
1149 else if (GET_CODE (body) == PARALLEL
1150 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1151 asmop = XVECEXP (body, 0, 0);
1157 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1158 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1162 *pfile = input_filename;
1167 /* Report an error at line LINE of file FILE. */
1170 v_error_with_file_and_line (file, line, s, ap)
1177 report_error_function (file);
1178 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1182 error_with_file_and_line (va_alist)
1184 /* (char *file, int line, char *s, ...) */
1192 file = va_arg (ap, char *);
1193 line = va_arg (ap, int);
1194 s = va_arg (ap, char *);
1195 v_error_with_file_and_line (file, line, s, ap);
1199 /* Report an error at the declaration DECL.
1200 S is a format string which uses %s to substitute the declaration
1201 name; subsequent substitutions are a la printf. */
1204 v_error_with_decl (decl, s, ap)
1210 report_error_function (DECL_SOURCE_FILE (decl));
1211 v_message_with_decl (decl, (char *)NULL, s, ap);
1215 error_with_decl (va_alist)
1217 /* (tree decl, char *s, ...) */
1224 decl = va_arg (ap, tree);
1225 s = va_arg (ap, char *);
1226 v_error_with_decl (decl, s, ap);
1230 /* Report an error at the line number of the insn INSN.
1231 This is used only when INSN is an `asm' with operands,
1232 and each ASM_OPERANDS records its own source file and line. */
1235 v_error_for_asm (insn, s, ap)
1244 file_and_line_for_asm (insn, &file, &line);
1245 report_error_function (file);
1246 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1250 error_for_asm (va_alist)
1252 /* (rtx insn, char *s, ...) */
1259 insn = va_arg (ap, rtx);
1260 s = va_arg (ap, char *);
1261 v_error_for_asm (insn, s, ap);
1265 /* Report an error at the current line number. */
1272 v_error_with_file_and_line (input_filename, lineno, s, ap);
1278 /* (char *s, ...) */
1284 s = va_arg (ap, char *);
1289 /* Report a fatal error at the current line number. */
1303 /* (char *s, ...) */
1309 s = va_arg (ap, char *);
1314 /* Report a warning at line LINE of file FILE. */
1317 v_warning_with_file_and_line (file, line, s, ap)
1323 if (count_error (1))
1325 report_error_function (file);
1326 v_message_with_file_and_line (file, line, "warning", s, ap);
1331 warning_with_file_and_line (va_alist)
1333 /* (char *file, int line, char *s, ...) */
1341 file = va_arg (ap, char *);
1342 line = va_arg (ap, int);
1343 s = va_arg (ap, char *);
1344 v_warning_with_file_and_line (file, line, s, ap);
1348 /* Report a warning at the declaration DECL.
1349 S is a format string which uses %s to substitute the declaration
1350 name; subsequent substitutions are a la printf. */
1353 v_warning_with_decl (decl, s, ap)
1358 if (count_error (1))
1360 report_error_function (DECL_SOURCE_FILE (decl));
1361 v_message_with_decl (decl, "warning", s, ap);
1366 warning_with_decl (va_alist)
1368 /* (tree decl, char *s, ...) */
1375 decl = va_arg (ap, tree);
1376 s = va_arg (ap, char *);
1377 v_warning_with_decl (decl, s, ap);
1381 /* Report a warning at the line number of the insn INSN.
1382 This is used only when INSN is an `asm' with operands,
1383 and each ASM_OPERANDS records its own source file and line. */
1386 v_warning_for_asm (insn, s, ap)
1391 if (count_error (1))
1396 file_and_line_for_asm (insn, &file, &line);
1397 report_error_function (file);
1398 v_message_with_file_and_line (file, line, "warning", s, ap);
1403 warning_for_asm (va_alist)
1405 /* (rtx insn, char *s, ...) */
1412 insn = va_arg (ap, rtx);
1413 s = va_arg (ap, char *);
1414 v_warning_for_asm (insn, s, ap);
1418 /* Report a warning at the current line number. */
1425 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1436 s = va_arg (ap, char *);
1441 /* These functions issue either warnings or errors depending on
1442 -pedantic-errors. */
1449 if (flag_pedantic_errors)
1458 /* (char *s, ...) */
1464 s = va_arg (ap, char *);
1470 v_pedwarn_with_decl (decl, s, ap)
1475 if (flag_pedantic_errors)
1476 v_error_with_decl (decl, s, ap);
1478 v_warning_with_decl (decl, s, ap);
1482 pedwarn_with_decl (va_alist)
1484 /* (tree decl, char *s, ...) */
1491 decl = va_arg (ap, tree);
1492 s = va_arg (ap, char *);
1493 v_pedwarn_with_decl (decl, s, ap);
1498 v_pedwarn_with_file_and_line (file, line, s, ap)
1504 if (flag_pedantic_errors)
1505 v_error_with_file_and_line (file, line, s, ap);
1507 v_warning_with_file_and_line (file, line, s, ap);
1511 pedwarn_with_file_and_line (va_alist)
1513 /* (char *file, int line, char *s, ...) */
1521 file = va_arg (ap, char *);
1522 line = va_arg (ap, int);
1523 s = va_arg (ap, char *);
1524 v_pedwarn_with_file_and_line (file, line, s, ap);
1528 /* Apologize for not implementing some feature. */
1537 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1539 fprintf (stderr, "%s: ", progname);
1540 vmessage ("sorry, not implemented", s, ap);
1541 fputc ('\n', stderr);
1547 /* (char *s, ...) */
1553 s = va_arg (ap, char *);
1558 /* Apologize for not implementing some feature, then quit. */
1561 v_really_sorry (s, ap)
1567 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1569 fprintf (stderr, "%s: ", progname);
1570 vmessage ("sorry, not implemented", s, ap);
1571 fatal (" (fatal)\n");
1575 really_sorry (va_alist)
1577 /* (char *s, ...) */
1583 s = va_arg (ap, char *);
1584 v_really_sorry (s, ap);
1588 /* More 'friendly' abort that prints the line and file.
1589 config.h can #define abort fancy_abort if you like that sort of thing.
1591 I don't think this is actually a good idea.
1592 Other sorts of crashes will look a certain way.
1593 It is a good thing if crashes from calling abort look the same way.
1599 fatal ("internal gcc abort");
1602 /* This calls abort and is used to avoid problems when abort if a macro.
1603 It is used when we need to pass the address of abort. */
1611 /* When `malloc.c' is compiled with `rcheck' defined,
1612 it calls this function to report clobberage. */
1620 /* Same as `malloc' but report error if no memory available. */
1626 register char *value = (char *) malloc (size);
1628 fatal ("virtual memory exhausted");
1632 /* Same as `realloc' but report error if no memory available. */
1635 xrealloc (ptr, size)
1639 char *result = (char *) realloc (ptr, size);
1641 fatal ("virtual memory exhausted");
1645 /* Return the logarithm of X, base 2, considering X unsigned,
1646 if X is a power of 2. Otherwise, returns -1.
1648 This should be used via the `exact_log2' macro. */
1652 register unsigned HOST_WIDE_INT x;
1654 register int log = 0;
1655 /* Test for 0 or a power of 2. */
1656 if (x == 0 || x != (x & -x))
1658 while ((x >>= 1) != 0)
1663 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1664 If X is 0, return -1.
1666 This should be used via the floor_log2 macro. */
1670 register unsigned HOST_WIDE_INT x;
1672 register int log = -1;
1680 jmp_buf float_handler;
1682 /* Specify where to longjmp to when a floating arithmetic error happens.
1683 If HANDLER is 0, it means don't handle the errors any more. */
1686 set_float_handler (handler)
1689 float_handled = (handler != 0);
1691 bcopy (handler, float_handler, sizeof (float_handler));
1694 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1695 error happens, pushing the previous specification into OLD_HANDLER.
1696 Return an indication of whether there was a previous handler in effect. */
1699 push_float_handler (handler, old_handler)
1700 jmp_buf handler, old_handler;
1702 int was_handled = float_handled;
1706 bcopy (float_handler, old_handler, sizeof (float_handler));
1707 bcopy (handler, float_handler, sizeof (float_handler));
1711 /* Restore the previous specification of whether and where to longjmp to
1712 when a floating arithmetic error happens. */
1715 pop_float_handler (handled, handler)
1719 float_handled = handled;
1721 bcopy (handler, float_handler, sizeof (float_handler));
1724 /* Signals actually come here. */
1727 float_signal (signo)
1728 /* If this is missing, some compilers complain. */
1731 if (float_handled == 0)
1733 #if defined (USG) || defined (hpux)
1734 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1737 signal (SIGFPE, float_signal);
1738 longjmp (float_handler, 1);
1741 /* Handler for SIGPIPE. */
1745 /* If this is missing, some compilers complain. */
1748 fatal ("output pipe has been closed");
1751 /* Strip off a legitimate source ending from the input string NAME of
1755 strip_off_ending (name, len)
1759 if (len > 2 && ! strcmp (".c", name + len - 2))
1761 else if (len > 2 && ! strcmp (".m", name + len - 2))
1763 else if (len > 2 && ! strcmp (".i", name + len - 2))
1765 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1767 else if (len > 3 && ! strcmp (".co", name + len - 3))
1769 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1771 else if (len > 2 && ! strcmp (".C", name + len - 2))
1773 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1775 else if (len > 4 && ! strcmp (".cpp", name + len - 4))
1777 else if (len > 2 && ! strcmp (".f", name + len - 2))
1779 /* Ada will use extensions like .ada, .adb, and .ads, so just test
1781 else if (len > 4 && ! strncmp (".ad", name + len - 4, 3))
1783 else if (len > 4 && ! strcmp (".atr", name + len - 4))
1787 /* Output a quoted string. */
1789 output_quoted_string (asm_file, string)
1795 putc ('\"', asm_file);
1796 while ((c = *string++) != 0)
1798 if (c == '\"' || c == '\\')
1799 putc ('\\', asm_file);
1802 putc ('\"', asm_file);
1805 /* Output a file name in the form wanted by System V. */
1808 output_file_directive (asm_file, input_name)
1812 int len = strlen (input_name);
1813 char *na = input_name + len;
1815 /* NA gets INPUT_NAME sans directory names. */
1816 while (na > input_name)
1823 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1824 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1826 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1827 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1829 fprintf (asm_file, "\t.file\t");
1830 output_quoted_string (asm_file, na);
1831 fputc ('\n', asm_file);
1836 /* Routine to build language identifier for object file. */
1838 output_lang_identify (asm_out_file)
1841 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1842 char *s = (char *) alloca (len);
1843 sprintf (s, "__gnu_compiled_%s", lang_identify ());
1844 ASM_OUTPUT_LABEL (asm_out_file, s);
1847 /* Compile an entire file of output from cpp, named NAME.
1848 Write a file of assembly output and various debugging dumps. */
1856 int dump_base_name_length;
1858 int name_specified = name != 0;
1860 if (dump_base_name == 0)
1861 dump_base_name = name ? name : "gccdump";
1862 dump_base_name_length = strlen (dump_base_name);
1866 integration_time = 0;
1874 local_alloc_time = 0;
1875 global_alloc_time = 0;
1878 shorten_branch_time = 0;
1884 /* Open input file. */
1886 if (name == 0 || !strcmp (name, "-"))
1892 finput = fopen (name, "r");
1894 pfatal_with_name (name);
1896 #ifdef IO_BUFFER_SIZE
1897 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
1900 /* Initialize data in various passes. */
1905 /* Some of these really don't need to be called when generating bytecode,
1906 but the options would have to be parsed first to know that. -bson */
1908 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
1909 || debug_info_level == DINFO_LEVEL_VERBOSE);
1910 init_decl_processing ();
1918 if (flag_caller_saves)
1919 init_caller_save ();
1921 /* If auxiliary info generation is desired, open the output file.
1922 This goes in the same directory as the source file--unlike
1923 all the other output files. */
1924 if (flag_gen_aux_info)
1926 aux_info_file = fopen (aux_info_file_name, "w");
1927 if (aux_info_file == 0)
1928 pfatal_with_name (aux_info_file_name);
1931 /* If rtl dump desired, open the output file. */
1934 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1935 strcpy (dumpname, dump_base_name);
1936 strcat (dumpname, ".rtl");
1937 rtl_dump_file = fopen (dumpname, "w");
1938 if (rtl_dump_file == 0)
1939 pfatal_with_name (dumpname);
1942 /* If jump_opt dump desired, open the output file. */
1945 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1946 strcpy (dumpname, dump_base_name);
1947 strcat (dumpname, ".jump");
1948 jump_opt_dump_file = fopen (dumpname, "w");
1949 if (jump_opt_dump_file == 0)
1950 pfatal_with_name (dumpname);
1953 /* If cse dump desired, open the output file. */
1956 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1957 strcpy (dumpname, dump_base_name);
1958 strcat (dumpname, ".cse");
1959 cse_dump_file = fopen (dumpname, "w");
1960 if (cse_dump_file == 0)
1961 pfatal_with_name (dumpname);
1964 /* If loop dump desired, open the output file. */
1967 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1968 strcpy (dumpname, dump_base_name);
1969 strcat (dumpname, ".loop");
1970 loop_dump_file = fopen (dumpname, "w");
1971 if (loop_dump_file == 0)
1972 pfatal_with_name (dumpname);
1975 /* If cse2 dump desired, open the output file. */
1978 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1979 strcpy (dumpname, dump_base_name);
1980 strcat (dumpname, ".cse2");
1981 cse2_dump_file = fopen (dumpname, "w");
1982 if (cse2_dump_file == 0)
1983 pfatal_with_name (dumpname);
1986 /* If flow dump desired, open the output file. */
1989 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1990 strcpy (dumpname, dump_base_name);
1991 strcat (dumpname, ".flow");
1992 flow_dump_file = fopen (dumpname, "w");
1993 if (flow_dump_file == 0)
1994 pfatal_with_name (dumpname);
1997 /* If combine dump desired, open the output file. */
2000 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
2001 strcpy (dumpname, dump_base_name);
2002 strcat (dumpname, ".combine");
2003 combine_dump_file = fopen (dumpname, "w");
2004 if (combine_dump_file == 0)
2005 pfatal_with_name (dumpname);
2008 /* If scheduling dump desired, open the output file. */
2011 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
2012 strcpy (dumpname, dump_base_name);
2013 strcat (dumpname, ".sched");
2014 sched_dump_file = fopen (dumpname, "w");
2015 if (sched_dump_file == 0)
2016 pfatal_with_name (dumpname);
2019 /* If local_reg dump desired, open the output file. */
2022 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
2023 strcpy (dumpname, dump_base_name);
2024 strcat (dumpname, ".lreg");
2025 local_reg_dump_file = fopen (dumpname, "w");
2026 if (local_reg_dump_file == 0)
2027 pfatal_with_name (dumpname);
2030 /* If global_reg dump desired, open the output file. */
2031 if (global_reg_dump)
2033 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
2034 strcpy (dumpname, dump_base_name);
2035 strcat (dumpname, ".greg");
2036 global_reg_dump_file = fopen (dumpname, "w");
2037 if (global_reg_dump_file == 0)
2038 pfatal_with_name (dumpname);
2041 /* If 2nd scheduling dump desired, open the output file. */
2044 register char *dumpname = (char *) xmalloc (dump_base_name_length + 8);
2045 strcpy (dumpname, dump_base_name);
2046 strcat (dumpname, ".sched2");
2047 sched2_dump_file = fopen (dumpname, "w");
2048 if (sched2_dump_file == 0)
2049 pfatal_with_name (dumpname);
2052 /* If jump2_opt dump desired, open the output file. */
2055 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
2056 strcpy (dumpname, dump_base_name);
2057 strcat (dumpname, ".jump2");
2058 jump2_opt_dump_file = fopen (dumpname, "w");
2059 if (jump2_opt_dump_file == 0)
2060 pfatal_with_name (dumpname);
2063 /* If dbr_sched dump desired, open the output file. */
2066 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
2067 strcpy (dumpname, dump_base_name);
2068 strcat (dumpname, ".dbr");
2069 dbr_sched_dump_file = fopen (dumpname, "w");
2070 if (dbr_sched_dump_file == 0)
2071 pfatal_with_name (dumpname);
2076 /* If stack_reg dump desired, open the output file. */
2079 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
2080 strcpy (dumpname, dump_base_name);
2081 strcat (dumpname, ".stack");
2082 stack_reg_dump_file = fopen (dumpname, "w");
2083 if (stack_reg_dump_file == 0)
2084 pfatal_with_name (dumpname);
2089 /* Open assembler code output file. */
2091 if (! name_specified && asm_file_name == 0)
2092 asm_out_file = stdout;
2095 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
2096 int len = strlen (dump_base_name);
2097 strcpy (dumpname, dump_base_name);
2098 strip_off_ending (dumpname, len);
2099 strcat (dumpname, ".s");
2100 if (asm_file_name == 0)
2102 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2103 strcpy (asm_file_name, dumpname);
2105 if (!strcmp (asm_file_name, "-"))
2106 asm_out_file = stdout;
2108 asm_out_file = fopen (asm_file_name, "w");
2109 if (asm_out_file == 0)
2110 pfatal_with_name (asm_file_name);
2113 #ifdef IO_BUFFER_SIZE
2114 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2115 _IOFBF, IO_BUFFER_SIZE);
2118 input_filename = name;
2120 /* Perform language-specific initialization.
2121 This may set main_input_filename. */
2124 /* If the input doesn't start with a #line, use the input name
2125 as the official input file name. */
2126 if (main_input_filename == 0)
2127 main_input_filename = name;
2129 /* Put an entry on the input file stack for the main input file. */
2131 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2132 input_file_stack->next = 0;
2133 input_file_stack->name = input_filename;
2135 if (!output_bytecode)
2137 ASM_FILE_START (asm_out_file);
2140 /* Output something to inform GDB that this compilation was by GCC. Also
2141 serves to tell GDB file consists of bytecodes. */
2142 if (output_bytecode)
2143 fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
2146 #ifndef ASM_IDENTIFY_GCC
2147 fprintf (asm_out_file, "gcc2_compiled.:\n");
2149 ASM_IDENTIFY_GCC (asm_out_file);
2153 /* Output something to identify which front-end produced this file. */
2154 #ifdef ASM_IDENTIFY_LANGUAGE
2155 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2158 if (output_bytecode)
2160 if (profile_flag || profile_block_flag)
2161 error ("profiling not supported in bytecode compilation");
2165 /* ??? Note: There used to be a conditional here
2166 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2167 This was to guarantee separation between gcc_compiled. and
2168 the first function, for the sake of dbx on Suns.
2169 However, having the extra zero here confused the Emacs
2170 code for unexec, and might confuse other programs too.
2171 Therefore, I took out that change.
2172 In future versions we should find another way to solve
2173 that dbx problem. -- rms, 23 May 93. */
2175 /* Don't let the first function fall at the same address
2176 as gcc_compiled., if profiling. */
2177 if (profile_flag || profile_block_flag)
2178 assemble_zeros (UNITS_PER_WORD);
2181 /* If dbx symbol table desired, initialize writing it
2182 and output the predefined types. */
2183 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2184 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2185 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2188 #ifdef SDB_DEBUGGING_INFO
2189 if (write_symbols == SDB_DEBUG)
2190 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2193 #ifdef DWARF_DEBUGGING_INFO
2194 if (write_symbols == DWARF_DEBUG)
2195 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2198 /* Initialize yet another pass. */
2200 if (!output_bytecode)
2201 init_final (main_input_filename);
2203 start_time = get_run_time ();
2205 /* Call the parser, which parses the entire file
2206 (calling rest_of_compilation for each function). */
2208 if (yyparse () != 0)
2210 if (errorcount == 0)
2211 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2213 /* In case there were missing closebraces,
2214 get us back to the global binding level. */
2215 while (! global_bindings_p ())
2219 /* Compilation is now finished except for writing
2220 what's left of the symbol table output. */
2222 parse_time += get_run_time () - start_time;
2224 parse_time -= integration_time;
2225 parse_time -= varconst_time;
2227 globals = getdecls ();
2229 /* Really define vars that have had only a tentative definition.
2230 Really output inline functions that must actually be callable
2231 and have not been output so far. */
2234 int len = list_length (globals);
2235 tree *vec = (tree *) alloca (sizeof (tree) * len);
2239 /* Process the decls in reverse order--earliest first.
2240 Put them into VEC from back to front, then take out from front. */
2242 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2243 vec[len - i - 1] = decl;
2245 for (i = 0; i < len; i++)
2248 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2249 && incomplete_decl_finalize_hook != 0)
2250 (*incomplete_decl_finalize_hook) (decl);
2252 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2253 && ! TREE_ASM_WRITTEN (decl))
2255 /* Don't write out static consts, unless we used them.
2256 (This used to write them out only if the address was
2257 taken, but that was wrong; if the variable was simply
2258 referred to, it still needs to exist or else it will
2259 be undefined in the linker.) */
2260 if (! TREE_READONLY (decl)
2261 || TREE_PUBLIC (decl)
2263 || TREE_ADDRESSABLE (decl)
2264 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
2265 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2267 /* Cancel the RTL for this decl so that, if debugging info
2268 output for global variables is still to come,
2269 this one will be omitted. */
2270 DECL_RTL (decl) = NULL;
2273 if (TREE_CODE (decl) == FUNCTION_DECL
2274 && ! TREE_ASM_WRITTEN (decl)
2275 && DECL_INITIAL (decl) != 0
2276 && (TREE_ADDRESSABLE (decl)
2277 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
2278 && ! DECL_EXTERNAL (decl))
2280 temporary_allocation ();
2281 output_inline_function (decl);
2282 permanent_allocation ();
2285 /* Warn about any function
2286 declared static but not defined.
2287 We don't warn about variables,
2288 because many programs have static variables
2289 that exist only to get some text into the object file. */
2292 || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))))
2293 && TREE_CODE (decl) == FUNCTION_DECL
2294 && DECL_INITIAL (decl) == 0
2295 && DECL_EXTERNAL (decl)
2296 && ! TREE_PUBLIC (decl))
2298 /* This should be a pedwarn, except that there is
2299 no easy way to prevent it from happening when the
2300 name is used only inside a sizeof.
2301 This at least avoids being incorrect. */
2302 warning_with_decl (decl,
2303 "`%s' declared `static' but never defined");
2304 /* This symbol is effectively an "extern" declaration now. */
2305 TREE_PUBLIC (decl) = 1;
2306 assemble_external (decl);
2309 /* Warn about static fns or vars defined but not used,
2310 but not about inline functions
2311 since unused inline statics is normal practice. */
2313 && (TREE_CODE (decl) == FUNCTION_DECL
2314 || TREE_CODE (decl) == VAR_DECL)
2315 && ! DECL_IN_SYSTEM_HEADER (decl)
2316 && ! DECL_EXTERNAL (decl)
2317 && ! TREE_PUBLIC (decl)
2318 && ! TREE_USED (decl)
2319 && ! DECL_INLINE (decl)
2320 && ! DECL_REGISTER (decl)
2321 /* The TREE_USED bit for file-scope decls
2322 is kept in the identifier, to handle multiple
2323 external decls in different scopes. */
2324 && ! TREE_USED (DECL_NAME (decl)))
2325 warning_with_decl (decl, "`%s' defined but not used");
2327 #ifdef SDB_DEBUGGING_INFO
2328 /* The COFF linker can move initialized global vars to the end.
2329 And that can screw up the symbol ordering.
2330 By putting the symbols in that order to begin with,
2331 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2332 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2333 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2334 && DECL_RTL (decl) != 0)
2335 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2337 /* Output COFF information for non-global
2338 file-scope initialized variables. */
2339 if (write_symbols == SDB_DEBUG
2340 && TREE_CODE (decl) == VAR_DECL
2341 && DECL_INITIAL (decl)
2342 && DECL_RTL (decl) != 0
2343 && GET_CODE (DECL_RTL (decl)) == MEM)
2344 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2345 #endif /* SDB_DEBUGGING_INFO */
2346 #ifdef DWARF_DEBUGGING_INFO
2347 /* Output DWARF information for file-scope tentative data object
2348 declarations, file-scope (extern) function declarations (which
2349 had no corresponding body) and file-scope tagged type declarations
2350 and definitions which have not yet been forced out. */
2352 if (write_symbols == DWARF_DEBUG
2353 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2354 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2359 /* Do dbx symbols */
2360 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2361 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2362 TIMEVAR (symout_time,
2364 dbxout_finish (asm_out_file, main_input_filename);
2368 #ifdef DWARF_DEBUGGING_INFO
2369 if (write_symbols == DWARF_DEBUG)
2370 TIMEVAR (symout_time,
2376 /* Output some stuff at end of file if nec. */
2378 if (!output_bytecode)
2380 end_final (main_input_filename);
2383 ASM_FILE_END (asm_out_file);
2387 after_finish_compilation:
2389 /* Language-specific end of compilation actions. */
2393 /* Close the dump files. */
2395 if (flag_gen_aux_info)
2397 fclose (aux_info_file);
2399 unlink (aux_info_file_name);
2403 fclose (rtl_dump_file);
2406 fclose (jump_opt_dump_file);
2409 fclose (cse_dump_file);
2412 fclose (loop_dump_file);
2415 fclose (cse2_dump_file);
2418 fclose (flow_dump_file);
2422 dump_combine_total_stats (combine_dump_file);
2423 fclose (combine_dump_file);
2427 fclose (sched_dump_file);
2430 fclose (local_reg_dump_file);
2432 if (global_reg_dump)
2433 fclose (global_reg_dump_file);
2436 fclose (sched2_dump_file);
2439 fclose (jump2_opt_dump_file);
2442 fclose (dbr_sched_dump_file);
2446 fclose (stack_reg_dump_file);
2449 /* Close non-debugging input and output files. Take special care to note
2450 whether fclose returns an error, since the pages might still be on the
2451 buffer chain while the file is open. */
2454 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2455 fatal_io_error (asm_file_name);
2457 /* Print the times. */
2461 fprintf (stderr,"\n");
2462 print_time ("parse", parse_time);
2464 if (!output_bytecode)
2466 print_time ("integration", integration_time);
2467 print_time ("jump", jump_time);
2468 print_time ("cse", cse_time);
2469 print_time ("loop", loop_time);
2470 print_time ("cse2", cse2_time);
2471 print_time ("flow", flow_time);
2472 print_time ("combine", combine_time);
2473 print_time ("sched", sched_time);
2474 print_time ("local-alloc", local_alloc_time);
2475 print_time ("global-alloc", global_alloc_time);
2476 print_time ("sched2", sched2_time);
2477 print_time ("dbranch", dbr_sched_time);
2478 print_time ("shorten-branch", shorten_branch_time);
2479 print_time ("stack-reg", stack_reg_time);
2480 print_time ("final", final_time);
2481 print_time ("varconst", varconst_time);
2482 print_time ("symout", symout_time);
2483 print_time ("dump", dump_time);
2488 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2489 and TYPE_DECL nodes.
2491 This does nothing for local (non-static) variables.
2492 Otherwise, it sets up the RTL and outputs any assembler code
2493 (label definition, storage allocation and initialization).
2495 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2496 the assembler symbol name to be used. TOP_LEVEL is nonzero
2497 if this declaration is not within a function. */
2500 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2506 /* Declarations of variables, and of functions defined elsewhere. */
2508 /* The most obvious approach, to put an #ifndef around where
2509 this macro is used, doesn't work since it's inside a macro call. */
2510 #ifndef ASM_FINISH_DECLARE_OBJECT
2511 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2514 /* Forward declarations for nested functions are not "external",
2515 but we need to treat them as if they were. */
2516 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2517 || TREE_CODE (decl) == FUNCTION_DECL)
2518 TIMEVAR (varconst_time,
2520 make_decl_rtl (decl, asmspec, top_level);
2521 /* Initialized extern variable exists to be replaced
2522 with its value, or represents something that will be
2523 output in another file. */
2524 if (! (TREE_CODE (decl) == VAR_DECL
2525 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2526 && DECL_INITIAL (decl) != 0
2527 && DECL_INITIAL (decl) != error_mark_node))
2528 /* Don't output anything
2529 when a tentative file-scope definition is seen.
2530 But at end of compilation, do output code for them. */
2531 if (! (! at_end && top_level
2532 && (DECL_INITIAL (decl) == 0
2533 || DECL_INITIAL (decl) == error_mark_node)))
2534 assemble_variable (decl, top_level, at_end, 0);
2535 if (decl == last_assemble_variable_decl)
2537 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2541 else if (DECL_REGISTER (decl) && asmspec != 0)
2543 if (decode_reg_name (asmspec) >= 0)
2545 DECL_RTL (decl) = 0;
2546 make_decl_rtl (decl, asmspec, top_level);
2549 error ("invalid register name `%s' for register variable", asmspec);
2551 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2552 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2553 && TREE_CODE (decl) == TYPE_DECL)
2554 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2556 #ifdef SDB_DEBUGGING_INFO
2557 else if (write_symbols == SDB_DEBUG && top_level
2558 && TREE_CODE (decl) == TYPE_DECL)
2559 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2563 /* Called after finishing a record, union or enumeral type. */
2566 rest_of_type_compilation (type, toplev)
2570 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2571 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2572 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2574 #ifdef SDB_DEBUGGING_INFO
2575 if (write_symbols == SDB_DEBUG)
2576 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2580 /* This is called from finish_function (within yyparse)
2581 after each top-level definition is parsed.
2582 It is supposed to compile that function or variable
2583 and output the assembler code for it.
2584 After we return, the tree storage is freed. */
2587 rest_of_compilation (decl)
2591 int start_time = get_run_time ();
2593 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2594 to be restored after we finish compiling the function
2595 (for use when compiling inline calls to this function). */
2596 tree saved_block_tree = 0;
2597 /* Likewise, for DECL_ARGUMENTS. */
2598 tree saved_arguments = 0;
2601 if (output_bytecode)
2604 /* If we are reconsidering an inline function
2605 at the end of compilation, skip the stuff for making it inline. */
2607 if (DECL_SAVED_INSNS (decl) == 0)
2609 int specd = DECL_INLINE (decl);
2612 /* If requested, consider whether to make this function inline. */
2613 if (specd || flag_inline_functions)
2614 TIMEVAR (integration_time,
2616 lose = function_cannot_inline_p (decl);
2617 /* If not optimzing, then make sure the DECL_INLINE
2619 if (lose || ! optimize)
2621 if (warn_inline && specd)
2622 warning_with_decl (decl, lose);
2623 DECL_INLINE (decl) = 0;
2624 /* Don't really compile an extern inline function.
2625 If we can't make it inline, pretend
2626 it was only declared. */
2627 if (DECL_EXTERNAL (decl))
2629 DECL_INITIAL (decl) = 0;
2630 goto exit_rest_of_compilation;
2634 DECL_INLINE (decl) = 1;
2637 insns = get_insns ();
2639 /* Dump the rtl code if we are dumping rtl. */
2644 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2645 IDENTIFIER_POINTER (DECL_NAME (decl)));
2646 if (DECL_SAVED_INSNS (decl))
2647 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2648 print_rtl (rtl_dump_file, insns);
2649 fflush (rtl_dump_file);
2652 /* If function is inline, and we don't yet know whether to
2653 compile it by itself, defer decision till end of compilation.
2654 finish_compilation will call rest_of_compilation again
2655 for those functions that need to be output. Also defer those
2656 functions that were marked inline but weren't inlined; they
2657 may never be used. */
2659 if ((specd || DECL_INLINE (decl))
2660 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2661 && ! flag_keep_inline_functions)
2662 || DECL_EXTERNAL (decl)))
2664 #ifdef DWARF_DEBUGGING_INFO
2665 /* Generate the DWARF info for the "abstract" instance
2666 of a function which we may later generate inlined and/or
2667 out-of-line instances of. */
2668 if (write_symbols == DWARF_DEBUG)
2670 set_decl_abstract_flags (decl, 1);
2671 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2672 set_decl_abstract_flags (decl, 0);
2675 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2676 goto exit_rest_of_compilation;
2679 /* If we have to compile the function now, save its rtl and subdecls
2680 so that its compilation will not affect what others get. */
2681 if (DECL_INLINE (decl))
2683 #ifdef DWARF_DEBUGGING_INFO
2684 /* Generate the DWARF info for the "abstract" instance of
2685 a function which we will generate an out-of-line instance
2686 of almost immediately (and which we may also later generate
2687 various inlined instances of). */
2688 if (write_symbols == DWARF_DEBUG)
2690 set_decl_abstract_flags (decl, 1);
2691 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2692 set_decl_abstract_flags (decl, 0);
2695 saved_block_tree = DECL_INITIAL (decl);
2696 saved_arguments = DECL_ARGUMENTS (decl);
2697 TIMEVAR (integration_time, save_for_inline_copying (decl));
2701 TREE_ASM_WRITTEN (decl) = 1;
2703 /* Now that integrate will no longer see our rtl, we need not distinguish
2704 between the return value of this function and the return value of called
2706 rtx_equal_function_value_matters = 0;
2708 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2709 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2711 goto exit_rest_of_compilation;
2714 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2715 Note that that may have been done above, in save_for_inline_copying.
2716 The call to resume_temporary_allocation near the end of this function
2717 goes back to the usual state of affairs. */
2719 rtl_in_current_obstack ();
2722 /* If we are doing position-independent code generation, now
2723 is the time to output special prologues and epilogues.
2724 We do not want to do this earlier, because it just clutters
2725 up inline functions with meaningless insns. */
2730 insns = get_insns ();
2732 /* Copy any shared structure that should not be shared. */
2734 unshare_all_rtl (insns);
2736 /* Instantiate all virtual registers. */
2738 instantiate_virtual_regs (current_function_decl, get_insns ());
2740 /* See if we have allocated stack slots that are not directly addressable.
2741 If so, scan all the insns and create explicit address computation
2742 for all references to such slots. */
2743 /* fixup_stack_slots (); */
2745 /* Do jump optimization the first time, if -opt.
2746 Also do it if -W, but in that case it doesn't change the rtl code,
2747 it only computes whether control can drop off the end of the function. */
2749 if (optimize > 0 || extra_warnings || warn_return_type
2750 /* If function is `noreturn', we should warn if it tries to return. */
2751 || TREE_THIS_VOLATILE (decl))
2753 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2754 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2757 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2758 if (rtl_dump_and_exit || flag_syntax_only)
2759 goto exit_rest_of_compilation;
2761 /* Dump rtl code after jump, if we are doing that. */
2766 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2767 IDENTIFIER_POINTER (DECL_NAME (decl)));
2768 print_rtl (jump_opt_dump_file, insns);
2769 fflush (jump_opt_dump_file);
2772 /* Perform common subexpression elimination.
2773 Nonzero value from `cse_main' means that jumps were simplified
2774 and some code may now be unreachable, so do
2775 jump optimization again. */
2780 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2781 IDENTIFIER_POINTER (DECL_NAME (decl)));
2786 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2788 if (flag_thread_jumps)
2789 /* Hacks by tiemann & kenner. */
2790 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
2792 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2794 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2797 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2800 /* Dump rtl code after cse, if we are doing that. */
2805 print_rtl (cse_dump_file, insns);
2806 fflush (cse_dump_file);
2812 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2813 IDENTIFIER_POINTER (DECL_NAME (decl)));
2816 /* Move constant computations out of loops. */
2822 loop_optimize (insns, loop_dump_file);
2826 /* Dump rtl code after loop opt, if we are doing that. */
2831 print_rtl (loop_dump_file, insns);
2832 fflush (loop_dump_file);
2838 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2839 IDENTIFIER_POINTER (DECL_NAME (decl)));
2842 if (optimize > 0 && flag_rerun_cse_after_loop)
2844 /* Running another jump optimization pass before the second
2845 cse pass sometimes simplifies the RTL enough to allow
2846 the second CSE pass to do a better job. Jump_optimize can change
2847 max_reg_num so we must rerun reg_scan afterwards.
2848 ??? Rework to not call reg_scan so often. */
2849 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2850 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2852 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2853 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2854 1, cse2_dump_file));
2856 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2859 if (optimize > 0 && flag_thread_jumps)
2860 /* This pass of jump threading straightens out code
2861 that was kinked by loop optimization. */
2862 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2864 /* Dump rtl code after cse, if we are doing that. */
2869 print_rtl (cse2_dump_file, insns);
2870 fflush (cse2_dump_file);
2873 /* We are no longer anticipating cse in this function, at least. */
2875 cse_not_expected = 1;
2877 /* Now we choose between stupid (pcc-like) register allocation
2878 (if we got the -noreg switch and not -opt)
2879 and smart register allocation. */
2881 if (optimize > 0) /* Stupid allocation probably won't work */
2882 obey_regdecls = 0; /* if optimizations being done. */
2886 /* Print function header into flow dump now
2887 because doing the flow analysis makes some of the dump. */
2892 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2893 IDENTIFIER_POINTER (DECL_NAME (decl)));
2900 regclass (insns, max_reg_num ());
2901 stupid_life_analysis (insns, max_reg_num (),
2907 /* Do control and data flow analysis,
2908 and write some of the results to dump file. */
2910 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2912 if (warn_uninitialized)
2914 uninitialized_vars_warning (DECL_INITIAL (decl));
2915 setjmp_args_warning ();
2919 /* Dump rtl after flow analysis. */
2924 print_rtl (flow_dump_file, insns);
2925 fflush (flow_dump_file);
2928 /* If -opt, try combining insns through substitution. */
2931 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2933 /* Dump rtl code after insn combination. */
2938 fprintf (combine_dump_file, "\n;; Function %s\n\n",
2939 IDENTIFIER_POINTER (DECL_NAME (decl)));
2940 dump_combine_stats (combine_dump_file);
2941 print_rtl (combine_dump_file, insns);
2942 fflush (combine_dump_file);
2945 /* Print function header into sched dump now
2946 because doing the sched analysis makes some of the dump. */
2951 fprintf (sched_dump_file, "\n;; Function %s\n\n",
2952 IDENTIFIER_POINTER (DECL_NAME (decl)));
2955 if (optimize > 0 && flag_schedule_insns)
2957 /* Do control and data sched analysis,
2958 and write some of the results to dump file. */
2960 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
2963 /* Dump rtl after instruction scheduling. */
2968 print_rtl (sched_dump_file, insns);
2969 fflush (sched_dump_file);
2972 /* Unless we did stupid register allocation,
2973 allocate pseudo-regs that are used only within 1 basic block. */
2976 TIMEVAR (local_alloc_time,
2978 regclass (insns, max_reg_num ());
2982 /* Dump rtl code after allocating regs within basic blocks. */
2987 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
2988 IDENTIFIER_POINTER (DECL_NAME (decl)));
2989 dump_flow_info (local_reg_dump_file);
2990 dump_local_alloc (local_reg_dump_file);
2991 print_rtl (local_reg_dump_file, insns);
2992 fflush (local_reg_dump_file);
2995 if (global_reg_dump)
2997 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
2998 IDENTIFIER_POINTER (DECL_NAME (decl))));
3000 /* Unless we did stupid register allocation,
3001 allocate remaining pseudo-regs, then do the reload pass
3002 fixing up any insns that are invalid. */
3004 TIMEVAR (global_alloc_time,
3007 failure = global_alloc (global_reg_dump_file);
3009 failure = reload (insns, 0, global_reg_dump_file);
3012 if (global_reg_dump)
3015 dump_global_regs (global_reg_dump_file);
3016 print_rtl (global_reg_dump_file, insns);
3017 fflush (global_reg_dump_file);
3021 goto exit_rest_of_compilation;
3023 reload_completed = 1;
3025 /* On some machines, the prologue and epilogue code, or parts thereof,
3026 can be represented as RTL. Doing so lets us schedule insns between
3027 it and the rest of the code and also allows delayed branch
3028 scheduling to operate in the epilogue. */
3030 thread_prologue_and_epilogue_insns (insns);
3032 if (optimize > 0 && flag_schedule_insns_after_reload)
3037 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
3038 IDENTIFIER_POINTER (DECL_NAME (decl)));
3041 /* Do control and data sched analysis again,
3042 and write some more of the results to dump file. */
3044 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
3046 /* Dump rtl after post-reorder instruction scheduling. */
3051 print_rtl (sched2_dump_file, insns);
3052 fflush (sched2_dump_file);
3056 #ifdef LEAF_REGISTERS
3058 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3062 /* One more attempt to remove jumps to .+1
3063 left by dead-store-elimination.
3064 Also do cross-jumping this time
3065 and delete no-op move insns. */
3069 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3072 /* Dump rtl code after jump, if we are doing that. */
3077 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
3078 IDENTIFIER_POINTER (DECL_NAME (decl)));
3079 print_rtl (jump2_opt_dump_file, insns);
3080 fflush (jump2_opt_dump_file);
3083 /* If a scheduling pass for delayed branches is to be done,
3084 call the scheduling code. */
3087 if (optimize > 0 && flag_delayed_branch)
3089 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3094 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
3095 IDENTIFIER_POINTER (DECL_NAME (decl)));
3096 print_rtl (dbr_sched_dump_file, insns);
3097 fflush (dbr_sched_dump_file);
3104 /* Shorten branches. */
3105 TIMEVAR (shorten_branch_time,
3107 shorten_branches (get_insns ());
3111 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3116 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
3117 IDENTIFIER_POINTER (DECL_NAME (decl)));
3118 print_rtl (stack_reg_dump_file, insns);
3119 fflush (stack_reg_dump_file);
3124 /* Now turn the rtl into assembler code. */
3126 TIMEVAR (final_time,
3131 /* Get the function's name, as described by its RTL.
3132 This may be different from the DECL_NAME name used
3133 in the source file. */
3135 x = DECL_RTL (decl);
3136 if (GET_CODE (x) != MEM)
3139 if (GET_CODE (x) != SYMBOL_REF)
3141 fnname = XSTR (x, 0);
3143 assemble_start_function (decl, fnname);
3144 final_start_function (insns, asm_out_file, optimize);
3145 final (insns, asm_out_file, optimize, 0);
3146 final_end_function (insns, asm_out_file, optimize);
3147 assemble_end_function (decl, fnname);
3148 fflush (asm_out_file);
3151 /* Write DBX symbols if requested */
3153 /* Note that for those inline functions where we don't initially
3154 know for certain that we will be generating an out-of-line copy,
3155 the first invocation of this routine (rest_of_compilation) will
3156 skip over this code by doing a `goto exit_rest_of_compilation;'.
3157 Later on, finish_compilation will call rest_of_compilation again
3158 for those inline functions that need to have out-of-line copies
3159 generated. During that call, we *will* be routed past here. */
3161 #ifdef DBX_DEBUGGING_INFO
3162 if (write_symbols == DBX_DEBUG)
3163 TIMEVAR (symout_time, dbxout_function (decl));
3166 #ifdef DWARF_DEBUGGING_INFO
3167 if (write_symbols == DWARF_DEBUG)
3168 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3171 exit_rest_of_compilation:
3173 /* In case the function was not output,
3174 don't leave any temporary anonymous types
3175 queued up for sdb output. */
3176 #ifdef SDB_DEBUGGING_INFO
3177 if (write_symbols == SDB_DEBUG)
3178 sdbout_types (NULL_TREE);
3181 /* Put back the tree of subblocks and list of arguments
3182 from before we copied them.
3183 Code generation and the output of debugging info may have modified
3184 the copy, but the original is unchanged. */
3186 if (saved_block_tree != 0)
3187 DECL_INITIAL (decl) = saved_block_tree;
3188 if (saved_arguments != 0)
3189 DECL_ARGUMENTS (decl) = saved_arguments;
3191 reload_completed = 0;
3193 /* Clear out the real_constant_chain before some of the rtx's
3194 it runs through become garbage. */
3196 clear_const_double_mem ();
3198 /* Cancel the effect of rtl_in_current_obstack. */
3200 resume_temporary_allocation ();
3202 /* The parsing time is all the time spent in yyparse
3203 *except* what is spent in this function. */
3205 parse_time -= get_run_time () - start_time;
3208 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3209 Exit code is 35 if can't open files, 34 if fatal error,
3210 33 if had nonfatal errors, else success. */
3213 main (argc, argv, envp)
3220 int flag_print_mem = 0;
3221 int version_flag = 0;
3224 /* save in case md file wants to emit args as a comment. */
3228 p = argv[0] + strlen (argv[0]);
3229 while (p != argv[0] && p[-1] != '/') --p;
3233 /* Get rid of any avoidable limit on stack size. */
3237 /* Set the stack limit huge so that alloca does not fail. */
3238 getrlimit (RLIMIT_STACK, &rlim);
3239 rlim.rlim_cur = rlim.rlim_max;
3240 setrlimit (RLIMIT_STACK, &rlim);
3242 #endif /* RLIMIT_STACK */
3244 signal (SIGFPE, float_signal);
3247 signal (SIGPIPE, pipe_closed);
3250 decl_printable_name = decl_name;
3251 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3253 /* Initialize whether `char' is signed. */
3254 flag_signed_char = DEFAULT_SIGNED_CHAR;
3255 #ifdef DEFAULT_SHORT_ENUMS
3256 /* Initialize how much space enums occupy, by default. */
3257 flag_short_enums = DEFAULT_SHORT_ENUMS;
3260 /* Scan to see what optimization level has been specified. That will
3261 determine the default value of many flags. */
3262 for (i = 1; i < argc; i++)
3264 if (!strcmp (argv[i], "-O"))
3268 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3270 /* Handle -O2, -O3, -O69, ... */
3271 char *p = &argv[i][2];
3275 if (! (c >= '0' && c <= '9'))
3278 optimize = atoi (&argv[i][2]);
3282 obey_regdecls = (optimize == 0);
3292 flag_thread_jumps = 1;
3294 flag_delayed_branch = 1;
3296 #ifdef CAN_DEBUG_WITHOUT_FP
3297 flag_omit_frame_pointer = 1;
3303 flag_cse_follow_jumps = 1;
3304 flag_cse_skip_blocks = 1;
3305 flag_expensive_optimizations = 1;
3306 flag_strength_reduce = 1;
3307 flag_rerun_cse_after_loop = 1;
3308 flag_caller_saves = 1;
3309 #ifdef INSN_SCHEDULING
3310 flag_schedule_insns = 1;
3311 flag_schedule_insns_after_reload = 1;
3317 flag_inline_functions = 1;
3320 #ifdef OPTIMIZATION_OPTIONS
3321 /* Allow default optimizations to be specified on a per-machine basis. */
3322 OPTIMIZATION_OPTIONS (optimize);
3325 /* Initialize register usage now so switches may override. */
3329 set_target_switch ("");
3331 for (i = 1; i < argc; i++)
3334 /* If this is a language-specific option,
3335 decode it in a language-specific way. */
3336 for (j = 0; lang_options[j] != 0; j++)
3337 if (!strncmp (argv[i], lang_options[j],
3338 strlen (lang_options[j])))
3340 if (lang_options[j] != 0)
3341 /* If the option is valid for *some* language,
3342 treat it as valid even if this language doesn't understand it. */
3343 lang_decode_option (argv[i]);
3344 else if (argv[i][0] == '-' && argv[i][1] != 0)
3346 register char *str = argv[i] + 1;
3351 set_target_switch (&str[1]);
3352 else if (!strcmp (str, "dumpbase"))
3354 dump_base_name = argv[++i];
3356 else if (str[0] == 'd')
3358 register char *p = &str[1];
3366 global_reg_dump = 1;
3372 cse_dump = 1, cse2_dump = 1;
3390 global_reg_dump = 1;
3408 flag_print_asm_name = 1;
3430 rtl_dump_and_exit = 1;
3434 else if (str[0] == 'f')
3436 register char *p = &str[1];
3439 /* Some kind of -f option.
3440 P's value is the option sans `-f'.
3441 Search for it in the table of options. */
3444 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3447 if (!strcmp (p, f_options[j].string))
3449 *f_options[j].variable = f_options[j].on_value;
3450 /* A goto here would be cleaner,
3451 but breaks the vax pcc. */
3454 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3455 && ! strcmp (p+3, f_options[j].string))
3457 *f_options[j].variable = ! f_options[j].on_value;
3464 else if (!strncmp (p, "fixed-", 6))
3465 fix_register (&p[6], 1, 1);
3466 else if (!strncmp (p, "call-used-", 10))
3467 fix_register (&p[10], 0, 1);
3468 else if (!strncmp (p, "call-saved-", 11))
3469 fix_register (&p[11], 0, 0);
3471 error ("Invalid option `%s'", argv[i]);
3473 else if (str[0] == 'O')
3475 register char *p = str+1;
3476 while (*p && *p >= '0' && *p <= '9')
3481 error ("Invalid option `%s'", argv[i]);
3483 else if (!strcmp (str, "pedantic"))
3485 else if (!strcmp (str, "pedantic-errors"))
3486 flag_pedantic_errors = pedantic = 1;
3487 else if (!strcmp (str, "quiet"))
3489 else if (!strcmp (str, "version"))
3491 else if (!strcmp (str, "w"))
3492 inhibit_warnings = 1;
3493 else if (!strcmp (str, "W"))
3496 /* We save the value of warn_uninitialized, since if they put
3497 -Wuninitialized on the command line, we need to generate a
3498 warning about not using it without also specifying -O. */
3499 if (warn_uninitialized != 1)
3500 warn_uninitialized = 2;
3502 else if (str[0] == 'W')
3504 register char *p = &str[1];
3507 /* Some kind of -W option.
3508 P's value is the option sans `-W'.
3509 Search for it in the table of options. */
3512 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3515 if (!strcmp (p, W_options[j].string))
3517 *W_options[j].variable = W_options[j].on_value;
3518 /* A goto here would be cleaner,
3519 but breaks the vax pcc. */
3522 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3523 && ! strcmp (p+3, W_options[j].string))
3525 *W_options[j].variable = ! W_options[j].on_value;
3532 else if (!strncmp (p, "id-clash-", 9))
3538 if (*endp >= '0' && *endp <= '9')
3542 error ("Invalid option `%s'", argv[i]);
3547 id_clash_len = atoi (str + 10);
3551 error ("Invalid option `%s'", argv[i]);
3553 else if (!strcmp (str, "p"))
3555 if (!output_bytecode)
3558 error ("profiling not supported in bytecode compilation");
3560 else if (!strcmp (str, "a"))
3562 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3563 warning ("`-a' option (basic block profile) not supported");
3565 profile_block_flag = 1;
3568 else if (str[0] == 'g')
3575 while (*p && (*p < '0' || *p > '9'))
3579 while (*q && (*q >= '0' && *q <= '9'))
3584 level = 2; /* default debugging info level */
3585 if (*q || level > 3)
3587 warning ("invalid debug level specification in option: `-%s'",
3589 warning ("no debugging information will be generated");
3593 /* If more than one debugging type is supported,
3594 you must define PREFERRED_DEBUGGING_TYPE
3595 to choose a format in a system-dependent way. */
3596 /* This is one long line cause VAXC can't handle a \-newline. */
3597 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3598 #ifdef PREFERRED_DEBUGGING_TYPE
3599 if (!strncmp (str, "ggdb", len))
3600 write_symbols = PREFERRED_DEBUGGING_TYPE;
3601 #else /* no PREFERRED_DEBUGGING_TYPE */
3602 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3603 #endif /* no PREFERRED_DEBUGGING_TYPE */
3604 #endif /* More than one debugger format enabled. */
3605 #ifdef DBX_DEBUGGING_INFO
3606 if (write_symbols != NO_DEBUG)
3608 else if (!strncmp (str, "ggdb", len))
3609 write_symbols = DBX_DEBUG;
3610 else if (!strncmp (str, "gstabs", len))
3611 write_symbols = DBX_DEBUG;
3612 else if (!strncmp (str, "gstabs+", len))
3613 write_symbols = DBX_DEBUG;
3615 /* Always enable extensions for -ggdb or -gstabs+,
3616 always disable for -gstabs.
3617 For plain -g, use system-specific default. */
3618 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3620 use_gnu_debug_info_extensions = 1;
3621 else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
3623 use_gnu_debug_info_extensions = 1;
3624 else if (write_symbols == DBX_DEBUG
3625 && !strncmp (str, "gstabs", len) && len >= 2)
3626 use_gnu_debug_info_extensions = 0;
3628 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3629 #endif /* DBX_DEBUGGING_INFO */
3630 #ifdef DWARF_DEBUGGING_INFO
3631 if (write_symbols != NO_DEBUG)
3633 else if (!strncmp (str, "g", len))
3634 write_symbols = DWARF_DEBUG;
3635 else if (!strncmp (str, "ggdb", len))
3636 write_symbols = DWARF_DEBUG;
3637 else if (!strncmp (str, "gdwarf", len))
3638 write_symbols = DWARF_DEBUG;
3640 /* Always enable extensions for -ggdb or -gdwarf+,
3641 always disable for -gdwarf.
3642 For plain -g, use system-specific default. */
3643 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3645 use_gnu_debug_info_extensions = 1;
3646 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3647 use_gnu_debug_info_extensions = 1;
3648 else if (write_symbols == DWARF_DEBUG
3649 && !strncmp (str, "gdwarf", len) && len >= 2)
3650 use_gnu_debug_info_extensions = 0;
3652 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3654 #ifdef SDB_DEBUGGING_INFO
3655 if (write_symbols != NO_DEBUG)
3657 else if (!strncmp (str, "g", len))
3658 write_symbols = SDB_DEBUG;
3659 else if (!strncmp (str, "gdb", len))
3660 write_symbols = SDB_DEBUG;
3661 else if (!strncmp (str, "gcoff", len))
3662 write_symbols = SDB_DEBUG;
3663 #endif /* SDB_DEBUGGING_INFO */
3664 #ifdef XCOFF_DEBUGGING_INFO
3665 if (write_symbols != NO_DEBUG)
3667 else if (!strncmp (str, "g", len))
3668 write_symbols = XCOFF_DEBUG;
3669 else if (!strncmp (str, "ggdb", len))
3670 write_symbols = XCOFF_DEBUG;
3671 else if (!strncmp (str, "gxcoff", len))
3672 write_symbols = XCOFF_DEBUG;
3674 /* Always enable extensions for -ggdb or -gxcoff+,
3675 always disable for -gxcoff.
3676 For plain -g, use system-specific default. */
3677 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3679 use_gnu_debug_info_extensions = 1;
3680 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3681 use_gnu_debug_info_extensions = 1;
3682 else if (write_symbols == XCOFF_DEBUG
3683 && !strncmp (str, "gxcoff", len) && len >= 2)
3684 use_gnu_debug_info_extensions = 0;
3686 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3688 if (write_symbols == NO_DEBUG)
3689 warning ("`-%s' option not supported on this version of GCC", str);
3690 else if (level == 0)
3691 write_symbols = NO_DEBUG;
3693 debug_info_level = (enum debug_info_level) level;
3695 else if (!strcmp (str, "o"))
3697 asm_file_name = argv[++i];
3699 else if (str[0] == 'G')
3701 g_switch_set = TRUE;
3702 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3704 else if (!strncmp (str, "aux-info", 8))
3706 flag_gen_aux_info = 1;
3707 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3710 error ("Invalid option `%s'", argv[i]);
3712 else if (argv[i][0] == '+')
3713 error ("Invalid option `%s'", argv[i]);
3718 /* Initialize for bytecode output. A good idea to do this as soon as
3719 possible after the "-f" options have been parsed. */
3720 if (output_bytecode)
3722 #ifndef TARGET_SUPPORTS_BYTECODE
3723 /* Just die with a fatal error if not supported */
3724 fatal ("-fbytecode can not be used for this target");
3732 /* Inlining does not work if not optimizing,
3733 so force it not to be done. */
3737 /* The c_decode_option and lang_decode_option functions set
3738 this to `2' if -Wall is used, so we can avoid giving out
3739 lots of errors for people who don't realize what -Wall does. */
3740 if (warn_uninitialized == 1)
3741 warning ("-Wuninitialized is not supported without -O");
3744 #if defined(DWARF_DEBUGGING_INFO)
3745 if (write_symbols == DWARF_DEBUG
3746 && strcmp (language_string, "GNU C++") == 0)
3748 warning ("-g option not supported for C++ on SVR4 systems");
3749 write_symbols = NO_DEBUG;
3751 #endif /* defined(DWARF_DEBUGGING_INFO) */
3753 #ifdef OVERRIDE_OPTIONS
3754 /* Some machines may reject certain combinations of options. */
3758 /* Unrolling all loops implies that standard loop unrolling must also
3760 if (flag_unroll_all_loops)
3761 flag_unroll_loops = 1;
3762 /* Loop unrolling requires that strength_reduction be on also. Silently
3763 turn on strength reduction here if it isn't already on. Also, the loop
3764 unrolling code assumes that cse will be run after loop, so that must
3765 be turned on also. */
3766 if (flag_unroll_loops)
3768 flag_strength_reduce = 1;
3769 flag_rerun_cse_after_loop = 1;
3772 /* Warn about options that are not supported on this machine. */
3773 #ifndef INSN_SCHEDULING
3774 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3775 warning ("instruction scheduling not supported on this target machine");
3778 if (flag_delayed_branch)
3779 warning ("this target machine does not have delayed branches");
3782 /* If we are in verbose mode, write out the version and maybe all the
3783 option flags in use. */
3786 fprintf (stderr, "%s version %s", language_string, version_string);
3787 #ifdef TARGET_VERSION
3792 #define __VERSION__ "[unknown]"
3794 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3796 fprintf (stderr, " compiled by CC.\n");
3799 print_switch_values ();
3802 /* Now that register usage is specified, convert it to HARD_REG_SETs. */
3803 if (!output_bytecode)
3806 compile_file (filename);
3808 if (output_bytecode)
3809 bc_write_file (stdout);
3815 char *lim = (char *) sbrk (0);
3817 fprintf (stderr, "Data size %d.\n",
3818 lim - (char *) &environ);
3822 system ("ps -l 1>&2");
3825 #endif /* not USG */
3827 #endif /* not VMS */
3828 #endif /* not OS2 */
3831 exit (FATAL_EXIT_CODE);
3833 exit (FATAL_EXIT_CODE);
3834 exit (SUCCESS_EXIT_CODE);
3838 /* Decode -m switches. */
3840 /* Here is a table, controlled by the tm.h file, listing each -m switch
3841 and which bits in `target_switches' it should set or clear.
3842 If VALUE is positive, it is bits to set.
3843 If VALUE is negative, -VALUE is bits to clear.
3844 (The sign bit is not used so there is no confusion.) */
3846 struct {char *name; int value;} target_switches []
3849 /* This table is similar, but allows the switch to have a value. */
3851 #ifdef TARGET_OPTIONS
3852 struct {char *prefix; char ** variable;} target_options []
3856 /* Decode the switch -mNAME. */
3859 set_target_switch (name)
3865 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3866 if (!strcmp (target_switches[j].name, name))
3868 if (target_switches[j].value < 0)
3869 target_flags &= ~-target_switches[j].value;
3871 target_flags |= target_switches[j].value;
3875 #ifdef TARGET_OPTIONS
3877 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3879 int len = strlen (target_options[j].prefix);
3880 if (!strncmp (target_options[j].prefix, name, len))
3882 *target_options[j].variable = name + len;
3889 error ("Invalid option `%s'", name);
3892 /* Variable used for communication between the following two routines. */
3894 static int line_position;
3896 /* Print an option value and adjust the position in the line. */
3899 print_single_switch (type, name)
3902 fprintf (stderr, " %s%s", type, name);
3904 line_position += strlen (type) + strlen (name) + 1;
3906 if (line_position > 65)
3908 fprintf (stderr, "\n\t");
3913 /* Print default target switches for -version. */
3916 print_switch_values ()
3920 fprintf (stderr, "enabled:");
3923 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3924 if (*f_options[j].variable == f_options[j].on_value)
3925 print_single_switch ("-f", f_options[j].string);
3927 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
3928 if (*W_options[j].variable == W_options[j].on_value)
3929 print_single_switch ("-W", W_options[j].string);
3931 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3932 if (target_switches[j].name[0] != '\0'
3933 && target_switches[j].value > 0
3934 && ((target_switches[j].value & target_flags)
3935 == target_switches[j].value))
3936 print_single_switch ("-m", target_switches[j].name);
3938 fprintf (stderr, "\n");