1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-6, 1997 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This is the top level of cc1/c++.
22 It parses command args, opens files, invokes the various passes
23 in the proper order, and counts the time used by each.
24 Error messages and low-level interface to malloc also handled here. */
35 #include <sys/types.h>
42 #include <sys/param.h>
43 /* This is for hpux. It is a real screw. They should change hpux. */
45 #include <sys/times.h>
46 #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
47 #undef FFS /* Some systems define this in param.h. */
51 #include <sys/resource.h>
60 #include "insn-attr.h"
67 #ifdef XCOFF_DEBUGGING_INFO
72 /* The extra parameters substantially improve the I/O performance. */
74 vms_fopen (fname, type)
78 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
79 fixed arguments, which matches ANSI's specification but not VAXCRTL's
80 pre-ANSI implementation. This hack circumvents the mismatch problem. */
81 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
84 return (*vmslib_fopen) (fname, type, "mbc=32",
85 "deq=64", "fop=tef", "shr=nil");
87 return (*vmslib_fopen) (fname, type, "mbc=32");
89 #define fopen vms_fopen
92 #ifndef DEFAULT_GDB_EXTENSIONS
93 #define DEFAULT_GDB_EXTENSIONS 1
96 /* If more than one debugging type is supported, you must define
97 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
99 This is one long line cause VAXC can't handle a \-newline. */
100 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
101 #ifndef PREFERRED_DEBUGGING_TYPE
102 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
103 #endif /* no PREFERRED_DEBUGGING_TYPE */
104 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
105 so the following code needn't care. */
106 #ifdef DBX_DEBUGGING_INFO
107 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
109 #ifdef SDB_DEBUGGING_INFO
110 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
112 #ifdef DWARF_DEBUGGING_INFO
113 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
115 #ifdef DWARF2_DEBUGGING_INFO
116 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
118 #ifdef XCOFF_DEBUGGING_INFO
119 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
121 #endif /* More than one debugger format enabled. */
123 /* If still not defined, must have been because no debugging formats
125 #ifndef PREFERRED_DEBUGGING_TYPE
126 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
129 extern int rtx_equal_function_value_matters;
131 #if ! (defined (VMS) || defined (OS2))
132 extern char **environ;
134 extern char *version_string, *language_string;
136 /* Carry information from ASM_DECLARE_OBJECT_NAME
137 to ASM_FINISH_DECLARE_OBJECT. */
139 extern int size_directive_output;
140 extern tree last_assemble_variable_decl;
142 extern void init_lex ();
143 extern void init_decl_processing ();
144 extern void init_obstacks ();
145 extern void init_tree_codes ();
146 extern void init_rtl ();
147 extern void init_regs ();
148 extern void init_optabs ();
149 extern void init_stmt ();
150 extern void init_reg_sets ();
151 extern void dump_flow_info ();
152 extern void dump_sched_info ();
153 extern void dump_local_alloc ();
155 void rest_of_decl_compilation ();
156 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
157 void error_with_decl PVPROTO((tree decl, char *s, ...));
158 void error_for_asm PVPROTO((rtx insn, char *s, ...));
159 void error PVPROTO((char *s, ...));
160 void fatal PVPROTO((char *s, ...));
161 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
162 void warning_with_decl PVPROTO((tree decl, char *s, ...));
163 void warning_for_asm PVPROTO((rtx insn, char *s, ...));
164 void warning PVPROTO((char *s, ...));
165 void pedwarn PVPROTO((char *s, ...));
166 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
167 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
168 void sorry PVPROTO((char *s, ...));
169 void really_sorry PVPROTO((char *s, ...));
174 void set_target_switch ();
175 static char *decl_name ();
177 void print_version ();
178 int print_single_switch ();
179 void print_switch_values ();
180 /* Length of line when printing switch values. */
184 extern char *sbrk ();
187 /* Name of program invoked, sans directories. */
191 /* Copy of arguments to main. */
195 /* Name of current original source file (what was input to cpp).
196 This comes from each #-command in the actual input. */
198 char *input_filename;
200 /* Name of top-level original source file (what was input to cpp).
201 This comes from the #-command at the beginning of the actual input.
202 If there isn't any there, then this is the cc1 input file name. */
204 char *main_input_filename;
206 /* Stream for reading from the input file. */
210 /* Current line number in real source file. */
214 /* Stack of currently pending input files. */
216 struct file_stack *input_file_stack;
218 /* Incremented on each change to input_file_stack. */
219 int input_file_stack_tick;
221 /* FUNCTION_DECL for function now being parsed or compiled. */
223 extern tree current_function_decl;
225 /* Name to use as base of names for dump output files. */
227 char *dump_base_name;
229 /* Bit flags that specify the machine subtype we are compiling for.
230 Bits are tested using macros TARGET_... defined in the tm.h file
231 and set by `-m...' switches. Must be defined in rtlanal.c. */
233 extern int target_flags;
235 /* Flags saying which kinds of debugging dump have been requested. */
238 int rtl_dump_and_exit = 0;
239 int jump_opt_dump = 0;
243 int branch_prob_dump = 0;
245 int combine_dump = 0;
247 int local_reg_dump = 0;
248 int global_reg_dump = 0;
250 int jump2_opt_dump = 0;
251 int dbr_sched_dump = 0;
252 int flag_print_asm_name = 0;
253 int stack_reg_dump = 0;
255 /* Name for output file of assembly code, specified with -o. */
259 /* Value of the -G xx switch, and whether it was passed or not. */
263 /* Type(s) of debugging information we are producing (if any).
264 See flags.h for the definitions of the different possible
265 types of debugging information. */
266 enum debug_info_type write_symbols = NO_DEBUG;
268 /* Level of debugging information we are producing. See flags.h
269 for the definitions of the different possible levels. */
270 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
272 /* Nonzero means use GNU-only extensions in the generated symbolic
273 debugging information. */
274 /* Currently, this only has an effect when write_symbols is set to
275 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
276 int use_gnu_debug_info_extensions = 0;
278 /* Nonzero means do optimizations. -O.
279 Particular numeric values stand for particular amounts of optimization;
280 thus, -O2 stores 2 here. However, the optimizations beyond the basic
281 ones are not controlled directly by this variable. Instead, they are
282 controlled by individual `flag_...' variables that are defaulted
283 based on this variable. */
287 /* Number of error messages and warning messages so far. */
290 int warningcount = 0;
293 /* Flag to output bytecode instead of native assembler */
294 int output_bytecode = 0;
296 /* Pointer to function to compute the name to use to print a declaration.
297 DECL is the declaration in question.
298 VERBOSITY determines what information will be printed:
299 0: DECL_NAME, demangled as necessary.
300 1: and scope information.
301 2: and any other information that might be interesting, such as function
302 parameter types in C++. */
304 char *(*decl_printable_name) (/* tree decl, int verbosity */);
306 /* Pointer to function to compute rtl for a language-specific tree code. */
308 struct rtx_def *(*lang_expand_expr) ();
310 /* Pointer to function to finish handling an incomplete decl at the
311 end of compilation. */
313 void (*incomplete_decl_finalize_hook) () = 0;
315 /* Highest label number used at the end of reload. */
317 int max_label_num_after_reload;
319 /* Nonzero if generating code to do profiling. */
321 int profile_flag = 0;
323 /* Nonzero if generating code to do profiling on a line-by-line basis. */
325 int profile_block_flag;
327 /* Nonzero if generating code to profile program flow graph arcs. */
329 int profile_arc_flag = 0;
331 /* Nonzero if generating info for gcov to calculate line test coverage. */
333 int flag_test_coverage = 0;
335 /* Nonzero indicates that branch taken probabilities should be calculated. */
337 int flag_branch_probabilities = 0;
339 /* Nonzero for -pedantic switch: warn about anything
340 that standard spec forbids. */
344 /* Temporarily suppress certain warnings.
345 This is set while reading code from a system header file. */
347 int in_system_header = 0;
349 /* Nonzero means do stupid register allocation.
350 Currently, this is 1 if `optimize' is 0. */
352 int obey_regdecls = 0;
354 /* Don't print functions as they are compiled and don't print
355 times taken by the various passes. -quiet. */
361 /* Nonzero means `char' should be signed. */
363 int flag_signed_char;
365 /* Nonzero means give an enum type only as many bytes as it needs. */
367 int flag_short_enums;
369 /* Nonzero for -fcaller-saves: allocate values in regs that need to
370 be saved across function calls, if that produces overall better code.
371 Optional now, so people can test it. */
373 #ifdef DEFAULT_CALLER_SAVES
374 int flag_caller_saves = 1;
376 int flag_caller_saves = 0;
379 /* Nonzero if structures and unions should be returned in memory.
381 This should only be defined if compatibility with another compiler or
382 with an ABI is needed, because it results in slower code. */
384 #ifndef DEFAULT_PCC_STRUCT_RETURN
385 #define DEFAULT_PCC_STRUCT_RETURN 1
388 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
390 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
392 /* Nonzero for -fforce-mem: load memory value into a register
393 before arithmetic on it. This makes better cse but slower compilation. */
395 int flag_force_mem = 0;
397 /* Nonzero for -fforce-addr: load memory address into a register before
398 reference to memory. This makes better cse but slower compilation. */
400 int flag_force_addr = 0;
402 /* Nonzero for -fdefer-pop: don't pop args after each function call;
403 instead save them up to pop many calls' args with one insns. */
405 int flag_defer_pop = 0;
407 /* Nonzero for -ffloat-store: don't allocate floats and doubles
408 in extended-precision registers. */
410 int flag_float_store = 0;
412 /* Nonzero for -fcse-follow-jumps:
413 have cse follow jumps to do a more extensive job. */
415 int flag_cse_follow_jumps;
417 /* Nonzero for -fcse-skip-blocks:
418 have cse follow a branch around a block. */
419 int flag_cse_skip_blocks;
421 /* Nonzero for -fexpensive-optimizations:
422 perform miscellaneous relatively-expensive optimizations. */
423 int flag_expensive_optimizations;
425 /* Nonzero for -fthread-jumps:
426 have jump optimize output of loop. */
428 int flag_thread_jumps;
430 /* Nonzero enables strength-reduction in loop.c. */
432 int flag_strength_reduce = 0;
434 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
435 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
436 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
439 int flag_unroll_loops;
441 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
442 This is generally not a win. */
444 int flag_unroll_all_loops;
446 /* Nonzero for -fwritable-strings:
447 store string constants in data segment and don't uniquize them. */
449 int flag_writable_strings = 0;
451 /* Nonzero means don't put addresses of constant functions in registers.
452 Used for compiling the Unix kernel, where strange substitutions are
453 done on the assembly output. */
455 int flag_no_function_cse = 0;
457 /* Nonzero for -fomit-frame-pointer:
458 don't make a frame pointer in simple functions that don't require one. */
460 int flag_omit_frame_pointer = 0;
462 /* Nonzero means place each function into its own section on those platforms
463 which support arbitrary section names and unlimited numbers of sections. */
465 int flag_function_sections = 0;
467 /* Nonzero to inhibit use of define_optimization peephole opts. */
469 int flag_no_peephole = 0;
471 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
472 operations in the interest of optimization. For example it allows
473 GCC to assume arguments to sqrt are nonnegative numbers, allowing
474 faster code for sqrt to be generated. */
476 int flag_fast_math = 0;
478 /* Nonzero means all references through pointers are volatile. */
482 /* Nonzero means treat all global and extern variables as global. */
484 int flag_volatile_global;
486 /* Nonzero means just do syntax checking; don't output anything. */
488 int flag_syntax_only = 0;
490 /* Nonzero means to rerun cse after loop optimization. This increases
491 compilation time about 20% and picks up a few more common expressions. */
493 static int flag_rerun_cse_after_loop;
495 /* Nonzero for -finline-functions: ok to inline functions that look like
496 good inline candidates. */
498 int flag_inline_functions;
500 /* Nonzero for -fkeep-inline-functions: even if we make a function
501 go inline everywhere, keep its definition around for debugging
504 int flag_keep_inline_functions;
506 /* Nonzero means that functions will not be inlined. */
510 /* Nonzero means that we should emit static const variables
511 regardless of whether or not optimization is turned on. */
513 int flag_keep_static_consts = 1;
515 /* Nonzero means we should be saving declaration info into a .X file. */
517 int flag_gen_aux_info = 0;
519 /* Specified name of aux-info file. */
521 static char *aux_info_file_name;
523 /* Nonzero means make the text shared if supported. */
525 int flag_shared_data;
527 /* Nonzero means schedule into delayed branch slots if supported. */
529 int flag_delayed_branch;
531 /* Nonzero means to run cleanups after CALL_EXPRs. */
533 int flag_short_temps;
535 /* Nonzero if we are compiling pure (sharable) code.
536 Value is 1 if we are doing reasonable (i.e. simple
537 offset into offset table) pic. Value is 2 if we can
538 only perform register offsets. */
542 /* Nonzero means generate extra code for exception handling and enable
543 exception handling. */
545 int flag_exceptions = 1;
547 /* Nonzero means don't place uninitialized global data in common storage
552 /* Nonzero means pretend it is OK to examine bits of target floats,
553 even if that isn't true. The resulting code will have incorrect constants,
554 but the same series of instructions that the native compiler would make. */
556 int flag_pretend_float;
558 /* Nonzero means change certain warnings into errors.
559 Usually these are warnings about failure to conform to some standard. */
561 int flag_pedantic_errors = 0;
563 /* flag_schedule_insns means schedule insns within basic blocks (before
565 flag_schedule_insns_after_reload means schedule insns after
568 int flag_schedule_insns = 0;
569 int flag_schedule_insns_after_reload = 0;
571 /* -finhibit-size-directive inhibits output of .size for ELF.
572 This is used only for compiling crtstuff.c,
573 and it may be extended to other effects
574 needed for crtstuff.c on other systems. */
575 int flag_inhibit_size_directive = 0;
577 /* -fverbose-asm causes extra commentary information to be produced in
578 the generated assembly code (to make it more readable). This option
579 is generally only of use to those who actually need to read the
580 generated assembly code (perhaps while debugging the compiler itself).
581 -fverbose-asm is the default. -fno-verbose-asm causes the extra information
582 to be omitted and is useful when comparing two assembler files. */
584 int flag_verbose_asm = 1;
586 /* -dA causes debug commentary information to be produced in
587 the generated assembly code (to make it more readable). This option
588 is generally only of use to those who actually need to read the
589 generated assembly code (perhaps while debugging the compiler itself).
590 Currently, this switch is only used by dwarfout.c; however, it is intended
591 to be a catchall for printing debug information in the assembler file. */
593 int flag_debug_asm = 0;
595 /* -fgnu-linker specifies use of the GNU linker for initializations.
596 (Or, more generally, a linker that handles initializations.)
597 -fno-gnu-linker says that collect2 will be used. */
599 int flag_gnu_linker = 0;
601 int flag_gnu_linker = 1;
604 /* Tag all structures with __attribute__(packed) */
605 int flag_pack_struct = 0;
607 /* Table of language-independent -f options.
608 STRING is the option name. VARIABLE is the address of the variable.
609 ON_VALUE is the value to store in VARIABLE
610 if `-fSTRING' is seen as an option.
611 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
613 struct { char *string; int *variable; int on_value;} f_options[] =
615 {"float-store", &flag_float_store, 1},
616 {"volatile", &flag_volatile, 1},
617 {"volatile-global", &flag_volatile_global, 1},
618 {"defer-pop", &flag_defer_pop, 1},
619 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
620 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
621 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
622 {"expensive-optimizations", &flag_expensive_optimizations, 1},
623 {"thread-jumps", &flag_thread_jumps, 1},
624 {"strength-reduce", &flag_strength_reduce, 1},
625 {"unroll-loops", &flag_unroll_loops, 1},
626 {"unroll-all-loops", &flag_unroll_all_loops, 1},
627 {"writable-strings", &flag_writable_strings, 1},
628 {"peephole", &flag_no_peephole, 0},
629 {"force-mem", &flag_force_mem, 1},
630 {"force-addr", &flag_force_addr, 1},
631 {"function-cse", &flag_no_function_cse, 0},
632 {"inline-functions", &flag_inline_functions, 1},
633 {"keep-inline-functions", &flag_keep_inline_functions, 1},
634 {"inline", &flag_no_inline, 0},
635 {"keep-static-consts", &flag_keep_static_consts, 1},
636 {"syntax-only", &flag_syntax_only, 1},
637 {"shared-data", &flag_shared_data, 1},
638 {"caller-saves", &flag_caller_saves, 1},
639 {"pcc-struct-return", &flag_pcc_struct_return, 1},
640 {"reg-struct-return", &flag_pcc_struct_return, 0},
641 {"delayed-branch", &flag_delayed_branch, 1},
642 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
643 {"pretend-float", &flag_pretend_float, 1},
644 {"schedule-insns", &flag_schedule_insns, 1},
645 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
646 {"pic", &flag_pic, 1},
647 {"PIC", &flag_pic, 2},
648 {"exceptions", &flag_exceptions, 1},
649 {"profile-arcs", &profile_arc_flag, 1},
650 {"test-coverage", &flag_test_coverage, 1},
651 {"branch-probabilities", &flag_branch_probabilities, 1},
652 {"fast-math", &flag_fast_math, 1},
653 {"common", &flag_no_common, 0},
654 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
655 {"function-sections", &flag_function_sections, 1},
656 {"verbose-asm", &flag_verbose_asm, 1},
657 {"gnu-linker", &flag_gnu_linker, 1},
658 {"pack-struct", &flag_pack_struct, 1},
659 {"bytecode", &output_bytecode, 1}
662 /* Table of language-specific options. */
664 char *lang_options[] =
667 "-fallow-single-precision",
669 "-fsigned-bitfields",
670 "-funsigned-bitfields",
671 "-fno-signed-bitfields",
672 "-fno-unsigned-bitfields",
676 "-fno-unsigned-char",
692 "-fno-cond-mismatch",
693 "-fdollars-in-identifiers",
694 "-fno-dollars-in-identifiers",
703 "-Wbad-function-cast",
704 "-Wno-bad-function-cast",
708 "-Wno-char-subscripts",
724 "-Wno-missing-braces",
725 "-Wmissing-declarations",
726 "-Wno-missing-declarations",
727 "-Wmissing-prototypes",
728 "-Wno-missing-prototypes",
730 "-Wno-nested-externs",
734 "-Wno-pointer-arith",
736 "-Wno-redundant-decls",
739 "-Wstrict-prototypes",
740 "-Wno-strict-prototypes",
748 "-Wno-write-strings",
750 /* these are for obj c */
766 /* Options controlling warnings */
768 /* Don't print warning messages. -w. */
770 int inhibit_warnings = 0;
772 /* Print various extra warnings. -W. */
774 int extra_warnings = 0;
776 /* Treat warnings as errors. -Werror. */
778 int warnings_are_errors = 0;
780 /* Nonzero to warn about unused local variables. */
784 /* Nonzero to warn about variables used before they are initialized. */
786 int warn_uninitialized;
788 /* Nonzero means warn about all declarations which shadow others. */
792 /* Warn if a switch on an enum fails to have a case for every enum value. */
796 /* Nonzero means warn about function definitions that default the return type
797 or that use a null return and have a return-type other than void. */
799 int warn_return_type;
801 /* Nonzero means warn about pointer casts that increase the required
802 alignment of the target type (and might therefore lead to a crash
803 due to a misaligned access). */
807 /* Nonzero means warn about any identifiers that match in the first N
808 characters. The value N is in `id_clash_len'. */
811 unsigned id_clash_len;
813 /* Nonzero means warn about any objects definitions whose size is larger
814 than N bytes. Also want about function definitions whose returned
815 values are larger than N bytes. The value N is in `larger_than_size'. */
817 int warn_larger_than;
818 unsigned larger_than_size;
820 /* Nonzero means warn if inline function is too large. */
824 /* Warn if a function returns an aggregate,
825 since there are often incompatible calling conventions for doing this. */
827 int warn_aggregate_return;
829 /* Likewise for -W. */
831 struct { char *string; int *variable; int on_value;} W_options[] =
833 {"unused", &warn_unused, 1},
834 {"error", &warnings_are_errors, 1},
835 {"shadow", &warn_shadow, 1},
836 {"switch", &warn_switch, 1},
837 {"aggregate-return", &warn_aggregate_return, 1},
838 {"cast-align", &warn_cast_align, 1},
839 {"uninitialized", &warn_uninitialized, 1},
840 {"inline", &warn_inline, 1}
843 /* Output files for assembler code (real compiler output)
844 and debugging dumps. */
849 FILE *jump_opt_dump_file;
851 FILE *loop_dump_file;
852 FILE *cse2_dump_file;
853 FILE *branch_prob_dump_file;
854 FILE *flow_dump_file;
855 FILE *combine_dump_file;
856 FILE *sched_dump_file;
857 FILE *local_reg_dump_file;
858 FILE *global_reg_dump_file;
859 FILE *sched2_dump_file;
860 FILE *jump2_opt_dump_file;
861 FILE *dbr_sched_dump_file;
862 FILE *stack_reg_dump_file;
864 /* Time accumulators, to count the total time spent in various passes. */
868 int integration_time;
873 int branch_prob_time;
877 int local_alloc_time;
878 int global_alloc_time;
881 int shorten_branch_time;
887 /* Return time used so far, in microseconds. */
897 struct rusage rusage;
902 int proc_system_time;
904 int child_system_time;
916 return (clock() * 1000);
917 #else /* not _WIN32 */
920 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
923 getrusage (0, &rusage);
924 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
925 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
928 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
934 #define TIMEVAR(VAR, BODY) \
935 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
938 print_time (str, total)
943 "time in %s: %d.%06d\n",
944 str, total / 1000000, total % 1000000);
947 /* Count an error or warning. Return 1 if the message should be printed. */
950 count_error (warningp)
953 if (warningp && inhibit_warnings)
956 if (warningp && !warnings_are_errors)
960 static int warning_message = 0;
962 if (warningp && !warning_message)
964 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
973 /* Print a fatal error message. NAME is the text.
974 Also include a system error message based on `errno'. */
977 pfatal_with_name (name)
980 fprintf (stderr, "%s: ", progname);
982 exit (FATAL_EXIT_CODE);
986 fatal_io_error (name)
989 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
990 exit (FATAL_EXIT_CODE);
993 /* Called to give a better error message for a bad insn rather than
994 just calling abort(). */
997 fatal_insn (message, insn)
1001 if (!output_bytecode)
1007 fflush (asm_out_file);
1009 fflush (aux_info_file);
1011 fflush (rtl_dump_file);
1012 if (jump_opt_dump_file)
1013 fflush (jump_opt_dump_file);
1015 fflush (cse_dump_file);
1017 fflush (loop_dump_file);
1019 fflush (cse2_dump_file);
1021 fflush (flow_dump_file);
1022 if (combine_dump_file)
1023 fflush (combine_dump_file);
1024 if (sched_dump_file)
1025 fflush (sched_dump_file);
1026 if (local_reg_dump_file)
1027 fflush (local_reg_dump_file);
1028 if (global_reg_dump_file)
1029 fflush (global_reg_dump_file);
1030 if (sched2_dump_file)
1031 fflush (sched2_dump_file);
1032 if (jump2_opt_dump_file)
1033 fflush (jump2_opt_dump_file);
1034 if (dbr_sched_dump_file)
1035 fflush (dbr_sched_dump_file);
1036 if (stack_reg_dump_file)
1037 fflush (stack_reg_dump_file);
1043 /* Called to give a better error message when we don't have an insn to match
1044 what we are looking for or if the insn's constraints aren't satisfied,
1045 rather than just calling abort(). */
1048 fatal_insn_not_found (insn)
1051 if (INSN_CODE (insn) < 0)
1052 fatal_insn ("internal error--unrecognizable insn:", insn);
1054 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1057 /* This is the default decl_printable_name function. */
1060 decl_name (decl, verbosity)
1064 return IDENTIFIER_POINTER (DECL_NAME (decl));
1067 static int need_error_newline;
1069 /* Function of last error message;
1070 more generally, function such that if next error message is in it
1071 then we don't have to mention the function name. */
1072 static tree last_error_function = NULL;
1074 /* Used to detect when input_file_stack has changed since last described. */
1075 static int last_error_tick;
1077 /* Called when the start of a function definition is parsed,
1078 this function prints on stderr the name of the function. */
1081 announce_function (decl)
1086 if (rtl_dump_and_exit)
1087 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1089 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1091 need_error_newline = 1;
1092 last_error_function = current_function_decl;
1096 /* The default function to print out name of current function that caused
1100 default_print_error_function (file)
1103 if (last_error_function != current_function_decl)
1105 char *kind = "function";
1106 if (current_function_decl != 0
1107 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1111 fprintf (stderr, "%s: ", file);
1113 if (current_function_decl == NULL)
1114 fprintf (stderr, "At top level:\n");
1117 char *name = (*decl_printable_name) (current_function_decl, 2);
1118 fprintf (stderr, "In %s `%s':\n", kind, name);
1121 last_error_function = current_function_decl;
1125 /* Called by report_error_function to print out function name.
1126 * Default may be overridden by language front-ends. */
1128 void (*print_error_function) PROTO((char *)) = default_print_error_function;
1130 /* Prints out, if necessary, the name of the current function
1131 that caused an error. Called from all error and warning functions. */
1134 report_error_function (file)
1137 struct file_stack *p;
1139 if (need_error_newline)
1141 fprintf (stderr, "\n");
1142 need_error_newline = 0;
1145 (*print_error_function) (file);
1147 if (input_file_stack && input_file_stack->next != 0
1148 && input_file_stack_tick != last_error_tick
1149 && file == input_filename)
1151 fprintf (stderr, "In file included");
1152 for (p = input_file_stack->next; p; p = p->next)
1154 fprintf (stderr, " from %s:%d", p->name, p->line);
1156 fprintf (stderr, ",\n ");
1158 fprintf (stderr, ":\n");
1159 last_error_tick = input_file_stack_tick;
1163 /* Print a message. */
1166 vmessage (prefix, s, ap)
1172 fprintf (stderr, "%s: ", prefix);
1175 vfprintf (stderr, s, ap);
1178 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1179 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1180 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1181 HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT);
1182 fprintf (stderr, s, v1, v2, v3, v4);
1187 /* Print a message relevant to line LINE of file FILE. */
1190 v_message_with_file_and_line (file, line, prefix, s, ap)
1198 fprintf (stderr, "%s:%d: ", file, line);
1200 fprintf (stderr, "%s: ", progname);
1202 vmessage (prefix, s, ap);
1203 fputc ('\n', stderr);
1206 /* Print a message relevant to the given DECL. */
1209 v_message_with_decl (decl, prefix, s, ap)
1217 fprintf (stderr, "%s:%d: ",
1218 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1221 fprintf (stderr, "%s: ", prefix);
1223 /* Do magic to get around lack of varargs support for insertion
1224 of arguments into existing list. We know that the decl is first;
1225 we ass_u_me that it will be printed with "%s". */
1227 for (p = s; *p; ++p)
1231 if (*(p + 1) == '%')
1238 if (p > s) /* Print the left-hand substring. */
1240 char fmt[sizeof "%.255s"];
1243 if (width > 255L) width = 255L; /* arbitrary */
1244 sprintf (fmt, "%%.%lds", width);
1245 fprintf (stderr, fmt, s);
1248 if (*p == '%') /* Print the name. */
1250 char *n = (DECL_NAME (decl)
1251 ? (*decl_printable_name) (decl, 2)
1257 if (isalpha (*(p - 1) & 0xFF))
1262 if (*p) /* Print the rest of the message. */
1263 vmessage ((char *)NULL, p, ap);
1265 fputc ('\n', stderr);
1268 /* Figure file and line of the given INSN. */
1271 file_and_line_for_asm (insn, pfile, pline)
1276 rtx body = PATTERN (insn);
1279 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1280 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1281 asmop = SET_SRC (body);
1282 else if (GET_CODE (body) == ASM_OPERANDS)
1284 else if (GET_CODE (body) == PARALLEL
1285 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1286 asmop = SET_SRC (XVECEXP (body, 0, 0));
1287 else if (GET_CODE (body) == PARALLEL
1288 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1289 asmop = XVECEXP (body, 0, 0);
1295 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1296 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1300 *pfile = input_filename;
1305 /* Report an error at line LINE of file FILE. */
1308 v_error_with_file_and_line (file, line, s, ap)
1315 report_error_function (file);
1316 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1320 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1332 file = va_arg (ap, char *);
1333 line = va_arg (ap, int);
1334 s = va_arg (ap, char *);
1337 v_error_with_file_and_line (file, line, s, ap);
1341 /* Report an error at the declaration DECL.
1342 S is a format string which uses %s to substitute the declaration
1343 name; subsequent substitutions are a la printf. */
1346 v_error_with_decl (decl, s, ap)
1352 report_error_function (DECL_SOURCE_FILE (decl));
1353 v_message_with_decl (decl, (char *)NULL, s, ap);
1357 error_with_decl VPROTO((tree decl, char *s, ...))
1368 decl = va_arg (ap, tree);
1369 s = va_arg (ap, char *);
1372 v_error_with_decl (decl, s, ap);
1376 /* Report an error at the line number of the insn INSN.
1377 This is used only when INSN is an `asm' with operands,
1378 and each ASM_OPERANDS records its own source file and line. */
1381 v_error_for_asm (insn, s, ap)
1390 file_and_line_for_asm (insn, &file, &line);
1391 report_error_function (file);
1392 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1396 error_for_asm VPROTO((rtx insn, char *s, ...))
1407 insn = va_arg (ap, rtx);
1408 s = va_arg (ap, char *);
1411 v_error_for_asm (insn, s, ap);
1415 /* Report an error at the current line number. */
1422 v_error_with_file_and_line (input_filename, lineno, s, ap);
1426 error VPROTO((char *s, ...))
1436 s = va_arg (ap, char *);
1443 /* Report a fatal error at the current line number. */
1451 exit (FATAL_EXIT_CODE);
1455 fatal VPROTO((char *s, ...))
1465 s = va_arg (ap, char *);
1472 /* Report a warning at line LINE of file FILE. */
1475 v_warning_with_file_and_line (file, line, s, ap)
1481 if (count_error (1))
1483 report_error_function (file);
1484 v_message_with_file_and_line (file, line, "warning", s, ap);
1489 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1501 file = va_arg (ap, char *);
1502 line = va_arg (ap, int);
1503 s = va_arg (ap, char *);
1506 v_warning_with_file_and_line (file, line, s, ap);
1510 /* Report a warning at the declaration DECL.
1511 S is a format string which uses %s to substitute the declaration
1512 name; subsequent substitutions are a la printf. */
1515 v_warning_with_decl (decl, s, ap)
1520 if (count_error (1))
1522 report_error_function (DECL_SOURCE_FILE (decl));
1523 v_message_with_decl (decl, "warning", s, ap);
1528 warning_with_decl VPROTO((tree decl, char *s, ...))
1539 decl = va_arg (ap, tree);
1540 s = va_arg (ap, char *);
1543 v_warning_with_decl (decl, s, ap);
1547 /* Report a warning at the line number of the insn INSN.
1548 This is used only when INSN is an `asm' with operands,
1549 and each ASM_OPERANDS records its own source file and line. */
1552 v_warning_for_asm (insn, s, ap)
1557 if (count_error (1))
1562 file_and_line_for_asm (insn, &file, &line);
1563 report_error_function (file);
1564 v_message_with_file_and_line (file, line, "warning", s, ap);
1569 warning_for_asm VPROTO((rtx insn, char *s, ...))
1580 insn = va_arg (ap, rtx);
1581 s = va_arg (ap, char *);
1584 v_warning_for_asm (insn, s, ap);
1588 /* Report a warning at the current line number. */
1595 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1599 warning VPROTO((char *s, ...))
1609 s = va_arg (ap, char *);
1616 /* These functions issue either warnings or errors depending on
1617 -pedantic-errors. */
1624 if (flag_pedantic_errors)
1631 pedwarn VPROTO((char *s, ...))
1641 s = va_arg (ap, char *);
1649 v_pedwarn_with_decl (decl, s, ap)
1654 /* We don't want -pedantic-errors to cause the compilation to fail from
1655 "errors" in system header files. Sometimes fixincludes can't fix what's
1656 broken (eg: unsigned char bitfields - fixing it may change the alignment
1657 which will cause programs to mysteriously fail because the C library
1658 or kernel uses the original layout). There's no point in issuing a
1659 warning either, it's just unnecessary noise. */
1661 if (! DECL_IN_SYSTEM_HEADER (decl))
1663 if (flag_pedantic_errors)
1664 v_error_with_decl (decl, s, ap);
1666 v_warning_with_decl (decl, s, ap);
1671 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1682 decl = va_arg (ap, tree);
1683 s = va_arg (ap, char *);
1686 v_pedwarn_with_decl (decl, s, ap);
1691 v_pedwarn_with_file_and_line (file, line, s, ap)
1697 if (flag_pedantic_errors)
1698 v_error_with_file_and_line (file, line, s, ap);
1700 v_warning_with_file_and_line (file, line, s, ap);
1704 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1716 file = va_arg (ap, char *);
1717 line = va_arg (ap, int);
1718 s = va_arg (ap, char *);
1721 v_pedwarn_with_file_and_line (file, line, s, ap);
1725 /* Apologize for not implementing some feature. */
1734 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1736 fprintf (stderr, "%s: ", progname);
1737 vmessage ("sorry, not implemented", s, ap);
1738 fputc ('\n', stderr);
1742 sorry VPROTO((char *s, ...))
1752 s = va_arg (ap, char *);
1759 /* Apologize for not implementing some feature, then quit. */
1762 v_really_sorry (s, ap)
1768 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1770 fprintf (stderr, "%s: ", progname);
1771 vmessage ("sorry, not implemented", s, ap);
1772 fatal (" (fatal)\n");
1776 really_sorry VPROTO((char *s, ...))
1786 s = va_arg (ap, char *);
1789 v_really_sorry (s, ap);
1793 /* More 'friendly' abort that prints the line and file.
1794 config.h can #define abort fancy_abort if you like that sort of thing.
1796 I don't think this is actually a good idea.
1797 Other sorts of crashes will look a certain way.
1798 It is a good thing if crashes from calling abort look the same way.
1804 fatal ("internal gcc abort");
1807 /* This calls abort and is used to avoid problems when abort if a macro.
1808 It is used when we need to pass the address of abort. */
1816 /* When `malloc.c' is compiled with `rcheck' defined,
1817 it calls this function to report clobberage. */
1825 /* Same as `malloc' but report error if no memory available. */
1831 register char *value = (char *) malloc (size);
1833 fatal ("virtual memory exhausted");
1837 /* Same as `realloc' but report error if no memory available. */
1840 xrealloc (ptr, size)
1844 char *result = (char *) realloc (ptr, size);
1846 fatal ("virtual memory exhausted");
1850 /* Same as `strdup' but report error if no memory available. */
1856 register char *result = (char *) malloc (strlen (s) + 1);
1859 fatal ("virtual memory exhausted");
1864 /* Return the logarithm of X, base 2, considering X unsigned,
1865 if X is a power of 2. Otherwise, returns -1.
1867 This should be used via the `exact_log2' macro. */
1871 register unsigned HOST_WIDE_INT x;
1873 register int log = 0;
1874 /* Test for 0 or a power of 2. */
1875 if (x == 0 || x != (x & -x))
1877 while ((x >>= 1) != 0)
1882 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1883 If X is 0, return -1.
1885 This should be used via the floor_log2 macro. */
1889 register unsigned HOST_WIDE_INT x;
1891 register int log = -1;
1898 static int float_handler_set;
1900 jmp_buf float_handler;
1902 /* Signals actually come here. */
1905 float_signal (signo)
1906 /* If this is missing, some compilers complain. */
1909 if (float_handled == 0)
1911 #if defined (USG) || defined (hpux)
1912 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1915 signal (SIGFPE, float_signal);
1916 longjmp (float_handler, 1);
1919 /* Specify where to longjmp to when a floating arithmetic error happens.
1920 If HANDLER is 0, it means don't handle the errors any more. */
1923 set_float_handler (handler)
1926 float_handled = (handler != 0);
1928 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1930 if (float_handled && ! float_handler_set)
1932 signal (SIGFPE, float_signal);
1933 float_handler_set = 1;
1937 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1938 error happens, pushing the previous specification into OLD_HANDLER.
1939 Return an indication of whether there was a previous handler in effect. */
1942 push_float_handler (handler, old_handler)
1943 jmp_buf handler, old_handler;
1945 int was_handled = float_handled;
1949 bcopy ((char *) float_handler, (char *) old_handler,
1950 sizeof (float_handler));
1952 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1956 /* Restore the previous specification of whether and where to longjmp to
1957 when a floating arithmetic error happens. */
1960 pop_float_handler (handled, handler)
1964 float_handled = handled;
1966 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1969 /* Handler for SIGPIPE. */
1973 /* If this is missing, some compilers complain. */
1976 fatal ("output pipe has been closed");
1979 /* Strip off a legitimate source ending from the input string NAME of
1980 length LEN. Rather than having to know the names used by all of
1981 our front ends, we strip off an ending of a period followed by one,
1982 two, or three characters. */
1985 strip_off_ending (name, len)
1989 if (len > 2 && name[len - 2] == '.')
1990 name[len - 2] = '\0';
1991 else if (len > 3 && name[len - 3] == '.')
1992 name[len - 3] = '\0';
1993 else if (len > 4 && name[len - 4] == '.')
1994 name[len - 4] = '\0';
1997 /* Output a quoted string. */
2000 output_quoted_string (asm_file, string)
2006 putc ('\"', asm_file);
2007 while ((c = *string++) != 0)
2009 if (c == '\"' || c == '\\')
2010 putc ('\\', asm_file);
2013 putc ('\"', asm_file);
2016 /* Output a file name in the form wanted by System V. */
2019 output_file_directive (asm_file, input_name)
2023 int len = strlen (input_name);
2024 char *na = input_name + len;
2026 /* NA gets INPUT_NAME sans directory names. */
2027 while (na > input_name)
2034 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2035 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2037 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2038 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2040 fprintf (asm_file, "\t.file\t");
2041 output_quoted_string (asm_file, na);
2042 fputc ('\n', asm_file);
2047 /* Routine to build language identifier for object file. */
2050 output_lang_identify (asm_out_file)
2053 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2054 char *s = (char *) alloca (len);
2055 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2056 ASM_OUTPUT_LABEL (asm_out_file, s);
2059 /* Routine to open a dump file. */
2062 open_dump_file (base_name, suffix)
2067 char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1);
2069 strcpy (dumpname, base_name);
2070 strcat (dumpname, suffix);
2071 f = fopen (dumpname, "w");
2073 pfatal_with_name (dumpname);
2077 /* Compile an entire file of output from cpp, named NAME.
2078 Write a file of assembly output and various debugging dumps. */
2087 int name_specified = name != 0;
2089 if (dump_base_name == 0)
2090 dump_base_name = name ? name : "gccdump";
2094 integration_time = 0;
2099 branch_prob_time = 0;
2103 local_alloc_time = 0;
2104 global_alloc_time = 0;
2107 shorten_branch_time = 0;
2113 /* Open input file. */
2115 if (name == 0 || !strcmp (name, "-"))
2121 finput = fopen (name, "r");
2123 pfatal_with_name (name);
2125 #ifdef IO_BUFFER_SIZE
2126 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2129 /* Initialize data in various passes. */
2134 /* Some of these really don't need to be called when generating bytecode,
2135 but the options would have to be parsed first to know that. -bson */
2137 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2138 || debug_info_level == DINFO_LEVEL_VERBOSE
2139 || flag_test_coverage);
2141 init_decl_processing ();
2149 if (flag_caller_saves)
2150 init_caller_save ();
2152 /* If auxiliary info generation is desired, open the output file.
2153 This goes in the same directory as the source file--unlike
2154 all the other output files. */
2155 if (flag_gen_aux_info)
2157 aux_info_file = fopen (aux_info_file_name, "w");
2158 if (aux_info_file == 0)
2159 pfatal_with_name (aux_info_file_name);
2162 /* If rtl dump desired, open the output file. */
2164 rtl_dump_file = open_dump_file (dump_base_name, ".rtl");
2166 /* If jump_opt dump desired, open the output file. */
2168 jump_opt_dump_file = open_dump_file (dump_base_name, ".jump");
2170 /* If cse dump desired, open the output file. */
2172 cse_dump_file = open_dump_file (dump_base_name, ".cse");
2174 /* If loop dump desired, open the output file. */
2176 loop_dump_file = open_dump_file (dump_base_name, ".loop");
2178 /* If cse2 dump desired, open the output file. */
2180 cse2_dump_file = open_dump_file (dump_base_name, ".cse2");
2182 /* If branch_prob dump desired, open the output file. */
2183 if (branch_prob_dump)
2184 branch_prob_dump_file = open_dump_file (dump_base_name, ".bp");
2186 /* If flow dump desired, open the output file. */
2188 flow_dump_file = open_dump_file (dump_base_name, ".flow");
2190 /* If combine dump desired, open the output file. */
2192 combine_dump_file = open_dump_file (dump_base_name, ".combine");
2194 /* If scheduling dump desired, open the output file. */
2196 sched_dump_file = open_dump_file (dump_base_name, ".sched");
2198 /* If local_reg dump desired, open the output file. */
2200 local_reg_dump_file = open_dump_file (dump_base_name, ".lreg");
2202 /* If global_reg dump desired, open the output file. */
2203 if (global_reg_dump)
2204 global_reg_dump_file = open_dump_file (dump_base_name, ".greg");
2206 /* If 2nd scheduling dump desired, open the output file. */
2208 sched2_dump_file = open_dump_file (dump_base_name, ".sched2");
2210 /* If jump2_opt dump desired, open the output file. */
2212 jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2");
2214 /* If dbr_sched dump desired, open the output file. */
2216 dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr");
2220 /* If stack_reg dump desired, open the output file. */
2222 stack_reg_dump_file = open_dump_file (dump_base_name, ".stack");
2226 /* Open assembler code output file. */
2228 if (! name_specified && asm_file_name == 0)
2229 asm_out_file = stdout;
2232 int len = strlen (dump_base_name);
2233 register char *dumpname = (char *) xmalloc (len + 6);
2234 strcpy (dumpname, dump_base_name);
2235 strip_off_ending (dumpname, len);
2236 strcat (dumpname, ".s");
2237 if (asm_file_name == 0)
2239 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2240 strcpy (asm_file_name, dumpname);
2242 if (!strcmp (asm_file_name, "-"))
2243 asm_out_file = stdout;
2245 asm_out_file = fopen (asm_file_name, "w");
2246 if (asm_out_file == 0)
2247 pfatal_with_name (asm_file_name);
2250 #ifdef IO_BUFFER_SIZE
2251 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2252 _IOFBF, IO_BUFFER_SIZE);
2255 input_filename = name;
2257 /* Put an entry on the input file stack for the main input file. */
2259 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2260 input_file_stack->next = 0;
2261 input_file_stack->name = input_filename;
2263 /* Perform language-specific initialization.
2264 This may set main_input_filename. */
2267 /* If the input doesn't start with a #line, use the input name
2268 as the official input file name. */
2269 if (main_input_filename == 0)
2270 main_input_filename = name;
2272 if (!output_bytecode)
2274 ASM_FILE_START (asm_out_file);
2276 #ifdef ASM_COMMENT_START
2277 if (flag_verbose_asm)
2279 /* Print the list of options in effect. */
2280 print_version (asm_out_file, ASM_COMMENT_START);
2281 print_switch_values (asm_out_file, 0, MAX_LINE,
2282 ASM_COMMENT_START, " ", "\n");
2283 /* Add a blank line here so it appears in assembler output but not
2285 fprintf (asm_out_file, "\n");
2290 /* Output something to inform GDB that this compilation was by GCC. Also
2291 serves to tell GDB file consists of bytecodes. */
2292 if (output_bytecode)
2293 fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
2296 #ifndef ASM_IDENTIFY_GCC
2297 fprintf (asm_out_file, "gcc2_compiled.:\n");
2299 ASM_IDENTIFY_GCC (asm_out_file);
2303 /* Output something to identify which front-end produced this file. */
2304 #ifdef ASM_IDENTIFY_LANGUAGE
2305 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2308 #ifndef ASM_OUTPUT_SECTION_NAME
2309 if (flag_function_sections)
2311 warning ("-ffunction-sections not supported for this target.");
2312 flag_function_sections = 0;
2316 if (flag_function_sections
2317 && (profile_flag || profile_block_flag))
2319 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2320 flag_function_sections = 0;
2323 if (flag_function_sections && write_symbols != NO_DEBUG)
2324 warning ("-ffunction-sections may affect debugging on some targets.");
2326 if (output_bytecode)
2328 if (profile_flag || profile_block_flag)
2329 error ("profiling not supported in bytecode compilation");
2333 /* ??? Note: There used to be a conditional here
2334 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2335 This was to guarantee separation between gcc_compiled. and
2336 the first function, for the sake of dbx on Suns.
2337 However, having the extra zero here confused the Emacs
2338 code for unexec, and might confuse other programs too.
2339 Therefore, I took out that change.
2340 In future versions we should find another way to solve
2341 that dbx problem. -- rms, 23 May 93. */
2343 /* Don't let the first function fall at the same address
2344 as gcc_compiled., if profiling. */
2345 if (profile_flag || profile_block_flag)
2346 assemble_zeros (UNITS_PER_WORD);
2349 /* If dbx symbol table desired, initialize writing it
2350 and output the predefined types. */
2351 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2352 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2353 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2356 #ifdef SDB_DEBUGGING_INFO
2357 if (write_symbols == SDB_DEBUG)
2358 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2361 #ifdef DWARF_DEBUGGING_INFO
2362 if (write_symbols == DWARF_DEBUG)
2363 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2365 #ifdef DWARF2_DEBUGGING_INFO
2366 if (write_symbols == DWARF2_DEBUG)
2367 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2370 /* Initialize yet another pass. */
2372 if (!output_bytecode)
2373 init_final (main_input_filename);
2374 init_branch_prob (dump_base_name);
2376 start_time = get_run_time ();
2378 /* Call the parser, which parses the entire file
2379 (calling rest_of_compilation for each function). */
2381 if (yyparse () != 0)
2383 if (errorcount == 0)
2384 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2386 /* In case there were missing closebraces,
2387 get us back to the global binding level. */
2388 while (! global_bindings_p ())
2392 output_func_start_profiler ();
2394 /* Compilation is now finished except for writing
2395 what's left of the symbol table output. */
2397 parse_time += get_run_time () - start_time;
2399 parse_time -= integration_time;
2400 parse_time -= varconst_time;
2402 globals = getdecls ();
2404 /* Really define vars that have had only a tentative definition.
2405 Really output inline functions that must actually be callable
2406 and have not been output so far. */
2409 int len = list_length (globals);
2410 tree *vec = (tree *) alloca (sizeof (tree) * len);
2415 /* Process the decls in reverse order--earliest first.
2416 Put them into VEC from back to front, then take out from front. */
2418 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2419 vec[len - i - 1] = decl;
2421 for (i = 0; i < len; i++)
2425 /* We're not deferring this any longer. */
2426 DECL_DEFER_OUTPUT (decl) = 0;
2428 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2429 && incomplete_decl_finalize_hook != 0)
2430 (*incomplete_decl_finalize_hook) (decl);
2433 /* Now emit any global variables or functions that we have been putting
2434 off. We need to loop in case one of the things emitted here
2435 references another one which comes earlier in the list. */
2439 for (i = 0; i < len; i++)
2443 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2446 /* Don't write out static consts, unless we still need them.
2448 We also keep static consts if not optimizing (for debugging),
2449 unless the user specified -fno-keep-static-consts.
2450 ??? They might be better written into the debug information.
2451 This is possible when using DWARF.
2453 A language processor that wants static constants to be always
2454 written out (even if it is not used) is responsible for
2455 calling rest_of_decl_compilation itself. E.g. the C front-end
2456 calls rest_of_decl_compilation from finish_decl.
2457 One motivation for this is that is conventional in some
2458 environments to write things like:
2459 static const char rcsid[] = "... version string ...";
2460 intending to force the string to be in the executable.
2462 A language processor that would prefer to have unneeded
2463 static constants "optimized away" would just defer writing
2464 them out until here. E.g. C++ does this, because static
2465 constants are often defined in header files.
2467 ??? A tempting alternative (for both C and C++) would be
2468 to force a constant to be written if and only if it is
2469 defined in a main file, as opposed to an include file. */
2471 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2472 && (! TREE_READONLY (decl)
2473 || TREE_PUBLIC (decl)
2474 || (!optimize && flag_keep_static_consts)
2475 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2478 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2481 if (TREE_CODE (decl) == FUNCTION_DECL
2482 && DECL_INITIAL (decl) != 0
2483 && DECL_SAVED_INSNS (decl) != 0
2484 && (flag_keep_inline_functions
2485 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2488 temporary_allocation ();
2489 output_inline_function (decl);
2490 permanent_allocation (1);
2495 /* Now that all possible functions have been output, we can dump
2496 the exception table. */
2498 if (exception_table_p ())
2499 output_exception_table ();
2501 for (i = 0; i < len; i++)
2505 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2506 && ! TREE_ASM_WRITTEN (decl))
2507 /* Cancel the RTL for this decl so that, if debugging info
2508 output for global variables is still to come,
2509 this one will be omitted. */
2510 DECL_RTL (decl) = NULL;
2512 /* Warn about any function
2513 declared static but not defined.
2514 We don't warn about variables,
2515 because many programs have static variables
2516 that exist only to get some text into the object file. */
2517 if (TREE_CODE (decl) == FUNCTION_DECL
2519 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2520 && DECL_INITIAL (decl) == 0
2521 && DECL_EXTERNAL (decl)
2522 && ! DECL_ARTIFICIAL (decl)
2523 && ! TREE_PUBLIC (decl))
2525 pedwarn_with_decl (decl,
2526 "`%s' declared `static' but never defined");
2527 /* This symbol is effectively an "extern" declaration now. */
2528 TREE_PUBLIC (decl) = 1;
2529 assemble_external (decl);
2532 /* Warn about static fns or vars defined but not used,
2533 but not about inline functions or static consts
2534 since defining those in header files is normal practice. */
2536 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2537 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2538 && ! DECL_IN_SYSTEM_HEADER (decl)
2539 && ! DECL_EXTERNAL (decl)
2540 && ! TREE_PUBLIC (decl)
2541 && ! TREE_USED (decl)
2542 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2543 /* The TREE_USED bit for file-scope decls
2544 is kept in the identifier, to handle multiple
2545 external decls in different scopes. */
2546 && ! TREE_USED (DECL_NAME (decl)))
2547 warning_with_decl (decl, "`%s' defined but not used");
2549 #ifdef SDB_DEBUGGING_INFO
2550 /* The COFF linker can move initialized global vars to the end.
2551 And that can screw up the symbol ordering.
2552 By putting the symbols in that order to begin with,
2553 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2554 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2555 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2556 && ! DECL_EXTERNAL (decl)
2557 && DECL_RTL (decl) != 0)
2558 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2560 /* Output COFF information for non-global
2561 file-scope initialized variables. */
2562 if (write_symbols == SDB_DEBUG
2563 && TREE_CODE (decl) == VAR_DECL
2564 && DECL_INITIAL (decl)
2565 && ! DECL_EXTERNAL (decl)
2566 && DECL_RTL (decl) != 0
2567 && GET_CODE (DECL_RTL (decl)) == MEM)
2568 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2569 #endif /* SDB_DEBUGGING_INFO */
2570 #ifdef DWARF_DEBUGGING_INFO
2571 /* Output DWARF information for file-scope tentative data object
2572 declarations, file-scope (extern) function declarations (which
2573 had no corresponding body) and file-scope tagged type declarations
2574 and definitions which have not yet been forced out. */
2576 if (write_symbols == DWARF_DEBUG
2577 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2578 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2580 #ifdef DWARF2_DEBUGGING_INFO
2581 /* Output DWARF2 information for file-scope tentative data object
2582 declarations, file-scope (extern) function declarations (which
2583 had no corresponding body) and file-scope tagged type declarations
2584 and definitions which have not yet been forced out. */
2586 if (write_symbols == DWARF2_DEBUG
2587 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2588 TIMEVAR (symout_time, dwarf2out_decl (decl));
2593 /* Write out any pending weak symbol declarations. */
2597 /* Do dbx symbols */
2598 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2599 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2600 TIMEVAR (symout_time,
2602 dbxout_finish (asm_out_file, main_input_filename);
2606 #ifdef DWARF_DEBUGGING_INFO
2607 if (write_symbols == DWARF_DEBUG)
2608 TIMEVAR (symout_time,
2614 #ifdef DWARF2_DEBUGGING_INFO
2615 if (write_symbols == DWARF2_DEBUG)
2616 TIMEVAR (symout_time,
2618 dwarf2out_finish ();
2622 /* Output some stuff at end of file if nec. */
2624 if (!output_bytecode)
2626 end_final (dump_base_name);
2627 end_branch_prob (branch_prob_dump_file);
2630 ASM_FILE_END (asm_out_file);
2634 /* Language-specific end of compilation actions. */
2638 if (output_bytecode)
2639 bc_write_file (asm_out_file);
2641 /* Close the dump files. */
2643 if (flag_gen_aux_info)
2645 fclose (aux_info_file);
2647 unlink (aux_info_file_name);
2651 fclose (rtl_dump_file);
2654 fclose (jump_opt_dump_file);
2657 fclose (cse_dump_file);
2660 fclose (loop_dump_file);
2663 fclose (cse2_dump_file);
2665 if (branch_prob_dump)
2666 fclose (branch_prob_dump_file);
2669 fclose (flow_dump_file);
2673 dump_combine_total_stats (combine_dump_file);
2674 fclose (combine_dump_file);
2678 fclose (sched_dump_file);
2681 fclose (local_reg_dump_file);
2683 if (global_reg_dump)
2684 fclose (global_reg_dump_file);
2687 fclose (sched2_dump_file);
2690 fclose (jump2_opt_dump_file);
2693 fclose (dbr_sched_dump_file);
2697 fclose (stack_reg_dump_file);
2700 /* Close non-debugging input and output files. Take special care to note
2701 whether fclose returns an error, since the pages might still be on the
2702 buffer chain while the file is open. */
2705 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2706 fatal_io_error (asm_file_name);
2708 /* Print the times. */
2712 fprintf (stderr,"\n");
2713 print_time ("parse", parse_time);
2715 if (!output_bytecode)
2717 print_time ("integration", integration_time);
2718 print_time ("jump", jump_time);
2719 print_time ("cse", cse_time);
2720 print_time ("loop", loop_time);
2721 print_time ("cse2", cse2_time);
2722 print_time ("branch-probabilities", branch_prob_time);
2723 print_time ("flow", flow_time);
2724 print_time ("combine", combine_time);
2725 print_time ("sched", sched_time);
2726 print_time ("local-alloc", local_alloc_time);
2727 print_time ("global-alloc", global_alloc_time);
2728 print_time ("sched2", sched2_time);
2729 print_time ("dbranch", dbr_sched_time);
2730 print_time ("shorten-branch", shorten_branch_time);
2731 print_time ("stack-reg", stack_reg_time);
2732 print_time ("final", final_time);
2733 print_time ("varconst", varconst_time);
2734 print_time ("symout", symout_time);
2735 print_time ("dump", dump_time);
2740 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2741 and TYPE_DECL nodes.
2743 This does nothing for local (non-static) variables.
2744 Otherwise, it sets up the RTL and outputs any assembler code
2745 (label definition, storage allocation and initialization).
2747 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2748 the assembler symbol name to be used. TOP_LEVEL is nonzero
2749 if this declaration is not within a function. */
2752 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2758 /* Declarations of variables, and of functions defined elsewhere. */
2760 /* The most obvious approach, to put an #ifndef around where
2761 this macro is used, doesn't work since it's inside a macro call. */
2762 #ifndef ASM_FINISH_DECLARE_OBJECT
2763 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2766 /* Forward declarations for nested functions are not "external",
2767 but we need to treat them as if they were. */
2768 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2769 || TREE_CODE (decl) == FUNCTION_DECL)
2770 TIMEVAR (varconst_time,
2772 make_decl_rtl (decl, asmspec, top_level);
2773 /* Initialized extern variable exists to be replaced
2774 with its value, or represents something that will be
2775 output in another file. */
2776 if (! (TREE_CODE (decl) == VAR_DECL
2777 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2778 && DECL_INITIAL (decl) != 0
2779 && DECL_INITIAL (decl) != error_mark_node))
2780 /* Don't output anything
2781 when a tentative file-scope definition is seen.
2782 But at end of compilation, do output code for them. */
2783 if (! (! at_end && top_level
2784 && (DECL_INITIAL (decl) == 0
2785 || DECL_INITIAL (decl) == error_mark_node)))
2786 assemble_variable (decl, top_level, at_end, 0);
2787 if (!output_bytecode
2788 && decl == last_assemble_variable_decl)
2790 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2794 else if (DECL_REGISTER (decl) && asmspec != 0)
2796 if (decode_reg_name (asmspec) >= 0)
2798 DECL_RTL (decl) = 0;
2799 make_decl_rtl (decl, asmspec, top_level);
2802 error ("invalid register name `%s' for register variable", asmspec);
2804 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2805 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2806 && TREE_CODE (decl) == TYPE_DECL)
2807 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2809 #ifdef SDB_DEBUGGING_INFO
2810 else if (write_symbols == SDB_DEBUG && top_level
2811 && TREE_CODE (decl) == TYPE_DECL)
2812 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2816 /* Called after finishing a record, union or enumeral type. */
2819 rest_of_type_compilation (type, toplev)
2823 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2824 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2825 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2827 #ifdef SDB_DEBUGGING_INFO
2828 if (write_symbols == SDB_DEBUG)
2829 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2833 /* This is called from finish_function (within yyparse)
2834 after each top-level definition is parsed.
2835 It is supposed to compile that function or variable
2836 and output the assembler code for it.
2837 After we return, the tree storage is freed. */
2840 rest_of_compilation (decl)
2844 int start_time = get_run_time ();
2846 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2847 to be restored after we finish compiling the function
2848 (for use when compiling inline calls to this function). */
2849 tree saved_block_tree = 0;
2850 /* Likewise, for DECL_ARGUMENTS. */
2851 tree saved_arguments = 0;
2854 if (output_bytecode)
2857 /* If we are reconsidering an inline function
2858 at the end of compilation, skip the stuff for making it inline. */
2860 if (DECL_SAVED_INSNS (decl) == 0)
2865 /* If requested, consider whether to make this function inline. */
2866 if (DECL_INLINE (decl) || flag_inline_functions)
2867 TIMEVAR (integration_time,
2869 lose = function_cannot_inline_p (decl);
2870 if (lose || ! optimize)
2872 if (warn_inline && DECL_INLINE (decl))
2873 warning_with_decl (decl, lose);
2874 DECL_ABSTRACT_ORIGIN (decl) = 0;
2875 /* Don't really compile an extern inline function.
2876 If we can't make it inline, pretend
2877 it was only declared. */
2878 if (DECL_EXTERNAL (decl))
2880 DECL_INITIAL (decl) = 0;
2881 goto exit_rest_of_compilation;
2885 /* ??? Note that this has the effect of making it look
2886 like "inline" was specified for a function if we choose
2887 to inline it. This isn't quite right, but it's
2888 probably not worth the trouble to fix. */
2889 inlineable = DECL_INLINE (decl) = 1;
2892 insns = get_insns ();
2894 /* Dump the rtl code if we are dumping rtl. */
2899 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2900 IDENTIFIER_POINTER (DECL_NAME (decl)));
2901 if (DECL_SAVED_INSNS (decl))
2902 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2903 print_rtl (rtl_dump_file, insns);
2904 fflush (rtl_dump_file);
2907 /* If function is inline, and we don't yet know whether to
2908 compile it by itself, defer decision till end of compilation.
2909 finish_compilation will call rest_of_compilation again
2910 for those functions that need to be output. Also defer those
2911 functions that we are supposed to defer. We cannot defer
2912 functions containing nested functions since the nested function
2913 data is in our non-saved obstack. */
2915 if (! current_function_contains_functions
2916 && (DECL_DEFER_OUTPUT (decl)
2917 || (DECL_INLINE (decl)
2918 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2919 && ! flag_keep_inline_functions)
2920 || DECL_EXTERNAL (decl)))))
2922 DECL_DEFER_OUTPUT (decl) = 1;
2924 /* If -Wreturn-type, we have to do a bit of compilation. */
2925 if (! warn_return_type)
2927 #ifdef DWARF_DEBUGGING_INFO
2928 /* Generate the DWARF info for the "abstract" instance
2929 of a function which we may later generate inlined and/or
2930 out-of-line instances of. */
2931 if (write_symbols == DWARF_DEBUG)
2933 set_decl_abstract_flags (decl, 1);
2934 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2935 set_decl_abstract_flags (decl, 0);
2938 #ifdef DWARF2_DEBUGGING_INFO
2939 /* Generate the DWARF2 info for the "abstract" instance
2940 of a function which we may later generate inlined and/or
2941 out-of-line instances of. */
2942 if (write_symbols == DWARF2_DEBUG)
2944 set_decl_abstract_flags (decl, 1);
2945 TIMEVAR (symout_time, dwarf2out_decl (decl));
2946 set_decl_abstract_flags (decl, 0);
2949 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2950 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
2951 goto exit_rest_of_compilation;
2955 /* If we have to compile the function now, save its rtl and subdecls
2956 so that its compilation will not affect what others get. */
2957 if (inlineable || DECL_DEFER_OUTPUT (decl))
2959 #ifdef DWARF_DEBUGGING_INFO
2960 /* Generate the DWARF info for the "abstract" instance of
2961 a function which we will generate an out-of-line instance
2962 of almost immediately (and which we may also later generate
2963 various inlined instances of). */
2964 if (write_symbols == DWARF_DEBUG)
2966 set_decl_abstract_flags (decl, 1);
2967 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2968 set_decl_abstract_flags (decl, 0);
2971 #ifdef DWARF2_DEBUGGING_INFO
2972 /* Generate the DWARF2 info for the "abstract" instance of
2973 a function which we will generate an out-of-line instance
2974 of almost immediately (and which we may also later generate
2975 various inlined instances of). */
2976 if (write_symbols == DWARF2_DEBUG)
2978 set_decl_abstract_flags (decl, 1);
2979 TIMEVAR (symout_time, dwarf2out_decl (decl));
2980 set_decl_abstract_flags (decl, 0);
2983 saved_block_tree = DECL_INITIAL (decl);
2984 saved_arguments = DECL_ARGUMENTS (decl);
2985 TIMEVAR (integration_time, save_for_inline_copying (decl));
2986 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
2989 /* If specified extern inline but we aren't inlining it, we are
2991 if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
2992 goto exit_rest_of_compilation;
2995 if (! DECL_DEFER_OUTPUT (decl))
2996 TREE_ASM_WRITTEN (decl) = 1;
2998 /* Now that integrate will no longer see our rtl, we need not distinguish
2999 between the return value of this function and the return value of called
3001 rtx_equal_function_value_matters = 0;
3003 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3004 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3006 goto exit_rest_of_compilation;
3009 /* Add an unwinder for exception handling, if needed.
3010 This must be done before we finalize PIC code. */
3014 /* If we are doing position-independent code generation, now
3015 is the time to output special prologues and epilogues.
3016 We do not want to do this earlier, because it just clutters
3017 up inline functions with meaningless insns. */
3022 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3023 Note that that may have been done above, in save_for_inline_copying.
3024 The call to resume_temporary_allocation near the end of this function
3025 goes back to the usual state of affairs. This must be done after
3026 we've built up any unwinders for exception handling, and done
3027 the FINALIZE_PIC work, if necessary. */
3029 rtl_in_current_obstack ();
3031 insns = get_insns ();
3033 /* Copy any shared structure that should not be shared. */
3035 unshare_all_rtl (insns);
3037 /* Instantiate all virtual registers. */
3039 instantiate_virtual_regs (current_function_decl, get_insns ());
3041 /* See if we have allocated stack slots that are not directly addressable.
3042 If so, scan all the insns and create explicit address computation
3043 for all references to such slots. */
3044 /* fixup_stack_slots (); */
3046 /* Find all the EH handlers. */
3047 find_exception_handler_labels ();
3049 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3050 are initialized and to compute whether control can drop off the end
3052 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3053 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3055 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3056 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3057 goto exit_rest_of_compilation;
3059 /* Dump rtl code after jump, if we are doing that. */
3064 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
3065 IDENTIFIER_POINTER (DECL_NAME (decl)));
3066 print_rtl (jump_opt_dump_file, insns);
3067 fflush (jump_opt_dump_file);
3070 /* Perform common subexpression elimination.
3071 Nonzero value from `cse_main' means that jumps were simplified
3072 and some code may now be unreachable, so do
3073 jump optimization again. */
3078 fprintf (cse_dump_file, "\n;; Function %s\n\n",
3079 IDENTIFIER_POINTER (DECL_NAME (decl)));
3084 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3086 if (flag_thread_jumps)
3087 /* Hacks by tiemann & kenner. */
3088 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3090 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3092 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
3094 if (tem || optimize > 1)
3095 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3098 /* Dump rtl code after cse, if we are doing that. */
3103 print_rtl (cse_dump_file, insns);
3104 fflush (cse_dump_file);
3110 fprintf (loop_dump_file, "\n;; Function %s\n\n",
3111 IDENTIFIER_POINTER (DECL_NAME (decl)));
3114 /* Move constant computations out of loops. */
3120 loop_optimize (insns, loop_dump_file);
3124 /* Dump rtl code after loop opt, if we are doing that. */
3129 print_rtl (loop_dump_file, insns);
3130 fflush (loop_dump_file);
3136 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
3137 IDENTIFIER_POINTER (DECL_NAME (decl)));
3140 if (optimize > 0 && flag_rerun_cse_after_loop)
3142 /* Running another jump optimization pass before the second
3143 cse pass sometimes simplifies the RTL enough to allow
3144 the second CSE pass to do a better job. Jump_optimize can change
3145 max_reg_num so we must rerun reg_scan afterwards.
3146 ??? Rework to not call reg_scan so often. */
3147 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3148 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3150 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3151 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3152 1, cse2_dump_file));
3154 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3157 if (optimize > 0 && flag_thread_jumps)
3159 /* This pass of jump threading straightens out code
3160 that was kinked by loop optimization. */
3161 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3162 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3164 /* Dump rtl code after cse, if we are doing that. */
3169 print_rtl (cse2_dump_file, insns);
3170 fflush (cse2_dump_file);
3173 if (branch_prob_dump)
3176 fprintf (branch_prob_dump_file, "\n;; Function %s\n\n",
3177 IDENTIFIER_POINTER (DECL_NAME (decl)));
3180 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3181 TIMEVAR (branch_prob_time,
3183 branch_prob (insns, branch_prob_dump_file);
3186 if (branch_prob_dump)
3189 print_rtl (branch_prob_dump_file, insns);
3190 fflush (branch_prob_dump_file);
3192 /* We are no longer anticipating cse in this function, at least. */
3194 cse_not_expected = 1;
3196 /* Now we choose between stupid (pcc-like) register allocation
3197 (if we got the -noreg switch and not -opt)
3198 and smart register allocation. */
3200 if (optimize > 0) /* Stupid allocation probably won't work */
3201 obey_regdecls = 0; /* if optimizations being done. */
3205 /* Print function header into flow dump now
3206 because doing the flow analysis makes some of the dump. */
3211 fprintf (flow_dump_file, "\n;; Function %s\n\n",
3212 IDENTIFIER_POINTER (DECL_NAME (decl)));
3219 regclass (insns, max_reg_num ());
3220 stupid_life_analysis (insns, max_reg_num (),
3226 /* Do control and data flow analysis,
3227 and write some of the results to dump file. */
3229 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
3231 if (warn_uninitialized)
3233 uninitialized_vars_warning (DECL_INITIAL (decl));
3234 setjmp_args_warning ();
3238 /* Dump rtl after flow analysis. */
3243 print_rtl (flow_dump_file, insns);
3244 fflush (flow_dump_file);
3247 /* If -opt, try combining insns through substitution. */
3250 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3252 /* Dump rtl code after insn combination. */
3257 fprintf (combine_dump_file, "\n;; Function %s\n\n",
3258 IDENTIFIER_POINTER (DECL_NAME (decl)));
3259 dump_combine_stats (combine_dump_file);
3260 print_rtl (combine_dump_file, insns);
3261 fflush (combine_dump_file);
3264 /* Print function header into sched dump now
3265 because doing the sched analysis makes some of the dump. */
3270 fprintf (sched_dump_file, "\n;; Function %s\n\n",
3271 IDENTIFIER_POINTER (DECL_NAME (decl)));
3274 if (optimize > 0 && flag_schedule_insns)
3276 /* Do control and data sched analysis,
3277 and write some of the results to dump file. */
3279 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
3282 /* Dump rtl after instruction scheduling. */
3287 print_rtl (sched_dump_file, insns);
3288 fflush (sched_dump_file);
3291 /* Unless we did stupid register allocation,
3292 allocate pseudo-regs that are used only within 1 basic block. */
3295 TIMEVAR (local_alloc_time,
3297 regclass (insns, max_reg_num ());
3301 /* Dump rtl code after allocating regs within basic blocks. */
3306 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
3307 IDENTIFIER_POINTER (DECL_NAME (decl)));
3308 dump_flow_info (local_reg_dump_file);
3309 dump_local_alloc (local_reg_dump_file);
3310 print_rtl (local_reg_dump_file, insns);
3311 fflush (local_reg_dump_file);
3314 if (global_reg_dump)
3316 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
3317 IDENTIFIER_POINTER (DECL_NAME (decl))));
3319 /* Save the last label number used so far, so reorg can tell
3320 when it's safe to kill spill regs. */
3321 max_label_num_after_reload = max_label_num ();
3323 /* Unless we did stupid register allocation,
3324 allocate remaining pseudo-regs, then do the reload pass
3325 fixing up any insns that are invalid. */
3327 TIMEVAR (global_alloc_time,
3330 failure = global_alloc (global_reg_dump_file);
3332 failure = reload (insns, 0, global_reg_dump_file);
3335 if (global_reg_dump)
3338 dump_global_regs (global_reg_dump_file);
3339 print_rtl (global_reg_dump_file, insns);
3340 fflush (global_reg_dump_file);
3344 goto exit_rest_of_compilation;
3346 reload_completed = 1;
3348 /* On some machines, the prologue and epilogue code, or parts thereof,
3349 can be represented as RTL. Doing so lets us schedule insns between
3350 it and the rest of the code and also allows delayed branch
3351 scheduling to operate in the epilogue. */
3353 thread_prologue_and_epilogue_insns (insns);
3355 if (optimize > 0 && flag_schedule_insns_after_reload)
3360 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
3361 IDENTIFIER_POINTER (DECL_NAME (decl)));
3364 /* Do control and data sched analysis again,
3365 and write some more of the results to dump file. */
3367 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
3369 /* Dump rtl after post-reorder instruction scheduling. */
3374 print_rtl (sched2_dump_file, insns);
3375 fflush (sched2_dump_file);
3379 #ifdef LEAF_REGISTERS
3381 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3385 /* One more attempt to remove jumps to .+1
3386 left by dead-store-elimination.
3387 Also do cross-jumping this time
3388 and delete no-op move insns. */
3392 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3395 /* Dump rtl code after jump, if we are doing that. */
3400 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
3401 IDENTIFIER_POINTER (DECL_NAME (decl)));
3402 print_rtl (jump2_opt_dump_file, insns);
3403 fflush (jump2_opt_dump_file);
3406 /* If a machine dependent reorganization is needed, call it. */
3407 #ifdef MACHINE_DEPENDENT_REORG
3408 MACHINE_DEPENDENT_REORG (insns);
3411 /* If a scheduling pass for delayed branches is to be done,
3412 call the scheduling code. */
3415 if (optimize > 0 && flag_delayed_branch)
3417 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3422 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
3423 IDENTIFIER_POINTER (DECL_NAME (decl)));
3424 print_rtl (dbr_sched_dump_file, insns);
3425 fflush (dbr_sched_dump_file);
3431 /* Shorten branches. */
3432 TIMEVAR (shorten_branch_time,
3434 shorten_branches (get_insns ());
3438 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3443 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
3444 IDENTIFIER_POINTER (DECL_NAME (decl)));
3445 print_rtl (stack_reg_dump_file, insns);
3446 fflush (stack_reg_dump_file);
3451 /* Now turn the rtl into assembler code. */
3453 TIMEVAR (final_time,
3458 /* Get the function's name, as described by its RTL.
3459 This may be different from the DECL_NAME name used
3460 in the source file. */
3462 x = DECL_RTL (decl);
3463 if (GET_CODE (x) != MEM)
3466 if (GET_CODE (x) != SYMBOL_REF)
3468 fnname = XSTR (x, 0);
3470 assemble_start_function (decl, fnname);
3471 final_start_function (insns, asm_out_file, optimize);
3472 final (insns, asm_out_file, optimize, 0);
3473 final_end_function (insns, asm_out_file, optimize);
3474 assemble_end_function (decl, fnname);
3475 fflush (asm_out_file);
3478 /* Write DBX symbols if requested */
3480 /* Note that for those inline functions where we don't initially
3481 know for certain that we will be generating an out-of-line copy,
3482 the first invocation of this routine (rest_of_compilation) will
3483 skip over this code by doing a `goto exit_rest_of_compilation;'.
3484 Later on, finish_compilation will call rest_of_compilation again
3485 for those inline functions that need to have out-of-line copies
3486 generated. During that call, we *will* be routed past here. */
3488 #ifdef DBX_DEBUGGING_INFO
3489 if (write_symbols == DBX_DEBUG)
3490 TIMEVAR (symout_time, dbxout_function (decl));
3493 #ifdef DWARF_DEBUGGING_INFO
3494 if (write_symbols == DWARF_DEBUG)
3495 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3498 #ifdef DWARF2_DEBUGGING_INFO
3499 if (write_symbols == DWARF2_DEBUG)
3500 TIMEVAR (symout_time, dwarf2out_decl (decl));
3503 exit_rest_of_compilation:
3505 /* In case the function was not output,
3506 don't leave any temporary anonymous types
3507 queued up for sdb output. */
3508 #ifdef SDB_DEBUGGING_INFO
3509 if (write_symbols == SDB_DEBUG)
3510 sdbout_types (NULL_TREE);
3513 /* Put back the tree of subblocks and list of arguments
3514 from before we copied them.
3515 Code generation and the output of debugging info may have modified
3516 the copy, but the original is unchanged. */
3518 if (saved_block_tree != 0)
3520 DECL_INITIAL (decl) = saved_block_tree;
3521 DECL_ARGUMENTS (decl) = saved_arguments;
3522 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3525 reload_completed = 0;
3527 /* Clear out the insn_length contents now that they are no longer valid. */
3528 init_insn_lengths ();
3530 /* Clear out the real_constant_chain before some of the rtx's
3531 it runs through become garbage. */
3533 clear_const_double_mem ();
3535 /* Cancel the effect of rtl_in_current_obstack. */
3537 resume_temporary_allocation ();
3539 /* Show no temporary slots allocated. */
3543 /* The parsing time is all the time spent in yyparse
3544 *except* what is spent in this function. */
3546 parse_time -= get_run_time () - start_time;
3549 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3550 Exit code is 35 if can't open files, 34 if fatal error,
3551 33 if had nonfatal errors, else success. */
3554 main (argc, argv, envp)
3561 int flag_print_mem = 0;
3562 int version_flag = 0;
3565 /* save in case md file wants to emit args as a comment. */
3569 p = argv[0] + strlen (argv[0]);
3570 while (p != argv[0] && p[-1] != '/'
3571 #ifdef DIR_SEPARATOR
3572 && p[-1] != DIR_SEPARATOR
3579 /* Get rid of any avoidable limit on stack size. */
3583 /* Set the stack limit huge so that alloca does not fail. */
3584 getrlimit (RLIMIT_STACK, &rlim);
3585 rlim.rlim_cur = rlim.rlim_max;
3586 setrlimit (RLIMIT_STACK, &rlim);
3588 #endif /* RLIMIT_STACK */
3590 signal (SIGFPE, float_signal);
3593 signal (SIGPIPE, pipe_closed);
3596 decl_printable_name = decl_name;
3597 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3599 /* Initialize whether `char' is signed. */
3600 flag_signed_char = DEFAULT_SIGNED_CHAR;
3601 #ifdef DEFAULT_SHORT_ENUMS
3602 /* Initialize how much space enums occupy, by default. */
3603 flag_short_enums = DEFAULT_SHORT_ENUMS;
3606 /* Scan to see what optimization level has been specified. That will
3607 determine the default value of many flags. */
3608 for (i = 1; i < argc; i++)
3610 if (!strcmp (argv[i], "-O"))
3614 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3616 /* Handle -O2, -O3, -O69, ... */
3617 char *p = &argv[i][2];
3621 if (! (c >= '0' && c <= '9'))
3624 optimize = atoi (&argv[i][2]);
3628 obey_regdecls = (optimize == 0);
3633 flag_thread_jumps = 1;
3635 flag_delayed_branch = 1;
3637 #ifdef CAN_DEBUG_WITHOUT_FP
3638 flag_omit_frame_pointer = 1;
3644 flag_cse_follow_jumps = 1;
3645 flag_cse_skip_blocks = 1;
3646 flag_expensive_optimizations = 1;
3647 flag_strength_reduce = 1;
3648 flag_rerun_cse_after_loop = 1;
3649 flag_caller_saves = 1;
3651 #ifdef INSN_SCHEDULING
3652 flag_schedule_insns = 1;
3653 flag_schedule_insns_after_reload = 1;
3659 flag_inline_functions = 1;
3662 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
3665 set_target_switch ("");
3667 #ifdef OPTIMIZATION_OPTIONS
3668 /* Allow default optimizations to be specified on a per-machine basis. */
3669 OPTIMIZATION_OPTIONS (optimize);
3672 /* Initialize register usage now so switches may override. */
3675 for (i = 1; i < argc; i++)
3678 /* If this is a language-specific option,
3679 decode it in a language-specific way. */
3680 for (j = 0; lang_options[j] != 0; j++)
3681 if (!strncmp (argv[i], lang_options[j],
3682 strlen (lang_options[j])))
3684 if (lang_options[j] != 0)
3685 /* If the option is valid for *some* language,
3686 treat it as valid even if this language doesn't understand it. */
3687 lang_decode_option (argv[i]);
3688 else if (argv[i][0] == '-' && argv[i][1] != 0)
3690 register char *str = argv[i] + 1;
3695 set_target_switch (&str[1]);
3696 else if (!strcmp (str, "dumpbase"))
3698 dump_base_name = argv[++i];
3700 else if (str[0] == 'd')
3702 register char *p = &str[1];
3707 branch_prob_dump = 1;
3711 global_reg_dump = 1;
3717 cse_dump = 1, cse2_dump = 1;
3723 branch_prob_dump = 1;
3738 global_reg_dump = 1;
3756 flag_print_asm_name = 1;
3777 rtl_dump_and_exit = 1;
3784 else if (str[0] == 'f')
3786 register char *p = &str[1];
3789 /* Some kind of -f option.
3790 P's value is the option sans `-f'.
3791 Search for it in the table of options. */
3794 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3797 if (!strcmp (p, f_options[j].string))
3799 *f_options[j].variable = f_options[j].on_value;
3800 /* A goto here would be cleaner,
3801 but breaks the vax pcc. */
3804 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3805 && ! strcmp (p+3, f_options[j].string))
3807 *f_options[j].variable = ! f_options[j].on_value;
3814 else if (!strncmp (p, "fixed-", 6))
3815 fix_register (&p[6], 1, 1);
3816 else if (!strncmp (p, "call-used-", 10))
3817 fix_register (&p[10], 0, 1);
3818 else if (!strncmp (p, "call-saved-", 11))
3819 fix_register (&p[11], 0, 0);
3821 error ("Invalid option `%s'", argv[i]);
3823 else if (str[0] == 'O')
3825 register char *p = str+1;
3826 while (*p && *p >= '0' && *p <= '9')
3831 error ("Invalid option `%s'", argv[i]);
3833 else if (!strcmp (str, "pedantic"))
3835 else if (!strcmp (str, "pedantic-errors"))
3836 flag_pedantic_errors = pedantic = 1;
3837 else if (!strcmp (str, "quiet"))
3839 else if (!strcmp (str, "version"))
3841 else if (!strcmp (str, "w"))
3842 inhibit_warnings = 1;
3843 else if (!strcmp (str, "W"))
3846 /* We save the value of warn_uninitialized, since if they put
3847 -Wuninitialized on the command line, we need to generate a
3848 warning about not using it without also specifying -O. */
3849 if (warn_uninitialized != 1)
3850 warn_uninitialized = 2;
3852 else if (str[0] == 'W')
3854 register char *p = &str[1];
3857 /* Some kind of -W option.
3858 P's value is the option sans `-W'.
3859 Search for it in the table of options. */
3862 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3865 if (!strcmp (p, W_options[j].string))
3867 *W_options[j].variable = W_options[j].on_value;
3868 /* A goto here would be cleaner,
3869 but breaks the vax pcc. */
3872 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3873 && ! strcmp (p+3, W_options[j].string))
3875 *W_options[j].variable = ! W_options[j].on_value;
3882 else if (!strncmp (p, "id-clash-", 9))
3888 if (*endp >= '0' && *endp <= '9')
3892 error ("Invalid option `%s'", argv[i]);
3897 id_clash_len = atoi (str + 10);
3900 else if (!strncmp (p, "larger-than-", 12))
3902 char *endp = p + 12;
3906 if (*endp >= '0' && *endp <= '9')
3910 error ("Invalid option `%s'", argv[i]);
3911 goto larger_than_lose;
3914 warn_larger_than = 1;
3915 larger_than_size = atoi (str + 13);
3919 error ("Invalid option `%s'", argv[i]);
3921 else if (!strcmp (str, "p"))
3925 else if (!strcmp (str, "a"))
3927 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3928 warning ("`-a' option (basic block profile) not supported");
3930 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
3933 else if (!strcmp (str, "ax"))
3935 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3936 warning ("`-ax' option (jump profiling) not supported");
3938 profile_block_flag = (!profile_block_flag
3939 || profile_block_flag == 2) ? 2 : 3;
3942 else if (str[0] == 'g')
3946 /* A lot of code assumes write_symbols == NO_DEBUG if the
3947 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
3948 of what debugging type has been selected). This records the
3949 selected type. It is an error to specify more than one
3951 static enum debug_info_type selected_debug_type = NO_DEBUG;
3952 /* Non-zero if debugging format has been explicitly set.
3953 -g and -ggdb don't explicitly set the debugging format so
3954 -gdwarf -g3 is equivalent to -gdwarf3. */
3955 static int type_explicitly_set_p = 0;
3956 /* Table of supported debugging formats. */
3959 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
3960 constant expression, we use NO_DEBUG in its place. */
3961 enum debug_info_type debug_type;
3962 int use_extensions_p;
3963 } *da, debug_args[] = {
3964 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS },
3965 { "ggdb", NO_DEBUG, 1 },
3966 #ifdef DBX_DEBUGGING_INFO
3967 { "gstabs", DBX_DEBUG, 0 },
3968 { "gstabs+", DBX_DEBUG, 1 },
3970 #ifdef DWARF_DEBUGGING_INFO
3971 { "gdwarf", DWARF_DEBUG, 0 },
3972 { "gdwarf+", DWARF_DEBUG, 1 },
3974 #ifdef DWARF2_DEBUGGING_INFO
3975 { "gdwarf-2", DWARF2_DEBUG, 0 },
3977 #ifdef XCOFF_DEBUGGING_INFO
3978 { "gxcoff", XCOFF_DEBUG, 0 },
3979 { "gxcoff+", XCOFF_DEBUG, 1 },
3981 #ifdef SDB_DEBUGGING_INFO
3982 { "gcoff", SDB_DEBUG, 0 },
3986 /* Indexed by enum debug_info_type. */
3987 static char *debug_type_names[] = {
3988 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
3991 /* Look up STR in the table. */
3992 for (da = debug_args; da->arg; da++)
3994 if (! strncmp (str, da->arg, strlen (da->arg)))
3996 enum debug_info_type type = da->debug_type;
3999 p = str + strlen (da->arg);
4000 if (*p && (*p < '0' || *p > '9'))
4003 while (*q && (*q >= '0' && *q <= '9'))
4008 level = 2; /* default debugging info level */
4009 if (*q || level > 3)
4011 warning ("invalid debug level specification in option: `-%s'",
4013 /* ??? This error message is incorrect in the case of
4015 warning ("no debugging information will be generated");
4019 /* ??? A few targets use STR in the
4020 definition of PREFERRED_DEBUGGING_TYPE! */
4021 if (type == NO_DEBUG)
4022 type = PREFERRED_DEBUGGING_TYPE;
4024 if (type == NO_DEBUG)
4025 warning ("`-%s' not supported by this configuration of GCC",
4028 /* Does it conflict with an already selected type? */
4029 if (type_explicitly_set_p
4030 /* -g/-ggdb don't conflict with anything */
4031 && da->debug_type != NO_DEBUG
4032 && type != selected_debug_type)
4033 warning ("`-%s' ignored, conflicts with `-g%s'",
4034 str, debug_type_names[(int) selected_debug_type]);
4037 /* If the format has already been set, -g/-ggdb
4038 only change the debug level. */
4039 if (type_explicitly_set_p
4040 && da->debug_type == NO_DEBUG)
4041 ; /* don't change debugging type */
4044 selected_debug_type = type;
4045 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4047 write_symbols = (level == 0
4049 : selected_debug_type);
4050 use_gnu_debug_info_extensions = da->use_extensions_p;
4051 debug_info_level = (enum debug_info_level) level;
4057 warning ("`-%s' not supported by this configuration of GCC",
4060 else if (!strcmp (str, "o"))
4062 asm_file_name = argv[++i];
4064 else if (str[0] == 'G')
4066 g_switch_set = TRUE;
4067 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
4069 else if (!strncmp (str, "aux-info", 8))
4071 flag_gen_aux_info = 1;
4072 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
4075 error ("Invalid option `%s'", argv[i]);
4077 else if (argv[i][0] == '+')
4078 error ("Invalid option `%s'", argv[i]);
4083 /* Initialize for bytecode output. A good idea to do this as soon as
4084 possible after the "-f" options have been parsed. */
4085 if (output_bytecode)
4087 #ifndef TARGET_SUPPORTS_BYTECODE
4088 /* Just die with a fatal error if not supported */
4089 fatal ("-fbytecode not supported for this target");
4097 /* Inlining does not work if not optimizing,
4098 so force it not to be done. */
4102 /* The c_decode_option and lang_decode_option functions set
4103 this to `2' if -Wall is used, so we can avoid giving out
4104 lots of errors for people who don't realize what -Wall does. */
4105 if (warn_uninitialized == 1)
4106 warning ("-Wuninitialized is not supported without -O");
4109 #ifdef OVERRIDE_OPTIONS
4110 /* Some machines may reject certain combinations of options. */
4114 if (profile_block_flag == 3)
4116 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4117 profile_block_flag = 2;
4120 /* Unrolling all loops implies that standard loop unrolling must also
4122 if (flag_unroll_all_loops)
4123 flag_unroll_loops = 1;
4124 /* Loop unrolling requires that strength_reduction be on also. Silently
4125 turn on strength reduction here if it isn't already on. Also, the loop
4126 unrolling code assumes that cse will be run after loop, so that must
4127 be turned on also. */
4128 if (flag_unroll_loops)
4130 flag_strength_reduce = 1;
4131 flag_rerun_cse_after_loop = 1;
4134 /* Warn about options that are not supported on this machine. */
4135 #ifndef INSN_SCHEDULING
4136 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4137 warning ("instruction scheduling not supported on this target machine");
4140 if (flag_delayed_branch)
4141 warning ("this target machine does not have delayed branches");
4144 /* If we are in verbose mode, write out the version and maybe all the
4145 option flags in use. */
4148 print_version (stderr, "");
4150 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4153 compile_file (filename);
4155 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4158 char *lim = (char *) sbrk (0);
4160 fprintf (stderr, "Data size %d.\n",
4161 lim - (char *) &environ);
4165 system ("ps -l 1>&2");
4168 #endif /* not USG */
4170 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4173 exit (FATAL_EXIT_CODE);
4175 exit (FATAL_EXIT_CODE);
4176 exit (SUCCESS_EXIT_CODE);
4180 /* Decode -m switches. */
4182 /* Here is a table, controlled by the tm.h file, listing each -m switch
4183 and which bits in `target_switches' it should set or clear.
4184 If VALUE is positive, it is bits to set.
4185 If VALUE is negative, -VALUE is bits to clear.
4186 (The sign bit is not used so there is no confusion.) */
4188 struct {char *name; int value;} target_switches []
4191 /* This table is similar, but allows the switch to have a value. */
4193 #ifdef TARGET_OPTIONS
4194 struct {char *prefix; char ** variable;} target_options []
4198 /* Decode the switch -mNAME. */
4201 set_target_switch (name)
4207 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4208 if (!strcmp (target_switches[j].name, name))
4210 if (target_switches[j].value < 0)
4211 target_flags &= ~-target_switches[j].value;
4213 target_flags |= target_switches[j].value;
4217 #ifdef TARGET_OPTIONS
4219 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4221 int len = strlen (target_options[j].prefix);
4222 if (!strncmp (target_options[j].prefix, name, len))
4224 *target_options[j].variable = name + len;
4231 error ("Invalid option `%s'", name);
4234 /* Print version information to FILE.
4235 Each line begins with INDENT (for the case where FILE is the
4236 assembler output file). */
4239 print_version (file, indent)
4243 fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4244 language_string, version_string);
4245 fprintf (file, " (%s)", TARGET_NAME);
4248 #define __VERSION__ "[unknown]"
4250 fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4252 fprintf (file, " compiled by CC.\n");
4256 /* Print an option value and return the adjusted position in the line.
4257 ??? We don't handle error returns from fprintf (disk full); presumably
4258 other code will catch a disk full though. */
4261 print_single_switch (file, pos, max, indent, sep, term, type, name)
4264 char *indent, *sep, *term, *type, *name;
4266 /* The ultrix fprintf returns 0 on success, so compute the result we want
4267 here since we need it for the following test. */
4268 int len = strlen (sep) + strlen (type) + strlen (name);
4273 fprintf (file, "%s", term);
4278 fprintf (file, "%s", indent);
4279 pos = strlen (indent);
4281 fprintf (file, "%s%s%s", sep, type, name);
4286 /* Print active target switches to FILE.
4287 POS is the current cursor position and MAX is the size of a "line".
4288 Each line begins with INDENT and ends with TERM.
4289 Each switch is separated from the next by SEP. */
4292 print_switch_values (file, pos, max, indent, sep, term)
4295 char *indent, *sep, *term;
4300 /* Print the options as passed. */
4302 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4303 "options passed: ", "");
4305 for (p = &save_argv[1]; *p != NULL; p++)
4309 if (strcmp (*p, "-o") == 0)
4315 if (strcmp (*p, "-quiet") == 0)
4317 if (strcmp (*p, "-version") == 0)
4322 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4325 fprintf (file, "%s", term);
4327 /* Print the -f and -m options that have been enabled.
4328 We don't handle language specific options but printing argv
4331 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4332 "options enabled: ", "");
4334 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4335 if (*f_options[j].variable == f_options[j].on_value)
4336 pos = print_single_switch (file, pos, max, indent, sep, term,
4337 "-f", f_options[j].string);
4339 /* Print target specific options. */
4341 flags = target_flags;
4342 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4343 if (target_switches[j].name[0] != '\0'
4344 && target_switches[j].value > 0
4345 && ((target_switches[j].value & target_flags)
4346 == target_switches[j].value))
4348 pos = print_single_switch (file, pos, max, indent, sep, term,
4349 "-m", target_switches[j].name);
4350 flags &= ~ target_switches[j].value;
4353 #ifdef TARGET_OPTIONS
4354 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4355 if (*target_options[j].variable != NULL)
4358 sprintf (prefix, "-m%s", target_options[j].prefix);
4359 pos = print_single_switch (file, pos, max, indent, sep, term,
4360 prefix, *target_options[j].variable);
4364 fprintf (file, "%s", term);
4367 /* Record the beginning of a new source file, named FILENAME. */
4370 debug_start_source_file (filename)
4371 register char *filename;
4373 #ifdef DBX_DEBUGGING_INFO
4374 if (write_symbols == DBX_DEBUG)
4375 dbxout_start_new_source_file (filename);
4377 #ifdef DWARF_DEBUGGING_INFO
4378 if (debug_info_level == DINFO_LEVEL_VERBOSE
4379 && write_symbols == DWARF_DEBUG)
4380 dwarfout_start_new_source_file (filename);
4381 #endif /* DWARF_DEBUGGING_INFO */
4382 #ifdef DWARF2_DEBUGGING_INFO
4383 if (debug_info_level == DINFO_LEVEL_VERBOSE
4384 && write_symbols == DWARF2_DEBUG)
4385 dwarf2out_start_source_file (filename);
4386 #endif /* DWARF2_DEBUGGING_INFO */
4387 #ifdef SDB_DEBUGGING_INFO
4388 if (write_symbols == SDB_DEBUG)
4389 sdbout_start_new_source_file (filename);
4393 /* Record the resumption of a source file. LINENO is the line number in
4394 the source file we are returning to. */
4397 debug_end_source_file (lineno)
4398 register unsigned lineno;
4400 #ifdef DBX_DEBUGGING_INFO
4401 if (write_symbols == DBX_DEBUG)
4402 dbxout_resume_previous_source_file ();
4404 #ifdef DWARF_DEBUGGING_INFO
4405 if (debug_info_level == DINFO_LEVEL_VERBOSE
4406 && write_symbols == DWARF_DEBUG)
4407 dwarfout_resume_previous_source_file (lineno);
4408 #endif /* DWARF_DEBUGGING_INFO */
4409 #ifdef DWARF2_DEBUGGING_INFO
4410 if (debug_info_level == DINFO_LEVEL_VERBOSE
4411 && write_symbols == DWARF2_DEBUG)
4412 dwarf2out_end_source_file ();
4413 #endif /* DWARF2_DEBUGGING_INFO */
4414 #ifdef SDB_DEBUGGING_INFO
4415 if (write_symbols == SDB_DEBUG)
4416 sdbout_resume_previous_source_file ();
4420 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4421 the tail part of the directive line, i.e. the part which is past the
4422 initial whitespace, #, whitespace, directive-name, whitespace part. */
4425 debug_define (lineno, buffer)
4426 register unsigned lineno;
4427 register char *buffer;
4429 #ifdef DWARF_DEBUGGING_INFO
4430 if (debug_info_level == DINFO_LEVEL_VERBOSE
4431 && write_symbols == DWARF_DEBUG)
4432 dwarfout_define (lineno, buffer);
4433 #endif /* DWARF_DEBUGGING_INFO */
4434 #ifdef DWARF2_DEBUGGING_INFO
4435 if (debug_info_level == DINFO_LEVEL_VERBOSE
4436 && write_symbols == DWARF2_DEBUG)
4437 dwarf2out_define (lineno, buffer);
4438 #endif /* DWARF2_DEBUGGING_INFO */
4441 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4442 the tail part of the directive line, i.e. the part which is past the
4443 initial whitespace, #, whitespace, directive-name, whitespace part. */
4446 debug_undef (lineno, buffer)
4447 register unsigned lineno;
4448 register char *buffer;
4450 #ifdef DWARF_DEBUGGING_INFO
4451 if (debug_info_level == DINFO_LEVEL_VERBOSE
4452 && write_symbols == DWARF_DEBUG)
4453 dwarfout_undef (lineno, buffer);
4454 #endif /* DWARF_DEBUGGING_INFO */
4455 #ifdef DWARF2_DEBUGGING_INFO
4456 if (debug_info_level == DINFO_LEVEL_VERBOSE
4457 && write_symbols == DWARF2_DEBUG)
4458 dwarf2out_undef (lineno, buffer);
4459 #endif /* DWARF2_DEBUGGING_INFO */