New testcase.
[official-gcc.git] / gcc / toplev.c
blobd63b0c25c806e92f46a40537185c8f7ed8b05f0d
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-7, 1998 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)
9 any later version.
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. */
26 #include "config.h"
27 #ifdef __STDC__
28 #include <stdarg.h>
29 #else
30 #include <varargs.h>
31 #endif
32 #undef FLOAT /* This is for hpux. They should change hpux. */
33 #undef FFS /* Some systems define this in param.h. */
34 #include "system.h"
35 #include <signal.h>
36 #include <setjmp.h>
37 #include <sys/stat.h>
39 #ifdef HAVE_SYS_RESOURCE_H
40 # include <sys/resource.h>
41 #endif
43 #ifdef HAVE_SYS_TIMES_H
44 # include <sys/times.h>
45 #endif
47 #include "input.h"
48 #include "tree.h"
49 #include "rtl.h"
50 #include "flags.h"
51 #include "insn-attr.h"
52 #include "insn-codes.h"
53 #include "insn-config.h"
54 #include "recog.h"
55 #include "defaults.h"
56 #include "output.h"
57 #include "except.h"
58 #include "toplev.h"
60 #ifdef DWARF_DEBUGGING_INFO
61 #include "dwarfout.h"
62 #endif
64 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
65 #include "dwarf2out.h"
66 #endif
68 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
69 #include "dbxout.h"
70 #endif
72 #ifdef SDB_DEBUGGING_INFO
73 #include "sdbout.h"
74 #endif
76 #ifdef XCOFF_DEBUGGING_INFO
77 #include "xcoffout.h"
78 #endif
80 #ifdef VMS
81 /* The extra parameters substantially improve the I/O performance. */
82 static FILE *
83 vms_fopen (fname, type)
84 char * fname;
85 char * type;
87 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
88 fixed arguments, which matches ANSI's specification but not VAXCRTL's
89 pre-ANSI implementation. This hack circumvents the mismatch problem. */
90 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
92 if (*type == 'w')
93 return (*vmslib_fopen) (fname, type, "mbc=32",
94 "deq=64", "fop=tef", "shr=nil");
95 else
96 return (*vmslib_fopen) (fname, type, "mbc=32");
98 #define fopen vms_fopen
99 #endif /* VMS */
101 #ifndef DEFAULT_GDB_EXTENSIONS
102 #define DEFAULT_GDB_EXTENSIONS 1
103 #endif
105 /* If more than one debugging type is supported, you must define
106 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
108 This is one long line cause VAXC can't handle a \-newline. */
109 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
110 #ifndef PREFERRED_DEBUGGING_TYPE
111 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
112 #endif /* no PREFERRED_DEBUGGING_TYPE */
113 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
114 so the following code needn't care. */
115 #ifdef DBX_DEBUGGING_INFO
116 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
117 #endif
118 #ifdef SDB_DEBUGGING_INFO
119 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
120 #endif
121 #ifdef DWARF_DEBUGGING_INFO
122 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
123 #endif
124 #ifdef DWARF2_DEBUGGING_INFO
125 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
126 #endif
127 #ifdef XCOFF_DEBUGGING_INFO
128 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
129 #endif
130 #endif /* More than one debugger format enabled. */
132 /* If still not defined, must have been because no debugging formats
133 are supported. */
134 #ifndef PREFERRED_DEBUGGING_TYPE
135 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
136 #endif
138 extern int rtx_equal_function_value_matters;
140 #if ! (defined (VMS) || defined (OS2))
141 extern char **environ;
142 #endif
143 extern char *version_string, *language_string;
145 /* Carry information from ASM_DECLARE_OBJECT_NAME
146 to ASM_FINISH_DECLARE_OBJECT. */
148 extern int size_directive_output;
149 extern tree last_assemble_variable_decl;
151 extern char *init_parse PVPROTO((char *));
152 extern void finish_parse ();
153 extern void init_decl_processing ();
154 extern void init_obstacks ();
155 extern void init_tree_codes ();
156 extern void init_rtl ();
157 extern void init_regs ();
158 extern void init_optabs ();
159 extern void init_stmt ();
160 extern void init_reg_sets ();
161 extern void dump_flow_info ();
162 extern void dump_sched_info ();
163 extern void dump_local_alloc ();
164 extern void regset_release_memory ();
166 extern void print_rtl ();
167 extern void print_rtl_with_bb ();
169 void rest_of_decl_compilation ();
170 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
171 void error_with_decl PVPROTO((tree decl, char *s, ...));
172 void error PVPROTO((char *s, ...));
173 void fatal PVPROTO((char *s, ...));
174 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
175 void warning_with_decl PVPROTO((tree decl, char *s, ...));
176 void warning PVPROTO((char *s, ...));
177 void pedwarn PVPROTO((char *s, ...));
178 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
179 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
180 void sorry PVPROTO((char *s, ...));
181 void really_sorry PVPROTO((char *s, ...));
182 void fancy_abort ();
183 void set_target_switch ();
184 static char *decl_name PROTO((tree, int));
185 static void vmessage PROTO((char *, char *, va_list));
186 static void v_message_with_file_and_line PROTO((char *, int, char *,
187 char *, va_list));
188 static void v_message_with_decl PROTO((tree, char *, char *, va_list));
189 static void file_and_line_for_asm PROTO((rtx, char **, int *));
190 static void v_error_with_file_and_line PROTO((char *, int, char *, va_list));
191 static void v_error_with_decl PROTO((tree, char *, va_list));
192 static void v_error_for_asm PROTO((rtx, char *, va_list));
193 static void verror PROTO((char *, va_list));
194 static void vfatal PROTO((char *, va_list));
195 static void v_warning_with_file_and_line PROTO ((char *, int, char *, va_list));
196 static void v_warning_with_decl PROTO((tree, char *, va_list));
197 static void v_warning_for_asm PROTO((rtx, char *, va_list));
198 static void vwarning PROTO((char *, va_list));
199 static void vpedwarn PROTO((char *, va_list));
200 static void v_pedwarn_with_decl PROTO((tree, char *, va_list));
201 static void v_pedwarn_with_file_and_line PROTO((char *, int, char *, va_list));
202 static void vsorry PROTO((char *, va_list));
203 static void v_really_sorry PROTO((char *, va_list));
204 static void float_signal PROTO((int));
205 static void pipe_closed PROTO((int));
206 static void output_lang_identify PROTO((FILE *));
207 static void open_dump_file PROTO((char *, char *));
208 static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
209 static void dump_rtl PROTO((char *, tree, void (*) (FILE *, rtx), rtx));
210 static void clean_dump_file PROTO((char *));
211 static void compile_file PROTO((char *));
213 void print_version ();
214 int print_single_switch ();
215 void print_switch_values ();
216 /* Length of line when printing switch values. */
217 #define MAX_LINE 75
219 /* Name of program invoked, sans directories. */
221 char *progname;
223 /* Copy of arguments to main. */
224 int save_argc;
225 char **save_argv;
227 /* Name of current original source file (what was input to cpp).
228 This comes from each #-command in the actual input. */
230 char *input_filename;
232 /* Name of top-level original source file (what was input to cpp).
233 This comes from the #-command at the beginning of the actual input.
234 If there isn't any there, then this is the cc1 input file name. */
236 char *main_input_filename;
238 /* Current line number in real source file. */
240 int lineno;
242 /* Stack of currently pending input files. */
244 struct file_stack *input_file_stack;
246 /* Incremented on each change to input_file_stack. */
247 int input_file_stack_tick;
249 /* FUNCTION_DECL for function now being parsed or compiled. */
251 extern tree current_function_decl;
253 /* Name to use as base of names for dump output files. */
255 char *dump_base_name;
257 /* Bit flags that specify the machine subtype we are compiling for.
258 Bits are tested using macros TARGET_... defined in the tm.h file
259 and set by `-m...' switches. Must be defined in rtlanal.c. */
261 extern int target_flags;
263 /* Flags saying which kinds of debugging dump have been requested. */
265 int rtl_dump = 0;
266 int rtl_dump_and_exit = 0;
267 int jump_opt_dump = 0;
268 int addressof_dump = 0;
269 int cse_dump = 0;
270 int gcse_dump = 0;
271 int loop_dump = 0;
272 int cse2_dump = 0;
273 int branch_prob_dump = 0;
274 int flow_dump = 0;
275 int combine_dump = 0;
276 int regmove_dump = 0;
277 int sched_dump = 0;
278 int local_reg_dump = 0;
279 int global_reg_dump = 0;
280 int sched2_dump = 0;
281 int jump2_opt_dump = 0;
282 #ifdef DELAY_SLOTS
283 int dbr_sched_dump = 0;
284 #endif
285 int flag_print_asm_name = 0;
286 #ifdef STACK_REGS
287 int stack_reg_dump = 0;
288 #endif
289 #ifdef MACHINE_DEPENDENT_REORG
290 int mach_dep_reorg_dump = 0;
291 #endif
293 /* Name for output file of assembly code, specified with -o. */
295 char *asm_file_name;
297 /* Value of the -G xx switch, and whether it was passed or not. */
298 int g_switch_value;
299 int g_switch_set;
301 /* Type(s) of debugging information we are producing (if any).
302 See flags.h for the definitions of the different possible
303 types of debugging information. */
304 enum debug_info_type write_symbols = NO_DEBUG;
306 /* Level of debugging information we are producing. See flags.h
307 for the definitions of the different possible levels. */
308 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
310 /* Nonzero means use GNU-only extensions in the generated symbolic
311 debugging information. */
312 /* Currently, this only has an effect when write_symbols is set to
313 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
314 int use_gnu_debug_info_extensions = 0;
316 /* Nonzero means do optimizations. -O.
317 Particular numeric values stand for particular amounts of optimization;
318 thus, -O2 stores 2 here. However, the optimizations beyond the basic
319 ones are not controlled directly by this variable. Instead, they are
320 controlled by individual `flag_...' variables that are defaulted
321 based on this variable. */
323 int optimize = 0;
325 /* Nonzero means optimize for size. -Os.
326 The only valid values are zero and non-zero. When optimize_size is
327 non-zero, optimize defaults to 2, but certain individual code
328 bloating optimizations are disabled. */
330 int optimize_size = 0;
332 /* Number of error messages and warning messages so far. */
334 int errorcount = 0;
335 int warningcount = 0;
336 int sorrycount = 0;
338 /* Pointer to function to compute the name to use to print a declaration.
339 DECL is the declaration in question.
340 VERBOSITY determines what information will be printed:
341 0: DECL_NAME, demangled as necessary.
342 1: and scope information.
343 2: and any other information that might be interesting, such as function
344 parameter types in C++. */
346 char *(*decl_printable_name) (/* tree decl, int verbosity */);
348 /* Pointer to function to compute rtl for a language-specific tree code. */
350 struct rtx_def *(*lang_expand_expr) ();
352 /* Pointer to function to finish handling an incomplete decl at the
353 end of compilation. */
355 void (*incomplete_decl_finalize_hook) () = 0;
357 /* Highest label number used at the end of reload. */
359 int max_label_num_after_reload;
361 /* Nonzero if generating code to do profiling. */
363 int profile_flag = 0;
365 /* Nonzero if generating code to do profiling on a line-by-line basis. */
367 int profile_block_flag;
369 /* Nonzero if generating code to profile program flow graph arcs. */
371 int profile_arc_flag = 0;
373 /* Nonzero if generating info for gcov to calculate line test coverage. */
375 int flag_test_coverage = 0;
377 /* Nonzero indicates that branch taken probabilities should be calculated. */
379 int flag_branch_probabilities = 0;
381 /* Nonzero for -pedantic switch: warn about anything
382 that standard spec forbids. */
384 int pedantic = 0;
386 /* Temporarily suppress certain warnings.
387 This is set while reading code from a system header file. */
389 int in_system_header = 0;
391 /* Nonzero means do stupid register allocation.
392 Currently, this is 1 if `optimize' is 0. */
394 int obey_regdecls = 0;
396 /* Don't print functions as they are compiled and don't print
397 times taken by the various passes. -quiet. */
399 int quiet_flag = 0;
401 /* -f flags. */
403 /* Nonzero means `char' should be signed. */
405 int flag_signed_char;
407 /* Nonzero means give an enum type only as many bytes as it needs. */
409 int flag_short_enums;
411 /* Nonzero for -fcaller-saves: allocate values in regs that need to
412 be saved across function calls, if that produces overall better code.
413 Optional now, so people can test it. */
415 #ifdef DEFAULT_CALLER_SAVES
416 int flag_caller_saves = 1;
417 #else
418 int flag_caller_saves = 0;
419 #endif
421 /* Nonzero if structures and unions should be returned in memory.
423 This should only be defined if compatibility with another compiler or
424 with an ABI is needed, because it results in slower code. */
426 #ifndef DEFAULT_PCC_STRUCT_RETURN
427 #define DEFAULT_PCC_STRUCT_RETURN 1
428 #endif
430 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
432 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
434 /* Nonzero for -fforce-mem: load memory value into a register
435 before arithmetic on it. This makes better cse but slower compilation. */
437 int flag_force_mem = 0;
439 /* Nonzero for -fforce-addr: load memory address into a register before
440 reference to memory. This makes better cse but slower compilation. */
442 int flag_force_addr = 0;
444 /* Nonzero for -fdefer-pop: don't pop args after each function call;
445 instead save them up to pop many calls' args with one insns. */
447 int flag_defer_pop = 0;
449 /* Nonzero for -ffloat-store: don't allocate floats and doubles
450 in extended-precision registers. */
452 int flag_float_store = 0;
454 /* Nonzero for -fcse-follow-jumps:
455 have cse follow jumps to do a more extensive job. */
457 int flag_cse_follow_jumps;
459 /* Nonzero for -fcse-skip-blocks:
460 have cse follow a branch around a block. */
461 int flag_cse_skip_blocks;
463 /* Nonzero for -fexpensive-optimizations:
464 perform miscellaneous relatively-expensive optimizations. */
465 int flag_expensive_optimizations;
467 /* Nonzero for -fthread-jumps:
468 have jump optimize output of loop. */
470 int flag_thread_jumps;
472 /* Nonzero enables strength-reduction in loop.c. */
474 int flag_strength_reduce = 0;
476 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
477 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
478 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
479 unrolled. */
481 int flag_unroll_loops;
483 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
484 This is generally not a win. */
486 int flag_unroll_all_loops;
488 /* Nonzero forces all invariant computations in loops to be moved
489 outside the loop. */
491 int flag_move_all_movables = 0;
493 /* Nonzero forces all general induction variables in loops to be
494 strength reduced. */
496 int flag_reduce_all_givs = 0;
498 /* Nonzero to perform full register move optimization passes. This is the
499 default for -O2. */
501 int flag_regmove = 0;
503 /* Nonzero for -fwritable-strings:
504 store string constants in data segment and don't uniquize them. */
506 int flag_writable_strings = 0;
508 /* Nonzero means don't put addresses of constant functions in registers.
509 Used for compiling the Unix kernel, where strange substitutions are
510 done on the assembly output. */
512 int flag_no_function_cse = 0;
514 /* Nonzero for -fomit-frame-pointer:
515 don't make a frame pointer in simple functions that don't require one. */
517 int flag_omit_frame_pointer = 0;
519 /* Nonzero means place each function into its own section on those platforms
520 which support arbitrary section names and unlimited numbers of sections. */
522 int flag_function_sections = 0;
524 /* Nonzero to inhibit use of define_optimization peephole opts. */
526 int flag_no_peephole = 0;
528 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
529 operations in the interest of optimization. For example it allows
530 GCC to assume arguments to sqrt are nonnegative numbers, allowing
531 faster code for sqrt to be generated. */
533 int flag_fast_math = 0;
535 /* Nonzero means all references through pointers are volatile. */
537 int flag_volatile;
539 /* Nonzero means treat all global and extern variables as global. */
541 int flag_volatile_global;
543 /* Nonzero means just do syntax checking; don't output anything. */
545 int flag_syntax_only = 0;
547 /* Nonzero means perform global cse. */
549 static int flag_gcse;
551 /* Nonzero means to rerun cse after loop optimization. This increases
552 compilation time about 20% and picks up a few more common expressions. */
554 static int flag_rerun_cse_after_loop;
556 /* Nonzero means to run loop optimizations twice. */
558 int flag_rerun_loop_opt;
560 /* Nonzero for -finline-functions: ok to inline functions that look like
561 good inline candidates. */
563 int flag_inline_functions;
565 /* Nonzero for -fkeep-inline-functions: even if we make a function
566 go inline everywhere, keep its definition around for debugging
567 purposes. */
569 int flag_keep_inline_functions;
571 /* Nonzero means that functions will not be inlined. */
573 int flag_no_inline;
575 /* Nonzero means that we should emit static const variables
576 regardless of whether or not optimization is turned on. */
578 int flag_keep_static_consts = 1;
580 /* Nonzero means we should be saving declaration info into a .X file. */
582 int flag_gen_aux_info = 0;
584 /* Specified name of aux-info file. */
586 static char *aux_info_file_name;
588 /* Nonzero means make the text shared if supported. */
590 int flag_shared_data;
592 /* Nonzero means schedule into delayed branch slots if supported. */
594 int flag_delayed_branch;
596 /* Nonzero if we are compiling pure (sharable) code.
597 Value is 1 if we are doing reasonable (i.e. simple
598 offset into offset table) pic. Value is 2 if we can
599 only perform register offsets. */
601 int flag_pic;
603 /* Nonzero means generate extra code for exception handling and enable
604 exception handling. */
606 int flag_exceptions;
608 /* Nonzero means use the new model for exception handling. Replaces
609 -DNEW_EH_MODEL as a compile option. */
611 int flag_new_exceptions = 0;
613 /* Nonzero means don't place uninitialized global data in common storage
614 by default. */
616 int flag_no_common;
618 /* Nonzero means pretend it is OK to examine bits of target floats,
619 even if that isn't true. The resulting code will have incorrect constants,
620 but the same series of instructions that the native compiler would make. */
622 int flag_pretend_float;
624 /* Nonzero means change certain warnings into errors.
625 Usually these are warnings about failure to conform to some standard. */
627 int flag_pedantic_errors = 0;
629 /* flag_schedule_insns means schedule insns within basic blocks (before
630 local_alloc).
631 flag_schedule_insns_after_reload means schedule insns after
632 global_alloc. */
634 int flag_schedule_insns = 0;
635 int flag_schedule_insns_after_reload = 0;
637 #ifdef HAIFA
638 /* The following flags have effect only for scheduling before register
639 allocation:
641 flag_schedule_interblock means schedule insns accross basic blocks.
642 flag_schedule_speculative means allow speculative motion of non-load insns.
643 flag_schedule_speculative_load means allow speculative motion of some
644 load insns.
645 flag_schedule_speculative_load_dangerous allows speculative motion of more
646 load insns. */
648 int flag_schedule_interblock = 1;
649 int flag_schedule_speculative = 1;
650 int flag_schedule_speculative_load = 0;
651 int flag_schedule_speculative_load_dangerous = 0;
653 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
654 by a cheaper branch, on a count register. */
655 int flag_branch_on_count_reg;
656 #endif /* HAIFA */
659 /* -finhibit-size-directive inhibits output of .size for ELF.
660 This is used only for compiling crtstuff.c,
661 and it may be extended to other effects
662 needed for crtstuff.c on other systems. */
663 int flag_inhibit_size_directive = 0;
665 /* -fverbose-asm causes extra commentary information to be produced in
666 the generated assembly code (to make it more readable). This option
667 is generally only of use to those who actually need to read the
668 generated assembly code (perhaps while debugging the compiler itself).
669 -fno-verbose-asm, the default, causes the extra information
670 to be omitted and is useful when comparing two assembler files. */
672 int flag_verbose_asm = 0;
674 /* -dA causes debug commentary information to be produced in
675 the generated assembly code (to make it more readable). This option
676 is generally only of use to those who actually need to read the
677 generated assembly code (perhaps while debugging the compiler itself).
678 Currently, this switch is only used by dwarfout.c; however, it is intended
679 to be a catchall for printing debug information in the assembler file. */
681 int flag_debug_asm = 0;
683 /* -fgnu-linker specifies use of the GNU linker for initializations.
684 (Or, more generally, a linker that handles initializations.)
685 -fno-gnu-linker says that collect2 will be used. */
686 #ifdef USE_COLLECT2
687 int flag_gnu_linker = 0;
688 #else
689 int flag_gnu_linker = 1;
690 #endif
692 /* Tag all structures with __attribute__(packed) */
693 int flag_pack_struct = 0;
695 /* Emit code to check for stack overflow; also may cause large objects
696 to be allocated dynamically. */
697 int flag_stack_check;
699 /* -fcheck-memory-usage causes extra code to be generated in order to check
700 memory accesses. This is used by a detector of bad memory accesses such
701 as Checker. */
702 int flag_check_memory_usage = 0;
704 /* -fprefix-function-name causes function name to be prefixed. This
705 can be used with -fcheck-memory-usage to isolate code compiled with
706 -fcheck-memory-usage. */
707 int flag_prefix_function_name = 0;
709 /* 0 if pointer arguments may alias each other. True in C.
710 1 if pointer arguments may not alias each other but may alias
711 global variables.
712 2 if pointer arguments may not alias each other and may not
713 alias global variables. True in Fortran.
714 This defaults to 0 for C. */
715 int flag_argument_noalias = 0;
717 /* Nonzero if we should do (language-dependent) alias analysis.
718 Typically, this analysis will assume that expressions of certain
719 types do not alias expressions of certain other types. Only used
720 if alias analysis (in general) is enabled. */
721 int flag_strict_aliasing = 0;
723 extern int flag_dump_unnumbered;
725 /* Table of language-independent -f options.
726 STRING is the option name. VARIABLE is the address of the variable.
727 ON_VALUE is the value to store in VARIABLE
728 if `-fSTRING' is seen as an option.
729 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
731 struct { char *string; int *variable; int on_value;} f_options[] =
733 {"float-store", &flag_float_store, 1},
734 {"volatile", &flag_volatile, 1},
735 {"volatile-global", &flag_volatile_global, 1},
736 {"defer-pop", &flag_defer_pop, 1},
737 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
738 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
739 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
740 {"expensive-optimizations", &flag_expensive_optimizations, 1},
741 {"thread-jumps", &flag_thread_jumps, 1},
742 {"strength-reduce", &flag_strength_reduce, 1},
743 {"unroll-loops", &flag_unroll_loops, 1},
744 {"unroll-all-loops", &flag_unroll_all_loops, 1},
745 {"move-all-movables", &flag_move_all_movables, 1},
746 {"reduce-all-givs", &flag_reduce_all_givs, 1},
747 {"writable-strings", &flag_writable_strings, 1},
748 {"peephole", &flag_no_peephole, 0},
749 {"force-mem", &flag_force_mem, 1},
750 {"force-addr", &flag_force_addr, 1},
751 {"function-cse", &flag_no_function_cse, 0},
752 {"inline-functions", &flag_inline_functions, 1},
753 {"keep-inline-functions", &flag_keep_inline_functions, 1},
754 {"inline", &flag_no_inline, 0},
755 {"keep-static-consts", &flag_keep_static_consts, 1},
756 {"syntax-only", &flag_syntax_only, 1},
757 {"shared-data", &flag_shared_data, 1},
758 {"caller-saves", &flag_caller_saves, 1},
759 {"pcc-struct-return", &flag_pcc_struct_return, 1},
760 {"reg-struct-return", &flag_pcc_struct_return, 0},
761 {"delayed-branch", &flag_delayed_branch, 1},
762 {"gcse", &flag_gcse, 1},
763 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
764 {"rerun-loop-opt", &flag_rerun_loop_opt, 1},
765 {"pretend-float", &flag_pretend_float, 1},
766 {"schedule-insns", &flag_schedule_insns, 1},
767 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
768 #ifdef HAIFA
769 {"sched-interblock",&flag_schedule_interblock, 1},
770 {"sched-spec",&flag_schedule_speculative, 1},
771 {"sched-spec-load",&flag_schedule_speculative_load, 1},
772 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1},
773 {"branch-count-reg",&flag_branch_on_count_reg, 1},
774 #endif /* HAIFA */
775 {"pic", &flag_pic, 1},
776 {"PIC", &flag_pic, 2},
777 {"exceptions", &flag_exceptions, 1},
778 {"new-exceptions", &flag_new_exceptions, 1},
779 {"sjlj-exceptions", &exceptions_via_longjmp, 1},
780 {"asynchronous-exceptions", &asynchronous_exceptions, 1},
781 {"profile-arcs", &profile_arc_flag, 1},
782 {"test-coverage", &flag_test_coverage, 1},
783 {"branch-probabilities", &flag_branch_probabilities, 1},
784 {"fast-math", &flag_fast_math, 1},
785 {"common", &flag_no_common, 0},
786 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
787 {"function-sections", &flag_function_sections, 1},
788 {"verbose-asm", &flag_verbose_asm, 1},
789 {"gnu-linker", &flag_gnu_linker, 1},
790 {"regmove", &flag_regmove, 1},
791 {"optimize-register-move", &flag_regmove, 1},
792 {"pack-struct", &flag_pack_struct, 1},
793 {"stack-check", &flag_stack_check, 1},
794 {"argument-alias", &flag_argument_noalias, 0},
795 {"argument-noalias", &flag_argument_noalias, 1},
796 {"argument-noalias-global", &flag_argument_noalias, 2},
797 {"strict-aliasing", &flag_strict_aliasing, 1},
798 {"check-memory-usage", &flag_check_memory_usage, 1},
799 {"prefix-function-name", &flag_prefix_function_name, 1},
800 {"dump-unnumbered", &flag_dump_unnumbered, 1}
803 /* Table of language-specific options. */
805 char *lang_options[] =
807 "-ansi",
808 "-fallow-single-precision",
810 "-fsigned-bitfields",
811 "-funsigned-bitfields",
812 "-fno-signed-bitfields",
813 "-fno-unsigned-bitfields",
814 "-fsigned-char",
815 "-funsigned-char",
816 "-fno-signed-char",
817 "-fno-unsigned-char",
819 "-ftraditional",
820 "-traditional",
821 "-fnotraditional",
822 "-fno-traditional",
824 "-fasm",
825 "-fno-asm",
826 "-fbuiltin",
827 "-fno-builtin",
828 "-fhosted",
829 "-fno-hosted",
830 "-ffreestanding",
831 "-fno-freestanding",
832 "-fcond-mismatch",
833 "-fno-cond-mismatch",
834 "-fdollars-in-identifiers",
835 "-fno-dollars-in-identifiers",
836 "-fident",
837 "-fno-ident",
838 "-fshort-double",
839 "-fno-short-double",
840 "-fshort-enums",
841 "-fno-short-enums",
843 "-Wall",
844 "-Wbad-function-cast",
845 "-Wno-bad-function-cast",
846 "-Wcast-qual",
847 "-Wno-cast-qual",
848 "-Wchar-subscripts",
849 "-Wno-char-subscripts",
850 "-Wcomment",
851 "-Wno-comment",
852 "-Wcomments",
853 "-Wno-comments",
854 "-Wconversion",
855 "-Wno-conversion",
856 "-Wformat",
857 "-Wno-format",
858 "-Wimport",
859 "-Wno-import",
860 "-Wimplicit-function-declaration",
861 "-Wno-implicit-function-declaration",
862 "-Werror-implicit-function-declaration",
863 "-Wimplicit-int",
864 "-Wno-implicit-int",
865 "-Wimplicit",
866 "-Wno-implicit",
867 "-Wlong-long",
868 "-Wno-long-long",
869 "-Wmain",
870 "-Wno-main",
871 "-Wmissing-braces",
872 "-Wno-missing-braces",
873 "-Wmissing-declarations",
874 "-Wno-missing-declarations",
875 "-Wmissing-prototypes",
876 "-Wno-missing-prototypes",
877 "-Wmultichar",
878 "-Wno-multichar",
879 "-Wnested-externs",
880 "-Wno-nested-externs",
881 "-Wparentheses",
882 "-Wno-parentheses",
883 "-Wpointer-arith",
884 "-Wno-pointer-arith",
885 "-Wredundant-decls",
886 "-Wno-redundant-decls",
887 "-Wsign-compare",
888 "-Wno-sign-compare",
889 "-Wunknown-pragmas",
890 "-Wno-unknown-pragmas",
891 "-Wstrict-prototypes",
892 "-Wno-strict-prototypes",
893 "-Wtraditional",
894 "-Wno-traditional",
895 "-Wtrigraphs",
896 "-Wno-trigraphs",
897 "-Wundef",
898 "-Wno-undef",
899 "-Wwrite-strings",
900 "-Wno-write-strings",
902 /* these are for obj c */
903 "-lang-objc",
904 "-gen-decls",
905 "-fgnu-runtime",
906 "-fno-gnu-runtime",
907 "-fnext-runtime",
908 "-fno-next-runtime",
909 "-Wselector",
910 "-Wno-selector",
911 "-Wprotocol",
912 "-Wno-protocol",
913 "-print-objc-runtime-info",
915 /* These are for languages with USE_CPPLIB. */
916 "-A",
917 "-D",
918 "-I",
919 "-U",
920 "-idirafter",
921 "-iprefix",
922 "-isystem",
923 "-lang-c",
924 "-lang-c89",
925 "-lang-c++",
926 "-nostdinc",
927 "-nostdinc++",
928 "-trigraphs",
929 "-undef",
930 "-remap",
932 #include "options.h"
936 /* Options controlling warnings */
938 /* Don't print warning messages. -w. */
940 int inhibit_warnings = 0;
942 /* Print various extra warnings. -W. */
944 int extra_warnings = 0;
946 /* Treat warnings as errors. -Werror. */
948 int warnings_are_errors = 0;
950 /* Nonzero to warn about unused local variables. */
952 int warn_unused;
954 /* Nonzero to warn about variables used before they are initialized. */
956 int warn_uninitialized;
958 /* Nonzero means warn about all declarations which shadow others. */
960 int warn_shadow;
962 /* Warn if a switch on an enum fails to have a case for every enum value. */
964 int warn_switch;
966 /* Nonzero means warn about function definitions that default the return type
967 or that use a null return and have a return-type other than void. */
969 int warn_return_type;
971 /* Nonzero means warn about pointer casts that increase the required
972 alignment of the target type (and might therefore lead to a crash
973 due to a misaligned access). */
975 int warn_cast_align;
977 /* Nonzero means warn about any identifiers that match in the first N
978 characters. The value N is in `id_clash_len'. */
980 int warn_id_clash;
981 unsigned id_clash_len;
983 /* Nonzero means warn about any objects definitions whose size is larger
984 than N bytes. Also want about function definitions whose returned
985 values are larger than N bytes. The value N is in `larger_than_size'. */
987 int warn_larger_than;
988 unsigned larger_than_size;
990 /* Nonzero means warn if inline function is too large. */
992 int warn_inline;
994 /* Warn if a function returns an aggregate,
995 since there are often incompatible calling conventions for doing this. */
997 int warn_aggregate_return;
999 /* Likewise for -W. */
1001 struct { char *string; int *variable; int on_value;} W_options[] =
1003 {"unused", &warn_unused, 1},
1004 {"error", &warnings_are_errors, 1},
1005 {"shadow", &warn_shadow, 1},
1006 {"switch", &warn_switch, 1},
1007 {"aggregate-return", &warn_aggregate_return, 1},
1008 {"cast-align", &warn_cast_align, 1},
1009 {"uninitialized", &warn_uninitialized, 1},
1010 {"inline", &warn_inline, 1}
1013 /* Output files for assembler code (real compiler output)
1014 and debugging dumps. */
1016 FILE *asm_out_file;
1017 FILE *aux_info_file;
1018 FILE *rtl_dump_file = NULL;
1020 /* Time accumulators, to count the total time spent in various passes. */
1022 int parse_time;
1023 int varconst_time;
1024 int integration_time;
1025 int jump_time;
1026 int cse_time;
1027 int gcse_time;
1028 int loop_time;
1029 int cse2_time;
1030 int branch_prob_time;
1031 int flow_time;
1032 int combine_time;
1033 int regmove_time;
1034 int sched_time;
1035 int local_alloc_time;
1036 int global_alloc_time;
1037 int sched2_time;
1038 #ifdef DELAY_SLOTS
1039 int dbr_sched_time;
1040 #endif
1041 int shorten_branch_time;
1042 int stack_reg_time;
1043 int final_time;
1044 int symout_time;
1045 int dump_time;
1047 /* Return time used so far, in microseconds. */
1050 get_run_time ()
1052 if (quiet_flag)
1053 return 0;
1055 #ifdef __BEOS__
1056 return 0;
1057 #else /* not BeOS */
1058 #if defined (_WIN32) && !defined (__CYGWIN32__)
1059 if (clock() < 0)
1060 return 0;
1061 else
1062 return (clock() * 1000);
1063 #else /* not _WIN32 */
1064 #ifdef _SC_CLK_TCK
1066 static int tick;
1067 struct tms tms;
1068 if (tick == 0)
1069 tick = 1000000 / sysconf(_SC_CLK_TCK);
1070 times (&tms);
1071 return (tms.tms_utime + tms.tms_stime) * tick;
1073 #else
1074 #ifdef USG
1076 struct tms tms;
1077 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1078 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1079 # else
1080 # ifdef CLK_TCK
1081 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1082 # else
1083 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1084 # endif
1085 # endif
1086 times (&tms);
1087 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1089 #else
1090 #ifndef VMS
1092 struct rusage rusage;
1093 getrusage (0, &rusage);
1094 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1095 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1097 #else /* VMS */
1099 struct
1101 int proc_user_time;
1102 int proc_system_time;
1103 int child_user_time;
1104 int child_system_time;
1105 } vms_times;
1106 times ((void *) &vms_times);
1107 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1109 #endif /* VMS */
1110 #endif /* USG */
1111 #endif /* _SC_CLK_TCK */
1112 #endif /* _WIN32 */
1113 #endif /* __BEOS__ */
1116 #define TIMEVAR(VAR, BODY) \
1117 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1119 void
1120 print_time (str, total)
1121 char *str;
1122 int total;
1124 fprintf (stderr,
1125 "time in %s: %d.%06d\n",
1126 str, total / 1000000, total % 1000000);
1129 /* Count an error or warning. Return 1 if the message should be printed. */
1132 count_error (warningp)
1133 int warningp;
1135 if (warningp && inhibit_warnings)
1136 return 0;
1138 if (warningp && !warnings_are_errors)
1139 warningcount++;
1140 else
1142 static int warning_message = 0;
1144 if (warningp && !warning_message)
1146 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
1147 warning_message = 1;
1149 errorcount++;
1152 return 1;
1155 /* Print a fatal error message. NAME is the text.
1156 Also include a system error message based on `errno'. */
1158 void
1159 pfatal_with_name (name)
1160 char *name;
1162 fprintf (stderr, "%s: ", progname);
1163 perror (name);
1164 exit (FATAL_EXIT_CODE);
1167 void
1168 fatal_io_error (name)
1169 char *name;
1171 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
1172 exit (FATAL_EXIT_CODE);
1175 /* Called to give a better error message for a bad insn rather than
1176 just calling abort(). */
1178 void
1179 fatal_insn (message, insn)
1180 char *message;
1181 rtx insn;
1183 error (message);
1184 debug_rtx (insn);
1185 if (asm_out_file)
1186 fflush (asm_out_file);
1187 if (aux_info_file)
1188 fflush (aux_info_file);
1189 if (rtl_dump_file != NULL)
1190 fflush (rtl_dump_file);
1191 fflush (stdout);
1192 fflush (stderr);
1193 abort ();
1196 /* Called to give a better error message when we don't have an insn to match
1197 what we are looking for or if the insn's constraints aren't satisfied,
1198 rather than just calling abort(). */
1200 void
1201 fatal_insn_not_found (insn)
1202 rtx insn;
1204 if (INSN_CODE (insn) < 0)
1205 fatal_insn ("internal error--unrecognizable insn:", insn);
1206 else
1207 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1210 /* This is the default decl_printable_name function. */
1212 static char *
1213 decl_name (decl, verbosity)
1214 tree decl;
1215 int verbosity;
1217 return IDENTIFIER_POINTER (DECL_NAME (decl));
1220 static int need_error_newline;
1222 /* Function of last error message;
1223 more generally, function such that if next error message is in it
1224 then we don't have to mention the function name. */
1225 static tree last_error_function = NULL;
1227 /* Used to detect when input_file_stack has changed since last described. */
1228 static int last_error_tick;
1230 /* Called when the start of a function definition is parsed,
1231 this function prints on stderr the name of the function. */
1233 void
1234 announce_function (decl)
1235 tree decl;
1237 if (! quiet_flag)
1239 if (rtl_dump_and_exit)
1240 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1241 else
1242 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1243 fflush (stderr);
1244 need_error_newline = 1;
1245 last_error_function = current_function_decl;
1249 /* The default function to print out name of current function that caused
1250 an error. */
1252 void
1253 default_print_error_function (file)
1254 char *file;
1256 if (last_error_function != current_function_decl)
1258 char *kind = "function";
1259 if (current_function_decl != 0
1260 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1261 kind = "method";
1263 if (file)
1264 fprintf (stderr, "%s: ", file);
1266 if (current_function_decl == NULL)
1267 fprintf (stderr, "At top level:\n");
1268 else
1270 char *name = (*decl_printable_name) (current_function_decl, 2);
1271 fprintf (stderr, "In %s `%s':\n", kind, name);
1274 last_error_function = current_function_decl;
1278 /* Called by report_error_function to print out function name.
1279 * Default may be overridden by language front-ends. */
1281 void (*print_error_function) PROTO((char *)) = default_print_error_function;
1283 /* Prints out, if necessary, the name of the current function
1284 that caused an error. Called from all error and warning functions. */
1286 void
1287 report_error_function (file)
1288 char *file;
1290 struct file_stack *p;
1292 if (need_error_newline)
1294 fprintf (stderr, "\n");
1295 need_error_newline = 0;
1298 (*print_error_function) (file);
1300 if (input_file_stack && input_file_stack->next != 0
1301 && input_file_stack_tick != last_error_tick
1302 && file == input_filename)
1304 fprintf (stderr, "In file included");
1305 for (p = input_file_stack->next; p; p = p->next)
1307 fprintf (stderr, " from %s:%d", p->name, p->line);
1308 if (p->next)
1309 fprintf (stderr, ",\n ");
1311 fprintf (stderr, ":\n");
1312 last_error_tick = input_file_stack_tick;
1316 /* Print a message. */
1318 static void
1319 vmessage (prefix, s, ap)
1320 char *prefix;
1321 char *s;
1322 va_list ap;
1324 if (prefix)
1325 fprintf (stderr, "%s: ", prefix);
1327 vfprintf (stderr, s, ap);
1330 /* Print a message relevant to line LINE of file FILE. */
1332 static void
1333 v_message_with_file_and_line (file, line, prefix, s, ap)
1334 char *file;
1335 int line;
1336 char *prefix;
1337 char *s;
1338 va_list ap;
1340 if (file)
1341 fprintf (stderr, "%s:%d: ", file, line);
1342 else
1343 fprintf (stderr, "%s: ", progname);
1345 vmessage (prefix, s, ap);
1346 fputc ('\n', stderr);
1349 /* Print a message relevant to the given DECL. */
1351 static void
1352 v_message_with_decl (decl, prefix, s, ap)
1353 tree decl;
1354 char *prefix;
1355 char *s;
1356 va_list ap;
1358 char *p;
1360 fprintf (stderr, "%s:%d: ",
1361 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1363 if (prefix)
1364 fprintf (stderr, "%s: ", prefix);
1366 /* Do magic to get around lack of varargs support for insertion
1367 of arguments into existing list. We know that the decl is first;
1368 we ass_u_me that it will be printed with "%s". */
1370 for (p = s; *p; ++p)
1372 if (*p == '%')
1374 if (*(p + 1) == '%')
1375 ++p;
1376 else
1377 break;
1381 if (p > s) /* Print the left-hand substring. */
1383 char fmt[sizeof "%.255s"];
1384 long width = p - s;
1386 if (width > 255L) width = 255L; /* arbitrary */
1387 sprintf (fmt, "%%.%lds", width);
1388 fprintf (stderr, fmt, s);
1391 if (*p == '%') /* Print the name. */
1393 char *n = (DECL_NAME (decl)
1394 ? (*decl_printable_name) (decl, 2)
1395 : "((anonymous))");
1396 fputs (n, stderr);
1397 while (*p)
1399 ++p;
1400 if (ISALPHA (*(p - 1) & 0xFF))
1401 break;
1405 if (*p) /* Print the rest of the message. */
1406 vmessage ((char *)NULL, p, ap);
1408 fputc ('\n', stderr);
1411 /* Figure file and line of the given INSN. */
1413 static void
1414 file_and_line_for_asm (insn, pfile, pline)
1415 rtx insn;
1416 char **pfile;
1417 int *pline;
1419 rtx body = PATTERN (insn);
1420 rtx asmop;
1422 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1423 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1424 asmop = SET_SRC (body);
1425 else if (GET_CODE (body) == ASM_OPERANDS)
1426 asmop = body;
1427 else if (GET_CODE (body) == PARALLEL
1428 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1429 asmop = SET_SRC (XVECEXP (body, 0, 0));
1430 else if (GET_CODE (body) == PARALLEL
1431 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1432 asmop = XVECEXP (body, 0, 0);
1433 else
1434 asmop = NULL;
1436 if (asmop)
1438 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1439 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1441 else
1443 *pfile = input_filename;
1444 *pline = lineno;
1448 /* Report an error at line LINE of file FILE. */
1450 static void
1451 v_error_with_file_and_line (file, line, s, ap)
1452 char *file;
1453 int line;
1454 char *s;
1455 va_list ap;
1457 count_error (0);
1458 report_error_function (file);
1459 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1462 void
1463 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1465 #ifndef __STDC__
1466 char *file;
1467 int line;
1468 char *s;
1469 #endif
1470 va_list ap;
1472 VA_START (ap, s);
1474 #ifndef __STDC__
1475 file = va_arg (ap, char *);
1476 line = va_arg (ap, int);
1477 s = va_arg (ap, char *);
1478 #endif
1480 v_error_with_file_and_line (file, line, s, ap);
1481 va_end (ap);
1484 /* Report an error at the declaration DECL.
1485 S is a format string which uses %s to substitute the declaration
1486 name; subsequent substitutions are a la printf. */
1488 static void
1489 v_error_with_decl (decl, s, ap)
1490 tree decl;
1491 char *s;
1492 va_list ap;
1494 count_error (0);
1495 report_error_function (DECL_SOURCE_FILE (decl));
1496 v_message_with_decl (decl, (char *)NULL, s, ap);
1499 void
1500 error_with_decl VPROTO((tree decl, char *s, ...))
1502 #ifndef __STDC__
1503 tree decl;
1504 char *s;
1505 #endif
1506 va_list ap;
1508 VA_START (ap, s);
1510 #ifndef __STDC__
1511 decl = va_arg (ap, tree);
1512 s = va_arg (ap, char *);
1513 #endif
1515 v_error_with_decl (decl, s, ap);
1516 va_end (ap);
1519 /* Report an error at the line number of the insn INSN.
1520 This is used only when INSN is an `asm' with operands,
1521 and each ASM_OPERANDS records its own source file and line. */
1523 static void
1524 v_error_for_asm (insn, s, ap)
1525 rtx insn;
1526 char *s;
1527 va_list ap;
1529 char *file;
1530 int line;
1532 count_error (0);
1533 file_and_line_for_asm (insn, &file, &line);
1534 report_error_function (file);
1535 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1538 void
1539 error_for_asm VPROTO((rtx insn, char *s, ...))
1541 #ifndef __STDC__
1542 rtx insn;
1543 char *s;
1544 #endif
1545 va_list ap;
1547 VA_START (ap, s);
1549 #ifndef __STDC__
1550 insn = va_arg (ap, rtx);
1551 s = va_arg (ap, char *);
1552 #endif
1554 v_error_for_asm (insn, s, ap);
1555 va_end (ap);
1558 /* Report an error at the current line number. */
1560 static void
1561 verror (s, ap)
1562 char *s;
1563 va_list ap;
1565 v_error_with_file_and_line (input_filename, lineno, s, ap);
1568 void
1569 error VPROTO((char *s, ...))
1571 #ifndef __STDC__
1572 char *s;
1573 #endif
1574 va_list ap;
1576 VA_START (ap, s);
1578 #ifndef __STDC__
1579 s = va_arg (ap, char *);
1580 #endif
1582 verror (s, ap);
1583 va_end (ap);
1586 /* Report a fatal error at the current line number. */
1588 static void
1589 vfatal (s, ap)
1590 char *s;
1591 va_list ap;
1593 verror (s, ap);
1594 exit (FATAL_EXIT_CODE);
1597 void
1598 fatal VPROTO((char *s, ...))
1600 #ifndef __STDC__
1601 char *s;
1602 #endif
1603 va_list ap;
1605 VA_START (ap, s);
1607 #ifndef __STDC__
1608 s = va_arg (ap, char *);
1609 #endif
1611 vfatal (s, ap);
1612 va_end (ap);
1615 /* Report a warning at line LINE of file FILE. */
1617 static void
1618 v_warning_with_file_and_line (file, line, s, ap)
1619 char *file;
1620 int line;
1621 char *s;
1622 va_list ap;
1624 if (count_error (1))
1626 report_error_function (file);
1627 v_message_with_file_and_line (file, line, "warning", s, ap);
1631 void
1632 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1634 #ifndef __STDC__
1635 char *file;
1636 int line;
1637 char *s;
1638 #endif
1639 va_list ap;
1641 VA_START (ap, s);
1643 #ifndef __STDC__
1644 file = va_arg (ap, char *);
1645 line = va_arg (ap, int);
1646 s = va_arg (ap, char *);
1647 #endif
1649 v_warning_with_file_and_line (file, line, s, ap);
1650 va_end (ap);
1653 /* Report a warning at the declaration DECL.
1654 S is a format string which uses %s to substitute the declaration
1655 name; subsequent substitutions are a la printf. */
1657 static void
1658 v_warning_with_decl (decl, s, ap)
1659 tree decl;
1660 char *s;
1661 va_list ap;
1663 if (count_error (1))
1665 report_error_function (DECL_SOURCE_FILE (decl));
1666 v_message_with_decl (decl, "warning", s, ap);
1670 void
1671 warning_with_decl VPROTO((tree decl, char *s, ...))
1673 #ifndef __STDC__
1674 tree decl;
1675 char *s;
1676 #endif
1677 va_list ap;
1679 VA_START (ap, s);
1681 #ifndef __STDC__
1682 decl = va_arg (ap, tree);
1683 s = va_arg (ap, char *);
1684 #endif
1686 v_warning_with_decl (decl, s, ap);
1687 va_end (ap);
1690 /* Report a warning at the line number of the insn INSN.
1691 This is used only when INSN is an `asm' with operands,
1692 and each ASM_OPERANDS records its own source file and line. */
1694 static void
1695 v_warning_for_asm (insn, s, ap)
1696 rtx insn;
1697 char *s;
1698 va_list ap;
1700 if (count_error (1))
1702 char *file;
1703 int line;
1705 file_and_line_for_asm (insn, &file, &line);
1706 report_error_function (file);
1707 v_message_with_file_and_line (file, line, "warning", s, ap);
1711 void
1712 warning_for_asm VPROTO((rtx insn, char *s, ...))
1714 #ifndef __STDC__
1715 rtx insn;
1716 char *s;
1717 #endif
1718 va_list ap;
1720 VA_START (ap, s);
1722 #ifndef __STDC__
1723 insn = va_arg (ap, rtx);
1724 s = va_arg (ap, char *);
1725 #endif
1727 v_warning_for_asm (insn, s, ap);
1728 va_end (ap);
1731 /* Report a warning at the current line number. */
1733 static void
1734 vwarning (s, ap)
1735 char *s;
1736 va_list ap;
1738 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1741 void
1742 warning VPROTO((char *s, ...))
1744 #ifndef __STDC__
1745 char *s;
1746 #endif
1747 va_list ap;
1749 VA_START (ap, s);
1751 #ifndef __STDC__
1752 s = va_arg (ap, char *);
1753 #endif
1755 vwarning (s, ap);
1756 va_end (ap);
1759 /* These functions issue either warnings or errors depending on
1760 -pedantic-errors. */
1762 static void
1763 vpedwarn (s, ap)
1764 char *s;
1765 va_list ap;
1767 if (flag_pedantic_errors)
1768 verror (s, ap);
1769 else
1770 vwarning (s, ap);
1773 void
1774 pedwarn VPROTO((char *s, ...))
1776 #ifndef __STDC__
1777 char *s;
1778 #endif
1779 va_list ap;
1781 VA_START (ap, s);
1783 #ifndef __STDC__
1784 s = va_arg (ap, char *);
1785 #endif
1787 vpedwarn (s, ap);
1788 va_end (ap);
1791 static void
1792 v_pedwarn_with_decl (decl, s, ap)
1793 tree decl;
1794 char *s;
1795 va_list ap;
1797 /* We don't want -pedantic-errors to cause the compilation to fail from
1798 "errors" in system header files. Sometimes fixincludes can't fix what's
1799 broken (eg: unsigned char bitfields - fixing it may change the alignment
1800 which will cause programs to mysteriously fail because the C library
1801 or kernel uses the original layout). There's no point in issuing a
1802 warning either, it's just unnecessary noise. */
1804 if (! DECL_IN_SYSTEM_HEADER (decl))
1806 if (flag_pedantic_errors)
1807 v_error_with_decl (decl, s, ap);
1808 else
1809 v_warning_with_decl (decl, s, ap);
1813 void
1814 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1816 #ifndef __STDC__
1817 tree decl;
1818 char *s;
1819 #endif
1820 va_list ap;
1822 VA_START (ap, s);
1824 #ifndef __STDC__
1825 decl = va_arg (ap, tree);
1826 s = va_arg (ap, char *);
1827 #endif
1829 v_pedwarn_with_decl (decl, s, ap);
1830 va_end (ap);
1833 static void
1834 v_pedwarn_with_file_and_line (file, line, s, ap)
1835 char *file;
1836 int line;
1837 char *s;
1838 va_list ap;
1840 if (flag_pedantic_errors)
1841 v_error_with_file_and_line (file, line, s, ap);
1842 else
1843 v_warning_with_file_and_line (file, line, s, ap);
1846 void
1847 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1849 #ifndef __STDC__
1850 char *file;
1851 int line;
1852 char *s;
1853 #endif
1854 va_list ap;
1856 VA_START (ap, s);
1858 #ifndef __STDC__
1859 file = va_arg (ap, char *);
1860 line = va_arg (ap, int);
1861 s = va_arg (ap, char *);
1862 #endif
1864 v_pedwarn_with_file_and_line (file, line, s, ap);
1865 va_end (ap);
1868 /* Apologize for not implementing some feature. */
1870 static void
1871 vsorry (s, ap)
1872 char *s;
1873 va_list ap;
1875 sorrycount++;
1876 if (input_filename)
1877 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1878 else
1879 fprintf (stderr, "%s: ", progname);
1880 vmessage ("sorry, not implemented", s, ap);
1881 fputc ('\n', stderr);
1884 void
1885 sorry VPROTO((char *s, ...))
1887 #ifndef __STDC__
1888 char *s;
1889 #endif
1890 va_list ap;
1892 VA_START (ap, s);
1894 #ifndef __STDC__
1895 s = va_arg (ap, char *);
1896 #endif
1898 vsorry (s, ap);
1899 va_end (ap);
1902 /* Apologize for not implementing some feature, then quit. */
1904 static void
1905 v_really_sorry (s, ap)
1906 char *s;
1907 va_list ap;
1909 sorrycount++;
1910 if (input_filename)
1911 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1912 else
1913 fprintf (stderr, "%s: ", progname);
1914 vmessage ("sorry, not implemented", s, ap);
1915 fatal (" (fatal)\n");
1918 void
1919 really_sorry VPROTO((char *s, ...))
1921 #ifndef __STDC__
1922 char *s;
1923 #endif
1924 va_list ap;
1926 VA_START (ap, s);
1928 #ifndef __STDC__
1929 s = va_arg (ap, char *);
1930 #endif
1932 v_really_sorry (s, ap);
1933 va_end (ap);
1936 /* More 'friendly' abort that prints the line and file.
1937 config.h can #define abort fancy_abort if you like that sort of thing.
1939 I don't think this is actually a good idea.
1940 Other sorts of crashes will look a certain way.
1941 It is a good thing if crashes from calling abort look the same way.
1942 -- RMS */
1944 void
1945 fancy_abort ()
1947 fatal ("internal gcc abort");
1950 /* This calls abort and is used to avoid problems when abort if a macro.
1951 It is used when we need to pass the address of abort. */
1953 void
1954 do_abort ()
1956 abort ();
1959 /* When `malloc.c' is compiled with `rcheck' defined,
1960 it calls this function to report clobberage. */
1962 void
1963 botch (s)
1964 char * s;
1966 abort ();
1969 /* Same as `malloc' but report error if no memory available. */
1971 char *
1972 xmalloc (size)
1973 unsigned size;
1975 register char *value;
1977 if (size == 0)
1978 size = 1;
1980 value = (char *) malloc (size);
1981 if (value == 0)
1982 fatal ("virtual memory exhausted");
1983 return value;
1986 /* Same as `calloc' but report error if no memory available. */
1988 char *
1989 xcalloc (size1, size2)
1990 unsigned size1, size2;
1992 register char *value;
1994 if (size1 == 0 || size2 == 0)
1995 size1 = size2 = 1;
1997 value = (char *) calloc (size1, size2);
1998 if (value == 0)
1999 fatal ("virtual memory exhausted");
2000 return value;
2004 /* Same as `realloc' but report error if no memory available.
2005 Also handle null PTR even if the vendor realloc gets it wrong. */
2007 char *
2008 xrealloc (ptr, size)
2009 char *ptr;
2010 int size;
2012 char *result;
2014 if (size == 0)
2015 size = 1;
2017 result = (ptr
2018 ? (char *) realloc (ptr, size)
2019 : (char *) malloc (size));
2021 if (!result)
2022 fatal ("virtual memory exhausted");
2024 return result;
2027 /* Same as `strdup' but report error if no memory available. */
2029 char *
2030 xstrdup (s)
2031 register char *s;
2033 register char *result = (char *) malloc (strlen (s) + 1);
2035 if (! result)
2036 fatal ("virtual memory exhausted");
2037 strcpy (result, s);
2038 return result;
2041 /* Return the logarithm of X, base 2, considering X unsigned,
2042 if X is a power of 2. Otherwise, returns -1.
2044 This should be used via the `exact_log2' macro. */
2047 exact_log2_wide (x)
2048 register unsigned HOST_WIDE_INT x;
2050 register int log = 0;
2051 /* Test for 0 or a power of 2. */
2052 if (x == 0 || x != (x & -x))
2053 return -1;
2054 while ((x >>= 1) != 0)
2055 log++;
2056 return log;
2059 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2060 If X is 0, return -1.
2062 This should be used via the floor_log2 macro. */
2065 floor_log2_wide (x)
2066 register unsigned HOST_WIDE_INT x;
2068 register int log = -1;
2069 while (x != 0)
2070 log++,
2071 x >>= 1;
2072 return log;
2075 static int float_handler_set;
2076 int float_handled;
2077 jmp_buf float_handler;
2079 /* Signals actually come here. */
2081 static void
2082 float_signal (signo)
2083 /* If this is missing, some compilers complain. */
2084 int signo ATTRIBUTE_UNUSED;
2086 if (float_handled == 0)
2087 abort ();
2088 #if defined (USG) || defined (hpux)
2089 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2090 #endif
2091 float_handled = 0;
2092 signal (SIGFPE, float_signal);
2093 longjmp (float_handler, 1);
2096 /* Specify where to longjmp to when a floating arithmetic error happens.
2097 If HANDLER is 0, it means don't handle the errors any more. */
2099 void
2100 set_float_handler (handler)
2101 jmp_buf handler;
2103 float_handled = (handler != 0);
2104 if (handler)
2105 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2107 if (float_handled && ! float_handler_set)
2109 signal (SIGFPE, float_signal);
2110 float_handler_set = 1;
2114 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2115 error happens, pushing the previous specification into OLD_HANDLER.
2116 Return an indication of whether there was a previous handler in effect. */
2119 push_float_handler (handler, old_handler)
2120 jmp_buf handler, old_handler;
2122 int was_handled = float_handled;
2124 float_handled = 1;
2125 if (was_handled)
2126 bcopy ((char *) float_handler, (char *) old_handler,
2127 sizeof (float_handler));
2129 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2130 return was_handled;
2133 /* Restore the previous specification of whether and where to longjmp to
2134 when a floating arithmetic error happens. */
2136 void
2137 pop_float_handler (handled, handler)
2138 int handled;
2139 jmp_buf handler;
2141 float_handled = handled;
2142 if (handled)
2143 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2146 /* Handler for SIGPIPE. */
2148 static void
2149 pipe_closed (signo)
2150 /* If this is missing, some compilers complain. */
2151 int signo ATTRIBUTE_UNUSED;
2153 fatal ("output pipe has been closed");
2156 /* Strip off a legitimate source ending from the input string NAME of
2157 length LEN. Rather than having to know the names used by all of
2158 our front ends, we strip off an ending of a period followed by
2159 up to five characters. (Java uses ".class".) */
2161 void
2162 strip_off_ending (name, len)
2163 char *name;
2164 int len;
2166 int i;
2167 for (i = 2; i < 6 && len > i; i++)
2169 if (name[len - i] == '.')
2171 name[len - i] = '\0';
2172 break;
2177 /* Output a quoted string. */
2179 void
2180 output_quoted_string (asm_file, string)
2181 FILE *asm_file;
2182 char *string;
2184 #ifdef OUTPUT_QUOTED_STRING
2185 OUTPUT_QUOTED_STRING (asm_file, string);
2186 #else
2187 char c;
2189 putc ('\"', asm_file);
2190 while ((c = *string++) != 0)
2192 if (c == '\"' || c == '\\')
2193 putc ('\\', asm_file);
2194 putc (c, asm_file);
2196 putc ('\"', asm_file);
2197 #endif
2200 /* Output a file name in the form wanted by System V. */
2202 void
2203 output_file_directive (asm_file, input_name)
2204 FILE *asm_file;
2205 char *input_name;
2207 int len = strlen (input_name);
2208 char *na = input_name + len;
2210 /* NA gets INPUT_NAME sans directory names. */
2211 while (na > input_name)
2213 if (na[-1] == '/')
2214 break;
2215 na--;
2218 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2219 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2220 #else
2221 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2222 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2223 #else
2224 fprintf (asm_file, "\t.file\t");
2225 output_quoted_string (asm_file, na);
2226 fputc ('\n', asm_file);
2227 #endif
2228 #endif
2231 /* Routine to build language identifier for object file. */
2233 static void
2234 output_lang_identify (asm_out_file)
2235 FILE *asm_out_file;
2237 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2238 char *s = (char *) alloca (len);
2239 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2240 ASM_OUTPUT_LABEL (asm_out_file, s);
2243 /* Routine to open a dump file. */
2244 static void
2245 open_dump_file (suffix, function_name)
2246 char *suffix;
2247 char *function_name;
2249 char *dumpname;
2251 TIMEVAR
2252 (dump_time,
2254 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2256 if (rtl_dump_file != NULL)
2257 fclose (rtl_dump_file);
2259 strcpy (dumpname, dump_base_name);
2260 strcat (dumpname, suffix);
2262 rtl_dump_file = fopen (dumpname, "a");
2264 if (rtl_dump_file == NULL)
2265 pfatal_with_name (dumpname);
2267 free (dumpname);
2269 if (function_name)
2270 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2273 return;
2276 /* Routine to close a dump file. */
2277 static void
2278 close_dump_file (func, insns)
2279 void (*func) PROTO ((FILE *, rtx));
2280 rtx insns;
2282 TIMEVAR
2283 (dump_time,
2285 if (func)
2286 func (rtl_dump_file, insns);
2288 fflush (rtl_dump_file);
2289 fclose (rtl_dump_file);
2291 rtl_dump_file = NULL;
2294 return;
2297 /* Routine to dump rtl into a file. */
2298 static void
2299 dump_rtl (suffix, decl, func, insns)
2300 char *suffix;
2301 tree decl;
2302 void (*func) PROTO ((FILE *, rtx));
2303 rtx insns;
2305 open_dump_file (suffix, decl_printable_name (decl, 2));
2306 close_dump_file (func, insns);
2309 /* Routine to empty a dump file. */
2310 static void
2311 clean_dump_file (suffix)
2312 char * suffix;
2314 char * dumpname;
2316 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2318 strcpy (dumpname, dump_base_name);
2319 strcat (dumpname, suffix);
2321 rtl_dump_file = fopen (dumpname, "w");
2323 if (rtl_dump_file == NULL)
2324 pfatal_with_name (dumpname);
2326 free (dumpname);
2328 fclose (rtl_dump_file);
2329 rtl_dump_file = NULL;
2331 return;
2335 /* Compile an entire file of output from cpp, named NAME.
2336 Write a file of assembly output and various debugging dumps. */
2338 static void
2339 compile_file (name)
2340 char *name;
2342 tree globals;
2343 int start_time;
2345 int name_specified = name != 0;
2347 if (dump_base_name == 0)
2348 dump_base_name = name ? name : "gccdump";
2350 parse_time = 0;
2351 varconst_time = 0;
2352 integration_time = 0;
2353 jump_time = 0;
2354 cse_time = 0;
2355 gcse_time = 0;
2356 loop_time = 0;
2357 cse2_time = 0;
2358 branch_prob_time = 0;
2359 flow_time = 0;
2360 combine_time = 0;
2361 regmove_time = 0;
2362 sched_time = 0;
2363 local_alloc_time = 0;
2364 global_alloc_time = 0;
2365 sched2_time = 0;
2366 #ifdef DELAY_SLOTS
2367 dbr_sched_time = 0;
2368 #endif
2369 shorten_branch_time = 0;
2370 stack_reg_time = 0;
2371 final_time = 0;
2372 symout_time = 0;
2373 dump_time = 0;
2375 /* Initialize data in various passes. */
2377 init_obstacks ();
2378 init_tree_codes ();
2379 name = init_parse (name);
2380 init_rtl ();
2381 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2382 || debug_info_level == DINFO_LEVEL_VERBOSE
2383 || flag_test_coverage);
2384 init_regs ();
2385 init_decl_processing ();
2386 init_optabs ();
2387 init_stmt ();
2388 init_expmed ();
2389 init_expr_once ();
2390 init_loop ();
2391 init_reload ();
2392 init_alias_once ();
2394 if (flag_caller_saves)
2395 init_caller_save ();
2397 /* If auxiliary info generation is desired, open the output file.
2398 This goes in the same directory as the source file--unlike
2399 all the other output files. */
2400 if (flag_gen_aux_info)
2402 aux_info_file = fopen (aux_info_file_name, "w");
2403 if (aux_info_file == 0)
2404 pfatal_with_name (aux_info_file_name);
2407 /* Clear the dump files file. */
2408 if (rtl_dump)
2409 clean_dump_file (".rtl");
2410 if (jump_opt_dump)
2411 clean_dump_file (".jump");
2412 if (addressof_dump)
2413 clean_dump_file (".addressof");
2414 if (cse_dump)
2415 clean_dump_file (".cse");
2416 if (loop_dump)
2417 clean_dump_file (".loop");
2418 if (cse2_dump)
2419 clean_dump_file (".cse2");
2420 if (branch_prob_dump)
2421 clean_dump_file (".bp");
2422 if (flow_dump)
2423 clean_dump_file (".flow");
2424 if (combine_dump)
2425 clean_dump_file (".combine");
2426 if (regmove_dump)
2427 clean_dump_file (".regmove");
2428 if (sched_dump)
2429 clean_dump_file (".sched");
2430 if (local_reg_dump)
2431 clean_dump_file (".lreg");
2432 if (global_reg_dump)
2433 clean_dump_file (".greg");
2434 if (sched2_dump)
2435 clean_dump_file (".sched2");
2436 if (jump2_opt_dump)
2437 clean_dump_file (".jump2");
2438 #ifdef DELAY_SLOTS
2439 if (dbr_sched_dump)
2440 clean_dump_file (".dbr");
2441 #endif
2442 if (gcse_dump)
2443 clean_dump_file (".gcse");
2444 #ifdef STACK_REGS
2445 if (stack_reg_dump)
2446 clean_dump_file (".stack");
2447 #endif
2448 #ifdef MACHINE_DEPENDENT_REORG
2449 if (mach_dep_reorg_dump)
2450 clean_dump_file (".mach");
2451 #endif
2453 /* Open assembler code output file. */
2455 if (! name_specified && asm_file_name == 0)
2456 asm_out_file = stdout;
2457 else
2459 int len = strlen (dump_base_name);
2460 register char *dumpname = (char *) xmalloc (len + 6);
2461 strcpy (dumpname, dump_base_name);
2462 strip_off_ending (dumpname, len);
2463 strcat (dumpname, ".s");
2464 if (asm_file_name == 0)
2466 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2467 strcpy (asm_file_name, dumpname);
2469 if (!strcmp (asm_file_name, "-"))
2470 asm_out_file = stdout;
2471 else
2472 asm_out_file = fopen (asm_file_name, "w");
2473 if (asm_out_file == 0)
2474 pfatal_with_name (asm_file_name);
2477 #ifdef IO_BUFFER_SIZE
2478 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2479 _IOFBF, IO_BUFFER_SIZE);
2480 #endif
2482 input_filename = name;
2484 /* Put an entry on the input file stack for the main input file. */
2485 input_file_stack
2486 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2487 input_file_stack->next = 0;
2488 input_file_stack->name = input_filename;
2490 /* Perform language-specific initialization.
2491 This may set main_input_filename. */
2492 lang_init ();
2494 /* If the input doesn't start with a #line, use the input name
2495 as the official input file name. */
2496 if (main_input_filename == 0)
2497 main_input_filename = name;
2499 ASM_FILE_START (asm_out_file);
2501 #ifdef ASM_COMMENT_START
2502 if (flag_verbose_asm)
2504 /* Print the list of options in effect. */
2505 print_version (asm_out_file, ASM_COMMENT_START);
2506 print_switch_values (asm_out_file, 0, MAX_LINE,
2507 ASM_COMMENT_START, " ", "\n");
2508 /* Add a blank line here so it appears in assembler output but not
2509 screen output. */
2510 fprintf (asm_out_file, "\n");
2512 #endif
2514 /* Output something to inform GDB that this compilation was by GCC. */
2515 #ifndef ASM_IDENTIFY_GCC
2516 fprintf (asm_out_file, "gcc2_compiled.:\n");
2517 #else
2518 ASM_IDENTIFY_GCC (asm_out_file);
2519 #endif
2521 /* Output something to identify which front-end produced this file. */
2522 #ifdef ASM_IDENTIFY_LANGUAGE
2523 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2524 #endif
2526 #ifndef ASM_OUTPUT_SECTION_NAME
2527 if (flag_function_sections)
2529 warning ("-ffunction-sections not supported for this target.");
2530 flag_function_sections = 0;
2532 #endif
2534 if (flag_function_sections
2535 && (profile_flag || profile_block_flag))
2537 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2538 flag_function_sections = 0;
2541 if (flag_function_sections && write_symbols != NO_DEBUG)
2542 warning ("-ffunction-sections may affect debugging on some targets.");
2544 /* ??? Note: There used to be a conditional here
2545 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2546 This was to guarantee separation between gcc_compiled. and
2547 the first function, for the sake of dbx on Suns.
2548 However, having the extra zero here confused the Emacs
2549 code for unexec, and might confuse other programs too.
2550 Therefore, I took out that change.
2551 In future versions we should find another way to solve
2552 that dbx problem. -- rms, 23 May 93. */
2554 /* Don't let the first function fall at the same address
2555 as gcc_compiled., if profiling. */
2556 if (profile_flag || profile_block_flag)
2558 /* It's best if we can write a nop here since some
2559 assemblers don't tolerate zeros in the text section. */
2560 if (insn_template[CODE_FOR_nop] != 0)
2561 output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR);
2562 else
2563 assemble_zeros (UNITS_PER_WORD);
2566 /* If dbx symbol table desired, initialize writing it
2567 and output the predefined types. */
2568 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2569 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2570 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2571 getdecls ()));
2572 #endif
2573 #ifdef SDB_DEBUGGING_INFO
2574 if (write_symbols == SDB_DEBUG)
2575 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2576 getdecls ()));
2577 #endif
2578 #ifdef DWARF_DEBUGGING_INFO
2579 if (write_symbols == DWARF_DEBUG)
2580 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2581 #endif
2582 #ifdef DWARF2_UNWIND_INFO
2583 if (dwarf2out_do_frame ())
2584 dwarf2out_frame_init ();
2585 #endif
2586 #ifdef DWARF2_DEBUGGING_INFO
2587 if (write_symbols == DWARF2_DEBUG)
2588 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2589 #endif
2591 /* Initialize yet another pass. */
2593 init_final (main_input_filename);
2594 init_branch_prob (dump_base_name);
2596 start_time = get_run_time ();
2598 /* Call the parser, which parses the entire file
2599 (calling rest_of_compilation for each function). */
2601 if (yyparse () != 0)
2603 if (errorcount == 0)
2604 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2606 /* In case there were missing closebraces,
2607 get us back to the global binding level. */
2608 while (! global_bindings_p ())
2609 poplevel (0, 0, 0);
2612 output_func_start_profiler ();
2614 /* Compilation is now finished except for writing
2615 what's left of the symbol table output. */
2617 parse_time += get_run_time () - start_time;
2619 parse_time -= integration_time;
2620 parse_time -= varconst_time;
2622 globals = getdecls ();
2624 /* Really define vars that have had only a tentative definition.
2625 Really output inline functions that must actually be callable
2626 and have not been output so far. */
2629 int len = list_length (globals);
2630 tree *vec = (tree *) alloca (sizeof (tree) * len);
2631 int i;
2632 tree decl;
2633 int reconsider = 1;
2635 /* Process the decls in reverse order--earliest first.
2636 Put them into VEC from back to front, then take out from front. */
2638 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2639 vec[len - i - 1] = decl;
2641 for (i = 0; i < len; i++)
2643 decl = vec[i];
2645 /* We're not deferring this any longer. */
2646 DECL_DEFER_OUTPUT (decl) = 0;
2648 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2649 && incomplete_decl_finalize_hook != 0)
2650 (*incomplete_decl_finalize_hook) (decl);
2653 /* Now emit any global variables or functions that we have been putting
2654 off. We need to loop in case one of the things emitted here
2655 references another one which comes earlier in the list. */
2656 while (reconsider)
2658 reconsider = 0;
2659 for (i = 0; i < len; i++)
2661 decl = vec[i];
2663 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2664 continue;
2666 /* Don't write out static consts, unless we still need them.
2668 We also keep static consts if not optimizing (for debugging),
2669 unless the user specified -fno-keep-static-consts.
2670 ??? They might be better written into the debug information.
2671 This is possible when using DWARF.
2673 A language processor that wants static constants to be always
2674 written out (even if it is not used) is responsible for
2675 calling rest_of_decl_compilation itself. E.g. the C front-end
2676 calls rest_of_decl_compilation from finish_decl.
2677 One motivation for this is that is conventional in some
2678 environments to write things like:
2679 static const char rcsid[] = "... version string ...";
2680 intending to force the string to be in the executable.
2682 A language processor that would prefer to have unneeded
2683 static constants "optimized away" would just defer writing
2684 them out until here. E.g. C++ does this, because static
2685 constants are often defined in header files.
2687 ??? A tempting alternative (for both C and C++) would be
2688 to force a constant to be written if and only if it is
2689 defined in a main file, as opposed to an include file. */
2691 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2692 && (! TREE_READONLY (decl)
2693 || TREE_PUBLIC (decl)
2694 || (!optimize && flag_keep_static_consts)
2695 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2697 reconsider = 1;
2698 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2701 if (TREE_CODE (decl) == FUNCTION_DECL
2702 && DECL_INITIAL (decl) != 0
2703 && DECL_SAVED_INSNS (decl) != 0
2704 && (flag_keep_inline_functions
2705 || TREE_PUBLIC (decl)
2706 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2708 reconsider = 1;
2709 temporary_allocation ();
2710 output_inline_function (decl);
2711 permanent_allocation (1);
2716 /* Now that all possible functions have been output, we can dump
2717 the exception table. */
2719 output_exception_table ();
2721 for (i = 0; i < len; i++)
2723 decl = vec[i];
2725 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2726 && ! TREE_ASM_WRITTEN (decl))
2727 /* Cancel the RTL for this decl so that, if debugging info
2728 output for global variables is still to come,
2729 this one will be omitted. */
2730 DECL_RTL (decl) = NULL;
2732 /* Warn about any function
2733 declared static but not defined.
2734 We don't warn about variables,
2735 because many programs have static variables
2736 that exist only to get some text into the object file. */
2737 if (TREE_CODE (decl) == FUNCTION_DECL
2738 && (warn_unused
2739 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2740 && DECL_INITIAL (decl) == 0
2741 && DECL_EXTERNAL (decl)
2742 && ! DECL_ARTIFICIAL (decl)
2743 && ! TREE_PUBLIC (decl))
2745 pedwarn_with_decl (decl,
2746 "`%s' declared `static' but never defined");
2747 /* This symbol is effectively an "extern" declaration now. */
2748 TREE_PUBLIC (decl) = 1;
2749 assemble_external (decl);
2752 /* Warn about static fns or vars defined but not used,
2753 but not about inline functions or static consts
2754 since defining those in header files is normal practice. */
2755 if (warn_unused
2756 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2757 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2758 && ! DECL_IN_SYSTEM_HEADER (decl)
2759 && ! DECL_EXTERNAL (decl)
2760 && ! TREE_PUBLIC (decl)
2761 && ! TREE_USED (decl)
2762 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2763 /* The TREE_USED bit for file-scope decls
2764 is kept in the identifier, to handle multiple
2765 external decls in different scopes. */
2766 && ! TREE_USED (DECL_NAME (decl)))
2767 warning_with_decl (decl, "`%s' defined but not used");
2769 #ifdef SDB_DEBUGGING_INFO
2770 /* The COFF linker can move initialized global vars to the end.
2771 And that can screw up the symbol ordering.
2772 By putting the symbols in that order to begin with,
2773 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2774 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2775 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2776 && ! DECL_EXTERNAL (decl)
2777 && DECL_RTL (decl) != 0)
2778 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2780 /* Output COFF information for non-global
2781 file-scope initialized variables. */
2782 if (write_symbols == SDB_DEBUG
2783 && TREE_CODE (decl) == VAR_DECL
2784 && DECL_INITIAL (decl)
2785 && ! DECL_EXTERNAL (decl)
2786 && DECL_RTL (decl) != 0
2787 && GET_CODE (DECL_RTL (decl)) == MEM)
2788 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2789 #endif /* SDB_DEBUGGING_INFO */
2790 #ifdef DWARF_DEBUGGING_INFO
2791 /* Output DWARF information for file-scope tentative data object
2792 declarations, file-scope (extern) function declarations (which
2793 had no corresponding body) and file-scope tagged type declarations
2794 and definitions which have not yet been forced out. */
2796 if (write_symbols == DWARF_DEBUG
2797 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2798 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2799 #endif
2800 #ifdef DWARF2_DEBUGGING_INFO
2801 /* Output DWARF2 information for file-scope tentative data object
2802 declarations, file-scope (extern) function declarations (which
2803 had no corresponding body) and file-scope tagged type declarations
2804 and definitions which have not yet been forced out. */
2806 if (write_symbols == DWARF2_DEBUG
2807 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2808 TIMEVAR (symout_time, dwarf2out_decl (decl));
2809 #endif
2813 /* Write out any pending weak symbol declarations. */
2815 weak_finish ();
2817 /* Do dbx symbols */
2818 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2819 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2820 TIMEVAR (symout_time,
2822 dbxout_finish (asm_out_file, main_input_filename);
2824 #endif
2826 #ifdef DWARF_DEBUGGING_INFO
2827 if (write_symbols == DWARF_DEBUG)
2828 TIMEVAR (symout_time,
2830 dwarfout_finish ();
2832 #endif
2834 #ifdef DWARF2_UNWIND_INFO
2835 if (dwarf2out_do_frame ())
2836 dwarf2out_frame_finish ();
2837 #endif
2839 #ifdef DWARF2_DEBUGGING_INFO
2840 if (write_symbols == DWARF2_DEBUG)
2841 TIMEVAR (symout_time,
2843 dwarf2out_finish ();
2845 #endif
2847 /* Output some stuff at end of file if nec. */
2849 end_final (dump_base_name);
2851 if (branch_prob_dump)
2852 open_dump_file (".bp", NULL);
2854 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
2856 if (branch_prob_dump)
2857 close_dump_file (NULL, NULL_RTX);
2859 #ifdef ASM_FILE_END
2860 ASM_FILE_END (asm_out_file);
2861 #endif
2863 /* Language-specific end of compilation actions. */
2865 lang_finish ();
2867 /* Close the dump files. */
2869 if (flag_gen_aux_info)
2871 fclose (aux_info_file);
2872 if (errorcount)
2873 unlink (aux_info_file_name);
2876 if (combine_dump)
2878 open_dump_file (".combine", NULL);
2879 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
2880 close_dump_file (NULL, NULL_RTX);
2883 /* Close non-debugging input and output files. Take special care to note
2884 whether fclose returns an error, since the pages might still be on the
2885 buffer chain while the file is open. */
2887 finish_parse ();
2889 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2890 fatal_io_error (asm_file_name);
2892 /* Print the times. */
2894 if (! quiet_flag)
2896 fprintf (stderr,"\n");
2897 print_time ("parse", parse_time);
2899 print_time ("integration", integration_time);
2900 print_time ("jump", jump_time);
2901 print_time ("cse", cse_time);
2902 print_time ("gcse", gcse_time);
2903 print_time ("loop", loop_time);
2904 print_time ("cse2", cse2_time);
2905 print_time ("branch-prob", branch_prob_time);
2906 print_time ("flow", flow_time);
2907 print_time ("combine", combine_time);
2908 print_time ("regmove", regmove_time);
2909 print_time ("sched", sched_time);
2910 print_time ("local-alloc", local_alloc_time);
2911 print_time ("global-alloc", global_alloc_time);
2912 print_time ("sched2", sched2_time);
2913 #ifdef DELAY_SLOTS
2914 print_time ("dbranch", dbr_sched_time);
2915 #endif
2916 print_time ("shorten-branch", shorten_branch_time);
2917 print_time ("stack-reg", stack_reg_time);
2918 print_time ("final", final_time);
2919 print_time ("varconst", varconst_time);
2920 print_time ("symout", symout_time);
2921 print_time ("dump", dump_time);
2925 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2926 and TYPE_DECL nodes.
2928 This does nothing for local (non-static) variables.
2929 Otherwise, it sets up the RTL and outputs any assembler code
2930 (label definition, storage allocation and initialization).
2932 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2933 the assembler symbol name to be used. TOP_LEVEL is nonzero
2934 if this declaration is not within a function. */
2936 void
2937 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2938 tree decl;
2939 char *asmspec;
2940 int top_level;
2941 int at_end;
2943 /* Declarations of variables, and of functions defined elsewhere. */
2945 /* The most obvious approach, to put an #ifndef around where
2946 this macro is used, doesn't work since it's inside a macro call. */
2947 #ifndef ASM_FINISH_DECLARE_OBJECT
2948 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2949 #endif
2951 /* Forward declarations for nested functions are not "external",
2952 but we need to treat them as if they were. */
2953 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2954 || TREE_CODE (decl) == FUNCTION_DECL)
2955 TIMEVAR (varconst_time,
2957 make_decl_rtl (decl, asmspec, top_level);
2958 /* Initialized extern variable exists to be replaced
2959 with its value, or represents something that will be
2960 output in another file. */
2961 if (! (TREE_CODE (decl) == VAR_DECL
2962 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2963 && DECL_INITIAL (decl) != 0
2964 && DECL_INITIAL (decl) != error_mark_node))
2965 /* Don't output anything
2966 when a tentative file-scope definition is seen.
2967 But at end of compilation, do output code for them. */
2968 if (! (! at_end && top_level
2969 && (DECL_INITIAL (decl) == 0
2970 || DECL_INITIAL (decl) == error_mark_node)))
2971 assemble_variable (decl, top_level, at_end, 0);
2972 if (decl == last_assemble_variable_decl)
2974 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2975 top_level, at_end);
2978 else if (DECL_REGISTER (decl) && asmspec != 0)
2980 if (decode_reg_name (asmspec) >= 0)
2982 DECL_RTL (decl) = 0;
2983 make_decl_rtl (decl, asmspec, top_level);
2985 else
2986 error ("invalid register name `%s' for register variable", asmspec);
2988 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2989 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2990 && TREE_CODE (decl) == TYPE_DECL)
2991 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2992 #endif
2993 #ifdef SDB_DEBUGGING_INFO
2994 else if (write_symbols == SDB_DEBUG && top_level
2995 && TREE_CODE (decl) == TYPE_DECL)
2996 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2997 #endif
3000 /* Called after finishing a record, union or enumeral type. */
3002 void
3003 rest_of_type_compilation (type, toplev)
3004 tree type;
3005 int toplev;
3007 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3008 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3009 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3010 #endif
3011 #ifdef SDB_DEBUGGING_INFO
3012 if (write_symbols == SDB_DEBUG)
3013 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3014 #endif
3017 /* This is called from finish_function (within yyparse)
3018 after each top-level definition is parsed.
3019 It is supposed to compile that function or variable
3020 and output the assembler code for it.
3021 After we return, the tree storage is freed. */
3023 void
3024 rest_of_compilation (decl)
3025 tree decl;
3027 register rtx insns;
3028 int start_time = get_run_time ();
3029 int tem;
3030 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3031 to be restored after we finish compiling the function
3032 (for use when compiling inline calls to this function). */
3033 tree saved_block_tree = 0;
3034 /* Likewise, for DECL_ARGUMENTS. */
3035 tree saved_arguments = 0;
3036 int failure = 0;
3038 /* If we are reconsidering an inline function
3039 at the end of compilation, skip the stuff for making it inline. */
3041 if (DECL_SAVED_INSNS (decl) == 0)
3043 int inlinable = 0;
3044 char *lose;
3046 /* If requested, consider whether to make this function inline. */
3047 if (DECL_INLINE (decl) || flag_inline_functions)
3048 TIMEVAR (integration_time,
3050 lose = function_cannot_inline_p (decl);
3051 if (lose || ! optimize)
3053 if (warn_inline && DECL_INLINE (decl))
3054 warning_with_decl (decl, lose);
3055 DECL_ABSTRACT_ORIGIN (decl) = 0;
3056 /* Don't really compile an extern inline function.
3057 If we can't make it inline, pretend
3058 it was only declared. */
3059 if (DECL_EXTERNAL (decl))
3061 DECL_INITIAL (decl) = 0;
3062 goto exit_rest_of_compilation;
3065 else
3066 /* ??? Note that this has the effect of making it look
3067 like "inline" was specified for a function if we choose
3068 to inline it. This isn't quite right, but it's
3069 probably not worth the trouble to fix. */
3070 inlinable = DECL_INLINE (decl) = 1;
3073 insns = get_insns ();
3075 /* Dump the rtl code if we are dumping rtl. */
3077 if (rtl_dump)
3079 open_dump_file (".rtl", decl_printable_name (decl, 2));
3081 if (DECL_SAVED_INSNS (decl))
3082 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3084 close_dump_file (print_rtl, insns);
3087 /* If we can, defer compiling inlines until EOF.
3088 save_for_inline_copying can be extremely expensive. */
3089 if (inlinable && ! decl_function_context (decl))
3090 DECL_DEFER_OUTPUT (decl) = 1;
3092 /* If function is inline, and we don't yet know whether to
3093 compile it by itself, defer decision till end of compilation.
3094 finish_compilation will call rest_of_compilation again
3095 for those functions that need to be output. Also defer those
3096 functions that we are supposed to defer. We cannot defer
3097 functions containing nested functions since the nested function
3098 data is in our non-saved obstack. We cannot defer nested
3099 functions for the same reason. */
3101 /* If this is a nested inline, remove ADDRESSOF now so we can
3102 finish compiling ourselves. Otherwise, wait until EOF.
3103 We have to do this because the purge_addressof transformation
3104 changes the DECL_RTL for many variables, which confuses integrate. */
3105 if (inlinable)
3107 if (decl_function_context (decl))
3108 purge_addressof (insns);
3109 else
3110 DECL_DEFER_OUTPUT (decl) = 1;
3113 if (! current_function_contains_functions
3114 && (DECL_DEFER_OUTPUT (decl)
3115 || (DECL_INLINE (decl)
3116 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3117 && ! flag_keep_inline_functions)
3118 || DECL_EXTERNAL (decl)))))
3120 DECL_DEFER_OUTPUT (decl) = 1;
3122 /* If -Wreturn-type, we have to do a bit of compilation.
3123 However, if we just fall through we will call
3124 save_for_inline_copying() which results in excessive
3125 memory use. Instead, we just want to call
3126 jump_optimize() to figure out whether or not we can fall
3127 off the end of the function; we do the minimum amount of
3128 work necessary to make that safe. And, we set optimize
3129 to zero to keep jump_optimize from working too hard. */
3130 if (warn_return_type)
3132 int saved_optimize = optimize;
3133 optimize = 0;
3134 find_exception_handler_labels ();
3135 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3136 !JUMP_AFTER_REGSCAN);
3137 optimize = saved_optimize;
3140 #ifdef DWARF_DEBUGGING_INFO
3141 /* Generate the DWARF info for the "abstract" instance
3142 of a function which we may later generate inlined and/or
3143 out-of-line instances of. */
3144 if (write_symbols == DWARF_DEBUG)
3146 set_decl_abstract_flags (decl, 1);
3147 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3148 set_decl_abstract_flags (decl, 0);
3150 #endif
3151 #ifdef DWARF2_DEBUGGING_INFO
3152 /* Generate the DWARF2 info for the "abstract" instance
3153 of a function which we may later generate inlined and/or
3154 out-of-line instances of. */
3155 if (write_symbols == DWARF2_DEBUG)
3157 set_decl_abstract_flags (decl, 1);
3158 TIMEVAR (symout_time, dwarf2out_decl (decl));
3159 set_decl_abstract_flags (decl, 0);
3161 #endif
3162 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3163 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3164 goto exit_rest_of_compilation;
3167 /* If we have to compile the function now, save its rtl and subdecls
3168 so that its compilation will not affect what others get. */
3169 if (inlinable || DECL_DEFER_OUTPUT (decl))
3171 #ifdef DWARF_DEBUGGING_INFO
3172 /* Generate the DWARF info for the "abstract" instance of
3173 a function which we will generate an out-of-line instance
3174 of almost immediately (and which we may also later generate
3175 various inlined instances of). */
3176 if (write_symbols == DWARF_DEBUG)
3178 set_decl_abstract_flags (decl, 1);
3179 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3180 set_decl_abstract_flags (decl, 0);
3182 #endif
3183 #ifdef DWARF2_DEBUGGING_INFO
3184 /* Generate the DWARF2 info for the "abstract" instance of
3185 a function which we will generate an out-of-line instance
3186 of almost immediately (and which we may also later generate
3187 various inlined instances of). */
3188 if (write_symbols == DWARF2_DEBUG)
3190 set_decl_abstract_flags (decl, 1);
3191 TIMEVAR (symout_time, dwarf2out_decl (decl));
3192 set_decl_abstract_flags (decl, 0);
3194 #endif
3195 saved_block_tree = DECL_INITIAL (decl);
3196 saved_arguments = DECL_ARGUMENTS (decl);
3197 TIMEVAR (integration_time, save_for_inline_copying (decl));
3198 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3201 /* If specified extern inline but we aren't inlining it, we are
3202 done. */
3203 if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
3204 goto exit_rest_of_compilation;
3207 if (! DECL_DEFER_OUTPUT (decl))
3208 TREE_ASM_WRITTEN (decl) = 1;
3210 /* Now that integrate will no longer see our rtl, we need not distinguish
3211 between the return value of this function and the return value of called
3212 functions. */
3213 rtx_equal_function_value_matters = 0;
3215 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3216 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3218 goto exit_rest_of_compilation;
3221 /* Emit code to get eh context, if needed. */
3222 emit_eh_context ();
3224 #ifdef FINALIZE_PIC
3225 /* If we are doing position-independent code generation, now
3226 is the time to output special prologues and epilogues.
3227 We do not want to do this earlier, because it just clutters
3228 up inline functions with meaningless insns. */
3229 if (flag_pic)
3230 FINALIZE_PIC;
3231 #endif
3233 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3234 Note that that may have been done above, in save_for_inline_copying.
3235 The call to resume_temporary_allocation near the end of this function
3236 goes back to the usual state of affairs. This must be done after
3237 we've built up any unwinders for exception handling, and done
3238 the FINALIZE_PIC work, if necessary. */
3240 rtl_in_current_obstack ();
3242 insns = get_insns ();
3244 /* Copy any shared structure that should not be shared. */
3246 unshare_all_rtl (insns);
3248 #ifdef SETJMP_VIA_SAVE_AREA
3249 /* This must be performed before virutal register instantiation. */
3250 if (current_function_calls_alloca)
3251 optimize_save_area_alloca (insns);
3252 #endif
3254 /* Instantiate all virtual registers. */
3256 instantiate_virtual_regs (current_function_decl, get_insns ());
3258 /* See if we have allocated stack slots that are not directly addressable.
3259 If so, scan all the insns and create explicit address computation
3260 for all references to such slots. */
3261 /* fixup_stack_slots (); */
3263 /* Find all the EH handlers. */
3264 find_exception_handler_labels ();
3266 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3267 are initialized and to compute whether control can drop off the end
3268 of the function. */
3269 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3270 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3271 JUMP_AFTER_REGSCAN));
3273 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3274 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3275 goto exit_rest_of_compilation;
3277 /* Dump rtl code after jump, if we are doing that. */
3279 if (jump_opt_dump)
3280 dump_rtl (".jump", decl, print_rtl, insns);
3282 /* Perform common subexpression elimination.
3283 Nonzero value from `cse_main' means that jumps were simplified
3284 and some code may now be unreachable, so do
3285 jump optimization again. */
3287 if (optimize > 0)
3289 if (cse_dump)
3290 open_dump_file (".cse", decl_printable_name (decl, 2));
3292 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3294 if (flag_thread_jumps)
3295 /* Hacks by tiemann & kenner. */
3296 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3298 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3299 0, rtl_dump_file));
3300 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3302 if (tem || optimize > 1)
3303 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3304 !JUMP_NOOP_MOVES,
3305 !JUMP_AFTER_REGSCAN));
3307 /* Dump rtl code after cse, if we are doing that. */
3309 if (cse_dump)
3310 close_dump_file (print_rtl, insns);
3313 purge_addressof (insns);
3314 reg_scan (insns, max_reg_num (), 1);
3316 if (addressof_dump)
3317 dump_rtl (".addressof", decl, print_rtl, insns);
3319 /* Perform global cse. */
3321 if (optimize > 0 && flag_gcse)
3323 if (gcse_dump)
3324 open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl)));
3326 TIMEVAR (gcse_time, gcse_main (insns, rtl_dump_file));
3328 if (gcse_dump)
3329 close_dump_file (print_rtl, insns);
3331 /* Move constant computations out of loops. */
3333 if (optimize > 0)
3335 if (loop_dump)
3336 open_dump_file (".loop", decl_printable_name (decl, 2));
3338 TIMEVAR
3339 (loop_time,
3341 if (flag_rerun_loop_opt)
3343 /* We only want to perform unrolling once. */
3345 loop_optimize (insns, rtl_dump_file, 0);
3348 /* The first call to loop_optimize makes some instructions
3349 trivially dead. We delete those instructions now in the
3350 hope that doing so will make the heuristics in loop work
3351 better and possibly speed up compilation. */
3352 delete_trivially_dead_insns (insns, max_reg_num ());
3354 /* The regscan pass is currently necessary as the alias
3355 analysis code depends on this information. */
3356 reg_scan (insns, max_reg_num (), 1);
3358 loop_optimize (insns, rtl_dump_file, flag_unroll_loops);
3361 /* Dump rtl code after loop opt, if we are doing that. */
3363 if (loop_dump)
3364 close_dump_file (print_rtl, insns);
3367 if (optimize > 0)
3369 if (cse2_dump)
3370 open_dump_file (".cse2", decl_printable_name (decl, 2));
3372 if (flag_rerun_cse_after_loop)
3374 /* Running another jump optimization pass before the second
3375 cse pass sometimes simplifies the RTL enough to allow
3376 the second CSE pass to do a better job. Jump_optimize can change
3377 max_reg_num so we must rerun reg_scan afterwards.
3378 ??? Rework to not call reg_scan so often. */
3379 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3380 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3381 !JUMP_NOOP_MOVES,
3382 JUMP_AFTER_REGSCAN));
3384 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3385 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3386 1, rtl_dump_file));
3387 if (tem)
3388 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3389 !JUMP_NOOP_MOVES,
3390 !JUMP_AFTER_REGSCAN));
3393 if (flag_thread_jumps)
3395 /* This pass of jump threading straightens out code
3396 that was kinked by loop optimization. */
3397 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3398 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3401 /* Dump rtl code after cse, if we are doing that. */
3403 if (cse2_dump)
3404 close_dump_file (print_rtl, insns);
3407 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3409 if (branch_prob_dump)
3410 open_dump_file (".bp", decl_printable_name (decl, 2));
3412 TIMEVAR
3413 (branch_prob_time,
3415 branch_prob (insns, rtl_dump_file);
3418 if (branch_prob_dump)
3419 close_dump_file (print_rtl, insns);
3422 /* We are no longer anticipating cse in this function, at least. */
3424 cse_not_expected = 1;
3426 /* Now we choose between stupid (pcc-like) register allocation
3427 (if we got the -noreg switch and not -opt)
3428 and smart register allocation. */
3430 if (optimize > 0) /* Stupid allocation probably won't work */
3431 obey_regdecls = 0; /* if optimizations being done. */
3433 regclass_init ();
3435 /* Print function header into flow dump now
3436 because doing the flow analysis makes some of the dump. */
3438 if (flow_dump)
3439 open_dump_file (".flow", decl_printable_name (decl, 2));
3441 if (obey_regdecls)
3443 TIMEVAR (flow_time,
3445 regclass (insns, max_reg_num ());
3446 stupid_life_analysis (insns, max_reg_num (),
3447 rtl_dump_file);
3450 else
3452 /* Do control and data flow analysis,
3453 and write some of the results to dump file. */
3455 TIMEVAR
3456 (flow_time,
3458 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
3459 life_analysis (insns, max_reg_num (), rtl_dump_file);
3462 if (warn_uninitialized)
3464 uninitialized_vars_warning (DECL_INITIAL (decl));
3465 setjmp_args_warning ();
3469 /* Dump rtl after flow analysis. */
3471 if (flow_dump)
3472 close_dump_file (print_rtl_with_bb, insns);
3474 /* If -opt, try combining insns through substitution. */
3476 if (optimize > 0)
3478 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3480 /* Dump rtl code after insn combination. */
3482 if (combine_dump)
3483 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
3486 /* Register allocation pre-pass, to reduce number of moves
3487 necessary for two-address machines. */
3488 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3490 if (regmove_dump)
3491 open_dump_file (".regmove", decl_printable_name (decl, 2));
3493 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
3494 rtl_dump_file));
3496 if (regmove_dump)
3497 close_dump_file (print_rtl_with_bb, insns);
3500 /* Print function header into sched dump now
3501 because doing the sched analysis makes some of the dump. */
3503 if (optimize > 0 && flag_schedule_insns)
3505 if (sched_dump)
3506 open_dump_file (".sched", decl_printable_name (decl, 2));
3508 /* Do control and data sched analysis,
3509 and write some of the results to dump file. */
3511 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
3513 /* Dump rtl after instruction scheduling. */
3515 if (sched_dump)
3516 close_dump_file (print_rtl_with_bb, insns);
3519 /* Unless we did stupid register allocation,
3520 allocate pseudo-regs that are used only within 1 basic block. */
3522 if (!obey_regdecls)
3523 TIMEVAR (local_alloc_time,
3525 recompute_reg_usage (insns);
3526 regclass (insns, max_reg_num ());
3527 local_alloc ();
3530 /* Dump rtl code after allocating regs within basic blocks. */
3532 if (local_reg_dump)
3534 open_dump_file (".lreg", decl_printable_name (decl, 2));
3536 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
3537 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
3539 close_dump_file (print_rtl_with_bb, insns);
3542 if (global_reg_dump)
3543 open_dump_file (".greg", decl_printable_name (decl, 2));
3545 /* Save the last label number used so far, so reorg can tell
3546 when it's safe to kill spill regs. */
3547 max_label_num_after_reload = max_label_num ();
3549 /* Unless we did stupid register allocation,
3550 allocate remaining pseudo-regs, then do the reload pass
3551 fixing up any insns that are invalid. */
3553 TIMEVAR (global_alloc_time,
3555 if (!obey_regdecls)
3556 failure = global_alloc (rtl_dump_file);
3557 else
3558 failure = reload (insns, 0, rtl_dump_file);
3562 if (failure)
3563 goto exit_rest_of_compilation;
3565 reload_completed = 1;
3567 /* Do a very simple CSE pass over just the hard registers. */
3568 if (optimize > 0)
3569 reload_cse_regs (insns);
3571 /* On some machines, the prologue and epilogue code, or parts thereof,
3572 can be represented as RTL. Doing so lets us schedule insns between
3573 it and the rest of the code and also allows delayed branch
3574 scheduling to operate in the epilogue. */
3576 thread_prologue_and_epilogue_insns (insns);
3578 if (global_reg_dump)
3580 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
3581 close_dump_file (print_rtl_with_bb, insns);
3583 if (optimize > 0 && flag_schedule_insns_after_reload)
3585 if (sched2_dump)
3586 open_dump_file (".sched2", decl_printable_name (decl, 2));
3588 /* Do control and data sched analysis again,
3589 and write some more of the results to dump file. */
3591 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
3593 /* Dump rtl after post-reorder instruction scheduling. */
3595 if (sched2_dump)
3596 close_dump_file (print_rtl_with_bb, insns);
3599 #ifdef LEAF_REGISTERS
3600 leaf_function = 0;
3601 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3602 leaf_function = 1;
3603 #endif
3605 /* One more attempt to remove jumps to .+1
3606 left by dead-store-elimination.
3607 Also do cross-jumping this time
3608 and delete no-op move insns. */
3610 if (optimize > 0)
3612 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
3613 JUMP_NOOP_MOVES,
3614 !JUMP_AFTER_REGSCAN));
3616 /* Dump rtl code after jump, if we are doing that. */
3618 if (jump2_opt_dump)
3619 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
3622 /* If a machine dependent reorganization is needed, call it. */
3623 #ifdef MACHINE_DEPENDENT_REORG
3624 MACHINE_DEPENDENT_REORG (insns);
3626 if (mach_dep_reorg_dump)
3627 dump_rtl (".mach", decl, print_rtl_with_bb, insns);
3628 #endif
3630 /* If a scheduling pass for delayed branches is to be done,
3631 call the scheduling code. */
3633 #ifdef DELAY_SLOTS
3634 if (optimize > 0 && flag_delayed_branch)
3636 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
3638 if (dbr_sched_dump)
3639 dump_rtl (".dbr", decl, print_rtl_with_bb, insns);
3641 #endif
3643 /* Shorten branches. */
3644 TIMEVAR (shorten_branch_time,
3646 shorten_branches (get_insns ());
3649 #ifdef STACK_REGS
3650 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
3652 if (stack_reg_dump)
3653 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
3654 #endif
3656 /* Now turn the rtl into assembler code. */
3658 TIMEVAR (final_time,
3660 rtx x;
3661 char *fnname;
3663 /* Get the function's name, as described by its RTL.
3664 This may be different from the DECL_NAME name used
3665 in the source file. */
3667 x = DECL_RTL (decl);
3668 if (GET_CODE (x) != MEM)
3669 abort ();
3670 x = XEXP (x, 0);
3671 if (GET_CODE (x) != SYMBOL_REF)
3672 abort ();
3673 fnname = XSTR (x, 0);
3675 assemble_start_function (decl, fnname);
3676 final_start_function (insns, asm_out_file, optimize);
3677 final (insns, asm_out_file, optimize, 0);
3678 final_end_function (insns, asm_out_file, optimize);
3679 assemble_end_function (decl, fnname);
3680 if (! quiet_flag)
3681 fflush (asm_out_file);
3683 /* Release all memory held by regsets now */
3684 regset_release_memory ();
3687 /* Write DBX symbols if requested */
3689 /* Note that for those inline functions where we don't initially
3690 know for certain that we will be generating an out-of-line copy,
3691 the first invocation of this routine (rest_of_compilation) will
3692 skip over this code by doing a `goto exit_rest_of_compilation;'.
3693 Later on, finish_compilation will call rest_of_compilation again
3694 for those inline functions that need to have out-of-line copies
3695 generated. During that call, we *will* be routed past here. */
3697 #ifdef DBX_DEBUGGING_INFO
3698 if (write_symbols == DBX_DEBUG)
3699 TIMEVAR (symout_time, dbxout_function (decl));
3700 #endif
3702 #ifdef DWARF_DEBUGGING_INFO
3703 if (write_symbols == DWARF_DEBUG)
3704 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3705 #endif
3707 #ifdef DWARF2_DEBUGGING_INFO
3708 if (write_symbols == DWARF2_DEBUG)
3709 TIMEVAR (symout_time, dwarf2out_decl (decl));
3710 #endif
3712 exit_rest_of_compilation:
3714 /* In case the function was not output,
3715 don't leave any temporary anonymous types
3716 queued up for sdb output. */
3717 #ifdef SDB_DEBUGGING_INFO
3718 if (write_symbols == SDB_DEBUG)
3719 sdbout_types (NULL_TREE);
3720 #endif
3722 /* Put back the tree of subblocks and list of arguments
3723 from before we copied them.
3724 Code generation and the output of debugging info may have modified
3725 the copy, but the original is unchanged. */
3727 if (saved_block_tree != 0)
3729 DECL_INITIAL (decl) = saved_block_tree;
3730 DECL_ARGUMENTS (decl) = saved_arguments;
3731 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3734 reload_completed = 0;
3736 TIMEVAR (final_time,
3738 /* Clear out the insn_length contents now that they are no
3739 longer valid. */
3740 init_insn_lengths ();
3742 /* Clear out the real_constant_chain before some of the rtx's
3743 it runs through become garbage. */
3744 clear_const_double_mem ();
3746 /* Cancel the effect of rtl_in_current_obstack. */
3747 resume_temporary_allocation ();
3749 /* Show no temporary slots allocated. */
3750 init_temp_slots ();
3753 /* Make sure volatile mem refs aren't considered valid operands for
3754 arithmetic insns. We must call this here if this is a nested inline
3755 function, since the above code leaves us in the init_recog state
3756 (from final.c), and the function context push/pop code does not
3757 save/restore volatile_ok.
3759 ??? Maybe it isn't necessary for expand_start_function to call this
3760 anymore if we do it here? */
3762 init_recog_no_volatile ();
3764 /* The parsing time is all the time spent in yyparse
3765 *except* what is spent in this function. */
3767 parse_time -= get_run_time () - start_time;
3770 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3771 Exit code is 35 if can't open files, 34 if fatal error,
3772 33 if had nonfatal errors, else success. */
3775 main (argc, argv, envp)
3776 int argc;
3777 char **argv;
3778 char **envp;
3780 register int i;
3781 char *filename = 0;
3782 int flag_print_mem = 0;
3783 int version_flag = 0;
3784 char *p;
3786 /* save in case md file wants to emit args as a comment. */
3787 save_argc = argc;
3788 save_argv = argv;
3790 p = argv[0] + strlen (argv[0]);
3791 while (p != argv[0] && p[-1] != '/'
3792 #ifdef DIR_SEPARATOR
3793 && p[-1] != DIR_SEPARATOR
3794 #endif
3796 --p;
3797 progname = p;
3799 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
3800 /* Get rid of any avoidable limit on stack size. */
3802 struct rlimit rlim;
3804 /* Set the stack limit huge so that alloca does not fail. */
3805 getrlimit (RLIMIT_STACK, &rlim);
3806 rlim.rlim_cur = rlim.rlim_max;
3807 setrlimit (RLIMIT_STACK, &rlim);
3809 #endif
3811 signal (SIGFPE, float_signal);
3813 #ifdef SIGPIPE
3814 signal (SIGPIPE, pipe_closed);
3815 #endif
3817 decl_printable_name = decl_name;
3818 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3820 /* Initialize whether `char' is signed. */
3821 flag_signed_char = DEFAULT_SIGNED_CHAR;
3822 #ifdef DEFAULT_SHORT_ENUMS
3823 /* Initialize how much space enums occupy, by default. */
3824 flag_short_enums = DEFAULT_SHORT_ENUMS;
3825 #endif
3827 /* Perform language-specific options intialization. */
3828 lang_init_options ();
3830 /* Scan to see what optimization level has been specified. That will
3831 determine the default value of many flags. */
3832 for (i = 1; i < argc; i++)
3834 if (!strcmp (argv[i], "-O"))
3836 optimize = 1;
3838 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3840 /* Handle -Os, -O2, -O3, -O69, ... */
3841 char *p = &argv[i][2];
3842 int c;
3844 if ((p[0] == 's') && (p[1] == 0))
3845 optimize_size = 1;
3846 else
3848 while ((c = *p++))
3849 if (! (c >= '0' && c <= '9'))
3850 break;
3851 if (c == 0)
3852 optimize = atoi (&argv[i][2]);
3857 /* Optimizing for size forces optimize to be no less than 2. */
3858 if (optimize_size && (optimize < 2))
3859 optimize = 2;
3861 obey_regdecls = (optimize == 0);
3863 if (optimize >= 1)
3865 flag_defer_pop = 1;
3866 flag_thread_jumps = 1;
3867 #ifdef DELAY_SLOTS
3868 flag_delayed_branch = 1;
3869 #endif
3870 #ifdef CAN_DEBUG_WITHOUT_FP
3871 flag_omit_frame_pointer = 1;
3872 #endif
3875 if (optimize >= 2)
3877 flag_cse_follow_jumps = 1;
3878 flag_cse_skip_blocks = 1;
3879 flag_gcse = 1;
3880 flag_expensive_optimizations = 1;
3881 flag_strength_reduce = 1;
3882 flag_rerun_cse_after_loop = 1;
3883 flag_rerun_loop_opt = 1;
3884 flag_caller_saves = 1;
3885 flag_force_mem = 1;
3886 #ifdef INSN_SCHEDULING
3887 flag_schedule_insns = 1;
3888 flag_schedule_insns_after_reload = 1;
3889 #endif
3890 flag_regmove = 1;
3891 /* We don't set flag_strict_aliasing here because we're still
3892 testing the functionality. After it has been tested, it
3893 should be turned on here. */
3896 if (optimize >= 3)
3898 flag_inline_functions = 1;
3901 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
3902 modify it. */
3903 target_flags = 0;
3904 set_target_switch ("");
3906 #ifdef OPTIMIZATION_OPTIONS
3907 /* Allow default optimizations to be specified on a per-machine basis. */
3908 OPTIMIZATION_OPTIONS (optimize, optimize_size);
3909 #endif
3911 /* Initialize register usage now so switches may override. */
3912 init_reg_sets ();
3914 for (i = 1; i < argc; i++)
3916 size_t j;
3917 /* If this is a language-specific option,
3918 decode it in a language-specific way. */
3919 for (j = 0; lang_options[j] != 0; j++)
3920 if (!strncmp (argv[i], lang_options[j],
3921 strlen (lang_options[j])))
3922 break;
3923 if (lang_options[j] != 0)
3925 /* If the option is valid for *some* language,
3926 treat it as valid even if this language doesn't understand it. */
3927 int strings_processed = lang_decode_option (argc - i, argv + i);
3928 if (strings_processed != 0)
3929 i += strings_processed - 1;
3931 else if (argv[i][0] == '-' && argv[i][1] != 0)
3933 register char *str = argv[i] + 1;
3934 if (str[0] == 'Y')
3935 str++;
3937 if (str[0] == 'm')
3938 set_target_switch (&str[1]);
3939 else if (!strcmp (str, "dumpbase"))
3941 dump_base_name = argv[++i];
3943 else if (str[0] == 'd')
3945 register char *p = &str[1];
3946 while (*p)
3947 switch (*p++)
3949 case 'a':
3950 branch_prob_dump = 1;
3951 combine_dump = 1;
3952 #ifdef DELAY_SLOTS
3953 dbr_sched_dump = 1;
3954 #endif
3955 flow_dump = 1;
3956 global_reg_dump = 1;
3957 jump_opt_dump = 1;
3958 addressof_dump = 1;
3959 jump2_opt_dump = 1;
3960 local_reg_dump = 1;
3961 loop_dump = 1;
3962 regmove_dump = 1;
3963 rtl_dump = 1;
3964 cse_dump = 1, cse2_dump = 1;
3965 gcse_dump = 1;
3966 sched_dump = 1;
3967 sched2_dump = 1;
3968 #ifdef STACK_REGS
3969 stack_reg_dump = 1;
3970 #endif
3971 #ifdef MACHINE_DEPENDENT_REORG
3972 mach_dep_reorg_dump = 1;
3973 #endif
3974 break;
3975 case 'A':
3976 flag_debug_asm = 1;
3977 break;
3978 case 'b':
3979 branch_prob_dump = 1;
3980 break;
3981 case 'c':
3982 combine_dump = 1;
3983 break;
3984 #ifdef DELAY_SLOTS
3985 case 'd':
3986 dbr_sched_dump = 1;
3987 break;
3988 #endif
3989 case 'f':
3990 flow_dump = 1;
3991 break;
3992 case 'F':
3993 addressof_dump = 1;
3994 break;
3995 case 'g':
3996 global_reg_dump = 1;
3997 break;
3998 case 'G':
3999 gcse_dump = 1;
4000 break;
4001 case 'j':
4002 jump_opt_dump = 1;
4003 break;
4004 case 'J':
4005 jump2_opt_dump = 1;
4006 break;
4007 #ifdef STACK_REGS
4008 case 'k':
4009 stack_reg_dump = 1;
4010 break;
4011 #endif
4012 case 'l':
4013 local_reg_dump = 1;
4014 break;
4015 case 'L':
4016 loop_dump = 1;
4017 break;
4018 case 'm':
4019 flag_print_mem = 1;
4020 break;
4021 #ifdef MACHINE_DEPENDENT_REORG
4022 case 'M':
4023 mach_dep_reorg_dump = 1;
4024 break;
4025 #endif
4026 case 'p':
4027 flag_print_asm_name = 1;
4028 break;
4029 case 'r':
4030 rtl_dump = 1;
4031 break;
4032 case 'R':
4033 sched2_dump = 1;
4034 break;
4035 case 's':
4036 cse_dump = 1;
4037 break;
4038 case 'S':
4039 sched_dump = 1;
4040 break;
4041 case 't':
4042 cse2_dump = 1;
4043 break;
4044 case 'N':
4045 regmove_dump = 1;
4046 break;
4047 case 'y':
4048 set_yydebug (1);
4049 break;
4050 case 'x':
4051 rtl_dump_and_exit = 1;
4052 break;
4053 default:
4054 warning ("unrecognised gcc debugging option: %c", p[-1]);
4055 break;
4058 else if (str[0] == 'f')
4060 register char *p = &str[1];
4061 int found = 0;
4063 /* Some kind of -f option.
4064 P's value is the option sans `-f'.
4065 Search for it in the table of options. */
4067 for (j = 0;
4068 !found && j < sizeof (f_options) / sizeof (f_options[0]);
4069 j++)
4071 if (!strcmp (p, f_options[j].string))
4073 *f_options[j].variable = f_options[j].on_value;
4074 /* A goto here would be cleaner,
4075 but breaks the vax pcc. */
4076 found = 1;
4078 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4079 && ! strcmp (p+3, f_options[j].string))
4081 *f_options[j].variable = ! f_options[j].on_value;
4082 found = 1;
4086 if (found)
4088 #ifdef HAIFA
4089 #ifdef INSN_SCHEDULING
4090 else if (!strncmp (p, "sched-verbose-",14))
4091 fix_sched_param("verbose",&p[14]);
4092 #endif
4093 #endif /* HAIFA */
4094 else if (!strncmp (p, "fixed-", 6))
4095 fix_register (&p[6], 1, 1);
4096 else if (!strncmp (p, "call-used-", 10))
4097 fix_register (&p[10], 0, 1);
4098 else if (!strncmp (p, "call-saved-", 11))
4099 fix_register (&p[11], 0, 0);
4100 else
4101 error ("Invalid option `%s'", argv[i]);
4103 else if (str[0] == 'O')
4105 register char *p = str+1;
4106 if (*p == 's')
4107 p++;
4108 else
4109 while (*p && *p >= '0' && *p <= '9')
4110 p++;
4111 if (*p == '\0')
4113 else
4114 error ("Invalid option `%s'", argv[i]);
4116 else if (!strcmp (str, "pedantic"))
4117 pedantic = 1;
4118 else if (!strcmp (str, "pedantic-errors"))
4119 flag_pedantic_errors = pedantic = 1;
4120 else if (!strcmp (str, "quiet"))
4121 quiet_flag = 1;
4122 else if (!strcmp (str, "version"))
4123 version_flag = 1;
4124 else if (!strcmp (str, "w"))
4125 inhibit_warnings = 1;
4126 else if (!strcmp (str, "W"))
4128 extra_warnings = 1;
4129 /* We save the value of warn_uninitialized, since if they put
4130 -Wuninitialized on the command line, we need to generate a
4131 warning about not using it without also specifying -O. */
4132 if (warn_uninitialized != 1)
4133 warn_uninitialized = 2;
4135 else if (str[0] == 'W')
4137 register char *p = &str[1];
4138 int found = 0;
4140 /* Some kind of -W option.
4141 P's value is the option sans `-W'.
4142 Search for it in the table of options. */
4144 for (j = 0;
4145 !found && j < sizeof (W_options) / sizeof (W_options[0]);
4146 j++)
4148 if (!strcmp (p, W_options[j].string))
4150 *W_options[j].variable = W_options[j].on_value;
4151 /* A goto here would be cleaner,
4152 but breaks the vax pcc. */
4153 found = 1;
4155 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4156 && ! strcmp (p+3, W_options[j].string))
4158 *W_options[j].variable = ! W_options[j].on_value;
4159 found = 1;
4163 if (found)
4165 else if (!strncmp (p, "id-clash-", 9))
4167 char *endp = p + 9;
4169 while (*endp)
4171 if (*endp >= '0' && *endp <= '9')
4172 endp++;
4173 else
4175 error ("Invalid option `%s'", argv[i]);
4176 goto id_clash_lose;
4179 warn_id_clash = 1;
4180 id_clash_len = atoi (str + 10);
4181 id_clash_lose: ;
4183 else if (!strncmp (p, "larger-than-", 12))
4185 char *endp = p + 12;
4187 while (*endp)
4189 if (*endp >= '0' && *endp <= '9')
4190 endp++;
4191 else
4193 error ("Invalid option `%s'", argv[i]);
4194 goto larger_than_lose;
4197 warn_larger_than = 1;
4198 larger_than_size = atoi (str + 13);
4199 larger_than_lose: ;
4201 else
4202 error ("Invalid option `%s'", argv[i]);
4204 else if (!strcmp (str, "p"))
4206 profile_flag = 1;
4208 else if (!strcmp (str, "a"))
4210 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4211 warning ("`-a' option (basic block profile) not supported");
4212 #else
4213 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4214 #endif
4216 else if (!strcmp (str, "ax"))
4218 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4219 warning ("`-ax' option (jump profiling) not supported");
4220 #else
4221 profile_block_flag = (!profile_block_flag
4222 || profile_block_flag == 2) ? 2 : 3;
4223 #endif
4225 else if (str[0] == 'g')
4227 unsigned len;
4228 unsigned level;
4229 /* A lot of code assumes write_symbols == NO_DEBUG if the
4230 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4231 of what debugging type has been selected). This records the
4232 selected type. It is an error to specify more than one
4233 debugging type. */
4234 static enum debug_info_type selected_debug_type = NO_DEBUG;
4235 /* Non-zero if debugging format has been explicitly set.
4236 -g and -ggdb don't explicitly set the debugging format so
4237 -gdwarf -g3 is equivalent to -gdwarf3. */
4238 static int type_explicitly_set_p = 0;
4239 /* Table of supported debugging formats. */
4240 static struct {
4241 char *arg;
4242 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
4243 constant expression, we use NO_DEBUG in its place. */
4244 enum debug_info_type debug_type;
4245 int use_extensions_p;
4246 } *da, debug_args[] = {
4247 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS },
4248 { "ggdb", NO_DEBUG, 1 },
4249 #ifdef DBX_DEBUGGING_INFO
4250 { "gstabs", DBX_DEBUG, 0 },
4251 { "gstabs+", DBX_DEBUG, 1 },
4252 #endif
4253 #ifdef DWARF_DEBUGGING_INFO
4254 { "gdwarf", DWARF_DEBUG, 0 },
4255 { "gdwarf+", DWARF_DEBUG, 1 },
4256 #endif
4257 #ifdef DWARF2_DEBUGGING_INFO
4258 { "gdwarf-2", DWARF2_DEBUG, 0 },
4259 #endif
4260 #ifdef XCOFF_DEBUGGING_INFO
4261 { "gxcoff", XCOFF_DEBUG, 0 },
4262 { "gxcoff+", XCOFF_DEBUG, 1 },
4263 #endif
4264 #ifdef SDB_DEBUGGING_INFO
4265 { "gcoff", SDB_DEBUG, 0 },
4266 #endif
4267 { 0, 0, 0 }
4269 /* Indexed by enum debug_info_type. */
4270 static char *debug_type_names[] = {
4271 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4274 /* Look up STR in the table. */
4275 for (da = debug_args; da->arg; da++)
4277 if (! strncmp (str, da->arg, strlen (da->arg)))
4279 enum debug_info_type type = da->debug_type;
4280 char *p, *q;
4282 p = str + strlen (da->arg);
4283 if (*p && (*p < '0' || *p > '9'))
4284 continue;
4285 len = p - str;
4286 q = p;
4287 while (*q && (*q >= '0' && *q <= '9'))
4288 q++;
4289 if (*p)
4291 level = atoi (p);
4292 if (len > 1 && !strncmp (str, "gdwarf", len))
4294 error ("use -gdwarf -g%d for DWARF v1, level %d",
4295 level, level);
4296 if (level == 2)
4297 error ("use -gdwarf-2 for DWARF v2");
4300 else
4301 level = 2; /* default debugging info level */
4302 if (*q || level > 3)
4304 warning ("invalid debug level specification in option: `-%s'",
4305 str);
4306 /* ??? This error message is incorrect in the case of
4307 -g4 -g. */
4308 warning ("no debugging information will be generated");
4309 level = 0;
4312 if (type == NO_DEBUG)
4314 type = PREFERRED_DEBUGGING_TYPE;
4315 if (len > 1 && strncmp (str, "ggdb", len) == 0)
4317 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4318 type = DWARF2_DEBUG;
4319 #else
4320 #ifdef DBX_DEBUGGING_INFO
4321 type = DBX_DEBUG;
4322 #endif
4323 #endif
4327 if (type == NO_DEBUG)
4328 warning ("`-%s' not supported by this configuration of GCC",
4329 str);
4331 /* Does it conflict with an already selected type? */
4332 if (type_explicitly_set_p
4333 /* -g/-ggdb don't conflict with anything */
4334 && da->debug_type != NO_DEBUG
4335 && type != selected_debug_type)
4336 warning ("`-%s' ignored, conflicts with `-g%s'",
4337 str, debug_type_names[(int) selected_debug_type]);
4338 else
4340 /* If the format has already been set, -g/-ggdb
4341 only change the debug level. */
4342 if (type_explicitly_set_p
4343 && da->debug_type == NO_DEBUG)
4344 ; /* don't change debugging type */
4345 else
4347 selected_debug_type = type;
4348 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4350 write_symbols = (level == 0
4351 ? NO_DEBUG
4352 : selected_debug_type);
4353 use_gnu_debug_info_extensions = da->use_extensions_p;
4354 debug_info_level = (enum debug_info_level) level;
4356 break;
4359 if (! da->arg)
4360 warning ("`-%s' not supported by this configuration of GCC",
4361 str);
4363 else if (!strcmp (str, "o"))
4365 asm_file_name = argv[++i];
4367 else if (str[0] == 'G')
4369 g_switch_set = TRUE;
4370 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
4372 else if (!strncmp (str, "aux-info", 8))
4374 flag_gen_aux_info = 1;
4375 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
4377 else
4378 error ("Invalid option `%s'", argv[i]);
4380 else if (argv[i][0] == '+')
4381 error ("Invalid option `%s'", argv[i]);
4382 else
4383 filename = argv[i];
4386 /* Checker uses the frame pointer. */
4387 if (flag_check_memory_usage)
4388 flag_omit_frame_pointer = 0;
4390 if (optimize == 0)
4392 /* Inlining does not work if not optimizing,
4393 so force it not to be done. */
4394 flag_no_inline = 1;
4395 warn_inline = 0;
4397 /* The c_decode_option and lang_decode_option functions set
4398 this to `2' if -Wall is used, so we can avoid giving out
4399 lots of errors for people who don't realize what -Wall does. */
4400 if (warn_uninitialized == 1)
4401 warning ("-Wuninitialized is not supported without -O");
4404 #ifdef OVERRIDE_OPTIONS
4405 /* Some machines may reject certain combinations of options. */
4406 OVERRIDE_OPTIONS;
4407 #endif
4409 if (exceptions_via_longjmp == 2)
4411 #ifdef DWARF2_UNWIND_INFO
4412 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4413 #else
4414 exceptions_via_longjmp = 1;
4415 #endif
4418 if (profile_block_flag == 3)
4420 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4421 profile_block_flag = 2;
4424 /* Unrolling all loops implies that standard loop unrolling must also
4425 be done. */
4426 if (flag_unroll_all_loops)
4427 flag_unroll_loops = 1;
4428 /* Loop unrolling requires that strength_reduction be on also. Silently
4429 turn on strength reduction here if it isn't already on. Also, the loop
4430 unrolling code assumes that cse will be run after loop, so that must
4431 be turned on also. */
4432 if (flag_unroll_loops)
4434 flag_strength_reduce = 1;
4435 flag_rerun_cse_after_loop = 1;
4438 /* Warn about options that are not supported on this machine. */
4439 #ifndef INSN_SCHEDULING
4440 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4441 warning ("instruction scheduling not supported on this target machine");
4442 #endif
4443 #ifndef DELAY_SLOTS
4444 if (flag_delayed_branch)
4445 warning ("this target machine does not have delayed branches");
4446 #endif
4448 /* If we are in verbose mode, write out the version and maybe all the
4449 option flags in use. */
4450 if (version_flag)
4452 print_version (stderr, "");
4453 if (! quiet_flag)
4454 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4457 compile_file (filename);
4459 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4460 if (flag_print_mem)
4462 char *lim = (char *) sbrk (0);
4464 fprintf (stderr, "Data size %ld.\n", (long)(lim - (char *) &environ));
4465 fflush (stderr);
4467 #ifndef __MSDOS__
4468 #ifdef USG
4469 system ("ps -l 1>&2");
4470 #else /* not USG */
4471 system ("ps v");
4472 #endif /* not USG */
4473 #endif
4475 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4477 if (errorcount)
4478 exit (FATAL_EXIT_CODE);
4479 if (sorrycount)
4480 exit (FATAL_EXIT_CODE);
4481 exit (SUCCESS_EXIT_CODE);
4482 return 0;
4485 /* Decode -m switches. */
4487 /* Here is a table, controlled by the tm.h file, listing each -m switch
4488 and which bits in `target_switches' it should set or clear.
4489 If VALUE is positive, it is bits to set.
4490 If VALUE is negative, -VALUE is bits to clear.
4491 (The sign bit is not used so there is no confusion.) */
4493 struct {char *name; int value;} target_switches []
4494 = TARGET_SWITCHES;
4496 /* This table is similar, but allows the switch to have a value. */
4498 #ifdef TARGET_OPTIONS
4499 struct {char *prefix; char ** variable;} target_options []
4500 = TARGET_OPTIONS;
4501 #endif
4503 /* Decode the switch -mNAME. */
4505 void
4506 set_target_switch (name)
4507 char *name;
4509 register size_t j;
4510 int valid = 0;
4512 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4513 if (!strcmp (target_switches[j].name, name))
4515 if (target_switches[j].value < 0)
4516 target_flags &= ~-target_switches[j].value;
4517 else
4518 target_flags |= target_switches[j].value;
4519 valid = 1;
4522 #ifdef TARGET_OPTIONS
4523 if (!valid)
4524 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4526 int len = strlen (target_options[j].prefix);
4527 if (!strncmp (target_options[j].prefix, name, len))
4529 *target_options[j].variable = name + len;
4530 valid = 1;
4533 #endif
4535 if (!valid)
4536 error ("Invalid option `%s'", name);
4539 /* Print version information to FILE.
4540 Each line begins with INDENT (for the case where FILE is the
4541 assembler output file). */
4543 void
4544 print_version (file, indent)
4545 FILE *file;
4546 char *indent;
4548 fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4549 language_string, version_string);
4550 fprintf (file, " (%s)", TARGET_NAME);
4551 #ifdef __GNUC__
4552 #ifndef __VERSION__
4553 #define __VERSION__ "[unknown]"
4554 #endif
4555 fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4556 #else
4557 fprintf (file, " compiled by CC.\n");
4558 #endif
4561 /* Print an option value and return the adjusted position in the line.
4562 ??? We don't handle error returns from fprintf (disk full); presumably
4563 other code will catch a disk full though. */
4566 print_single_switch (file, pos, max, indent, sep, term, type, name)
4567 FILE *file;
4568 int pos, max;
4569 char *indent, *sep, *term, *type, *name;
4571 /* The ultrix fprintf returns 0 on success, so compute the result we want
4572 here since we need it for the following test. */
4573 int len = strlen (sep) + strlen (type) + strlen (name);
4575 if (pos != 0
4576 && pos + len > max)
4578 fprintf (file, "%s", term);
4579 pos = 0;
4581 if (pos == 0)
4583 fprintf (file, "%s", indent);
4584 pos = strlen (indent);
4586 fprintf (file, "%s%s%s", sep, type, name);
4587 pos += len;
4588 return pos;
4591 /* Print active target switches to FILE.
4592 POS is the current cursor position and MAX is the size of a "line".
4593 Each line begins with INDENT and ends with TERM.
4594 Each switch is separated from the next by SEP. */
4596 void
4597 print_switch_values (file, pos, max, indent, sep, term)
4598 FILE *file;
4599 int pos, max;
4600 char *indent, *sep, *term;
4602 size_t j;
4603 char **p;
4605 /* Print the options as passed. */
4607 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4608 "options passed: ", "");
4610 for (p = &save_argv[1]; *p != NULL; p++)
4611 if (**p == '-')
4613 /* Ignore these. */
4614 if (strcmp (*p, "-o") == 0)
4616 if (p[1] != NULL)
4617 p++;
4618 continue;
4620 if (strcmp (*p, "-quiet") == 0)
4621 continue;
4622 if (strcmp (*p, "-version") == 0)
4623 continue;
4624 if ((*p)[1] == 'd')
4625 continue;
4627 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4629 if (pos > 0)
4630 fprintf (file, "%s", term);
4632 /* Print the -f and -m options that have been enabled.
4633 We don't handle language specific options but printing argv
4634 should suffice. */
4636 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4637 "options enabled: ", "");
4639 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4640 if (*f_options[j].variable == f_options[j].on_value)
4641 pos = print_single_switch (file, pos, max, indent, sep, term,
4642 "-f", f_options[j].string);
4644 /* Print target specific options. */
4646 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4647 if (target_switches[j].name[0] != '\0'
4648 && target_switches[j].value > 0
4649 && ((target_switches[j].value & target_flags)
4650 == target_switches[j].value))
4652 pos = print_single_switch (file, pos, max, indent, sep, term,
4653 "-m", target_switches[j].name);
4656 #ifdef TARGET_OPTIONS
4657 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4658 if (*target_options[j].variable != NULL)
4660 char prefix[256];
4661 sprintf (prefix, "-m%s", target_options[j].prefix);
4662 pos = print_single_switch (file, pos, max, indent, sep, term,
4663 prefix, *target_options[j].variable);
4665 #endif
4667 fprintf (file, "%s", term);
4670 /* Record the beginning of a new source file, named FILENAME. */
4672 void
4673 debug_start_source_file (filename)
4674 register char *filename;
4676 #ifdef DBX_DEBUGGING_INFO
4677 if (write_symbols == DBX_DEBUG)
4678 dbxout_start_new_source_file (filename);
4679 #endif
4680 #ifdef DWARF_DEBUGGING_INFO
4681 if (debug_info_level == DINFO_LEVEL_VERBOSE
4682 && write_symbols == DWARF_DEBUG)
4683 dwarfout_start_new_source_file (filename);
4684 #endif /* DWARF_DEBUGGING_INFO */
4685 #ifdef DWARF2_DEBUGGING_INFO
4686 if (debug_info_level == DINFO_LEVEL_VERBOSE
4687 && write_symbols == DWARF2_DEBUG)
4688 dwarf2out_start_source_file (filename);
4689 #endif /* DWARF2_DEBUGGING_INFO */
4690 #ifdef SDB_DEBUGGING_INFO
4691 if (write_symbols == SDB_DEBUG)
4692 sdbout_start_new_source_file (filename);
4693 #endif
4696 /* Record the resumption of a source file. LINENO is the line number in
4697 the source file we are returning to. */
4699 void
4700 debug_end_source_file (lineno)
4701 register unsigned lineno;
4703 #ifdef DBX_DEBUGGING_INFO
4704 if (write_symbols == DBX_DEBUG)
4705 dbxout_resume_previous_source_file ();
4706 #endif
4707 #ifdef DWARF_DEBUGGING_INFO
4708 if (debug_info_level == DINFO_LEVEL_VERBOSE
4709 && write_symbols == DWARF_DEBUG)
4710 dwarfout_resume_previous_source_file (lineno);
4711 #endif /* DWARF_DEBUGGING_INFO */
4712 #ifdef DWARF2_DEBUGGING_INFO
4713 if (debug_info_level == DINFO_LEVEL_VERBOSE
4714 && write_symbols == DWARF2_DEBUG)
4715 dwarf2out_end_source_file ();
4716 #endif /* DWARF2_DEBUGGING_INFO */
4717 #ifdef SDB_DEBUGGING_INFO
4718 if (write_symbols == SDB_DEBUG)
4719 sdbout_resume_previous_source_file ();
4720 #endif
4723 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4724 the tail part of the directive line, i.e. the part which is past the
4725 initial whitespace, #, whitespace, directive-name, whitespace part. */
4727 void
4728 debug_define (lineno, buffer)
4729 register unsigned lineno;
4730 register char *buffer;
4732 #ifdef DWARF_DEBUGGING_INFO
4733 if (debug_info_level == DINFO_LEVEL_VERBOSE
4734 && write_symbols == DWARF_DEBUG)
4735 dwarfout_define (lineno, buffer);
4736 #endif /* DWARF_DEBUGGING_INFO */
4737 #ifdef DWARF2_DEBUGGING_INFO
4738 if (debug_info_level == DINFO_LEVEL_VERBOSE
4739 && write_symbols == DWARF2_DEBUG)
4740 dwarf2out_define (lineno, buffer);
4741 #endif /* DWARF2_DEBUGGING_INFO */
4744 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4745 the tail part of the directive line, i.e. the part which is past the
4746 initial whitespace, #, whitespace, directive-name, whitespace part. */
4748 void
4749 debug_undef (lineno, buffer)
4750 register unsigned lineno;
4751 register char *buffer;
4753 #ifdef DWARF_DEBUGGING_INFO
4754 if (debug_info_level == DINFO_LEVEL_VERBOSE
4755 && write_symbols == DWARF_DEBUG)
4756 dwarfout_undef (lineno, buffer);
4757 #endif /* DWARF_DEBUGGING_INFO */
4758 #ifdef DWARF2_DEBUGGING_INFO
4759 if (debug_info_level == DINFO_LEVEL_VERBOSE
4760 && write_symbols == DWARF2_DEBUG)
4761 dwarf2out_undef (lineno, buffer);
4762 #endif /* DWARF2_DEBUGGING_INFO */