1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-98, 1999 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. */
27 #undef FLOAT /* This is for hpux. They should change hpux. */
28 #undef FFS /* Some systems define this in param.h. */
33 #ifdef HAVE_SYS_RESOURCE_H
34 # include <sys/resource.h>
37 #ifdef HAVE_SYS_TIMES_H
38 # include <sys/times.h>
45 #include "insn-attr.h"
46 #include "insn-codes.h"
47 #include "insn-config.h"
55 #ifdef DWARF_DEBUGGING_INFO
59 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
60 #include "dwarf2out.h"
63 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
67 #ifdef SDB_DEBUGGING_INFO
71 #ifdef XCOFF_DEBUGGING_INFO
76 /* The extra parameters substantially improve the I/O performance. */
78 vms_fopen (fname
, type
)
82 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
83 fixed arguments, which matches ANSI's specification but not VAXCRTL's
84 pre-ANSI implementation. This hack circumvents the mismatch problem. */
85 FILE *(*vmslib_fopen
)() = (FILE *(*)()) fopen
;
88 return (*vmslib_fopen
) (fname
, type
, "mbc=32",
89 "deq=64", "fop=tef", "shr=nil");
91 return (*vmslib_fopen
) (fname
, type
, "mbc=32");
93 #define fopen vms_fopen
96 #ifndef DEFAULT_GDB_EXTENSIONS
97 #define DEFAULT_GDB_EXTENSIONS 1
100 /* If more than one debugging type is supported, you must define
101 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
103 This is one long line cause VAXC can't handle a \-newline. */
104 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
105 #ifndef PREFERRED_DEBUGGING_TYPE
106 You Lose
! You must define PREFERRED_DEBUGGING_TYPE
!
107 #endif /* no PREFERRED_DEBUGGING_TYPE */
108 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
109 so the following code needn't care. */
110 #ifdef DBX_DEBUGGING_INFO
111 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
113 #ifdef SDB_DEBUGGING_INFO
114 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
116 #ifdef DWARF_DEBUGGING_INFO
117 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
119 #ifdef DWARF2_DEBUGGING_INFO
120 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
122 #ifdef XCOFF_DEBUGGING_INFO
123 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
125 #endif /* More than one debugger format enabled. */
127 /* If still not defined, must have been because no debugging formats
129 #ifndef PREFERRED_DEBUGGING_TYPE
130 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
133 extern int rtx_equal_function_value_matters
;
135 #if ! (defined (VMS) || defined (OS2))
136 extern char **environ
;
138 extern char *version_string
, *language_string
;
140 /* Carry information from ASM_DECLARE_OBJECT_NAME
141 to ASM_FINISH_DECLARE_OBJECT. */
143 extern int size_directive_output
;
144 extern tree last_assemble_variable_decl
;
146 extern char *init_parse
PVPROTO((char *));
147 extern void finish_parse ();
148 extern void init_decl_processing ();
149 extern void init_obstacks ();
150 extern void init_tree_codes ();
151 extern void init_rtl ();
152 extern void init_regs ();
153 extern void init_optabs ();
154 extern void init_stmt ();
155 extern void init_reg_sets ();
156 extern void dump_flow_info ();
157 extern void dump_sched_info ();
158 extern void dump_local_alloc ();
159 extern void regset_release_memory ();
161 extern void print_rtl ();
162 extern void print_rtl_with_bb ();
164 void rest_of_decl_compilation ();
165 static void set_target_switch
PROTO((const char *));
166 static char *decl_name
PROTO((tree
, int));
167 static void vmessage
PROTO((const char *, const char *, va_list));
168 static void v_message_with_file_and_line
PROTO((const char *, int,
169 const char *, const char *,
171 static void v_message_with_decl
PROTO((tree
, const char *,
172 const char *, va_list));
173 static void file_and_line_for_asm
PROTO((rtx
, char **, int *));
174 static void v_error_with_file_and_line
PROTO((const char *, int,
175 const char *, va_list));
176 static void v_error_with_decl
PROTO((tree
, const char *, va_list));
177 static void v_error_for_asm
PROTO((rtx
, const char *, va_list));
178 static void verror
PROTO((const char *, va_list));
179 static void vfatal
PROTO((const char *, va_list)) ATTRIBUTE_NORETURN
;
180 static void v_warning_with_file_and_line
PROTO ((const char *, int,
181 const char *, va_list));
182 static void v_warning_with_decl
PROTO((tree
, const char *, va_list));
183 static void v_warning_for_asm
PROTO((rtx
, const char *, va_list));
184 static void vwarning
PROTO((const char *, va_list));
185 static void vpedwarn
PROTO((const char *, va_list));
186 static void v_pedwarn_with_decl
PROTO((tree
, const char *, va_list));
187 static void v_pedwarn_with_file_and_line
PROTO((const char *, int,
188 const char *, va_list));
189 static void vsorry
PROTO((const char *, va_list));
190 static void v_really_sorry
PROTO((const char *, va_list)) ATTRIBUTE_NORETURN
;
191 static void float_signal
PROTO((int)) ATTRIBUTE_NORETURN
;
192 static void pipe_closed
PROTO((int)) ATTRIBUTE_NORETURN
;
193 #ifdef ASM_IDENTIFY_LANGUAGE
194 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
195 static void output_lang_identify
PROTO((FILE *)) ATTRIBUTE_UNUSED
;
197 static void open_dump_file
PROTO((const char *, const char *));
198 static void close_dump_file
PROTO((void (*) (FILE *, rtx
), rtx
));
199 static void dump_rtl
PROTO((const char *, tree
, void (*) (FILE *, rtx
), rtx
));
200 static void clean_dump_file
PROTO((const char *));
201 static void compile_file
PROTO((char *));
202 static void display_help
PROTO ((void));
204 static void print_version
PROTO((FILE *, const char *));
205 static int print_single_switch
PROTO((FILE *, int, int, const char *,
206 const char *, const char *,
207 const char *, const char *));
208 static void print_switch_values
PROTO((FILE *, int, int, const char *,
209 const char *, const char *));
211 void print_rtl_graph_with_bb
PROTO ((const char *, const char *, rtx
));
212 void clean_graph_dump_file
PROTO ((const char *, const char *));
213 void finish_graph_dump_file
PROTO ((const char *, const char *));
214 /* Length of line when printing switch values. */
217 /* Name of program invoked, sans directories. */
221 /* Copy of arguments to main. */
225 /* Name of current original source file (what was input to cpp).
226 This comes from each #-command in the actual input. */
228 char *input_filename
;
230 /* Name of top-level original source file (what was input to cpp).
231 This comes from the #-command at the beginning of the actual input.
232 If there isn't any there, then this is the cc1 input file name. */
234 char *main_input_filename
;
236 /* Current line number in real source file. */
240 /* Nonzero if it is unsafe to create any new pseudo registers. */
243 /* Stack of currently pending input files. */
245 struct file_stack
*input_file_stack
;
247 /* Incremented on each change to input_file_stack. */
248 int input_file_stack_tick
;
250 /* FUNCTION_DECL for function now being parsed or compiled. */
252 extern tree current_function_decl
;
254 /* Name to use as base of names for dump output files. */
256 const char *dump_base_name
;
258 /* Bit flags that specify the machine subtype we are compiling for.
259 Bits are tested using macros TARGET_... defined in the tm.h file
260 and set by `-m...' switches. Must be defined in rtlanal.c. */
262 extern int target_flags
;
264 /* Flags saying which kinds of debugging dump have been requested. */
267 int rtl_dump_and_exit
= 0;
268 int jump_opt_dump
= 0;
269 int addressof_dump
= 0;
274 int branch_prob_dump
= 0;
276 int combine_dump
= 0;
277 int regmove_dump
= 0;
279 int local_reg_dump
= 0;
280 int global_reg_dump
= 0;
282 int jump2_opt_dump
= 0;
284 int dbr_sched_dump
= 0;
286 int flag_print_asm_name
= 0;
288 int stack_reg_dump
= 0;
290 #ifdef MACHINE_DEPENDENT_REORG
291 int mach_dep_reorg_dump
= 0;
293 enum graph_dump_types graph_dump_format
;
295 /* Name for output file of assembly code, specified with -o. */
299 /* Value of the -G xx switch, and whether it was passed or not. */
303 /* Type(s) of debugging information we are producing (if any).
304 See flags.h for the definitions of the different possible
305 types of debugging information. */
306 enum debug_info_type write_symbols
= NO_DEBUG
;
308 /* Level of debugging information we are producing. See flags.h
309 for the definitions of the different possible levels. */
310 enum debug_info_level debug_info_level
= DINFO_LEVEL_NONE
;
312 /* Nonzero means use GNU-only extensions in the generated symbolic
313 debugging information. */
314 /* Currently, this only has an effect when write_symbols is set to
315 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
316 int use_gnu_debug_info_extensions
= 0;
318 /* Nonzero means do optimizations. -O.
319 Particular numeric values stand for particular amounts of optimization;
320 thus, -O2 stores 2 here. However, the optimizations beyond the basic
321 ones are not controlled directly by this variable. Instead, they are
322 controlled by individual `flag_...' variables that are defaulted
323 based on this variable. */
327 /* Nonzero means optimize for size. -Os.
328 The only valid values are zero and non-zero. When optimize_size is
329 non-zero, optimize defaults to 2, but certain individual code
330 bloating optimizations are disabled. */
332 int optimize_size
= 0;
334 /* Number of error messages and warning messages so far. */
337 int warningcount
= 0;
340 /* Pointer to function to compute the name to use to print a declaration.
341 DECL is the declaration in question.
342 VERBOSITY determines what information will be printed:
343 0: DECL_NAME, demangled as necessary.
344 1: and scope information.
345 2: and any other information that might be interesting, such as function
346 parameter types in C++. */
348 char *(*decl_printable_name
) PROTO ((tree
, int));
350 /* Pointer to function to compute rtl for a language-specific tree code. */
352 typedef rtx (*lang_expand_expr_t
)
353 PROTO ((union tree_node
*, rtx
, enum machine_mode
,
354 enum expand_modifier modifier
));
356 lang_expand_expr_t lang_expand_expr
= 0;
358 /* Pointer to function to finish handling an incomplete decl at the
359 end of compilation. */
361 void (*incomplete_decl_finalize_hook
) PROTO((tree
)) = 0;
363 /* Nonzero if generating code to do profiling. */
365 int profile_flag
= 0;
367 /* Nonzero if generating code to do profiling on a line-by-line basis. */
369 int profile_block_flag
;
371 /* Nonzero if generating code to profile program flow graph arcs. */
373 int profile_arc_flag
= 0;
375 /* Nonzero if generating info for gcov to calculate line test coverage. */
377 int flag_test_coverage
= 0;
379 /* Nonzero indicates that branch taken probabilities should be calculated. */
381 int flag_branch_probabilities
= 0;
383 /* Nonzero for -pedantic switch: warn about anything
384 that standard spec forbids. */
388 /* Temporarily suppress certain warnings.
389 This is set while reading code from a system header file. */
391 int in_system_header
= 0;
393 /* Nonzero means do stupid register allocation.
394 Currently, this is 1 if `optimize' is 0. */
396 int obey_regdecls
= 0;
398 /* Don't print functions as they are compiled and don't print
399 times taken by the various passes. -quiet. */
405 /* Nonzero means `char' should be signed. */
407 int flag_signed_char
;
409 /* Nonzero means give an enum type only as many bytes as it needs. */
411 int flag_short_enums
;
413 /* Nonzero for -fcaller-saves: allocate values in regs that need to
414 be saved across function calls, if that produces overall better code.
415 Optional now, so people can test it. */
417 #ifdef DEFAULT_CALLER_SAVES
418 int flag_caller_saves
= 1;
420 int flag_caller_saves
= 0;
423 /* Nonzero if structures and unions should be returned in memory.
425 This should only be defined if compatibility with another compiler or
426 with an ABI is needed, because it results in slower code. */
428 #ifndef DEFAULT_PCC_STRUCT_RETURN
429 #define DEFAULT_PCC_STRUCT_RETURN 1
432 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
434 int flag_pcc_struct_return
= DEFAULT_PCC_STRUCT_RETURN
;
436 /* Nonzero for -fforce-mem: load memory value into a register
437 before arithmetic on it. This makes better cse but slower compilation. */
439 int flag_force_mem
= 0;
441 /* Nonzero for -fforce-addr: load memory address into a register before
442 reference to memory. This makes better cse but slower compilation. */
444 int flag_force_addr
= 0;
446 /* Nonzero for -fdefer-pop: don't pop args after each function call;
447 instead save them up to pop many calls' args with one insns. */
449 int flag_defer_pop
= 0;
451 /* Nonzero for -ffloat-store: don't allocate floats and doubles
452 in extended-precision registers. */
454 int flag_float_store
= 0;
456 /* Nonzero for -fcse-follow-jumps:
457 have cse follow jumps to do a more extensive job. */
459 int flag_cse_follow_jumps
;
461 /* Nonzero for -fcse-skip-blocks:
462 have cse follow a branch around a block. */
463 int flag_cse_skip_blocks
;
465 /* Nonzero for -fexpensive-optimizations:
466 perform miscellaneous relatively-expensive optimizations. */
467 int flag_expensive_optimizations
;
469 /* Nonzero for -fthread-jumps:
470 have jump optimize output of loop. */
472 int flag_thread_jumps
;
474 /* Nonzero enables strength-reduction in loop.c. */
476 int flag_strength_reduce
= 0;
478 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
479 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
480 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
483 int flag_unroll_loops
;
485 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
486 This is generally not a win. */
488 int flag_unroll_all_loops
;
490 /* Nonzero forces all invariant computations in loops to be moved
493 int flag_move_all_movables
= 0;
495 /* Nonzero forces all general induction variables in loops to be
498 int flag_reduce_all_givs
= 0;
500 /* Nonzero to perform full register move optimization passes. This is the
503 int flag_regmove
= 0;
505 /* Nonzero for -fwritable-strings:
506 store string constants in data segment and don't uniquize them. */
508 int flag_writable_strings
= 0;
510 /* Nonzero means don't put addresses of constant functions in registers.
511 Used for compiling the Unix kernel, where strange substitutions are
512 done on the assembly output. */
514 int flag_no_function_cse
= 0;
516 /* Nonzero for -fomit-frame-pointer:
517 don't make a frame pointer in simple functions that don't require one. */
519 int flag_omit_frame_pointer
= 0;
521 /* Nonzero means place each function into its own section on those platforms
522 which support arbitrary section names and unlimited numbers of sections. */
524 int flag_function_sections
= 0;
526 /* ... and similar for data. */
528 int flag_data_sections
= 0;
530 /* Nonzero to inhibit use of define_optimization peephole opts. */
532 int flag_no_peephole
= 0;
534 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
535 operations in the interest of optimization. For example it allows
536 GCC to assume arguments to sqrt are nonnegative numbers, allowing
537 faster code for sqrt to be generated. */
539 int flag_fast_math
= 0;
541 /* Nonzero means all references through pointers are volatile. */
545 /* Nonzero means treat all global and extern variables as global. */
547 int flag_volatile_global
;
549 /* Nonzero means just do syntax checking; don't output anything. */
551 int flag_syntax_only
= 0;
553 /* Nonzero means perform global cse. */
555 static int flag_gcse
;
557 /* Nonzero means to rerun cse after loop optimization. This increases
558 compilation time about 20% and picks up a few more common expressions. */
560 static int flag_rerun_cse_after_loop
;
562 /* Nonzero means to run loop optimizations twice. */
564 int flag_rerun_loop_opt
;
566 /* Nonzero for -finline-functions: ok to inline functions that look like
567 good inline candidates. */
569 int flag_inline_functions
;
571 /* Nonzero for -fkeep-inline-functions: even if we make a function
572 go inline everywhere, keep its definition around for debugging
575 int flag_keep_inline_functions
;
577 /* Nonzero means that functions will not be inlined. */
581 /* Nonzero means that we should emit static const variables
582 regardless of whether or not optimization is turned on. */
584 int flag_keep_static_consts
= 1;
586 /* Nonzero means we should be saving declaration info into a .X file. */
588 int flag_gen_aux_info
= 0;
590 /* Specified name of aux-info file. */
592 static char *aux_info_file_name
;
594 /* Nonzero means make the text shared if supported. */
596 int flag_shared_data
;
598 /* Nonzero means schedule into delayed branch slots if supported. */
600 int flag_delayed_branch
;
602 /* Nonzero if we are compiling pure (sharable) code.
603 Value is 1 if we are doing reasonable (i.e. simple
604 offset into offset table) pic. Value is 2 if we can
605 only perform register offsets. */
609 /* Nonzero means generate extra code for exception handling and enable
610 exception handling. */
614 /* Nonzero means use the new model for exception handling. Replaces
615 -DNEW_EH_MODEL as a compile option. */
617 int flag_new_exceptions
= 0;
619 /* Nonzero means don't place uninitialized global data in common storage
624 /* Nonzero means pretend it is OK to examine bits of target floats,
625 even if that isn't true. The resulting code will have incorrect constants,
626 but the same series of instructions that the native compiler would make. */
628 int flag_pretend_float
;
630 /* Nonzero means change certain warnings into errors.
631 Usually these are warnings about failure to conform to some standard. */
633 int flag_pedantic_errors
= 0;
635 /* flag_schedule_insns means schedule insns within basic blocks (before
637 flag_schedule_insns_after_reload means schedule insns after
640 int flag_schedule_insns
= 0;
641 int flag_schedule_insns_after_reload
= 0;
644 /* The following flags have effect only for scheduling before register
647 flag_schedule_interblock means schedule insns accross basic blocks.
648 flag_schedule_speculative means allow speculative motion of non-load insns.
649 flag_schedule_speculative_load means allow speculative motion of some
651 flag_schedule_speculative_load_dangerous allows speculative motion of more
654 int flag_schedule_interblock
= 1;
655 int flag_schedule_speculative
= 1;
656 int flag_schedule_speculative_load
= 0;
657 int flag_schedule_speculative_load_dangerous
= 0;
660 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
661 by a cheaper branch, on a count register. */
662 int flag_branch_on_count_reg
;
664 /* -finhibit-size-directive inhibits output of .size for ELF.
665 This is used only for compiling crtstuff.c,
666 and it may be extended to other effects
667 needed for crtstuff.c on other systems. */
668 int flag_inhibit_size_directive
= 0;
670 /* -fverbose-asm causes extra commentary information to be produced in
671 the generated assembly code (to make it more readable). This option
672 is generally only of use to those who actually need to read the
673 generated assembly code (perhaps while debugging the compiler itself).
674 -fno-verbose-asm, the default, causes the extra information
675 to be omitted and is useful when comparing two assembler files. */
677 int flag_verbose_asm
= 0;
679 /* -dA causes debug commentary information to be produced in
680 the generated assembly code (to make it more readable). This option
681 is generally only of use to those who actually need to read the
682 generated assembly code (perhaps while debugging the compiler itself).
683 Currently, this switch is only used by dwarfout.c; however, it is intended
684 to be a catchall for printing debug information in the assembler file. */
686 int flag_debug_asm
= 0;
688 /* -fgnu-linker specifies use of the GNU linker for initializations.
689 (Or, more generally, a linker that handles initializations.)
690 -fno-gnu-linker says that collect2 will be used. */
692 int flag_gnu_linker
= 0;
694 int flag_gnu_linker
= 1;
697 /* Tag all structures with __attribute__(packed) */
698 int flag_pack_struct
= 0;
700 /* Emit code to check for stack overflow; also may cause large objects
701 to be allocated dynamically. */
702 int flag_stack_check
;
704 /* -fcheck-memory-usage causes extra code to be generated in order to check
705 memory accesses. This is used by a detector of bad memory accesses such
707 int flag_check_memory_usage
= 0;
709 /* -fprefix-function-name causes function name to be prefixed. This
710 can be used with -fcheck-memory-usage to isolate code compiled with
711 -fcheck-memory-usage. */
712 int flag_prefix_function_name
= 0;
714 /* 0 if pointer arguments may alias each other. True in C.
715 1 if pointer arguments may not alias each other but may alias
717 2 if pointer arguments may not alias each other and may not
718 alias global variables. True in Fortran.
719 This defaults to 0 for C. */
720 int flag_argument_noalias
= 0;
722 /* Nonzero if we should do (language-dependent) alias analysis.
723 Typically, this analysis will assume that expressions of certain
724 types do not alias expressions of certain other types. Only used
725 if alias analysis (in general) is enabled. */
726 int flag_strict_aliasing
= 0;
728 /* Instrument functions with calls at entry and exit, for profiling. */
729 int flag_instrument_function_entry_exit
= 0;
732 /* Table of supported debugging formats. */
736 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
737 constant expression, we use NO_DEBUG in its place. */
738 enum debug_info_type debug_type
;
739 int use_extensions_p
;
740 const char * description
;
744 { "g", NO_DEBUG
, DEFAULT_GDB_EXTENSIONS
,
745 "Generate default debug format output" },
746 { "ggdb", NO_DEBUG
, 1, "Generate default extended debug format output" },
747 #ifdef DBX_DEBUGGING_INFO
748 { "gstabs", DBX_DEBUG
, 0, "Generate STABS format debug output" },
749 { "gstabs+", DBX_DEBUG
, 1, "Generate extended STABS format debug output" },
751 #ifdef DWARF_DEBUGGING_INFO
752 { "gdwarf", DWARF_DEBUG
, 0, "Generate DWARF-1 format debug output"},
753 { "gdwarf+", DWARF_DEBUG
, 1,
754 "Generated extended DWARF-1 format debug output" },
756 #ifdef DWARF2_DEBUGGING_INFO
757 { "gdwarf-2", DWARF2_DEBUG
, 0, "Enable DWARF-2 debug output" },
759 #ifdef XCOFF_DEBUGGING_INFO
760 { "gxcoff", XCOFF_DEBUG
, 0, "Generate XCOFF format debug output" },
761 { "gxcoff+", XCOFF_DEBUG
, 1, "Generate extended XCOFF format debug output" },
763 #ifdef SDB_DEBUGGING_INFO
764 { "gcoff", SDB_DEBUG
, 0, "Generate COFF format debug output" },
774 const char * description
;
776 lang_independent_options
;
778 /* Add or remove a leading underscore from user symbols. */
779 int flag_leading_underscore
= -1;
781 /* The user symbol prefix after having resolved same. */
782 const char *user_label_prefix
;
784 /* A default for same. */
785 #ifndef USER_LABEL_PREFIX
786 #define USER_LABEL_PREFIX ""
789 /* Table of language-independent -f options.
790 STRING is the option name. VARIABLE is the address of the variable.
791 ON_VALUE is the value to store in VARIABLE
792 if `-fSTRING' is seen as an option.
793 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
795 lang_independent_options f_options
[] =
797 {"float-store", &flag_float_store
, 1,
798 "Do not store floats in registers" },
799 {"volatile", &flag_volatile
, 1,
800 "Consider all mem refs through pointers as volatile"},
801 {"volatile-global", &flag_volatile_global
, 1,
802 "Consider all mem refs to global data to be volatile" },
803 {"defer-pop", &flag_defer_pop
, 1,
804 "Defer popping functions args from stack until later" },
805 {"omit-frame-pointer", &flag_omit_frame_pointer
, 1,
806 "When possible do not generate stack frames"},
807 {"cse-follow-jumps", &flag_cse_follow_jumps
, 1,
808 "When running CSE, follow jumps to their targets" },
809 {"cse-skip-blocks", &flag_cse_skip_blocks
, 1,
810 "When running CSE, follow conditional jumps" },
811 {"expensive-optimizations", &flag_expensive_optimizations
, 1,
812 "Perform a number of minor, expensive optimisations" },
813 {"thread-jumps", &flag_thread_jumps
, 1,
814 "Perform jump threading optimisations"},
815 {"strength-reduce", &flag_strength_reduce
, 1,
816 "Perform strength reduction optimisations" },
817 {"unroll-loops", &flag_unroll_loops
, 1,
818 "Perform loop unrolling when iteration count is known" },
819 {"unroll-all-loops", &flag_unroll_all_loops
, 1,
820 "Perform loop unrolling for all loops" },
821 {"move-all-movables", &flag_move_all_movables
, 1,
822 "Force all loop invariant computations out of loops" },
823 {"reduce-all-givs", &flag_reduce_all_givs
, 1,
824 "Strength reduce all loop general induction variables" },
825 {"writable-strings", &flag_writable_strings
, 1,
826 "Store strings in writable data section" },
827 {"peephole", &flag_no_peephole
, 0,
828 "Enable machine specific peephole optimisations" },
829 {"force-mem", &flag_force_mem
, 1,
830 "Copy memory operands into registers before using" },
831 {"force-addr", &flag_force_addr
, 1,
832 "Copy memory address constants into regs before using" },
833 {"function-cse", &flag_no_function_cse
, 0,
834 "Allow function addresses to be held in registers" },
835 {"inline-functions", &flag_inline_functions
, 1,
836 "Integrate simple functions into their callers" },
837 {"keep-inline-functions", &flag_keep_inline_functions
, 1,
838 "Generate code for funcs even if they are fully inlined" },
839 {"inline", &flag_no_inline
, 0,
840 "Pay attention to the 'inline' keyword"},
841 {"keep-static-consts", &flag_keep_static_consts
, 1,
842 "Emit static const variables even if they are not used" },
843 {"syntax-only", &flag_syntax_only
, 1,
844 "Check for syntax errors, then stop" },
845 {"shared-data", &flag_shared_data
, 1,
846 "Mark data as shared rather than private" },
847 {"caller-saves", &flag_caller_saves
, 1,
848 "Enable saving registers around function calls" },
849 {"pcc-struct-return", &flag_pcc_struct_return
, 1,
850 "Return 'short' aggregates in memory, not registers" },
851 {"reg-struct-return", &flag_pcc_struct_return
, 0,
852 "Return 'short' aggregates in registers" },
853 {"delayed-branch", &flag_delayed_branch
, 1,
854 "Attempt to fill delay slots of branch instructions" },
855 {"gcse", &flag_gcse
, 1,
856 "Perform the global common subexpression elimination" },
857 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop
, 1,
858 "Run CSE pass after loop optimisations"},
859 {"rerun-loop-opt", &flag_rerun_loop_opt
, 1,
860 "Run the loop optimiser twice"},
861 {"pretend-float", &flag_pretend_float
, 1,
862 "Pretend that host and target use the same FP format"},
863 {"schedule-insns", &flag_schedule_insns
, 1,
864 "Reschedule instructions to avoid pipeline stalls"},
865 {"schedule-insns2", &flag_schedule_insns_after_reload
, 1,
866 "Run two passes of the instruction scheduler"},
868 {"sched-interblock",&flag_schedule_interblock
, 1,
869 "Enable scheduling across basic blocks" },
870 {"sched-spec",&flag_schedule_speculative
, 1,
871 "Allow speculative motion of non-loads" },
872 {"sched-spec-load",&flag_schedule_speculative_load
, 1,
873 "Allow speculative motion of some loads" },
874 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous
, 1,
875 "Allow speculative motion of more loads" },
877 {"branch-count-reg",&flag_branch_on_count_reg
, 1,
878 "Replace add,compare,branch with branch on count reg"},
879 {"pic", &flag_pic
, 1,
880 "Generate position independent code, if possible"},
881 {"PIC", &flag_pic
, 2, ""},
882 {"exceptions", &flag_exceptions
, 1,
883 "Enable exception handling" },
884 {"new-exceptions", &flag_new_exceptions
, 1,
885 "Use the new model for exception handling" },
886 {"sjlj-exceptions", &exceptions_via_longjmp
, 1,
887 "Use setjmp/longjmp to handle exceptions" },
888 {"asynchronous-exceptions", &asynchronous_exceptions
, 1,
889 "Support asynchronous exceptions" },
890 {"profile-arcs", &profile_arc_flag
, 1,
891 "Insert arc based program profiling code" },
892 {"test-coverage", &flag_test_coverage
, 1,
893 "Create data files needed by gcov" },
894 {"branch-probabilities", &flag_branch_probabilities
, 1,
895 "Use profiling information for branch probabilities" },
896 {"fast-math", &flag_fast_math
, 1,
897 "Improve FP speed by violating ANSI & IEEE rules" },
898 {"common", &flag_no_common
, 0,
899 "Do not put unitialised globals in the common section" },
900 {"inhibit-size-directive", &flag_inhibit_size_directive
, 1,
901 "Do not generate .size directives" },
902 {"function-sections", &flag_function_sections
, 1,
903 "place each function into its own section" },
904 {"data-sections", &flag_data_sections
, 1,
905 "place data items into their own section" },
906 {"verbose-asm", &flag_verbose_asm
, 1,
907 "Add extra commentry to assembler output"},
908 {"gnu-linker", &flag_gnu_linker
, 1,
909 "Output GNU ld formatted global initialisers"},
910 {"regmove", &flag_regmove
, 1,
911 "Enables a register move optimisation"},
912 {"optimize-register-move", &flag_regmove
, 1,
913 "Do the full regmove optimization pass"},
914 {"pack-struct", &flag_pack_struct
, 1,
915 "Pack structure members together without holes" },
916 {"stack-check", &flag_stack_check
, 1,
917 "Insert stack checking code into the program" },
918 {"argument-alias", &flag_argument_noalias
, 0,
919 "Specify that arguments may alias each other & globals"},
920 {"argument-noalias", &flag_argument_noalias
, 1,
921 "Assume arguments may alias globals but not each other"},
922 {"argument-noalias-global", &flag_argument_noalias
, 2,
923 "Assume arguments do not alias each other or globals" },
924 {"strict-aliasing", &flag_strict_aliasing
, 1,
925 "Assume strict aliasing rules apply" },
926 {"check-memory-usage", &flag_check_memory_usage
, 1,
927 "Generate code to check every memory access" },
928 {"prefix-function-name", &flag_prefix_function_name
, 1,
929 "Add a prefix to all function names" },
930 {"dump-unnumbered", &flag_dump_unnumbered
, 1,
931 "Suppress output of instruction numbers and line number notes in debugging dumps"},
932 {"instrument-functions", &flag_instrument_function_entry_exit
, 1,
933 "Instrument function entry/exit with profiling calls"},
934 {"leading-underscore", &flag_leading_underscore
, 1,
935 "External symbols have a leading underscore" }
938 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
940 /* Table of language-specific options. */
942 static struct lang_opt
945 const char * description
;
947 documented_lang_options
[] =
949 /* In order not to overload the --help output, the convention
950 used here is to only describe those options which are not
951 enabled by default. */
953 { "-ansi", "Compile just for ANSI C" },
954 { "-fallow-single-precision",
955 "Do not promote floats to double if using -traditional" },
956 { "-std= ", "Determine language standard"},
958 { "-fsigned-bitfields", "" },
959 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
960 { "-fno-signed-bitfields", "" },
961 { "-fno-unsigned-bitfields","" },
962 { "-fsigned-char", "Make 'char' be signed by default"},
963 { "-funsigned-char", "Make 'char' be unsigned by default"},
964 { "-fno-signed-char", "" },
965 { "-fno-unsigned-char", "" },
967 { "-ftraditional", "" },
968 { "-traditional", "Attempt to support traditional K&R style C"},
969 { "-fnotraditional", "" },
970 { "-fno-traditional", "" },
973 { "-fno-asm", "Do not recognise the 'asm' keyword" },
975 { "-fno-builtin", "Do not recognise any built in functions" },
976 { "-fhosted", "Assume normal C execution environment" },
977 { "-fno-hosted", "" },
979 "Assume that standard libraries & main might not exist" },
980 { "-fno-freestanding", "" },
981 { "-fcond-mismatch", "Allow different types as args of ? operator"},
982 { "-fno-cond-mismatch", "" },
983 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
984 { "-fno-dollars-in-identifiers", "" },
986 { "-fno-ident", "Ignore #ident directives" },
987 { "-fshort-double", "Use the same size for double as for float" },
988 { "-fno-short-double", "" },
989 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
990 { "-fno-short-enums", "" },
992 { "-Wall", "Enable most warning messages" },
993 { "-Wbad-function-cast",
994 "Warn about casting functions to incompatible types" },
995 { "-Wno-bad-function-cast", "" },
996 { "-Wmissing-noreturn",
997 "Warn about functions which might be candidates for attribute noreturn" },
998 { "-Wno-missing-noreturn", "" },
999 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1000 { "-Wno-cast-qual", "" },
1001 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1002 { "-Wno-char-subscripts", "" },
1003 { "-Wcomment", "Warn if nested comments are detected" },
1004 { "-Wno-comment", "" },
1005 { "-Wcomments", "Warn if nested comments are detected" },
1006 { "-Wno-comments", "" },
1007 { "-Wconversion", "Warn about possibly confusing type conversions" },
1008 { "-Wno-conversion", "" },
1009 { "-Wformat", "Warn about printf format anomalies" },
1010 { "-Wno-format", "" },
1011 { "-Wimplicit-function-declaration",
1012 "Warn about implicit function declarations" },
1013 { "-Wno-implicit-function-declaration", "" },
1014 { "-Werror-implicit-function-declaration", "" },
1015 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1016 { "-Wno-implicit-int", "" },
1017 { "-Wimplicit", "" },
1018 { "-Wno-implicit", "" },
1019 { "-Wimport", "Warn about the use of the #import directive" },
1020 { "-Wno-import", "" },
1021 { "-Wlong-long","" },
1022 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1023 { "-Wmain", "Warn about suspicious declarations of main" },
1024 { "-Wno-main", "" },
1025 { "-Wmissing-braces",
1026 "Warn about possibly missing braces around initialisers" },
1027 { "-Wno-missing-braces", "" },
1028 { "-Wmissing-declarations",
1029 "Warn about global funcs without previous declarations"},
1030 { "-Wno-missing-declarations", "" },
1031 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1032 { "-Wno-missing-prototypes", "" },
1033 { "-Wmultichar", "Warn about use of multicharacter literals"},
1034 { "-Wno-multichar", "" },
1035 { "-Wnested-externs", "Warn about externs not at file scope level" },
1036 { "-Wno-nested-externs", "" },
1037 { "-Wparentheses", "Warn about possible missing parentheses" },
1038 { "-Wno-parentheses", "" },
1039 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1040 { "-Wno-pointer-arith", "" },
1041 { "-Wredundant-decls",
1042 "Warn about multiple declarations of the same object" },
1043 { "-Wno-redundant-decls", "" },
1044 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1045 { "-Wno-sign-compare", "" },
1046 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1047 { "-Wno-unknown-pragmas", "" },
1048 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1049 { "-Wno-strict-prototypes", "" },
1050 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1051 { "-Wno-traditional", "" },
1052 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1053 { "-Wno-trigraphs", "" },
1055 { "-Wno-undef", "" },
1056 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1057 { "-Wno-write-strings", "" },
1059 /* These are for languages with USE_CPPLIB. */
1060 /* These options are already documented in cpplib.c */
1067 { "-idirafter", "" },
1072 { "-iwithprefix", "" },
1073 { "-iwithprefixbefore", "" },
1075 { "-lang-c89", "" },
1076 { "-lang-c++", "" },
1078 { "-nostdinc", "" },
1079 { "-nostdinc++", "" },
1080 { "-trigraphs", "" },
1083 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1085 /* These are for obj c. */
1086 DEFINE_LANG_NAME ("Objective C")
1088 { "-lang-objc", "" },
1089 { "-gen-decls", "Dump decls to a .decl file" },
1090 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1091 { "-fno-gnu-runtime", "" },
1092 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1093 { "-fno-next-runtime", "" },
1094 { "-Wselector", "Warn if a selector has multiple methods" },
1095 { "-Wno-selector", "" },
1096 { "-Wprotocol", "" },
1097 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1098 { "-print-objc-runtime-info",
1099 "Generate C header of platform specific features" },
1101 #include "options.h"
1105 /* Here is a table, controlled by the tm.h file, listing each -m switch
1106 and which bits in `target_switches' it should set or clear.
1107 If VALUE is positive, it is bits to set.
1108 If VALUE is negative, -VALUE is bits to clear.
1109 (The sign bit is not used so there is no confusion.) */
1115 const char * description
;
1117 target_switches
[] = TARGET_SWITCHES
;
1119 /* This table is similar, but allows the switch to have a value. */
1121 #ifdef TARGET_OPTIONS
1124 const char * prefix
;
1125 const char ** variable
;
1126 const char * description
;
1128 target_options
[] = TARGET_OPTIONS
;
1131 /* Options controlling warnings */
1133 /* Don't print warning messages. -w. */
1135 int inhibit_warnings
= 0;
1137 /* Print various extra warnings. -W. */
1139 int extra_warnings
= 0;
1141 /* Treat warnings as errors. -Werror. */
1143 int warnings_are_errors
= 0;
1145 /* Nonzero to warn about unused local variables. */
1149 /* Nonzero to warn about variables used before they are initialized. */
1151 int warn_uninitialized
;
1153 /* Nonzero means warn about all declarations which shadow others. */
1157 /* Warn if a switch on an enum fails to have a case for every enum value. */
1161 /* Nonzero means warn about function definitions that default the return type
1162 or that use a null return and have a return-type other than void. */
1164 int warn_return_type
;
1166 /* Nonzero means warn about pointer casts that increase the required
1167 alignment of the target type (and might therefore lead to a crash
1168 due to a misaligned access). */
1170 int warn_cast_align
;
1172 /* Nonzero means warn about any identifiers that match in the first N
1173 characters. The value N is in `id_clash_len'. */
1176 unsigned id_clash_len
;
1178 /* Nonzero means warn about any objects definitions whose size is larger
1179 than N bytes. Also want about function definitions whose returned
1180 values are larger than N bytes. The value N is in `larger_than_size'. */
1182 int warn_larger_than
;
1183 unsigned larger_than_size
;
1185 /* Nonzero means warn if inline function is too large. */
1189 /* Warn if a function returns an aggregate,
1190 since there are often incompatible calling conventions for doing this. */
1192 int warn_aggregate_return
;
1194 /* Likewise for -W. */
1196 lang_independent_options W_options
[] =
1198 {"unused", &warn_unused
, 1, "Warn when a variable is unused" },
1199 {"error", &warnings_are_errors
, 1, ""},
1200 {"shadow", &warn_shadow
, 1, "Warn when one local variable shadows another" },
1201 {"switch", &warn_switch
, 1,
1202 "Warn about enumerated switches missing a specific case" },
1203 {"aggregate-return", &warn_aggregate_return
, 1,
1204 "Warn about returning structures, unions or arrays" },
1205 {"cast-align", &warn_cast_align
, 1,
1206 "Warn about pointer casts which increase alignment" },
1207 {"uninitialized", &warn_uninitialized
, 1,
1208 "Warn about unitialized automatic variables"},
1209 {"inline", &warn_inline
, 1,
1210 "Warn when an inlined function cannot be inlined"}
1213 /* Output files for assembler code (real compiler output)
1214 and debugging dumps. */
1217 FILE *aux_info_file
;
1218 FILE *rtl_dump_file
= NULL
;
1220 /* Time accumulators, to count the total time spent in various passes. */
1224 int integration_time
;
1230 int branch_prob_time
;
1235 int local_alloc_time
;
1236 int global_alloc_time
;
1241 int shorten_branch_time
;
1247 /* Return time used so far, in microseconds. */
1257 #else /* not BeOS */
1258 #if defined (_WIN32) && !defined (__CYGWIN__)
1262 return (clock() * 1000);
1263 #else /* not _WIN32 */
1269 tick
= 1000000 / sysconf(_SC_CLK_TCK
);
1271 return (tms
.tms_utime
+ tms
.tms_stime
) * tick
;
1277 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1278 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1281 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1283 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1287 return (tms
.tms_utime
+ tms
.tms_stime
) * (1000000 / TICKS_PER_SECOND
);
1292 struct rusage rusage
;
1293 getrusage (0, &rusage
);
1294 return (rusage
.ru_utime
.tv_sec
* 1000000 + rusage
.ru_utime
.tv_usec
1295 + rusage
.ru_stime
.tv_sec
* 1000000 + rusage
.ru_stime
.tv_usec
);
1302 int proc_system_time
;
1303 int child_user_time
;
1304 int child_system_time
;
1306 times ((void *) &vms_times
);
1307 return (vms_times
.proc_user_time
+ vms_times
.proc_system_time
) * 10000;
1311 #endif /* _SC_CLK_TCK */
1313 #endif /* __BEOS__ */
1316 #define TIMEVAR(VAR, BODY) \
1317 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1320 print_time (str
, total
)
1325 "time in %s: %d.%06d\n",
1326 str
, total
/ 1000000, total
% 1000000);
1329 /* Count an error or warning. Return 1 if the message should be printed. */
1332 count_error (warningp
)
1335 if (warningp
&& inhibit_warnings
)
1338 if (warningp
&& !warnings_are_errors
)
1342 static int warning_message
= 0;
1344 if (warningp
&& !warning_message
)
1346 fprintf (stderr
, "%s: warnings being treated as errors\n", progname
);
1347 warning_message
= 1;
1355 /* Print a fatal error message. NAME is the text.
1356 Also include a system error message based on `errno'. */
1359 pfatal_with_name (name
)
1362 fprintf (stderr
, "%s: ", progname
);
1364 exit (FATAL_EXIT_CODE
);
1368 fatal_io_error (name
)
1371 fprintf (stderr
, "%s: %s: I/O error\n", progname
, name
);
1372 exit (FATAL_EXIT_CODE
);
1375 /* Called to give a better error message for a bad insn rather than
1376 just calling abort(). */
1379 fatal_insn (message
, insn
)
1380 const char *message
;
1386 fflush (asm_out_file
);
1388 fflush (aux_info_file
);
1389 if (rtl_dump_file
!= NULL
)
1390 fflush (rtl_dump_file
);
1396 /* Called to give a better error message when we don't have an insn to match
1397 what we are looking for or if the insn's constraints aren't satisfied,
1398 rather than just calling abort(). */
1401 fatal_insn_not_found (insn
)
1404 if (INSN_CODE (insn
) < 0)
1405 fatal_insn ("internal error--unrecognizable insn:", insn
);
1407 fatal_insn ("internal error--insn does not satisfy its constraints:", insn
);
1410 /* This is the default decl_printable_name function. */
1413 decl_name (decl
, verbosity
)
1415 int verbosity ATTRIBUTE_UNUSED
;
1417 return IDENTIFIER_POINTER (DECL_NAME (decl
));
1420 static int need_error_newline
;
1422 /* Function of last error message;
1423 more generally, function such that if next error message is in it
1424 then we don't have to mention the function name. */
1425 static tree last_error_function
= NULL
;
1427 /* Used to detect when input_file_stack has changed since last described. */
1428 static int last_error_tick
;
1430 /* Called when the start of a function definition is parsed,
1431 this function prints on stderr the name of the function. */
1434 announce_function (decl
)
1439 if (rtl_dump_and_exit
)
1440 fprintf (stderr
, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl
)));
1442 fprintf (stderr
, " %s", (*decl_printable_name
) (decl
, 2));
1444 need_error_newline
= 1;
1445 last_error_function
= current_function_decl
;
1449 /* The default function to print out name of current function that caused
1453 default_print_error_function (file
)
1456 if (last_error_function
!= current_function_decl
)
1458 const char *kind
= "function";
1459 if (current_function_decl
!= 0
1460 && TREE_CODE (TREE_TYPE (current_function_decl
)) == METHOD_TYPE
)
1464 fprintf (stderr
, "%s: ", file
);
1466 if (current_function_decl
== NULL
)
1467 fprintf (stderr
, "At top level:\n");
1470 char *name
= (*decl_printable_name
) (current_function_decl
, 2);
1471 fprintf (stderr
, "In %s `%s':\n", kind
, name
);
1474 last_error_function
= current_function_decl
;
1478 /* Called by report_error_function to print out function name.
1479 * Default may be overridden by language front-ends. */
1481 void (*print_error_function
) PROTO((const char *)) =
1482 default_print_error_function
;
1484 /* Prints out, if necessary, the name of the current function
1485 that caused an error. Called from all error and warning functions. */
1488 report_error_function (file
)
1491 struct file_stack
*p
;
1493 if (need_error_newline
)
1495 fprintf (stderr
, "\n");
1496 need_error_newline
= 0;
1499 (*print_error_function
) (file
);
1501 if (input_file_stack
&& input_file_stack
->next
!= 0
1502 && input_file_stack_tick
!= last_error_tick
1503 && file
== input_filename
)
1505 fprintf (stderr
, "In file included");
1506 for (p
= input_file_stack
->next
; p
; p
= p
->next
)
1508 fprintf (stderr
, " from %s:%d", p
->name
, p
->line
);
1510 fprintf (stderr
, ",\n ");
1512 fprintf (stderr
, ":\n");
1513 last_error_tick
= input_file_stack_tick
;
1517 /* Print a message. */
1520 vmessage (prefix
, s
, ap
)
1526 fprintf (stderr
, "%s: ", prefix
);
1528 vfprintf (stderr
, s
, ap
);
1531 /* Print a message relevant to line LINE of file FILE. */
1534 v_message_with_file_and_line (file
, line
, prefix
, s
, ap
)
1542 fprintf (stderr
, "%s:%d: ", file
, line
);
1544 fprintf (stderr
, "%s: ", progname
);
1546 vmessage (prefix
, s
, ap
);
1547 fputc ('\n', stderr
);
1550 /* Print a message relevant to the given DECL. */
1553 v_message_with_decl (decl
, prefix
, s
, ap
)
1561 fprintf (stderr
, "%s:%d: ",
1562 DECL_SOURCE_FILE (decl
), DECL_SOURCE_LINE (decl
));
1565 fprintf (stderr
, "%s: ", prefix
);
1567 /* Do magic to get around lack of varargs support for insertion
1568 of arguments into existing list. We know that the decl is first;
1569 we ass_u_me that it will be printed with "%s". */
1571 for (p
= s
; *p
; ++p
)
1575 if (*(p
+ 1) == '%')
1582 if (p
> s
) /* Print the left-hand substring. */
1584 char fmt
[sizeof "%.255s"];
1587 if (width
> 255L) width
= 255L; /* arbitrary */
1588 sprintf (fmt
, "%%.%lds", width
);
1589 fprintf (stderr
, fmt
, s
);
1592 if (*p
== '%') /* Print the name. */
1594 const char *n
= (DECL_NAME (decl
)
1595 ? (*decl_printable_name
) (decl
, 2)
1601 if (ISALPHA (*(p
- 1) & 0xFF))
1606 if (*p
) /* Print the rest of the message. */
1607 vmessage ((char *)NULL
, p
, ap
);
1609 fputc ('\n', stderr
);
1612 /* Figure file and line of the given INSN. */
1615 file_and_line_for_asm (insn
, pfile
, pline
)
1620 rtx body
= PATTERN (insn
);
1623 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1624 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
1625 asmop
= SET_SRC (body
);
1626 else if (GET_CODE (body
) == ASM_OPERANDS
)
1628 else if (GET_CODE (body
) == PARALLEL
1629 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
)
1630 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
1631 else if (GET_CODE (body
) == PARALLEL
1632 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
1633 asmop
= XVECEXP (body
, 0, 0);
1639 *pfile
= ASM_OPERANDS_SOURCE_FILE (asmop
);
1640 *pline
= ASM_OPERANDS_SOURCE_LINE (asmop
);
1644 *pfile
= input_filename
;
1649 /* Report an error at line LINE of file FILE. */
1652 v_error_with_file_and_line (file
, line
, s
, ap
)
1659 report_error_function (file
);
1660 v_message_with_file_and_line (file
, line
, (char *)NULL
, s
, ap
);
1664 error_with_file_and_line
VPROTO((const char *file
, int line
,
1665 const char *s
, ...))
1667 #ifndef ANSI_PROTOTYPES
1676 #ifndef ANSI_PROTOTYPES
1677 file
= va_arg (ap
, const char *);
1678 line
= va_arg (ap
, int);
1679 s
= va_arg (ap
, const char *);
1682 v_error_with_file_and_line (file
, line
, s
, ap
);
1686 /* Report an error at the declaration DECL.
1687 S is a format string which uses %s to substitute the declaration
1688 name; subsequent substitutions are a la printf. */
1691 v_error_with_decl (decl
, s
, ap
)
1697 report_error_function (DECL_SOURCE_FILE (decl
));
1698 v_message_with_decl (decl
, (char *)NULL
, s
, ap
);
1702 error_with_decl
VPROTO((tree decl
, const char *s
, ...))
1704 #ifndef ANSI_PROTOTYPES
1712 #ifndef ANSI_PROTOTYPES
1713 decl
= va_arg (ap
, tree
);
1714 s
= va_arg (ap
, const char *);
1717 v_error_with_decl (decl
, s
, ap
);
1721 /* Report an error at the line number of the insn INSN.
1722 This is used only when INSN is an `asm' with operands,
1723 and each ASM_OPERANDS records its own source file and line. */
1726 v_error_for_asm (insn
, s
, ap
)
1735 file_and_line_for_asm (insn
, &file
, &line
);
1736 report_error_function (file
);
1737 v_message_with_file_and_line (file
, line
, (char *)NULL
, s
, ap
);
1741 error_for_asm
VPROTO((rtx insn
, const char *s
, ...))
1743 #ifndef ANSI_PROTOTYPES
1751 #ifndef ANSI_PROTOTYPES
1752 insn
= va_arg (ap
, rtx
);
1753 s
= va_arg (ap
, const char *);
1756 v_error_for_asm (insn
, s
, ap
);
1760 /* Report an error at the current line number. */
1767 v_error_with_file_and_line (input_filename
, lineno
, s
, ap
);
1771 error
VPROTO((const char *s
, ...))
1773 #ifndef ANSI_PROTOTYPES
1780 #ifndef ANSI_PROTOTYPES
1781 s
= va_arg (ap
, const char *);
1788 /* Report a fatal error at the current line number. */
1796 exit (FATAL_EXIT_CODE
);
1800 fatal
VPROTO((const char *s
, ...))
1802 #ifndef ANSI_PROTOTYPES
1809 #ifndef ANSI_PROTOTYPES
1810 s
= va_arg (ap
, const char *);
1817 /* Report a warning at line LINE of file FILE. */
1820 v_warning_with_file_and_line (file
, line
, s
, ap
)
1826 if (count_error (1))
1828 report_error_function (file
);
1829 v_message_with_file_and_line (file
, line
, "warning", s
, ap
);
1834 warning_with_file_and_line
VPROTO((const char *file
, int line
,
1835 const char *s
, ...))
1837 #ifndef ANSI_PROTOTYPES
1846 #ifndef ANSI_PROTOTYPES
1847 file
= va_arg (ap
, const char *);
1848 line
= va_arg (ap
, int);
1849 s
= va_arg (ap
, const char *);
1852 v_warning_with_file_and_line (file
, line
, s
, ap
);
1856 /* Report a warning at the declaration DECL.
1857 S is a format string which uses %s to substitute the declaration
1858 name; subsequent substitutions are a la printf. */
1861 v_warning_with_decl (decl
, s
, ap
)
1866 if (count_error (1))
1868 report_error_function (DECL_SOURCE_FILE (decl
));
1869 v_message_with_decl (decl
, "warning", s
, ap
);
1874 warning_with_decl
VPROTO((tree decl
, const char *s
, ...))
1876 #ifndef ANSI_PROTOTYPES
1884 #ifndef ANSI_PROTOTYPES
1885 decl
= va_arg (ap
, tree
);
1886 s
= va_arg (ap
, const char *);
1889 v_warning_with_decl (decl
, s
, ap
);
1893 /* Report a warning at the line number of the insn INSN.
1894 This is used only when INSN is an `asm' with operands,
1895 and each ASM_OPERANDS records its own source file and line. */
1898 v_warning_for_asm (insn
, s
, ap
)
1903 if (count_error (1))
1908 file_and_line_for_asm (insn
, &file
, &line
);
1909 report_error_function (file
);
1910 v_message_with_file_and_line (file
, line
, "warning", s
, ap
);
1915 warning_for_asm
VPROTO((rtx insn
, const char *s
, ...))
1917 #ifndef ANSI_PROTOTYPES
1925 #ifndef ANSI_PROTOTYPES
1926 insn
= va_arg (ap
, rtx
);
1927 s
= va_arg (ap
, const char *);
1930 v_warning_for_asm (insn
, s
, ap
);
1934 /* Report a warning at the current line number. */
1941 v_warning_with_file_and_line (input_filename
, lineno
, s
, ap
);
1945 warning
VPROTO((const char *s
, ...))
1947 #ifndef ANSI_PROTOTYPES
1954 #ifndef ANSI_PROTOTYPES
1955 s
= va_arg (ap
, const char *);
1962 /* These functions issue either warnings or errors depending on
1963 -pedantic-errors. */
1970 if (flag_pedantic_errors
)
1977 pedwarn
VPROTO((const char *s
, ...))
1979 #ifndef ANSI_PROTOTYPES
1986 #ifndef ANSI_PROTOTYPES
1987 s
= va_arg (ap
, const char *);
1995 v_pedwarn_with_decl (decl
, s
, ap
)
2000 /* We don't want -pedantic-errors to cause the compilation to fail from
2001 "errors" in system header files. Sometimes fixincludes can't fix what's
2002 broken (eg: unsigned char bitfields - fixing it may change the alignment
2003 which will cause programs to mysteriously fail because the C library
2004 or kernel uses the original layout). There's no point in issuing a
2005 warning either, it's just unnecessary noise. */
2007 if (! DECL_IN_SYSTEM_HEADER (decl
))
2009 if (flag_pedantic_errors
)
2010 v_error_with_decl (decl
, s
, ap
);
2012 v_warning_with_decl (decl
, s
, ap
);
2017 pedwarn_with_decl
VPROTO((tree decl
, const char *s
, ...))
2019 #ifndef ANSI_PROTOTYPES
2027 #ifndef ANSI_PROTOTYPES
2028 decl
= va_arg (ap
, tree
);
2029 s
= va_arg (ap
, const char *);
2032 v_pedwarn_with_decl (decl
, s
, ap
);
2037 v_pedwarn_with_file_and_line (file
, line
, s
, ap
)
2043 if (flag_pedantic_errors
)
2044 v_error_with_file_and_line (file
, line
, s
, ap
);
2046 v_warning_with_file_and_line (file
, line
, s
, ap
);
2050 pedwarn_with_file_and_line
VPROTO((const char *file
, int line
,
2051 const char *s
, ...))
2053 #ifndef ANSI_PROTOTYPES
2062 #ifndef ANSI_PROTOTYPES
2063 file
= va_arg (ap
, const char *);
2064 line
= va_arg (ap
, int);
2065 s
= va_arg (ap
, const char *);
2068 v_pedwarn_with_file_and_line (file
, line
, s
, ap
);
2072 /* Apologize for not implementing some feature. */
2081 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
2083 fprintf (stderr
, "%s: ", progname
);
2084 vmessage ("sorry, not implemented", s
, ap
);
2085 fputc ('\n', stderr
);
2089 sorry
VPROTO((const char *s
, ...))
2091 #ifndef ANSI_PROTOTYPES
2098 #ifndef ANSI_PROTOTYPES
2099 s
= va_arg (ap
, const char *);
2106 /* Apologize for not implementing some feature, then quit. */
2109 v_really_sorry (s
, ap
)
2115 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
2117 fprintf (stderr
, "%s: ", progname
);
2118 vmessage ("sorry, not implemented", s
, ap
);
2119 fatal (" (fatal)\n");
2123 really_sorry
VPROTO((const char *s
, ...))
2125 #ifndef ANSI_PROTOTYPES
2132 #ifndef ANSI_PROTOTYPES
2133 s
= va_arg (ap
, const char *);
2136 v_really_sorry (s
, ap
);
2140 /* More 'friendly' abort that prints the line and file.
2141 config.h can #define abort fancy_abort if you like that sort of thing.
2143 I don't think this is actually a good idea.
2144 Other sorts of crashes will look a certain way.
2145 It is a good thing if crashes from calling abort look the same way.
2151 fatal ("internal gcc abort");
2154 /* This calls abort and is used to avoid problems when abort if a macro.
2155 It is used when we need to pass the address of abort. */
2163 /* When `malloc.c' is compiled with `rcheck' defined,
2164 it calls this function to report clobberage. */
2168 const char * s ATTRIBUTE_UNUSED
;
2173 /* Same as `malloc' but report error if no memory available. */
2184 value
= (PTR
) malloc (size
);
2186 fatal ("virtual memory exhausted");
2190 /* Same as `calloc' but report error if no memory available. */
2193 xcalloc (size1
, size2
)
2194 size_t size1
, size2
;
2198 if (size1
== 0 || size2
== 0)
2201 value
= (PTR
) calloc (size1
, size2
);
2203 fatal ("virtual memory exhausted");
2208 /* Same as `realloc' but report error if no memory available.
2209 Also handle null PTR even if the vendor realloc gets it wrong. */
2212 xrealloc (ptr
, size
)
2216 register PTR result
;
2221 result
= (ptr
? (PTR
) realloc (ptr
, size
) : (PTR
) malloc (size
));
2224 fatal ("virtual memory exhausted");
2229 /* Same as `strdup' but report error if no memory available. */
2233 register const char *s
;
2235 register char *result
= (char *) malloc (strlen (s
) + 1);
2238 fatal ("virtual memory exhausted");
2243 /* Return the logarithm of X, base 2, considering X unsigned,
2244 if X is a power of 2. Otherwise, returns -1.
2246 This should be used via the `exact_log2' macro. */
2250 register unsigned HOST_WIDE_INT x
;
2252 register int log
= 0;
2253 /* Test for 0 or a power of 2. */
2254 if (x
== 0 || x
!= (x
& -x
))
2256 while ((x
>>= 1) != 0)
2261 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2262 If X is 0, return -1.
2264 This should be used via the floor_log2 macro. */
2268 register unsigned HOST_WIDE_INT x
;
2270 register int log
= -1;
2277 static int float_handler_set
;
2279 jmp_buf float_handler
;
2281 /* Signals actually come here. */
2284 float_signal (signo
)
2285 /* If this is missing, some compilers complain. */
2286 int signo ATTRIBUTE_UNUSED
;
2288 if (float_handled
== 0)
2290 #if defined (USG) || defined (hpux)
2291 signal (SIGFPE
, float_signal
); /* re-enable the signal catcher */
2294 signal (SIGFPE
, float_signal
);
2295 longjmp (float_handler
, 1);
2298 /* Specify where to longjmp to when a floating arithmetic error happens.
2299 If HANDLER is 0, it means don't handle the errors any more. */
2302 set_float_handler (handler
)
2305 float_handled
= (handler
!= 0);
2307 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
2309 if (float_handled
&& ! float_handler_set
)
2311 signal (SIGFPE
, float_signal
);
2312 float_handler_set
= 1;
2316 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2317 error happens, pushing the previous specification into OLD_HANDLER.
2318 Return an indication of whether there was a previous handler in effect. */
2321 push_float_handler (handler
, old_handler
)
2322 jmp_buf handler
, old_handler
;
2324 int was_handled
= float_handled
;
2328 memcpy ((char *) old_handler
, (char *) float_handler
,
2329 sizeof (float_handler
));
2331 memcpy ((char *) float_handler
, (char *) handler
, sizeof (float_handler
));
2335 /* Restore the previous specification of whether and where to longjmp to
2336 when a floating arithmetic error happens. */
2339 pop_float_handler (handled
, handler
)
2343 float_handled
= handled
;
2345 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
2348 /* Handler for SIGPIPE. */
2352 /* If this is missing, some compilers complain. */
2353 int signo ATTRIBUTE_UNUSED
;
2355 fatal ("output pipe has been closed");
2358 /* Strip off a legitimate source ending from the input string NAME of
2359 length LEN. Rather than having to know the names used by all of
2360 our front ends, we strip off an ending of a period followed by
2361 up to five characters. (Java uses ".class".) */
2364 strip_off_ending (name
, len
)
2369 for (i
= 2; i
< 6 && len
> i
; i
++)
2371 if (name
[len
- i
] == '.')
2373 name
[len
- i
] = '\0';
2379 /* Output a quoted string. */
2382 output_quoted_string (asm_file
, string
)
2386 #ifdef OUTPUT_QUOTED_STRING
2387 OUTPUT_QUOTED_STRING (asm_file
, string
);
2391 putc ('\"', asm_file
);
2392 while ((c
= *string
++) != 0)
2394 if (c
== '\"' || c
== '\\')
2395 putc ('\\', asm_file
);
2398 putc ('\"', asm_file
);
2402 /* Output a file name in the form wanted by System V. */
2405 output_file_directive (asm_file
, input_name
)
2407 const char *input_name
;
2409 int len
= strlen (input_name
);
2410 const char *na
= input_name
+ len
;
2412 /* NA gets INPUT_NAME sans directory names. */
2413 while (na
> input_name
)
2417 #ifdef DIR_SEPARATOR
2418 if (na
[-1] == DIR_SEPARATOR
)
2424 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2425 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file
, na
);
2427 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2428 ASM_OUTPUT_SOURCE_FILENAME (asm_file
, na
);
2430 fprintf (asm_file
, "\t.file\t");
2431 output_quoted_string (asm_file
, na
);
2432 fputc ('\n', asm_file
);
2437 #ifdef ASM_IDENTIFY_LANGUAGE
2438 /* Routine to build language identifier for object file. */
2440 output_lang_identify (asm_out_file
)
2443 int len
= strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2444 char *s
= (char *) alloca (len
);
2445 sprintf (s
, "__gnu_compiled_%s", lang_identify ());
2446 ASM_OUTPUT_LABEL (asm_out_file
, s
);
2450 /* Routine to open a dump file. */
2452 open_dump_file (suffix
, function_name
)
2454 const char *function_name
;
2461 dumpname
= (char *) xmalloc (strlen (dump_base_name
) + strlen (suffix
) + 1);
2463 if (rtl_dump_file
!= NULL
)
2464 fclose (rtl_dump_file
);
2466 strcpy (dumpname
, dump_base_name
);
2467 strcat (dumpname
, suffix
);
2469 rtl_dump_file
= fopen (dumpname
, "a");
2471 if (rtl_dump_file
== NULL
)
2472 pfatal_with_name (dumpname
);
2477 fprintf (rtl_dump_file
, "\n;; Function %s\n\n", function_name
);
2483 /* Routine to close a dump file. */
2485 close_dump_file (func
, insns
)
2486 void (*func
) PROTO ((FILE *, rtx
));
2493 func (rtl_dump_file
, insns
);
2495 fflush (rtl_dump_file
);
2496 fclose (rtl_dump_file
);
2498 rtl_dump_file
= NULL
;
2504 /* Routine to dump rtl into a file. */
2506 dump_rtl (suffix
, decl
, func
, insns
)
2509 void (*func
) PROTO ((FILE *, rtx
));
2512 open_dump_file (suffix
, decl_printable_name (decl
, 2));
2513 close_dump_file (func
, insns
);
2516 /* Routine to empty a dump file. */
2518 clean_dump_file (suffix
)
2523 dumpname
= (char *) xmalloc (strlen (dump_base_name
) + strlen (suffix
) + 1);
2525 strcpy (dumpname
, dump_base_name
);
2526 strcat (dumpname
, suffix
);
2528 rtl_dump_file
= fopen (dumpname
, "w");
2530 if (rtl_dump_file
== NULL
)
2531 pfatal_with_name (dumpname
);
2535 fclose (rtl_dump_file
);
2536 rtl_dump_file
= NULL
;
2542 /* Compile an entire file of output from cpp, named NAME.
2543 Write a file of assembly output and various debugging dumps. */
2552 int name_specified
= name
!= 0;
2554 if (dump_base_name
== 0)
2555 dump_base_name
= name
? name
: "gccdump";
2559 integration_time
= 0;
2565 branch_prob_time
= 0;
2570 local_alloc_time
= 0;
2571 global_alloc_time
= 0;
2576 shorten_branch_time
= 0;
2582 /* Initialize data in various passes. */
2586 name
= init_parse (name
);
2588 init_emit_once (debug_info_level
== DINFO_LEVEL_NORMAL
2589 || debug_info_level
== DINFO_LEVEL_VERBOSE
2590 || flag_test_coverage
);
2592 init_decl_processing ();
2601 if (flag_caller_saves
)
2602 init_caller_save ();
2604 /* If auxiliary info generation is desired, open the output file.
2605 This goes in the same directory as the source file--unlike
2606 all the other output files. */
2607 if (flag_gen_aux_info
)
2609 aux_info_file
= fopen (aux_info_file_name
, "w");
2610 if (aux_info_file
== 0)
2611 pfatal_with_name (aux_info_file_name
);
2614 /* Clear the dump files. */
2616 clean_dump_file (".rtl");
2619 clean_dump_file (".jump");
2620 if (graph_dump_format
!= no_graph
)
2621 clean_graph_dump_file (dump_base_name
, ".jump");
2625 clean_dump_file (".addressof");
2626 if (graph_dump_format
!= no_graph
)
2627 clean_graph_dump_file (dump_base_name
, ".addressof");
2631 clean_dump_file (".cse");
2632 if (graph_dump_format
!= no_graph
)
2633 clean_graph_dump_file (dump_base_name
, ".cse");
2637 clean_dump_file (".loop");
2638 if (graph_dump_format
!= no_graph
)
2639 clean_graph_dump_file (dump_base_name
, ".loop");
2643 clean_dump_file (".cse2");
2644 if (graph_dump_format
!= no_graph
)
2645 clean_graph_dump_file (dump_base_name
, ".cse2");
2647 if (branch_prob_dump
)
2649 clean_dump_file (".bp");
2650 if (graph_dump_format
!= no_graph
)
2651 clean_graph_dump_file (dump_base_name
, ".bp");
2655 clean_dump_file (".flow");
2656 if (graph_dump_format
!= no_graph
)
2657 clean_graph_dump_file (dump_base_name
, ".flow");
2661 clean_dump_file (".combine");
2662 if (graph_dump_format
!= no_graph
)
2663 clean_graph_dump_file (dump_base_name
, ".combine");
2667 clean_dump_file (".regmove");
2668 if (graph_dump_format
!= no_graph
)
2669 clean_graph_dump_file (dump_base_name
, ".regmove");
2673 clean_dump_file (".sched");
2674 if (graph_dump_format
!= no_graph
)
2675 clean_graph_dump_file (dump_base_name
, ".sched");
2679 clean_dump_file (".lreg");
2680 if (graph_dump_format
!= no_graph
)
2681 clean_graph_dump_file (dump_base_name
, ".lreg");
2683 if (global_reg_dump
)
2685 clean_dump_file (".greg");
2686 if (graph_dump_format
!= no_graph
)
2687 clean_graph_dump_file (dump_base_name
, ".greg");
2691 clean_dump_file (".sched2");
2692 if (graph_dump_format
!= no_graph
)
2693 clean_graph_dump_file (dump_base_name
, ".sched2");
2697 clean_dump_file (".jump2");
2698 if (graph_dump_format
!= no_graph
)
2699 clean_graph_dump_file (dump_base_name
, ".jump2");
2704 clean_dump_file (".dbr");
2705 if (graph_dump_format
!= no_graph
)
2706 clean_graph_dump_file (dump_base_name
, ".dbr");
2711 clean_dump_file (".gcse");
2712 if (graph_dump_format
!= no_graph
)
2713 clean_graph_dump_file (dump_base_name
, ".gcse");
2718 clean_dump_file (".stack");
2719 if (graph_dump_format
!= no_graph
)
2720 clean_graph_dump_file (dump_base_name
, ".stack");
2723 #ifdef MACHINE_DEPENDENT_REORG
2724 if (mach_dep_reorg_dump
)
2726 clean_dump_file (".mach");
2727 if (graph_dump_format
!= no_graph
)
2728 clean_graph_dump_file (dump_base_name
, ".mach");
2732 /* Open assembler code output file. */
2734 if (flag_syntax_only
)
2735 asm_out_file
= NULL
;
2738 if (! name_specified
&& asm_file_name
== 0)
2739 asm_out_file
= stdout
;
2742 int len
= strlen (dump_base_name
);
2743 register char *dumpname
= (char *) xmalloc (len
+ 6);
2744 strcpy (dumpname
, dump_base_name
);
2745 strip_off_ending (dumpname
, len
);
2746 strcat (dumpname
, ".s");
2747 if (asm_file_name
== 0)
2749 asm_file_name
= (char *) xmalloc (strlen (dumpname
) + 1);
2750 strcpy (asm_file_name
, dumpname
);
2752 if (!strcmp (asm_file_name
, "-"))
2753 asm_out_file
= stdout
;
2755 asm_out_file
= fopen (asm_file_name
, "w");
2756 if (asm_out_file
== 0)
2757 pfatal_with_name (asm_file_name
);
2760 #ifdef IO_BUFFER_SIZE
2761 setvbuf (asm_out_file
, (char *) xmalloc (IO_BUFFER_SIZE
),
2762 _IOFBF
, IO_BUFFER_SIZE
);
2766 input_filename
= name
;
2768 /* Put an entry on the input file stack for the main input file. */
2770 = (struct file_stack
*) xmalloc (sizeof (struct file_stack
));
2771 input_file_stack
->next
= 0;
2772 input_file_stack
->name
= input_filename
;
2774 /* Perform language-specific initialization.
2775 This may set main_input_filename. */
2778 /* If the input doesn't start with a #line, use the input name
2779 as the official input file name. */
2780 if (main_input_filename
== 0)
2781 main_input_filename
= name
;
2783 if (flag_syntax_only
)
2785 write_symbols
= NO_DEBUG
;
2787 profile_block_flag
= 0;
2791 ASM_FILE_START (asm_out_file
);
2793 #ifdef ASM_COMMENT_START
2794 if (flag_verbose_asm
)
2796 /* Print the list of options in effect. */
2797 print_version (asm_out_file
, ASM_COMMENT_START
);
2798 print_switch_values (asm_out_file
, 0, MAX_LINE
,
2799 ASM_COMMENT_START
, " ", "\n");
2800 /* Add a blank line here so it appears in assembler output but not
2802 fprintf (asm_out_file
, "\n");
2806 /* Output something to inform GDB that this compilation was by GCC. */
2807 #ifndef ASM_IDENTIFY_GCC
2808 fprintf (asm_out_file
, "gcc2_compiled.:\n");
2810 ASM_IDENTIFY_GCC (asm_out_file
);
2813 /* Output something to identify which front-end produced this file. */
2814 #ifdef ASM_IDENTIFY_LANGUAGE
2815 ASM_IDENTIFY_LANGUAGE (asm_out_file
);
2817 } /* ! flag_syntax_only */
2819 #ifndef ASM_OUTPUT_SECTION_NAME
2820 if (flag_function_sections
)
2822 warning ("-ffunction-sections not supported for this target.");
2823 flag_function_sections
= 0;
2825 if (flag_data_sections
)
2827 warning ("-fdata-sections not supported for this target.");
2828 flag_data_sections
= 0;
2832 if (flag_function_sections
2833 && (profile_flag
|| profile_block_flag
))
2835 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2836 flag_function_sections
= 0;
2839 if (flag_function_sections
&& write_symbols
!= NO_DEBUG
)
2840 warning ("-ffunction-sections may affect debugging on some targets.");
2842 /* ??? Note: There used to be a conditional here
2843 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2844 This was to guarantee separation between gcc_compiled. and
2845 the first function, for the sake of dbx on Suns.
2846 However, having the extra zero here confused the Emacs
2847 code for unexec, and might confuse other programs too.
2848 Therefore, I took out that change.
2849 In future versions we should find another way to solve
2850 that dbx problem. -- rms, 23 May 93. */
2852 /* Don't let the first function fall at the same address
2853 as gcc_compiled., if profiling. */
2854 if (profile_flag
|| profile_block_flag
)
2856 /* It's best if we can write a nop here since some
2857 assemblers don't tolerate zeros in the text section. */
2858 if (insn_template
[CODE_FOR_nop
] != 0)
2859 output_asm_insn (insn_template
[CODE_FOR_nop
], NULL_PTR
);
2861 assemble_zeros (UNITS_PER_WORD
);
2864 /* If dbx symbol table desired, initialize writing it
2865 and output the predefined types. */
2866 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2867 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2868 TIMEVAR (symout_time
, dbxout_init (asm_out_file
, main_input_filename
,
2871 #ifdef SDB_DEBUGGING_INFO
2872 if (write_symbols
== SDB_DEBUG
)
2873 TIMEVAR (symout_time
, sdbout_init (asm_out_file
, main_input_filename
,
2876 #ifdef DWARF_DEBUGGING_INFO
2877 if (write_symbols
== DWARF_DEBUG
)
2878 TIMEVAR (symout_time
, dwarfout_init (asm_out_file
, main_input_filename
));
2880 #ifdef DWARF2_UNWIND_INFO
2881 if (dwarf2out_do_frame ())
2882 dwarf2out_frame_init ();
2884 #ifdef DWARF2_DEBUGGING_INFO
2885 if (write_symbols
== DWARF2_DEBUG
)
2886 TIMEVAR (symout_time
, dwarf2out_init (asm_out_file
, main_input_filename
));
2889 /* Initialize yet another pass. */
2891 init_final (main_input_filename
);
2892 init_branch_prob (dump_base_name
);
2894 start_time
= get_run_time ();
2896 /* Call the parser, which parses the entire file
2897 (calling rest_of_compilation for each function). */
2899 if (yyparse () != 0)
2901 if (errorcount
== 0)
2902 fprintf (stderr
, "Errors detected in input file (your bison.simple is out of date)");
2904 /* In case there were missing closebraces,
2905 get us back to the global binding level. */
2906 while (! global_bindings_p ())
2910 /* Compilation is now finished except for writing
2911 what's left of the symbol table output. */
2913 parse_time
+= get_run_time () - start_time
;
2915 parse_time
-= integration_time
;
2916 parse_time
-= varconst_time
;
2918 if (flag_syntax_only
)
2921 globals
= getdecls ();
2923 /* Really define vars that have had only a tentative definition.
2924 Really output inline functions that must actually be callable
2925 and have not been output so far. */
2928 int len
= list_length (globals
);
2929 tree
*vec
= (tree
*) alloca (sizeof (tree
) * len
);
2934 /* Process the decls in reverse order--earliest first.
2935 Put them into VEC from back to front, then take out from front. */
2937 for (i
= 0, decl
= globals
; i
< len
; i
++, decl
= TREE_CHAIN (decl
))
2938 vec
[len
- i
- 1] = decl
;
2940 for (i
= 0; i
< len
; i
++)
2944 /* We're not deferring this any longer. */
2945 DECL_DEFER_OUTPUT (decl
) = 0;
2947 if (TREE_CODE (decl
) == VAR_DECL
&& DECL_SIZE (decl
) == 0
2948 && incomplete_decl_finalize_hook
!= 0)
2949 (*incomplete_decl_finalize_hook
) (decl
);
2952 /* Now emit any global variables or functions that we have been putting
2953 off. We need to loop in case one of the things emitted here
2954 references another one which comes earlier in the list. */
2958 for (i
= 0; i
< len
; i
++)
2962 if (TREE_ASM_WRITTEN (decl
) || DECL_EXTERNAL (decl
))
2965 /* Don't write out static consts, unless we still need them.
2967 We also keep static consts if not optimizing (for debugging),
2968 unless the user specified -fno-keep-static-consts.
2969 ??? They might be better written into the debug information.
2970 This is possible when using DWARF.
2972 A language processor that wants static constants to be always
2973 written out (even if it is not used) is responsible for
2974 calling rest_of_decl_compilation itself. E.g. the C front-end
2975 calls rest_of_decl_compilation from finish_decl.
2976 One motivation for this is that is conventional in some
2977 environments to write things like:
2978 static const char rcsid[] = "... version string ...";
2979 intending to force the string to be in the executable.
2981 A language processor that would prefer to have unneeded
2982 static constants "optimized away" would just defer writing
2983 them out until here. E.g. C++ does this, because static
2984 constants are often defined in header files.
2986 ??? A tempting alternative (for both C and C++) would be
2987 to force a constant to be written if and only if it is
2988 defined in a main file, as opposed to an include file. */
2990 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
2991 && (! TREE_READONLY (decl
)
2992 || TREE_PUBLIC (decl
)
2993 || (!optimize
&& flag_keep_static_consts
)
2994 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
2997 rest_of_decl_compilation (decl
, NULL_PTR
, 1, 1);
3000 if (TREE_CODE (decl
) == FUNCTION_DECL
3001 && DECL_INITIAL (decl
) != 0
3002 && DECL_SAVED_INSNS (decl
) != 0
3003 && (flag_keep_inline_functions
3004 || TREE_PUBLIC (decl
)
3005 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
3008 temporary_allocation ();
3009 output_inline_function (decl
);
3010 permanent_allocation (1);
3015 /* This must occur after the loop to output deferred functions. Else
3016 the profiler initializer would not be emitted if all the functions
3017 in this compilation unit were deferred.
3019 output_func_start_profiler can not cause any additional functions or
3020 data to need to be output, so it need not be in the deferred function
3022 output_func_start_profiler ();
3024 /* Now that all possible functions have been output, we can dump
3025 the exception table. */
3027 output_exception_table ();
3029 for (i
= 0; i
< len
; i
++)
3033 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
3034 && ! TREE_ASM_WRITTEN (decl
))
3035 /* Cancel the RTL for this decl so that, if debugging info
3036 output for global variables is still to come,
3037 this one will be omitted. */
3038 DECL_RTL (decl
) = NULL
;
3040 /* Warn about any function
3041 declared static but not defined.
3042 We don't warn about variables,
3043 because many programs have static variables
3044 that exist only to get some text into the object file. */
3045 if (TREE_CODE (decl
) == FUNCTION_DECL
3047 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
3048 && DECL_INITIAL (decl
) == 0
3049 && DECL_EXTERNAL (decl
)
3050 && ! DECL_ARTIFICIAL (decl
)
3051 && ! TREE_PUBLIC (decl
))
3053 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
3054 pedwarn_with_decl (decl
,
3055 "`%s' used but never defined");
3057 warning_with_decl (decl
,
3058 "`%s' declared `static' but never defined");
3059 /* This symbol is effectively an "extern" declaration now. */
3060 TREE_PUBLIC (decl
) = 1;
3061 assemble_external (decl
);
3064 /* Warn about static fns or vars defined but not used,
3065 but not about inline functions or static consts
3066 since defining those in header files is normal practice. */
3068 && ((TREE_CODE (decl
) == FUNCTION_DECL
&& ! DECL_INLINE (decl
))
3069 || (TREE_CODE (decl
) == VAR_DECL
&& ! TREE_READONLY (decl
)))
3070 && ! DECL_IN_SYSTEM_HEADER (decl
)
3071 && ! DECL_EXTERNAL (decl
)
3072 && ! TREE_PUBLIC (decl
)
3073 && ! TREE_USED (decl
)
3074 && (TREE_CODE (decl
) == FUNCTION_DECL
|| ! DECL_REGISTER (decl
))
3075 /* The TREE_USED bit for file-scope decls
3076 is kept in the identifier, to handle multiple
3077 external decls in different scopes. */
3078 && ! TREE_USED (DECL_NAME (decl
)))
3079 warning_with_decl (decl
, "`%s' defined but not used");
3081 #ifdef SDB_DEBUGGING_INFO
3082 /* The COFF linker can move initialized global vars to the end.
3083 And that can screw up the symbol ordering.
3084 By putting the symbols in that order to begin with,
3085 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
3086 if (write_symbols
== SDB_DEBUG
&& TREE_CODE (decl
) == VAR_DECL
3087 && TREE_PUBLIC (decl
) && DECL_INITIAL (decl
)
3088 && ! DECL_EXTERNAL (decl
)
3089 && DECL_RTL (decl
) != 0)
3090 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
3092 /* Output COFF information for non-global
3093 file-scope initialized variables. */
3094 if (write_symbols
== SDB_DEBUG
3095 && TREE_CODE (decl
) == VAR_DECL
3096 && DECL_INITIAL (decl
)
3097 && ! DECL_EXTERNAL (decl
)
3098 && DECL_RTL (decl
) != 0
3099 && GET_CODE (DECL_RTL (decl
)) == MEM
)
3100 TIMEVAR (symout_time
, sdbout_toplevel_data (decl
));
3101 #endif /* SDB_DEBUGGING_INFO */
3102 #ifdef DWARF_DEBUGGING_INFO
3103 /* Output DWARF information for file-scope tentative data object
3104 declarations, file-scope (extern) function declarations (which
3105 had no corresponding body) and file-scope tagged type declarations
3106 and definitions which have not yet been forced out. */
3108 if (write_symbols
== DWARF_DEBUG
3109 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
3110 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 1));
3112 #ifdef DWARF2_DEBUGGING_INFO
3113 /* Output DWARF2 information for file-scope tentative data object
3114 declarations, file-scope (extern) function declarations (which
3115 had no corresponding body) and file-scope tagged type declarations
3116 and definitions which have not yet been forced out. */
3118 if (write_symbols
== DWARF2_DEBUG
3119 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
3120 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
3125 /* Write out any pending weak symbol declarations. */
3129 /* Do dbx symbols */
3130 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3131 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3132 TIMEVAR (symout_time
,
3134 dbxout_finish (asm_out_file
, main_input_filename
);
3138 #ifdef DWARF_DEBUGGING_INFO
3139 if (write_symbols
== DWARF_DEBUG
)
3140 TIMEVAR (symout_time
,
3146 #ifdef DWARF2_UNWIND_INFO
3147 if (dwarf2out_do_frame ())
3148 dwarf2out_frame_finish ();
3151 #ifdef DWARF2_DEBUGGING_INFO
3152 if (write_symbols
== DWARF2_DEBUG
)
3153 TIMEVAR (symout_time
,
3155 dwarf2out_finish ();
3159 /* Output some stuff at end of file if nec. */
3161 end_final (dump_base_name
);
3163 if (branch_prob_dump
)
3164 open_dump_file (".bp", NULL
);
3166 TIMEVAR (dump_time
, end_branch_prob (rtl_dump_file
));
3168 if (branch_prob_dump
)
3169 close_dump_file (NULL
, NULL_RTX
);
3172 ASM_FILE_END (asm_out_file
);
3176 /* Language-specific end of compilation actions. */
3180 /* Close the dump files. */
3182 if (flag_gen_aux_info
)
3184 fclose (aux_info_file
);
3186 unlink (aux_info_file_name
);
3191 open_dump_file (".combine", NULL
);
3192 TIMEVAR (dump_time
, dump_combine_total_stats (rtl_dump_file
));
3193 close_dump_file (NULL
, NULL_RTX
);
3196 /* Close non-debugging input and output files. Take special care to note
3197 whether fclose returns an error, since the pages might still be on the
3198 buffer chain while the file is open. */
3202 if (! flag_syntax_only
3203 && (ferror (asm_out_file
) != 0 || fclose (asm_out_file
) != 0))
3204 fatal_io_error (asm_file_name
);
3206 /* Do whatever is necessary to finish printing the graphs. */
3207 if (graph_dump_format
!= no_graph
)
3210 finish_graph_dump_file (dump_base_name
, ".jump");
3212 finish_graph_dump_file (dump_base_name
, ".addressof");
3214 finish_graph_dump_file (dump_base_name
, ".cse");
3216 finish_graph_dump_file (dump_base_name
, ".loop");
3218 finish_graph_dump_file (dump_base_name
, ".cse2");
3219 if (branch_prob_dump
)
3220 finish_graph_dump_file (dump_base_name
, ".bp");
3222 finish_graph_dump_file (dump_base_name
, ".flow");
3224 finish_graph_dump_file (dump_base_name
, ".combine");
3226 finish_graph_dump_file (dump_base_name
, ".regmove");
3228 finish_graph_dump_file (dump_base_name
, ".sched");
3230 finish_graph_dump_file (dump_base_name
, ".lreg");
3231 if (global_reg_dump
)
3232 finish_graph_dump_file (dump_base_name
, ".greg");
3234 finish_graph_dump_file (dump_base_name
, ".sched2");
3236 finish_graph_dump_file (dump_base_name
, ".jump2");
3239 finish_graph_dump_file (dump_base_name
, ".dbr");
3242 finish_graph_dump_file (dump_base_name
, ".gcse");
3245 finish_graph_dump_file (dump_base_name
, ".stack");
3247 #ifdef MACHINE_DEPENDENT_REORG
3248 if (mach_dep_reorg_dump
)
3249 finish_graph_dump_file (dump_base_name
, ".mach");
3253 /* Free up memory for the benefit of leak detectors. */
3256 /* Print the times. */
3260 fprintf (stderr
,"\n");
3261 print_time ("parse", parse_time
);
3263 print_time ("integration", integration_time
);
3264 print_time ("jump", jump_time
);
3265 print_time ("cse", cse_time
);
3266 print_time ("gcse", gcse_time
);
3267 print_time ("loop", loop_time
);
3268 print_time ("cse2", cse2_time
);
3269 print_time ("branch-prob", branch_prob_time
);
3270 print_time ("flow", flow_time
);
3271 print_time ("combine", combine_time
);
3272 print_time ("regmove", regmove_time
);
3273 print_time ("sched", sched_time
);
3274 print_time ("local-alloc", local_alloc_time
);
3275 print_time ("global-alloc", global_alloc_time
);
3276 print_time ("sched2", sched2_time
);
3278 print_time ("dbranch", dbr_sched_time
);
3280 print_time ("shorten-branch", shorten_branch_time
);
3281 print_time ("stack-reg", stack_reg_time
);
3282 print_time ("final", final_time
);
3283 print_time ("varconst", varconst_time
);
3284 print_time ("symout", symout_time
);
3285 print_time ("dump", dump_time
);
3289 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3290 and TYPE_DECL nodes.
3292 This does nothing for local (non-static) variables.
3293 Otherwise, it sets up the RTL and outputs any assembler code
3294 (label definition, storage allocation and initialization).
3296 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3297 the assembler symbol name to be used. TOP_LEVEL is nonzero
3298 if this declaration is not within a function. */
3301 rest_of_decl_compilation (decl
, asmspec
, top_level
, at_end
)
3303 const char *asmspec
;
3307 /* Declarations of variables, and of functions defined elsewhere. */
3309 /* The most obvious approach, to put an #ifndef around where
3310 this macro is used, doesn't work since it's inside a macro call. */
3311 #ifndef ASM_FINISH_DECLARE_OBJECT
3312 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3315 /* Forward declarations for nested functions are not "external",
3316 but we need to treat them as if they were. */
3317 if (TREE_STATIC (decl
) || DECL_EXTERNAL (decl
)
3318 || TREE_CODE (decl
) == FUNCTION_DECL
)
3319 TIMEVAR (varconst_time
,
3321 make_decl_rtl (decl
, asmspec
, top_level
);
3322 /* Initialized extern variable exists to be replaced
3323 with its value, or represents something that will be
3324 output in another file. */
3325 if (! (TREE_CODE (decl
) == VAR_DECL
3326 && DECL_EXTERNAL (decl
) && TREE_READONLY (decl
)
3327 && DECL_INITIAL (decl
) != 0
3328 && DECL_INITIAL (decl
) != error_mark_node
))
3329 /* Don't output anything
3330 when a tentative file-scope definition is seen.
3331 But at end of compilation, do output code for them. */
3332 if (! (! at_end
&& top_level
3333 && (DECL_INITIAL (decl
) == 0
3334 || DECL_INITIAL (decl
) == error_mark_node
)))
3335 assemble_variable (decl
, top_level
, at_end
, 0);
3336 if (decl
== last_assemble_variable_decl
)
3338 ASM_FINISH_DECLARE_OBJECT (asm_out_file
, decl
,
3342 else if (DECL_REGISTER (decl
) && asmspec
!= 0)
3344 if (decode_reg_name (asmspec
) >= 0)
3346 DECL_RTL (decl
) = 0;
3347 make_decl_rtl (decl
, asmspec
, top_level
);
3350 error ("invalid register name `%s' for register variable", asmspec
);
3352 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3353 else if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3354 && TREE_CODE (decl
) == TYPE_DECL
)
3355 TIMEVAR (symout_time
, dbxout_symbol (decl
, 0));
3357 #ifdef SDB_DEBUGGING_INFO
3358 else if (write_symbols
== SDB_DEBUG
&& top_level
3359 && TREE_CODE (decl
) == TYPE_DECL
)
3360 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
3364 /* Called after finishing a record, union or enumeral type. */
3367 rest_of_type_compilation (type
, toplev
)
3368 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3372 tree type ATTRIBUTE_UNUSED
;
3373 int toplev ATTRIBUTE_UNUSED
;
3376 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3377 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
3378 TIMEVAR (symout_time
, dbxout_symbol (TYPE_STUB_DECL (type
), !toplev
));
3380 #ifdef SDB_DEBUGGING_INFO
3381 if (write_symbols
== SDB_DEBUG
)
3382 TIMEVAR (symout_time
, sdbout_symbol (TYPE_STUB_DECL (type
), !toplev
));
3386 /* This is called from finish_function (within yyparse)
3387 after each top-level definition is parsed.
3388 It is supposed to compile that function or variable
3389 and output the assembler code for it.
3390 After we return, the tree storage is freed. */
3393 rest_of_compilation (decl
)
3397 int start_time
= get_run_time ();
3399 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3400 to be restored after we finish compiling the function
3401 (for use when compiling inline calls to this function). */
3402 tree saved_block_tree
= 0;
3403 /* Likewise, for DECL_ARGUMENTS. */
3404 tree saved_arguments
= 0;
3407 /* If we are reconsidering an inline function
3408 at the end of compilation, skip the stuff for making it inline. */
3410 if (DECL_SAVED_INSNS (decl
) == 0)
3415 /* If requested, consider whether to make this function inline. */
3416 if (DECL_INLINE (decl
) || flag_inline_functions
)
3417 TIMEVAR (integration_time
,
3419 lose
= function_cannot_inline_p (decl
);
3420 if (lose
|| ! optimize
)
3422 if (warn_inline
&& DECL_INLINE (decl
))
3423 warning_with_decl (decl
, lose
);
3424 DECL_ABSTRACT_ORIGIN (decl
) = 0;
3425 /* Don't really compile an extern inline function.
3426 If we can't make it inline, pretend
3427 it was only declared. */
3428 if (DECL_EXTERNAL (decl
))
3430 DECL_INITIAL (decl
) = 0;
3431 goto exit_rest_of_compilation
;
3435 /* ??? Note that this has the effect of making it look
3436 like "inline" was specified for a function if we choose
3437 to inline it. This isn't quite right, but it's
3438 probably not worth the trouble to fix. */
3439 inlinable
= DECL_INLINE (decl
) = 1;
3442 insns
= get_insns ();
3444 /* Dump the rtl code if we are dumping rtl. */
3448 open_dump_file (".rtl", decl_printable_name (decl
, 2));
3450 if (DECL_SAVED_INSNS (decl
))
3451 fprintf (rtl_dump_file
, ";; (integrable)\n\n");
3453 close_dump_file (print_rtl
, insns
);
3456 /* If we can, defer compiling inlines until EOF.
3457 save_for_inline_copying can be extremely expensive. */
3458 if (inlinable
&& ! decl_function_context (decl
))
3459 DECL_DEFER_OUTPUT (decl
) = 1;
3461 /* If function is inline, and we don't yet know whether to
3462 compile it by itself, defer decision till end of compilation.
3463 finish_compilation will call rest_of_compilation again
3464 for those functions that need to be output. Also defer those
3465 functions that we are supposed to defer. We cannot defer
3466 functions containing nested functions since the nested function
3467 data is in our non-saved obstack. We cannot defer nested
3468 functions for the same reason. */
3470 /* If this is a nested inline, remove ADDRESSOF now so we can
3471 finish compiling ourselves. Otherwise, wait until EOF.
3472 We have to do this because the purge_addressof transformation
3473 changes the DECL_RTL for many variables, which confuses integrate. */
3476 if (decl_function_context (decl
))
3477 purge_addressof (insns
);
3479 DECL_DEFER_OUTPUT (decl
) = 1;
3482 if (! current_function_contains_functions
3483 && (DECL_DEFER_OUTPUT (decl
)
3484 || (DECL_INLINE (decl
)
3485 && ((! TREE_PUBLIC (decl
) && ! TREE_ADDRESSABLE (decl
)
3486 && ! flag_keep_inline_functions
)
3487 || DECL_EXTERNAL (decl
)))))
3489 DECL_DEFER_OUTPUT (decl
) = 1;
3491 /* If -Wreturn-type, we have to do a bit of compilation.
3492 However, if we just fall through we will call
3493 save_for_inline_copying() which results in excessive
3494 memory use. Instead, we just want to call
3495 jump_optimize() to figure out whether or not we can fall
3496 off the end of the function; we do the minimum amount of
3497 work necessary to make that safe. And, we set optimize
3498 to zero to keep jump_optimize from working too hard. */
3499 if (warn_return_type
)
3501 int saved_optimize
= optimize
;
3503 find_exception_handler_labels ();
3504 jump_optimize (get_insns(), !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
3505 !JUMP_AFTER_REGSCAN
);
3506 optimize
= saved_optimize
;
3509 #ifdef DWARF_DEBUGGING_INFO
3510 /* Generate the DWARF info for the "abstract" instance
3511 of a function which we may later generate inlined and/or
3512 out-of-line instances of. */
3513 if (write_symbols
== DWARF_DEBUG
)
3515 set_decl_abstract_flags (decl
, 1);
3516 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
3517 set_decl_abstract_flags (decl
, 0);
3520 #ifdef DWARF2_DEBUGGING_INFO
3521 /* Generate the DWARF2 info for the "abstract" instance
3522 of a function which we may later generate inlined and/or
3523 out-of-line instances of. */
3524 if (write_symbols
== DWARF2_DEBUG
)
3526 set_decl_abstract_flags (decl
, 1);
3527 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
3528 set_decl_abstract_flags (decl
, 0);
3531 TIMEVAR (integration_time
, save_for_inline_nocopy (decl
));
3532 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl
)) = inlinable
;
3533 goto exit_rest_of_compilation
;
3536 /* If we have to compile the function now, save its rtl and subdecls
3537 so that its compilation will not affect what others get. */
3538 if (inlinable
|| DECL_DEFER_OUTPUT (decl
))
3540 #ifdef DWARF_DEBUGGING_INFO
3541 /* Generate the DWARF info for the "abstract" instance of
3542 a function which we will generate an out-of-line instance
3543 of almost immediately (and which we may also later generate
3544 various inlined instances of). */
3545 if (write_symbols
== DWARF_DEBUG
)
3547 set_decl_abstract_flags (decl
, 1);
3548 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
3549 set_decl_abstract_flags (decl
, 0);
3552 #ifdef DWARF2_DEBUGGING_INFO
3553 /* Generate the DWARF2 info for the "abstract" instance of
3554 a function which we will generate an out-of-line instance
3555 of almost immediately (and which we may also later generate
3556 various inlined instances of). */
3557 if (write_symbols
== DWARF2_DEBUG
)
3559 set_decl_abstract_flags (decl
, 1);
3560 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
3561 set_decl_abstract_flags (decl
, 0);
3564 saved_block_tree
= DECL_INITIAL (decl
);
3565 saved_arguments
= DECL_ARGUMENTS (decl
);
3566 TIMEVAR (integration_time
, save_for_inline_copying (decl
));
3567 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl
)) = inlinable
;
3570 /* If specified extern inline but we aren't inlining it, we are
3571 done. This goes for anything that gets here with DECL_EXTERNAL
3572 set, not just things with DECL_INLINE. */
3573 if (DECL_EXTERNAL (decl
))
3574 goto exit_rest_of_compilation
;
3577 if (! DECL_DEFER_OUTPUT (decl
))
3578 TREE_ASM_WRITTEN (decl
) = 1;
3580 /* Now that integrate will no longer see our rtl, we need not distinguish
3581 between the return value of this function and the return value of called
3583 rtx_equal_function_value_matters
= 0;
3585 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3586 if ((rtl_dump_and_exit
|| flag_syntax_only
) && !warn_return_type
)
3588 goto exit_rest_of_compilation
;
3591 /* Emit code to get eh context, if needed. */
3595 /* If we are doing position-independent code generation, now
3596 is the time to output special prologues and epilogues.
3597 We do not want to do this earlier, because it just clutters
3598 up inline functions with meaningless insns. */
3603 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3604 Note that that may have been done above, in save_for_inline_copying.
3605 The call to resume_temporary_allocation near the end of this function
3606 goes back to the usual state of affairs. This must be done after
3607 we've built up any unwinders for exception handling, and done
3608 the FINALIZE_PIC work, if necessary. */
3610 rtl_in_current_obstack ();
3612 insns
= get_insns ();
3614 /* Copy any shared structure that should not be shared. */
3616 unshare_all_rtl (insns
);
3618 #ifdef SETJMP_VIA_SAVE_AREA
3619 /* This must be performed before virutal register instantiation. */
3620 if (current_function_calls_alloca
)
3621 optimize_save_area_alloca (insns
);
3624 /* Instantiate all virtual registers. */
3626 instantiate_virtual_regs (current_function_decl
, get_insns ());
3628 /* See if we have allocated stack slots that are not directly addressable.
3629 If so, scan all the insns and create explicit address computation
3630 for all references to such slots. */
3631 /* fixup_stack_slots (); */
3633 /* Find all the EH handlers. */
3634 find_exception_handler_labels ();
3636 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3637 are initialized and to compute whether control can drop off the end
3639 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3640 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
3641 JUMP_AFTER_REGSCAN
));
3643 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3644 if (rtl_dump_and_exit
|| flag_syntax_only
|| DECL_DEFER_OUTPUT (decl
))
3645 goto exit_rest_of_compilation
;
3647 /* Dump rtl code after jump, if we are doing that. */
3650 dump_rtl (".jump", decl
, print_rtl
, insns
);
3652 /* Perform common subexpression elimination.
3653 Nonzero value from `cse_main' means that jumps were simplified
3654 and some code may now be unreachable, so do
3655 jump optimization again. */
3660 open_dump_file (".cse", decl_printable_name (decl
, 2));
3662 TIMEVAR (cse_time
, reg_scan (insns
, max_reg_num (), 1));
3664 if (flag_thread_jumps
)
3665 /* Hacks by tiemann & kenner. */
3666 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 1));
3668 TIMEVAR (cse_time
, tem
= cse_main (insns
, max_reg_num (),
3670 TIMEVAR (cse_time
, delete_trivially_dead_insns (insns
, max_reg_num ()));
3672 if (tem
|| optimize
> 1)
3673 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3675 !JUMP_AFTER_REGSCAN
));
3677 /* Dump rtl code after cse, if we are doing that. */
3681 close_dump_file (print_rtl
, insns
);
3682 if (graph_dump_format
!= no_graph
)
3683 print_rtl_graph_with_bb (dump_base_name
, ".cse", insns
);
3687 purge_addressof (insns
);
3688 reg_scan (insns
, max_reg_num (), 1);
3692 dump_rtl (".addressof", decl
, print_rtl
, insns
);
3693 if (graph_dump_format
!= no_graph
)
3694 print_rtl_graph_with_bb (dump_base_name
, ".addressof", insns
);
3697 /* Perform global cse. */
3699 if (optimize
> 0 && flag_gcse
)
3702 open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl
)));
3704 TIMEVAR (gcse_time
, gcse_main (insns
, rtl_dump_file
));
3708 close_dump_file (print_rtl
, insns
);
3709 if (graph_dump_format
!= no_graph
)
3710 print_rtl_graph_with_bb (dump_base_name
, ".gcse", insns
);
3713 /* Move constant computations out of loops. */
3718 open_dump_file (".loop", decl_printable_name (decl
, 2));
3723 if (flag_rerun_loop_opt
)
3725 /* We only want to perform unrolling once. */
3727 loop_optimize (insns
, rtl_dump_file
, 0, 0);
3730 /* The first call to loop_optimize makes some instructions
3731 trivially dead. We delete those instructions now in the
3732 hope that doing so will make the heuristics in loop work
3733 better and possibly speed up compilation. */
3734 delete_trivially_dead_insns (insns
, max_reg_num ());
3736 /* The regscan pass is currently necessary as the alias
3737 analysis code depends on this information. */
3738 reg_scan (insns
, max_reg_num (), 1);
3740 loop_optimize (insns
, rtl_dump_file
, flag_unroll_loops
, 1);
3743 /* Dump rtl code after loop opt, if we are doing that. */
3747 close_dump_file (print_rtl
, insns
);
3748 if (graph_dump_format
!= no_graph
)
3749 print_rtl_graph_with_bb (dump_base_name
, ".loop", insns
);
3756 open_dump_file (".cse2", decl_printable_name (decl
, 2));
3758 if (flag_rerun_cse_after_loop
)
3760 /* Running another jump optimization pass before the second
3761 cse pass sometimes simplifies the RTL enough to allow
3762 the second CSE pass to do a better job. Jump_optimize can change
3763 max_reg_num so we must rerun reg_scan afterwards.
3764 ??? Rework to not call reg_scan so often. */
3765 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3766 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3768 JUMP_AFTER_REGSCAN
));
3770 TIMEVAR (cse2_time
, reg_scan (insns
, max_reg_num (), 0));
3771 TIMEVAR (cse2_time
, tem
= cse_main (insns
, max_reg_num (),
3774 TIMEVAR (jump_time
, jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3776 !JUMP_AFTER_REGSCAN
));
3779 if (flag_thread_jumps
)
3781 /* This pass of jump threading straightens out code
3782 that was kinked by loop optimization. */
3783 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
3784 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 0));
3787 /* Dump rtl code after cse, if we are doing that. */
3791 close_dump_file (print_rtl
, insns
);
3792 if (graph_dump_format
!= no_graph
)
3793 print_rtl_graph_with_bb (dump_base_name
, ".cse2", insns
);
3797 if (profile_arc_flag
|| flag_test_coverage
|| flag_branch_probabilities
)
3799 if (branch_prob_dump
)
3800 open_dump_file (".bp", decl_printable_name (decl
, 2));
3805 branch_prob (insns
, rtl_dump_file
);
3808 if (branch_prob_dump
)
3810 close_dump_file (print_rtl
, insns
);
3811 if (graph_dump_format
!= no_graph
)
3812 print_rtl_graph_with_bb (dump_base_name
, ".bp", insns
);
3816 /* We are no longer anticipating cse in this function, at least. */
3818 cse_not_expected
= 1;
3820 /* Now we choose between stupid (pcc-like) register allocation
3821 (if we got the -noreg switch and not -opt)
3822 and smart register allocation. */
3824 if (optimize
> 0) /* Stupid allocation probably won't work */
3825 obey_regdecls
= 0; /* if optimizations being done. */
3829 /* Print function header into flow dump now
3830 because doing the flow analysis makes some of the dump. */
3833 open_dump_file (".flow", decl_printable_name (decl
, 2));
3839 regclass (insns
, max_reg_num ());
3840 stupid_life_analysis (insns
, max_reg_num (),
3846 /* Do control and data flow analysis,
3847 and write some of the results to dump file. */
3852 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
);
3853 life_analysis (insns
, max_reg_num (), rtl_dump_file
);
3856 if (warn_uninitialized
)
3858 uninitialized_vars_warning (DECL_INITIAL (decl
));
3859 setjmp_args_warning ();
3863 /* Dump rtl after flow analysis. */
3867 close_dump_file (print_rtl_with_bb
, insns
);
3868 if (graph_dump_format
!= no_graph
)
3869 print_rtl_graph_with_bb (dump_base_name
, ".flow", insns
);
3872 /* The first life analysis pass has finished. From now on we can not
3873 generate any new pseudos. */
3876 /* If -opt, try combining insns through substitution. */
3880 TIMEVAR (combine_time
, combine_instructions (insns
, max_reg_num ()));
3882 /* Dump rtl code after insn combination. */
3886 dump_rtl (".combine", decl
, print_rtl_with_bb
, insns
);
3887 if (graph_dump_format
!= no_graph
)
3888 print_rtl_graph_with_bb (dump_base_name
, ".combine", insns
);
3892 /* Register allocation pre-pass, to reduce number of moves
3893 necessary for two-address machines. */
3894 if (optimize
> 0 && (flag_regmove
|| flag_expensive_optimizations
))
3897 open_dump_file (".regmove", decl_printable_name (decl
, 2));
3899 TIMEVAR (regmove_time
, regmove_optimize (insns
, max_reg_num (),
3904 close_dump_file (print_rtl_with_bb
, insns
);
3905 if (graph_dump_format
!= no_graph
)
3906 print_rtl_graph_with_bb (dump_base_name
, ".regmove", insns
);
3910 /* Print function header into sched dump now
3911 because doing the sched analysis makes some of the dump. */
3913 if (optimize
> 0 && flag_schedule_insns
)
3916 open_dump_file (".sched", decl_printable_name (decl
, 2));
3918 /* Do control and data sched analysis,
3919 and write some of the results to dump file. */
3921 TIMEVAR (sched_time
, schedule_insns (rtl_dump_file
));
3923 /* Dump rtl after instruction scheduling. */
3927 close_dump_file (print_rtl_with_bb
, insns
);
3928 if (graph_dump_format
!= no_graph
)
3929 print_rtl_graph_with_bb (dump_base_name
, ".sched", insns
);
3933 /* Unless we did stupid register allocation,
3934 allocate pseudo-regs that are used only within 1 basic block. */
3937 TIMEVAR (local_alloc_time
,
3939 recompute_reg_usage (insns
, ! optimize_size
);
3940 regclass (insns
, max_reg_num ());
3944 /* Dump rtl code after allocating regs within basic blocks. */
3948 open_dump_file (".lreg", decl_printable_name (decl
, 2));
3950 TIMEVAR (dump_time
, dump_flow_info (rtl_dump_file
));
3951 TIMEVAR (dump_time
, dump_local_alloc (rtl_dump_file
));
3953 close_dump_file (print_rtl_with_bb
, insns
);
3954 if (graph_dump_format
!= no_graph
)
3955 print_rtl_graph_with_bb (dump_base_name
, ".lreg", insns
);
3958 if (global_reg_dump
)
3959 open_dump_file (".greg", decl_printable_name (decl
, 2));
3961 /* Unless we did stupid register allocation,
3962 allocate remaining pseudo-regs, then do the reload pass
3963 fixing up any insns that are invalid. */
3965 TIMEVAR (global_alloc_time
,
3968 failure
= global_alloc (rtl_dump_file
);
3970 failure
= reload (insns
, 0, rtl_dump_file
);
3975 goto exit_rest_of_compilation
;
3977 /* Do a very simple CSE pass over just the hard registers. */
3979 reload_cse_regs (insns
);
3981 /* If optimizing and we are performing instruction scheduling after
3982 reload, then go ahead and split insns now since we are about to
3983 recompute flow information anyway.
3985 reload_cse_regs may expose more splitting opportunities, expecially
3986 for double-word operations. */
3987 if (optimize
> 0 && flag_schedule_insns_after_reload
)
3991 for (insn
= insns
; insn
; insn
= NEXT_INSN (insn
))
3995 if (GET_RTX_CLASS (GET_CODE (insn
)) != 'i')
3998 last
= try_split (PATTERN (insn
), insn
, 1);
4002 PUT_CODE (insn
, NOTE
);
4003 NOTE_SOURCE_FILE (insn
) = 0;
4004 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
4009 /* Re-create the death notes which were deleted during reload. */
4014 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
);
4015 life_analysis (insns
, max_reg_num (), rtl_dump_file
);
4018 flow2_completed
= 1;
4020 /* On some machines, the prologue and epilogue code, or parts thereof,
4021 can be represented as RTL. Doing so lets us schedule insns between
4022 it and the rest of the code and also allows delayed branch
4023 scheduling to operate in the epilogue. */
4025 thread_prologue_and_epilogue_insns (insns
);
4027 if (global_reg_dump
)
4029 TIMEVAR (dump_time
, dump_global_regs (rtl_dump_file
));
4030 close_dump_file (print_rtl_with_bb
, insns
);
4031 if (graph_dump_format
!= no_graph
)
4032 print_rtl_graph_with_bb (dump_base_name
, ".greg", insns
);
4034 if (optimize
> 0 && flag_schedule_insns_after_reload
)
4037 open_dump_file (".sched2", decl_printable_name (decl
, 2));
4039 /* Do control and data sched analysis again,
4040 and write some more of the results to dump file. */
4042 TIMEVAR (sched2_time
, schedule_insns (rtl_dump_file
));
4044 /* Dump rtl after post-reorder instruction scheduling. */
4048 close_dump_file (print_rtl_with_bb
, insns
);
4049 if (graph_dump_format
!= no_graph
)
4050 print_rtl_graph_with_bb (dump_base_name
, ".sched2", insns
);
4054 #ifdef LEAF_REGISTERS
4056 if (optimize
> 0 && only_leaf_regs_used () && leaf_function_p ())
4060 /* One more attempt to remove jumps to .+1
4061 left by dead-store-elimination.
4062 Also do cross-jumping this time
4063 and delete no-op move insns. */
4067 TIMEVAR (jump_time
, jump_optimize (insns
, JUMP_CROSS_JUMP
,
4069 !JUMP_AFTER_REGSCAN
));
4071 /* Dump rtl code after jump, if we are doing that. */
4075 dump_rtl (".jump2", decl
, print_rtl_with_bb
, insns
);
4076 if (graph_dump_format
!= no_graph
)
4077 print_rtl_graph_with_bb (dump_base_name
, ".jump2", insns
);
4081 /* If a machine dependent reorganization is needed, call it. */
4082 #ifdef MACHINE_DEPENDENT_REORG
4083 MACHINE_DEPENDENT_REORG (insns
);
4085 if (mach_dep_reorg_dump
)
4087 dump_rtl (".mach", decl
, print_rtl_with_bb
, insns
);
4088 if (graph_dump_format
!= no_graph
)
4089 print_rtl_graph_with_bb (dump_base_name
, ".mach", insns
);
4093 /* If a scheduling pass for delayed branches is to be done,
4094 call the scheduling code. */
4097 if (optimize
> 0 && flag_delayed_branch
)
4099 TIMEVAR (dbr_sched_time
, dbr_schedule (insns
, rtl_dump_file
));
4103 dump_rtl (".dbr", decl
, print_rtl_with_bb
, insns
);
4104 if (graph_dump_format
!= no_graph
)
4105 print_rtl_graph_with_bb (dump_base_name
, ".dbr", insns
);
4110 /* Shorten branches. */
4111 TIMEVAR (shorten_branch_time
,
4113 shorten_branches (get_insns ());
4118 open_dump_file (".stack", decl_printable_name (decl
, 2));
4120 TIMEVAR (stack_reg_time
, reg_to_stack (insns
, rtl_dump_file
));
4124 dump_rtl (".stack", decl
, print_rtl_with_bb
, insns
);
4125 if (graph_dump_format
!= no_graph
)
4126 print_rtl_graph_with_bb (dump_base_name
, ".stack", insns
);
4130 /* Now turn the rtl into assembler code. */
4132 TIMEVAR (final_time
,
4137 /* Get the function's name, as described by its RTL.
4138 This may be different from the DECL_NAME name used
4139 in the source file. */
4141 x
= DECL_RTL (decl
);
4142 if (GET_CODE (x
) != MEM
)
4145 if (GET_CODE (x
) != SYMBOL_REF
)
4147 fnname
= XSTR (x
, 0);
4149 assemble_start_function (decl
, fnname
);
4150 final_start_function (insns
, asm_out_file
, optimize
);
4151 final (insns
, asm_out_file
, optimize
, 0);
4152 final_end_function (insns
, asm_out_file
, optimize
);
4153 assemble_end_function (decl
, fnname
);
4155 fflush (asm_out_file
);
4157 /* Release all memory held by regsets now */
4158 regset_release_memory ();
4161 /* Write DBX symbols if requested */
4163 /* Note that for those inline functions where we don't initially
4164 know for certain that we will be generating an out-of-line copy,
4165 the first invocation of this routine (rest_of_compilation) will
4166 skip over this code by doing a `goto exit_rest_of_compilation;'.
4167 Later on, finish_compilation will call rest_of_compilation again
4168 for those inline functions that need to have out-of-line copies
4169 generated. During that call, we *will* be routed past here. */
4171 #ifdef DBX_DEBUGGING_INFO
4172 if (write_symbols
== DBX_DEBUG
)
4173 TIMEVAR (symout_time
, dbxout_function (decl
));
4176 #ifdef DWARF_DEBUGGING_INFO
4177 if (write_symbols
== DWARF_DEBUG
)
4178 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
4181 #ifdef DWARF2_DEBUGGING_INFO
4182 if (write_symbols
== DWARF2_DEBUG
)
4183 TIMEVAR (symout_time
, dwarf2out_decl (decl
));
4186 exit_rest_of_compilation
:
4190 /* In case the function was not output,
4191 don't leave any temporary anonymous types
4192 queued up for sdb output. */
4193 #ifdef SDB_DEBUGGING_INFO
4194 if (write_symbols
== SDB_DEBUG
)
4195 sdbout_types (NULL_TREE
);
4198 /* Put back the tree of subblocks and list of arguments
4199 from before we copied them.
4200 Code generation and the output of debugging info may have modified
4201 the copy, but the original is unchanged. */
4203 if (saved_block_tree
!= 0)
4205 DECL_INITIAL (decl
) = saved_block_tree
;
4206 DECL_ARGUMENTS (decl
) = saved_arguments
;
4207 DECL_ABSTRACT_ORIGIN (decl
) = NULL_TREE
;
4210 reload_completed
= 0;
4211 flow2_completed
= 0;
4214 TIMEVAR (final_time
,
4216 /* Clear out the insn_length contents now that they are no
4218 init_insn_lengths ();
4220 /* Clear out the real_constant_chain before some of the rtx's
4221 it runs through become garbage. */
4222 clear_const_double_mem ();
4224 /* Cancel the effect of rtl_in_current_obstack. */
4225 resume_temporary_allocation ();
4227 /* Show no temporary slots allocated. */
4231 /* Make sure volatile mem refs aren't considered valid operands for
4232 arithmetic insns. We must call this here if this is a nested inline
4233 function, since the above code leaves us in the init_recog state
4234 (from final.c), and the function context push/pop code does not
4235 save/restore volatile_ok.
4237 ??? Maybe it isn't necessary for expand_start_function to call this
4238 anymore if we do it here? */
4240 init_recog_no_volatile ();
4242 /* The parsing time is all the time spent in yyparse
4243 *except* what is spent in this function. */
4245 parse_time
-= get_run_time () - start_time
;
4247 /* Reset global variables. */
4248 free_basic_block_vars (0);
4259 printf ("Usage: %s input [switches]\n", progname
);
4260 printf ("Switches:\n");
4262 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
4263 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
4264 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4266 for (i
= NUM_ELEM (f_options
); i
--;)
4268 const char * description
= f_options
[i
].description
;
4270 if (description
!= NULL
&& * description
!= 0)
4271 printf (" -f%-21s %s\n",
4272 f_options
[i
].string
, description
);
4275 printf (" -O[number] Set optimisation level to [number]\n");
4276 printf (" -Os Optimise for space rather than speed\n");
4277 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
4278 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
4279 printf (" -w Suppress warnings\n");
4280 printf (" -W Enable extra warnings\n");
4282 for (i
= NUM_ELEM (W_options
); i
--;)
4284 const char * description
= W_options
[i
].description
;
4286 if (description
!= NULL
&& * description
!= 0)
4287 printf (" -W%-21s %s\n",
4288 W_options
[i
].string
, description
);
4291 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4292 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4293 printf (" -p Enable function profiling\n");
4294 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4295 printf (" -a Enable block profiling \n");
4297 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4298 printf (" -ax Enable jump profiling \n");
4300 printf (" -o <file> Place output into <file> \n");
4301 printf (" -G <number> Put global and static data smaller than <number>\n");
4302 printf (" bytes into a special section (on some targets)\n");
4304 for (i
= NUM_ELEM (debug_args
); i
--;)
4306 if (debug_args
[i
].description
!= NULL
)
4307 printf (" -%-22s %s\n", debug_args
[i
].arg
, debug_args
[i
].description
);
4310 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4311 printf (" -quiet Do not display functions compiled or elapsed time\n");
4312 printf (" -version Display the compiler's version\n");
4313 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4314 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4315 #if defined HAIFA || defined INSN_SCHEDULING
4316 printf (" -sched-verbose-<number> Set the verbosity level of the scheduler\n");
4318 printf (" --help Display this information\n");
4323 /* Display descriptions of language specific options.
4324 If there is no description, note that there is an undocumented option.
4325 If the description is empty, do not display anything. (This allows
4326 options to be deliberately undocumented, for whatever reason).
4327 If the option string is missing, then this is a marker, indicating
4328 that the description string is in fact the name of a language, whose
4329 language specific options are to follow. */
4331 if (NUM_ELEM (documented_lang_options
) > 1)
4333 printf ("\nLanguage specific options:\n");
4335 for (i
= 0; i
< NUM_ELEM (documented_lang_options
); i
++)
4337 const char * description
= documented_lang_options
[i
].description
;
4338 const char * option
= documented_lang_options
[i
].option
;
4340 if (description
== NULL
)
4345 printf (" %-23.23s [undocumented]\n", option
);
4347 else if (* description
== 0)
4349 else if (option
== NULL
)
4353 ("\nThere are undocumented %s specific options as well.\n",
4357 printf ("\n Options for %s:\n", description
);
4362 printf (" %-23.23s %s\n", option
, description
);
4367 printf ("\nThere are undocumented %s specific options as well.\n", lang
);
4369 if (NUM_ELEM (target_switches
) > 1
4370 #ifdef TARGET_OPTIONS
4371 || NUM_ELEM (target_options
) > 1
4379 printf ("\nTarget specific options:\n");
4381 for (i
= NUM_ELEM (target_switches
); i
--;)
4383 const char * option
= target_switches
[i
].name
;
4384 const char * description
= target_switches
[i
].description
;
4386 if (option
== NULL
|| * option
== 0)
4388 else if (description
== NULL
)
4393 printf (" -m%-21.21s [undocumented]\n", option
);
4395 else if (* description
!= 0)
4396 doc
+= printf (" -m%-21.21s %s\n", option
, description
);
4399 #ifdef TARGET_OPTIONS
4400 for (i
= NUM_ELEM (target_options
); i
--;)
4402 const char * option
= target_options
[i
].prefix
;
4403 const char * description
= target_options
[i
].description
;
4405 if (option
== NULL
|| * option
== 0)
4407 else if (description
== NULL
)
4412 printf (" -m%-21.21s [undocumented]\n", option
);
4414 else if (* description
!= 0)
4415 doc
+= printf (" -m%-21.21s %s\n", option
, description
);
4421 printf ("\nThere are undocumented target specific options as well.\n");
4423 printf (" They exist, but they are not documented.\n");
4428 /* Compare the user specified 'option' with the language
4429 specific 'lang_option'. Return true if they match, or
4430 if 'option' is a viable prefix of 'lang_option'. */
4433 check_lang_option (option
, lang_option
)
4437 lang_independent_options
* indep_options
;
4442 /* Ignore NULL entries. */
4443 if (option
== NULL
|| lang_option
== NULL
)
4446 if ((space
= strchr (lang_option
, ' ')) != NULL
)
4447 len
= space
- lang_option
;
4449 len
= strlen (lang_option
);
4451 /* If they do not match to the first n characters then fail. */
4452 if (strncmp (option
, lang_option
, len
) != 0)
4455 /* Do not accept a lang option, if it matches a normal -f or -W
4456 option. Chill defines a -fpack, but we want to support
4459 /* An exact match is OK */
4460 if ((int) strlen (option
) == len
)
4463 /* If it is not an -f or -W option allow the match */
4464 if (option
[0] != '-')
4469 case 'f': indep_options
= f_options
; break;
4470 case 'W': indep_options
= W_options
; break;
4474 /* The option is a -f or -W option.
4475 Skip past the prefix and search for the remainder in the
4476 appropriate table of options. */
4479 if (option
[0] == 'n' && option
[1] == 'o' && option
[2] == '-')
4482 for (k
= NUM_ELEM (indep_options
); k
--;)
4484 if (!strcmp (option
, indep_options
[k
].string
))
4486 /* The option matched a language independent option,
4487 do not allow the language specific match. */
4493 /* The option matches the start of the langauge specific option
4494 and it is not an exact match for a language independent option. */
4498 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4499 Exit code is 35 if can't open files, 34 if fatal error,
4500 33 if had nonfatal errors, else success. */
4509 int flag_print_mem
= 0;
4510 int version_flag
= 0;
4513 /* save in case md file wants to emit args as a comment. */
4517 p
= argv
[0] + strlen (argv
[0]);
4518 while (p
!= argv
[0] && p
[-1] != '/'
4519 #ifdef DIR_SEPARATOR
4520 && p
[-1] != DIR_SEPARATOR
4526 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
4527 /* Get rid of any avoidable limit on stack size. */
4531 /* Set the stack limit huge so that alloca does not fail. */
4532 getrlimit (RLIMIT_STACK
, &rlim
);
4533 rlim
.rlim_cur
= rlim
.rlim_max
;
4534 setrlimit (RLIMIT_STACK
, &rlim
);
4538 signal (SIGFPE
, float_signal
);
4541 signal (SIGPIPE
, pipe_closed
);
4544 decl_printable_name
= decl_name
;
4545 lang_expand_expr
= (lang_expand_expr_t
) do_abort
;
4547 /* Initialize whether `char' is signed. */
4548 flag_signed_char
= DEFAULT_SIGNED_CHAR
;
4549 #ifdef DEFAULT_SHORT_ENUMS
4550 /* Initialize how much space enums occupy, by default. */
4551 flag_short_enums
= DEFAULT_SHORT_ENUMS
;
4554 /* Perform language-specific options intialization. */
4555 lang_init_options ();
4557 /* Scan to see what optimization level has been specified. That will
4558 determine the default value of many flags. */
4559 for (i
= 1; i
< argc
; i
++)
4561 if (!strcmp (argv
[i
], "-O"))
4566 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'O')
4568 /* Handle -Os, -O2, -O3, -O69, ... */
4569 char *p
= &argv
[i
][2];
4572 if ((p
[0] == 's') && (p
[1] == 0))
4576 /* Optimizing for size forces optimize to be 2. */
4582 if (! (c
>= '0' && c
<= '9'))
4586 optimize
= atoi (&argv
[i
][2]);
4593 obey_regdecls
= (optimize
== 0);
4598 flag_thread_jumps
= 1;
4600 flag_delayed_branch
= 1;
4602 #ifdef CAN_DEBUG_WITHOUT_FP
4603 flag_omit_frame_pointer
= 1;
4609 flag_cse_follow_jumps
= 1;
4610 flag_cse_skip_blocks
= 1;
4612 flag_expensive_optimizations
= 1;
4613 flag_strength_reduce
= 1;
4614 flag_rerun_cse_after_loop
= 1;
4615 flag_rerun_loop_opt
= 1;
4616 flag_caller_saves
= 1;
4618 #ifdef INSN_SCHEDULING
4619 flag_schedule_insns
= 1;
4620 flag_schedule_insns_after_reload
= 1;
4623 flag_strict_aliasing
= 1;
4628 flag_inline_functions
= 1;
4631 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4634 set_target_switch ("");
4636 #ifdef OPTIMIZATION_OPTIONS
4637 /* Allow default optimizations to be specified on a per-machine basis. */
4638 OPTIMIZATION_OPTIONS (optimize
, optimize_size
);
4641 /* Initialize register usage now so switches may override. */
4644 for (i
= 1; i
< argc
; i
++)
4648 /* If this is a language-specific option,
4649 decode it in a language-specific way. */
4650 for (j
= NUM_ELEM (documented_lang_options
); j
--;)
4651 if (check_lang_option (argv
[i
], documented_lang_options
[j
].option
))
4654 if (j
!= (size_t)-1)
4656 /* If the option is valid for *some* language,
4657 treat it as valid even if this language doesn't understand it. */
4658 int strings_processed
= lang_decode_option (argc
- i
, argv
+ i
);
4660 if (!strcmp (argv
[i
], "--help"))
4666 if (strings_processed
!= 0)
4667 i
+= strings_processed
- 1;
4669 else if (argv
[i
][0] == '-' && argv
[i
][1] != 0)
4671 register char *str
= argv
[i
] + 1;
4676 set_target_switch (&str
[1]);
4677 else if (!strcmp (str
, "dumpbase"))
4679 dump_base_name
= argv
[++i
];
4681 else if (str
[0] == 'd')
4683 register char *p
= &str
[1];
4688 branch_prob_dump
= 1;
4694 global_reg_dump
= 1;
4702 cse_dump
= 1, cse2_dump
= 1;
4709 #ifdef MACHINE_DEPENDENT_REORG
4710 mach_dep_reorg_dump
= 1;
4717 branch_prob_dump
= 1;
4734 global_reg_dump
= 1;
4759 #ifdef MACHINE_DEPENDENT_REORG
4761 mach_dep_reorg_dump
= 1;
4765 flag_print_asm_name
= 1;
4786 graph_dump_format
= vcg
;
4792 rtl_dump_and_exit
= 1;
4794 case 'D': /* these are handled by the preprocessor */
4798 warning ("unrecognised gcc debugging option: %c", p
[-1]);
4802 else if (str
[0] == 'f')
4804 register char *p
= &str
[1];
4807 /* Some kind of -f option.
4808 P's value is the option sans `-f'.
4809 Search for it in the table of options. */
4812 !found
&& j
< sizeof (f_options
) / sizeof (f_options
[0]);
4815 if (!strcmp (p
, f_options
[j
].string
))
4817 *f_options
[j
].variable
= f_options
[j
].on_value
;
4818 /* A goto here would be cleaner,
4819 but breaks the vax pcc. */
4822 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
4823 && ! strcmp (p
+3, f_options
[j
].string
))
4825 *f_options
[j
].variable
= ! f_options
[j
].on_value
;
4833 #ifdef INSN_SCHEDULING
4834 else if (!strncmp (p
, "sched-verbose-",14))
4835 fix_sched_param("verbose",&p
[14]);
4838 else if (!strncmp (p
, "fixed-", 6))
4839 fix_register (&p
[6], 1, 1);
4840 else if (!strncmp (p
, "call-used-", 10))
4841 fix_register (&p
[10], 0, 1);
4842 else if (!strncmp (p
, "call-saved-", 11))
4843 fix_register (&p
[11], 0, 0);
4845 error ("Invalid option `%s'", argv
[i
]);
4847 else if (str
[0] == 'O')
4849 register char *p
= str
+1;
4853 while (*p
&& *p
>= '0' && *p
<= '9')
4858 error ("Invalid option `%s'", argv
[i
]);
4860 else if (!strcmp (str
, "pedantic"))
4862 else if (!strcmp (str
, "pedantic-errors"))
4863 flag_pedantic_errors
= pedantic
= 1;
4864 else if (!strcmp (str
, "quiet"))
4866 else if (!strcmp (str
, "version"))
4868 else if (!strcmp (str
, "w"))
4869 inhibit_warnings
= 1;
4870 else if (!strcmp (str
, "W"))
4873 /* We save the value of warn_uninitialized, since if they put
4874 -Wuninitialized on the command line, we need to generate a
4875 warning about not using it without also specifying -O. */
4876 if (warn_uninitialized
!= 1)
4877 warn_uninitialized
= 2;
4879 else if (str
[0] == 'W')
4881 register char *p
= &str
[1];
4884 /* Some kind of -W option.
4885 P's value is the option sans `-W'.
4886 Search for it in the table of options. */
4889 !found
&& j
< sizeof (W_options
) / sizeof (W_options
[0]);
4892 if (!strcmp (p
, W_options
[j
].string
))
4894 *W_options
[j
].variable
= W_options
[j
].on_value
;
4895 /* A goto here would be cleaner,
4896 but breaks the vax pcc. */
4899 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
4900 && ! strcmp (p
+3, W_options
[j
].string
))
4902 *W_options
[j
].variable
= ! W_options
[j
].on_value
;
4909 else if (!strncmp (p
, "id-clash-", 9))
4915 if (*endp
>= '0' && *endp
<= '9')
4919 error ("Invalid option `%s'", argv
[i
]);
4924 id_clash_len
= atoi (str
+ 10);
4927 else if (!strncmp (p
, "larger-than-", 12))
4929 char *endp
= p
+ 12;
4933 if (*endp
>= '0' && *endp
<= '9')
4937 error ("Invalid option `%s'", argv
[i
]);
4938 goto larger_than_lose
;
4941 warn_larger_than
= 1;
4942 larger_than_size
= atoi (str
+ 13);
4946 error ("Invalid option `%s'", argv
[i
]);
4948 else if (!strcmp (str
, "p"))
4952 else if (!strcmp (str
, "a"))
4954 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4955 warning ("`-a' option (basic block profile) not supported");
4957 profile_block_flag
= (profile_block_flag
< 2) ? 1 : 3;
4960 else if (!strcmp (str
, "ax"))
4962 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4963 warning ("`-ax' option (jump profiling) not supported");
4965 profile_block_flag
= (!profile_block_flag
4966 || profile_block_flag
== 2) ? 2 : 3;
4969 else if (str
[0] == 'g')
4973 /* A lot of code assumes write_symbols == NO_DEBUG if the
4974 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4975 of what debugging type has been selected). This records the
4976 selected type. It is an error to specify more than one
4978 static enum debug_info_type selected_debug_type
= NO_DEBUG
;
4979 /* Non-zero if debugging format has been explicitly set.
4980 -g and -ggdb don't explicitly set the debugging format so
4981 -gdwarf -g3 is equivalent to -gdwarf3. */
4982 static int type_explicitly_set_p
= 0;
4983 /* Indexed by enum debug_info_type. */
4984 static const char *debug_type_names
[] =
4986 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4989 /* Look up STR in the table. */
4990 for (da
= debug_args
; da
->arg
; da
++)
4992 if (! strncmp (str
, da
->arg
, strlen (da
->arg
)))
4994 enum debug_info_type type
= da
->debug_type
;
4997 p
= str
+ strlen (da
->arg
);
4998 if (*p
&& (*p
< '0' || *p
> '9'))
5002 while (*q
&& (*q
>= '0' && *q
<= '9'))
5007 if (len
> 1 && !strncmp (str
, "gdwarf", len
))
5009 error ("use -gdwarf -g%d for DWARF v1, level %d",
5012 error ("use -gdwarf-2 for DWARF v2");
5016 level
= 2; /* default debugging info level */
5017 if (*q
|| level
> 3)
5019 warning ("invalid debug level specification in option: `-%s'",
5021 /* ??? This error message is incorrect in the case of
5023 warning ("no debugging information will be generated");
5027 if (type
== NO_DEBUG
)
5029 type
= PREFERRED_DEBUGGING_TYPE
;
5030 if (len
> 1 && strncmp (str
, "ggdb", len
) == 0)
5032 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
5033 type
= DWARF2_DEBUG
;
5035 #ifdef DBX_DEBUGGING_INFO
5042 if (type
== NO_DEBUG
)
5043 warning ("`-%s' not supported by this configuration of GCC",
5046 /* Does it conflict with an already selected type? */
5047 if (type_explicitly_set_p
5048 /* -g/-ggdb don't conflict with anything */
5049 && da
->debug_type
!= NO_DEBUG
5050 && type
!= selected_debug_type
)
5051 warning ("`-%s' ignored, conflicts with `-g%s'",
5052 str
, debug_type_names
[(int) selected_debug_type
]);
5055 /* If the format has already been set, -g/-ggdb
5056 only change the debug level. */
5057 if (type_explicitly_set_p
5058 && da
->debug_type
== NO_DEBUG
)
5059 ; /* don't change debugging type */
5062 selected_debug_type
= type
;
5063 type_explicitly_set_p
= da
->debug_type
!= NO_DEBUG
;
5065 write_symbols
= (level
== 0
5067 : selected_debug_type
);
5068 use_gnu_debug_info_extensions
= da
->use_extensions_p
;
5069 debug_info_level
= (enum debug_info_level
) level
;
5075 warning ("`-%s' not supported by this configuration of GCC",
5078 else if (!strcmp (str
, "o"))
5080 asm_file_name
= argv
[++i
];
5082 else if (str
[0] == 'G')
5084 g_switch_set
= TRUE
;
5085 g_switch_value
= atoi ((str
[1] != '\0') ? str
+1 : argv
[++i
]);
5087 else if (!strncmp (str
, "aux-info", 8))
5089 flag_gen_aux_info
= 1;
5090 aux_info_file_name
= (str
[8] != '\0' ? str
+8 : argv
[++i
]);
5092 else if (!strcmp (str
, "-help"))
5098 error ("Invalid option `%s'", argv
[i
]);
5100 else if (argv
[i
][0] == '+')
5101 error ("Invalid option `%s'", argv
[i
]);
5106 /* Checker uses the frame pointer. */
5107 if (flag_check_memory_usage
)
5108 flag_omit_frame_pointer
= 0;
5112 /* Inlining does not work if not optimizing,
5113 so force it not to be done. */
5117 /* The c_decode_option and lang_decode_option functions set
5118 this to `2' if -Wall is used, so we can avoid giving out
5119 lots of errors for people who don't realize what -Wall does. */
5120 if (warn_uninitialized
== 1)
5121 warning ("-Wuninitialized is not supported without -O");
5124 #ifdef OVERRIDE_OPTIONS
5125 /* Some machines may reject certain combinations of options. */
5129 if (exceptions_via_longjmp
== 2)
5131 #ifdef DWARF2_UNWIND_INFO
5132 exceptions_via_longjmp
= ! DWARF2_UNWIND_INFO
;
5134 exceptions_via_longjmp
= 1;
5138 if (profile_block_flag
== 3)
5140 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
5141 profile_block_flag
= 2;
5144 /* Unrolling all loops implies that standard loop unrolling must also
5146 if (flag_unroll_all_loops
)
5147 flag_unroll_loops
= 1;
5148 /* Loop unrolling requires that strength_reduction be on also. Silently
5149 turn on strength reduction here if it isn't already on. Also, the loop
5150 unrolling code assumes that cse will be run after loop, so that must
5151 be turned on also. */
5152 if (flag_unroll_loops
)
5154 flag_strength_reduce
= 1;
5155 flag_rerun_cse_after_loop
= 1;
5158 /* Warn about options that are not supported on this machine. */
5159 #ifndef INSN_SCHEDULING
5160 if (flag_schedule_insns
|| flag_schedule_insns_after_reload
)
5161 warning ("instruction scheduling not supported on this target machine");
5164 if (flag_delayed_branch
)
5165 warning ("this target machine does not have delayed branches");
5168 user_label_prefix
= USER_LABEL_PREFIX
;
5169 if (flag_leading_underscore
!= -1)
5171 /* If the default prefix is more complicated than "" or "_",
5172 issue a warning and ignore this option. */
5173 if (user_label_prefix
[0] == 0 ||
5174 (user_label_prefix
[0] == '_' && user_label_prefix
[1] == 0))
5176 user_label_prefix
= flag_leading_underscore
? "_" : "";
5179 warning ("-f%sleading-underscore not supported on this target machine",
5180 flag_leading_underscore
? "" : "no-");
5183 /* If we are in verbose mode, write out the version and maybe all the
5184 option flags in use. */
5187 print_version (stderr
, "");
5189 print_switch_values (stderr
, 0, MAX_LINE
, "", " ", "\n");
5192 compile_file (filename
);
5194 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__))
5197 char *lim
= (char *) sbrk (0);
5199 fprintf (stderr
, "Data size %ld.\n", (long)(lim
- (char *) &environ
));
5204 system ("ps -l 1>&2");
5207 #endif /* not USG */
5210 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) */
5213 exit (FATAL_EXIT_CODE
);
5215 exit (FATAL_EXIT_CODE
);
5216 exit (SUCCESS_EXIT_CODE
);
5220 /* Decode -m switches. */
5221 /* Decode the switch -mNAME. */
5224 set_target_switch (name
)
5230 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
5231 if (!strcmp (target_switches
[j
].name
, name
))
5233 if (target_switches
[j
].value
< 0)
5234 target_flags
&= ~-target_switches
[j
].value
;
5236 target_flags
|= target_switches
[j
].value
;
5240 #ifdef TARGET_OPTIONS
5242 for (j
= 0; j
< sizeof target_options
/ sizeof target_options
[0]; j
++)
5244 int len
= strlen (target_options
[j
].prefix
);
5245 if (!strncmp (target_options
[j
].prefix
, name
, len
))
5247 *target_options
[j
].variable
= name
+ len
;
5254 error ("Invalid option `%s'", name
);
5257 /* Print version information to FILE.
5258 Each line begins with INDENT (for the case where FILE is the
5259 assembler output file). */
5262 print_version (file
, indent
)
5266 fprintf (file
, "%s%s%s version %s", indent
, *indent
!= 0 ? " " : "",
5267 language_string
, version_string
);
5268 fprintf (file
, " (%s)", TARGET_NAME
);
5271 #define __VERSION__ "[unknown]"
5273 fprintf (file
, " compiled by GNU C version %s.\n", __VERSION__
);
5275 fprintf (file
, " compiled by CC.\n");
5279 /* Print an option value and return the adjusted position in the line.
5280 ??? We don't handle error returns from fprintf (disk full); presumably
5281 other code will catch a disk full though. */
5284 print_single_switch (file
, pos
, max
, indent
, sep
, term
, type
, name
)
5287 const char *indent
, *sep
, *term
, *type
, *name
;
5289 /* The ultrix fprintf returns 0 on success, so compute the result we want
5290 here since we need it for the following test. */
5291 int len
= strlen (sep
) + strlen (type
) + strlen (name
);
5296 fprintf (file
, "%s", term
);
5301 fprintf (file
, "%s", indent
);
5302 pos
= strlen (indent
);
5304 fprintf (file
, "%s%s%s", sep
, type
, name
);
5309 /* Print active target switches to FILE.
5310 POS is the current cursor position and MAX is the size of a "line".
5311 Each line begins with INDENT and ends with TERM.
5312 Each switch is separated from the next by SEP. */
5315 print_switch_values (file
, pos
, max
, indent
, sep
, term
)
5318 const char *indent
, *sep
, *term
;
5323 /* Print the options as passed. */
5325 pos
= print_single_switch (file
, pos
, max
, indent
, *indent
? " " : "", term
,
5326 "options passed: ", "");
5328 for (p
= &save_argv
[1]; *p
!= NULL
; p
++)
5332 if (strcmp (*p
, "-o") == 0)
5338 if (strcmp (*p
, "-quiet") == 0)
5340 if (strcmp (*p
, "-version") == 0)
5345 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
, *p
, "");
5348 fprintf (file
, "%s", term
);
5350 /* Print the -f and -m options that have been enabled.
5351 We don't handle language specific options but printing argv
5354 pos
= print_single_switch (file
, 0, max
, indent
, *indent
? " " : "", term
,
5355 "options enabled: ", "");
5357 for (j
= 0; j
< sizeof f_options
/ sizeof f_options
[0]; j
++)
5358 if (*f_options
[j
].variable
== f_options
[j
].on_value
)
5359 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5360 "-f", f_options
[j
].string
);
5362 /* Print target specific options. */
5364 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
5365 if (target_switches
[j
].name
[0] != '\0'
5366 && target_switches
[j
].value
> 0
5367 && ((target_switches
[j
].value
& target_flags
)
5368 == target_switches
[j
].value
))
5370 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5371 "-m", target_switches
[j
].name
);
5374 #ifdef TARGET_OPTIONS
5375 for (j
= 0; j
< sizeof target_options
/ sizeof target_options
[0]; j
++)
5376 if (*target_options
[j
].variable
!= NULL
)
5379 sprintf (prefix
, "-m%s", target_options
[j
].prefix
);
5380 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5381 prefix
, *target_options
[j
].variable
);
5385 fprintf (file
, "%s", term
);
5388 /* Record the beginning of a new source file, named FILENAME. */
5391 debug_start_source_file (filename
)
5392 register char *filename
;
5394 #ifdef DBX_DEBUGGING_INFO
5395 if (write_symbols
== DBX_DEBUG
)
5396 dbxout_start_new_source_file (filename
);
5398 #ifdef DWARF_DEBUGGING_INFO
5399 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5400 && write_symbols
== DWARF_DEBUG
)
5401 dwarfout_start_new_source_file (filename
);
5402 #endif /* DWARF_DEBUGGING_INFO */
5403 #ifdef DWARF2_DEBUGGING_INFO
5404 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5405 && write_symbols
== DWARF2_DEBUG
)
5406 dwarf2out_start_source_file (filename
);
5407 #endif /* DWARF2_DEBUGGING_INFO */
5408 #ifdef SDB_DEBUGGING_INFO
5409 if (write_symbols
== SDB_DEBUG
)
5410 sdbout_start_new_source_file (filename
);
5414 /* Record the resumption of a source file. LINENO is the line number in
5415 the source file we are returning to. */
5418 debug_end_source_file (lineno
)
5419 register unsigned lineno ATTRIBUTE_UNUSED
;
5421 #ifdef DBX_DEBUGGING_INFO
5422 if (write_symbols
== DBX_DEBUG
)
5423 dbxout_resume_previous_source_file ();
5425 #ifdef DWARF_DEBUGGING_INFO
5426 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5427 && write_symbols
== DWARF_DEBUG
)
5428 dwarfout_resume_previous_source_file (lineno
);
5429 #endif /* DWARF_DEBUGGING_INFO */
5430 #ifdef DWARF2_DEBUGGING_INFO
5431 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5432 && write_symbols
== DWARF2_DEBUG
)
5433 dwarf2out_end_source_file ();
5434 #endif /* DWARF2_DEBUGGING_INFO */
5435 #ifdef SDB_DEBUGGING_INFO
5436 if (write_symbols
== SDB_DEBUG
)
5437 sdbout_resume_previous_source_file ();
5441 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5442 the tail part of the directive line, i.e. the part which is past the
5443 initial whitespace, #, whitespace, directive-name, whitespace part. */
5446 debug_define (lineno
, buffer
)
5447 register unsigned lineno
;
5448 register char *buffer
;
5450 #ifdef DWARF_DEBUGGING_INFO
5451 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5452 && write_symbols
== DWARF_DEBUG
)
5453 dwarfout_define (lineno
, buffer
);
5454 #endif /* DWARF_DEBUGGING_INFO */
5455 #ifdef DWARF2_DEBUGGING_INFO
5456 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5457 && write_symbols
== DWARF2_DEBUG
)
5458 dwarf2out_define (lineno
, buffer
);
5459 #endif /* DWARF2_DEBUGGING_INFO */
5462 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5463 the tail part of the directive line, i.e. the part which is past the
5464 initial whitespace, #, whitespace, directive-name, whitespace part. */
5467 debug_undef (lineno
, buffer
)
5468 register unsigned lineno
;
5469 register char *buffer
;
5471 #ifdef DWARF_DEBUGGING_INFO
5472 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5473 && write_symbols
== DWARF_DEBUG
)
5474 dwarfout_undef (lineno
, buffer
);
5475 #endif /* DWARF_DEBUGGING_INFO */
5476 #ifdef DWARF2_DEBUGGING_INFO
5477 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5478 && write_symbols
== DWARF2_DEBUG
)
5479 dwarf2out_undef (lineno
, buffer
);
5480 #endif /* DWARF2_DEBUGGING_INFO */