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;
244 int combine_dump = 0;
246 int local_reg_dump = 0;
247 int global_reg_dump = 0;
249 int jump2_opt_dump = 0;
250 int dbr_sched_dump = 0;
251 int flag_print_asm_name = 0;
252 int stack_reg_dump = 0;
254 /* Name for output file of assembly code, specified with -o. */
258 /* Value of the -G xx switch, and whether it was passed or not. */
262 /* Type(s) of debugging information we are producing (if any).
263 See flags.h for the definitions of the different possible
264 types of debugging information. */
265 enum debug_info_type write_symbols = NO_DEBUG;
267 /* Level of debugging information we are producing. See flags.h
268 for the definitions of the different possible levels. */
269 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
271 /* Nonzero means use GNU-only extensions in the generated symbolic
272 debugging information. */
273 /* Currently, this only has an effect when write_symbols is set to
274 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
275 int use_gnu_debug_info_extensions = 0;
277 /* Nonzero means do optimizations. -O.
278 Particular numeric values stand for particular amounts of optimization;
279 thus, -O2 stores 2 here. However, the optimizations beyond the basic
280 ones are not controlled directly by this variable. Instead, they are
281 controlled by individual `flag_...' variables that are defaulted
282 based on this variable. */
286 /* Number of error messages and warning messages so far. */
289 int warningcount = 0;
292 /* Flag to output bytecode instead of native assembler */
293 int output_bytecode = 0;
295 /* Pointer to function to compute the name to use to print a declaration. */
297 char *(*decl_printable_name) ();
299 /* Pointer to function to compute rtl for a language-specific tree code. */
301 struct rtx_def *(*lang_expand_expr) ();
303 /* Pointer to function to finish handling an incomplete decl at the
304 end of compilation. */
306 void (*incomplete_decl_finalize_hook) () = 0;
308 /* Highest label number used at the end of reload. */
310 int max_label_num_after_reload;
312 /* Nonzero if generating code to do profiling. */
314 int profile_flag = 0;
316 /* Nonzero if generating code to do profiling on a line-by-line basis. */
318 int profile_block_flag;
320 /* Nonzero for -pedantic switch: warn about anything
321 that standard spec forbids. */
325 /* Temporarily suppress certain warnings.
326 This is set while reading code from a system header file. */
328 int in_system_header = 0;
330 /* Nonzero means do stupid register allocation.
331 Currently, this is 1 if `optimize' is 0. */
333 int obey_regdecls = 0;
335 /* Don't print functions as they are compiled and don't print
336 times taken by the various passes. -quiet. */
342 /* Nonzero means `char' should be signed. */
344 int flag_signed_char;
346 /* Nonzero means give an enum type only as many bytes as it needs. */
348 int flag_short_enums;
350 /* Nonzero for -fcaller-saves: allocate values in regs that need to
351 be saved across function calls, if that produces overall better code.
352 Optional now, so people can test it. */
354 #ifdef DEFAULT_CALLER_SAVES
355 int flag_caller_saves = 1;
357 int flag_caller_saves = 0;
360 /* Nonzero if structures and unions should be returned in memory.
362 This should only be defined if compatibility with another compiler or
363 with an ABI is needed, because it results in slower code. */
365 #ifndef DEFAULT_PCC_STRUCT_RETURN
366 #define DEFAULT_PCC_STRUCT_RETURN 1
369 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
371 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
373 /* Nonzero for -fforce-mem: load memory value into a register
374 before arithmetic on it. This makes better cse but slower compilation. */
376 int flag_force_mem = 0;
378 /* Nonzero for -fforce-addr: load memory address into a register before
379 reference to memory. This makes better cse but slower compilation. */
381 int flag_force_addr = 0;
383 /* Nonzero for -fdefer-pop: don't pop args after each function call;
384 instead save them up to pop many calls' args with one insns. */
386 int flag_defer_pop = 0;
388 /* Nonzero for -ffloat-store: don't allocate floats and doubles
389 in extended-precision registers. */
391 int flag_float_store = 0;
393 /* Nonzero for -fcse-follow-jumps:
394 have cse follow jumps to do a more extensive job. */
396 int flag_cse_follow_jumps;
398 /* Nonzero for -fcse-skip-blocks:
399 have cse follow a branch around a block. */
400 int flag_cse_skip_blocks;
402 /* Nonzero for -fexpensive-optimizations:
403 perform miscellaneous relatively-expensive optimizations. */
404 int flag_expensive_optimizations;
406 /* Nonzero for -fthread-jumps:
407 have jump optimize output of loop. */
409 int flag_thread_jumps;
411 /* Nonzero enables strength-reduction in loop.c. */
413 int flag_strength_reduce = 0;
415 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
416 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
417 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
420 int flag_unroll_loops;
422 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
423 This is generally not a win. */
425 int flag_unroll_all_loops;
427 /* Nonzero for -fwritable-strings:
428 store string constants in data segment and don't uniquize them. */
430 int flag_writable_strings = 0;
432 /* Nonzero means don't put addresses of constant functions in registers.
433 Used for compiling the Unix kernel, where strange substitutions are
434 done on the assembly output. */
436 int flag_no_function_cse = 0;
438 /* Nonzero for -fomit-frame-pointer:
439 don't make a frame pointer in simple functions that don't require one. */
441 int flag_omit_frame_pointer = 0;
443 /* Nonzero means place each function into its own section on those platforms
444 which support arbitrary section names and unlimited numbers of sections. */
446 int flag_function_sections = 0;
448 /* Nonzero to inhibit use of define_optimization peephole opts. */
450 int flag_no_peephole = 0;
452 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
453 operations in the interest of optimization. For example it allows
454 GCC to assume arguments to sqrt are nonnegative numbers, allowing
455 faster code for sqrt to be generated. */
457 int flag_fast_math = 0;
459 /* Nonzero means all references through pointers are volatile. */
463 /* Nonzero means treat all global and extern variables as global. */
465 int flag_volatile_global;
467 /* Nonzero means just do syntax checking; don't output anything. */
469 int flag_syntax_only = 0;
471 /* Nonzero means to rerun cse after loop optimization. This increases
472 compilation time about 20% and picks up a few more common expressions. */
474 static int flag_rerun_cse_after_loop;
476 /* Nonzero for -finline-functions: ok to inline functions that look like
477 good inline candidates. */
479 int flag_inline_functions;
481 /* Nonzero for -fkeep-inline-functions: even if we make a function
482 go inline everywhere, keep its definition around for debugging
485 int flag_keep_inline_functions;
487 /* Nonzero means that functions will not be inlined. */
491 /* Nonzero means that we should emit static const variables
492 regardless of whether or not optimization is turned on. */
494 int flag_keep_static_consts = 1;
496 /* Nonzero means we should be saving declaration info into a .X file. */
498 int flag_gen_aux_info = 0;
500 /* Specified name of aux-info file. */
502 static char *aux_info_file_name;
504 /* Nonzero means make the text shared if supported. */
506 int flag_shared_data;
508 /* Nonzero means schedule into delayed branch slots if supported. */
510 int flag_delayed_branch;
512 /* Nonzero means to run cleanups after CALL_EXPRs. */
514 int flag_short_temps;
516 /* Nonzero if we are compiling pure (sharable) code.
517 Value is 1 if we are doing reasonable (i.e. simple
518 offset into offset table) pic. Value is 2 if we can
519 only perform register offsets. */
523 /* Nonzero means generate extra code for exception handling and enable
524 exception handling. */
526 int flag_exceptions = 1;
528 /* Nonzero means don't place uninitialized global data in common storage
533 /* Nonzero means pretend it is OK to examine bits of target floats,
534 even if that isn't true. The resulting code will have incorrect constants,
535 but the same series of instructions that the native compiler would make. */
537 int flag_pretend_float;
539 /* Nonzero means change certain warnings into errors.
540 Usually these are warnings about failure to conform to some standard. */
542 int flag_pedantic_errors = 0;
544 /* flag_schedule_insns means schedule insns within basic blocks (before
546 flag_schedule_insns_after_reload means schedule insns after
549 int flag_schedule_insns = 0;
550 int flag_schedule_insns_after_reload = 0;
552 /* -finhibit-size-directive inhibits output of .size for ELF.
553 This is used only for compiling crtstuff.c,
554 and it may be extended to other effects
555 needed for crtstuff.c on other systems. */
556 int flag_inhibit_size_directive = 0;
558 /* -fverbose-asm causes extra commentary information to be produced in
559 the generated assembly code (to make it more readable). This option
560 is generally only of use to those who actually need to read the
561 generated assembly code (perhaps while debugging the compiler itself).
562 -fverbose-asm is the default. -fno-verbose-asm causes the extra information
563 to be omitted and is useful when comparing two assembler files. */
565 int flag_verbose_asm = 1;
567 /* -dA causes debug commentary information to be produced in
568 the generated assembly code (to make it more readable). This option
569 is generally only of use to those who actually need to read the
570 generated assembly code (perhaps while debugging the compiler itself).
571 Currently, this switch is only used by dwarfout.c; however, it is intended
572 to be a catchall for printing debug information in the assembler file. */
574 int flag_debug_asm = 0;
576 /* -fgnu-linker specifies use of the GNU linker for initializations.
577 (Or, more generally, a linker that handles initializations.)
578 -fno-gnu-linker says that collect2 will be used. */
580 int flag_gnu_linker = 0;
582 int flag_gnu_linker = 1;
585 /* Tag all structures with __attribute__(packed) */
586 int flag_pack_struct = 0;
588 /* Table of language-independent -f options.
589 STRING is the option name. VARIABLE is the address of the variable.
590 ON_VALUE is the value to store in VARIABLE
591 if `-fSTRING' is seen as an option.
592 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
594 struct { char *string; int *variable; int on_value;} f_options[] =
596 {"float-store", &flag_float_store, 1},
597 {"volatile", &flag_volatile, 1},
598 {"volatile-global", &flag_volatile_global, 1},
599 {"defer-pop", &flag_defer_pop, 1},
600 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
601 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
602 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
603 {"expensive-optimizations", &flag_expensive_optimizations, 1},
604 {"thread-jumps", &flag_thread_jumps, 1},
605 {"strength-reduce", &flag_strength_reduce, 1},
606 {"unroll-loops", &flag_unroll_loops, 1},
607 {"unroll-all-loops", &flag_unroll_all_loops, 1},
608 {"writable-strings", &flag_writable_strings, 1},
609 {"peephole", &flag_no_peephole, 0},
610 {"force-mem", &flag_force_mem, 1},
611 {"force-addr", &flag_force_addr, 1},
612 {"function-cse", &flag_no_function_cse, 0},
613 {"inline-functions", &flag_inline_functions, 1},
614 {"keep-inline-functions", &flag_keep_inline_functions, 1},
615 {"inline", &flag_no_inline, 0},
616 {"keep-static-consts", &flag_keep_static_consts, 1},
617 {"syntax-only", &flag_syntax_only, 1},
618 {"shared-data", &flag_shared_data, 1},
619 {"caller-saves", &flag_caller_saves, 1},
620 {"pcc-struct-return", &flag_pcc_struct_return, 1},
621 {"reg-struct-return", &flag_pcc_struct_return, 0},
622 {"delayed-branch", &flag_delayed_branch, 1},
623 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
624 {"pretend-float", &flag_pretend_float, 1},
625 {"schedule-insns", &flag_schedule_insns, 1},
626 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
627 {"pic", &flag_pic, 1},
628 {"PIC", &flag_pic, 2},
629 {"exceptions", &flag_exceptions, 1},
630 {"fast-math", &flag_fast_math, 1},
631 {"common", &flag_no_common, 0},
632 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
633 {"function-sections", &flag_function_sections, 1},
634 {"verbose-asm", &flag_verbose_asm, 1},
635 {"gnu-linker", &flag_gnu_linker, 1},
636 {"pack-struct", &flag_pack_struct, 1},
637 {"bytecode", &output_bytecode, 1}
640 /* Table of language-specific options. */
642 char *lang_options[] =
645 "-fallow-single-precision",
647 "-fsigned-bitfields",
648 "-funsigned-bitfields",
649 "-fno-signed-bitfields",
650 "-fno-unsigned-bitfields",
654 "-fno-unsigned-char",
670 "-fno-cond-mismatch",
671 "-fdollars-in-identifiers",
672 "-fno-dollars-in-identifiers",
681 "-Wbad-function-cast",
682 "-Wno-bad-function-cast",
686 "-Wno-char-subscripts",
702 "-Wno-missing-braces",
703 "-Wmissing-declarations",
704 "-Wno-missing-declarations",
705 "-Wmissing-prototypes",
706 "-Wno-missing-prototypes",
708 "-Wno-nested-externs",
712 "-Wno-pointer-arith",
714 "-Wno-redundant-decls",
717 "-Wstrict-prototypes",
718 "-Wno-strict-prototypes",
724 "-Wno-write-strings",
726 /* these are for obj c */
742 /* Options controlling warnings */
744 /* Don't print warning messages. -w. */
746 int inhibit_warnings = 0;
748 /* Print various extra warnings. -W. */
750 int extra_warnings = 0;
752 /* Treat warnings as errors. -Werror. */
754 int warnings_are_errors = 0;
756 /* Nonzero to warn about unused local variables. */
760 /* Nonzero to warn about variables used before they are initialized. */
762 int warn_uninitialized;
764 /* Nonzero means warn about all declarations which shadow others. */
768 /* Warn if a switch on an enum fails to have a case for every enum value. */
772 /* Nonzero means warn about function definitions that default the return type
773 or that use a null return and have a return-type other than void. */
775 int warn_return_type;
777 /* Nonzero means warn about pointer casts that increase the required
778 alignment of the target type (and might therefore lead to a crash
779 due to a misaligned access). */
783 /* Nonzero means warn about any identifiers that match in the first N
784 characters. The value N is in `id_clash_len'. */
787 unsigned id_clash_len;
789 /* Nonzero means warn about any objects definitions whose size is larger
790 than N bytes. Also want about function definitions whose returned
791 values are larger than N bytes. The value N is in `larger_than_size'. */
793 int warn_larger_than;
794 unsigned larger_than_size;
796 /* Nonzero means warn if inline function is too large. */
800 /* Warn if a function returns an aggregate,
801 since there are often incompatible calling conventions for doing this. */
803 int warn_aggregate_return;
805 /* Likewise for -W. */
807 struct { char *string; int *variable; int on_value;} W_options[] =
809 {"unused", &warn_unused, 1},
810 {"error", &warnings_are_errors, 1},
811 {"shadow", &warn_shadow, 1},
812 {"switch", &warn_switch, 1},
813 {"aggregate-return", &warn_aggregate_return, 1},
814 {"cast-align", &warn_cast_align, 1},
815 {"uninitialized", &warn_uninitialized, 1},
816 {"inline", &warn_inline, 1}
819 /* Output files for assembler code (real compiler output)
820 and debugging dumps. */
825 FILE *jump_opt_dump_file;
827 FILE *loop_dump_file;
828 FILE *cse2_dump_file;
829 FILE *flow_dump_file;
830 FILE *combine_dump_file;
831 FILE *sched_dump_file;
832 FILE *local_reg_dump_file;
833 FILE *global_reg_dump_file;
834 FILE *sched2_dump_file;
835 FILE *jump2_opt_dump_file;
836 FILE *dbr_sched_dump_file;
837 FILE *stack_reg_dump_file;
839 /* Time accumulators, to count the total time spent in various passes. */
843 int integration_time;
851 int local_alloc_time;
852 int global_alloc_time;
855 int shorten_branch_time;
861 /* Return time used so far, in microseconds. */
871 struct rusage rusage;
876 int proc_system_time;
878 int child_system_time;
890 return (clock() * 1000);
891 #else /* not _WIN32 */
894 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
897 getrusage (0, &rusage);
898 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
899 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
902 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
908 #define TIMEVAR(VAR, BODY) \
909 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
912 print_time (str, total)
917 "time in %s: %d.%06d\n",
918 str, total / 1000000, total % 1000000);
921 /* Count an error or warning. Return 1 if the message should be printed. */
924 count_error (warningp)
927 if (warningp && inhibit_warnings)
930 if (warningp && !warnings_are_errors)
934 static int warning_message = 0;
936 if (warningp && !warning_message)
938 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
947 /* Print a fatal error message. NAME is the text.
948 Also include a system error message based on `errno'. */
951 pfatal_with_name (name)
954 fprintf (stderr, "%s: ", progname);
956 exit (FATAL_EXIT_CODE);
960 fatal_io_error (name)
963 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
964 exit (FATAL_EXIT_CODE);
967 /* Called to give a better error message for a bad insn rather than
968 just calling abort(). */
971 fatal_insn (message, insn)
975 if (!output_bytecode)
981 fflush (asm_out_file);
983 fflush (aux_info_file);
985 fflush (rtl_dump_file);
986 if (jump_opt_dump_file)
987 fflush (jump_opt_dump_file);
989 fflush (cse_dump_file);
991 fflush (loop_dump_file);
993 fflush (cse2_dump_file);
995 fflush (flow_dump_file);
996 if (combine_dump_file)
997 fflush (combine_dump_file);
999 fflush (sched_dump_file);
1000 if (local_reg_dump_file)
1001 fflush (local_reg_dump_file);
1002 if (global_reg_dump_file)
1003 fflush (global_reg_dump_file);
1004 if (sched2_dump_file)
1005 fflush (sched2_dump_file);
1006 if (jump2_opt_dump_file)
1007 fflush (jump2_opt_dump_file);
1008 if (dbr_sched_dump_file)
1009 fflush (dbr_sched_dump_file);
1010 if (stack_reg_dump_file)
1011 fflush (stack_reg_dump_file);
1017 /* Called to give a better error message when we don't have an insn to match
1018 what we are looking for or if the insn's constraints aren't satisfied,
1019 rather than just calling abort(). */
1022 fatal_insn_not_found (insn)
1025 if (INSN_CODE (insn) < 0)
1026 fatal_insn ("internal error--unrecognizable insn:", insn);
1028 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1031 /* This is the default decl_printable_name function. */
1034 decl_name (decl, kind)
1038 return IDENTIFIER_POINTER (DECL_NAME (decl));
1041 static int need_error_newline;
1043 /* Function of last error message;
1044 more generally, function such that if next error message is in it
1045 then we don't have to mention the function name. */
1046 static tree last_error_function = NULL;
1048 /* Used to detect when input_file_stack has changed since last described. */
1049 static int last_error_tick;
1051 /* Called when the start of a function definition is parsed,
1052 this function prints on stderr the name of the function. */
1055 announce_function (decl)
1061 if (rtl_dump_and_exit)
1062 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1064 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
1066 need_error_newline = 1;
1067 last_error_function = current_function_decl;
1071 /* The default function to print out name of current function that caused
1075 default_print_error_function (file)
1078 if (last_error_function != current_function_decl)
1080 char *kind = "function";
1081 if (current_function_decl != 0
1082 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1086 fprintf (stderr, "%s: ", file);
1088 if (current_function_decl == NULL)
1089 fprintf (stderr, "At top level:\n");
1092 char *name = (*decl_printable_name) (current_function_decl, &kind);
1093 fprintf (stderr, "In %s `%s':\n", kind, name);
1096 last_error_function = current_function_decl;
1100 /* Called by report_error_function to print out function name.
1101 * Default may be overridden by language front-ends. */
1103 void (*print_error_function) PROTO((char *)) = default_print_error_function;
1105 /* Prints out, if necessary, the name of the current function
1106 that caused an error. Called from all error and warning functions. */
1109 report_error_function (file)
1112 struct file_stack *p;
1114 if (need_error_newline)
1116 fprintf (stderr, "\n");
1117 need_error_newline = 0;
1120 (*print_error_function) (file);
1122 if (input_file_stack && input_file_stack->next != 0
1123 && input_file_stack_tick != last_error_tick
1124 && file == input_filename)
1126 fprintf (stderr, "In file included");
1127 for (p = input_file_stack->next; p; p = p->next)
1129 fprintf (stderr, " from %s:%d", p->name, p->line);
1131 fprintf (stderr, ",\n ");
1133 fprintf (stderr, ":\n");
1134 last_error_tick = input_file_stack_tick;
1138 /* Print a message. */
1141 vmessage (prefix, s, ap)
1147 fprintf (stderr, "%s: ", prefix);
1150 vfprintf (stderr, s, ap);
1153 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1154 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1155 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1156 HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT);
1157 fprintf (stderr, s, v1, v2, v3, v4);
1162 /* Print a message relevant to line LINE of file FILE. */
1165 v_message_with_file_and_line (file, line, prefix, s, ap)
1173 fprintf (stderr, "%s:%d: ", file, line);
1175 fprintf (stderr, "%s: ", progname);
1177 vmessage (prefix, s, ap);
1178 fputc ('\n', stderr);
1181 /* Print a message relevant to the given DECL. */
1184 v_message_with_decl (decl, prefix, s, ap)
1192 fprintf (stderr, "%s:%d: ",
1193 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1196 fprintf (stderr, "%s: ", prefix);
1198 /* Do magic to get around lack of varargs support for insertion
1199 of arguments into existing list. We know that the decl is first;
1200 we ass_u_me that it will be printed with "%s". */
1202 for (p = s; *p; ++p)
1206 if (*(p + 1) == '%')
1213 if (p > s) /* Print the left-hand substring. */
1215 char fmt[sizeof "%.255s"];
1218 if (width > 255L) width = 255L; /* arbitrary */
1219 sprintf (fmt, "%%.%lds", width);
1220 fprintf (stderr, fmt, s);
1223 if (*p == '%') /* Print the name. */
1225 char *n = (DECL_NAME (decl)
1226 ? (*decl_printable_name) (decl, &junk)
1232 if (isalpha (*(p - 1) & 0xFF))
1237 if (*p) /* Print the rest of the message. */
1238 vmessage ((char *)NULL, p, ap);
1240 fputc ('\n', stderr);
1243 /* Figure file and line of the given INSN. */
1246 file_and_line_for_asm (insn, pfile, pline)
1251 rtx body = PATTERN (insn);
1254 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1255 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1256 asmop = SET_SRC (body);
1257 else if (GET_CODE (body) == ASM_OPERANDS)
1259 else if (GET_CODE (body) == PARALLEL
1260 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1261 asmop = SET_SRC (XVECEXP (body, 0, 0));
1262 else if (GET_CODE (body) == PARALLEL
1263 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1264 asmop = XVECEXP (body, 0, 0);
1270 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1271 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1275 *pfile = input_filename;
1280 /* Report an error at line LINE of file FILE. */
1283 v_error_with_file_and_line (file, line, s, ap)
1290 report_error_function (file);
1291 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1295 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1307 file = va_arg (ap, char *);
1308 line = va_arg (ap, int);
1309 s = va_arg (ap, char *);
1312 v_error_with_file_and_line (file, line, s, ap);
1316 /* Report an error at the declaration DECL.
1317 S is a format string which uses %s to substitute the declaration
1318 name; subsequent substitutions are a la printf. */
1321 v_error_with_decl (decl, s, ap)
1327 report_error_function (DECL_SOURCE_FILE (decl));
1328 v_message_with_decl (decl, (char *)NULL, s, ap);
1332 error_with_decl VPROTO((tree decl, char *s, ...))
1343 decl = va_arg (ap, tree);
1344 s = va_arg (ap, char *);
1347 v_error_with_decl (decl, s, ap);
1351 /* Report an error at the line number of the insn INSN.
1352 This is used only when INSN is an `asm' with operands,
1353 and each ASM_OPERANDS records its own source file and line. */
1356 v_error_for_asm (insn, s, ap)
1365 file_and_line_for_asm (insn, &file, &line);
1366 report_error_function (file);
1367 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1371 error_for_asm VPROTO((rtx insn, char *s, ...))
1382 insn = va_arg (ap, rtx);
1383 s = va_arg (ap, char *);
1386 v_error_for_asm (insn, s, ap);
1390 /* Report an error at the current line number. */
1397 v_error_with_file_and_line (input_filename, lineno, s, ap);
1401 error VPROTO((char *s, ...))
1411 s = va_arg (ap, char *);
1418 /* Report a fatal error at the current line number. */
1426 exit (FATAL_EXIT_CODE);
1430 fatal VPROTO((char *s, ...))
1440 s = va_arg (ap, char *);
1447 /* Report a warning at line LINE of file FILE. */
1450 v_warning_with_file_and_line (file, line, s, ap)
1456 if (count_error (1))
1458 report_error_function (file);
1459 v_message_with_file_and_line (file, line, "warning", s, ap);
1464 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1476 file = va_arg (ap, char *);
1477 line = va_arg (ap, int);
1478 s = va_arg (ap, char *);
1481 v_warning_with_file_and_line (file, line, s, ap);
1485 /* Report a warning at the declaration DECL.
1486 S is a format string which uses %s to substitute the declaration
1487 name; subsequent substitutions are a la printf. */
1490 v_warning_with_decl (decl, s, ap)
1495 if (count_error (1))
1497 report_error_function (DECL_SOURCE_FILE (decl));
1498 v_message_with_decl (decl, "warning", s, ap);
1503 warning_with_decl VPROTO((tree decl, char *s, ...))
1514 decl = va_arg (ap, tree);
1515 s = va_arg (ap, char *);
1518 v_warning_with_decl (decl, s, ap);
1522 /* Report a warning at the line number of the insn INSN.
1523 This is used only when INSN is an `asm' with operands,
1524 and each ASM_OPERANDS records its own source file and line. */
1527 v_warning_for_asm (insn, s, ap)
1532 if (count_error (1))
1537 file_and_line_for_asm (insn, &file, &line);
1538 report_error_function (file);
1539 v_message_with_file_and_line (file, line, "warning", s, ap);
1544 warning_for_asm VPROTO((rtx insn, char *s, ...))
1555 insn = va_arg (ap, rtx);
1556 s = va_arg (ap, char *);
1559 v_warning_for_asm (insn, s, ap);
1563 /* Report a warning at the current line number. */
1570 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1574 warning VPROTO((char *s, ...))
1584 s = va_arg (ap, char *);
1591 /* These functions issue either warnings or errors depending on
1592 -pedantic-errors. */
1599 if (flag_pedantic_errors)
1606 pedwarn VPROTO((char *s, ...))
1616 s = va_arg (ap, char *);
1624 v_pedwarn_with_decl (decl, s, ap)
1629 /* We don't want -pedantic-errors to cause the compilation to fail from
1630 "errors" in system header files. Sometimes fixincludes can't fix what's
1631 broken (eg: unsigned char bitfields - fixing it may change the alignment
1632 which will cause programs to mysteriously fail because the C library
1633 or kernel uses the original layout). There's no point in issuing a
1634 warning either, it's just unnecessary noise. */
1636 if (! DECL_IN_SYSTEM_HEADER (decl))
1638 if (flag_pedantic_errors)
1639 v_error_with_decl (decl, s, ap);
1641 v_warning_with_decl (decl, s, ap);
1646 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1657 decl = va_arg (ap, tree);
1658 s = va_arg (ap, char *);
1661 v_pedwarn_with_decl (decl, s, ap);
1666 v_pedwarn_with_file_and_line (file, line, s, ap)
1672 if (flag_pedantic_errors)
1673 v_error_with_file_and_line (file, line, s, ap);
1675 v_warning_with_file_and_line (file, line, s, ap);
1679 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1691 file = va_arg (ap, char *);
1692 line = va_arg (ap, int);
1693 s = va_arg (ap, char *);
1696 v_pedwarn_with_file_and_line (file, line, s, ap);
1700 /* Apologize for not implementing some feature. */
1709 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1711 fprintf (stderr, "%s: ", progname);
1712 vmessage ("sorry, not implemented", s, ap);
1713 fputc ('\n', stderr);
1717 sorry VPROTO((char *s, ...))
1727 s = va_arg (ap, char *);
1734 /* Apologize for not implementing some feature, then quit. */
1737 v_really_sorry (s, ap)
1743 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1745 fprintf (stderr, "%s: ", progname);
1746 vmessage ("sorry, not implemented", s, ap);
1747 fatal (" (fatal)\n");
1751 really_sorry VPROTO((char *s, ...))
1761 s = va_arg (ap, char *);
1764 v_really_sorry (s, ap);
1768 /* More 'friendly' abort that prints the line and file.
1769 config.h can #define abort fancy_abort if you like that sort of thing.
1771 I don't think this is actually a good idea.
1772 Other sorts of crashes will look a certain way.
1773 It is a good thing if crashes from calling abort look the same way.
1779 fatal ("internal gcc abort");
1782 /* This calls abort and is used to avoid problems when abort if a macro.
1783 It is used when we need to pass the address of abort. */
1791 /* When `malloc.c' is compiled with `rcheck' defined,
1792 it calls this function to report clobberage. */
1800 /* Same as `malloc' but report error if no memory available. */
1806 register char *value = (char *) malloc (size);
1808 fatal ("virtual memory exhausted");
1812 /* Same as `realloc' but report error if no memory available. */
1815 xrealloc (ptr, size)
1819 char *result = (char *) realloc (ptr, size);
1821 fatal ("virtual memory exhausted");
1825 /* Same as `strdup' but report error if no memory available. */
1831 register char *result = (char *) malloc (strlen (s) + 1);
1834 fatal ("virtual memory exhausted");
1839 /* Return the logarithm of X, base 2, considering X unsigned,
1840 if X is a power of 2. Otherwise, returns -1.
1842 This should be used via the `exact_log2' macro. */
1846 register unsigned HOST_WIDE_INT x;
1848 register int log = 0;
1849 /* Test for 0 or a power of 2. */
1850 if (x == 0 || x != (x & -x))
1852 while ((x >>= 1) != 0)
1857 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1858 If X is 0, return -1.
1860 This should be used via the floor_log2 macro. */
1864 register unsigned HOST_WIDE_INT x;
1866 register int log = -1;
1874 jmp_buf float_handler;
1876 /* Specify where to longjmp to when a floating arithmetic error happens.
1877 If HANDLER is 0, it means don't handle the errors any more. */
1880 set_float_handler (handler)
1883 float_handled = (handler != 0);
1885 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1888 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1889 error happens, pushing the previous specification into OLD_HANDLER.
1890 Return an indication of whether there was a previous handler in effect. */
1893 push_float_handler (handler, old_handler)
1894 jmp_buf handler, old_handler;
1896 int was_handled = float_handled;
1900 bcopy ((char *) float_handler, (char *) old_handler,
1901 sizeof (float_handler));
1903 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1907 /* Restore the previous specification of whether and where to longjmp to
1908 when a floating arithmetic error happens. */
1911 pop_float_handler (handled, handler)
1915 float_handled = handled;
1917 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1920 /* Signals actually come here. */
1923 float_signal (signo)
1924 /* If this is missing, some compilers complain. */
1927 if (float_handled == 0)
1929 #if defined (USG) || defined (hpux)
1930 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1933 signal (SIGFPE, float_signal);
1934 longjmp (float_handler, 1);
1937 /* Handler for SIGPIPE. */
1941 /* If this is missing, some compilers complain. */
1944 fatal ("output pipe has been closed");
1947 /* Strip off a legitimate source ending from the input string NAME of
1948 length LEN. Rather than having to know the names used by all of
1949 our front ends, we strip off an ending of a period followed by one,
1950 two, or three characters. */
1953 strip_off_ending (name, len)
1957 if (len > 2 && name[len - 2] == '.')
1958 name[len - 2] = '\0';
1959 else if (len > 3 && name[len - 3] == '.')
1960 name[len - 3] = '\0';
1961 else if (len > 4 && name[len - 4] == '.')
1962 name[len - 4] = '\0';
1965 /* Output a quoted string. */
1968 output_quoted_string (asm_file, string)
1974 putc ('\"', asm_file);
1975 while ((c = *string++) != 0)
1977 if (c == '\"' || c == '\\')
1978 putc ('\\', asm_file);
1981 putc ('\"', asm_file);
1984 /* Output a file name in the form wanted by System V. */
1987 output_file_directive (asm_file, input_name)
1991 int len = strlen (input_name);
1992 char *na = input_name + len;
1994 /* NA gets INPUT_NAME sans directory names. */
1995 while (na > input_name)
2002 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2003 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2005 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2006 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2008 fprintf (asm_file, "\t.file\t");
2009 output_quoted_string (asm_file, na);
2010 fputc ('\n', asm_file);
2015 /* Routine to build language identifier for object file. */
2018 output_lang_identify (asm_out_file)
2021 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2022 char *s = (char *) alloca (len);
2023 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2024 ASM_OUTPUT_LABEL (asm_out_file, s);
2027 /* Routine to open a dump file. */
2030 open_dump_file (base_name, suffix)
2035 char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1);
2037 strcpy (dumpname, base_name);
2038 strcat (dumpname, suffix);
2039 f = fopen (dumpname, "w");
2041 pfatal_with_name (dumpname);
2045 /* Compile an entire file of output from cpp, named NAME.
2046 Write a file of assembly output and various debugging dumps. */
2055 int name_specified = name != 0;
2057 if (dump_base_name == 0)
2058 dump_base_name = name ? name : "gccdump";
2062 integration_time = 0;
2070 local_alloc_time = 0;
2071 global_alloc_time = 0;
2074 shorten_branch_time = 0;
2080 /* Open input file. */
2082 if (name == 0 || !strcmp (name, "-"))
2088 finput = fopen (name, "r");
2090 pfatal_with_name (name);
2092 #ifdef IO_BUFFER_SIZE
2093 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2096 /* Initialize data in various passes. */
2101 /* Some of these really don't need to be called when generating bytecode,
2102 but the options would have to be parsed first to know that. -bson */
2104 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2105 || debug_info_level == DINFO_LEVEL_VERBOSE);
2107 init_decl_processing ();
2115 if (flag_caller_saves)
2116 init_caller_save ();
2118 /* If auxiliary info generation is desired, open the output file.
2119 This goes in the same directory as the source file--unlike
2120 all the other output files. */
2121 if (flag_gen_aux_info)
2123 aux_info_file = fopen (aux_info_file_name, "w");
2124 if (aux_info_file == 0)
2125 pfatal_with_name (aux_info_file_name);
2128 /* If rtl dump desired, open the output file. */
2130 rtl_dump_file = open_dump_file (dump_base_name, ".rtl");
2132 /* If jump_opt dump desired, open the output file. */
2134 jump_opt_dump_file = open_dump_file (dump_base_name, ".jump");
2136 /* If cse dump desired, open the output file. */
2138 cse_dump_file = open_dump_file (dump_base_name, ".cse");
2140 /* If loop dump desired, open the output file. */
2142 loop_dump_file = open_dump_file (dump_base_name, ".loop");
2144 /* If cse2 dump desired, open the output file. */
2146 cse2_dump_file = open_dump_file (dump_base_name, ".cse2");
2148 /* If flow dump desired, open the output file. */
2150 flow_dump_file = open_dump_file (dump_base_name, ".flow");
2152 /* If combine dump desired, open the output file. */
2154 combine_dump_file = open_dump_file (dump_base_name, ".combine");
2156 /* If scheduling dump desired, open the output file. */
2158 sched_dump_file = open_dump_file (dump_base_name, ".sched");
2160 /* If local_reg dump desired, open the output file. */
2162 local_reg_dump_file = open_dump_file (dump_base_name, ".lreg");
2164 /* If global_reg dump desired, open the output file. */
2165 if (global_reg_dump)
2166 global_reg_dump_file = open_dump_file (dump_base_name, ".greg");
2168 /* If 2nd scheduling dump desired, open the output file. */
2170 sched2_dump_file = open_dump_file (dump_base_name, ".sched2");
2172 /* If jump2_opt dump desired, open the output file. */
2174 jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2");
2176 /* If dbr_sched dump desired, open the output file. */
2178 dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr");
2182 /* If stack_reg dump desired, open the output file. */
2184 stack_reg_dump_file = open_dump_file (dump_base_name, ".stack");
2188 /* Open assembler code output file. */
2190 if (! name_specified && asm_file_name == 0)
2191 asm_out_file = stdout;
2194 int len = strlen (dump_base_name);
2195 register char *dumpname = (char *) xmalloc (len + 6);
2196 strcpy (dumpname, dump_base_name);
2197 strip_off_ending (dumpname, len);
2198 strcat (dumpname, ".s");
2199 if (asm_file_name == 0)
2201 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2202 strcpy (asm_file_name, dumpname);
2204 if (!strcmp (asm_file_name, "-"))
2205 asm_out_file = stdout;
2207 asm_out_file = fopen (asm_file_name, "w");
2208 if (asm_out_file == 0)
2209 pfatal_with_name (asm_file_name);
2212 #ifdef IO_BUFFER_SIZE
2213 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2214 _IOFBF, IO_BUFFER_SIZE);
2217 input_filename = name;
2219 /* Put an entry on the input file stack for the main input file. */
2221 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2222 input_file_stack->next = 0;
2223 input_file_stack->name = input_filename;
2225 /* Perform language-specific initialization.
2226 This may set main_input_filename. */
2229 /* If the input doesn't start with a #line, use the input name
2230 as the official input file name. */
2231 if (main_input_filename == 0)
2232 main_input_filename = name;
2234 if (!output_bytecode)
2236 ASM_FILE_START (asm_out_file);
2238 #ifdef ASM_COMMENT_START
2239 if (flag_verbose_asm)
2241 /* Print the list of options in effect. */
2242 print_version (asm_out_file, ASM_COMMENT_START);
2243 print_switch_values (asm_out_file, 0, MAX_LINE,
2244 ASM_COMMENT_START, " ", "\n");
2245 /* Add a blank line here so it appears in assembler output but not
2247 fprintf (asm_out_file, "\n");
2252 /* Output something to inform GDB that this compilation was by GCC. Also
2253 serves to tell GDB file consists of bytecodes. */
2254 if (output_bytecode)
2255 fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
2258 #ifndef ASM_IDENTIFY_GCC
2259 fprintf (asm_out_file, "gcc2_compiled.:\n");
2261 ASM_IDENTIFY_GCC (asm_out_file);
2265 /* Output something to identify which front-end produced this file. */
2266 #ifdef ASM_IDENTIFY_LANGUAGE
2267 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2270 #ifndef ASM_OUTPUT_SECTION_NAME
2271 if (flag_function_sections)
2273 warning ("-ffunction-sections not supported for this target.");
2274 flag_function_sections = 0;
2278 if (flag_function_sections
2279 && (profile_flag || profile_block_flag))
2281 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2282 flag_function_sections = 0;
2285 if (flag_function_sections && write_symbols != NO_DEBUG)
2286 warning ("-ffunction-sections may affect debugging on some targets.");
2288 if (output_bytecode)
2290 if (profile_flag || profile_block_flag)
2291 error ("profiling not supported in bytecode compilation");
2295 /* ??? Note: There used to be a conditional here
2296 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2297 This was to guarantee separation between gcc_compiled. and
2298 the first function, for the sake of dbx on Suns.
2299 However, having the extra zero here confused the Emacs
2300 code for unexec, and might confuse other programs too.
2301 Therefore, I took out that change.
2302 In future versions we should find another way to solve
2303 that dbx problem. -- rms, 23 May 93. */
2305 /* Don't let the first function fall at the same address
2306 as gcc_compiled., if profiling. */
2307 if (profile_flag || profile_block_flag)
2308 assemble_zeros (UNITS_PER_WORD);
2311 /* If dbx symbol table desired, initialize writing it
2312 and output the predefined types. */
2313 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2314 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2315 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2318 #ifdef SDB_DEBUGGING_INFO
2319 if (write_symbols == SDB_DEBUG)
2320 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2323 #ifdef DWARF_DEBUGGING_INFO
2324 if (write_symbols == DWARF_DEBUG)
2325 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2327 #ifdef DWARF2_DEBUGGING_INFO
2328 if (write_symbols == DWARF2_DEBUG)
2329 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2332 /* Initialize yet another pass. */
2334 if (!output_bytecode)
2335 init_final (main_input_filename);
2337 start_time = get_run_time ();
2339 /* Call the parser, which parses the entire file
2340 (calling rest_of_compilation for each function). */
2342 if (yyparse () != 0)
2344 if (errorcount == 0)
2345 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2347 /* In case there were missing closebraces,
2348 get us back to the global binding level. */
2349 while (! global_bindings_p ())
2353 /* Compilation is now finished except for writing
2354 what's left of the symbol table output. */
2356 parse_time += get_run_time () - start_time;
2358 parse_time -= integration_time;
2359 parse_time -= varconst_time;
2361 globals = getdecls ();
2363 /* Really define vars that have had only a tentative definition.
2364 Really output inline functions that must actually be callable
2365 and have not been output so far. */
2368 int len = list_length (globals);
2369 tree *vec = (tree *) alloca (sizeof (tree) * len);
2374 /* Process the decls in reverse order--earliest first.
2375 Put them into VEC from back to front, then take out from front. */
2377 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2378 vec[len - i - 1] = decl;
2380 for (i = 0; i < len; i++)
2384 /* We're not deferring this any longer. */
2385 DECL_DEFER_OUTPUT (decl) = 0;
2387 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2388 && incomplete_decl_finalize_hook != 0)
2389 (*incomplete_decl_finalize_hook) (decl);
2392 /* Now emit any global variables or functions that we have been putting
2393 off. We need to loop in case one of the things emitted here
2394 references another one which comes earlier in the list. */
2398 for (i = 0; i < len; i++)
2402 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2405 /* Don't write out static consts, unless we still need them.
2407 We also keep static consts if not optimizing (for debugging),
2408 unless the user specified -fno-keep-static-consts.
2409 ??? They might be better written into the debug information.
2410 This is possible when using DWARF.
2412 A language processor that wants static constants to be always
2413 written out (even if it is not used) is responsible for
2414 calling rest_of_decl_compilation itself. E.g. the C front-end
2415 calls rest_of_decl_compilation from finish_decl.
2416 One motivation for this is that is conventional in some
2417 environments to write things like:
2418 static const char rcsid[] = "... version string ...";
2419 intending to force the string to be in the executable.
2421 A language processor that would prefer to have unneeded
2422 static constants "optimized away" would just defer writing
2423 them out until here. E.g. C++ does this, because static
2424 constants are often defined in header files.
2426 ??? A tempting alternative (for both C and C++) would be
2427 to force a constant to be written if and only if it is
2428 defined in a main file, as opposed to an include file. */
2430 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2431 && (! TREE_READONLY (decl)
2432 || TREE_PUBLIC (decl)
2433 || (!optimize && flag_keep_static_consts)
2434 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2437 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2440 if (TREE_CODE (decl) == FUNCTION_DECL
2441 && DECL_INITIAL (decl) != 0
2442 && DECL_SAVED_INSNS (decl) != 0
2443 && (flag_keep_inline_functions
2444 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2447 temporary_allocation ();
2448 output_inline_function (decl);
2449 permanent_allocation (1);
2454 /* Now that all possible functions have been output, we can dump
2455 the exception table. */
2457 if (exception_table_p ())
2458 output_exception_table ();
2460 for (i = 0; i < len; i++)
2464 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2465 && ! TREE_ASM_WRITTEN (decl))
2466 /* Cancel the RTL for this decl so that, if debugging info
2467 output for global variables is still to come,
2468 this one will be omitted. */
2469 DECL_RTL (decl) = NULL;
2471 /* Warn about any function
2472 declared static but not defined.
2473 We don't warn about variables,
2474 because many programs have static variables
2475 that exist only to get some text into the object file. */
2476 if (TREE_CODE (decl) == FUNCTION_DECL
2478 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2479 && DECL_INITIAL (decl) == 0
2480 && DECL_EXTERNAL (decl)
2481 && ! DECL_ARTIFICIAL (decl)
2482 && ! TREE_PUBLIC (decl))
2484 pedwarn_with_decl (decl,
2485 "`%s' declared `static' but never defined");
2486 /* This symbol is effectively an "extern" declaration now. */
2487 TREE_PUBLIC (decl) = 1;
2488 assemble_external (decl);
2491 /* Warn about static fns or vars defined but not used,
2492 but not about inline functions or static consts
2493 since defining those in header files is normal practice. */
2495 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2496 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2497 && ! DECL_IN_SYSTEM_HEADER (decl)
2498 && ! DECL_EXTERNAL (decl)
2499 && ! TREE_PUBLIC (decl)
2500 && ! TREE_USED (decl)
2501 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2502 /* The TREE_USED bit for file-scope decls
2503 is kept in the identifier, to handle multiple
2504 external decls in different scopes. */
2505 && ! TREE_USED (DECL_NAME (decl)))
2506 warning_with_decl (decl, "`%s' defined but not used");
2508 #ifdef SDB_DEBUGGING_INFO
2509 /* The COFF linker can move initialized global vars to the end.
2510 And that can screw up the symbol ordering.
2511 By putting the symbols in that order to begin with,
2512 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2513 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2514 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2515 && ! DECL_EXTERNAL (decl)
2516 && DECL_RTL (decl) != 0)
2517 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2519 /* Output COFF information for non-global
2520 file-scope initialized variables. */
2521 if (write_symbols == SDB_DEBUG
2522 && TREE_CODE (decl) == VAR_DECL
2523 && DECL_INITIAL (decl)
2524 && ! DECL_EXTERNAL (decl)
2525 && DECL_RTL (decl) != 0
2526 && GET_CODE (DECL_RTL (decl)) == MEM)
2527 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2528 #endif /* SDB_DEBUGGING_INFO */
2529 #ifdef DWARF_DEBUGGING_INFO
2530 /* Output DWARF information for file-scope tentative data object
2531 declarations, file-scope (extern) function declarations (which
2532 had no corresponding body) and file-scope tagged type declarations
2533 and definitions which have not yet been forced out. */
2535 if (write_symbols == DWARF_DEBUG
2536 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2537 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2539 #ifdef DWARF2_DEBUGGING_INFO
2540 /* Output DWARF2 information for file-scope tentative data object
2541 declarations, file-scope (extern) function declarations (which
2542 had no corresponding body) and file-scope tagged type declarations
2543 and definitions which have not yet been forced out. */
2545 if (write_symbols == DWARF2_DEBUG
2546 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2547 TIMEVAR (symout_time, dwarf2out_decl (decl));
2552 /* Write out any pending weak symbol declarations. */
2556 /* Do dbx symbols */
2557 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2558 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2559 TIMEVAR (symout_time,
2561 dbxout_finish (asm_out_file, main_input_filename);
2565 #ifdef DWARF_DEBUGGING_INFO
2566 if (write_symbols == DWARF_DEBUG)
2567 TIMEVAR (symout_time,
2573 #ifdef DWARF2_DEBUGGING_INFO
2574 if (write_symbols == DWARF2_DEBUG)
2575 TIMEVAR (symout_time,
2577 dwarf2out_finish ();
2581 /* Output some stuff at end of file if nec. */
2583 if (!output_bytecode)
2585 end_final (main_input_filename);
2588 ASM_FILE_END (asm_out_file);
2592 /* Language-specific end of compilation actions. */
2596 if (output_bytecode)
2597 bc_write_file (asm_out_file);
2599 /* Close the dump files. */
2601 if (flag_gen_aux_info)
2603 fclose (aux_info_file);
2605 unlink (aux_info_file_name);
2609 fclose (rtl_dump_file);
2612 fclose (jump_opt_dump_file);
2615 fclose (cse_dump_file);
2618 fclose (loop_dump_file);
2621 fclose (cse2_dump_file);
2624 fclose (flow_dump_file);
2628 dump_combine_total_stats (combine_dump_file);
2629 fclose (combine_dump_file);
2633 fclose (sched_dump_file);
2636 fclose (local_reg_dump_file);
2638 if (global_reg_dump)
2639 fclose (global_reg_dump_file);
2642 fclose (sched2_dump_file);
2645 fclose (jump2_opt_dump_file);
2648 fclose (dbr_sched_dump_file);
2652 fclose (stack_reg_dump_file);
2655 /* Close non-debugging input and output files. Take special care to note
2656 whether fclose returns an error, since the pages might still be on the
2657 buffer chain while the file is open. */
2660 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2661 fatal_io_error (asm_file_name);
2663 /* Print the times. */
2667 fprintf (stderr,"\n");
2668 print_time ("parse", parse_time);
2670 if (!output_bytecode)
2672 print_time ("integration", integration_time);
2673 print_time ("jump", jump_time);
2674 print_time ("cse", cse_time);
2675 print_time ("loop", loop_time);
2676 print_time ("cse2", cse2_time);
2677 print_time ("flow", flow_time);
2678 print_time ("combine", combine_time);
2679 print_time ("sched", sched_time);
2680 print_time ("local-alloc", local_alloc_time);
2681 print_time ("global-alloc", global_alloc_time);
2682 print_time ("sched2", sched2_time);
2683 print_time ("dbranch", dbr_sched_time);
2684 print_time ("shorten-branch", shorten_branch_time);
2685 print_time ("stack-reg", stack_reg_time);
2686 print_time ("final", final_time);
2687 print_time ("varconst", varconst_time);
2688 print_time ("symout", symout_time);
2689 print_time ("dump", dump_time);
2694 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2695 and TYPE_DECL nodes.
2697 This does nothing for local (non-static) variables.
2698 Otherwise, it sets up the RTL and outputs any assembler code
2699 (label definition, storage allocation and initialization).
2701 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2702 the assembler symbol name to be used. TOP_LEVEL is nonzero
2703 if this declaration is not within a function. */
2706 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2712 /* Declarations of variables, and of functions defined elsewhere. */
2714 /* The most obvious approach, to put an #ifndef around where
2715 this macro is used, doesn't work since it's inside a macro call. */
2716 #ifndef ASM_FINISH_DECLARE_OBJECT
2717 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2720 /* Forward declarations for nested functions are not "external",
2721 but we need to treat them as if they were. */
2722 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2723 || TREE_CODE (decl) == FUNCTION_DECL)
2724 TIMEVAR (varconst_time,
2726 make_decl_rtl (decl, asmspec, top_level);
2727 /* Initialized extern variable exists to be replaced
2728 with its value, or represents something that will be
2729 output in another file. */
2730 if (! (TREE_CODE (decl) == VAR_DECL
2731 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2732 && DECL_INITIAL (decl) != 0
2733 && DECL_INITIAL (decl) != error_mark_node))
2734 /* Don't output anything
2735 when a tentative file-scope definition is seen.
2736 But at end of compilation, do output code for them. */
2737 if (! (! at_end && top_level
2738 && (DECL_INITIAL (decl) == 0
2739 || DECL_INITIAL (decl) == error_mark_node)))
2740 assemble_variable (decl, top_level, at_end, 0);
2741 if (!output_bytecode
2742 && decl == last_assemble_variable_decl)
2744 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2748 else if (DECL_REGISTER (decl) && asmspec != 0)
2750 if (decode_reg_name (asmspec) >= 0)
2752 DECL_RTL (decl) = 0;
2753 make_decl_rtl (decl, asmspec, top_level);
2756 error ("invalid register name `%s' for register variable", asmspec);
2758 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2759 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2760 && TREE_CODE (decl) == TYPE_DECL)
2761 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2763 #ifdef SDB_DEBUGGING_INFO
2764 else if (write_symbols == SDB_DEBUG && top_level
2765 && TREE_CODE (decl) == TYPE_DECL)
2766 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2770 /* Called after finishing a record, union or enumeral type. */
2773 rest_of_type_compilation (type, toplev)
2777 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2778 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2779 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2781 #ifdef SDB_DEBUGGING_INFO
2782 if (write_symbols == SDB_DEBUG)
2783 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2787 /* This is called from finish_function (within yyparse)
2788 after each top-level definition is parsed.
2789 It is supposed to compile that function or variable
2790 and output the assembler code for it.
2791 After we return, the tree storage is freed. */
2794 rest_of_compilation (decl)
2798 int start_time = get_run_time ();
2800 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2801 to be restored after we finish compiling the function
2802 (for use when compiling inline calls to this function). */
2803 tree saved_block_tree = 0;
2804 /* Likewise, for DECL_ARGUMENTS. */
2805 tree saved_arguments = 0;
2808 if (output_bytecode)
2811 /* If we are reconsidering an inline function
2812 at the end of compilation, skip the stuff for making it inline. */
2814 if (DECL_SAVED_INSNS (decl) == 0)
2819 /* If requested, consider whether to make this function inline. */
2820 if (DECL_INLINE (decl) || flag_inline_functions)
2821 TIMEVAR (integration_time,
2823 lose = function_cannot_inline_p (decl);
2824 if (lose || ! optimize)
2826 if (warn_inline && DECL_INLINE (decl))
2827 warning_with_decl (decl, lose);
2828 DECL_ABSTRACT_ORIGIN (decl) = 0;
2829 /* Don't really compile an extern inline function.
2830 If we can't make it inline, pretend
2831 it was only declared. */
2832 if (DECL_EXTERNAL (decl))
2834 DECL_INITIAL (decl) = 0;
2835 goto exit_rest_of_compilation;
2839 /* ??? Note that this has the effect of making it look
2840 like "inline" was specified for a function if we choose
2841 to inline it. This isn't quite right, but it's
2842 probably not worth the trouble to fix. */
2843 inlineable = DECL_INLINE (decl) = 1;
2846 insns = get_insns ();
2848 /* Dump the rtl code if we are dumping rtl. */
2853 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2854 IDENTIFIER_POINTER (DECL_NAME (decl)));
2855 if (DECL_SAVED_INSNS (decl))
2856 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2857 print_rtl (rtl_dump_file, insns);
2858 fflush (rtl_dump_file);
2861 /* If function is inline, and we don't yet know whether to
2862 compile it by itself, defer decision till end of compilation.
2863 finish_compilation will call rest_of_compilation again
2864 for those functions that need to be output. Also defer those
2865 functions that we are supposed to defer. We cannot defer
2866 functions containing nested functions since the nested function
2867 data is in our non-saved obstack. */
2869 if (! current_function_contains_functions
2870 && (DECL_DEFER_OUTPUT (decl)
2871 || (DECL_INLINE (decl)
2872 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2873 && ! flag_keep_inline_functions)
2874 || DECL_EXTERNAL (decl)))))
2876 DECL_DEFER_OUTPUT (decl) = 1;
2878 /* If -Wreturn-type, we have to do a bit of compilation. */
2879 if (! warn_return_type)
2881 #ifdef DWARF_DEBUGGING_INFO
2882 /* Generate the DWARF info for the "abstract" instance
2883 of a function which we may later generate inlined and/or
2884 out-of-line instances of. */
2885 if (write_symbols == DWARF_DEBUG)
2887 set_decl_abstract_flags (decl, 1);
2888 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2889 set_decl_abstract_flags (decl, 0);
2892 #ifdef DWARF2_DEBUGGING_INFO
2893 /* Generate the DWARF2 info for the "abstract" instance
2894 of a function which we may later generate inlined and/or
2895 out-of-line instances of. */
2896 if (write_symbols == DWARF2_DEBUG)
2898 set_decl_abstract_flags (decl, 1);
2899 TIMEVAR (symout_time, dwarf2out_decl (decl));
2900 set_decl_abstract_flags (decl, 0);
2903 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2904 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
2905 goto exit_rest_of_compilation;
2909 /* If we have to compile the function now, save its rtl and subdecls
2910 so that its compilation will not affect what others get. */
2911 if (inlineable || DECL_DEFER_OUTPUT (decl))
2913 #ifdef DWARF_DEBUGGING_INFO
2914 /* Generate the DWARF info for the "abstract" instance of
2915 a function which we will generate an out-of-line instance
2916 of almost immediately (and which we may also later generate
2917 various inlined instances of). */
2918 if (write_symbols == DWARF_DEBUG)
2920 set_decl_abstract_flags (decl, 1);
2921 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2922 set_decl_abstract_flags (decl, 0);
2925 #ifdef DWARF2_DEBUGGING_INFO
2926 /* Generate the DWARF2 info for the "abstract" instance of
2927 a function which we will generate an out-of-line instance
2928 of almost immediately (and which we may also later generate
2929 various inlined instances of). */
2930 if (write_symbols == DWARF2_DEBUG)
2932 set_decl_abstract_flags (decl, 1);
2933 TIMEVAR (symout_time, dwarf2out_decl (decl));
2934 set_decl_abstract_flags (decl, 0);
2937 saved_block_tree = DECL_INITIAL (decl);
2938 saved_arguments = DECL_ARGUMENTS (decl);
2939 TIMEVAR (integration_time, save_for_inline_copying (decl));
2940 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
2943 /* If specified extern inline but we aren't inlining it, we are
2945 if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
2946 goto exit_rest_of_compilation;
2949 if (! DECL_DEFER_OUTPUT (decl))
2950 TREE_ASM_WRITTEN (decl) = 1;
2952 /* Now that integrate will no longer see our rtl, we need not distinguish
2953 between the return value of this function and the return value of called
2955 rtx_equal_function_value_matters = 0;
2957 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2958 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2960 goto exit_rest_of_compilation;
2963 /* Add an unwinder for exception handling, if needed.
2964 This must be done before we finalize PIC code. */
2968 /* If we are doing position-independent code generation, now
2969 is the time to output special prologues and epilogues.
2970 We do not want to do this earlier, because it just clutters
2971 up inline functions with meaningless insns. */
2976 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2977 Note that that may have been done above, in save_for_inline_copying.
2978 The call to resume_temporary_allocation near the end of this function
2979 goes back to the usual state of affairs. This must be done after
2980 we've built up any unwinders for exception handling, and done
2981 the FINALIZE_PIC work, if necessary. */
2983 rtl_in_current_obstack ();
2985 insns = get_insns ();
2987 /* Copy any shared structure that should not be shared. */
2989 unshare_all_rtl (insns);
2991 /* Instantiate all virtual registers. */
2993 instantiate_virtual_regs (current_function_decl, get_insns ());
2995 /* See if we have allocated stack slots that are not directly addressable.
2996 If so, scan all the insns and create explicit address computation
2997 for all references to such slots. */
2998 /* fixup_stack_slots (); */
3000 /* Find all the EH handlers. */
3001 find_exception_handler_labels ();
3003 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3004 are initialized and to compute whether control can drop off the end
3006 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3007 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3009 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3010 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3011 goto exit_rest_of_compilation;
3013 /* Dump rtl code after jump, if we are doing that. */
3018 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
3019 IDENTIFIER_POINTER (DECL_NAME (decl)));
3020 print_rtl (jump_opt_dump_file, insns);
3021 fflush (jump_opt_dump_file);
3024 /* Perform common subexpression elimination.
3025 Nonzero value from `cse_main' means that jumps were simplified
3026 and some code may now be unreachable, so do
3027 jump optimization again. */
3032 fprintf (cse_dump_file, "\n;; Function %s\n\n",
3033 IDENTIFIER_POINTER (DECL_NAME (decl)));
3038 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3040 if (flag_thread_jumps)
3041 /* Hacks by tiemann & kenner. */
3042 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3044 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3046 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
3048 if (tem || optimize > 1)
3049 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3052 /* Dump rtl code after cse, if we are doing that. */
3057 print_rtl (cse_dump_file, insns);
3058 fflush (cse_dump_file);
3064 fprintf (loop_dump_file, "\n;; Function %s\n\n",
3065 IDENTIFIER_POINTER (DECL_NAME (decl)));
3068 /* Move constant computations out of loops. */
3074 loop_optimize (insns, loop_dump_file);
3078 /* Dump rtl code after loop opt, if we are doing that. */
3083 print_rtl (loop_dump_file, insns);
3084 fflush (loop_dump_file);
3090 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
3091 IDENTIFIER_POINTER (DECL_NAME (decl)));
3094 if (optimize > 0 && flag_rerun_cse_after_loop)
3096 /* Running another jump optimization pass before the second
3097 cse pass sometimes simplifies the RTL enough to allow
3098 the second CSE pass to do a better job. Jump_optimize can change
3099 max_reg_num so we must rerun reg_scan afterwards.
3100 ??? Rework to not call reg_scan so often. */
3101 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3102 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3104 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3105 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3106 1, cse2_dump_file));
3108 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3111 if (optimize > 0 && flag_thread_jumps)
3113 /* This pass of jump threading straightens out code
3114 that was kinked by loop optimization. */
3115 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3116 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3118 /* Dump rtl code after cse, if we are doing that. */
3123 print_rtl (cse2_dump_file, insns);
3124 fflush (cse2_dump_file);
3127 /* We are no longer anticipating cse in this function, at least. */
3129 cse_not_expected = 1;
3131 /* Now we choose between stupid (pcc-like) register allocation
3132 (if we got the -noreg switch and not -opt)
3133 and smart register allocation. */
3135 if (optimize > 0) /* Stupid allocation probably won't work */
3136 obey_regdecls = 0; /* if optimizations being done. */
3140 /* Print function header into flow dump now
3141 because doing the flow analysis makes some of the dump. */
3146 fprintf (flow_dump_file, "\n;; Function %s\n\n",
3147 IDENTIFIER_POINTER (DECL_NAME (decl)));
3154 regclass (insns, max_reg_num ());
3155 stupid_life_analysis (insns, max_reg_num (),
3161 /* Do control and data flow analysis,
3162 and write some of the results to dump file. */
3164 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
3166 if (warn_uninitialized)
3168 uninitialized_vars_warning (DECL_INITIAL (decl));
3169 setjmp_args_warning ();
3173 /* Dump rtl after flow analysis. */
3178 print_rtl (flow_dump_file, insns);
3179 fflush (flow_dump_file);
3182 /* If -opt, try combining insns through substitution. */
3185 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3187 /* Dump rtl code after insn combination. */
3192 fprintf (combine_dump_file, "\n;; Function %s\n\n",
3193 IDENTIFIER_POINTER (DECL_NAME (decl)));
3194 dump_combine_stats (combine_dump_file);
3195 print_rtl (combine_dump_file, insns);
3196 fflush (combine_dump_file);
3199 /* Print function header into sched dump now
3200 because doing the sched analysis makes some of the dump. */
3205 fprintf (sched_dump_file, "\n;; Function %s\n\n",
3206 IDENTIFIER_POINTER (DECL_NAME (decl)));
3209 if (optimize > 0 && flag_schedule_insns)
3211 /* Do control and data sched analysis,
3212 and write some of the results to dump file. */
3214 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
3217 /* Dump rtl after instruction scheduling. */
3222 print_rtl (sched_dump_file, insns);
3223 fflush (sched_dump_file);
3226 /* Unless we did stupid register allocation,
3227 allocate pseudo-regs that are used only within 1 basic block. */
3230 TIMEVAR (local_alloc_time,
3232 regclass (insns, max_reg_num ());
3236 /* Dump rtl code after allocating regs within basic blocks. */
3241 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
3242 IDENTIFIER_POINTER (DECL_NAME (decl)));
3243 dump_flow_info (local_reg_dump_file);
3244 dump_local_alloc (local_reg_dump_file);
3245 print_rtl (local_reg_dump_file, insns);
3246 fflush (local_reg_dump_file);
3249 if (global_reg_dump)
3251 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
3252 IDENTIFIER_POINTER (DECL_NAME (decl))));
3254 /* Save the last label number used so far, so reorg can tell
3255 when it's safe to kill spill regs. */
3256 max_label_num_after_reload = max_label_num ();
3258 /* Unless we did stupid register allocation,
3259 allocate remaining pseudo-regs, then do the reload pass
3260 fixing up any insns that are invalid. */
3262 TIMEVAR (global_alloc_time,
3265 failure = global_alloc (global_reg_dump_file);
3267 failure = reload (insns, 0, global_reg_dump_file);
3270 if (global_reg_dump)
3273 dump_global_regs (global_reg_dump_file);
3274 print_rtl (global_reg_dump_file, insns);
3275 fflush (global_reg_dump_file);
3279 goto exit_rest_of_compilation;
3281 reload_completed = 1;
3283 /* On some machines, the prologue and epilogue code, or parts thereof,
3284 can be represented as RTL. Doing so lets us schedule insns between
3285 it and the rest of the code and also allows delayed branch
3286 scheduling to operate in the epilogue. */
3288 thread_prologue_and_epilogue_insns (insns);
3290 if (optimize > 0 && flag_schedule_insns_after_reload)
3295 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
3296 IDENTIFIER_POINTER (DECL_NAME (decl)));
3299 /* Do control and data sched analysis again,
3300 and write some more of the results to dump file. */
3302 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
3304 /* Dump rtl after post-reorder instruction scheduling. */
3309 print_rtl (sched2_dump_file, insns);
3310 fflush (sched2_dump_file);
3314 #ifdef LEAF_REGISTERS
3316 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3320 /* One more attempt to remove jumps to .+1
3321 left by dead-store-elimination.
3322 Also do cross-jumping this time
3323 and delete no-op move insns. */
3327 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3330 /* Dump rtl code after jump, if we are doing that. */
3335 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
3336 IDENTIFIER_POINTER (DECL_NAME (decl)));
3337 print_rtl (jump2_opt_dump_file, insns);
3338 fflush (jump2_opt_dump_file);
3341 /* If a machine dependent reorganization is needed, call it. */
3342 #ifdef MACHINE_DEPENDENT_REORG
3343 MACHINE_DEPENDENT_REORG (insns);
3346 /* If a scheduling pass for delayed branches is to be done,
3347 call the scheduling code. */
3350 if (optimize > 0 && flag_delayed_branch)
3352 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3357 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
3358 IDENTIFIER_POINTER (DECL_NAME (decl)));
3359 print_rtl (dbr_sched_dump_file, insns);
3360 fflush (dbr_sched_dump_file);
3366 /* Shorten branches. */
3367 TIMEVAR (shorten_branch_time,
3369 shorten_branches (get_insns ());
3373 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3378 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
3379 IDENTIFIER_POINTER (DECL_NAME (decl)));
3380 print_rtl (stack_reg_dump_file, insns);
3381 fflush (stack_reg_dump_file);
3386 /* Now turn the rtl into assembler code. */
3388 TIMEVAR (final_time,
3393 /* Get the function's name, as described by its RTL.
3394 This may be different from the DECL_NAME name used
3395 in the source file. */
3397 x = DECL_RTL (decl);
3398 if (GET_CODE (x) != MEM)
3401 if (GET_CODE (x) != SYMBOL_REF)
3403 fnname = XSTR (x, 0);
3405 assemble_start_function (decl, fnname);
3406 final_start_function (insns, asm_out_file, optimize);
3407 final (insns, asm_out_file, optimize, 0);
3408 final_end_function (insns, asm_out_file, optimize);
3409 assemble_end_function (decl, fnname);
3410 fflush (asm_out_file);
3413 /* Write DBX symbols if requested */
3415 /* Note that for those inline functions where we don't initially
3416 know for certain that we will be generating an out-of-line copy,
3417 the first invocation of this routine (rest_of_compilation) will
3418 skip over this code by doing a `goto exit_rest_of_compilation;'.
3419 Later on, finish_compilation will call rest_of_compilation again
3420 for those inline functions that need to have out-of-line copies
3421 generated. During that call, we *will* be routed past here. */
3423 #ifdef DBX_DEBUGGING_INFO
3424 if (write_symbols == DBX_DEBUG)
3425 TIMEVAR (symout_time, dbxout_function (decl));
3428 #ifdef DWARF_DEBUGGING_INFO
3429 if (write_symbols == DWARF_DEBUG)
3430 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3433 #ifdef DWARF2_DEBUGGING_INFO
3434 if (write_symbols == DWARF2_DEBUG)
3435 TIMEVAR (symout_time, dwarf2out_decl (decl));
3438 exit_rest_of_compilation:
3440 /* In case the function was not output,
3441 don't leave any temporary anonymous types
3442 queued up for sdb output. */
3443 #ifdef SDB_DEBUGGING_INFO
3444 if (write_symbols == SDB_DEBUG)
3445 sdbout_types (NULL_TREE);
3448 /* Put back the tree of subblocks and list of arguments
3449 from before we copied them.
3450 Code generation and the output of debugging info may have modified
3451 the copy, but the original is unchanged. */
3453 if (saved_block_tree != 0)
3455 DECL_INITIAL (decl) = saved_block_tree;
3456 DECL_ARGUMENTS (decl) = saved_arguments;
3457 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3460 reload_completed = 0;
3462 /* Clear out the insn_length contents now that they are no longer valid. */
3463 init_insn_lengths ();
3465 /* Clear out the real_constant_chain before some of the rtx's
3466 it runs through become garbage. */
3468 clear_const_double_mem ();
3470 /* Cancel the effect of rtl_in_current_obstack. */
3472 resume_temporary_allocation ();
3474 /* Show no temporary slots allocated. */
3478 /* The parsing time is all the time spent in yyparse
3479 *except* what is spent in this function. */
3481 parse_time -= get_run_time () - start_time;
3484 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3485 Exit code is 35 if can't open files, 34 if fatal error,
3486 33 if had nonfatal errors, else success. */
3489 main (argc, argv, envp)
3496 int flag_print_mem = 0;
3497 int version_flag = 0;
3500 /* save in case md file wants to emit args as a comment. */
3504 p = argv[0] + strlen (argv[0]);
3505 while (p != argv[0] && p[-1] != '/'
3506 #ifdef DIR_SEPARATOR
3507 && p[-1] != DIR_SEPARATOR
3514 /* Get rid of any avoidable limit on stack size. */
3518 /* Set the stack limit huge so that alloca does not fail. */
3519 getrlimit (RLIMIT_STACK, &rlim);
3520 rlim.rlim_cur = rlim.rlim_max;
3521 setrlimit (RLIMIT_STACK, &rlim);
3523 #endif /* RLIMIT_STACK */
3525 signal (SIGFPE, float_signal);
3528 signal (SIGPIPE, pipe_closed);
3531 decl_printable_name = decl_name;
3532 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3534 /* Initialize whether `char' is signed. */
3535 flag_signed_char = DEFAULT_SIGNED_CHAR;
3536 #ifdef DEFAULT_SHORT_ENUMS
3537 /* Initialize how much space enums occupy, by default. */
3538 flag_short_enums = DEFAULT_SHORT_ENUMS;
3541 /* Scan to see what optimization level has been specified. That will
3542 determine the default value of many flags. */
3543 for (i = 1; i < argc; i++)
3545 if (!strcmp (argv[i], "-O"))
3549 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3551 /* Handle -O2, -O3, -O69, ... */
3552 char *p = &argv[i][2];
3556 if (! (c >= '0' && c <= '9'))
3559 optimize = atoi (&argv[i][2]);
3563 obey_regdecls = (optimize == 0);
3573 flag_thread_jumps = 1;
3575 flag_delayed_branch = 1;
3577 #ifdef CAN_DEBUG_WITHOUT_FP
3578 flag_omit_frame_pointer = 1;
3584 flag_cse_follow_jumps = 1;
3585 flag_cse_skip_blocks = 1;
3586 flag_expensive_optimizations = 1;
3587 flag_strength_reduce = 1;
3588 flag_rerun_cse_after_loop = 1;
3589 flag_caller_saves = 1;
3591 #ifdef INSN_SCHEDULING
3592 flag_schedule_insns = 1;
3593 flag_schedule_insns_after_reload = 1;
3599 flag_inline_functions = 1;
3602 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
3605 set_target_switch ("");
3607 #ifdef OPTIMIZATION_OPTIONS
3608 /* Allow default optimizations to be specified on a per-machine basis. */
3609 OPTIMIZATION_OPTIONS (optimize);
3612 /* Initialize register usage now so switches may override. */
3615 for (i = 1; i < argc; i++)
3618 /* If this is a language-specific option,
3619 decode it in a language-specific way. */
3620 for (j = 0; lang_options[j] != 0; j++)
3621 if (!strncmp (argv[i], lang_options[j],
3622 strlen (lang_options[j])))
3624 if (lang_options[j] != 0)
3625 /* If the option is valid for *some* language,
3626 treat it as valid even if this language doesn't understand it. */
3627 lang_decode_option (argv[i]);
3628 else if (argv[i][0] == '-' && argv[i][1] != 0)
3630 register char *str = argv[i] + 1;
3635 set_target_switch (&str[1]);
3636 else if (!strcmp (str, "dumpbase"))
3638 dump_base_name = argv[++i];
3640 else if (str[0] == 'd')
3642 register char *p = &str[1];
3650 global_reg_dump = 1;
3656 cse_dump = 1, cse2_dump = 1;
3674 global_reg_dump = 1;
3692 flag_print_asm_name = 1;
3713 rtl_dump_and_exit = 1;
3720 else if (str[0] == 'f')
3722 register char *p = &str[1];
3725 /* Some kind of -f option.
3726 P's value is the option sans `-f'.
3727 Search for it in the table of options. */
3730 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3733 if (!strcmp (p, f_options[j].string))
3735 *f_options[j].variable = f_options[j].on_value;
3736 /* A goto here would be cleaner,
3737 but breaks the vax pcc. */
3740 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3741 && ! strcmp (p+3, f_options[j].string))
3743 *f_options[j].variable = ! f_options[j].on_value;
3750 else if (!strncmp (p, "fixed-", 6))
3751 fix_register (&p[6], 1, 1);
3752 else if (!strncmp (p, "call-used-", 10))
3753 fix_register (&p[10], 0, 1);
3754 else if (!strncmp (p, "call-saved-", 11))
3755 fix_register (&p[11], 0, 0);
3757 error ("Invalid option `%s'", argv[i]);
3759 else if (str[0] == 'O')
3761 register char *p = str+1;
3762 while (*p && *p >= '0' && *p <= '9')
3767 error ("Invalid option `%s'", argv[i]);
3769 else if (!strcmp (str, "pedantic"))
3771 else if (!strcmp (str, "pedantic-errors"))
3772 flag_pedantic_errors = pedantic = 1;
3773 else if (!strcmp (str, "quiet"))
3775 else if (!strcmp (str, "version"))
3777 else if (!strcmp (str, "w"))
3778 inhibit_warnings = 1;
3779 else if (!strcmp (str, "W"))
3782 /* We save the value of warn_uninitialized, since if they put
3783 -Wuninitialized on the command line, we need to generate a
3784 warning about not using it without also specifying -O. */
3785 if (warn_uninitialized != 1)
3786 warn_uninitialized = 2;
3788 else if (str[0] == 'W')
3790 register char *p = &str[1];
3793 /* Some kind of -W option.
3794 P's value is the option sans `-W'.
3795 Search for it in the table of options. */
3798 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3801 if (!strcmp (p, W_options[j].string))
3803 *W_options[j].variable = W_options[j].on_value;
3804 /* A goto here would be cleaner,
3805 but breaks the vax pcc. */
3808 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3809 && ! strcmp (p+3, W_options[j].string))
3811 *W_options[j].variable = ! W_options[j].on_value;
3818 else if (!strncmp (p, "id-clash-", 9))
3824 if (*endp >= '0' && *endp <= '9')
3828 error ("Invalid option `%s'", argv[i]);
3833 id_clash_len = atoi (str + 10);
3836 else if (!strncmp (p, "larger-than-", 12))
3838 char *endp = p + 12;
3842 if (*endp >= '0' && *endp <= '9')
3846 error ("Invalid option `%s'", argv[i]);
3847 goto larger_than_lose;
3850 warn_larger_than = 1;
3851 larger_than_size = atoi (str + 13);
3855 error ("Invalid option `%s'", argv[i]);
3857 else if (!strcmp (str, "p"))
3861 else if (!strcmp (str, "a"))
3863 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3864 warning ("`-a' option (basic block profile) not supported");
3866 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
3869 else if (!strcmp (str, "ax"))
3871 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3872 warning ("`-ax' option (jump profiling) not supported");
3874 profile_block_flag = (!profile_block_flag
3875 || profile_block_flag == 2) ? 2 : 3;
3878 else if (str[0] == 'g')
3882 /* A lot of code assumes write_symbols == NO_DEBUG if the
3883 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
3884 of what debugging type has been selected). This records the
3885 selected type. It is an error to specify more than one
3887 static enum debug_info_type selected_debug_type = NO_DEBUG;
3888 /* Non-zero if debugging format has been explicitly set.
3889 -g and -ggdb don't explicitly set the debugging format so
3890 -gdwarf -g3 is equivalent to -gdwarf3. */
3891 static int type_explicitly_set_p = 0;
3892 /* Table of supported debugging formats. */
3895 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
3896 constant expression, we use NO_DEBUG in its place. */
3897 enum debug_info_type debug_type;
3898 int use_extensions_p;
3899 } *da, debug_args[] = {
3900 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS },
3901 { "ggdb", NO_DEBUG, 1 },
3902 #ifdef DBX_DEBUGGING_INFO
3903 { "gstabs", DBX_DEBUG, 0 },
3904 { "gstabs+", DBX_DEBUG, 1 },
3906 #ifdef DWARF_DEBUGGING_INFO
3907 { "gdwarf", DWARF_DEBUG, 0 },
3908 { "gdwarf+", DWARF_DEBUG, 1 },
3910 #ifdef DWARF2_DEBUGGING_INFO
3911 { "gdwarf-2", DWARF2_DEBUG, 0 },
3913 #ifdef XCOFF_DEBUGGING_INFO
3914 { "gxcoff", XCOFF_DEBUG, 0 },
3915 { "gxcoff+", XCOFF_DEBUG, 1 },
3917 #ifdef SDB_DEBUGGING_INFO
3918 { "gcoff", SDB_DEBUG, 0 },
3922 /* Indexed by enum debug_info_type. */
3923 static char *debug_type_names[] = {
3924 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
3927 /* Look up STR in the table. */
3928 for (da = debug_args; da->arg; da++)
3930 if (! strncmp (str, da->arg, strlen (da->arg)))
3932 enum debug_info_type type = da->debug_type;
3935 p = str + strlen (da->arg);
3936 if (*p && (*p < '0' || *p > '9'))
3939 while (*q && (*q >= '0' && *q <= '9'))
3944 level = 2; /* default debugging info level */
3945 if (*q || level > 3)
3947 warning ("invalid debug level specification in option: `-%s'",
3949 /* ??? This error message is incorrect in the case of
3951 warning ("no debugging information will be generated");
3955 /* ??? A few targets use STR in the
3956 definition of PREFERRED_DEBUGGING_TYPE! */
3957 if (type == NO_DEBUG)
3958 type = PREFERRED_DEBUGGING_TYPE;
3960 if (type == NO_DEBUG)
3961 warning ("`-%s' not supported by this configuration of GCC",
3964 /* Does it conflict with an already selected type? */
3965 if (type_explicitly_set_p
3966 /* -g/-ggdb don't conflict with anything */
3967 && da->debug_type != NO_DEBUG
3968 && type != selected_debug_type)
3969 warning ("`-%s' ignored, conflicts with `-g%s'",
3970 str, debug_type_names[(int) selected_debug_type]);
3973 /* If the format has already been set, -g/-ggdb
3974 only change the debug level. */
3975 if (type_explicitly_set_p
3976 && da->debug_type == NO_DEBUG)
3977 ; /* don't change debugging type */
3980 selected_debug_type = type;
3981 type_explicitly_set_p = da->debug_type != NO_DEBUG;
3983 write_symbols = (level == 0
3985 : selected_debug_type);
3986 use_gnu_debug_info_extensions = da->use_extensions_p;
3987 debug_info_level = (enum debug_info_level) level;
3993 warning ("`-%s' not supported by this configuration of GCC",
3996 else if (!strcmp (str, "o"))
3998 asm_file_name = argv[++i];
4000 else if (str[0] == 'G')
4002 g_switch_set = TRUE;
4003 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
4005 else if (!strncmp (str, "aux-info", 8))
4007 flag_gen_aux_info = 1;
4008 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
4011 error ("Invalid option `%s'", argv[i]);
4013 else if (argv[i][0] == '+')
4014 error ("Invalid option `%s'", argv[i]);
4019 /* Initialize for bytecode output. A good idea to do this as soon as
4020 possible after the "-f" options have been parsed. */
4021 if (output_bytecode)
4023 #ifndef TARGET_SUPPORTS_BYTECODE
4024 /* Just die with a fatal error if not supported */
4025 fatal ("-fbytecode not supported for this target");
4033 /* Inlining does not work if not optimizing,
4034 so force it not to be done. */
4038 /* The c_decode_option and lang_decode_option functions set
4039 this to `2' if -Wall is used, so we can avoid giving out
4040 lots of errors for people who don't realize what -Wall does. */
4041 if (warn_uninitialized == 1)
4042 warning ("-Wuninitialized is not supported without -O");
4045 #ifdef OVERRIDE_OPTIONS
4046 /* Some machines may reject certain combinations of options. */
4050 if (profile_block_flag == 3)
4052 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4053 profile_block_flag = 2;
4056 /* Unrolling all loops implies that standard loop unrolling must also
4058 if (flag_unroll_all_loops)
4059 flag_unroll_loops = 1;
4060 /* Loop unrolling requires that strength_reduction be on also. Silently
4061 turn on strength reduction here if it isn't already on. Also, the loop
4062 unrolling code assumes that cse will be run after loop, so that must
4063 be turned on also. */
4064 if (flag_unroll_loops)
4066 flag_strength_reduce = 1;
4067 flag_rerun_cse_after_loop = 1;
4070 /* Warn about options that are not supported on this machine. */
4071 #ifndef INSN_SCHEDULING
4072 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4073 warning ("instruction scheduling not supported on this target machine");
4076 if (flag_delayed_branch)
4077 warning ("this target machine does not have delayed branches");
4080 /* If we are in verbose mode, write out the version and maybe all the
4081 option flags in use. */
4084 print_version (stderr, "");
4086 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4089 compile_file (filename);
4091 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4094 char *lim = (char *) sbrk (0);
4096 fprintf (stderr, "Data size %d.\n",
4097 lim - (char *) &environ);
4101 system ("ps -l 1>&2");
4104 #endif /* not USG */
4106 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4109 exit (FATAL_EXIT_CODE);
4111 exit (FATAL_EXIT_CODE);
4112 exit (SUCCESS_EXIT_CODE);
4116 /* Decode -m switches. */
4118 /* Here is a table, controlled by the tm.h file, listing each -m switch
4119 and which bits in `target_switches' it should set or clear.
4120 If VALUE is positive, it is bits to set.
4121 If VALUE is negative, -VALUE is bits to clear.
4122 (The sign bit is not used so there is no confusion.) */
4124 struct {char *name; int value;} target_switches []
4127 /* This table is similar, but allows the switch to have a value. */
4129 #ifdef TARGET_OPTIONS
4130 struct {char *prefix; char ** variable;} target_options []
4134 /* Decode the switch -mNAME. */
4137 set_target_switch (name)
4143 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4144 if (!strcmp (target_switches[j].name, name))
4146 if (target_switches[j].value < 0)
4147 target_flags &= ~-target_switches[j].value;
4149 target_flags |= target_switches[j].value;
4153 #ifdef TARGET_OPTIONS
4155 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4157 int len = strlen (target_options[j].prefix);
4158 if (!strncmp (target_options[j].prefix, name, len))
4160 *target_options[j].variable = name + len;
4167 error ("Invalid option `%s'", name);
4170 /* Print version information to FILE.
4171 Each line begins with INDENT (for the case where FILE is the
4172 assembler output file). */
4175 print_version (file, indent)
4179 fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4180 language_string, version_string);
4181 fprintf (file, " (%s)", TARGET_NAME);
4184 #define __VERSION__ "[unknown]"
4186 fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4188 fprintf (file, " compiled by CC.\n");
4192 /* Print an option value and return the adjusted position in the line.
4193 ??? We don't handle error returns from fprintf (disk full); presumably
4194 other code will catch a disk full though. */
4197 print_single_switch (file, pos, max, indent, sep, term, type, name)
4200 char *indent, *sep, *term, *type, *name;
4202 /* The ultrix fprintf returns 0 on success, so compute the result we want
4203 here since we need it for the following test. */
4204 int len = strlen (sep) + strlen (type) + strlen (name);
4209 fprintf (file, "%s", term);
4214 fprintf (file, "%s", indent);
4215 pos = strlen (indent);
4217 fprintf (file, "%s%s%s", sep, type, name);
4222 /* Print active target switches to FILE.
4223 POS is the current cursor position and MAX is the size of a "line".
4224 Each line begins with INDENT and ends with TERM.
4225 Each switch is separated from the next by SEP. */
4228 print_switch_values (file, pos, max, indent, sep, term)
4231 char *indent, *sep, *term;
4236 /* Print the options as passed. */
4238 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4239 "options passed: ", "");
4241 for (p = &save_argv[1]; *p != NULL; p++)
4245 if (strcmp (*p, "-o") == 0)
4251 if (strcmp (*p, "-quiet") == 0)
4253 if (strcmp (*p, "-version") == 0)
4258 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4261 fprintf (file, "%s", term);
4263 /* Print the -f and -m options that have been enabled.
4264 We don't handle language specific options but printing argv
4267 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4268 "options enabled: ", "");
4270 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4271 if (*f_options[j].variable == f_options[j].on_value)
4272 pos = print_single_switch (file, pos, max, indent, sep, term,
4273 "-f", f_options[j].string);
4275 /* Print target specific options. */
4277 flags = target_flags;
4278 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4279 if (target_switches[j].name[0] != '\0'
4280 && target_switches[j].value > 0
4281 && ((target_switches[j].value & target_flags)
4282 == target_switches[j].value))
4284 pos = print_single_switch (file, pos, max, indent, sep, term,
4285 "-m", target_switches[j].name);
4286 flags &= ~ target_switches[j].value;
4289 #ifdef TARGET_OPTIONS
4290 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4291 if (*target_options[j].variable != NULL)
4294 sprintf (prefix, "-m%s", target_options[j].prefix);
4295 pos = print_single_switch (file, pos, max, indent, sep, term,
4296 prefix, *target_options[j].variable);
4300 fprintf (file, "%s", term);
4303 /* Record the beginning of a new source file, named FILENAME. */
4306 debug_start_source_file (filename)
4307 register char *filename;
4309 #ifdef DBX_DEBUGGING_INFO
4310 if (write_symbols == DBX_DEBUG)
4311 dbxout_start_new_source_file (filename);
4313 #ifdef DWARF_DEBUGGING_INFO
4314 if (debug_info_level == DINFO_LEVEL_VERBOSE
4315 && write_symbols == DWARF_DEBUG)
4316 dwarfout_start_new_source_file (filename);
4317 #endif /* DWARF_DEBUGGING_INFO */
4318 #ifdef DWARF2_DEBUGGING_INFO
4319 if (debug_info_level == DINFO_LEVEL_VERBOSE
4320 && write_symbols == DWARF2_DEBUG)
4321 dwarf2out_start_source_file (filename);
4322 #endif /* DWARF2_DEBUGGING_INFO */
4323 #ifdef SDB_DEBUGGING_INFO
4324 if (write_symbols == SDB_DEBUG)
4325 sdbout_start_new_source_file (filename);
4329 /* Record the resumption of a source file. LINENO is the line number in
4330 the source file we are returning to. */
4333 debug_end_source_file (lineno)
4334 register unsigned lineno;
4336 #ifdef DBX_DEBUGGING_INFO
4337 if (write_symbols == DBX_DEBUG)
4338 dbxout_resume_previous_source_file ();
4340 #ifdef DWARF_DEBUGGING_INFO
4341 if (debug_info_level == DINFO_LEVEL_VERBOSE
4342 && write_symbols == DWARF_DEBUG)
4343 dwarfout_resume_previous_source_file (lineno);
4344 #endif /* DWARF_DEBUGGING_INFO */
4345 #ifdef DWARF2_DEBUGGING_INFO
4346 if (debug_info_level == DINFO_LEVEL_VERBOSE
4347 && write_symbols == DWARF2_DEBUG)
4348 dwarf2out_end_source_file ();
4349 #endif /* DWARF2_DEBUGGING_INFO */
4350 #ifdef SDB_DEBUGGING_INFO
4351 if (write_symbols == SDB_DEBUG)
4352 sdbout_resume_previous_source_file ();
4356 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4357 the tail part of the directive line, i.e. the part which is past the
4358 initial whitespace, #, whitespace, directive-name, whitespace part. */
4361 debug_define (lineno, buffer)
4362 register unsigned lineno;
4363 register char *buffer;
4365 #ifdef DWARF_DEBUGGING_INFO
4366 if (debug_info_level == DINFO_LEVEL_VERBOSE
4367 && write_symbols == DWARF_DEBUG)
4368 dwarfout_define (lineno, buffer);
4369 #endif /* DWARF_DEBUGGING_INFO */
4370 #ifdef DWARF2_DEBUGGING_INFO
4371 if (debug_info_level == DINFO_LEVEL_VERBOSE
4372 && write_symbols == DWARF2_DEBUG)
4373 dwarf2out_define (lineno, buffer);
4374 #endif /* DWARF2_DEBUGGING_INFO */
4377 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4378 the tail part of the directive line, i.e. the part which is past the
4379 initial whitespace, #, whitespace, directive-name, whitespace part. */
4382 debug_undef (lineno, buffer)
4383 register unsigned lineno;
4384 register char *buffer;
4386 #ifdef DWARF_DEBUGGING_INFO
4387 if (debug_info_level == DINFO_LEVEL_VERBOSE
4388 && write_symbols == DWARF_DEBUG)
4389 dwarfout_undef (lineno, buffer);
4390 #endif /* DWARF_DEBUGGING_INFO */
4391 #ifdef DWARF2_DEBUGGING_INFO
4392 if (debug_info_level == DINFO_LEVEL_VERBOSE
4393 && write_symbols == DWARF2_DEBUG)
4394 dwarf2out_undef (lineno, buffer);
4395 #endif /* DWARF2_DEBUGGING_INFO */