1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* THESE ARE FOR FORTRAN. */
44 "-fintrin-case-initcap",
45 "-fintrin-case-upper",
46 "-fintrin-case-lower",
48 "-fmatch-case-initcap",
52 "-fsource-case-upper",
53 "-fsource-case-upper",
54 "-fsource-case-lower",
55 "-fsource-case-preserve",
56 "-fsymbol-case-initcap",
57 "-fsymbol-case-upper",
58 "-fsymbol-case-lower",
60 "-fcase-strict-upper",
61 "-fcase-strict-lower",
66 "-fdcp-intrinsics-delete",
67 "-fdcp-intrinsics-hide",
68 "-fdcp-intrinsics-disable",
69 "-fdcp-intrinsics-enable",
70 "-ff2c-intrinsics-delete",
71 "-ff2c-intrinsics-hide",
72 "-ff2c-intrinsics-disable",
73 "-ff2c-intrinsics-enable",
74 "-ff90-intrinsics-delete",
75 "-ff90-intrinsics-hide",
76 "-ff90-intrinsics-disable",
77 "-ff90-intrinsics-enable",
78 "-fmil-intrinsics-delete",
79 "-fmil-intrinsics-hide",
80 "-fmil-intrinsics-disable",
81 "-fmil-intrinsics-enable",
82 "-fvxt-intrinsics-delete",
83 "-fvxt-intrinsics-hide",
84 "-fvxt-intrinsics-disable",
85 "-fvxt-intrinsics-enable",
88 /* This is the top level of cc1/c++.
89 It parses command args, opens files, invokes the various passes
90 in the proper order, and counts the time used by each.
91 Error messages and low-level interface to malloc also handled here. */
102 #include <sys/types.h>
104 #include <sys/stat.h>
109 #include <sys/param.h>
110 /* This is for hpux. It is a real screw. They should change hpux. */
112 #include <sys/times.h>
113 #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
114 #undef FFS /* Some systems define this in param.h. */
117 #include <sys/time.h>
118 #include <sys/resource.h>
127 #include "insn-attr.h"
128 #include "defaults.h"
130 #include "bytecode.h"
133 #ifdef XCOFF_DEBUGGING_INFO
134 #include "xcoffout.h"
138 /* The extra parameters substantially improve the I/O performance. */
140 vms_fopen (fname
, type
)
144 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
145 fixed arguments, which matches ANSI's specification but not VAXCRTL's
146 pre-ANSI implementation. This hack circumvents the mismatch problem. */
147 FILE *(*vmslib_fopen
)() = (FILE *(*)()) fopen
;
150 return (*vmslib_fopen
) (fname
, type
, "mbc=32",
151 "deq=64", "fop=tef", "shr=nil");
153 return (*vmslib_fopen
) (fname
, type
, "mbc=32");
155 #define fopen vms_fopen
158 #ifndef DEFAULT_GDB_EXTENSIONS
159 #define DEFAULT_GDB_EXTENSIONS 1
162 extern int rtx_equal_function_value_matters
;
164 #if ! (defined (VMS) || defined (OS2))
165 extern char **environ
;
167 extern char *version_string
, *language_string
;
169 /* Carry information from ASM_DECLARE_OBJECT_NAME
170 to ASM_FINISH_DECLARE_OBJECT. */
172 extern int size_directive_output
;
173 extern tree last_assemble_variable_decl
;
175 extern void init_lex ();
176 extern void init_decl_processing ();
177 extern void init_obstacks ();
178 extern void init_tree_codes ();
179 extern void init_rtl ();
180 extern void init_regs ();
181 extern void init_optabs ();
182 extern void init_stmt ();
183 extern void init_reg_sets ();
184 extern void dump_flow_info ();
185 extern void dump_sched_info ();
186 extern void dump_local_alloc ();
188 void rest_of_decl_compilation ();
189 void error_with_file_and_line
PVPROTO((char *file
, int line
, char *s
, ...));
190 void error_with_decl
PVPROTO((tree decl
, char *s
, ...));
191 void error_for_asm
PVPROTO((rtx insn
, char *s
, ...));
192 void error
PVPROTO((char *s
, ...));
193 void fatal
PVPROTO((char *s
, ...));
194 void warning_with_file_and_line
PVPROTO((char *file
, int line
, char *s
, ...));
195 void warning_with_decl
PVPROTO((tree decl
, char *s
, ...));
196 void warning_for_asm
PVPROTO((rtx insn
, char *s
, ...));
197 void warning
PVPROTO((char *s
, ...));
198 void pedwarn
PVPROTO((char *s
, ...));
199 void pedwarn_with_decl
PVPROTO((tree decl
, char *s
, ...));
200 void pedwarn_with_file_and_line
PVPROTO((char *file
, int line
, char *s
, ...));
201 void sorry
PVPROTO((char *s
, ...));
202 void really_sorry
PVPROTO((char *s
, ...));
207 void set_target_switch ();
208 static void print_switch_values ();
209 static char *decl_name ();
211 /* Name of program invoked, sans directories. */
215 /* Copy of arguments to main. */
219 /* Name of current original source file (what was input to cpp).
220 This comes from each #-command in the actual input. */
222 char *input_filename
;
224 /* Name of top-level original source file (what was input to cpp).
225 This comes from the #-command at the beginning of the actual input.
226 If there isn't any there, then this is the cc1 input file name. */
228 char *main_input_filename
;
230 /* Stream for reading from the input file. */
234 /* Current line number in real source file. */
238 /* Stack of currently pending input files. */
240 struct file_stack
*input_file_stack
;
242 /* Incremented on each change to input_file_stack. */
243 int input_file_stack_tick
;
245 /* FUNCTION_DECL for function now being parsed or compiled. */
247 extern tree current_function_decl
;
249 /* Name to use as base of names for dump output files. */
251 char *dump_base_name
;
253 /* Bit flags that specify the machine subtype we are compiling for.
254 Bits are tested using macros TARGET_... defined in the tm.h file
255 and set by `-m...' switches. Must be defined in rtlanal.c. */
257 extern int target_flags
;
259 /* Flags saying which kinds of debugging dump have been requested. */
262 int rtl_dump_and_exit
= 0;
263 int jump_opt_dump
= 0;
268 int combine_dump
= 0;
270 int local_reg_dump
= 0;
271 int global_reg_dump
= 0;
273 int jump2_opt_dump
= 0;
274 int dbr_sched_dump
= 0;
275 int flag_print_asm_name
= 0;
276 int stack_reg_dump
= 0;
278 /* Name for output file of assembly code, specified with -o. */
282 /* Value of the -G xx switch, and whether it was passed or not. */
286 /* Type(s) of debugging information we are producing (if any).
287 See flags.h for the definitions of the different possible
288 types of debugging information. */
289 enum debug_info_type write_symbols
= NO_DEBUG
;
291 /* Level of debugging information we are producing. See flags.h
292 for the definitions of the different possible levels. */
293 enum debug_info_level debug_info_level
= DINFO_LEVEL_NONE
;
295 /* Nonzero means use GNU-only extensions in the generated symbolic
296 debugging information. */
297 /* Currently, this only has an effect when write_symbols is set to
298 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
299 int use_gnu_debug_info_extensions
= 0;
301 /* Nonzero means do optimizations. -O.
302 Particular numeric values stand for particular amounts of optimization;
303 thus, -O2 stores 2 here. However, the optimizations beyond the basic
304 ones are not controlled directly by this variable. Instead, they are
305 controlled by individual `flag_...' variables that are defaulted
306 based on this variable. */
310 /* Number of error messages and warning messages so far. */
313 int warningcount
= 0;
316 /* Flag to output bytecode instead of native assembler */
317 int output_bytecode
= 0;
319 /* Pointer to function to compute the name to use to print a declaration. */
321 char *(*decl_printable_name
) ();
323 /* Pointer to function to compute rtl for a language-specific tree code. */
325 struct rtx_def
*(*lang_expand_expr
) ();
327 /* Pointer to function to finish handling an incomplete decl at the
328 end of compilation. */
330 void (*incomplete_decl_finalize_hook
) () = 0;
332 /* Pointer to function for interim exception handling implementation.
333 This interface will change, and it is only here until a better interface
336 void (*interim_eh_hook
) PROTO((tree
));
338 /* Nonzero if generating code to do profiling. */
340 int profile_flag
= 0;
342 /* Nonzero if generating code to do profiling on a line-by-line basis. */
344 int profile_block_flag
;
346 /* Nonzero for -pedantic switch: warn about anything
347 that standard spec forbids. */
351 /* Temporarily suppress certain warnings.
352 This is set while reading code from a system header file. */
354 int in_system_header
= 0;
356 /* Nonzero means do stupid register allocation.
357 Currently, this is 1 if `optimize' is 0. */
359 int obey_regdecls
= 0;
361 /* Don't print functions as they are compiled and don't print
362 times taken by the various passes. -quiet. */
368 /* Nonzero means `char' should be signed. */
370 int flag_signed_char
;
372 /* Nonzero means give an enum type only as many bytes as it needs. */
374 int flag_short_enums
;
376 /* Nonzero for -fcaller-saves: allocate values in regs that need to
377 be saved across function calls, if that produces overall better code.
378 Optional now, so people can test it. */
380 #ifdef DEFAULT_CALLER_SAVES
381 int flag_caller_saves
= 1;
383 int flag_caller_saves
= 0;
386 /* Nonzero if structures and unions should be returned in memory.
388 This should only be defined if compatibility with another compiler or
389 with an ABI is needed, because it results in slower code. */
391 #ifndef DEFAULT_PCC_STRUCT_RETURN
392 #define DEFAULT_PCC_STRUCT_RETURN 1
395 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
397 int flag_pcc_struct_return
= DEFAULT_PCC_STRUCT_RETURN
;
399 /* Nonzero for -fforce-mem: load memory value into a register
400 before arithmetic on it. This makes better cse but slower compilation. */
402 int flag_force_mem
= 0;
404 /* Nonzero for -fforce-addr: load memory address into a register before
405 reference to memory. This makes better cse but slower compilation. */
407 int flag_force_addr
= 0;
409 /* Nonzero for -fdefer-pop: don't pop args after each function call;
410 instead save them up to pop many calls' args with one insns. */
412 int flag_defer_pop
= 0;
414 /* Nonzero for -ffloat-store: don't allocate floats and doubles
415 in extended-precision registers. */
417 int flag_float_store
= 0;
419 /* Nonzero for -fcse-follow-jumps:
420 have cse follow jumps to do a more extensive job. */
422 int flag_cse_follow_jumps
;
424 /* Nonzero for -fcse-skip-blocks:
425 have cse follow a branch around a block. */
426 int flag_cse_skip_blocks
;
428 /* Nonzero for -fexpensive-optimizations:
429 perform miscellaneous relatively-expensive optimizations. */
430 int flag_expensive_optimizations
;
432 /* Nonzero for -fthread-jumps:
433 have jump optimize output of loop. */
435 int flag_thread_jumps
;
437 /* Nonzero enables strength-reduction in loop.c. */
439 int flag_strength_reduce
= 0;
441 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
442 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
443 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
446 int flag_unroll_loops
;
448 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
449 This is generally not a win. */
451 int flag_unroll_all_loops
;
453 /* Nonzero for -fwritable-strings:
454 store string constants in data segment and don't uniquize them. */
456 int flag_writable_strings
= 0;
458 /* Nonzero means don't put addresses of constant functions in registers.
459 Used for compiling the Unix kernel, where strange substitutions are
460 done on the assembly output. */
462 int flag_no_function_cse
= 0;
464 /* Nonzero for -fomit-frame-pointer:
465 don't make a frame pointer in simple functions that don't require one. */
467 int flag_omit_frame_pointer
= 0;
469 /* Nonzero to inhibit use of define_optimization peephole opts. */
471 int flag_no_peephole
= 0;
473 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
474 operations in the interest of optimization. For example it allows
475 GCC to assume arguments to sqrt are nonnegative numbers, allowing
476 faster code for sqrt to be generated. */
478 int flag_fast_math
= 0;
480 /* Nonzero means all references through pointers are volatile. */
484 /* Nonzero means treat all global and extern variables as global. */
486 int flag_volatile_global
;
488 /* Nonzero means just do syntax checking; don't output anything. */
490 int flag_syntax_only
= 0;
492 /* Nonzero means to rerun cse after loop optimization. This increases
493 compilation time about 20% and picks up a few more common expressions. */
495 static int flag_rerun_cse_after_loop
;
497 /* Nonzero for -finline-functions: ok to inline functions that look like
498 good inline candidates. */
500 int flag_inline_functions
;
502 /* Nonzero for -fkeep-inline-functions: even if we make a function
503 go inline everywhere, keep its definition around for debugging
506 int flag_keep_inline_functions
;
508 /* Nonzero means that functions will not be inlined. */
512 /* Nonzero means we should be saving declaration info into a .X file. */
514 int flag_gen_aux_info
= 0;
516 /* Specified name of aux-info file. */
518 static char *aux_info_file_name
;
520 /* Nonzero means make the text shared if supported. */
522 int flag_shared_data
;
524 /* Nonzero means schedule into delayed branch slots if supported. */
526 int flag_delayed_branch
;
528 /* Nonzero means to run cleanups after CALL_EXPRs. */
530 int flag_short_temps
;
532 /* Nonzero if we are compiling pure (sharable) code.
533 Value is 1 if we are doing reasonable (i.e. simple
534 offset into offset table) pic. Value is 2 if we can
535 only perform register offsets. */
539 /* Nonzero means place uninitialized global data in the bss section. */
543 /* Nonzero means pretend it is OK to examine bits of target floats,
544 even if that isn't true. The resulting code will have incorrect constants,
545 but the same series of instructions that the native compiler would make. */
547 int flag_pretend_float
;
549 /* Nonzero means change certain warnings into errors.
550 Usually these are warnings about failure to conform to some standard. */
552 int flag_pedantic_errors
= 0;
554 /* flag_schedule_insns means schedule insns within basic blocks (before
556 flag_schedule_insns_after_reload means schedule insns after
559 int flag_schedule_insns
= 0;
560 int flag_schedule_insns_after_reload
= 0;
562 /* -finhibit-size-directive inhibits output of .size for ELF.
563 This is used only for compiling crtstuff.c,
564 and it may be extended to other effects
565 needed for crtstuff.c on other systems. */
566 int flag_inhibit_size_directive
= 0;
568 /* -fverbose-asm causes extra commentary information to be produced in
569 the generated assembly code (to make it more readable). This option
570 is generally only of use to those who actually need to read the
571 generated assembly code (perhaps while debugging the compiler itself). */
573 int flag_verbose_asm
= 0;
575 /* -fgnu-linker specifies use of the GNU linker for initializations.
576 (Or, more generally, a linker that handles initializations.)
577 -fno-gnu-linker says that collect2 will be used. */
579 int flag_gnu_linker
= 0;
581 int flag_gnu_linker
= 1;
584 /* Table of language-independent -f options.
585 STRING is the option name. VARIABLE is the address of the variable.
586 ON_VALUE is the value to store in VARIABLE
587 if `-fSTRING' is seen as an option.
588 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
590 struct { char *string
; int *variable
; int on_value
;} f_options
[] =
592 {"float-store", &flag_float_store
, 1},
593 {"volatile", &flag_volatile
, 1},
594 {"volatile-global", &flag_volatile_global
, 1},
595 {"defer-pop", &flag_defer_pop
, 1},
596 {"omit-frame-pointer", &flag_omit_frame_pointer
, 1},
597 {"cse-follow-jumps", &flag_cse_follow_jumps
, 1},
598 {"cse-skip-blocks", &flag_cse_skip_blocks
, 1},
599 {"expensive-optimizations", &flag_expensive_optimizations
, 1},
600 {"thread-jumps", &flag_thread_jumps
, 1},
601 {"strength-reduce", &flag_strength_reduce
, 1},
602 {"unroll-loops", &flag_unroll_loops
, 1},
603 {"unroll-all-loops", &flag_unroll_all_loops
, 1},
604 {"writable-strings", &flag_writable_strings
, 1},
605 {"peephole", &flag_no_peephole
, 0},
606 {"force-mem", &flag_force_mem
, 1},
607 {"force-addr", &flag_force_addr
, 1},
608 {"function-cse", &flag_no_function_cse
, 0},
609 {"inline-functions", &flag_inline_functions
, 1},
610 {"keep-inline-functions", &flag_keep_inline_functions
, 1},
611 {"inline", &flag_no_inline
, 0},
612 {"syntax-only", &flag_syntax_only
, 1},
613 {"shared-data", &flag_shared_data
, 1},
614 {"caller-saves", &flag_caller_saves
, 1},
615 {"pcc-struct-return", &flag_pcc_struct_return
, 1},
616 {"reg-struct-return", &flag_pcc_struct_return
, 0},
617 {"delayed-branch", &flag_delayed_branch
, 1},
618 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop
, 1},
619 {"pretend-float", &flag_pretend_float
, 1},
620 {"schedule-insns", &flag_schedule_insns
, 1},
621 {"schedule-insns2", &flag_schedule_insns_after_reload
, 1},
622 {"pic", &flag_pic
, 1},
623 {"PIC", &flag_pic
, 2},
624 {"fast-math", &flag_fast_math
, 1},
625 {"common", &flag_no_common
, 0},
626 {"inhibit-size-directive", &flag_inhibit_size_directive
, 1},
627 {"verbose-asm", &flag_verbose_asm
, 1},
628 {"gnu-linker", &flag_gnu_linker
, 1},
629 {"bytecode", &output_bytecode
, 1}
632 /* Table of language-specific options. */
634 char *lang_options
[] =
637 "-fallow-single-precision",
639 "-fsigned-bitfields",
640 "-funsigned-bitfields",
641 "-fno-signed-bitfields",
642 "-fno-unsigned-bitfields",
646 "-fno-unsigned-char",
658 "-fno-cond-mismatch",
659 "-fdollars-in-identifiers",
660 "-fno-dollars-in-identifiers",
669 "-Wbad-function-cast",
670 "-Wno-bad-function-cast",
674 "-Wno-char-subscripts",
688 "-Wno-missing-braces",
689 "-Wmissing-declarations",
690 "-Wno-missing-declarations",
691 "-Wmissing-prototypes",
692 "-Wno-missing-prototypes",
694 "-Wno-nested-externs",
698 "-Wno-pointer-arith",
700 "-Wno-redundant-decls",
701 "-Wstrict-prototypes",
702 "-Wno-strict-prototypes",
708 "-Wno-write-strings",
710 /* These are for C++. */
711 "-+e0", /* gcc.c tacks the `-' on the front. */
715 "-fno-access-control",
718 "-falt-external-templates",
719 "-fno-alt-external-templates",
720 "-fansi-overloading",
721 "-fno-ansi-overloading",
727 "-fno-conserve-space",
729 "-fno-default-inline",
732 "-felide-constructors",
733 "-fno-elide-constructors",
735 "-fno-enum-int-equiv",
736 "-fexternal-templates",
737 "-fno-external-templates",
742 "-fhandle-exceptions",
743 "-fno-handle-exceptions",
744 "-fhandle-signatures",
745 "-fno-handle-signatures",
748 "-fimplement-inlines",
749 "-fno-implement-inlines",
750 "-fimplicit-templates",
751 "-fno-implicit-templates",
755 "-fno-memoize-lookups",
757 "-fno-nonnull-objects",
759 "-fno-operator-names",
761 "-fno-save-memoized",
766 "-fstrict-prototype",
767 "-fno-strict-prototype",
768 "-fthis-is-variable",
769 "-fno-this-is-variable",
771 "-fno-vtable-thunks",
777 "-Woverloaded-virtual",
778 "-Wno-overloaded-virtual",
781 "-Wtemplate-debugging",
782 "-Wno-template-debugging",
783 "-Wctor-dtor-privacy",
784 "-Wno-ctor-dtor-privacy",
785 "-Wnon-virtual-dtor",
786 "-Wno-non-virtual-dtor",
788 "-Wno-extern-inline",
794 /* these are for obj c */
806 /* This is for GNAT and is temporary. */
811 /* Options controlling warnings */
813 /* Don't print warning messages. -w. */
815 int inhibit_warnings
= 0;
817 /* Print various extra warnings. -W. */
819 int extra_warnings
= 0;
821 /* Treat warnings as errors. -Werror. */
823 int warnings_are_errors
= 0;
825 /* Nonzero to warn about unused local variables. */
829 /* Nonzero to warn about variables used before they are initialized. */
831 int warn_uninitialized
;
833 /* Nonzero means warn about all declarations which shadow others. */
837 /* Warn if a switch on an enum fails to have a case for every enum value. */
841 /* Nonzero means warn about function definitions that default the return type
842 or that use a null return and have a return-type other than void. */
844 int warn_return_type
;
846 /* Nonzero means warn about pointer casts that increase the required
847 alignment of the target type (and might therefore lead to a crash
848 due to a misaligned access). */
852 /* Nonzero means warn about any identifiers that match in the first N
853 characters. The value N is in `id_clash_len'. */
856 unsigned id_clash_len
;
858 /* Nonzero means warn about any objects definitions whose size is larger
859 than N bytes. Also want about function definitions whose returned
860 values are larger than N bytes. The value N is in `larger_than_size'. */
862 int warn_larger_than
;
863 unsigned larger_than_size
;
865 /* Nonzero means warn if inline function is too large. */
869 /* Warn if a function returns an aggregate,
870 since there are often incompatible calling conventions for doing this. */
872 int warn_aggregate_return
;
874 /* Likewise for -W. */
876 struct { char *string
; int *variable
; int on_value
;} W_options
[] =
878 {"unused", &warn_unused
, 1},
879 {"error", &warnings_are_errors
, 1},
880 {"shadow", &warn_shadow
, 1},
881 {"switch", &warn_switch
, 1},
882 {"aggregate-return", &warn_aggregate_return
, 1},
883 {"cast-align", &warn_cast_align
, 1},
884 {"uninitialized", &warn_uninitialized
, 1},
885 {"inline", &warn_inline
, 1}
888 /* Output files for assembler code (real compiler output)
889 and debugging dumps. */
894 FILE *jump_opt_dump_file
;
896 FILE *loop_dump_file
;
897 FILE *cse2_dump_file
;
898 FILE *flow_dump_file
;
899 FILE *combine_dump_file
;
900 FILE *sched_dump_file
;
901 FILE *local_reg_dump_file
;
902 FILE *global_reg_dump_file
;
903 FILE *sched2_dump_file
;
904 FILE *jump2_opt_dump_file
;
905 FILE *dbr_sched_dump_file
;
906 FILE *stack_reg_dump_file
;
908 /* Time accumulators, to count the total time spent in various passes. */
912 int integration_time
;
920 int local_alloc_time
;
921 int global_alloc_time
;
924 int shorten_branch_time
;
930 /* Return time used so far, in microseconds. */
942 struct rusage rusage
;
947 int proc_system_time
;
949 int child_system_time
;
959 return (tms
.tms_utime
+ tms
.tms_stime
) * (1000000 / HZ
);
962 getrusage (0, &rusage
);
963 return (rusage
.ru_utime
.tv_sec
* 1000000 + rusage
.ru_utime
.tv_usec
964 + rusage
.ru_stime
.tv_sec
* 1000000 + rusage
.ru_stime
.tv_usec
);
967 return (vms_times
.proc_user_time
+ vms_times
.proc_system_time
) * 10000;
973 #define TIMEVAR(VAR, BODY) \
974 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
977 print_time (str
, total
)
982 "time in %s: %d.%06d\n",
983 str
, total
/ 1000000, total
% 1000000);
986 /* Count an error or warning. Return 1 if the message should be printed. */
989 count_error (warningp
)
992 if (warningp
&& inhibit_warnings
)
995 if (warningp
&& !warnings_are_errors
)
999 static int warning_message
= 0;
1001 if (warningp
&& !warning_message
)
1003 fprintf (stderr
, "%s: warnings being treated as errors\n", progname
);
1004 warning_message
= 1;
1012 /* Print a fatal error message. NAME is the text.
1013 Also include a system error message based on `errno'. */
1016 pfatal_with_name (name
)
1019 fprintf (stderr
, "%s: ", progname
);
1025 fatal_io_error (name
)
1028 fprintf (stderr
, "%s: %s: I/O error\n", progname
, name
);
1032 /* Called to give a better error message for a bad insn rather than
1033 just calling abort(). */
1036 fatal_insn (message
, insn
)
1040 if (!output_bytecode
)
1046 fflush (asm_out_file
);
1048 fflush (aux_info_file
);
1050 fflush (rtl_dump_file
);
1051 if (jump_opt_dump_file
)
1052 fflush (jump_opt_dump_file
);
1054 fflush (cse_dump_file
);
1056 fflush (loop_dump_file
);
1058 fflush (cse2_dump_file
);
1060 fflush (flow_dump_file
);
1061 if (combine_dump_file
)
1062 fflush (combine_dump_file
);
1063 if (sched_dump_file
)
1064 fflush (sched_dump_file
);
1065 if (local_reg_dump_file
)
1066 fflush (local_reg_dump_file
);
1067 if (global_reg_dump_file
)
1068 fflush (global_reg_dump_file
);
1069 if (sched2_dump_file
)
1070 fflush (sched2_dump_file
);
1071 if (jump2_opt_dump_file
)
1072 fflush (jump2_opt_dump_file
);
1073 if (dbr_sched_dump_file
)
1074 fflush (dbr_sched_dump_file
);
1075 if (stack_reg_dump_file
)
1076 fflush (stack_reg_dump_file
);
1080 /* Called to give a better error message when we don't have an insn to match
1081 what we are looking for or if the insn's constraints aren't satisfied,
1082 rather than just calling abort(). */
1085 fatal_insn_not_found (insn
)
1088 if (INSN_CODE (insn
) < 0)
1089 fatal_insn ("internal error--unrecognizable insn:", insn
);
1091 fatal_insn ("internal error--insn does not satisfy its constraints:", insn
);
1094 /* This is the default decl_printable_name function. */
1097 decl_name (decl
, kind
)
1101 return IDENTIFIER_POINTER (DECL_NAME (decl
));
1104 /* This is the default interim_eh_hook function. */
1107 interim_eh (finalization
)
1110 /* Don't do anything by default. */
1113 static int need_error_newline
;
1115 /* Function of last error message;
1116 more generally, function such that if next error message is in it
1117 then we don't have to mention the function name. */
1118 static tree last_error_function
= NULL
;
1120 /* Used to detect when input_file_stack has changed since last described. */
1121 static int last_error_tick
;
1123 /* Called when the start of a function definition is parsed,
1124 this function prints on stderr the name of the function. */
1127 announce_function (decl
)
1133 if (rtl_dump_and_exit
)
1134 fprintf (stderr
, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl
)));
1136 fprintf (stderr
, " %s", (*decl_printable_name
) (decl
, &junk
));
1138 need_error_newline
= 1;
1139 last_error_function
= current_function_decl
;
1143 /* Prints out, if necessary, the name of the current function
1144 which caused an error. Called from all error and warning functions. */
1147 report_error_function (file
)
1150 struct file_stack
*p
;
1152 if (need_error_newline
)
1154 fprintf (stderr
, "\n");
1155 need_error_newline
= 0;
1158 if (last_error_function
!= current_function_decl
)
1160 char *kind
= "function";
1161 if (current_function_decl
!= 0
1162 && TREE_CODE (TREE_TYPE (current_function_decl
)) == METHOD_TYPE
)
1166 fprintf (stderr
, "%s: ", file
);
1168 if (current_function_decl
== NULL
)
1169 fprintf (stderr
, "At top level:\n");
1172 char *name
= (*decl_printable_name
) (current_function_decl
, &kind
);
1173 fprintf (stderr
, "In %s `%s':\n", kind
, name
);
1176 last_error_function
= current_function_decl
;
1178 if (input_file_stack
&& input_file_stack
->next
!= 0
1179 && input_file_stack_tick
!= last_error_tick
)
1181 fprintf (stderr
, "In file included");
1182 for (p
= input_file_stack
->next
; p
; p
= p
->next
)
1184 fprintf (stderr
, " from %s:%d", p
->name
, p
->line
);
1186 fprintf (stderr
, ",\n ");
1188 fprintf (stderr
, ":\n");
1189 last_error_tick
= input_file_stack_tick
;
1193 /* Print a message. */
1196 vmessage (prefix
, s
, ap
)
1202 fprintf (stderr
, "%s: ", prefix
);
1205 vfprintf (stderr
, s
, ap
);
1208 HOST_WIDE_INT v1
= va_arg(ap
, HOST_WIDE_INT
);
1209 HOST_WIDE_INT v2
= va_arg(ap
, HOST_WIDE_INT
);
1210 HOST_WIDE_INT v3
= va_arg(ap
, HOST_WIDE_INT
);
1211 fprintf (stderr
, s
, v1
, v2
, v3
);
1216 /* Print a message relevant to line LINE of file FILE. */
1219 v_message_with_file_and_line (file
, line
, prefix
, s
, ap
)
1227 fprintf (stderr
, "%s:%d: ", file
, line
);
1229 fprintf (stderr
, "%s: ", progname
);
1231 vmessage (prefix
, s
, ap
);
1232 fputc ('\n', stderr
);
1235 /* Print a message relevant to the given DECL. */
1238 v_message_with_decl (decl
, prefix
, s
, ap
)
1246 fprintf (stderr
, "%s:%d: ",
1247 DECL_SOURCE_FILE (decl
), DECL_SOURCE_LINE (decl
));
1250 fprintf (stderr
, "%s: ", prefix
);
1252 /* Do magic to get around lack of varargs support for insertion
1253 of arguments into existing list. We know that the decl is first;
1254 we ass_u_me that it will be printed with "%s". */
1256 for (p
= s
; *p
; ++p
)
1260 if (*(p
+ 1) == '%')
1267 if (p
> s
) /* Print the left-hand substring. */
1269 char fmt
[sizeof "%.255s"];
1272 if (width
> 255L) width
= 255L; /* arbitrary */
1273 sprintf (fmt
, "%%.%lds", width
);
1274 fprintf (stderr
, fmt
, s
);
1277 if (*p
== '%') /* Print the name. */
1279 char *n
= (DECL_NAME (decl
)
1280 ? (*decl_printable_name
) (decl
, &junk
)
1286 if (isalpha (*(p
- 1) & 0xFF))
1291 if (*p
) /* Print the rest of the message. */
1292 vmessage ((char *)NULL
, p
, ap
);
1294 fputc ('\n', stderr
);
1297 /* Figure file and line of the given INSN. */
1300 file_and_line_for_asm (insn
, pfile
, pline
)
1305 rtx body
= PATTERN (insn
);
1308 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1309 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
1310 asmop
= SET_SRC (body
);
1311 else if (GET_CODE (body
) == ASM_OPERANDS
)
1313 else if (GET_CODE (body
) == PARALLEL
1314 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
)
1315 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
1316 else if (GET_CODE (body
) == PARALLEL
1317 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
1318 asmop
= XVECEXP (body
, 0, 0);
1324 *pfile
= ASM_OPERANDS_SOURCE_FILE (asmop
);
1325 *pline
= ASM_OPERANDS_SOURCE_LINE (asmop
);
1329 *pfile
= input_filename
;
1334 /* Report an error at line LINE of file FILE. */
1337 v_error_with_file_and_line (file
, line
, s
, ap
)
1344 report_error_function (file
);
1345 v_message_with_file_and_line (file
, line
, (char *)NULL
, s
, ap
);
1349 error_with_file_and_line
VPROTO((char *file
, int line
, char *s
, ...))
1361 file
= va_arg (ap
, char *);
1362 line
= va_arg (ap
, int);
1363 s
= va_arg (ap
, char *);
1366 v_error_with_file_and_line (file
, line
, s
, ap
);
1370 /* Report an error at the declaration DECL.
1371 S is a format string which uses %s to substitute the declaration
1372 name; subsequent substitutions are a la printf. */
1375 v_error_with_decl (decl
, s
, ap
)
1381 report_error_function (DECL_SOURCE_FILE (decl
));
1382 v_message_with_decl (decl
, (char *)NULL
, s
, ap
);
1386 error_with_decl
VPROTO((tree decl
, char *s
, ...))
1397 decl
= va_arg (ap
, tree
);
1398 s
= va_arg (ap
, char *);
1401 v_error_with_decl (decl
, s
, ap
);
1405 /* Report an error at the line number of the insn INSN.
1406 This is used only when INSN is an `asm' with operands,
1407 and each ASM_OPERANDS records its own source file and line. */
1410 v_error_for_asm (insn
, s
, ap
)
1419 file_and_line_for_asm (insn
, &file
, &line
);
1420 report_error_function (file
);
1421 v_message_with_file_and_line (file
, line
, (char *)NULL
, s
, ap
);
1425 error_for_asm
VPROTO((rtx insn
, char *s
, ...))
1436 insn
= va_arg (ap
, rtx
);
1437 s
= va_arg (ap
, char *);
1440 v_error_for_asm (insn
, s
, ap
);
1444 /* Report an error at the current line number. */
1451 v_error_with_file_and_line (input_filename
, lineno
, s
, ap
);
1455 error
VPROTO((char *s
, ...))
1465 s
= va_arg (ap
, char *);
1472 /* Report a fatal error at the current line number. */
1484 fatal
VPROTO((char *s
, ...))
1494 s
= va_arg (ap
, char *);
1501 /* Report a warning at line LINE of file FILE. */
1504 v_warning_with_file_and_line (file
, line
, s
, ap
)
1510 if (count_error (1))
1512 report_error_function (file
);
1513 v_message_with_file_and_line (file
, line
, "warning", s
, ap
);
1518 warning_with_file_and_line
VPROTO((char *file
, int line
, char *s
, ...))
1530 file
= va_arg (ap
, char *);
1531 line
= va_arg (ap
, int);
1532 s
= va_arg (ap
, char *);
1535 v_warning_with_file_and_line (file
, line
, s
, ap
);
1539 /* Report a warning at the declaration DECL.
1540 S is a format string which uses %s to substitute the declaration
1541 name; subsequent substitutions are a la printf. */
1544 v_warning_with_decl (decl
, s
, ap
)
1549 if (count_error (1))
1551 report_error_function (DECL_SOURCE_FILE (decl
));
1552 v_message_with_decl (decl
, "warning", s
, ap
);
1557 warning_with_decl
VPROTO((tree decl
, char *s
, ...))
1568 decl
= va_arg (ap
, tree
);
1569 s
= va_arg (ap
, char *);
1572 v_warning_with_decl (decl
, s
, ap
);
1576 /* Report a warning at the line number of the insn INSN.
1577 This is used only when INSN is an `asm' with operands,
1578 and each ASM_OPERANDS records its own source file and line. */
1581 v_warning_for_asm (insn
, s
, ap
)
1586 if (count_error (1))
1591 file_and_line_for_asm (insn
, &file
, &line
);
1592 report_error_function (file
);
1593 v_message_with_file_and_line (file
, line
, "warning", s
, ap
);
1598 warning_for_asm
VPROTO((rtx insn
, char *s
, ...))
1609 insn
= va_arg (ap
, rtx
);
1610 s
= va_arg (ap
, char *);
1613 v_warning_for_asm (insn
, s
, ap
);
1617 /* Report a warning at the current line number. */
1624 v_warning_with_file_and_line (input_filename
, lineno
, s
, ap
);
1628 warning
VPROTO((char *s
, ...))
1638 s
= va_arg (ap
, char *);
1645 /* These functions issue either warnings or errors depending on
1646 -pedantic-errors. */
1653 if (flag_pedantic_errors
)
1660 pedwarn
VPROTO((char *s
, ...))
1670 s
= va_arg (ap
, char *);
1678 v_pedwarn_with_decl (decl
, s
, ap
)
1683 /* We don't want -pedantic-errors to cause the compilation to fail from
1684 "errors" in system header files. Sometimes fixincludes can't fix what's
1685 broken (eg: unsigned char bitfields - fixing it may change the alignment
1686 which will cause programs to mysteriously fail because the C library
1687 or kernel uses the original layout). There's no point in issuing a
1688 warning either, it's just unnecessary noise. */
1690 if (! DECL_IN_SYSTEM_HEADER (decl
))
1692 if (flag_pedantic_errors
)
1693 v_error_with_decl (decl
, s
, ap
);
1695 v_warning_with_decl (decl
, s
, ap
);
1700 pedwarn_with_decl
VPROTO((tree decl
, char *s
, ...))
1711 decl
= va_arg (ap
, tree
);
1712 s
= va_arg (ap
, char *);
1715 v_pedwarn_with_decl (decl
, s
, ap
);
1720 v_pedwarn_with_file_and_line (file
, line
, s
, ap
)
1726 if (flag_pedantic_errors
)
1727 v_error_with_file_and_line (file
, line
, s
, ap
);
1729 v_warning_with_file_and_line (file
, line
, s
, ap
);
1733 pedwarn_with_file_and_line
VPROTO((char *file
, int line
, char *s
, ...))
1745 file
= va_arg (ap
, char *);
1746 line
= va_arg (ap
, int);
1747 s
= va_arg (ap
, char *);
1750 v_pedwarn_with_file_and_line (file
, line
, s
, ap
);
1754 /* Apologize for not implementing some feature. */
1763 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
1765 fprintf (stderr
, "%s: ", progname
);
1766 vmessage ("sorry, not implemented", s
, ap
);
1767 fputc ('\n', stderr
);
1771 sorry
VPROTO((char *s
, ...))
1781 s
= va_arg (ap
, char *);
1788 /* Apologize for not implementing some feature, then quit. */
1791 v_really_sorry (s
, ap
)
1797 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
1799 fprintf (stderr
, "%s: ", progname
);
1800 vmessage ("sorry, not implemented", s
, ap
);
1801 fatal (" (fatal)\n");
1805 really_sorry
VPROTO((char *s
, ...))
1815 s
= va_arg (ap
, char *);
1818 v_really_sorry (s
, ap
);
1822 /* More 'friendly' abort that prints the line and file.
1823 config.h can #define abort fancy_abort if you like that sort of thing.
1825 I don't think this is actually a good idea.
1826 Other sorts of crashes will look a certain way.
1827 It is a good thing if crashes from calling abort look the same way.
1833 fatal ("internal gcc abort");
1836 /* This calls abort and is used to avoid problems when abort if a macro.
1837 It is used when we need to pass the address of abort. */
1845 /* When `malloc.c' is compiled with `rcheck' defined,
1846 it calls this function to report clobberage. */
1854 /* Same as `malloc' but report error if no memory available. */
1860 register char *value
= (char *) malloc (size
);
1862 fatal ("virtual memory exhausted");
1866 /* Same as `realloc' but report error if no memory available. */
1869 xrealloc (ptr
, size
)
1873 char *result
= (char *) realloc (ptr
, size
);
1875 fatal ("virtual memory exhausted");
1879 /* Return the logarithm of X, base 2, considering X unsigned,
1880 if X is a power of 2. Otherwise, returns -1.
1882 This should be used via the `exact_log2' macro. */
1886 register unsigned HOST_WIDE_INT x
;
1888 register int log
= 0;
1889 /* Test for 0 or a power of 2. */
1890 if (x
== 0 || x
!= (x
& -x
))
1892 while ((x
>>= 1) != 0)
1897 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1898 If X is 0, return -1.
1900 This should be used via the floor_log2 macro. */
1904 register unsigned HOST_WIDE_INT x
;
1906 register int log
= -1;
1914 jmp_buf float_handler
;
1916 /* Specify where to longjmp to when a floating arithmetic error happens.
1917 If HANDLER is 0, it means don't handle the errors any more. */
1920 set_float_handler (handler
)
1923 float_handled
= (handler
!= 0);
1925 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
1928 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1929 error happens, pushing the previous specification into OLD_HANDLER.
1930 Return an indication of whether there was a previous handler in effect. */
1933 push_float_handler (handler
, old_handler
)
1934 jmp_buf handler
, old_handler
;
1936 int was_handled
= float_handled
;
1940 bcopy ((char *) float_handler
, (char *) old_handler
,
1941 sizeof (float_handler
));
1943 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
1947 /* Restore the previous specification of whether and where to longjmp to
1948 when a floating arithmetic error happens. */
1951 pop_float_handler (handled
, handler
)
1955 float_handled
= handled
;
1957 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
1960 /* Signals actually come here. */
1963 float_signal (signo
)
1964 /* If this is missing, some compilers complain. */
1967 if (float_handled
== 0)
1969 #if defined (USG) || defined (hpux)
1970 signal (SIGFPE
, float_signal
); /* re-enable the signal catcher */
1973 signal (SIGFPE
, float_signal
);
1974 longjmp (float_handler
, 1);
1977 /* Handler for SIGPIPE. */
1981 /* If this is missing, some compilers complain. */
1984 fatal ("output pipe has been closed");
1987 /* Strip off a legitimate source ending from the input string NAME of
1991 strip_off_ending (name
, len
)
1995 if (len
> 2 && ! strcmp (".c", name
+ len
- 2))
1997 else if (len
> 2 && ! strcmp (".m", name
+ len
- 2))
1999 else if (len
> 2 && ! strcmp (".i", name
+ len
- 2))
2001 else if (len
> 3 && ! strcmp (".ii", name
+ len
- 3))
2003 else if (len
> 3 && ! strcmp (".co", name
+ len
- 3))
2005 else if (len
> 3 && ! strcmp (".cc", name
+ len
- 3))
2007 else if (len
> 2 && ! strcmp (".C", name
+ len
- 2))
2009 else if (len
> 4 && ! strcmp (".cxx", name
+ len
- 4))
2011 else if (len
> 4 && ! strcmp (".cpp", name
+ len
- 4))
2013 else if (len
> 2 && ! strcmp (".f", name
+ len
- 2))
2015 /* Ada will use extensions like .ada, .adb, and .ads, so just test
2017 else if (len
> 4 && ! strncmp (".ad", name
+ len
- 4, 3))
2019 else if (len
> 4 && ! strcmp (".atr", name
+ len
- 4))
2023 /* Output a quoted string. */
2025 output_quoted_string (asm_file
, string
)
2031 putc ('\"', asm_file
);
2032 while ((c
= *string
++) != 0)
2034 if (c
== '\"' || c
== '\\')
2035 putc ('\\', asm_file
);
2038 putc ('\"', asm_file
);
2041 /* Output a file name in the form wanted by System V. */
2044 output_file_directive (asm_file
, input_name
)
2048 int len
= strlen (input_name
);
2049 char *na
= input_name
+ len
;
2051 /* NA gets INPUT_NAME sans directory names. */
2052 while (na
> input_name
)
2059 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2060 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file
, na
);
2062 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2063 ASM_OUTPUT_SOURCE_FILENAME (asm_file
, na
);
2065 fprintf (asm_file
, "\t.file\t");
2066 output_quoted_string (asm_file
, na
);
2067 fputc ('\n', asm_file
);
2072 /* Routine to build language identifier for object file. */
2074 output_lang_identify (asm_out_file
)
2077 int len
= strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2078 char *s
= (char *) alloca (len
);
2079 sprintf (s
, "__gnu_compiled_%s", lang_identify ());
2080 ASM_OUTPUT_LABEL (asm_out_file
, s
);
2083 /* Routine to open a dump file. */
2085 open_dump_file (base_name
, suffix
)
2090 char *dumpname
= (char *) alloca (strlen (base_name
) + strlen (suffix
) + 1);
2092 strcpy (dumpname
, base_name
);
2093 strcat (dumpname
, suffix
);
2094 f
= fopen (dumpname
, "w");
2096 pfatal_with_name (dumpname
);
2100 /* Compile an entire file of output from cpp, named NAME.
2101 Write a file of assembly output and various debugging dumps. */
2110 int name_specified
= name
!= 0;
2112 if (dump_base_name
== 0)
2113 dump_base_name
= name
? name
: "gccdump";
2117 integration_time
= 0;
2125 local_alloc_time
= 0;
2126 global_alloc_time
= 0;
2129 shorten_branch_time
= 0;
2135 /* Open input file. */
2137 if (name
== 0 || !strcmp (name
, "-"))
2143 finput
= fopen (name
, "r");
2145 pfatal_with_name (name
);
2147 #ifdef IO_BUFFER_SIZE
2148 setvbuf (finput
, (char *) xmalloc (IO_BUFFER_SIZE
), _IOFBF
, IO_BUFFER_SIZE
);
2151 /* Initialize data in various passes. */
2156 /* Some of these really don't need to be called when generating bytecode,
2157 but the options would have to be parsed first to know that. -bson */
2159 init_emit_once (debug_info_level
== DINFO_LEVEL_NORMAL
2160 || debug_info_level
== DINFO_LEVEL_VERBOSE
);
2162 init_decl_processing ();
2170 if (flag_caller_saves
)
2171 init_caller_save ();
2173 /* If auxiliary info generation is desired, open the output file.
2174 This goes in the same directory as the source file--unlike
2175 all the other output files. */
2176 if (flag_gen_aux_info
)
2178 aux_info_file
= fopen (aux_info_file_name
, "w");
2179 if (aux_info_file
== 0)
2180 pfatal_with_name (aux_info_file_name
);
2183 /* If rtl dump desired, open the output file. */
2185 rtl_dump_file
= open_dump_file (dump_base_name
, ".rtl");
2187 /* If jump_opt dump desired, open the output file. */
2189 jump_opt_dump_file
= open_dump_file (dump_base_name
, ".jump");
2191 /* If cse dump desired, open the output file. */
2193 cse_dump_file
= open_dump_file (dump_base_name
, ".cse");
2195 /* If loop dump desired, open the output file. */
2197 loop_dump_file
= open_dump_file (dump_base_name
, ".loop");
2199 /* If cse2 dump desired, open the output file. */
2201 cse2_dump_file
= open_dump_file (dump_base_name
, ".cse2");
2203 /* If flow dump desired, open the output file. */
2205 flow_dump_file
= open_dump_file (dump_base_name
, ".flow");
2207 /* If combine dump desired, open the output file. */
2209 combine_dump_file
= open_dump_file (dump_base_name
, ".combine");
2211 /* If scheduling dump desired, open the output file. */
2213 sched_dump_file
= open_dump_file (dump_base_name
, ".sched");
2215 /* If local_reg dump desired, open the output file. */
2217 local_reg_dump_file
= open_dump_file (dump_base_name
, ".lreg");
2219 /* If global_reg dump desired, open the output file. */
2220 if (global_reg_dump
)
2221 global_reg_dump_file
= open_dump_file (dump_base_name
, ".greg");
2223 /* If 2nd scheduling dump desired, open the output file. */
2225 sched2_dump_file
= open_dump_file (dump_base_name
, ".sched2");
2227 /* If jump2_opt dump desired, open the output file. */
2229 jump2_opt_dump_file
= open_dump_file (dump_base_name
, ".jump2");
2231 /* If dbr_sched dump desired, open the output file. */
2233 dbr_sched_dump_file
= open_dump_file (dump_base_name
, ".dbr");
2237 /* If stack_reg dump desired, open the output file. */
2239 stack_reg_dump_file
= open_dump_file (dump_base_name
, ".stack");
2243 /* Open assembler code output file. */
2245 if (! name_specified
&& asm_file_name
== 0)
2246 asm_out_file
= stdout
;
2249 int len
= strlen (dump_base_name
);
2250 register char *dumpname
= (char *) xmalloc (len
+ 6);
2251 strcpy (dumpname
, dump_base_name
);
2252 strip_off_ending (dumpname
, len
);
2253 strcat (dumpname
, ".s");
2254 if (asm_file_name
== 0)
2256 asm_file_name
= (char *) xmalloc (strlen (dumpname
) + 1);
2257 strcpy (asm_file_name
, dumpname
);
2259 if (!strcmp (asm_file_name
, "-"))
2260 asm_out_file
= stdout
;
2262 asm_out_file
= fopen (asm_file_name
, "w");
2263 if (asm_out_file
== 0)
2264 pfatal_with_name (asm_file_name
);
2267 #ifdef IO_BUFFER_SIZE
2268 setvbuf (asm_out_file
, (char *) xmalloc (IO_BUFFER_SIZE
),
2269 _IOFBF
, IO_BUFFER_SIZE
);
2272 input_filename
= name
;
2274 /* Put an entry on the input file stack for the main input file. */
2276 = (struct file_stack
*) xmalloc (sizeof (struct file_stack
));
2277 input_file_stack
->next
= 0;
2278 input_file_stack
->name
= input_filename
;
2280 /* Perform language-specific initialization.
2281 This may set main_input_filename. */
2284 /* If the input doesn't start with a #line, use the input name
2285 as the official input file name. */
2286 if (main_input_filename
== 0)
2287 main_input_filename
= name
;
2289 if (!output_bytecode
)
2291 ASM_FILE_START (asm_out_file
);
2294 /* Output something to inform GDB that this compilation was by GCC. Also
2295 serves to tell GDB file consists of bytecodes. */
2296 if (output_bytecode
)
2297 fprintf (asm_out_file
, "bc_gcc2_compiled.:\n");
2300 #ifndef ASM_IDENTIFY_GCC
2301 fprintf (asm_out_file
, "gcc2_compiled.:\n");
2303 ASM_IDENTIFY_GCC (asm_out_file
);
2307 /* Output something to identify which front-end produced this file. */
2308 #ifdef ASM_IDENTIFY_LANGUAGE
2309 ASM_IDENTIFY_LANGUAGE (asm_out_file
);
2312 if (output_bytecode
)
2314 if (profile_flag
|| profile_block_flag
)
2315 error ("profiling not supported in bytecode compilation");
2319 /* ??? Note: There used to be a conditional here
2320 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2321 This was to guarantee separation between gcc_compiled. and
2322 the first function, for the sake of dbx on Suns.
2323 However, having the extra zero here confused the Emacs
2324 code for unexec, and might confuse other programs too.
2325 Therefore, I took out that change.
2326 In future versions we should find another way to solve
2327 that dbx problem. -- rms, 23 May 93. */
2329 /* Don't let the first function fall at the same address
2330 as gcc_compiled., if profiling. */
2331 if (profile_flag
|| profile_block_flag
)
2332 assemble_zeros (UNITS_PER_WORD
);
2335 /* If dbx symbol table desired, initialize writing it
2336 and output the predefined types. */
2337 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2338 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2339 TIMEVAR (symout_time
, dbxout_init (asm_out_file
, main_input_filename
,
2342 #ifdef SDB_DEBUGGING_INFO
2343 if (write_symbols
== SDB_DEBUG
)
2344 TIMEVAR (symout_time
, sdbout_init (asm_out_file
, main_input_filename
,
2347 #ifdef DWARF_DEBUGGING_INFO
2348 if (write_symbols
== DWARF_DEBUG
)
2349 TIMEVAR (symout_time
, dwarfout_init (asm_out_file
, main_input_filename
));
2352 /* Initialize yet another pass. */
2354 if (!output_bytecode
)
2355 init_final (main_input_filename
);
2357 start_time
= get_run_time ();
2359 /* Call the parser, which parses the entire file
2360 (calling rest_of_compilation for each function). */
2362 if (yyparse () != 0)
2364 if (errorcount
== 0)
2365 fprintf (stderr
, "Errors detected in input file (your bison.simple is out of date)");
2367 /* In case there were missing closebraces,
2368 get us back to the global binding level. */
2369 while (! global_bindings_p ())
2373 /* Compilation is now finished except for writing
2374 what's left of the symbol table output. */
2376 parse_time
+= get_run_time () - start_time
;
2378 parse_time
-= integration_time
;
2379 parse_time
-= varconst_time
;
2381 globals
= getdecls ();
2383 /* Really define vars that have had only a tentative definition.
2384 Really output inline functions that must actually be callable
2385 and have not been output so far. */
2388 int len
= list_length (globals
);
2389 tree
*vec
= (tree
*) alloca (sizeof (tree
) * len
);
2394 /* Process the decls in reverse order--earliest first.
2395 Put them into VEC from back to front, then take out from front. */
2397 for (i
= 0, decl
= globals
; i
< len
; i
++, decl
= TREE_CHAIN (decl
))
2398 vec
[len
- i
- 1] = decl
;
2400 for (i
= 0; i
< len
; i
++)
2404 /* We're not deferring this any longer. */
2405 DECL_DEFER_OUTPUT (decl
) = 0;
2407 if (TREE_CODE (decl
) == VAR_DECL
&& DECL_SIZE (decl
) == 0
2408 && incomplete_decl_finalize_hook
!= 0)
2409 (*incomplete_decl_finalize_hook
) (decl
);
2412 /* Now emit any global variables or functions that we have been putting
2413 off. We need to loop in case one of the things emitted here
2414 references another one which comes earlier in the list. */
2418 for (i
= 0; i
< len
; i
++)
2422 if (TREE_ASM_WRITTEN (decl
) || DECL_EXTERNAL (decl
))
2425 /* Don't write out static consts, unless we still need them.
2427 We also keep static consts if not optimizing (for debugging).
2428 ??? They might be better written into the debug information.
2429 This is possible when using DWARF.
2431 A language processor that wants static constants to be always
2432 written out (even if it is not used) is responsible for
2433 calling rest_of_decl_compilation itself. E.g. the C front-end
2434 calls rest_of_decl_compilation from finish_decl.
2435 One motivation for this is that is conventional in some
2436 environments to write things like:
2437 static const char rcsid[] = "... version string ...";
2438 intending to force the string to be in the executable.
2440 A language processor that would prefer to have unneeded
2441 static constants "optimized away" would just defer writing
2442 them out until here. E.g. C++ does this, because static
2443 constants are often defined in header files.
2445 ??? A tempting alternative (for both C and C++) would be
2446 to force a constant to be written if and only if it is
2447 defined in a main file, as opposed to an include file. */
2449 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
2450 && (! TREE_READONLY (decl
)
2451 || TREE_PUBLIC (decl
)
2453 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
2456 rest_of_decl_compilation (decl
, NULL_PTR
, 1, 1);
2459 if (TREE_CODE (decl
) == FUNCTION_DECL
2460 && DECL_INITIAL (decl
) != 0
2461 && DECL_SAVED_INSNS (decl
) != 0
2462 && (flag_keep_inline_functions
2463 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
2466 temporary_allocation ();
2467 output_inline_function (decl
);
2468 permanent_allocation (1);
2473 for (i
= 0; i
< len
; i
++)
2477 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
2478 && ! TREE_ASM_WRITTEN (decl
))
2479 /* Cancel the RTL for this decl so that, if debugging info
2480 output for global variables is still to come,
2481 this one will be omitted. */
2482 DECL_RTL (decl
) = NULL
;
2484 /* Warn about any function
2485 declared static but not defined.
2486 We don't warn about variables,
2487 because many programs have static variables
2488 that exist only to get some text into the object file. */
2489 if (TREE_CODE (decl
) == FUNCTION_DECL
2491 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
2492 && DECL_INITIAL (decl
) == 0
2493 && DECL_EXTERNAL (decl
)
2494 && ! TREE_PUBLIC (decl
))
2496 pedwarn_with_decl (decl
,
2497 "`%s' declared `static' but never defined");
2498 /* This symbol is effectively an "extern" declaration now. */
2499 TREE_PUBLIC (decl
) = 1;
2500 assemble_external (decl
);
2503 /* Warn about static fns or vars defined but not used,
2504 but not about inline functions or static consts
2505 since defining those in header files is normal practice. */
2507 && ((TREE_CODE (decl
) == FUNCTION_DECL
&& ! DECL_INLINE (decl
))
2508 || (TREE_CODE (decl
) == VAR_DECL
&& ! TREE_READONLY (decl
)))
2509 && ! DECL_IN_SYSTEM_HEADER (decl
)
2510 && ! DECL_EXTERNAL (decl
)
2511 && ! TREE_PUBLIC (decl
)
2512 && ! TREE_USED (decl
)
2513 && ! DECL_REGISTER (decl
)
2514 /* The TREE_USED bit for file-scope decls
2515 is kept in the identifier, to handle multiple
2516 external decls in different scopes. */
2517 && ! TREE_USED (DECL_NAME (decl
)))
2518 warning_with_decl (decl
, "`%s' defined but not used");
2520 #ifdef SDB_DEBUGGING_INFO
2521 /* The COFF linker can move initialized global vars to the end.
2522 And that can screw up the symbol ordering.
2523 By putting the symbols in that order to begin with,
2524 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2525 if (write_symbols
== SDB_DEBUG
&& TREE_CODE (decl
) == VAR_DECL
2526 && TREE_PUBLIC (decl
) && DECL_INITIAL (decl
)
2527 && ! DECL_EXTERNAL (decl
)
2528 && DECL_RTL (decl
) != 0)
2529 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
2531 /* Output COFF information for non-global
2532 file-scope initialized variables. */
2533 if (write_symbols
== SDB_DEBUG
2534 && TREE_CODE (decl
) == VAR_DECL
2535 && DECL_INITIAL (decl
)
2536 && ! DECL_EXTERNAL (decl
)
2537 && DECL_RTL (decl
) != 0
2538 && GET_CODE (DECL_RTL (decl
)) == MEM
)
2539 TIMEVAR (symout_time
, sdbout_toplevel_data (decl
));
2540 #endif /* SDB_DEBUGGING_INFO */
2541 #ifdef DWARF_DEBUGGING_INFO
2542 /* Output DWARF information for file-scope tentative data object
2543 declarations, file-scope (extern) function declarations (which
2544 had no corresponding body) and file-scope tagged type declarations
2545 and definitions which have not yet been forced out. */
2547 if (write_symbols
== DWARF_DEBUG
2548 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
2549 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 1));
2554 /* Do dbx symbols */
2555 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2556 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2557 TIMEVAR (symout_time
,
2559 dbxout_finish (asm_out_file
, main_input_filename
);
2563 #ifdef DWARF_DEBUGGING_INFO
2564 if (write_symbols
== DWARF_DEBUG
)
2565 TIMEVAR (symout_time
,
2571 /* Output some stuff at end of file if nec. */
2573 if (!output_bytecode
)
2575 end_final (main_input_filename
);
2578 ASM_FILE_END (asm_out_file
);
2582 /* Language-specific end of compilation actions. */
2586 if (output_bytecode
)
2587 bc_write_file (asm_out_file
);
2589 /* Close the dump files. */
2591 if (flag_gen_aux_info
)
2593 fclose (aux_info_file
);
2595 unlink (aux_info_file_name
);
2599 fclose (rtl_dump_file
);
2602 fclose (jump_opt_dump_file
);
2605 fclose (cse_dump_file
);
2608 fclose (loop_dump_file
);
2611 fclose (cse2_dump_file
);
2614 fclose (flow_dump_file
);
2618 dump_combine_total_stats (combine_dump_file
);
2619 fclose (combine_dump_file
);
2623 fclose (sched_dump_file
);
2626 fclose (local_reg_dump_file
);
2628 if (global_reg_dump
)
2629 fclose (global_reg_dump_file
);
2632 fclose (sched2_dump_file
);
2635 fclose (jump2_opt_dump_file
);
2638 fclose (dbr_sched_dump_file
);
2642 fclose (stack_reg_dump_file
);
2645 /* Close non-debugging input and output files. Take special care to note
2646 whether fclose returns an error, since the pages might still be on the
2647 buffer chain while the file is open. */
2650 if (ferror (asm_out_file
) != 0 || fclose (asm_out_file
) != 0)
2651 fatal_io_error (asm_file_name
);
2653 /* Print the times. */
2657 fprintf (stderr
,"\n");
2658 print_time ("parse", parse_time
);
2660 if (!output_bytecode
)
2662 print_time ("integration", integration_time
);
2663 print_time ("jump", jump_time
);
2664 print_time ("cse", cse_time
);
2665 print_time ("loop", loop_time
);
2666 print_time ("cse2", cse2_time
);
2667 print_time ("flow", flow_time
);
2668 print_time ("combine", combine_time
);
2669 print_time ("sched", sched_time
);
2670 print_time ("local-alloc", local_alloc_time
);
2671 print_time ("global-alloc", global_alloc_time
);
2672 print_time ("sched2", sched2_time
);
2673 print_time ("dbranch", dbr_sched_time
);
2674 print_time ("shorten-branch", shorten_branch_time
);
2675 print_time ("stack-reg", stack_reg_time
);
2676 print_time ("final", final_time
);
2677 print_time ("varconst", varconst_time
);
2678 print_time ("symout", symout_time
);
2679 print_time ("dump", dump_time
);
2684 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2685 and TYPE_DECL nodes.
2687 This does nothing for local (non-static) variables.
2688 Otherwise, it sets up the RTL and outputs any assembler code
2689 (label definition, storage allocation and initialization).
2691 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2692 the assembler symbol name to be used. TOP_LEVEL is nonzero
2693 if this declaration is not within a function. */
2696 rest_of_decl_compilation (decl
, asmspec
, top_level
, at_end
)
2702 /* Declarations of variables, and of functions defined elsewhere. */
2704 /* The most obvious approach, to put an #ifndef around where
2705 this macro is used, doesn't work since it's inside a macro call. */
2706 #ifndef ASM_FINISH_DECLARE_OBJECT
2707 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2710 /* Forward declarations for nested functions are not "external",
2711 but we need to treat them as if they were. */
2712 if (TREE_STATIC (decl
) || DECL_EXTERNAL (decl
)
2713 || TREE_CODE (decl
) == FUNCTION_DECL
)
2714 TIMEVAR (varconst_time
,
2716 make_decl_rtl (decl
, asmspec
, top_level
);
2717 /* Initialized extern variable exists to be replaced
2718 with its value, or represents something that will be
2719 output in another file. */
2720 if (! (TREE_CODE (decl
) == VAR_DECL
2721 && DECL_EXTERNAL (decl
) && TREE_READONLY (decl
)
2722 && DECL_INITIAL (decl
) != 0
2723 && DECL_INITIAL (decl
) != error_mark_node
))
2724 /* Don't output anything
2725 when a tentative file-scope definition is seen.
2726 But at end of compilation, do output code for them. */
2727 if (! (! at_end
&& top_level
2728 && (DECL_INITIAL (decl
) == 0
2729 || DECL_INITIAL (decl
) == error_mark_node
)))
2730 assemble_variable (decl
, top_level
, at_end
, 0);
2731 if (decl
== last_assemble_variable_decl
)
2733 ASM_FINISH_DECLARE_OBJECT (asm_out_file
, decl
,
2737 else if (DECL_REGISTER (decl
) && asmspec
!= 0)
2739 if (decode_reg_name (asmspec
) >= 0)
2741 DECL_RTL (decl
) = 0;
2742 make_decl_rtl (decl
, asmspec
, top_level
);
2745 error ("invalid register name `%s' for register variable", asmspec
);
2747 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2748 else if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2749 && TREE_CODE (decl
) == TYPE_DECL
)
2750 TIMEVAR (symout_time
, dbxout_symbol (decl
, 0));
2752 #ifdef SDB_DEBUGGING_INFO
2753 else if (write_symbols
== SDB_DEBUG
&& top_level
2754 && TREE_CODE (decl
) == TYPE_DECL
)
2755 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
2759 /* Called after finishing a record, union or enumeral type. */
2762 rest_of_type_compilation (type
, toplev
)
2766 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2767 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2768 TIMEVAR (symout_time
, dbxout_symbol (TYPE_STUB_DECL (type
), !toplev
));
2770 #ifdef SDB_DEBUGGING_INFO
2771 if (write_symbols
== SDB_DEBUG
)
2772 TIMEVAR (symout_time
, sdbout_symbol (TYPE_STUB_DECL (type
), !toplev
));
2776 /* This is called from finish_function (within yyparse)
2777 after each top-level definition is parsed.
2778 It is supposed to compile that function or variable
2779 and output the assembler code for it.
2780 After we return, the tree storage is freed. */
2783 rest_of_compilation (decl
)
2787 int start_time
= get_run_time ();
2789 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2790 to be restored after we finish compiling the function
2791 (for use when compiling inline calls to this function). */
2792 tree saved_block_tree
= 0;
2793 /* Likewise, for DECL_ARGUMENTS. */
2794 tree saved_arguments
= 0;
2797 if (output_bytecode
)
2800 /* If we are reconsidering an inline function
2801 at the end of compilation, skip the stuff for making it inline. */
2803 if (DECL_SAVED_INSNS (decl
) == 0)
2805 int specd
= DECL_INLINE (decl
);
2808 /* If requested, consider whether to make this function inline. */
2809 if (specd
|| flag_inline_functions
)
2810 TIMEVAR (integration_time
,
2812 lose
= function_cannot_inline_p (decl
);
2813 /* If not optimzing, then make sure the DECL_INLINE
2815 if (lose
|| ! optimize
)
2817 if (warn_inline
&& specd
)
2818 warning_with_decl (decl
, lose
);
2819 DECL_INLINE (decl
) = 0;
2820 DECL_ABSTRACT_ORIGIN (decl
) = 0;
2821 /* Don't really compile an extern inline function.
2822 If we can't make it inline, pretend
2823 it was only declared. */
2824 if (DECL_EXTERNAL (decl
))
2826 DECL_INITIAL (decl
) = 0;
2827 goto exit_rest_of_compilation
;
2831 DECL_INLINE (decl
) = 1;
2834 insns
= get_insns ();
2836 /* Dump the rtl code if we are dumping rtl. */
2841 fprintf (rtl_dump_file
, "\n;; Function %s\n\n",
2842 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2843 if (DECL_SAVED_INSNS (decl
))
2844 fprintf (rtl_dump_file
, ";; (integrable)\n\n");
2845 print_rtl (rtl_dump_file
, insns
);
2846 fflush (rtl_dump_file
);
2849 /* If function is inline, and we don't yet know whether to
2850 compile it by itself, defer decision till end of compilation.
2851 finish_compilation will call rest_of_compilation again
2852 for those functions that need to be output. Also defer those
2853 functions that we are supposed to defer. */
2855 if (DECL_DEFER_OUTPUT (decl
)
2856 || (DECL_INLINE (decl
)
2857 && ((! TREE_PUBLIC (decl
) && ! TREE_ADDRESSABLE (decl
)
2858 && ! flag_keep_inline_functions
)
2859 || DECL_EXTERNAL (decl
))))
2861 #ifdef DWARF_DEBUGGING_INFO
2862 /* Generate the DWARF info for the "abstract" instance
2863 of a function which we may later generate inlined and/or
2864 out-of-line instances of. */
2865 if (write_symbols
== DWARF_DEBUG
)
2867 set_decl_abstract_flags (decl
, 1);
2868 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
2869 set_decl_abstract_flags (decl
, 0);
2872 TIMEVAR (integration_time
, save_for_inline_nocopy (decl
));
2873 goto exit_rest_of_compilation
;
2876 /* If we have to compile the function now, save its rtl and subdecls
2877 so that its compilation will not affect what others get. */
2878 if (DECL_INLINE (decl
))
2880 #ifdef DWARF_DEBUGGING_INFO
2881 /* Generate the DWARF info for the "abstract" instance of
2882 a function which we will generate an out-of-line instance
2883 of almost immediately (and which we may also later generate
2884 various inlined instances of). */
2885 if (write_symbols
== DWARF_DEBUG
)
2887 set_decl_abstract_flags (decl
, 1);
2888 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
2889 set_decl_abstract_flags (decl
, 0);
2892 saved_block_tree
= DECL_INITIAL (decl
);
2893 saved_arguments
= DECL_ARGUMENTS (decl
);
2894 TIMEVAR (integration_time
, save_for_inline_copying (decl
));
2897 /* If specified extern inline but we aren't inlining it, we are
2899 if (specd
&& DECL_EXTERNAL (decl
))
2900 goto exit_rest_of_compilation
;
2903 TREE_ASM_WRITTEN (decl
) = 1;
2905 /* Now that integrate will no longer see our rtl, we need not distinguish
2906 between the return value of this function and the return value of called
2908 rtx_equal_function_value_matters
= 0;
2910 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2911 if ((rtl_dump_and_exit
|| flag_syntax_only
) && !warn_return_type
)
2913 goto exit_rest_of_compilation
;
2916 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2917 Note that that may have been done above, in save_for_inline_copying.
2918 The call to resume_temporary_allocation near the end of this function
2919 goes back to the usual state of affairs. */
2921 rtl_in_current_obstack ();
2924 /* If we are doing position-independent code generation, now
2925 is the time to output special prologues and epilogues.
2926 We do not want to do this earlier, because it just clutters
2927 up inline functions with meaningless insns. */
2932 insns
= get_insns ();
2934 /* Copy any shared structure that should not be shared. */
2936 unshare_all_rtl (insns
);
2938 /* Instantiate all virtual registers. */
2940 instantiate_virtual_regs (current_function_decl
, get_insns ());
2942 /* See if we have allocated stack slots that are not directly addressable.
2943 If so, scan all the insns and create explicit address computation
2944 for all references to such slots. */
2945 /* fixup_stack_slots (); */
2947 /* Do jump optimization the first time, if -opt.
2948 Also do it if -W, but in that case it doesn't change the rtl code,
2949 it only computes whether control can drop off the end of the function. */
2951 if (optimize
> 0 || extra_warnings
|| warn_return_type
2952 /* If function is `noreturn', we should warn if it tries to return. */
2953 || TREE_THIS_VOLATILE (decl
))
2955 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
2956 TIMEVAR (jump_time
, jump_optimize (insns
, 0, 0, 1));
2959 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2960 if (rtl_dump_and_exit
|| flag_syntax_only
)
2961 goto exit_rest_of_compilation
;
2963 /* Dump rtl code after jump, if we are doing that. */
2968 fprintf (jump_opt_dump_file
, "\n;; Function %s\n\n",
2969 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2970 print_rtl (jump_opt_dump_file
, insns
);
2971 fflush (jump_opt_dump_file
);
2974 /* Perform common subexpression elimination.
2975 Nonzero value from `cse_main' means that jumps were simplified
2976 and some code may now be unreachable, so do
2977 jump optimization again. */
2982 fprintf (cse_dump_file
, "\n;; Function %s\n\n",
2983 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2988 TIMEVAR (cse_time
, reg_scan (insns
, max_reg_num (), 1));
2990 if (flag_thread_jumps
)
2991 /* Hacks by tiemann & kenner. */
2992 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 1));
2994 TIMEVAR (cse_time
, tem
= cse_main (insns
, max_reg_num (),
2996 TIMEVAR (cse_time
, delete_dead_from_cse (insns
, max_reg_num ()));
2998 if (tem
|| optimize
> 1)
2999 TIMEVAR (jump_time
, jump_optimize (insns
, 0, 0, 0));
3002 /* Dump rtl code after cse, if we are doing that. */
3007 print_rtl (cse_dump_file
, insns
);
3008 fflush (cse_dump_file
);
3014 fprintf (loop_dump_file
, "\n;; Function %s\n\n",
3015 IDENTIFIER_POINTER (DECL_NAME (decl
)));
3018 /* Move constant computations out of loops. */
3024 loop_optimize (insns
, loop_dump_file
);
3028 /* Dump rtl code after loop opt, if we are doing that. */
3033 print_rtl (loop_dump_file
, insns
);
3034 fflush (loop_dump_file
);
3040 fprintf (cse2_dump_file
, "\n;; Function %s\n\n",
3041 IDENTIFIER_POINTER (DECL_NAME (decl
)));
3044 if (optimize
> 0 && flag_rerun_cse_after_loop
)
3046 /* Running another jump optimization pass before the second
3047 cse pass sometimes simplifies the RTL enough to allow
3048 the second CSE pass to do a better job. Jump_optimize can change
3049 max_reg_num so we must rerun reg_scan afterwards.
3050 ??? Rework to not call reg_scan so often. */
3051 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3052 TIMEVAR (jump_time
, jump_optimize (insns
, 0, 0, 1));
3054 TIMEVAR (cse2_time
, reg_scan (insns
, max_reg_num (), 0));
3055 TIMEVAR (cse2_time
, tem
= cse_main (insns
, max_reg_num (),
3056 1, cse2_dump_file
));
3058 TIMEVAR (jump_time
, jump_optimize (insns
, 0, 0, 0));
3061 if (optimize
> 0 && flag_thread_jumps
)
3062 /* This pass of jump threading straightens out code
3063 that was kinked by loop optimization. */
3064 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 0));
3066 /* Dump rtl code after cse, if we are doing that. */
3071 print_rtl (cse2_dump_file
, insns
);
3072 fflush (cse2_dump_file
);
3075 /* We are no longer anticipating cse in this function, at least. */
3077 cse_not_expected
= 1;
3079 /* Now we choose between stupid (pcc-like) register allocation
3080 (if we got the -noreg switch and not -opt)
3081 and smart register allocation. */
3083 if (optimize
> 0) /* Stupid allocation probably won't work */
3084 obey_regdecls
= 0; /* if optimizations being done. */
3088 /* Print function header into flow dump now
3089 because doing the flow analysis makes some of the dump. */
3094 fprintf (flow_dump_file
, "\n;; Function %s\n\n",
3095 IDENTIFIER_POINTER (DECL_NAME (decl
)));
3102 regclass (insns
, max_reg_num ());
3103 stupid_life_analysis (insns
, max_reg_num (),
3109 /* Do control and data flow analysis,
3110 and write some of the results to dump file. */
3112 TIMEVAR (flow_time
, flow_analysis (insns
, max_reg_num (),
3114 if (warn_uninitialized
)
3116 uninitialized_vars_warning (DECL_INITIAL (decl
));
3117 setjmp_args_warning ();
3121 /* Dump rtl after flow analysis. */
3126 print_rtl (flow_dump_file
, insns
);
3127 fflush (flow_dump_file
);
3130 /* If -opt, try combining insns through substitution. */
3133 TIMEVAR (combine_time
, combine_instructions (insns
, max_reg_num ()));
3135 /* Dump rtl code after insn combination. */
3140 fprintf (combine_dump_file
, "\n;; Function %s\n\n",
3141 IDENTIFIER_POINTER (DECL_NAME (decl
)));
3142 dump_combine_stats (combine_dump_file
);
3143 print_rtl (combine_dump_file
, insns
);
3144 fflush (combine_dump_file
);
3147 /* Print function header into sched dump now
3148 because doing the sched analysis makes some of the dump. */
3153 fprintf (sched_dump_file
, "\n;; Function %s\n\n",
3154 IDENTIFIER_POINTER (DECL_NAME (decl
)));
3157 if (optimize
> 0 && flag_schedule_insns
)
3159 /* Do control and data sched analysis,
3160 and write some of the results to dump file. */
3162 TIMEVAR (sched_time
, schedule_insns (sched_dump_file
));
3165 /* Dump rtl after instruction scheduling. */
3170 print_rtl (sched_dump_file
, insns
);
3171 fflush (sched_dump_file
);
3174 /* Unless we did stupid register allocation,
3175 allocate pseudo-regs that are used only within 1 basic block. */
3178 TIMEVAR (local_alloc_time
,
3180 regclass (insns
, max_reg_num ());
3184 /* Dump rtl code after allocating regs within basic blocks. */
3189 fprintf (local_reg_dump_file
, "\n;; Function %s\n\n",
3190 IDENTIFIER_POINTER (DECL_NAME (decl
)));
3191 dump_flow_info (local_reg_dump_file
);
3192 dump_local_alloc (local_reg_dump_file
);
3193 print_rtl (local_reg_dump_file
, insns
);
3194 fflush (local_reg_dump_file
);
3197 if (global_reg_dump
)
3199 fprintf (global_reg_dump_file
, "\n;; Function %s\n\n",
3200 IDENTIFIER_POINTER (DECL_NAME (decl
))));
3202 /* Unless we did stupid register allocation,
3203 allocate remaining pseudo-regs, then do the reload pass
3204 fixing up any insns that are invalid. */
3206 TIMEVAR (global_alloc_time
,
3209 failure
= global_alloc (global_reg_dump_file
);
3211 failure
= reload (insns
, 0, global_reg_dump_file
);
3214 if (global_reg_dump
)
3217 dump_global_regs (global_reg_dump_file
);
3218 print_rtl (global_reg_dump_file
, insns
);
3219 fflush (global_reg_dump_file
);
3223 goto exit_rest_of_compilation
;
3225 reload_completed
= 1;
3227 /* On some machines, the prologue and epilogue code, or parts thereof,
3228 can be represented as RTL. Doing so lets us schedule insns between
3229 it and the rest of the code and also allows delayed branch
3230 scheduling to operate in the epilogue. */
3232 thread_prologue_and_epilogue_insns (insns
);
3234 if (optimize
> 0 && flag_schedule_insns_after_reload
)
3239 fprintf (sched2_dump_file
, "\n;; Function %s\n\n",
3240 IDENTIFIER_POINTER (DECL_NAME (decl
)));
3243 /* Do control and data sched analysis again,
3244 and write some more of the results to dump file. */
3246 TIMEVAR (sched2_time
, schedule_insns (sched2_dump_file
));
3248 /* Dump rtl after post-reorder instruction scheduling. */
3253 print_rtl (sched2_dump_file
, insns
);
3254 fflush (sched2_dump_file
);
3258 #ifdef LEAF_REGISTERS
3260 if (optimize
> 0 && only_leaf_regs_used () && leaf_function_p ())
3264 /* One more attempt to remove jumps to .+1
3265 left by dead-store-elimination.
3266 Also do cross-jumping this time
3267 and delete no-op move insns. */
3271 TIMEVAR (jump_time
, jump_optimize (insns
, 1, 1, 0));
3274 /* Dump rtl code after jump, if we are doing that. */
3279 fprintf (jump2_opt_dump_file
, "\n;; Function %s\n\n",
3280 IDENTIFIER_POINTER (DECL_NAME (decl
)));
3281 print_rtl (jump2_opt_dump_file
, insns
);
3282 fflush (jump2_opt_dump_file
);
3285 /* If a machine dependent reorganization is needed, call it. */
3286 #ifdef MACHINE_DEPENDENT_REORG
3287 MACHINE_DEPENDENT_REORG (insns
);
3290 /* If a scheduling pass for delayed branches is to be done,
3291 call the scheduling code. */
3294 if (optimize
> 0 && flag_delayed_branch
)
3296 TIMEVAR (dbr_sched_time
, dbr_schedule (insns
, dbr_sched_dump_file
));
3301 fprintf (dbr_sched_dump_file
, "\n;; Function %s\n\n",
3302 IDENTIFIER_POINTER (DECL_NAME (decl
)));
3303 print_rtl (dbr_sched_dump_file
, insns
);
3304 fflush (dbr_sched_dump_file
);
3311 /* Shorten branches. */
3312 TIMEVAR (shorten_branch_time
,
3314 shorten_branches (get_insns ());
3318 TIMEVAR (stack_reg_time
, reg_to_stack (insns
, stack_reg_dump_file
));
3323 fprintf (stack_reg_dump_file
, "\n;; Function %s\n\n",
3324 IDENTIFIER_POINTER (DECL_NAME (decl
)));
3325 print_rtl (stack_reg_dump_file
, insns
);
3326 fflush (stack_reg_dump_file
);
3331 /* Now turn the rtl into assembler code. */
3333 TIMEVAR (final_time
,
3338 /* Get the function's name, as described by its RTL.
3339 This may be different from the DECL_NAME name used
3340 in the source file. */
3342 x
= DECL_RTL (decl
);
3343 if (GET_CODE (x
) != MEM
)
3346 if (GET_CODE (x
) != SYMBOL_REF
)
3348 fnname
= XSTR (x
, 0);
3350 assemble_start_function (decl
, fnname
);
3351 final_start_function (insns
, asm_out_file
, optimize
);
3352 final (insns
, asm_out_file
, optimize
, 0);
3353 final_end_function (insns
, asm_out_file
, optimize
);
3354 assemble_end_function (decl
, fnname
);
3355 fflush (asm_out_file
);
3358 /* Write DBX symbols if requested */
3360 /* Note that for those inline functions where we don't initially
3361 know for certain that we will be generating an out-of-line copy,
3362 the first invocation of this routine (rest_of_compilation) will
3363 skip over this code by doing a `goto exit_rest_of_compilation;'.
3364 Later on, finish_compilation will call rest_of_compilation again
3365 for those inline functions that need to have out-of-line copies
3366 generated. During that call, we *will* be routed past here. */
3368 #ifdef DBX_DEBUGGING_INFO
3369 if (write_symbols
== DBX_DEBUG
)
3370 TIMEVAR (symout_time
, dbxout_function (decl
));
3373 #ifdef DWARF_DEBUGGING_INFO
3374 if (write_symbols
== DWARF_DEBUG
)
3375 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
3378 exit_rest_of_compilation
:
3380 /* In case the function was not output,
3381 don't leave any temporary anonymous types
3382 queued up for sdb output. */
3383 #ifdef SDB_DEBUGGING_INFO
3384 if (write_symbols
== SDB_DEBUG
)
3385 sdbout_types (NULL_TREE
);
3388 /* Put back the tree of subblocks and list of arguments
3389 from before we copied them.
3390 Code generation and the output of debugging info may have modified
3391 the copy, but the original is unchanged. */
3393 if (saved_block_tree
!= 0)
3394 DECL_INITIAL (decl
) = saved_block_tree
;
3395 if (saved_arguments
!= 0)
3396 DECL_ARGUMENTS (decl
) = saved_arguments
;
3398 reload_completed
= 0;
3400 /* Clear out the real_constant_chain before some of the rtx's
3401 it runs through become garbage. */
3403 clear_const_double_mem ();
3405 /* Cancel the effect of rtl_in_current_obstack. */
3407 resume_temporary_allocation ();
3409 /* The parsing time is all the time spent in yyparse
3410 *except* what is spent in this function. */
3412 parse_time
-= get_run_time () - start_time
;
3415 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3416 Exit code is 35 if can't open files, 34 if fatal error,
3417 33 if had nonfatal errors, else success. */
3420 main (argc
, argv
, envp
)
3427 int flag_print_mem
= 0;
3428 int version_flag
= 0;
3431 /* save in case md file wants to emit args as a comment. */
3435 p
= argv
[0] + strlen (argv
[0]);
3436 while (p
!= argv
[0] && p
[-1] != '/'
3437 #ifdef DIR_SEPARATOR
3438 && p
[-1] != DIR_SEPARATOR
3445 /* Get rid of any avoidable limit on stack size. */
3449 /* Set the stack limit huge so that alloca does not fail. */
3450 getrlimit (RLIMIT_STACK
, &rlim
);
3451 rlim
.rlim_cur
= rlim
.rlim_max
;
3452 setrlimit (RLIMIT_STACK
, &rlim
);
3454 #endif /* RLIMIT_STACK */
3456 signal (SIGFPE
, float_signal
);
3459 signal (SIGPIPE
, pipe_closed
);
3462 decl_printable_name
= decl_name
;
3463 lang_expand_expr
= (struct rtx_def
*(*)()) do_abort
;
3464 interim_eh_hook
= interim_eh
;
3466 /* Initialize whether `char' is signed. */
3467 flag_signed_char
= DEFAULT_SIGNED_CHAR
;
3468 #ifdef DEFAULT_SHORT_ENUMS
3469 /* Initialize how much space enums occupy, by default. */
3470 flag_short_enums
= DEFAULT_SHORT_ENUMS
;
3473 /* Scan to see what optimization level has been specified. That will
3474 determine the default value of many flags. */
3475 for (i
= 1; i
< argc
; i
++)
3477 if (!strcmp (argv
[i
], "-O"))
3481 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'O')
3483 /* Handle -O2, -O3, -O69, ... */
3484 char *p
= &argv
[i
][2];
3488 if (! (c
>= '0' && c
<= '9'))
3491 optimize
= atoi (&argv
[i
][2]);
3495 obey_regdecls
= (optimize
== 0);
3505 flag_thread_jumps
= 1;
3507 flag_delayed_branch
= 1;
3509 #ifdef CAN_DEBUG_WITHOUT_FP
3510 flag_omit_frame_pointer
= 1;
3516 flag_cse_follow_jumps
= 1;
3517 flag_cse_skip_blocks
= 1;
3518 flag_expensive_optimizations
= 1;
3519 flag_strength_reduce
= 1;
3520 flag_rerun_cse_after_loop
= 1;
3521 flag_caller_saves
= 1;
3522 #ifdef INSN_SCHEDULING
3523 flag_schedule_insns
= 1;
3524 flag_schedule_insns_after_reload
= 1;
3530 flag_inline_functions
= 1;
3533 #ifdef OPTIMIZATION_OPTIONS
3534 /* Allow default optimizations to be specified on a per-machine basis. */
3535 OPTIMIZATION_OPTIONS (optimize
);
3538 /* Initialize register usage now so switches may override. */
3542 set_target_switch ("");
3544 for (i
= 1; i
< argc
; i
++)
3547 /* If this is a language-specific option,
3548 decode it in a language-specific way. */
3549 for (j
= 0; lang_options
[j
] != 0; j
++)
3550 if (!strncmp (argv
[i
], lang_options
[j
],
3551 strlen (lang_options
[j
])))
3553 if (lang_options
[j
] != 0)
3554 /* If the option is valid for *some* language,
3555 treat it as valid even if this language doesn't understand it. */
3556 lang_decode_option (argv
[i
]);
3557 else if (argv
[i
][0] == '-' && argv
[i
][1] != 0)
3559 register char *str
= argv
[i
] + 1;
3564 set_target_switch (&str
[1]);
3565 else if (!strcmp (str
, "dumpbase"))
3567 dump_base_name
= argv
[++i
];
3569 else if (str
[0] == 'd')
3571 register char *p
= &str
[1];
3579 global_reg_dump
= 1;
3585 cse_dump
= 1, cse2_dump
= 1;
3603 global_reg_dump
= 1;
3621 flag_print_asm_name
= 1;
3643 rtl_dump_and_exit
= 1;
3647 else if (str
[0] == 'f')
3649 register char *p
= &str
[1];
3652 /* Some kind of -f option.
3653 P's value is the option sans `-f'.
3654 Search for it in the table of options. */
3657 !found
&& j
< sizeof (f_options
) / sizeof (f_options
[0]);
3660 if (!strcmp (p
, f_options
[j
].string
))
3662 *f_options
[j
].variable
= f_options
[j
].on_value
;
3663 /* A goto here would be cleaner,
3664 but breaks the vax pcc. */
3667 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
3668 && ! strcmp (p
+3, f_options
[j
].string
))
3670 *f_options
[j
].variable
= ! f_options
[j
].on_value
;
3677 else if (!strncmp (p
, "fixed-", 6))
3678 fix_register (&p
[6], 1, 1);
3679 else if (!strncmp (p
, "call-used-", 10))
3680 fix_register (&p
[10], 0, 1);
3681 else if (!strncmp (p
, "call-saved-", 11))
3682 fix_register (&p
[11], 0, 0);
3684 error ("Invalid option `%s'", argv
[i
]);
3686 else if (str
[0] == 'O')
3688 register char *p
= str
+1;
3689 while (*p
&& *p
>= '0' && *p
<= '9')
3694 error ("Invalid option `%s'", argv
[i
]);
3696 else if (!strcmp (str
, "pedantic"))
3698 else if (!strcmp (str
, "pedantic-errors"))
3699 flag_pedantic_errors
= pedantic
= 1;
3700 else if (!strcmp (str
, "quiet"))
3702 else if (!strcmp (str
, "version"))
3704 else if (!strcmp (str
, "w"))
3705 inhibit_warnings
= 1;
3706 else if (!strcmp (str
, "W"))
3709 /* We save the value of warn_uninitialized, since if they put
3710 -Wuninitialized on the command line, we need to generate a
3711 warning about not using it without also specifying -O. */
3712 if (warn_uninitialized
!= 1)
3713 warn_uninitialized
= 2;
3715 else if (str
[0] == 'W')
3717 register char *p
= &str
[1];
3720 /* Some kind of -W option.
3721 P's value is the option sans `-W'.
3722 Search for it in the table of options. */
3725 !found
&& j
< sizeof (W_options
) / sizeof (W_options
[0]);
3728 if (!strcmp (p
, W_options
[j
].string
))
3730 *W_options
[j
].variable
= W_options
[j
].on_value
;
3731 /* A goto here would be cleaner,
3732 but breaks the vax pcc. */
3735 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
3736 && ! strcmp (p
+3, W_options
[j
].string
))
3738 *W_options
[j
].variable
= ! W_options
[j
].on_value
;
3745 else if (!strncmp (p
, "id-clash-", 9))
3751 if (*endp
>= '0' && *endp
<= '9')
3755 error ("Invalid option `%s'", argv
[i
]);
3760 id_clash_len
= atoi (str
+ 10);
3763 else if (!strncmp (p
, "larger-than-", 12))
3765 char *endp
= p
+ 12;
3769 if (*endp
>= '0' && *endp
<= '9')
3773 error ("Invalid option `%s'", argv
[i
]);
3774 goto larger_than_lose
;
3777 warn_larger_than
= 1;
3778 larger_than_size
= atoi (str
+ 13);
3782 error ("Invalid option `%s'", argv
[i
]);
3784 else if (!strcmp (str
, "p"))
3786 if (!output_bytecode
)
3789 error ("profiling not supported in bytecode compilation");
3791 else if (!strcmp (str
, "a"))
3793 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3794 warning ("`-a' option (basic block profile) not supported");
3796 profile_block_flag
= 1;
3799 else if (str
[0] == 'g')
3806 while (*p
&& (*p
< '0' || *p
> '9'))
3810 while (*q
&& (*q
>= '0' && *q
<= '9'))
3815 level
= 2; /* default debugging info level */
3816 if (*q
|| level
> 3)
3818 warning ("invalid debug level specification in option: `-%s'",
3820 warning ("no debugging information will be generated");
3824 /* If more than one debugging type is supported,
3825 you must define PREFERRED_DEBUGGING_TYPE
3826 to choose a format in a system-dependent way. */
3827 /* This is one long line cause VAXC can't handle a \-newline. */
3828 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3829 #ifdef PREFERRED_DEBUGGING_TYPE
3830 if (!strncmp (str
, "ggdb", len
))
3831 write_symbols
= PREFERRED_DEBUGGING_TYPE
;
3832 #else /* no PREFERRED_DEBUGGING_TYPE */
3833 You Lose
! You must define PREFERRED_DEBUGGING_TYPE
!
3834 #endif /* no PREFERRED_DEBUGGING_TYPE */
3835 #endif /* More than one debugger format enabled. */
3836 #ifdef DBX_DEBUGGING_INFO
3837 if (write_symbols
!= NO_DEBUG
)
3839 else if (!strncmp (str
, "ggdb", len
))
3840 write_symbols
= DBX_DEBUG
;
3841 else if (!strncmp (str
, "gstabs", len
))
3842 write_symbols
= DBX_DEBUG
;
3843 else if (!strncmp (str
, "gstabs+", len
))
3844 write_symbols
= DBX_DEBUG
;
3846 /* Always enable extensions for -ggdb or -gstabs+,
3847 always disable for -gstabs.
3848 For plain -g, use system-specific default. */
3849 if (write_symbols
== DBX_DEBUG
&& !strncmp (str
, "ggdb", len
)
3851 use_gnu_debug_info_extensions
= 1;
3852 else if (write_symbols
== DBX_DEBUG
&& !strncmp (str
, "gstabs+", len
)
3854 use_gnu_debug_info_extensions
= 1;
3855 else if (write_symbols
== DBX_DEBUG
3856 && !strncmp (str
, "gstabs", len
) && len
>= 2)
3857 use_gnu_debug_info_extensions
= 0;
3859 use_gnu_debug_info_extensions
= DEFAULT_GDB_EXTENSIONS
;
3860 #endif /* DBX_DEBUGGING_INFO */
3861 #ifdef DWARF_DEBUGGING_INFO
3862 if (write_symbols
!= NO_DEBUG
)
3864 else if (!strncmp (str
, "g", len
))
3865 write_symbols
= DWARF_DEBUG
;
3866 else if (!strncmp (str
, "ggdb", len
))
3867 write_symbols
= DWARF_DEBUG
;
3868 else if (!strncmp (str
, "gdwarf", len
))
3869 write_symbols
= DWARF_DEBUG
;
3871 /* Always enable extensions for -ggdb or -gdwarf+,
3872 always disable for -gdwarf.
3873 For plain -g, use system-specific default. */
3874 if (write_symbols
== DWARF_DEBUG
&& !strncmp (str
, "ggdb", len
)
3876 use_gnu_debug_info_extensions
= 1;
3877 else if (write_symbols
== DWARF_DEBUG
&& !strcmp (str
, "gdwarf+"))
3878 use_gnu_debug_info_extensions
= 1;
3879 else if (write_symbols
== DWARF_DEBUG
3880 && !strncmp (str
, "gdwarf", len
) && len
>= 2)
3881 use_gnu_debug_info_extensions
= 0;
3883 use_gnu_debug_info_extensions
= DEFAULT_GDB_EXTENSIONS
;
3885 #ifdef SDB_DEBUGGING_INFO
3886 if (write_symbols
!= NO_DEBUG
)
3888 else if (!strncmp (str
, "g", len
))
3889 write_symbols
= SDB_DEBUG
;
3890 else if (!strncmp (str
, "gdb", len
))
3891 write_symbols
= SDB_DEBUG
;
3892 else if (!strncmp (str
, "gcoff", len
))
3893 write_symbols
= SDB_DEBUG
;
3894 #endif /* SDB_DEBUGGING_INFO */
3895 #ifdef XCOFF_DEBUGGING_INFO
3896 if (write_symbols
!= NO_DEBUG
)
3898 else if (!strncmp (str
, "g", len
))
3899 write_symbols
= XCOFF_DEBUG
;
3900 else if (!strncmp (str
, "ggdb", len
))
3901 write_symbols
= XCOFF_DEBUG
;
3902 else if (!strncmp (str
, "gxcoff", len
))
3903 write_symbols
= XCOFF_DEBUG
;
3905 /* Always enable extensions for -ggdb or -gxcoff+,
3906 always disable for -gxcoff.
3907 For plain -g, use system-specific default. */
3908 if (write_symbols
== XCOFF_DEBUG
&& !strncmp (str
, "ggdb", len
)
3910 use_gnu_debug_info_extensions
= 1;
3911 else if (write_symbols
== XCOFF_DEBUG
&& !strcmp (str
, "gxcoff+"))
3912 use_gnu_debug_info_extensions
= 1;
3913 else if (write_symbols
== XCOFF_DEBUG
3914 && !strncmp (str
, "gxcoff", len
) && len
>= 2)
3915 use_gnu_debug_info_extensions
= 0;
3917 use_gnu_debug_info_extensions
= DEFAULT_GDB_EXTENSIONS
;
3919 if (write_symbols
== NO_DEBUG
)
3920 warning ("`-%s' option not supported on this version of GCC", str
);
3921 else if (level
== 0)
3922 write_symbols
= NO_DEBUG
;
3924 debug_info_level
= (enum debug_info_level
) level
;
3926 else if (!strcmp (str
, "o"))
3928 asm_file_name
= argv
[++i
];
3930 else if (str
[0] == 'G')
3932 g_switch_set
= TRUE
;
3933 g_switch_value
= atoi ((str
[1] != '\0') ? str
+1 : argv
[++i
]);
3935 else if (!strncmp (str
, "aux-info", 8))
3937 flag_gen_aux_info
= 1;
3938 aux_info_file_name
= (str
[8] != '\0' ? str
+8 : argv
[++i
]);
3941 error ("Invalid option `%s'", argv
[i
]);
3943 else if (argv
[i
][0] == '+')
3944 error ("Invalid option `%s'", argv
[i
]);
3949 /* Initialize for bytecode output. A good idea to do this as soon as
3950 possible after the "-f" options have been parsed. */
3951 if (output_bytecode
)
3953 #ifndef TARGET_SUPPORTS_BYTECODE
3954 /* Just die with a fatal error if not supported */
3955 fatal ("-fbytecode not supporter for this target");
3963 /* Inlining does not work if not optimizing,
3964 so force it not to be done. */
3968 /* The c_decode_option and lang_decode_option functions set
3969 this to `2' if -Wall is used, so we can avoid giving out
3970 lots of errors for people who don't realize what -Wall does. */
3971 if (warn_uninitialized
== 1)
3972 warning ("-Wuninitialized is not supported without -O");
3975 #if defined(DWARF_DEBUGGING_INFO)
3976 if (write_symbols
== DWARF_DEBUG
3977 && strcmp (language_string
, "GNU C++") == 0)
3979 warning ("-g option not supported for C++ on SVR4 systems");
3980 write_symbols
= NO_DEBUG
;
3982 #endif /* defined(DWARF_DEBUGGING_INFO) */
3984 #ifdef OVERRIDE_OPTIONS
3985 /* Some machines may reject certain combinations of options. */
3989 /* Unrolling all loops implies that standard loop unrolling must also
3991 if (flag_unroll_all_loops
)
3992 flag_unroll_loops
= 1;
3993 /* Loop unrolling requires that strength_reduction be on also. Silently
3994 turn on strength reduction here if it isn't already on. Also, the loop
3995 unrolling code assumes that cse will be run after loop, so that must
3996 be turned on also. */
3997 if (flag_unroll_loops
)
3999 flag_strength_reduce
= 1;
4000 flag_rerun_cse_after_loop
= 1;
4003 /* Warn about options that are not supported on this machine. */
4004 #ifndef INSN_SCHEDULING
4005 if (flag_schedule_insns
|| flag_schedule_insns_after_reload
)
4006 warning ("instruction scheduling not supported on this target machine");
4009 if (flag_delayed_branch
)
4010 warning ("this target machine does not have delayed branches");
4013 /* If we are in verbose mode, write out the version and maybe all the
4014 option flags in use. */
4017 fprintf (stderr
, "%s version %s", language_string
, version_string
);
4018 #ifdef TARGET_VERSION
4023 #define __VERSION__ "[unknown]"
4025 fprintf (stderr
, " compiled by GNU C version %s.\n", __VERSION__
);
4027 fprintf (stderr
, " compiled by CC.\n");
4030 print_switch_values ();
4033 compile_file (filename
);
4035 #if !defined(OS2) && !defined(VMS) && !defined(WINNT)
4041 char *lim
= (char *) sbrk (0);
4043 fprintf (stderr
, "Data size %d.\n",
4044 lim
- (char *) &environ
);
4048 system ("ps -l 1>&2");
4051 #endif /* not USG */
4053 #endif /* not OS2 and not VMS and not WINNT */
4056 exit (FATAL_EXIT_CODE
);
4058 exit (FATAL_EXIT_CODE
);
4059 exit (SUCCESS_EXIT_CODE
);
4063 /* Decode -m switches. */
4065 /* Here is a table, controlled by the tm.h file, listing each -m switch
4066 and which bits in `target_switches' it should set or clear.
4067 If VALUE is positive, it is bits to set.
4068 If VALUE is negative, -VALUE is bits to clear.
4069 (The sign bit is not used so there is no confusion.) */
4071 struct {char *name
; int value
;} target_switches
[]
4074 /* This table is similar, but allows the switch to have a value. */
4076 #ifdef TARGET_OPTIONS
4077 struct {char *prefix
; char ** variable
;} target_options
[]
4081 /* Decode the switch -mNAME. */
4084 set_target_switch (name
)
4090 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
4091 if (!strcmp (target_switches
[j
].name
, name
))
4093 if (target_switches
[j
].value
< 0)
4094 target_flags
&= ~-target_switches
[j
].value
;
4096 target_flags
|= target_switches
[j
].value
;
4100 #ifdef TARGET_OPTIONS
4102 for (j
= 0; j
< sizeof target_options
/ sizeof target_options
[0]; j
++)
4104 int len
= strlen (target_options
[j
].prefix
);
4105 if (!strncmp (target_options
[j
].prefix
, name
, len
))
4107 *target_options
[j
].variable
= name
+ len
;
4114 error ("Invalid option `%s'", name
);
4117 /* Variable used for communication between the following two routines. */
4119 static int line_position
;
4121 /* Print an option value and adjust the position in the line. */
4124 print_single_switch (type
, name
)
4127 fprintf (stderr
, " %s%s", type
, name
);
4129 line_position
+= strlen (type
) + strlen (name
) + 1;
4131 if (line_position
> 65)
4133 fprintf (stderr
, "\n\t");
4138 /* Print default target switches for -version. */
4141 print_switch_values ()
4145 fprintf (stderr
, "enabled:");
4148 for (j
= 0; j
< sizeof f_options
/ sizeof f_options
[0]; j
++)
4149 if (*f_options
[j
].variable
== f_options
[j
].on_value
)
4150 print_single_switch ("-f", f_options
[j
].string
);
4152 for (j
= 0; j
< sizeof W_options
/ sizeof W_options
[0]; j
++)
4153 if (*W_options
[j
].variable
== W_options
[j
].on_value
)
4154 print_single_switch ("-W", W_options
[j
].string
);
4156 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
4157 if (target_switches
[j
].name
[0] != '\0'
4158 && target_switches
[j
].value
> 0
4159 && ((target_switches
[j
].value
& target_flags
)
4160 == target_switches
[j
].value
))
4161 print_single_switch ("-m", target_switches
[j
].name
);
4163 fprintf (stderr
, "\n");