1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-5, 1996 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",
666 "-fno-cond-mismatch",
667 "-fdollars-in-identifiers",
668 "-fno-dollars-in-identifiers",
677 "-Wbad-function-cast",
678 "-Wno-bad-function-cast",
682 "-Wno-char-subscripts",
696 "-Wno-missing-braces",
697 "-Wmissing-declarations",
698 "-Wno-missing-declarations",
699 "-Wmissing-prototypes",
700 "-Wno-missing-prototypes",
702 "-Wno-nested-externs",
706 "-Wno-pointer-arith",
708 "-Wno-redundant-decls",
711 "-Wstrict-prototypes",
712 "-Wno-strict-prototypes",
718 "-Wno-write-strings",
720 /* these are for obj c */
736 /* Options controlling warnings */
738 /* Don't print warning messages. -w. */
740 int inhibit_warnings = 0;
742 /* Print various extra warnings. -W. */
744 int extra_warnings = 0;
746 /* Treat warnings as errors. -Werror. */
748 int warnings_are_errors = 0;
750 /* Nonzero to warn about unused local variables. */
754 /* Nonzero to warn about variables used before they are initialized. */
756 int warn_uninitialized;
758 /* Nonzero means warn about all declarations which shadow others. */
762 /* Warn if a switch on an enum fails to have a case for every enum value. */
766 /* Nonzero means warn about function definitions that default the return type
767 or that use a null return and have a return-type other than void. */
769 int warn_return_type;
771 /* Nonzero means warn about pointer casts that increase the required
772 alignment of the target type (and might therefore lead to a crash
773 due to a misaligned access). */
777 /* Nonzero means warn about any identifiers that match in the first N
778 characters. The value N is in `id_clash_len'. */
781 unsigned id_clash_len;
783 /* Nonzero means warn about any objects definitions whose size is larger
784 than N bytes. Also want about function definitions whose returned
785 values are larger than N bytes. The value N is in `larger_than_size'. */
787 int warn_larger_than;
788 unsigned larger_than_size;
790 /* Nonzero means warn if inline function is too large. */
794 /* Warn if a function returns an aggregate,
795 since there are often incompatible calling conventions for doing this. */
797 int warn_aggregate_return;
799 /* Likewise for -W. */
801 struct { char *string; int *variable; int on_value;} W_options[] =
803 {"unused", &warn_unused, 1},
804 {"error", &warnings_are_errors, 1},
805 {"shadow", &warn_shadow, 1},
806 {"switch", &warn_switch, 1},
807 {"aggregate-return", &warn_aggregate_return, 1},
808 {"cast-align", &warn_cast_align, 1},
809 {"uninitialized", &warn_uninitialized, 1},
810 {"inline", &warn_inline, 1}
813 /* Output files for assembler code (real compiler output)
814 and debugging dumps. */
819 FILE *jump_opt_dump_file;
821 FILE *loop_dump_file;
822 FILE *cse2_dump_file;
823 FILE *flow_dump_file;
824 FILE *combine_dump_file;
825 FILE *sched_dump_file;
826 FILE *local_reg_dump_file;
827 FILE *global_reg_dump_file;
828 FILE *sched2_dump_file;
829 FILE *jump2_opt_dump_file;
830 FILE *dbr_sched_dump_file;
831 FILE *stack_reg_dump_file;
833 /* Time accumulators, to count the total time spent in various passes. */
837 int integration_time;
845 int local_alloc_time;
846 int global_alloc_time;
849 int shorten_branch_time;
855 /* Return time used so far, in microseconds. */
865 struct rusage rusage;
870 int proc_system_time;
872 int child_system_time;
884 return (clock() * 1000);
885 #else /* not _WIN32 */
888 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
891 getrusage (0, &rusage);
892 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
893 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
896 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
902 #define TIMEVAR(VAR, BODY) \
903 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
906 print_time (str, total)
911 "time in %s: %d.%06d\n",
912 str, total / 1000000, total % 1000000);
915 /* Count an error or warning. Return 1 if the message should be printed. */
918 count_error (warningp)
921 if (warningp && inhibit_warnings)
924 if (warningp && !warnings_are_errors)
928 static int warning_message = 0;
930 if (warningp && !warning_message)
932 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
941 /* Print a fatal error message. NAME is the text.
942 Also include a system error message based on `errno'. */
945 pfatal_with_name (name)
948 fprintf (stderr, "%s: ", progname);
950 exit (FATAL_EXIT_CODE);
954 fatal_io_error (name)
957 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
958 exit (FATAL_EXIT_CODE);
961 /* Called to give a better error message for a bad insn rather than
962 just calling abort(). */
965 fatal_insn (message, insn)
969 if (!output_bytecode)
975 fflush (asm_out_file);
977 fflush (aux_info_file);
979 fflush (rtl_dump_file);
980 if (jump_opt_dump_file)
981 fflush (jump_opt_dump_file);
983 fflush (cse_dump_file);
985 fflush (loop_dump_file);
987 fflush (cse2_dump_file);
989 fflush (flow_dump_file);
990 if (combine_dump_file)
991 fflush (combine_dump_file);
993 fflush (sched_dump_file);
994 if (local_reg_dump_file)
995 fflush (local_reg_dump_file);
996 if (global_reg_dump_file)
997 fflush (global_reg_dump_file);
998 if (sched2_dump_file)
999 fflush (sched2_dump_file);
1000 if (jump2_opt_dump_file)
1001 fflush (jump2_opt_dump_file);
1002 if (dbr_sched_dump_file)
1003 fflush (dbr_sched_dump_file);
1004 if (stack_reg_dump_file)
1005 fflush (stack_reg_dump_file);
1011 /* Called to give a better error message when we don't have an insn to match
1012 what we are looking for or if the insn's constraints aren't satisfied,
1013 rather than just calling abort(). */
1016 fatal_insn_not_found (insn)
1019 if (INSN_CODE (insn) < 0)
1020 fatal_insn ("internal error--unrecognizable insn:", insn);
1022 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1025 /* This is the default decl_printable_name function. */
1028 decl_name (decl, kind)
1032 return IDENTIFIER_POINTER (DECL_NAME (decl));
1035 static int need_error_newline;
1037 /* Function of last error message;
1038 more generally, function such that if next error message is in it
1039 then we don't have to mention the function name. */
1040 static tree last_error_function = NULL;
1042 /* Used to detect when input_file_stack has changed since last described. */
1043 static int last_error_tick;
1045 /* Called when the start of a function definition is parsed,
1046 this function prints on stderr the name of the function. */
1049 announce_function (decl)
1055 if (rtl_dump_and_exit)
1056 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1058 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
1060 need_error_newline = 1;
1061 last_error_function = current_function_decl;
1065 /* The default function to print out name of current function that caused
1069 default_print_error_function (file)
1072 if (last_error_function != current_function_decl)
1074 char *kind = "function";
1075 if (current_function_decl != 0
1076 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1080 fprintf (stderr, "%s: ", file);
1082 if (current_function_decl == NULL)
1083 fprintf (stderr, "At top level:\n");
1086 char *name = (*decl_printable_name) (current_function_decl, &kind);
1087 fprintf (stderr, "In %s `%s':\n", kind, name);
1090 last_error_function = current_function_decl;
1094 /* Called by report_error_function to print out function name.
1095 * Default may be overridden by language front-ends. */
1097 void (*print_error_function) PROTO((char *)) = default_print_error_function;
1099 /* Prints out, if necessary, the name of the current function
1100 that caused an error. Called from all error and warning functions. */
1103 report_error_function (file)
1106 struct file_stack *p;
1108 if (need_error_newline)
1110 fprintf (stderr, "\n");
1111 need_error_newline = 0;
1114 (*print_error_function) (file);
1116 if (input_file_stack && input_file_stack->next != 0
1117 && input_file_stack_tick != last_error_tick
1118 && file == input_filename)
1120 fprintf (stderr, "In file included");
1121 for (p = input_file_stack->next; p; p = p->next)
1123 fprintf (stderr, " from %s:%d", p->name, p->line);
1125 fprintf (stderr, ",\n ");
1127 fprintf (stderr, ":\n");
1128 last_error_tick = input_file_stack_tick;
1132 /* Print a message. */
1135 vmessage (prefix, s, ap)
1141 fprintf (stderr, "%s: ", prefix);
1144 vfprintf (stderr, s, ap);
1147 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1148 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1149 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1150 HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT);
1151 fprintf (stderr, s, v1, v2, v3, v4);
1156 /* Print a message relevant to line LINE of file FILE. */
1159 v_message_with_file_and_line (file, line, prefix, s, ap)
1167 fprintf (stderr, "%s:%d: ", file, line);
1169 fprintf (stderr, "%s: ", progname);
1171 vmessage (prefix, s, ap);
1172 fputc ('\n', stderr);
1175 /* Print a message relevant to the given DECL. */
1178 v_message_with_decl (decl, prefix, s, ap)
1186 fprintf (stderr, "%s:%d: ",
1187 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1190 fprintf (stderr, "%s: ", prefix);
1192 /* Do magic to get around lack of varargs support for insertion
1193 of arguments into existing list. We know that the decl is first;
1194 we ass_u_me that it will be printed with "%s". */
1196 for (p = s; *p; ++p)
1200 if (*(p + 1) == '%')
1207 if (p > s) /* Print the left-hand substring. */
1209 char fmt[sizeof "%.255s"];
1212 if (width > 255L) width = 255L; /* arbitrary */
1213 sprintf (fmt, "%%.%lds", width);
1214 fprintf (stderr, fmt, s);
1217 if (*p == '%') /* Print the name. */
1219 char *n = (DECL_NAME (decl)
1220 ? (*decl_printable_name) (decl, &junk)
1226 if (isalpha (*(p - 1) & 0xFF))
1231 if (*p) /* Print the rest of the message. */
1232 vmessage ((char *)NULL, p, ap);
1234 fputc ('\n', stderr);
1237 /* Figure file and line of the given INSN. */
1240 file_and_line_for_asm (insn, pfile, pline)
1245 rtx body = PATTERN (insn);
1248 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1249 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1250 asmop = SET_SRC (body);
1251 else if (GET_CODE (body) == ASM_OPERANDS)
1253 else if (GET_CODE (body) == PARALLEL
1254 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1255 asmop = SET_SRC (XVECEXP (body, 0, 0));
1256 else if (GET_CODE (body) == PARALLEL
1257 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1258 asmop = XVECEXP (body, 0, 0);
1264 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1265 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1269 *pfile = input_filename;
1274 /* Report an error at line LINE of file FILE. */
1277 v_error_with_file_and_line (file, line, s, ap)
1284 report_error_function (file);
1285 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1289 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1301 file = va_arg (ap, char *);
1302 line = va_arg (ap, int);
1303 s = va_arg (ap, char *);
1306 v_error_with_file_and_line (file, line, s, ap);
1310 /* Report an error at the declaration DECL.
1311 S is a format string which uses %s to substitute the declaration
1312 name; subsequent substitutions are a la printf. */
1315 v_error_with_decl (decl, s, ap)
1321 report_error_function (DECL_SOURCE_FILE (decl));
1322 v_message_with_decl (decl, (char *)NULL, s, ap);
1326 error_with_decl VPROTO((tree decl, char *s, ...))
1337 decl = va_arg (ap, tree);
1338 s = va_arg (ap, char *);
1341 v_error_with_decl (decl, s, ap);
1345 /* Report an error at the line number of the insn INSN.
1346 This is used only when INSN is an `asm' with operands,
1347 and each ASM_OPERANDS records its own source file and line. */
1350 v_error_for_asm (insn, s, ap)
1359 file_and_line_for_asm (insn, &file, &line);
1360 report_error_function (file);
1361 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1365 error_for_asm VPROTO((rtx insn, char *s, ...))
1376 insn = va_arg (ap, rtx);
1377 s = va_arg (ap, char *);
1380 v_error_for_asm (insn, s, ap);
1384 /* Report an error at the current line number. */
1391 v_error_with_file_and_line (input_filename, lineno, s, ap);
1395 error VPROTO((char *s, ...))
1405 s = va_arg (ap, char *);
1412 /* Report a fatal error at the current line number. */
1420 exit (FATAL_EXIT_CODE);
1424 fatal VPROTO((char *s, ...))
1434 s = va_arg (ap, char *);
1441 /* Report a warning at line LINE of file FILE. */
1444 v_warning_with_file_and_line (file, line, s, ap)
1450 if (count_error (1))
1452 report_error_function (file);
1453 v_message_with_file_and_line (file, line, "warning", s, ap);
1458 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1470 file = va_arg (ap, char *);
1471 line = va_arg (ap, int);
1472 s = va_arg (ap, char *);
1475 v_warning_with_file_and_line (file, line, s, ap);
1479 /* Report a warning at the declaration DECL.
1480 S is a format string which uses %s to substitute the declaration
1481 name; subsequent substitutions are a la printf. */
1484 v_warning_with_decl (decl, s, ap)
1489 if (count_error (1))
1491 report_error_function (DECL_SOURCE_FILE (decl));
1492 v_message_with_decl (decl, "warning", s, ap);
1497 warning_with_decl VPROTO((tree decl, char *s, ...))
1508 decl = va_arg (ap, tree);
1509 s = va_arg (ap, char *);
1512 v_warning_with_decl (decl, s, ap);
1516 /* Report a warning at the line number of the insn INSN.
1517 This is used only when INSN is an `asm' with operands,
1518 and each ASM_OPERANDS records its own source file and line. */
1521 v_warning_for_asm (insn, s, ap)
1526 if (count_error (1))
1531 file_and_line_for_asm (insn, &file, &line);
1532 report_error_function (file);
1533 v_message_with_file_and_line (file, line, "warning", s, ap);
1538 warning_for_asm VPROTO((rtx insn, char *s, ...))
1549 insn = va_arg (ap, rtx);
1550 s = va_arg (ap, char *);
1553 v_warning_for_asm (insn, s, ap);
1557 /* Report a warning at the current line number. */
1564 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1568 warning VPROTO((char *s, ...))
1578 s = va_arg (ap, char *);
1585 /* These functions issue either warnings or errors depending on
1586 -pedantic-errors. */
1593 if (flag_pedantic_errors)
1600 pedwarn VPROTO((char *s, ...))
1610 s = va_arg (ap, char *);
1618 v_pedwarn_with_decl (decl, s, ap)
1623 /* We don't want -pedantic-errors to cause the compilation to fail from
1624 "errors" in system header files. Sometimes fixincludes can't fix what's
1625 broken (eg: unsigned char bitfields - fixing it may change the alignment
1626 which will cause programs to mysteriously fail because the C library
1627 or kernel uses the original layout). There's no point in issuing a
1628 warning either, it's just unnecessary noise. */
1630 if (! DECL_IN_SYSTEM_HEADER (decl))
1632 if (flag_pedantic_errors)
1633 v_error_with_decl (decl, s, ap);
1635 v_warning_with_decl (decl, s, ap);
1640 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1651 decl = va_arg (ap, tree);
1652 s = va_arg (ap, char *);
1655 v_pedwarn_with_decl (decl, s, ap);
1660 v_pedwarn_with_file_and_line (file, line, s, ap)
1666 if (flag_pedantic_errors)
1667 v_error_with_file_and_line (file, line, s, ap);
1669 v_warning_with_file_and_line (file, line, s, ap);
1673 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1685 file = va_arg (ap, char *);
1686 line = va_arg (ap, int);
1687 s = va_arg (ap, char *);
1690 v_pedwarn_with_file_and_line (file, line, s, ap);
1694 /* Apologize for not implementing some feature. */
1703 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1705 fprintf (stderr, "%s: ", progname);
1706 vmessage ("sorry, not implemented", s, ap);
1707 fputc ('\n', stderr);
1711 sorry VPROTO((char *s, ...))
1721 s = va_arg (ap, char *);
1728 /* Apologize for not implementing some feature, then quit. */
1731 v_really_sorry (s, ap)
1737 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1739 fprintf (stderr, "%s: ", progname);
1740 vmessage ("sorry, not implemented", s, ap);
1741 fatal (" (fatal)\n");
1745 really_sorry VPROTO((char *s, ...))
1755 s = va_arg (ap, char *);
1758 v_really_sorry (s, ap);
1762 /* More 'friendly' abort that prints the line and file.
1763 config.h can #define abort fancy_abort if you like that sort of thing.
1765 I don't think this is actually a good idea.
1766 Other sorts of crashes will look a certain way.
1767 It is a good thing if crashes from calling abort look the same way.
1773 fatal ("internal gcc abort");
1776 /* This calls abort and is used to avoid problems when abort if a macro.
1777 It is used when we need to pass the address of abort. */
1785 /* When `malloc.c' is compiled with `rcheck' defined,
1786 it calls this function to report clobberage. */
1794 /* Same as `malloc' but report error if no memory available. */
1800 register char *value = (char *) malloc (size);
1802 fatal ("virtual memory exhausted");
1806 /* Same as `realloc' but report error if no memory available. */
1809 xrealloc (ptr, size)
1813 char *result = (char *) realloc (ptr, size);
1815 fatal ("virtual memory exhausted");
1819 /* Same as `strdup' but report error if no memory available. */
1825 register char *result = (char *) malloc (strlen (s) + 1);
1828 fatal ("virtual memory exhausted");
1833 /* Return the logarithm of X, base 2, considering X unsigned,
1834 if X is a power of 2. Otherwise, returns -1.
1836 This should be used via the `exact_log2' macro. */
1840 register unsigned HOST_WIDE_INT x;
1842 register int log = 0;
1843 /* Test for 0 or a power of 2. */
1844 if (x == 0 || x != (x & -x))
1846 while ((x >>= 1) != 0)
1851 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1852 If X is 0, return -1.
1854 This should be used via the floor_log2 macro. */
1858 register unsigned HOST_WIDE_INT x;
1860 register int log = -1;
1868 jmp_buf float_handler;
1870 /* Specify where to longjmp to when a floating arithmetic error happens.
1871 If HANDLER is 0, it means don't handle the errors any more. */
1874 set_float_handler (handler)
1877 float_handled = (handler != 0);
1879 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1882 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1883 error happens, pushing the previous specification into OLD_HANDLER.
1884 Return an indication of whether there was a previous handler in effect. */
1887 push_float_handler (handler, old_handler)
1888 jmp_buf handler, old_handler;
1890 int was_handled = float_handled;
1894 bcopy ((char *) float_handler, (char *) old_handler,
1895 sizeof (float_handler));
1897 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1901 /* Restore the previous specification of whether and where to longjmp to
1902 when a floating arithmetic error happens. */
1905 pop_float_handler (handled, handler)
1909 float_handled = handled;
1911 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1914 /* Signals actually come here. */
1917 float_signal (signo)
1918 /* If this is missing, some compilers complain. */
1921 if (float_handled == 0)
1923 #if defined (USG) || defined (hpux)
1924 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1927 signal (SIGFPE, float_signal);
1928 longjmp (float_handler, 1);
1931 /* Handler for SIGPIPE. */
1935 /* If this is missing, some compilers complain. */
1938 fatal ("output pipe has been closed");
1941 /* Strip off a legitimate source ending from the input string NAME of
1942 length LEN. Rather than having to know the names used by all of
1943 our front ends, we strip off an ending of a period followed by one,
1944 two, or three characters. */
1947 strip_off_ending (name, len)
1951 if (len > 2 && name[len - 2] == '.')
1952 name[len - 2] = '\0';
1953 else if (len > 3 && name[len - 3] == '.')
1954 name[len - 3] = '\0';
1955 else if (len > 4 && name[len - 4] == '.')
1956 name[len - 4] = '\0';
1959 /* Output a quoted string. */
1962 output_quoted_string (asm_file, string)
1968 putc ('\"', asm_file);
1969 while ((c = *string++) != 0)
1971 if (c == '\"' || c == '\\')
1972 putc ('\\', asm_file);
1975 putc ('\"', asm_file);
1978 /* Output a file name in the form wanted by System V. */
1981 output_file_directive (asm_file, input_name)
1985 int len = strlen (input_name);
1986 char *na = input_name + len;
1988 /* NA gets INPUT_NAME sans directory names. */
1989 while (na > input_name)
1996 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1997 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1999 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2000 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2002 fprintf (asm_file, "\t.file\t");
2003 output_quoted_string (asm_file, na);
2004 fputc ('\n', asm_file);
2009 /* Routine to build language identifier for object file. */
2012 output_lang_identify (asm_out_file)
2015 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2016 char *s = (char *) alloca (len);
2017 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2018 ASM_OUTPUT_LABEL (asm_out_file, s);
2021 /* Routine to open a dump file. */
2024 open_dump_file (base_name, suffix)
2029 char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1);
2031 strcpy (dumpname, base_name);
2032 strcat (dumpname, suffix);
2033 f = fopen (dumpname, "w");
2035 pfatal_with_name (dumpname);
2039 /* Compile an entire file of output from cpp, named NAME.
2040 Write a file of assembly output and various debugging dumps. */
2049 int name_specified = name != 0;
2051 if (dump_base_name == 0)
2052 dump_base_name = name ? name : "gccdump";
2056 integration_time = 0;
2064 local_alloc_time = 0;
2065 global_alloc_time = 0;
2068 shorten_branch_time = 0;
2074 /* Open input file. */
2076 if (name == 0 || !strcmp (name, "-"))
2082 finput = fopen (name, "r");
2084 pfatal_with_name (name);
2086 #ifdef IO_BUFFER_SIZE
2087 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2090 /* Initialize data in various passes. */
2095 /* Some of these really don't need to be called when generating bytecode,
2096 but the options would have to be parsed first to know that. -bson */
2098 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2099 || debug_info_level == DINFO_LEVEL_VERBOSE);
2101 init_decl_processing ();
2109 if (flag_caller_saves)
2110 init_caller_save ();
2112 /* If auxiliary info generation is desired, open the output file.
2113 This goes in the same directory as the source file--unlike
2114 all the other output files. */
2115 if (flag_gen_aux_info)
2117 aux_info_file = fopen (aux_info_file_name, "w");
2118 if (aux_info_file == 0)
2119 pfatal_with_name (aux_info_file_name);
2122 /* If rtl dump desired, open the output file. */
2124 rtl_dump_file = open_dump_file (dump_base_name, ".rtl");
2126 /* If jump_opt dump desired, open the output file. */
2128 jump_opt_dump_file = open_dump_file (dump_base_name, ".jump");
2130 /* If cse dump desired, open the output file. */
2132 cse_dump_file = open_dump_file (dump_base_name, ".cse");
2134 /* If loop dump desired, open the output file. */
2136 loop_dump_file = open_dump_file (dump_base_name, ".loop");
2138 /* If cse2 dump desired, open the output file. */
2140 cse2_dump_file = open_dump_file (dump_base_name, ".cse2");
2142 /* If flow dump desired, open the output file. */
2144 flow_dump_file = open_dump_file (dump_base_name, ".flow");
2146 /* If combine dump desired, open the output file. */
2148 combine_dump_file = open_dump_file (dump_base_name, ".combine");
2150 /* If scheduling dump desired, open the output file. */
2152 sched_dump_file = open_dump_file (dump_base_name, ".sched");
2154 /* If local_reg dump desired, open the output file. */
2156 local_reg_dump_file = open_dump_file (dump_base_name, ".lreg");
2158 /* If global_reg dump desired, open the output file. */
2159 if (global_reg_dump)
2160 global_reg_dump_file = open_dump_file (dump_base_name, ".greg");
2162 /* If 2nd scheduling dump desired, open the output file. */
2164 sched2_dump_file = open_dump_file (dump_base_name, ".sched2");
2166 /* If jump2_opt dump desired, open the output file. */
2168 jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2");
2170 /* If dbr_sched dump desired, open the output file. */
2172 dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr");
2176 /* If stack_reg dump desired, open the output file. */
2178 stack_reg_dump_file = open_dump_file (dump_base_name, ".stack");
2182 /* Open assembler code output file. */
2184 if (! name_specified && asm_file_name == 0)
2185 asm_out_file = stdout;
2188 int len = strlen (dump_base_name);
2189 register char *dumpname = (char *) xmalloc (len + 6);
2190 strcpy (dumpname, dump_base_name);
2191 strip_off_ending (dumpname, len);
2192 strcat (dumpname, ".s");
2193 if (asm_file_name == 0)
2195 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2196 strcpy (asm_file_name, dumpname);
2198 if (!strcmp (asm_file_name, "-"))
2199 asm_out_file = stdout;
2201 asm_out_file = fopen (asm_file_name, "w");
2202 if (asm_out_file == 0)
2203 pfatal_with_name (asm_file_name);
2206 #ifdef IO_BUFFER_SIZE
2207 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2208 _IOFBF, IO_BUFFER_SIZE);
2211 input_filename = name;
2213 /* Put an entry on the input file stack for the main input file. */
2215 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2216 input_file_stack->next = 0;
2217 input_file_stack->name = input_filename;
2219 /* Perform language-specific initialization.
2220 This may set main_input_filename. */
2223 /* If the input doesn't start with a #line, use the input name
2224 as the official input file name. */
2225 if (main_input_filename == 0)
2226 main_input_filename = name;
2228 if (!output_bytecode)
2230 ASM_FILE_START (asm_out_file);
2232 #ifdef ASM_COMMENT_START
2233 if (flag_verbose_asm)
2235 /* Print the list of options in effect. */
2236 print_version (asm_out_file, ASM_COMMENT_START);
2237 print_switch_values (asm_out_file, 0, MAX_LINE,
2238 ASM_COMMENT_START, " ", "\n");
2239 /* Add a blank line here so it appears in assembler output but not
2241 fprintf (asm_out_file, "\n");
2246 /* Output something to inform GDB that this compilation was by GCC. Also
2247 serves to tell GDB file consists of bytecodes. */
2248 if (output_bytecode)
2249 fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
2252 #ifndef ASM_IDENTIFY_GCC
2253 fprintf (asm_out_file, "gcc2_compiled.:\n");
2255 ASM_IDENTIFY_GCC (asm_out_file);
2259 /* Output something to identify which front-end produced this file. */
2260 #ifdef ASM_IDENTIFY_LANGUAGE
2261 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2264 #ifndef ASM_OUTPUT_SECTION_NAME
2265 if (flag_function_sections)
2267 warning ("-ffunction-sections not supported for this target.");
2268 flag_function_sections = 0;
2272 if (flag_function_sections
2273 && (profile_flag || profile_block_flag))
2275 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2276 flag_function_sections = 0;
2279 if (flag_function_sections && write_symbols != NO_DEBUG)
2280 warning ("-ffunction-sections may affect debugging on some targets.");
2282 if (output_bytecode)
2284 if (profile_flag || profile_block_flag)
2285 error ("profiling not supported in bytecode compilation");
2289 /* ??? Note: There used to be a conditional here
2290 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2291 This was to guarantee separation between gcc_compiled. and
2292 the first function, for the sake of dbx on Suns.
2293 However, having the extra zero here confused the Emacs
2294 code for unexec, and might confuse other programs too.
2295 Therefore, I took out that change.
2296 In future versions we should find another way to solve
2297 that dbx problem. -- rms, 23 May 93. */
2299 /* Don't let the first function fall at the same address
2300 as gcc_compiled., if profiling. */
2301 if (profile_flag || profile_block_flag)
2302 assemble_zeros (UNITS_PER_WORD);
2305 /* If dbx symbol table desired, initialize writing it
2306 and output the predefined types. */
2307 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2308 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2309 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2312 #ifdef SDB_DEBUGGING_INFO
2313 if (write_symbols == SDB_DEBUG)
2314 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2317 #ifdef DWARF_DEBUGGING_INFO
2318 if (write_symbols == DWARF_DEBUG)
2319 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2321 #ifdef DWARF2_DEBUGGING_INFO
2322 if (write_symbols == DWARF2_DEBUG)
2323 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2326 /* Initialize yet another pass. */
2328 if (!output_bytecode)
2329 init_final (main_input_filename);
2331 start_time = get_run_time ();
2333 /* Call the parser, which parses the entire file
2334 (calling rest_of_compilation for each function). */
2336 if (yyparse () != 0)
2338 if (errorcount == 0)
2339 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2341 /* In case there were missing closebraces,
2342 get us back to the global binding level. */
2343 while (! global_bindings_p ())
2347 /* Compilation is now finished except for writing
2348 what's left of the symbol table output. */
2350 parse_time += get_run_time () - start_time;
2352 parse_time -= integration_time;
2353 parse_time -= varconst_time;
2355 globals = getdecls ();
2357 /* Really define vars that have had only a tentative definition.
2358 Really output inline functions that must actually be callable
2359 and have not been output so far. */
2362 int len = list_length (globals);
2363 tree *vec = (tree *) alloca (sizeof (tree) * len);
2368 /* Process the decls in reverse order--earliest first.
2369 Put them into VEC from back to front, then take out from front. */
2371 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2372 vec[len - i - 1] = decl;
2374 for (i = 0; i < len; i++)
2378 /* We're not deferring this any longer. */
2379 DECL_DEFER_OUTPUT (decl) = 0;
2381 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2382 && incomplete_decl_finalize_hook != 0)
2383 (*incomplete_decl_finalize_hook) (decl);
2386 /* Now emit any global variables or functions that we have been putting
2387 off. We need to loop in case one of the things emitted here
2388 references another one which comes earlier in the list. */
2392 for (i = 0; i < len; i++)
2396 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2399 /* Don't write out static consts, unless we still need them.
2401 We also keep static consts if not optimizing (for debugging),
2402 unless the user specified -fno-keep-static-consts.
2403 ??? They might be better written into the debug information.
2404 This is possible when using DWARF.
2406 A language processor that wants static constants to be always
2407 written out (even if it is not used) is responsible for
2408 calling rest_of_decl_compilation itself. E.g. the C front-end
2409 calls rest_of_decl_compilation from finish_decl.
2410 One motivation for this is that is conventional in some
2411 environments to write things like:
2412 static const char rcsid[] = "... version string ...";
2413 intending to force the string to be in the executable.
2415 A language processor that would prefer to have unneeded
2416 static constants "optimized away" would just defer writing
2417 them out until here. E.g. C++ does this, because static
2418 constants are often defined in header files.
2420 ??? A tempting alternative (for both C and C++) would be
2421 to force a constant to be written if and only if it is
2422 defined in a main file, as opposed to an include file. */
2424 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2425 && (! TREE_READONLY (decl)
2426 || TREE_PUBLIC (decl)
2427 || (!optimize && flag_keep_static_consts)
2428 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2431 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2434 if (TREE_CODE (decl) == FUNCTION_DECL
2435 && DECL_INITIAL (decl) != 0
2436 && DECL_SAVED_INSNS (decl) != 0
2437 && (flag_keep_inline_functions
2438 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2441 temporary_allocation ();
2442 output_inline_function (decl);
2443 permanent_allocation (1);
2448 /* Now that all possible functions have been output, we can dump
2449 the exception table. */
2451 if (exception_table_p ())
2452 output_exception_table ();
2454 for (i = 0; i < len; i++)
2458 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2459 && ! TREE_ASM_WRITTEN (decl))
2460 /* Cancel the RTL for this decl so that, if debugging info
2461 output for global variables is still to come,
2462 this one will be omitted. */
2463 DECL_RTL (decl) = NULL;
2465 /* Warn about any function
2466 declared static but not defined.
2467 We don't warn about variables,
2468 because many programs have static variables
2469 that exist only to get some text into the object file. */
2470 if (TREE_CODE (decl) == FUNCTION_DECL
2472 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2473 && DECL_INITIAL (decl) == 0
2474 && DECL_EXTERNAL (decl)
2475 && ! DECL_ARTIFICIAL (decl)
2476 && ! TREE_PUBLIC (decl))
2478 pedwarn_with_decl (decl,
2479 "`%s' declared `static' but never defined");
2480 /* This symbol is effectively an "extern" declaration now. */
2481 TREE_PUBLIC (decl) = 1;
2482 assemble_external (decl);
2485 /* Warn about static fns or vars defined but not used,
2486 but not about inline functions or static consts
2487 since defining those in header files is normal practice. */
2489 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2490 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2491 && ! DECL_IN_SYSTEM_HEADER (decl)
2492 && ! DECL_EXTERNAL (decl)
2493 && ! TREE_PUBLIC (decl)
2494 && ! TREE_USED (decl)
2495 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2496 /* The TREE_USED bit for file-scope decls
2497 is kept in the identifier, to handle multiple
2498 external decls in different scopes. */
2499 && ! TREE_USED (DECL_NAME (decl)))
2500 warning_with_decl (decl, "`%s' defined but not used");
2502 #ifdef SDB_DEBUGGING_INFO
2503 /* The COFF linker can move initialized global vars to the end.
2504 And that can screw up the symbol ordering.
2505 By putting the symbols in that order to begin with,
2506 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2507 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2508 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2509 && ! DECL_EXTERNAL (decl)
2510 && DECL_RTL (decl) != 0)
2511 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2513 /* Output COFF information for non-global
2514 file-scope initialized variables. */
2515 if (write_symbols == SDB_DEBUG
2516 && TREE_CODE (decl) == VAR_DECL
2517 && DECL_INITIAL (decl)
2518 && ! DECL_EXTERNAL (decl)
2519 && DECL_RTL (decl) != 0
2520 && GET_CODE (DECL_RTL (decl)) == MEM)
2521 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2522 #endif /* SDB_DEBUGGING_INFO */
2523 #ifdef DWARF_DEBUGGING_INFO
2524 /* Output DWARF information for file-scope tentative data object
2525 declarations, file-scope (extern) function declarations (which
2526 had no corresponding body) and file-scope tagged type declarations
2527 and definitions which have not yet been forced out. */
2529 if (write_symbols == DWARF_DEBUG
2530 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2531 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2533 #ifdef DWARF2_DEBUGGING_INFO
2534 /* Output DWARF2 information for file-scope tentative data object
2535 declarations, file-scope (extern) function declarations (which
2536 had no corresponding body) and file-scope tagged type declarations
2537 and definitions which have not yet been forced out. */
2539 if (write_symbols == DWARF2_DEBUG
2540 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2541 TIMEVAR (symout_time, dwarf2out_file_scope_decl (decl, 1));
2546 /* Write out any pending weak symbol declarations. */
2550 /* Do dbx symbols */
2551 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2552 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2553 TIMEVAR (symout_time,
2555 dbxout_finish (asm_out_file, main_input_filename);
2559 #ifdef DWARF_DEBUGGING_INFO
2560 if (write_symbols == DWARF_DEBUG)
2561 TIMEVAR (symout_time,
2567 #ifdef DWARF2_DEBUGGING_INFO
2568 if (write_symbols == DWARF2_DEBUG)
2569 TIMEVAR (symout_time,
2571 dwarf2out_finish ();
2575 /* Output some stuff at end of file if nec. */
2577 if (!output_bytecode)
2579 end_final (main_input_filename);
2582 ASM_FILE_END (asm_out_file);
2586 /* Language-specific end of compilation actions. */
2590 if (output_bytecode)
2591 bc_write_file (asm_out_file);
2593 /* Close the dump files. */
2595 if (flag_gen_aux_info)
2597 fclose (aux_info_file);
2599 unlink (aux_info_file_name);
2603 fclose (rtl_dump_file);
2606 fclose (jump_opt_dump_file);
2609 fclose (cse_dump_file);
2612 fclose (loop_dump_file);
2615 fclose (cse2_dump_file);
2618 fclose (flow_dump_file);
2622 dump_combine_total_stats (combine_dump_file);
2623 fclose (combine_dump_file);
2627 fclose (sched_dump_file);
2630 fclose (local_reg_dump_file);
2632 if (global_reg_dump)
2633 fclose (global_reg_dump_file);
2636 fclose (sched2_dump_file);
2639 fclose (jump2_opt_dump_file);
2642 fclose (dbr_sched_dump_file);
2646 fclose (stack_reg_dump_file);
2649 /* Close non-debugging input and output files. Take special care to note
2650 whether fclose returns an error, since the pages might still be on the
2651 buffer chain while the file is open. */
2654 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2655 fatal_io_error (asm_file_name);
2657 /* Print the times. */
2661 fprintf (stderr,"\n");
2662 print_time ("parse", parse_time);
2664 if (!output_bytecode)
2666 print_time ("integration", integration_time);
2667 print_time ("jump", jump_time);
2668 print_time ("cse", cse_time);
2669 print_time ("loop", loop_time);
2670 print_time ("cse2", cse2_time);
2671 print_time ("flow", flow_time);
2672 print_time ("combine", combine_time);
2673 print_time ("sched", sched_time);
2674 print_time ("local-alloc", local_alloc_time);
2675 print_time ("global-alloc", global_alloc_time);
2676 print_time ("sched2", sched2_time);
2677 print_time ("dbranch", dbr_sched_time);
2678 print_time ("shorten-branch", shorten_branch_time);
2679 print_time ("stack-reg", stack_reg_time);
2680 print_time ("final", final_time);
2681 print_time ("varconst", varconst_time);
2682 print_time ("symout", symout_time);
2683 print_time ("dump", dump_time);
2688 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2689 and TYPE_DECL nodes.
2691 This does nothing for local (non-static) variables.
2692 Otherwise, it sets up the RTL and outputs any assembler code
2693 (label definition, storage allocation and initialization).
2695 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2696 the assembler symbol name to be used. TOP_LEVEL is nonzero
2697 if this declaration is not within a function. */
2700 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2706 /* Declarations of variables, and of functions defined elsewhere. */
2708 /* The most obvious approach, to put an #ifndef around where
2709 this macro is used, doesn't work since it's inside a macro call. */
2710 #ifndef ASM_FINISH_DECLARE_OBJECT
2711 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2714 /* Forward declarations for nested functions are not "external",
2715 but we need to treat them as if they were. */
2716 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2717 || TREE_CODE (decl) == FUNCTION_DECL)
2718 TIMEVAR (varconst_time,
2720 make_decl_rtl (decl, asmspec, top_level);
2721 /* Initialized extern variable exists to be replaced
2722 with its value, or represents something that will be
2723 output in another file. */
2724 if (! (TREE_CODE (decl) == VAR_DECL
2725 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2726 && DECL_INITIAL (decl) != 0
2727 && DECL_INITIAL (decl) != error_mark_node))
2728 /* Don't output anything
2729 when a tentative file-scope definition is seen.
2730 But at end of compilation, do output code for them. */
2731 if (! (! at_end && top_level
2732 && (DECL_INITIAL (decl) == 0
2733 || DECL_INITIAL (decl) == error_mark_node)))
2734 assemble_variable (decl, top_level, at_end, 0);
2735 if (!output_bytecode
2736 && decl == last_assemble_variable_decl)
2738 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2742 else if (DECL_REGISTER (decl) && asmspec != 0)
2744 if (decode_reg_name (asmspec) >= 0)
2746 DECL_RTL (decl) = 0;
2747 make_decl_rtl (decl, asmspec, top_level);
2750 error ("invalid register name `%s' for register variable", asmspec);
2752 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2753 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2754 && TREE_CODE (decl) == TYPE_DECL)
2755 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2757 #ifdef SDB_DEBUGGING_INFO
2758 else if (write_symbols == SDB_DEBUG && top_level
2759 && TREE_CODE (decl) == TYPE_DECL)
2760 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2764 /* Called after finishing a record, union or enumeral type. */
2767 rest_of_type_compilation (type, toplev)
2771 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2772 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2773 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2775 #ifdef SDB_DEBUGGING_INFO
2776 if (write_symbols == SDB_DEBUG)
2777 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2779 #ifdef DWARF_DEBUGGING_INFO
2780 /* Don't write out function-scope types here. */
2781 if (write_symbols == DWARF_DEBUG && toplev)
2782 TIMEVAR (symout_time, dwarfout_file_scope_decl (TYPE_STUB_DECL (type), 0));
2784 #ifdef DWARF2_DEBUGGING_INFO
2785 /* Don't write out function-scope types here. */
2786 if (write_symbols == DWARF2_DEBUG && toplev)
2787 TIMEVAR (symout_time, dwarf2out_file_scope_decl (TYPE_STUB_DECL (type), 0));
2791 /* This is called from finish_function (within yyparse)
2792 after each top-level definition is parsed.
2793 It is supposed to compile that function or variable
2794 and output the assembler code for it.
2795 After we return, the tree storage is freed. */
2798 rest_of_compilation (decl)
2802 int start_time = get_run_time ();
2804 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2805 to be restored after we finish compiling the function
2806 (for use when compiling inline calls to this function). */
2807 tree saved_block_tree = 0;
2808 /* Likewise, for DECL_ARGUMENTS. */
2809 tree saved_arguments = 0;
2812 if (output_bytecode)
2815 /* If we are reconsidering an inline function
2816 at the end of compilation, skip the stuff for making it inline. */
2818 if (DECL_SAVED_INSNS (decl) == 0)
2823 /* If requested, consider whether to make this function inline. */
2824 if (DECL_INLINE (decl) || flag_inline_functions)
2825 TIMEVAR (integration_time,
2827 lose = function_cannot_inline_p (decl);
2828 if (lose || ! optimize)
2830 if (warn_inline && DECL_INLINE (decl))
2831 warning_with_decl (decl, lose);
2832 DECL_ABSTRACT_ORIGIN (decl) = 0;
2833 /* Don't really compile an extern inline function.
2834 If we can't make it inline, pretend
2835 it was only declared. */
2836 if (DECL_EXTERNAL (decl))
2838 DECL_INITIAL (decl) = 0;
2839 goto exit_rest_of_compilation;
2843 /* ??? Note that this has the effect of making it look
2844 like "inline" was specified for a function if we choose
2845 to inline it. This isn't quite right, but it's
2846 probably not worth the trouble to fix. */
2847 inlineable = DECL_INLINE (decl) = 1;
2850 insns = get_insns ();
2852 /* Dump the rtl code if we are dumping rtl. */
2857 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2858 IDENTIFIER_POINTER (DECL_NAME (decl)));
2859 if (DECL_SAVED_INSNS (decl))
2860 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2861 print_rtl (rtl_dump_file, insns);
2862 fflush (rtl_dump_file);
2865 /* If function is inline, and we don't yet know whether to
2866 compile it by itself, defer decision till end of compilation.
2867 finish_compilation will call rest_of_compilation again
2868 for those functions that need to be output. Also defer those
2869 functions that we are supposed to defer. We cannot defer
2870 functions containing nested functions since the nested function
2871 data is in our non-saved obstack. */
2873 if (! current_function_contains_functions
2874 && (DECL_DEFER_OUTPUT (decl)
2875 || (DECL_INLINE (decl)
2876 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2877 && ! flag_keep_inline_functions)
2878 || DECL_EXTERNAL (decl)))))
2880 DECL_DEFER_OUTPUT (decl) = 1;
2882 /* If -Wreturn-type, we have to do a bit of compilation. */
2883 if (! warn_return_type)
2885 #ifdef DWARF_DEBUGGING_INFO
2886 /* Generate the DWARF info for the "abstract" instance
2887 of a function which we may later generate inlined and/or
2888 out-of-line instances of. */
2889 if (write_symbols == DWARF_DEBUG)
2891 set_decl_abstract_flags (decl, 1);
2892 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2893 set_decl_abstract_flags (decl, 0);
2896 #ifdef DWARF2_DEBUGGING_INFO
2897 /* Generate the DWARF2 info for the "abstract" instance
2898 of a function which we may later generate inlined and/or
2899 out-of-line instances of. */
2900 if (write_symbols == DWARF2_DEBUG)
2902 set_decl_abstract_flags (decl, 1);
2903 TIMEVAR (symout_time, dwarf2out_file_scope_decl (decl, 0));
2904 set_decl_abstract_flags (decl, 0);
2907 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2908 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
2909 goto exit_rest_of_compilation;
2913 /* If we have to compile the function now, save its rtl and subdecls
2914 so that its compilation will not affect what others get. */
2915 if (inlineable || DECL_DEFER_OUTPUT (decl))
2917 #ifdef DWARF_DEBUGGING_INFO
2918 /* Generate the DWARF info for the "abstract" instance of
2919 a function which we will generate an out-of-line instance
2920 of almost immediately (and which we may also later generate
2921 various inlined instances of). */
2922 if (write_symbols == DWARF_DEBUG)
2924 set_decl_abstract_flags (decl, 1);
2925 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2926 set_decl_abstract_flags (decl, 0);
2929 #ifdef DWARF2_DEBUGGING_INFO
2930 /* Generate the DWARF2 info for the "abstract" instance of
2931 a function which we will generate an out-of-line instance
2932 of almost immediately (and which we may also later generate
2933 various inlined instances of). */
2934 if (write_symbols == DWARF2_DEBUG)
2936 set_decl_abstract_flags (decl, 1);
2937 TIMEVAR (symout_time, dwarf2out_file_scope_decl (decl, 0));
2938 set_decl_abstract_flags (decl, 0);
2941 saved_block_tree = DECL_INITIAL (decl);
2942 saved_arguments = DECL_ARGUMENTS (decl);
2943 TIMEVAR (integration_time, save_for_inline_copying (decl));
2944 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
2947 /* If specified extern inline but we aren't inlining it, we are
2949 if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
2950 goto exit_rest_of_compilation;
2953 if (! DECL_DEFER_OUTPUT (decl))
2954 TREE_ASM_WRITTEN (decl) = 1;
2956 /* Now that integrate will no longer see our rtl, we need not distinguish
2957 between the return value of this function and the return value of called
2959 rtx_equal_function_value_matters = 0;
2961 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2962 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2964 goto exit_rest_of_compilation;
2967 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2968 Note that that may have been done above, in save_for_inline_copying.
2969 The call to resume_temporary_allocation near the end of this function
2970 goes back to the usual state of affairs. */
2972 rtl_in_current_obstack ();
2975 /* If we are doing position-independent code generation, now
2976 is the time to output special prologues and epilogues.
2977 We do not want to do this earlier, because it just clutters
2978 up inline functions with meaningless insns. */
2983 /* Add an unwinder for exception handling, if needed. */
2986 insns = get_insns ();
2988 /* Copy any shared structure that should not be shared. */
2990 unshare_all_rtl (insns);
2992 /* Instantiate all virtual registers. */
2994 instantiate_virtual_regs (current_function_decl, get_insns ());
2996 /* See if we have allocated stack slots that are not directly addressable.
2997 If so, scan all the insns and create explicit address computation
2998 for all references to such slots. */
2999 /* fixup_stack_slots (); */
3001 /* Find all the EH handlers. */
3002 find_exception_handler_labels ();
3004 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3005 are initialized and to compute whether control can drop off the end
3007 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3008 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3010 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3011 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3012 goto exit_rest_of_compilation;
3014 /* Dump rtl code after jump, if we are doing that. */
3019 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
3020 IDENTIFIER_POINTER (DECL_NAME (decl)));
3021 print_rtl (jump_opt_dump_file, insns);
3022 fflush (jump_opt_dump_file);
3025 /* Perform common subexpression elimination.
3026 Nonzero value from `cse_main' means that jumps were simplified
3027 and some code may now be unreachable, so do
3028 jump optimization again. */
3033 fprintf (cse_dump_file, "\n;; Function %s\n\n",
3034 IDENTIFIER_POINTER (DECL_NAME (decl)));
3039 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3041 if (flag_thread_jumps)
3042 /* Hacks by tiemann & kenner. */
3043 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3045 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3047 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
3049 if (tem || optimize > 1)
3050 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3053 /* Dump rtl code after cse, if we are doing that. */
3058 print_rtl (cse_dump_file, insns);
3059 fflush (cse_dump_file);
3065 fprintf (loop_dump_file, "\n;; Function %s\n\n",
3066 IDENTIFIER_POINTER (DECL_NAME (decl)));
3069 /* Move constant computations out of loops. */
3075 loop_optimize (insns, loop_dump_file);
3079 /* Dump rtl code after loop opt, if we are doing that. */
3084 print_rtl (loop_dump_file, insns);
3085 fflush (loop_dump_file);
3091 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
3092 IDENTIFIER_POINTER (DECL_NAME (decl)));
3095 if (optimize > 0 && flag_rerun_cse_after_loop)
3097 /* Running another jump optimization pass before the second
3098 cse pass sometimes simplifies the RTL enough to allow
3099 the second CSE pass to do a better job. Jump_optimize can change
3100 max_reg_num so we must rerun reg_scan afterwards.
3101 ??? Rework to not call reg_scan so often. */
3102 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3103 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3105 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3106 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3107 1, cse2_dump_file));
3109 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3112 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, thread_jumps (insns, max_reg_num (), 0));
3117 /* Dump rtl code after cse, if we are doing that. */
3122 print_rtl (cse2_dump_file, insns);
3123 fflush (cse2_dump_file);
3126 /* We are no longer anticipating cse in this function, at least. */
3128 cse_not_expected = 1;
3130 /* Now we choose between stupid (pcc-like) register allocation
3131 (if we got the -noreg switch and not -opt)
3132 and smart register allocation. */
3134 if (optimize > 0) /* Stupid allocation probably won't work */
3135 obey_regdecls = 0; /* if optimizations being done. */
3139 /* Print function header into flow dump now
3140 because doing the flow analysis makes some of the dump. */
3145 fprintf (flow_dump_file, "\n;; Function %s\n\n",
3146 IDENTIFIER_POINTER (DECL_NAME (decl)));
3153 regclass (insns, max_reg_num ());
3154 stupid_life_analysis (insns, max_reg_num (),
3160 /* Do control and data flow analysis,
3161 and write some of the results to dump file. */
3163 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
3165 if (warn_uninitialized)
3167 uninitialized_vars_warning (DECL_INITIAL (decl));
3168 setjmp_args_warning ();
3172 /* Dump rtl after flow analysis. */
3177 print_rtl (flow_dump_file, insns);
3178 fflush (flow_dump_file);
3181 /* If -opt, try combining insns through substitution. */
3184 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3186 /* Dump rtl code after insn combination. */
3191 fprintf (combine_dump_file, "\n;; Function %s\n\n",
3192 IDENTIFIER_POINTER (DECL_NAME (decl)));
3193 dump_combine_stats (combine_dump_file);
3194 print_rtl (combine_dump_file, insns);
3195 fflush (combine_dump_file);
3198 /* Print function header into sched dump now
3199 because doing the sched analysis makes some of the dump. */
3204 fprintf (sched_dump_file, "\n;; Function %s\n\n",
3205 IDENTIFIER_POINTER (DECL_NAME (decl)));
3208 if (optimize > 0 && flag_schedule_insns)
3210 /* Do control and data sched analysis,
3211 and write some of the results to dump file. */
3213 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
3216 /* Dump rtl after instruction scheduling. */
3221 print_rtl (sched_dump_file, insns);
3222 fflush (sched_dump_file);
3225 /* Unless we did stupid register allocation,
3226 allocate pseudo-regs that are used only within 1 basic block. */
3229 TIMEVAR (local_alloc_time,
3231 regclass (insns, max_reg_num ());
3235 /* Dump rtl code after allocating regs within basic blocks. */
3240 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
3241 IDENTIFIER_POINTER (DECL_NAME (decl)));
3242 dump_flow_info (local_reg_dump_file);
3243 dump_local_alloc (local_reg_dump_file);
3244 print_rtl (local_reg_dump_file, insns);
3245 fflush (local_reg_dump_file);
3248 if (global_reg_dump)
3250 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
3251 IDENTIFIER_POINTER (DECL_NAME (decl))));
3253 /* Save the last label number used so far, so reorg can tell
3254 when it's safe to kill spill regs. */
3255 max_label_num_after_reload = max_label_num ();
3257 /* Unless we did stupid register allocation,
3258 allocate remaining pseudo-regs, then do the reload pass
3259 fixing up any insns that are invalid. */
3261 TIMEVAR (global_alloc_time,
3264 failure = global_alloc (global_reg_dump_file);
3266 failure = reload (insns, 0, global_reg_dump_file);
3269 if (global_reg_dump)
3272 dump_global_regs (global_reg_dump_file);
3273 print_rtl (global_reg_dump_file, insns);
3274 fflush (global_reg_dump_file);
3278 goto exit_rest_of_compilation;
3280 reload_completed = 1;
3282 /* On some machines, the prologue and epilogue code, or parts thereof,
3283 can be represented as RTL. Doing so lets us schedule insns between
3284 it and the rest of the code and also allows delayed branch
3285 scheduling to operate in the epilogue. */
3287 thread_prologue_and_epilogue_insns (insns);
3289 if (optimize > 0 && flag_schedule_insns_after_reload)
3294 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
3295 IDENTIFIER_POINTER (DECL_NAME (decl)));
3298 /* Do control and data sched analysis again,
3299 and write some more of the results to dump file. */
3301 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
3303 /* Dump rtl after post-reorder instruction scheduling. */
3308 print_rtl (sched2_dump_file, insns);
3309 fflush (sched2_dump_file);
3313 #ifdef LEAF_REGISTERS
3315 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3319 /* One more attempt to remove jumps to .+1
3320 left by dead-store-elimination.
3321 Also do cross-jumping this time
3322 and delete no-op move insns. */
3326 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3329 /* Dump rtl code after jump, if we are doing that. */
3334 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
3335 IDENTIFIER_POINTER (DECL_NAME (decl)));
3336 print_rtl (jump2_opt_dump_file, insns);
3337 fflush (jump2_opt_dump_file);
3340 /* If a machine dependent reorganization is needed, call it. */
3341 #ifdef MACHINE_DEPENDENT_REORG
3342 MACHINE_DEPENDENT_REORG (insns);
3345 /* If a scheduling pass for delayed branches is to be done,
3346 call the scheduling code. */
3349 if (optimize > 0 && flag_delayed_branch)
3351 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3356 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
3357 IDENTIFIER_POINTER (DECL_NAME (decl)));
3358 print_rtl (dbr_sched_dump_file, insns);
3359 fflush (dbr_sched_dump_file);
3365 /* Shorten branches. */
3366 TIMEVAR (shorten_branch_time,
3368 shorten_branches (get_insns ());
3372 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3377 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
3378 IDENTIFIER_POINTER (DECL_NAME (decl)));
3379 print_rtl (stack_reg_dump_file, insns);
3380 fflush (stack_reg_dump_file);
3385 /* Now turn the rtl into assembler code. */
3387 TIMEVAR (final_time,
3392 /* Get the function's name, as described by its RTL.
3393 This may be different from the DECL_NAME name used
3394 in the source file. */
3396 x = DECL_RTL (decl);
3397 if (GET_CODE (x) != MEM)
3400 if (GET_CODE (x) != SYMBOL_REF)
3402 fnname = XSTR (x, 0);
3404 assemble_start_function (decl, fnname);
3405 final_start_function (insns, asm_out_file, optimize);
3406 final (insns, asm_out_file, optimize, 0);
3407 final_end_function (insns, asm_out_file, optimize);
3408 assemble_end_function (decl, fnname);
3409 fflush (asm_out_file);
3412 /* Write DBX symbols if requested */
3414 /* Note that for those inline functions where we don't initially
3415 know for certain that we will be generating an out-of-line copy,
3416 the first invocation of this routine (rest_of_compilation) will
3417 skip over this code by doing a `goto exit_rest_of_compilation;'.
3418 Later on, finish_compilation will call rest_of_compilation again
3419 for those inline functions that need to have out-of-line copies
3420 generated. During that call, we *will* be routed past here. */
3422 #ifdef DBX_DEBUGGING_INFO
3423 if (write_symbols == DBX_DEBUG)
3424 TIMEVAR (symout_time, dbxout_function (decl));
3427 #ifdef DWARF_DEBUGGING_INFO
3428 if (write_symbols == DWARF_DEBUG)
3429 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3432 #ifdef DWARF2_DEBUGGING_INFO
3433 if (write_symbols == DWARF2_DEBUG)
3434 TIMEVAR (symout_time, dwarf2out_file_scope_decl (decl, 0));
3437 exit_rest_of_compilation:
3439 /* In case the function was not output,
3440 don't leave any temporary anonymous types
3441 queued up for sdb output. */
3442 #ifdef SDB_DEBUGGING_INFO
3443 if (write_symbols == SDB_DEBUG)
3444 sdbout_types (NULL_TREE);
3447 /* Put back the tree of subblocks and list of arguments
3448 from before we copied them.
3449 Code generation and the output of debugging info may have modified
3450 the copy, but the original is unchanged. */
3452 if (saved_block_tree != 0)
3454 DECL_INITIAL (decl) = saved_block_tree;
3455 DECL_ARGUMENTS (decl) = saved_arguments;
3456 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3459 reload_completed = 0;
3461 /* Clear out the insn_length contents now that they are no longer valid. */
3462 init_insn_lengths ();
3464 /* Clear out the real_constant_chain before some of the rtx's
3465 it runs through become garbage. */
3467 clear_const_double_mem ();
3469 /* Cancel the effect of rtl_in_current_obstack. */
3471 resume_temporary_allocation ();
3473 /* Show no temporary slots allocated. */
3477 /* The parsing time is all the time spent in yyparse
3478 *except* what is spent in this function. */
3480 parse_time -= get_run_time () - start_time;
3483 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3484 Exit code is 35 if can't open files, 34 if fatal error,
3485 33 if had nonfatal errors, else success. */
3488 main (argc, argv, envp)
3495 int flag_print_mem = 0;
3496 int version_flag = 0;
3499 /* save in case md file wants to emit args as a comment. */
3503 p = argv[0] + strlen (argv[0]);
3504 while (p != argv[0] && p[-1] != '/'
3505 #ifdef DIR_SEPARATOR
3506 && p[-1] != DIR_SEPARATOR
3513 /* Get rid of any avoidable limit on stack size. */
3517 /* Set the stack limit huge so that alloca does not fail. */
3518 getrlimit (RLIMIT_STACK, &rlim);
3519 rlim.rlim_cur = rlim.rlim_max;
3520 setrlimit (RLIMIT_STACK, &rlim);
3522 #endif /* RLIMIT_STACK */
3524 signal (SIGFPE, float_signal);
3527 signal (SIGPIPE, pipe_closed);
3530 decl_printable_name = decl_name;
3531 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3533 /* Initialize whether `char' is signed. */
3534 flag_signed_char = DEFAULT_SIGNED_CHAR;
3535 #ifdef DEFAULT_SHORT_ENUMS
3536 /* Initialize how much space enums occupy, by default. */
3537 flag_short_enums = DEFAULT_SHORT_ENUMS;
3540 /* Scan to see what optimization level has been specified. That will
3541 determine the default value of many flags. */
3542 for (i = 1; i < argc; i++)
3544 if (!strcmp (argv[i], "-O"))
3548 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3550 /* Handle -O2, -O3, -O69, ... */
3551 char *p = &argv[i][2];
3555 if (! (c >= '0' && c <= '9'))
3558 optimize = atoi (&argv[i][2]);
3562 obey_regdecls = (optimize == 0);
3572 flag_thread_jumps = 1;
3574 flag_delayed_branch = 1;
3576 #ifdef CAN_DEBUG_WITHOUT_FP
3577 flag_omit_frame_pointer = 1;
3583 flag_cse_follow_jumps = 1;
3584 flag_cse_skip_blocks = 1;
3585 flag_expensive_optimizations = 1;
3586 flag_strength_reduce = 1;
3587 flag_rerun_cse_after_loop = 1;
3588 flag_caller_saves = 1;
3590 #ifdef INSN_SCHEDULING
3591 flag_schedule_insns = 1;
3592 flag_schedule_insns_after_reload = 1;
3598 flag_inline_functions = 1;
3601 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
3604 set_target_switch ("");
3606 #ifdef OPTIMIZATION_OPTIONS
3607 /* Allow default optimizations to be specified on a per-machine basis. */
3608 OPTIMIZATION_OPTIONS (optimize);
3611 /* Initialize register usage now so switches may override. */
3614 for (i = 1; i < argc; i++)
3617 /* If this is a language-specific option,
3618 decode it in a language-specific way. */
3619 for (j = 0; lang_options[j] != 0; j++)
3620 if (!strncmp (argv[i], lang_options[j],
3621 strlen (lang_options[j])))
3623 if (lang_options[j] != 0)
3624 /* If the option is valid for *some* language,
3625 treat it as valid even if this language doesn't understand it. */
3626 lang_decode_option (argv[i]);
3627 else if (argv[i][0] == '-' && argv[i][1] != 0)
3629 register char *str = argv[i] + 1;
3634 set_target_switch (&str[1]);
3635 else if (!strcmp (str, "dumpbase"))
3637 dump_base_name = argv[++i];
3639 else if (str[0] == 'd')
3641 register char *p = &str[1];
3649 global_reg_dump = 1;
3655 cse_dump = 1, cse2_dump = 1;
3673 global_reg_dump = 1;
3691 flag_print_asm_name = 1;
3712 rtl_dump_and_exit = 1;
3719 else if (str[0] == 'f')
3721 register char *p = &str[1];
3724 /* Some kind of -f option.
3725 P's value is the option sans `-f'.
3726 Search for it in the table of options. */
3729 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3732 if (!strcmp (p, f_options[j].string))
3734 *f_options[j].variable = f_options[j].on_value;
3735 /* A goto here would be cleaner,
3736 but breaks the vax pcc. */
3739 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3740 && ! strcmp (p+3, f_options[j].string))
3742 *f_options[j].variable = ! f_options[j].on_value;
3749 else if (!strncmp (p, "fixed-", 6))
3750 fix_register (&p[6], 1, 1);
3751 else if (!strncmp (p, "call-used-", 10))
3752 fix_register (&p[10], 0, 1);
3753 else if (!strncmp (p, "call-saved-", 11))
3754 fix_register (&p[11], 0, 0);
3756 error ("Invalid option `%s'", argv[i]);
3758 else if (str[0] == 'O')
3760 register char *p = str+1;
3761 while (*p && *p >= '0' && *p <= '9')
3766 error ("Invalid option `%s'", argv[i]);
3768 else if (!strcmp (str, "pedantic"))
3770 else if (!strcmp (str, "pedantic-errors"))
3771 flag_pedantic_errors = pedantic = 1;
3772 else if (!strcmp (str, "quiet"))
3774 else if (!strcmp (str, "version"))
3776 else if (!strcmp (str, "w"))
3777 inhibit_warnings = 1;
3778 else if (!strcmp (str, "W"))
3781 /* We save the value of warn_uninitialized, since if they put
3782 -Wuninitialized on the command line, we need to generate a
3783 warning about not using it without also specifying -O. */
3784 if (warn_uninitialized != 1)
3785 warn_uninitialized = 2;
3787 else if (str[0] == 'W')
3789 register char *p = &str[1];
3792 /* Some kind of -W option.
3793 P's value is the option sans `-W'.
3794 Search for it in the table of options. */
3797 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3800 if (!strcmp (p, W_options[j].string))
3802 *W_options[j].variable = W_options[j].on_value;
3803 /* A goto here would be cleaner,
3804 but breaks the vax pcc. */
3807 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3808 && ! strcmp (p+3, W_options[j].string))
3810 *W_options[j].variable = ! W_options[j].on_value;
3817 else if (!strncmp (p, "id-clash-", 9))
3823 if (*endp >= '0' && *endp <= '9')
3827 error ("Invalid option `%s'", argv[i]);
3832 id_clash_len = atoi (str + 10);
3835 else if (!strncmp (p, "larger-than-", 12))
3837 char *endp = p + 12;
3841 if (*endp >= '0' && *endp <= '9')
3845 error ("Invalid option `%s'", argv[i]);
3846 goto larger_than_lose;
3849 warn_larger_than = 1;
3850 larger_than_size = atoi (str + 13);
3854 error ("Invalid option `%s'", argv[i]);
3856 else if (!strcmp (str, "p"))
3860 else if (!strcmp (str, "a"))
3862 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3863 warning ("`-a' option (basic block profile) not supported");
3865 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
3868 else if (!strcmp (str, "ax"))
3870 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3871 warning ("`-ax' option (jump profiling) not supported");
3873 profile_block_flag = (!profile_block_flag
3874 || profile_block_flag == 2) ? 2 : 3;
3877 else if (str[0] == 'g')
3881 /* A lot of code assumes write_symbols == NO_DEBUG if the
3882 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
3883 of what debugging type has been selected). This records the
3884 selected type. It is an error to specify more than one
3886 static enum debug_info_type selected_debug_type = NO_DEBUG;
3887 /* Non-zero if debugging format has been explicitly set.
3888 -g and -ggdb don't explicitly set the debugging format so
3889 -gdwarf -g3 is equivalent to -gdwarf3. */
3890 static int type_explicitly_set_p = 0;
3891 /* Table of supported debugging formats. */
3894 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
3895 constant expression, we use NO_DEBUG in its place. */
3896 enum debug_info_type debug_type;
3897 int use_extensions_p;
3898 } *da, debug_args[] = {
3899 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS },
3900 { "ggdb", NO_DEBUG, 1 },
3901 #ifdef DBX_DEBUGGING_INFO
3902 { "gstabs", DBX_DEBUG, 0 },
3903 { "gstabs+", DBX_DEBUG, 1 },
3905 #ifdef DWARF_DEBUGGING_INFO
3906 { "gdwarf-1", DWARF_DEBUG, 0 },
3907 { "gdwarf-1+", DWARF_DEBUG, 1 },
3909 #ifdef DWARF2_DEBUGGING_INFO
3910 { "gdwarf-2", DWARF2_DEBUG, 0 },
3912 #if defined (DWARF_DEBUGGING_INFO) || defined (DWARF2_DEBUGGING_INFO)
3913 #if PREFERRED_DEBUGGING_TYPE == DWARF_DEBUG || !defined (DWARF2_DEBUGGING_INFO)
3914 { "gdwarf", DWARF_DEBUG, 0 },
3915 { "gdwarf+", DWARF_DEBUG, 1 },
3917 { "gdwarf", DWARF2_DEBUG, 0 },
3920 #ifdef XCOFF_DEBUGGING_INFO
3921 { "gxcoff", XCOFF_DEBUG, 0 },
3922 { "gxcoff+", XCOFF_DEBUG, 1 },
3924 #ifdef SDB_DEBUGGING_INFO
3925 { "gcoff", SDB_DEBUG, 0 },
3929 /* Indexed by enum debug_info_type. */
3930 static char *debug_type_names[] = {
3931 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
3934 /* Look up STR in the table. */
3935 for (da = debug_args; da->arg; da++)
3937 if (! strncmp (str, da->arg, strlen (da->arg)))
3939 enum debug_info_type type = da->debug_type;
3942 p = str + strlen (da->arg);
3943 if (*p && (*p < '0' || *p > '9'))
3946 while (*q && (*q >= '0' && *q <= '9'))
3951 level = 2; /* default debugging info level */
3952 if (*q || level > 3)
3954 warning ("invalid debug level specification in option: `-%s'",
3956 /* ??? This error message is incorrect in the case of
3958 warning ("no debugging information will be generated");
3962 /* ??? A few targets use STR in the
3963 definition of PREFERRED_DEBUGGING_TYPE! */
3964 if (type == NO_DEBUG)
3965 type = PREFERRED_DEBUGGING_TYPE;
3967 /* Does it conflict with an already selected type? */
3968 if (type_explicitly_set_p
3969 /* -g/-ggdb don't conflict with anything */
3970 && da->debug_type != NO_DEBUG
3971 && type != selected_debug_type)
3972 warning ("`-%s' ignored, conflicts with `-g%s'",
3973 str, debug_type_names[(int) selected_debug_type]);
3976 /* If the format has already been set, -g/-ggdb
3977 only change the debug level. */
3978 if (type_explicitly_set_p
3979 && da->debug_type == NO_DEBUG)
3980 ; /* don't change debugging type */
3983 selected_debug_type = type;
3984 type_explicitly_set_p = da->debug_type != NO_DEBUG;
3986 write_symbols = (level == 0
3988 : selected_debug_type);
3989 use_gnu_debug_info_extensions = da->use_extensions_p;
3990 debug_info_level = (enum debug_info_level) level;
3996 warning ("`-%s' not supported by this configuration of GCC",
3999 else if (!strcmp (str, "o"))
4001 asm_file_name = argv[++i];
4003 else if (str[0] == 'G')
4005 g_switch_set = TRUE;
4006 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
4008 else if (!strncmp (str, "aux-info", 8))
4010 flag_gen_aux_info = 1;
4011 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
4014 error ("Invalid option `%s'", argv[i]);
4016 else if (argv[i][0] == '+')
4017 error ("Invalid option `%s'", argv[i]);
4022 /* Initialize for bytecode output. A good idea to do this as soon as
4023 possible after the "-f" options have been parsed. */
4024 if (output_bytecode)
4026 #ifndef TARGET_SUPPORTS_BYTECODE
4027 /* Just die with a fatal error if not supported */
4028 fatal ("-fbytecode not supported for this target");
4036 /* Inlining does not work if not optimizing,
4037 so force it not to be done. */
4041 /* The c_decode_option and lang_decode_option functions set
4042 this to `2' if -Wall is used, so we can avoid giving out
4043 lots of errors for people who don't realize what -Wall does. */
4044 if (warn_uninitialized == 1)
4045 warning ("-Wuninitialized is not supported without -O");
4048 #ifdef OVERRIDE_OPTIONS
4049 /* Some machines may reject certain combinations of options. */
4053 if (profile_block_flag == 3)
4055 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4056 profile_block_flag = 2;
4059 /* Unrolling all loops implies that standard loop unrolling must also
4061 if (flag_unroll_all_loops)
4062 flag_unroll_loops = 1;
4063 /* Loop unrolling requires that strength_reduction be on also. Silently
4064 turn on strength reduction here if it isn't already on. Also, the loop
4065 unrolling code assumes that cse will be run after loop, so that must
4066 be turned on also. */
4067 if (flag_unroll_loops)
4069 flag_strength_reduce = 1;
4070 flag_rerun_cse_after_loop = 1;
4073 /* Warn about options that are not supported on this machine. */
4074 #ifndef INSN_SCHEDULING
4075 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4076 warning ("instruction scheduling not supported on this target machine");
4079 if (flag_delayed_branch)
4080 warning ("this target machine does not have delayed branches");
4083 /* If we are in verbose mode, write out the version and maybe all the
4084 option flags in use. */
4087 print_version (stderr, "");
4089 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4092 compile_file (filename);
4094 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4097 char *lim = (char *) sbrk (0);
4099 fprintf (stderr, "Data size %d.\n",
4100 lim - (char *) &environ);
4104 system ("ps -l 1>&2");
4107 #endif /* not USG */
4109 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4112 exit (FATAL_EXIT_CODE);
4114 exit (FATAL_EXIT_CODE);
4115 exit (SUCCESS_EXIT_CODE);
4119 /* Decode -m switches. */
4121 /* Here is a table, controlled by the tm.h file, listing each -m switch
4122 and which bits in `target_switches' it should set or clear.
4123 If VALUE is positive, it is bits to set.
4124 If VALUE is negative, -VALUE is bits to clear.
4125 (The sign bit is not used so there is no confusion.) */
4127 struct {char *name; int value;} target_switches []
4130 /* This table is similar, but allows the switch to have a value. */
4132 #ifdef TARGET_OPTIONS
4133 struct {char *prefix; char ** variable;} target_options []
4137 /* Decode the switch -mNAME. */
4140 set_target_switch (name)
4146 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4147 if (!strcmp (target_switches[j].name, name))
4149 if (target_switches[j].value < 0)
4150 target_flags &= ~-target_switches[j].value;
4152 target_flags |= target_switches[j].value;
4156 #ifdef TARGET_OPTIONS
4158 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4160 int len = strlen (target_options[j].prefix);
4161 if (!strncmp (target_options[j].prefix, name, len))
4163 *target_options[j].variable = name + len;
4170 error ("Invalid option `%s'", name);
4173 /* Print version information to FILE.
4174 Each line begins with INDENT (for the case where FILE is the
4175 assembler output file). */
4178 print_version (file, indent)
4182 fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4183 language_string, version_string);
4184 fprintf (file, " (%s)", TARGET_NAME);
4187 #define __VERSION__ "[unknown]"
4189 fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4191 fprintf (file, " compiled by CC.\n");
4195 /* Print an option value and return the adjusted position in the line.
4196 ??? We don't handle error returns from fprintf (disk full); presumably
4197 other code will catch a disk full though. */
4200 print_single_switch (file, pos, max, indent, sep, term, type, name)
4203 char *indent, *sep, *term, *type, *name;
4205 /* The ultrix fprintf returns 0 on success, so compute the result we want
4206 here since we need it for the following test. */
4207 int len = strlen (sep) + strlen (type) + strlen (name);
4212 fprintf (file, "%s", term);
4217 fprintf (file, "%s", indent);
4218 pos = strlen (indent);
4220 fprintf (file, "%s%s%s", sep, type, name);
4225 /* Print active target switches to FILE.
4226 POS is the current cursor position and MAX is the size of a "line".
4227 Each line begins with INDENT and ends with TERM.
4228 Each switch is separated from the next by SEP. */
4231 print_switch_values (file, pos, max, indent, sep, term)
4234 char *indent, *sep, *term;
4239 /* Print the options as passed. */
4241 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4242 "options passed: ", "");
4244 for (p = &save_argv[1]; *p != NULL; p++)
4248 if (strcmp (*p, "-o") == 0)
4254 if (strcmp (*p, "-quiet") == 0)
4256 if (strcmp (*p, "-version") == 0)
4261 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4264 fprintf (file, "%s", term);
4266 /* Print the -f and -m options that have been enabled.
4267 We don't handle language specific options but printing argv
4270 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4271 "options enabled: ", "");
4273 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4274 if (*f_options[j].variable == f_options[j].on_value)
4275 pos = print_single_switch (file, pos, max, indent, sep, term,
4276 "-f", f_options[j].string);
4278 /* Print target specific options. */
4280 flags = target_flags;
4281 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4282 if (target_switches[j].name[0] != '\0'
4283 && target_switches[j].value > 0
4284 && ((target_switches[j].value & target_flags)
4285 == target_switches[j].value))
4287 pos = print_single_switch (file, pos, max, indent, sep, term,
4288 "-m", target_switches[j].name);
4289 flags &= ~ target_switches[j].value;
4292 #ifdef TARGET_OPTIONS
4293 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4294 if (*target_options[j].variable != NULL)
4297 sprintf (prefix, "-m%s", target_options[j].prefix);
4298 pos = print_single_switch (file, pos, max, indent, sep, term,
4299 prefix, *target_options[j].variable);
4303 fprintf (file, "%s", term);
4306 /* Record the beginning of a new source file, named FILENAME. */
4309 debug_start_source_file (filename)
4310 register char *filename;
4312 #ifdef DBX_DEBUGGING_INFO
4313 if (write_symbols == DBX_DEBUG)
4314 dbxout_start_new_source_file (filename);
4316 #ifdef DWARF_DEBUGGING_INFO
4317 if (debug_info_level == DINFO_LEVEL_VERBOSE
4318 && write_symbols == DWARF_DEBUG)
4319 dwarfout_start_new_source_file (filename);
4320 #endif /* DWARF_DEBUGGING_INFO */
4321 #ifdef DWARF2_DEBUGGING_INFO
4322 if (debug_info_level == DINFO_LEVEL_VERBOSE
4323 && write_symbols == DWARF2_DEBUG)
4324 dwarf2out_start_source_file (filename);
4325 #endif /* DWARF2_DEBUGGING_INFO */
4328 /* Record the resumption of a source file. LINENO is the line number in
4329 the source file we are returning to. */
4332 debug_end_source_file (lineno)
4333 register unsigned lineno;
4335 #ifdef DBX_DEBUGGING_INFO
4336 if (write_symbols == DBX_DEBUG)
4337 dbxout_resume_previous_source_file ();
4339 #ifdef DWARF_DEBUGGING_INFO
4340 if (debug_info_level == DINFO_LEVEL_VERBOSE
4341 && write_symbols == DWARF_DEBUG)
4342 dwarfout_resume_previous_source_file (lineno);
4343 #endif /* DWARF_DEBUGGING_INFO */
4344 #ifdef DWARF2_DEBUGGING_INFO
4345 if (debug_info_level == DINFO_LEVEL_VERBOSE
4346 && write_symbols == DWARF2_DEBUG)
4347 dwarf2out_end_source_file ();
4348 #endif /* DWARF2_DEBUGGING_INFO */
4351 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4352 the tail part of the directive line, i.e. the part which is past the
4353 initial whitespace, #, whitespace, directive-name, whitespace part. */
4356 debug_define (lineno, buffer)
4357 register unsigned lineno;
4358 register char *buffer;
4360 #ifdef DWARF_DEBUGGING_INFO
4361 if (debug_info_level == DINFO_LEVEL_VERBOSE
4362 && write_symbols == DWARF_DEBUG)
4363 dwarfout_define (lineno, buffer);
4364 #endif /* DWARF_DEBUGGING_INFO */
4365 #ifdef DWARF2_DEBUGGING_INFO
4366 if (debug_info_level == DINFO_LEVEL_VERBOSE
4367 && write_symbols == DWARF2_DEBUG)
4368 dwarf2out_define (lineno, buffer);
4369 #endif /* DWARF2_DEBUGGING_INFO */
4372 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4373 the tail part of the directive line, i.e. the part which is past the
4374 initial whitespace, #, whitespace, directive-name, whitespace part. */
4377 debug_undef (lineno, buffer)
4378 register unsigned lineno;
4379 register char *buffer;
4381 #ifdef DWARF_DEBUGGING_INFO
4382 if (debug_info_level == DINFO_LEVEL_VERBOSE
4383 && write_symbols == DWARF_DEBUG)
4384 dwarfout_undef (lineno, buffer);
4385 #endif /* DWARF_DEBUGGING_INFO */
4386 #ifdef DWARF2_DEBUGGING_INFO
4387 if (debug_info_level == DINFO_LEVEL_VERBOSE
4388 && write_symbols == DWARF2_DEBUG)
4389 dwarf2out_undef (lineno, buffer);
4390 #endif /* DWARF2_DEBUGGING_INFO */