Add movdi pattern to FR30 port.
[official-gcc.git] / gcc / toplev.c
blob1d89a7c686b53077aae1fb1b1accb53fd5171c08
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* This is the top level of cc1/c++.
23 It parses command args, opens files, invokes the various passes
24 in the proper order, and counts the time used by each.
25 Error messages and low-level interface to malloc also handled here. */
27 #include "config.h"
28 #undef FLOAT /* This is for hpux. They should change hpux. */
29 #undef FFS /* Some systems define this in param.h. */
30 #include "system.h"
31 #include <signal.h>
32 #include <setjmp.h>
34 #ifdef HAVE_SYS_RESOURCE_H
35 # include <sys/resource.h>
36 #endif
38 #ifdef HAVE_SYS_TIMES_H
39 # include <sys/times.h>
40 #endif
42 #include "input.h"
43 #include "tree.h"
44 #include "rtl.h"
45 #include "tm_p.h"
46 #include "flags.h"
47 #include "insn-attr.h"
48 #include "insn-codes.h"
49 #include "insn-config.h"
50 #include "recog.h"
51 #include "defaults.h"
52 #include "output.h"
53 #include "except.h"
54 #include "function.h"
55 #include "toplev.h"
56 #include "expr.h"
57 #include "basic-block.h"
58 #include "intl.h"
59 #include "ggc.h"
60 #include "graph.h"
61 #include "loop.h"
62 #include "regs.h"
63 #include "timevar.h"
65 #ifndef ACCUMULATE_OUTGOING_ARGS
66 #define ACCUMULATE_OUTGOING_ARGS 0
67 #endif
69 #ifdef DWARF_DEBUGGING_INFO
70 #include "dwarfout.h"
71 #endif
73 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
74 #include "dwarf2out.h"
75 #endif
77 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
78 #include "dbxout.h"
79 #endif
81 #ifdef SDB_DEBUGGING_INFO
82 #include "sdbout.h"
83 #endif
85 #ifdef XCOFF_DEBUGGING_INFO
86 #include "xcoffout.h"
87 #endif
89 #ifdef VMS
90 /* The extra parameters substantially improve the I/O performance. */
91 static FILE *
92 vms_fopen (fname, type)
93 char * fname;
94 char * type;
96 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
97 fixed arguments, which matches ANSI's specification but not VAXCRTL's
98 pre-ANSI implementation. This hack circumvents the mismatch problem. */
99 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
101 if (*type == 'w')
102 return (*vmslib_fopen) (fname, type, "mbc=32",
103 "deq=64", "fop=tef", "shr=nil");
104 else
105 return (*vmslib_fopen) (fname, type, "mbc=32");
107 #define fopen vms_fopen
108 #endif /* VMS */
110 #ifndef DEFAULT_GDB_EXTENSIONS
111 #define DEFAULT_GDB_EXTENSIONS 1
112 #endif
114 /* If more than one debugging type is supported, you must define
115 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
117 This is one long line cause VAXC can't handle a \-newline. */
118 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
119 #ifndef PREFERRED_DEBUGGING_TYPE
120 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
121 #endif /* no PREFERRED_DEBUGGING_TYPE */
122 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
123 so the following code needn't care. */
124 #ifdef DBX_DEBUGGING_INFO
125 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
126 #endif
127 #ifdef SDB_DEBUGGING_INFO
128 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
129 #endif
130 #ifdef DWARF_DEBUGGING_INFO
131 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
132 #endif
133 #ifdef DWARF2_DEBUGGING_INFO
134 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
135 #endif
136 #ifdef XCOFF_DEBUGGING_INFO
137 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
138 #endif
139 #endif /* More than one debugger format enabled. */
141 /* If still not defined, must have been because no debugging formats
142 are supported. */
143 #ifndef PREFERRED_DEBUGGING_TYPE
144 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
145 #endif
147 #ifdef NEED_DECLARATION_ENVIRON
148 extern char **environ;
149 #endif
151 /* Carry information from ASM_DECLARE_OBJECT_NAME
152 to ASM_FINISH_DECLARE_OBJECT. */
154 extern int size_directive_output;
155 extern tree last_assemble_variable_decl;
157 static void set_target_switch PARAMS ((const char *));
158 static const char *decl_name PARAMS ((tree, int));
160 static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
161 static void pipe_closed PARAMS ((int)) ATTRIBUTE_NORETURN;
162 #ifdef ASM_IDENTIFY_LANGUAGE
163 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
164 static void output_lang_identify PARAMS ((FILE *)) ATTRIBUTE_UNUSED;
165 #endif
166 static void compile_file PARAMS ((const char *));
167 static void display_help PARAMS ((void));
168 static void mark_file_stack PARAMS ((void *));
170 static void decode_d_option PARAMS ((const char *));
171 static int decode_f_option PARAMS ((const char *));
172 static int decode_W_option PARAMS ((const char *));
173 static int decode_g_option PARAMS ((const char *));
174 static unsigned int independent_decode_option PARAMS ((int, char **,
175 unsigned int));
177 static void print_version PARAMS ((FILE *, const char *));
178 static int print_single_switch PARAMS ((FILE *, int, int, const char *,
179 const char *, const char *,
180 const char *, const char *));
181 static void print_switch_values PARAMS ((FILE *, int, int, const char *,
182 const char *, const char *));
184 /* Length of line when printing switch values. */
185 #define MAX_LINE 75
187 /* Name of program invoked, sans directories. */
189 const char *progname;
191 /* Copy of arguments to main. */
192 int save_argc;
193 char **save_argv;
195 /* Name of current original source file (what was input to cpp).
196 This comes from each #-command in the actual input. */
198 const char *input_filename;
200 /* Name of top-level original source file (what was input to cpp).
201 This comes from the #-command at the beginning of the actual input.
202 If there isn't any there, then this is the cc1 input file name. */
204 const char *main_input_filename;
206 /* Current line number in real source file. */
208 int lineno;
210 /* Nonzero if it is unsafe to create any new pseudo registers. */
211 int no_new_pseudos;
213 /* Stack of currently pending input files. */
215 struct file_stack *input_file_stack;
217 /* Incremented on each change to input_file_stack. */
218 int input_file_stack_tick;
220 /* Name to use as base of names for dump output files. */
222 const char *dump_base_name;
224 /* Bit flags that specify the machine subtype we are compiling for.
225 Bits are tested using macros TARGET_... defined in the tm.h file
226 and set by `-m...' switches. Must be defined in rtlanal.c. */
228 extern int target_flags;
230 /* Describes a dump file. */
232 struct dump_file_info
234 /* The unique extension to apply, e.g. ".jump". */
235 const char * const extension;
237 /* The -d<c> character that enables this dump file. */
238 char const debug_switch;
240 /* True if there is a corresponding graph dump file. */
241 char const graph_dump_p;
243 /* True if the user selected this dump. */
244 char enabled;
246 /* True if the files have been initialized (ie truncated). */
247 char initialized;
250 /* Enumerate the extant dump files. */
252 enum dump_file_index
254 DFI_rtl,
255 DFI_sibling,
256 DFI_jump,
257 DFI_cse,
258 DFI_addressof,
259 DFI_ssa,
260 DFI_ussa,
261 DFI_gcse,
262 DFI_loop,
263 DFI_cse2,
264 DFI_bp,
265 DFI_flow,
266 DFI_combine,
267 DFI_ce,
268 DFI_regmove,
269 DFI_sched,
270 DFI_lreg,
271 DFI_greg,
272 DFI_flow2,
273 DFI_ce2,
274 DFI_peephole2,
275 DFI_rnreg,
276 DFI_sched2,
277 DFI_bbro,
278 DFI_jump2,
279 DFI_mach,
280 DFI_dbr,
281 DFI_stack,
282 DFI_MAX
285 /* Describes all the dump files. Should be kept in order of the
286 pass and in sync with dump_file_index above.
288 Remaining -d letters:
290 " h o q u "
291 " H K OPQ TUVWXYZ"
294 struct dump_file_info dump_file[DFI_MAX] =
296 { "rtl", 'r', 0, 0, 0 },
297 { "sibling", 'i', 0, 0, 0 },
298 { "jump", 'j', 0, 0, 0 },
299 { "cse", 's', 0, 0, 0 },
300 { "addressof", 'F', 0, 0, 0 },
301 { "ssa", 'e', 1, 0, 0 },
302 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
303 { "gcse", 'G', 1, 0, 0 },
304 { "loop", 'L', 1, 0, 0 },
305 { "cse2", 't', 1, 0, 0 },
306 { "bp", 'b', 1, 0, 0 },
307 { "flow", 'f', 1, 0, 0 },
308 { "combine", 'c', 1, 0, 0 },
309 { "ce", 'C', 1, 0, 0 },
310 { "regmove", 'N', 1, 0, 0 },
311 { "sched", 'S', 1, 0, 0 },
312 { "lreg", 'l', 1, 0, 0 },
313 { "greg", 'g', 1, 0, 0 },
314 { "flow2", 'w', 1, 0, 0 },
315 { "ce2", 'E', 1, 0, 0 },
316 { "peephole2", 'z', 1, 0, 0 },
317 { "rnreg", 'n', 1, 0, 0 },
318 { "sched2", 'R', 1, 0, 0 },
319 { "bbro", 'B', 1, 0, 0 },
320 { "jump2", 'J', 1, 0, 0 },
321 { "mach", 'M', 1, 0, 0 },
322 { "dbr", 'd', 0, 0, 0 },
323 { "stack", 'k', 1, 0, 0 },
326 static int open_dump_file PARAMS ((enum dump_file_index, tree));
327 static void close_dump_file PARAMS ((enum dump_file_index,
328 void (*) (FILE *, rtx), rtx));
330 /* Other flags saying which kinds of debugging dump have been requested. */
332 int rtl_dump_and_exit;
333 int flag_print_asm_name;
334 static int flag_print_mem;
335 static int version_flag;
336 static char * filename;
337 enum graph_dump_types graph_dump_format;
339 /* Name for output file of assembly code, specified with -o. */
341 char *asm_file_name;
343 /* Value of the -G xx switch, and whether it was passed or not. */
344 int g_switch_value;
345 int g_switch_set;
347 /* Type(s) of debugging information we are producing (if any).
348 See flags.h for the definitions of the different possible
349 types of debugging information. */
350 enum debug_info_type write_symbols = NO_DEBUG;
352 /* Level of debugging information we are producing. See flags.h
353 for the definitions of the different possible levels. */
354 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
356 /* Nonzero means use GNU-only extensions in the generated symbolic
357 debugging information. */
358 /* Currently, this only has an effect when write_symbols is set to
359 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
360 int use_gnu_debug_info_extensions = 0;
362 /* Nonzero means do optimizations. -O.
363 Particular numeric values stand for particular amounts of optimization;
364 thus, -O2 stores 2 here. However, the optimizations beyond the basic
365 ones are not controlled directly by this variable. Instead, they are
366 controlled by individual `flag_...' variables that are defaulted
367 based on this variable. */
369 int optimize = 0;
371 /* Nonzero means optimize for size. -Os.
372 The only valid values are zero and non-zero. When optimize_size is
373 non-zero, optimize defaults to 2, but certain individual code
374 bloating optimizations are disabled. */
376 int optimize_size = 0;
378 /* Number of error messages and warning messages so far. */
380 int errorcount = 0;
381 int warningcount = 0;
382 int sorrycount = 0;
384 /* The FUNCTION_DECL for the function currently being compiled,
385 or 0 if between functions. */
386 tree current_function_decl;
388 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
389 if none. */
390 tree current_function_func_begin_label;
392 /* Pointer to function to compute the name to use to print a declaration.
393 DECL is the declaration in question.
394 VERBOSITY determines what information will be printed:
395 0: DECL_NAME, demangled as necessary.
396 1: and scope information.
397 2: and any other information that might be interesting, such as function
398 parameter types in C++. */
400 const char *(*decl_printable_name) PARAMS ((tree, int));
402 /* Pointer to function to compute rtl for a language-specific tree code. */
404 typedef rtx (*lang_expand_expr_t)
405 PARAMS ((union tree_node *, rtx, enum machine_mode,
406 enum expand_modifier modifier));
408 lang_expand_expr_t lang_expand_expr = 0;
410 tree (*lang_expand_constant) PARAMS ((tree)) = 0;
412 /* Pointer to function to finish handling an incomplete decl at the
413 end of compilation. */
415 void (*incomplete_decl_finalize_hook) PARAMS ((tree)) = 0;
417 /* Nonzero if generating code to do profiling. */
419 int profile_flag = 0;
421 /* Nonzero if generating code to do profiling on a line-by-line basis. */
423 int profile_block_flag;
425 /* Nonzero if generating code to profile program flow graph arcs. */
427 int profile_arc_flag = 0;
429 /* Nonzero if generating info for gcov to calculate line test coverage. */
431 int flag_test_coverage = 0;
433 /* Nonzero indicates that branch taken probabilities should be calculated. */
435 int flag_branch_probabilities = 0;
437 /* Nonzero if basic blocks should be reordered. */
439 int flag_reorder_blocks = 0;
441 /* Nonzero if registers should be renamed */
443 int flag_rename_registers = 0;
445 /* Nonzero for -pedantic switch: warn about anything
446 that standard spec forbids. */
448 int pedantic = 0;
450 /* Temporarily suppress certain warnings.
451 This is set while reading code from a system header file. */
453 int in_system_header = 0;
455 /* Don't print functions as they are compiled and don't print
456 times taken by the various passes. -quiet. */
458 int quiet_flag = 0;
460 /* -f flags. */
462 /* Nonzero means `char' should be signed. */
464 int flag_signed_char;
466 /* Nonzero means give an enum type only as many bytes as it needs. */
468 int flag_short_enums;
470 /* Nonzero for -fcaller-saves: allocate values in regs that need to
471 be saved across function calls, if that produces overall better code.
472 Optional now, so people can test it. */
474 #ifdef DEFAULT_CALLER_SAVES
475 int flag_caller_saves = 1;
476 #else
477 int flag_caller_saves = 0;
478 #endif
480 /* Nonzero if structures and unions should be returned in memory.
482 This should only be defined if compatibility with another compiler or
483 with an ABI is needed, because it results in slower code. */
485 #ifndef DEFAULT_PCC_STRUCT_RETURN
486 #define DEFAULT_PCC_STRUCT_RETURN 1
487 #endif
489 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
491 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
493 /* Nonzero for -fforce-mem: load memory value into a register
494 before arithmetic on it. This makes better cse but slower compilation. */
496 int flag_force_mem = 0;
498 /* Nonzero for -fforce-addr: load memory address into a register before
499 reference to memory. This makes better cse but slower compilation. */
501 int flag_force_addr = 0;
503 /* Nonzero for -fdefer-pop: don't pop args after each function call;
504 instead save them up to pop many calls' args with one insns. */
506 int flag_defer_pop = 0;
508 /* Nonzero for -ffloat-store: don't allocate floats and doubles
509 in extended-precision registers. */
511 int flag_float_store = 0;
513 /* Nonzero for -fcse-follow-jumps:
514 have cse follow jumps to do a more extensive job. */
516 int flag_cse_follow_jumps;
518 /* Nonzero for -fcse-skip-blocks:
519 have cse follow a branch around a block. */
520 int flag_cse_skip_blocks;
522 /* Nonzero for -fexpensive-optimizations:
523 perform miscellaneous relatively-expensive optimizations. */
524 int flag_expensive_optimizations;
526 /* Nonzero for -fthread-jumps:
527 have jump optimize output of loop. */
529 int flag_thread_jumps;
531 /* Nonzero enables strength-reduction in loop.c. */
533 int flag_strength_reduce = 0;
535 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
536 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
537 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
538 unrolled. */
540 int flag_unroll_loops;
542 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
543 This is generally not a win. */
545 int flag_unroll_all_loops;
547 /* Nonzero forces all invariant computations in loops to be moved
548 outside the loop. */
550 int flag_move_all_movables = 0;
552 /* Nonzero forces all general induction variables in loops to be
553 strength reduced. */
555 int flag_reduce_all_givs = 0;
557 /* Nonzero to perform full register move optimization passes. This is the
558 default for -O2. */
560 int flag_regmove = 0;
562 /* Nonzero for -fwritable-strings:
563 store string constants in data segment and don't uniquize them. */
565 int flag_writable_strings = 0;
567 /* Nonzero means don't put addresses of constant functions in registers.
568 Used for compiling the Unix kernel, where strange substitutions are
569 done on the assembly output. */
571 int flag_no_function_cse = 0;
573 /* Nonzero for -fomit-frame-pointer:
574 don't make a frame pointer in simple functions that don't require one. */
576 int flag_omit_frame_pointer = 0;
578 /* Nonzero means place each function into its own section on those platforms
579 which support arbitrary section names and unlimited numbers of sections. */
581 int flag_function_sections = 0;
583 /* ... and similar for data. */
585 int flag_data_sections = 0;
587 /* Nonzero to inhibit use of define_optimization peephole opts. */
589 int flag_no_peephole = 0;
591 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
592 operations in the interest of optimization. For example it allows
593 GCC to assume arguments to sqrt are nonnegative numbers, allowing
594 faster code for sqrt to be generated. */
596 int flag_fast_math = 0;
598 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
600 int flag_optimize_sibling_calls = 0;
602 /* Nonzero means the front end generally wants `errno' maintained by math
603 operations, like built-in SQRT, unless overridden by flag_fast_math. */
605 int flag_errno_math = 1;
607 /* 0 means straightforward implementation of complex divide acceptable.
608 1 means wide ranges of inputs must work for complex divide.
609 2 means C9X-like requirements for complex divide (not yet implemented). */
611 int flag_complex_divide_method = 0;
613 /* Nonzero means all references through pointers are volatile. */
615 int flag_volatile;
617 /* Nonzero means treat all global and extern variables as volatile. */
619 int flag_volatile_global;
621 /* Nonzero means treat all static variables as volatile. */
623 int flag_volatile_static;
625 /* Nonzero means just do syntax checking; don't output anything. */
627 int flag_syntax_only = 0;
629 /* Nonzero means perform global cse. */
631 static int flag_gcse;
633 /* Nonzero means to use global dataflow analysis to eliminate
634 useless null pointer tests. */
636 static int flag_delete_null_pointer_checks;
638 /* Nonzero means to rerun cse after loop optimization. This increases
639 compilation time about 20% and picks up a few more common expressions. */
641 static int flag_rerun_cse_after_loop;
643 /* Nonzero means to run loop optimizations twice. */
645 int flag_rerun_loop_opt;
647 /* Nonzero for -finline-functions: ok to inline functions that look like
648 good inline candidates. */
650 int flag_inline_functions;
652 /* Nonzero for -fkeep-inline-functions: even if we make a function
653 go inline everywhere, keep its definition around for debugging
654 purposes. */
656 int flag_keep_inline_functions;
658 /* Nonzero means that functions will not be inlined. */
660 int flag_no_inline;
662 /* Nonzero means that we should emit static const variables
663 regardless of whether or not optimization is turned on. */
665 int flag_keep_static_consts = 1;
667 /* Nonzero means we should be saving declaration info into a .X file. */
669 int flag_gen_aux_info = 0;
671 /* Specified name of aux-info file. */
673 static char *aux_info_file_name;
675 /* Nonzero means make the text shared if supported. */
677 int flag_shared_data;
679 /* Nonzero means schedule into delayed branch slots if supported. */
681 int flag_delayed_branch;
683 /* Nonzero if we are compiling pure (sharable) code.
684 Value is 1 if we are doing reasonable (i.e. simple
685 offset into offset table) pic. Value is 2 if we can
686 only perform register offsets. */
688 int flag_pic;
690 /* Nonzero means generate extra code for exception handling and enable
691 exception handling. */
693 int flag_exceptions;
695 /* Nonzero means use the new model for exception handling. Replaces
696 -DNEW_EH_MODEL as a compile option. */
698 int flag_new_exceptions = 1;
700 /* Nonzero means generate frame unwind info table when supported */
702 int flag_unwind_tables = 0;
704 /* Nonzero means don't place uninitialized global data in common storage
705 by default. */
707 int flag_no_common;
709 /* Nonzero means pretend it is OK to examine bits of target floats,
710 even if that isn't true. The resulting code will have incorrect constants,
711 but the same series of instructions that the native compiler would make. */
713 int flag_pretend_float;
715 /* Nonzero means change certain warnings into errors.
716 Usually these are warnings about failure to conform to some standard. */
718 int flag_pedantic_errors = 0;
720 /* flag_schedule_insns means schedule insns within basic blocks (before
721 local_alloc).
722 flag_schedule_insns_after_reload means schedule insns after
723 global_alloc. */
725 int flag_schedule_insns = 0;
726 int flag_schedule_insns_after_reload = 0;
728 /* The following flags have effect only for scheduling before register
729 allocation:
731 flag_schedule_interblock means schedule insns accross basic blocks.
732 flag_schedule_speculative means allow speculative motion of non-load insns.
733 flag_schedule_speculative_load means allow speculative motion of some
734 load insns.
735 flag_schedule_speculative_load_dangerous allows speculative motion of more
736 load insns. */
738 int flag_schedule_interblock = 1;
739 int flag_schedule_speculative = 1;
740 int flag_schedule_speculative_load = 0;
741 int flag_schedule_speculative_load_dangerous = 0;
743 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
744 by a cheaper branch, on a count register. */
745 int flag_branch_on_count_reg;
747 /* -finhibit-size-directive inhibits output of .size for ELF.
748 This is used only for compiling crtstuff.c,
749 and it may be extended to other effects
750 needed for crtstuff.c on other systems. */
751 int flag_inhibit_size_directive = 0;
753 /* -fverbose-asm causes extra commentary information to be produced in
754 the generated assembly code (to make it more readable). This option
755 is generally only of use to those who actually need to read the
756 generated assembly code (perhaps while debugging the compiler itself).
757 -fno-verbose-asm, the default, causes the extra information
758 to be omitted and is useful when comparing two assembler files. */
760 int flag_verbose_asm = 0;
762 /* -dA causes debug commentary information to be produced in
763 the generated assembly code (to make it more readable). This option
764 is generally only of use to those who actually need to read the
765 generated assembly code (perhaps while debugging the compiler itself).
766 Currently, this switch is only used by dwarfout.c; however, it is intended
767 to be a catchall for printing debug information in the assembler file. */
769 int flag_debug_asm = 0;
771 /* -fgnu-linker specifies use of the GNU linker for initializations.
772 (Or, more generally, a linker that handles initializations.)
773 -fno-gnu-linker says that collect2 will be used. */
774 #ifdef USE_COLLECT2
775 int flag_gnu_linker = 0;
776 #else
777 int flag_gnu_linker = 1;
778 #endif
780 /* Enable SSA. */
781 int flag_ssa = 0;
783 /* Tag all structures with __attribute__(packed) */
784 int flag_pack_struct = 0;
786 /* Emit code to check for stack overflow; also may cause large objects
787 to be allocated dynamically. */
788 int flag_stack_check;
790 /* When non-NULL, indicates that whenever space is allocated on the
791 stack, the resulting stack pointer must not pass this
792 address---that is, for stacks that grow downward, the stack pointer
793 must always be greater than or equal to this address; for stacks
794 that grow upward, the stack pointer must be less than this address.
795 At present, the rtx may be either a REG or a SYMBOL_REF, although
796 the support provided depends on the backend. */
797 rtx stack_limit_rtx;
799 /* -fcheck-memory-usage causes extra code to be generated in order to check
800 memory accesses. This is used by a detector of bad memory accesses such
801 as Checker. */
802 int flag_check_memory_usage = 0;
804 /* -fprefix-function-name causes function name to be prefixed. This
805 can be used with -fcheck-memory-usage to isolate code compiled with
806 -fcheck-memory-usage. */
807 int flag_prefix_function_name = 0;
809 /* 0 if pointer arguments may alias each other. True in C.
810 1 if pointer arguments may not alias each other but may alias
811 global variables.
812 2 if pointer arguments may not alias each other and may not
813 alias global variables. True in Fortran.
814 This defaults to 0 for C. */
815 int flag_argument_noalias = 0;
817 /* Nonzero if we should do (language-dependent) alias analysis.
818 Typically, this analysis will assume that expressions of certain
819 types do not alias expressions of certain other types. Only used
820 if alias analysis (in general) is enabled. */
821 int flag_strict_aliasing = 0;
823 /* Instrument functions with calls at entry and exit, for profiling. */
824 int flag_instrument_function_entry_exit = 0;
826 /* Nonzero means ignore `#ident' directives. 0 means handle them.
827 On SVR4 targets, it also controls whether or not to emit a
828 string identifying the compiler. */
830 int flag_no_ident = 0;
832 /* This will perform a peephole pass before sched2. */
833 int flag_peephole2 = 0;
835 /* -fbounded-pointers causes gcc to compile pointers as composite
836 objects occupying three words: the pointer value, the base address
837 of the referent object, and the address immediately beyond the end
838 of the referent object. The base and extent allow us to perform
839 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
840 int flag_bounded_pointers = 0;
842 /* -fcheck-bounds causes gcc to generate array bounds checks.
843 For C, C++: defaults to value of flag_bounded_pointers.
844 For ObjC: defaults to off.
845 For Java: defaults to on.
846 For Fortran: defaults to off.
847 For CHILL: defaults to off. */
848 int flag_bounds_check = 0;
850 /* If one, renumber instruction UIDs to reduce the number of
851 unused UIDs if there are a lot of instructions. If greater than
852 one, unconditionally renumber instruction UIDs. */
853 int flag_renumber_insns = 1;
855 /* Values of the -falign-* flags: how much to align labels in code.
856 0 means `use default', 1 means `don't align'.
857 For each variable, there is an _log variant which is the power
858 of two not less than the variable, for .align output. */
860 int align_loops;
861 int align_loops_log;
862 int align_jumps;
863 int align_jumps_log;
864 int align_labels;
865 int align_labels_log;
866 int align_functions;
867 int align_functions_log;
869 /* Table of supported debugging formats. */
870 static struct
872 const char * arg;
873 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
874 constant expression, we use NO_DEBUG in its place. */
875 enum debug_info_type debug_type;
876 int use_extensions_p;
877 const char * description;
878 } *da,
879 debug_args[] =
881 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
882 "Generate default debug format output" },
883 { "gdb", NO_DEBUG, 1, "Generate default extended debug format output" },
884 #ifdef DBX_DEBUGGING_INFO
885 { "stabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
886 { "stabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
887 #endif
888 #ifdef DWARF_DEBUGGING_INFO
889 { "dwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
890 { "dwarf+", DWARF_DEBUG, 1,
891 "Generated extended DWARF-1 format debug output" },
892 #endif
893 #ifdef DWARF2_DEBUGGING_INFO
894 { "dwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
895 #endif
896 #ifdef XCOFF_DEBUGGING_INFO
897 { "xcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
898 { "xcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
899 #endif
900 #ifdef SDB_DEBUGGING_INFO
901 { "coff", SDB_DEBUG, 0, "Generate COFF format debug output" },
902 #endif
903 { 0, 0, 0, 0 }
906 typedef struct
908 const char * string;
909 int * variable;
910 int on_value;
911 const char * description;
913 lang_independent_options;
915 /* Add or remove a leading underscore from user symbols. */
916 int flag_leading_underscore = -1;
918 /* The user symbol prefix after having resolved same. */
919 const char *user_label_prefix;
921 /* A default for same. */
922 #ifndef USER_LABEL_PREFIX
923 #define USER_LABEL_PREFIX ""
924 #endif
926 /* Table of language-independent -f options.
927 STRING is the option name. VARIABLE is the address of the variable.
928 ON_VALUE is the value to store in VARIABLE
929 if `-fSTRING' is seen as an option.
930 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
932 lang_independent_options f_options[] =
934 {"float-store", &flag_float_store, 1,
935 "Do not store floats in registers" },
936 {"volatile", &flag_volatile, 1,
937 "Consider all mem refs through pointers as volatile"},
938 {"volatile-global", &flag_volatile_global, 1,
939 "Consider all mem refs to global data to be volatile" },
940 {"volatile-static", &flag_volatile_static, 1,
941 "Consider all mem refs to static data to be volatile" },
942 {"defer-pop", &flag_defer_pop, 1,
943 "Defer popping functions args from stack until later" },
944 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
945 "When possible do not generate stack frames"},
946 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
947 "Optimize sibling and tail recursive calls" },
948 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
949 "When running CSE, follow jumps to their targets" },
950 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
951 "When running CSE, follow conditional jumps" },
952 {"expensive-optimizations", &flag_expensive_optimizations, 1,
953 "Perform a number of minor, expensive optimisations" },
954 {"thread-jumps", &flag_thread_jumps, 1,
955 "Perform jump threading optimisations"},
956 {"strength-reduce", &flag_strength_reduce, 1,
957 "Perform strength reduction optimisations" },
958 {"unroll-loops", &flag_unroll_loops, 1,
959 "Perform loop unrolling when iteration count is known" },
960 {"unroll-all-loops", &flag_unroll_all_loops, 1,
961 "Perform loop unrolling for all loops" },
962 {"move-all-movables", &flag_move_all_movables, 1,
963 "Force all loop invariant computations out of loops" },
964 {"reduce-all-givs", &flag_reduce_all_givs, 1,
965 "Strength reduce all loop general induction variables" },
966 {"writable-strings", &flag_writable_strings, 1,
967 "Store strings in writable data section" },
968 {"peephole", &flag_no_peephole, 0,
969 "Enable machine specific peephole optimisations" },
970 {"force-mem", &flag_force_mem, 1,
971 "Copy memory operands into registers before using" },
972 {"force-addr", &flag_force_addr, 1,
973 "Copy memory address constants into regs before using" },
974 {"function-cse", &flag_no_function_cse, 0,
975 "Allow function addresses to be held in registers" },
976 {"inline-functions", &flag_inline_functions, 1,
977 "Integrate simple functions into their callers" },
978 {"keep-inline-functions", &flag_keep_inline_functions, 1,
979 "Generate code for funcs even if they are fully inlined" },
980 {"inline", &flag_no_inline, 0,
981 "Pay attention to the 'inline' keyword"},
982 {"keep-static-consts", &flag_keep_static_consts, 1,
983 "Emit static const variables even if they are not used" },
984 {"syntax-only", &flag_syntax_only, 1,
985 "Check for syntax errors, then stop" },
986 {"shared-data", &flag_shared_data, 1,
987 "Mark data as shared rather than private" },
988 {"caller-saves", &flag_caller_saves, 1,
989 "Enable saving registers around function calls" },
990 {"pcc-struct-return", &flag_pcc_struct_return, 1,
991 "Return 'short' aggregates in memory, not registers" },
992 {"reg-struct-return", &flag_pcc_struct_return, 0,
993 "Return 'short' aggregates in registers" },
994 {"delayed-branch", &flag_delayed_branch, 1,
995 "Attempt to fill delay slots of branch instructions" },
996 {"gcse", &flag_gcse, 1,
997 "Perform the global common subexpression elimination" },
998 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
999 "Run CSE pass after loop optimisations"},
1000 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1001 "Run the loop optimiser twice"},
1002 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1003 "Delete useless null pointer checks" },
1004 {"pretend-float", &flag_pretend_float, 1,
1005 "Pretend that host and target use the same FP format"},
1006 {"schedule-insns", &flag_schedule_insns, 1,
1007 "Reschedule instructions to avoid pipeline stalls"},
1008 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1009 "Run two passes of the instruction scheduler"},
1010 {"sched-interblock",&flag_schedule_interblock, 1,
1011 "Enable scheduling across basic blocks" },
1012 {"sched-spec",&flag_schedule_speculative, 1,
1013 "Allow speculative motion of non-loads" },
1014 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1015 "Allow speculative motion of some loads" },
1016 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1017 "Allow speculative motion of more loads" },
1018 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1019 "Replace add,compare,branch with branch on count reg"},
1020 {"pic", &flag_pic, 1,
1021 "Generate position independent code, if possible"},
1022 {"PIC", &flag_pic, 2, ""},
1023 {"exceptions", &flag_exceptions, 1,
1024 "Enable exception handling" },
1025 {"new-exceptions", &flag_new_exceptions, 1,
1026 "Use the new model for exception handling" },
1027 {"unwind-tables", &flag_unwind_tables, 1,
1028 "Just generate unwind tables for exception handling" },
1029 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
1030 "Use setjmp/longjmp to handle exceptions" },
1031 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
1032 "Support asynchronous exceptions" },
1033 {"profile-arcs", &profile_arc_flag, 1,
1034 "Insert arc based program profiling code" },
1035 {"test-coverage", &flag_test_coverage, 1,
1036 "Create data files needed by gcov" },
1037 {"branch-probabilities", &flag_branch_probabilities, 1,
1038 "Use profiling information for branch probabilities" },
1039 {"reorder-blocks", &flag_reorder_blocks, 1,
1040 "Reorder basic blocks to improve code placement" },
1041 {"rename-registers", &flag_rename_registers, 1,
1042 "Do the register renaming optimization pass"},
1043 {"fast-math", &flag_fast_math, 1,
1044 "Improve FP speed by violating ANSI & IEEE rules" },
1045 {"common", &flag_no_common, 0,
1046 "Do not put unitialised globals in the common section" },
1047 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1048 "Do not generate .size directives" },
1049 {"function-sections", &flag_function_sections, 1,
1050 "place each function into its own section" },
1051 {"data-sections", &flag_data_sections, 1,
1052 "place data items into their own section" },
1053 {"verbose-asm", &flag_verbose_asm, 1,
1054 "Add extra commentry to assembler output"},
1055 {"gnu-linker", &flag_gnu_linker, 1,
1056 "Output GNU ld formatted global initialisers"},
1057 {"regmove", &flag_regmove, 1,
1058 "Enables a register move optimisation"},
1059 {"optimize-register-move", &flag_regmove, 1,
1060 "Do the full regmove optimization pass"},
1061 {"pack-struct", &flag_pack_struct, 1,
1062 "Pack structure members together without holes" },
1063 {"stack-check", &flag_stack_check, 1,
1064 "Insert stack checking code into the program" },
1065 {"argument-alias", &flag_argument_noalias, 0,
1066 "Specify that arguments may alias each other & globals"},
1067 {"argument-noalias", &flag_argument_noalias, 1,
1068 "Assume arguments may alias globals but not each other"},
1069 {"argument-noalias-global", &flag_argument_noalias, 2,
1070 "Assume arguments do not alias each other or globals" },
1071 {"strict-aliasing", &flag_strict_aliasing, 1,
1072 "Assume strict aliasing rules apply" },
1073 {"align-loops", &align_loops, 0,
1074 "Align the start of loops" },
1075 {"align-jumps", &align_jumps, 0,
1076 "Align labels which are only reached by jumping" },
1077 {"align-labels", &align_labels, 0,
1078 "Align all labels" },
1079 {"align-functions", &align_functions, 0,
1080 "Align the start of functions" },
1081 {"check-memory-usage", &flag_check_memory_usage, 1,
1082 "Generate code to check every memory access" },
1083 {"prefix-function-name", &flag_prefix_function_name, 1,
1084 "Add a prefix to all function names" },
1085 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1086 "Suppress output of instruction numbers and line number notes in debugging dumps"},
1087 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1088 "Instrument function entry/exit with profiling calls"},
1089 {"ssa", &flag_ssa, 1,
1090 "Enable SSA optimizations" },
1091 {"leading-underscore", &flag_leading_underscore, 1,
1092 "External symbols have a leading underscore" },
1093 {"ident", &flag_no_ident, 0,
1094 "Process #ident directives"},
1095 { "peephole2", &flag_peephole2, 1,
1096 "Enables an rtl peephole pass run before sched2" },
1097 {"math-errno", &flag_errno_math, 1,
1098 "Set errno after built-in math functions"},
1099 {"bounded-pointers", &flag_bounded_pointers, 1,
1100 "Compile pointers as triples: value, base & end" },
1101 {"bounds-check", &flag_bounds_check, 1,
1102 "Generate code to check bounds before dereferencing pointers and arrays" }
1105 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
1107 /* Table of language-specific options. */
1109 static struct lang_opt
1111 const char * option;
1112 const char * description;
1114 documented_lang_options[] =
1116 /* In order not to overload the --help output, the convention
1117 used here is to only describe those options which are not
1118 enabled by default. */
1120 { "-ansi", "Compile just for ANSI C" },
1121 { "-fallow-single-precision",
1122 "Do not promote floats to double if using -traditional" },
1123 { "-std= ", "Determine language standard"},
1125 { "-fsigned-bitfields", "" },
1126 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1127 { "-fno-signed-bitfields", "" },
1128 { "-fno-unsigned-bitfields","" },
1129 { "-fsigned-char", "Make 'char' be signed by default"},
1130 { "-funsigned-char", "Make 'char' be unsigned by default"},
1131 { "-fno-signed-char", "" },
1132 { "-fno-unsigned-char", "" },
1134 { "-ftraditional", "" },
1135 { "-traditional", "Attempt to support traditional K&R style C"},
1136 { "-fnotraditional", "" },
1137 { "-fno-traditional", "" },
1139 { "-fasm", "" },
1140 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1141 { "-fbuiltin", "" },
1142 { "-fno-builtin", "Do not recognise any built in functions" },
1143 { "-fhosted", "Assume normal C execution environment" },
1144 { "-fno-hosted", "" },
1145 { "-ffreestanding",
1146 "Assume that standard libraries & main might not exist" },
1147 { "-fno-freestanding", "" },
1148 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1149 { "-fno-cond-mismatch", "" },
1150 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1151 { "-fno-dollars-in-identifiers", "" },
1152 { "-fpreprocessed", "" },
1153 { "-fno-preprocessed", "" },
1154 { "-fshort-double", "Use the same size for double as for float" },
1155 { "-fno-short-double", "" },
1156 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1157 { "-fno-short-enums", "" },
1158 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1159 { "-fno-short-wchar", "" },
1161 { "-Wall", "Enable most warning messages" },
1162 { "-Wbad-function-cast",
1163 "Warn about casting functions to incompatible types" },
1164 { "-Wno-bad-function-cast", "" },
1165 { "-Wmissing-noreturn",
1166 "Warn about functions which might be candidates for attribute noreturn" },
1167 { "-Wno-missing-noreturn", "" },
1168 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1169 { "-Wno-cast-qual", "" },
1170 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1171 { "-Wno-char-subscripts", "" },
1172 { "-Wcomment", "Warn if nested comments are detected" },
1173 { "-Wno-comment", "" },
1174 { "-Wcomments", "Warn if nested comments are detected" },
1175 { "-Wno-comments", "" },
1176 { "-Wconversion", "Warn about possibly confusing type conversions" },
1177 { "-Wno-conversion", "" },
1178 { "-Wformat", "Warn about printf format anomalies" },
1179 { "-Wno-format", "" },
1180 { "-Wimplicit-function-declaration",
1181 "Warn about implicit function declarations" },
1182 { "-Wno-implicit-function-declaration", "" },
1183 { "-Werror-implicit-function-declaration", "" },
1184 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1185 { "-Wno-implicit-int", "" },
1186 { "-Wimplicit", "" },
1187 { "-Wno-implicit", "" },
1188 { "-Wimport", "Warn about the use of the #import directive" },
1189 { "-Wno-import", "" },
1190 { "-Wlong-long","" },
1191 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1192 { "-Wmain", "Warn about suspicious declarations of main" },
1193 { "-Wno-main", "" },
1194 { "-Wmissing-braces",
1195 "Warn about possibly missing braces around initialisers" },
1196 { "-Wno-missing-braces", "" },
1197 { "-Wmissing-declarations",
1198 "Warn about global funcs without previous declarations"},
1199 { "-Wno-missing-declarations", "" },
1200 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1201 { "-Wno-missing-prototypes", "" },
1202 { "-Wmultichar", "Warn about use of multicharacter literals"},
1203 { "-Wno-multichar", "" },
1204 { "-Wnested-externs", "Warn about externs not at file scope level" },
1205 { "-Wno-nested-externs", "" },
1206 { "-Wparentheses", "Warn about possible missing parentheses" },
1207 { "-Wno-parentheses", "" },
1208 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1209 { "-Wno-pointer-arith", "" },
1210 { "-Wredundant-decls",
1211 "Warn about multiple declarations of the same object" },
1212 { "-Wno-redundant-decls", "" },
1213 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1214 { "-Wno-sign-compare", "" },
1215 { "-Wfloat-equal", "Warn about testing equality of floating point numbers" },
1216 { "-Wno-float-equal", "" },
1217 { "-Wunknown-pragmas", "Warn about unrecognized pragmas" },
1218 { "-Wno-unknown-pragmas", "" },
1219 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1220 { "-Wno-strict-prototypes", "" },
1221 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1222 { "-Wno-traditional", "" },
1223 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1224 { "-Wno-trigraphs", "" },
1225 { "-Wundef", "" },
1226 { "-Wno-undef", "" },
1227 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1228 { "-Wno-write-strings", "" },
1230 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1232 /* These are for Objective C. */
1233 DEFINE_LANG_NAME ("Objective C")
1235 { "-lang-objc", "" },
1236 { "-gen-decls", "Dump decls to a .decl file" },
1237 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1238 { "-fno-gnu-runtime", "" },
1239 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1240 { "-fno-next-runtime", "" },
1241 { "-Wselector", "Warn if a selector has multiple methods" },
1242 { "-Wno-selector", "" },
1243 { "-Wprotocol", "" },
1244 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1245 { "-print-objc-runtime-info",
1246 "Generate C header of platform specific features" },
1248 #include "options.h"
1252 /* Here is a table, controlled by the tm.h file, listing each -m switch
1253 and which bits in `target_switches' it should set or clear.
1254 If VALUE is positive, it is bits to set.
1255 If VALUE is negative, -VALUE is bits to clear.
1256 (The sign bit is not used so there is no confusion.) */
1258 struct
1260 const char * name;
1261 int value;
1262 const char * description;
1264 target_switches [] = TARGET_SWITCHES;
1266 /* This table is similar, but allows the switch to have a value. */
1268 #ifdef TARGET_OPTIONS
1269 struct
1271 const char * prefix;
1272 const char ** variable;
1273 const char * description;
1275 target_options [] = TARGET_OPTIONS;
1276 #endif
1278 /* Options controlling warnings */
1280 /* Don't print warning messages. -w. */
1282 int inhibit_warnings = 0;
1284 /* Print various extra warnings. -W. */
1286 int extra_warnings = 0;
1288 /* Treat warnings as errors. -Werror. */
1290 int warnings_are_errors = 0;
1292 /* Nonzero to warn about unused local variables. */
1294 int warn_unused;
1296 /* Nonzero to warn about code which is never reached. */
1298 int warn_notreached;
1300 /* Nonzero to warn about variables used before they are initialized. */
1302 int warn_uninitialized;
1304 /* Nonzero means warn about all declarations which shadow others. */
1306 int warn_shadow;
1308 /* Warn if a switch on an enum fails to have a case for every enum value. */
1310 int warn_switch;
1312 /* Nonzero means warn about function definitions that default the return type
1313 or that use a null return and have a return-type other than void. */
1315 int warn_return_type;
1317 /* Nonzero means warn about pointer casts that increase the required
1318 alignment of the target type (and might therefore lead to a crash
1319 due to a misaligned access). */
1321 int warn_cast_align;
1323 /* Nonzero means warn about any identifiers that match in the first N
1324 characters. The value N is in `id_clash_len'. */
1326 int warn_id_clash;
1327 int id_clash_len;
1329 /* Nonzero means warn about any objects definitions whose size is larger
1330 than N bytes. Also want about function definitions whose returned
1331 values are larger than N bytes. The value N is in `larger_than_size'. */
1333 int warn_larger_than;
1334 HOST_WIDE_INT larger_than_size;
1336 /* Nonzero means warn if inline function is too large. */
1338 int warn_inline;
1340 /* Warn if a function returns an aggregate,
1341 since there are often incompatible calling conventions for doing this. */
1343 int warn_aggregate_return;
1345 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1347 int warn_packed;
1349 /* Warn when gcc pads a structure to an alignment boundary. */
1351 int warn_padded;
1353 /* Likewise for -W. */
1355 lang_independent_options W_options[] =
1357 {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1358 {"error", &warnings_are_errors, 1, ""},
1359 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1360 {"switch", &warn_switch, 1,
1361 "Warn about enumerated switches missing a specific case" },
1362 {"aggregate-return", &warn_aggregate_return, 1,
1363 "Warn about returning structures, unions or arrays" },
1364 {"cast-align", &warn_cast_align, 1,
1365 "Warn about pointer casts which increase alignment" },
1366 {"unreachable-code", &warn_notreached, 1,
1367 "Warn about code that will never be executed" },
1368 {"uninitialized", &warn_uninitialized, 1,
1369 "Warn about unitialized automatic variables"},
1370 {"inline", &warn_inline, 1,
1371 "Warn when an inlined function cannot be inlined"},
1372 {"packed", &warn_packed, 1,
1373 "Warn when the packed attribute has no effect on struct layout"},
1374 {"padded", &warn_padded, 1,
1375 "Warn when padding is required to align struct members"}
1378 /* Output files for assembler code (real compiler output)
1379 and debugging dumps. */
1381 FILE *asm_out_file;
1382 FILE *aux_info_file;
1383 FILE *rtl_dump_file = NULL;
1385 /* Decode the string P as an integral parameter.
1386 If the string is indeed an integer return its numeric value else
1387 issue an Invalid Option error for the option PNAME and return DEFVAL.
1388 If PNAME is zero just return DEFVAL, do not call error. */
1391 read_integral_parameter (p, pname, defval)
1392 const char *p;
1393 const char *pname;
1394 const int defval;
1396 const char *endp = p;
1398 while (*endp)
1400 if (*endp >= '0' && *endp <= '9')
1401 endp++;
1402 else
1403 break;
1406 if (*endp != 0)
1408 if (pname != 0)
1409 error ("Invalid option `%s'", pname);
1410 return defval;
1413 return atoi (p);
1417 /* This is the default decl_printable_name function. */
1419 static const char *
1420 decl_name (decl, verbosity)
1421 tree decl;
1422 int verbosity ATTRIBUTE_UNUSED;
1424 return IDENTIFIER_POINTER (DECL_NAME (decl));
1427 /* Mark P for GC. Also mark main_input_filename and input_filename. */
1429 static void
1430 mark_file_stack (p)
1431 void *p;
1433 struct file_stack *stack = *(struct file_stack **)p;
1435 /* We're only called for input_file_stack, so we can mark the current
1436 input_filename here as well. */
1437 ggc_mark_string (main_input_filename);
1438 ggc_mark_string (input_filename);
1440 while (stack)
1442 ggc_mark_string (stack->name);
1443 stack = stack->next;
1448 /* This calls abort and is used to avoid problems when abort if a macro.
1449 It is used when we need to pass the address of abort. */
1451 void
1452 do_abort ()
1454 abort ();
1457 /* When `malloc.c' is compiled with `rcheck' defined,
1458 it calls this function to report clobberage. */
1460 void
1461 botch (s)
1462 const char * s ATTRIBUTE_UNUSED;
1464 abort ();
1467 /* Return the logarithm of X, base 2, considering X unsigned,
1468 if X is a power of 2. Otherwise, returns -1.
1470 This should be used via the `exact_log2' macro. */
1473 exact_log2_wide (x)
1474 register unsigned HOST_WIDE_INT x;
1476 register int log = 0;
1477 /* Test for 0 or a power of 2. */
1478 if (x == 0 || x != (x & -x))
1479 return -1;
1480 while ((x >>= 1) != 0)
1481 log++;
1482 return log;
1485 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1486 If X is 0, return -1.
1488 This should be used via the floor_log2 macro. */
1491 floor_log2_wide (x)
1492 register unsigned HOST_WIDE_INT x;
1494 register int log = -1;
1495 while (x != 0)
1496 log++,
1497 x >>= 1;
1498 return log;
1501 static int float_handler_set;
1502 int float_handled;
1503 jmp_buf float_handler;
1505 /* Signals actually come here. */
1507 static void
1508 float_signal (signo)
1509 /* If this is missing, some compilers complain. */
1510 int signo ATTRIBUTE_UNUSED;
1512 if (float_handled == 0)
1513 abort ();
1514 #if defined (USG) || defined (hpux)
1515 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1516 #endif
1517 float_handled = 0;
1518 signal (SIGFPE, float_signal);
1519 longjmp (float_handler, 1);
1522 /* Specify where to longjmp to when a floating arithmetic error happens.
1523 If HANDLER is 0, it means don't handle the errors any more. */
1525 void
1526 set_float_handler (handler)
1527 jmp_buf handler;
1529 float_handled = (handler != 0);
1530 if (handler)
1531 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1533 if (float_handled && ! float_handler_set)
1535 signal (SIGFPE, float_signal);
1536 float_handler_set = 1;
1540 /* This is a wrapper function for code which might elicit an
1541 arithmetic exception. That code should be passed in as a function
1542 pointer FN, and one argument DATA. DATA is usually a struct which
1543 contains the real input and output for function FN. This function
1544 returns 0 (failure) if longjmp was called (i.e. an exception
1545 occured.) It returns 1 (success) otherwise. */
1548 do_float_handler (fn, data)
1549 void (*fn) PARAMS ((PTR));
1550 PTR data;
1552 jmp_buf buf;
1554 if (setjmp (buf))
1556 /* We got here via longjmp() caused by an exception in function fn() */
1557 set_float_handler (NULL);
1558 return 0;
1561 set_float_handler (buf);
1562 (*fn)(data);
1563 set_float_handler (NULL);
1564 return 1;
1567 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1568 error happens, pushing the previous specification into OLD_HANDLER.
1569 Return an indication of whether there was a previous handler in effect. */
1572 push_float_handler (handler, old_handler)
1573 jmp_buf handler, old_handler;
1575 int was_handled = float_handled;
1577 float_handled = 1;
1578 if (was_handled)
1579 memcpy ((char *) old_handler, (char *) float_handler,
1580 sizeof (float_handler));
1582 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
1583 return was_handled;
1586 /* Restore the previous specification of whether and where to longjmp to
1587 when a floating arithmetic error happens. */
1589 void
1590 pop_float_handler (handled, handler)
1591 int handled;
1592 jmp_buf handler;
1594 float_handled = handled;
1595 if (handled)
1596 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1599 /* Handler for SIGPIPE. */
1601 static void
1602 pipe_closed (signo)
1603 /* If this is missing, some compilers complain. */
1604 int signo ATTRIBUTE_UNUSED;
1606 fatal ("output pipe has been closed");
1609 /* Strip off a legitimate source ending from the input string NAME of
1610 length LEN. Rather than having to know the names used by all of
1611 our front ends, we strip off an ending of a period followed by
1612 up to five characters. (Java uses ".class".) */
1614 void
1615 strip_off_ending (name, len)
1616 char *name;
1617 int len;
1619 int i;
1620 for (i = 2; i < 6 && len > i; i++)
1622 if (name[len - i] == '.')
1624 name[len - i] = '\0';
1625 break;
1630 /* Output a quoted string. */
1632 void
1633 output_quoted_string (asm_file, string)
1634 FILE *asm_file;
1635 const char *string;
1637 #ifdef OUTPUT_QUOTED_STRING
1638 OUTPUT_QUOTED_STRING (asm_file, string);
1639 #else
1640 char c;
1642 putc ('\"', asm_file);
1643 while ((c = *string++) != 0)
1645 if (c == '\"' || c == '\\')
1646 putc ('\\', asm_file);
1647 putc (c, asm_file);
1649 putc ('\"', asm_file);
1650 #endif
1653 /* Output a file name in the form wanted by System V. */
1655 void
1656 output_file_directive (asm_file, input_name)
1657 FILE *asm_file;
1658 const char *input_name;
1660 int len = strlen (input_name);
1661 const char *na = input_name + len;
1663 /* NA gets INPUT_NAME sans directory names. */
1664 while (na > input_name)
1666 if (IS_DIR_SEPARATOR (na[-1]))
1667 break;
1668 na--;
1671 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1672 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1673 #else
1674 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1675 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1676 #else
1677 fprintf (asm_file, "\t.file\t");
1678 output_quoted_string (asm_file, na);
1679 fputc ('\n', asm_file);
1680 #endif
1681 #endif
1684 #ifdef ASM_IDENTIFY_LANGUAGE
1685 /* Routine to build language identifier for object file. */
1686 static void
1687 output_lang_identify (asm_out_file)
1688 FILE *asm_out_file;
1690 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1691 char *s = (char *) alloca (len);
1692 sprintf (s, "__gnu_compiled_%s", lang_identify ());
1693 ASM_OUTPUT_LABEL (asm_out_file, s);
1695 #endif
1697 /* Routine to open a dump file. Return true if the dump file is enabled. */
1699 static int
1700 open_dump_file (index, decl)
1701 enum dump_file_index index;
1702 tree decl;
1704 char *dump_name;
1705 const char *open_arg;
1706 char seq[16];
1708 if (! dump_file[index].enabled)
1709 return 0;
1711 timevar_push (TV_DUMP);
1712 if (rtl_dump_file != NULL)
1713 fclose (rtl_dump_file);
1715 sprintf (seq, ".%02d.", index);
1717 if (! dump_file[index].initialized)
1719 /* If we've not initialized the files, do so now. */
1720 if (graph_dump_format != no_graph
1721 && dump_file[index].graph_dump_p)
1723 dump_name = concat (seq, dump_file[index].extension, NULL);
1724 clean_graph_dump_file (dump_base_name, dump_name);
1725 free (dump_name);
1727 dump_file[index].initialized = 1;
1728 open_arg = "w";
1730 else
1731 open_arg = "a";
1733 dump_name = concat (dump_base_name, seq,
1734 dump_file[index].extension, NULL);
1736 rtl_dump_file = fopen (dump_name, open_arg);
1737 if (rtl_dump_file == NULL)
1738 pfatal_with_name (dump_name);
1740 free (dump_name);
1742 if (decl)
1743 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1744 decl_printable_name (decl, 2));
1746 timevar_pop (TV_DUMP);
1747 return 1;
1750 /* Routine to close a dump file. */
1752 static void
1753 close_dump_file (index, func, insns)
1754 enum dump_file_index index;
1755 void (*func) PARAMS ((FILE *, rtx));
1756 rtx insns;
1758 if (! rtl_dump_file)
1759 return;
1761 timevar_push (TV_DUMP);
1762 if (insns
1763 && graph_dump_format != no_graph
1764 && dump_file[index].graph_dump_p)
1766 char seq[16];
1767 char *suffix;
1769 sprintf (seq, ".%02d.", index);
1770 suffix = concat (seq, dump_file[index].extension, NULL);
1771 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1772 free (suffix);
1775 if (func && insns)
1776 func (rtl_dump_file, insns);
1778 fflush (rtl_dump_file);
1779 fclose (rtl_dump_file);
1781 rtl_dump_file = NULL;
1782 timevar_pop (TV_DUMP);
1785 /* Do any final processing required for the declarations in VEC, of
1786 which there are LEN. We write out inline functions and variables
1787 that have been deferred until this point, but which are required.
1788 Returns non-zero if anything was put out. */
1790 wrapup_global_declarations (vec, len)
1791 tree *vec;
1792 int len;
1794 tree decl;
1795 int i;
1796 int reconsider;
1797 int output_something = 0;
1799 for (i = 0; i < len; i++)
1801 decl = vec[i];
1803 /* We're not deferring this any longer. */
1804 DECL_DEFER_OUTPUT (decl) = 0;
1806 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
1807 && incomplete_decl_finalize_hook != 0)
1808 (*incomplete_decl_finalize_hook) (decl);
1811 /* Now emit any global variables or functions that we have been
1812 putting off. We need to loop in case one of the things emitted
1813 here references another one which comes earlier in the list. */
1816 reconsider = 0;
1817 for (i = 0; i < len; i++)
1819 decl = vec[i];
1821 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1822 continue;
1824 /* Don't write out static consts, unless we still need them.
1826 We also keep static consts if not optimizing (for debugging),
1827 unless the user specified -fno-keep-static-consts.
1828 ??? They might be better written into the debug information.
1829 This is possible when using DWARF.
1831 A language processor that wants static constants to be always
1832 written out (even if it is not used) is responsible for
1833 calling rest_of_decl_compilation itself. E.g. the C front-end
1834 calls rest_of_decl_compilation from finish_decl.
1835 One motivation for this is that is conventional in some
1836 environments to write things like:
1837 static const char rcsid[] = "... version string ...";
1838 intending to force the string to be in the executable.
1840 A language processor that would prefer to have unneeded
1841 static constants "optimized away" would just defer writing
1842 them out until here. E.g. C++ does this, because static
1843 constants are often defined in header files.
1845 ??? A tempting alternative (for both C and C++) would be
1846 to force a constant to be written if and only if it is
1847 defined in a main file, as opposed to an include file. */
1849 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1850 && (! TREE_READONLY (decl)
1851 || TREE_PUBLIC (decl)
1852 || (!optimize && flag_keep_static_consts)
1853 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1855 reconsider = 1;
1856 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1859 if (TREE_CODE (decl) == FUNCTION_DECL
1860 && DECL_INITIAL (decl) != 0
1861 && DECL_SAVED_INSNS (decl) != 0
1862 && (flag_keep_inline_functions
1863 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1864 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1866 reconsider = 1;
1867 temporary_allocation ();
1868 output_inline_function (decl);
1869 permanent_allocation (1);
1873 if (reconsider)
1874 output_something = 1;
1876 while (reconsider);
1878 return output_something;
1881 /* Issue appropriate warnings for the global declarations in VEC (of
1882 which there are LEN). Output debugging information for them. */
1883 void
1884 check_global_declarations (vec, len)
1885 tree *vec;
1886 int len;
1888 tree decl;
1889 int i;
1891 for (i = 0; i < len; i++)
1893 decl = vec[i];
1895 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1896 && ! TREE_ASM_WRITTEN (decl))
1897 /* Cancel the RTL for this decl so that, if debugging info
1898 output for global variables is still to come,
1899 this one will be omitted. */
1900 DECL_RTL (decl) = NULL;
1902 /* Warn about any function
1903 declared static but not defined.
1904 We don't warn about variables,
1905 because many programs have static variables
1906 that exist only to get some text into the object file. */
1907 if (TREE_CODE (decl) == FUNCTION_DECL
1908 && (warn_unused
1909 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1910 && DECL_INITIAL (decl) == 0
1911 && DECL_EXTERNAL (decl)
1912 && ! DECL_ARTIFICIAL (decl)
1913 && ! TREE_PUBLIC (decl))
1915 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1916 pedwarn_with_decl (decl,
1917 "`%s' used but never defined");
1918 else
1919 warning_with_decl (decl,
1920 "`%s' declared `static' but never defined");
1921 /* This symbol is effectively an "extern" declaration now. */
1922 TREE_PUBLIC (decl) = 1;
1923 assemble_external (decl);
1926 /* Warn about static fns or vars defined but not used,
1927 but not about inline functions or static consts
1928 since defining those in header files is normal practice. */
1929 if (warn_unused
1930 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
1931 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
1932 && ! DECL_IN_SYSTEM_HEADER (decl)
1933 && ! DECL_EXTERNAL (decl)
1934 && ! TREE_PUBLIC (decl)
1935 && ! TREE_USED (decl)
1936 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
1937 /* The TREE_USED bit for file-scope decls
1938 is kept in the identifier, to handle multiple
1939 external decls in different scopes. */
1940 && ! TREE_USED (DECL_NAME (decl)))
1941 warning_with_decl (decl, "`%s' defined but not used");
1943 timevar_push (TV_SYMOUT);
1944 #ifdef SDB_DEBUGGING_INFO
1945 /* The COFF linker can move initialized global vars to the end.
1946 And that can screw up the symbol ordering.
1947 By putting the symbols in that order to begin with,
1948 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1949 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
1950 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
1951 && ! DECL_EXTERNAL (decl)
1952 && DECL_RTL (decl) != 0)
1953 sdbout_symbol (decl, 0);
1955 /* Output COFF information for non-global
1956 file-scope initialized variables. */
1957 if (write_symbols == SDB_DEBUG
1958 && TREE_CODE (decl) == VAR_DECL
1959 && DECL_INITIAL (decl)
1960 && ! DECL_EXTERNAL (decl)
1961 && DECL_RTL (decl) != 0
1962 && GET_CODE (DECL_RTL (decl)) == MEM)
1963 sdbout_toplevel_data (decl);
1964 #endif /* SDB_DEBUGGING_INFO */
1965 #ifdef DWARF_DEBUGGING_INFO
1966 /* Output DWARF information for file-scope tentative data object
1967 declarations, file-scope (extern) function declarations (which
1968 had no corresponding body) and file-scope tagged type declarations
1969 and definitions which have not yet been forced out. */
1971 if (write_symbols == DWARF_DEBUG
1972 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1973 dwarfout_file_scope_decl (decl, 1);
1974 #endif
1975 #ifdef DWARF2_DEBUGGING_INFO
1976 /* Output DWARF2 information for file-scope tentative data object
1977 declarations, file-scope (extern) function declarations (which
1978 had no corresponding body) and file-scope tagged type declarations
1979 and definitions which have not yet been forced out. */
1981 if (write_symbols == DWARF2_DEBUG
1982 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1983 dwarf2out_decl (decl);
1984 #endif
1985 timevar_pop (TV_SYMOUT);
1989 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
1990 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
1991 INPUT_FILENAME and LINENO accordingly. */
1993 void
1994 push_srcloc (file, line)
1995 const char *file;
1996 int line;
1998 struct file_stack *fs;
2000 if (input_file_stack)
2002 input_file_stack->name = input_filename;
2003 input_file_stack->line = lineno;
2006 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2007 fs->name = input_filename = file;
2008 fs->line = lineno = line;
2009 fs->indent_level = 0;
2010 fs->next = input_file_stack;
2011 input_file_stack = fs;
2012 input_file_stack_tick++;
2015 /* Pop the top entry off the stack of presently open source files.
2016 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2017 the stack. */
2019 void
2020 pop_srcloc ()
2022 struct file_stack *fs;
2024 fs = input_file_stack;
2025 input_file_stack = fs->next;
2026 free (fs);
2027 input_file_stack_tick++;
2028 /* The initial souce file is never popped. */
2029 if (!input_file_stack)
2030 abort ();
2031 input_filename = input_file_stack->name;
2032 lineno = input_file_stack->line;
2035 /* Compile an entire file of output from cpp, named NAME.
2036 Write a file of assembly output and various debugging dumps. */
2038 static void
2039 compile_file (name)
2040 const char *name;
2042 tree globals;
2044 int name_specified = name != 0;
2046 if (dump_base_name == 0)
2047 dump_base_name = name ? name : "gccdump";
2049 /* Start timing total execution time. */
2051 init_timevar ();
2052 timevar_start (TV_TOTAL);
2054 /* Initialize data in various passes. */
2056 init_obstacks ();
2057 init_tree_codes ();
2058 name = init_parse (name);
2059 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2060 || debug_info_level == DINFO_LEVEL_VERBOSE
2061 || flag_test_coverage
2062 || warn_notreached);
2063 init_regs ();
2064 init_decl_processing ();
2065 init_optabs ();
2066 init_stmt ();
2067 init_eh ();
2068 init_loop ();
2069 init_reload ();
2070 init_alias_once ();
2071 init_function_once ();
2072 init_stor_layout_once ();
2073 init_varasm_once ();
2075 /* The following initialization functions need to generate rtl, so
2076 provide a dummy function context for them. */
2077 init_dummy_function_start ();
2078 init_expmed ();
2079 init_expr_once ();
2080 if (flag_caller_saves)
2081 init_caller_save ();
2082 expand_dummy_function_end ();
2084 /* If auxiliary info generation is desired, open the output file.
2085 This goes in the same directory as the source file--unlike
2086 all the other output files. */
2087 if (flag_gen_aux_info)
2089 aux_info_file = fopen (aux_info_file_name, "w");
2090 if (aux_info_file == 0)
2091 pfatal_with_name (aux_info_file_name);
2094 /* Open assembler code output file. */
2096 if (flag_syntax_only)
2097 asm_out_file = NULL;
2098 else
2100 if (! name_specified && asm_file_name == 0)
2101 asm_out_file = stdout;
2102 else
2104 if (asm_file_name == 0)
2106 int len = strlen (dump_base_name);
2107 char *dumpname = (char *) xmalloc (len + 6);
2108 memcpy (dumpname, dump_base_name, len + 1);
2109 strip_off_ending (dumpname, len);
2110 strcat (dumpname, ".s");
2111 asm_file_name = dumpname;
2113 if (!strcmp (asm_file_name, "-"))
2114 asm_out_file = stdout;
2115 else
2116 asm_out_file = fopen (asm_file_name, "w");
2117 if (asm_out_file == 0)
2118 pfatal_with_name (asm_file_name);
2121 #ifdef IO_BUFFER_SIZE
2122 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2123 _IOFBF, IO_BUFFER_SIZE);
2124 #endif
2127 if (ggc_p && name != 0)
2128 name = ggc_alloc_string (name, strlen (name));
2130 input_filename = name;
2132 /* Put an entry on the input file stack for the main input file. */
2133 push_srcloc (input_filename, 0);
2135 /* Perform language-specific initialization.
2136 This may set main_input_filename. */
2137 lang_init ();
2139 /* If the input doesn't start with a #line, use the input name
2140 as the official input file name. */
2141 if (main_input_filename == 0)
2142 main_input_filename = name;
2144 if (flag_syntax_only)
2146 write_symbols = NO_DEBUG;
2147 profile_flag = 0;
2148 profile_block_flag = 0;
2150 else
2152 ASM_FILE_START (asm_out_file);
2154 #ifdef ASM_COMMENT_START
2155 if (flag_verbose_asm)
2157 /* Print the list of options in effect. */
2158 print_version (asm_out_file, ASM_COMMENT_START);
2159 print_switch_values (asm_out_file, 0, MAX_LINE,
2160 ASM_COMMENT_START, " ", "\n");
2161 /* Add a blank line here so it appears in assembler output but not
2162 screen output. */
2163 fprintf (asm_out_file, "\n");
2165 #endif
2167 /* Output something to inform GDB that this compilation was by GCC. */
2168 #ifndef ASM_IDENTIFY_GCC
2169 fprintf (asm_out_file, "gcc2_compiled.:\n");
2170 #else
2171 ASM_IDENTIFY_GCC (asm_out_file);
2172 #endif
2174 /* Output something to identify which front-end produced this file. */
2175 #ifdef ASM_IDENTIFY_LANGUAGE
2176 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2177 #endif
2178 } /* ! flag_syntax_only */
2180 #ifndef ASM_OUTPUT_SECTION_NAME
2181 if (flag_function_sections)
2183 warning ("-ffunction-sections not supported for this target.");
2184 flag_function_sections = 0;
2186 if (flag_data_sections)
2188 warning ("-fdata-sections not supported for this target.");
2189 flag_data_sections = 0;
2191 #endif
2193 if (flag_function_sections
2194 && (profile_flag || profile_block_flag))
2196 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2197 flag_function_sections = 0;
2200 #ifndef OBJECT_FORMAT_ELF
2201 if (flag_function_sections && write_symbols != NO_DEBUG)
2202 warning ("-ffunction-sections may affect debugging on some targets.");
2203 #endif
2205 /* ??? Note: There used to be a conditional here
2206 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2207 This was to guarantee separation between gcc_compiled. and
2208 the first function, for the sake of dbx on Suns.
2209 However, having the extra zero here confused the Emacs
2210 code for unexec, and might confuse other programs too.
2211 Therefore, I took out that change.
2212 In future versions we should find another way to solve
2213 that dbx problem. -- rms, 23 May 93. */
2215 /* Don't let the first function fall at the same address
2216 as gcc_compiled., if profiling. */
2217 if (profile_flag || profile_block_flag)
2219 /* It's best if we can write a nop here since some
2220 assemblers don't tolerate zeros in the text section. */
2221 output_asm_insn (get_insn_template (CODE_FOR_nop, NULL), NULL_PTR);
2224 /* If dbx symbol table desired, initialize writing it
2225 and output the predefined types. */
2226 timevar_push (TV_SYMOUT);
2227 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2228 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2229 dbxout_init (asm_out_file, main_input_filename, getdecls ());
2230 #endif
2231 #ifdef SDB_DEBUGGING_INFO
2232 if (write_symbols == SDB_DEBUG)
2233 sdbout_init (asm_out_file, main_input_filename, getdecls ());
2234 #endif
2235 #ifdef DWARF_DEBUGGING_INFO
2236 if (write_symbols == DWARF_DEBUG)
2237 dwarfout_init (asm_out_file, main_input_filename);
2238 #endif
2239 #ifdef DWARF2_UNWIND_INFO
2240 if (dwarf2out_do_frame ())
2241 dwarf2out_frame_init ();
2242 #endif
2243 #ifdef DWARF2_DEBUGGING_INFO
2244 if (write_symbols == DWARF2_DEBUG)
2245 dwarf2out_init (asm_out_file, main_input_filename);
2246 #endif
2247 timevar_pop (TV_SYMOUT);
2249 /* Initialize yet another pass. */
2251 init_final (main_input_filename);
2252 init_branch_prob (dump_base_name);
2254 timevar_push (TV_PARSE);
2256 /* Call the parser, which parses the entire file
2257 (calling rest_of_compilation for each function). */
2259 if (yyparse () != 0)
2261 if (errorcount == 0)
2262 fnotice (stderr, "Errors detected in input file (your bison.simple is out of date)\n");
2264 /* In case there were missing closebraces,
2265 get us back to the global binding level. */
2266 while (! global_bindings_p ())
2267 poplevel (0, 0, 0);
2270 /* Compilation is now finished except for writing
2271 what's left of the symbol table output. */
2273 timevar_pop (TV_PARSE);
2275 if (flag_syntax_only)
2276 goto finish_syntax;
2278 globals = getdecls ();
2280 /* Really define vars that have had only a tentative definition.
2281 Really output inline functions that must actually be callable
2282 and have not been output so far. */
2285 int len = list_length (globals);
2286 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2287 int i;
2288 tree decl;
2290 /* Process the decls in reverse order--earliest first.
2291 Put them into VEC from back to front, then take out from front. */
2293 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2294 vec[len - i - 1] = decl;
2296 wrapup_global_declarations (vec, len);
2298 /* This must occur after the loop to output deferred functions. Else
2299 the profiler initializer would not be emitted if all the functions
2300 in this compilation unit were deferred.
2302 output_func_start_profiler can not cause any additional functions or
2303 data to need to be output, so it need not be in the deferred function
2304 loop above. */
2305 output_func_start_profiler ();
2307 /* Now that all possible functions have been output, we can dump
2308 the exception table. */
2310 output_exception_table ();
2312 check_global_declarations (vec, len);
2314 /* Clean up. */
2315 free (vec);
2318 /* Write out any pending weak symbol declarations. */
2320 weak_finish ();
2322 /* Do dbx symbols */
2323 timevar_push (TV_SYMOUT);
2324 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2325 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2326 dbxout_finish (asm_out_file, main_input_filename);
2327 #endif
2329 #ifdef DWARF_DEBUGGING_INFO
2330 if (write_symbols == DWARF_DEBUG)
2331 dwarfout_finish ();
2332 #endif
2334 #ifdef DWARF2_UNWIND_INFO
2335 if (dwarf2out_do_frame ())
2336 dwarf2out_frame_finish ();
2337 #endif
2339 #ifdef DWARF2_DEBUGGING_INFO
2340 if (write_symbols == DWARF2_DEBUG)
2341 dwarf2out_finish ();
2342 #endif
2343 timevar_pop (TV_SYMOUT);
2345 /* Output some stuff at end of file if nec. */
2347 end_final (dump_base_name);
2349 if (flag_test_coverage || flag_branch_probabilities)
2351 timevar_push (TV_DUMP);
2352 open_dump_file (DFI_bp, NULL);
2353 end_branch_prob (rtl_dump_file);
2354 close_dump_file (DFI_bp, NULL, NULL_RTX);
2355 timevar_pop (TV_DUMP);
2358 #ifdef ASM_FILE_END
2359 ASM_FILE_END (asm_out_file);
2360 #endif
2362 /* Language-specific end of compilation actions. */
2363 finish_syntax:
2364 lang_finish ();
2366 /* Close the dump files. */
2368 if (flag_gen_aux_info)
2370 fclose (aux_info_file);
2371 if (errorcount)
2372 unlink (aux_info_file_name);
2375 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2377 timevar_push (TV_DUMP);
2378 dump_combine_total_stats (rtl_dump_file);
2379 close_dump_file (DFI_combine, NULL, NULL_RTX);
2380 timevar_pop (TV_DUMP);
2383 /* Close non-debugging input and output files. Take special care to note
2384 whether fclose returns an error, since the pages might still be on the
2385 buffer chain while the file is open. */
2387 finish_parse ();
2389 if (! flag_syntax_only
2390 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
2391 fatal_io_error (asm_file_name);
2393 /* Do whatever is necessary to finish printing the graphs. */
2394 if (graph_dump_format != no_graph)
2396 int i;
2398 for (i = 0; i < DFI_MAX; ++i)
2399 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
2401 char seq[16];
2402 char *suffix;
2404 sprintf (seq, ".%02d.", i);
2405 suffix = concat (seq, dump_file[i].extension, NULL);
2406 finish_graph_dump_file (dump_base_name, suffix);
2407 free (suffix);
2411 /* Free up memory for the benefit of leak detectors. */
2412 free_reg_info ();
2414 /* Stop timing total execution time. */
2415 timevar_stop (TV_TOTAL);
2417 /* Print the times. */
2419 if (! quiet_flag)
2420 timevar_print (stderr);
2423 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2424 and TYPE_DECL nodes.
2426 This does nothing for local (non-static) variables, unless the
2427 variable is a register variable with an ASMSPEC. In that case, or
2428 if the variable is not an automatice, it sets up the RTL and
2429 outputs any assembler code (label definition, storage allocation
2430 and initialization).
2432 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2433 the assembler symbol name to be used. TOP_LEVEL is nonzero
2434 if this declaration is not within a function. */
2436 void
2437 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2438 tree decl;
2439 const char *asmspec;
2440 int top_level;
2441 int at_end;
2443 /* Declarations of variables, and of functions defined elsewhere. */
2445 /* The most obvious approach, to put an #ifndef around where
2446 this macro is used, doesn't work since it's inside a macro call. */
2447 #ifndef ASM_FINISH_DECLARE_OBJECT
2448 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2449 #endif
2451 /* Forward declarations for nested functions are not "external",
2452 but we need to treat them as if they were. */
2453 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2454 || TREE_CODE (decl) == FUNCTION_DECL)
2456 timevar_push (TV_VARCONST);
2457 make_decl_rtl (decl, asmspec, top_level);
2458 /* Initialized extern variable exists to be replaced
2459 with its value, or represents something that will be
2460 output in another file. */
2461 if (! (TREE_CODE (decl) == VAR_DECL
2462 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2463 && DECL_INITIAL (decl) != 0
2464 && DECL_INITIAL (decl) != error_mark_node))
2465 /* Don't output anything
2466 when a tentative file-scope definition is seen.
2467 But at end of compilation, do output code for them. */
2468 if (! (! at_end && top_level
2469 && (DECL_INITIAL (decl) == 0
2470 || DECL_INITIAL (decl) == error_mark_node)))
2471 assemble_variable (decl, top_level, at_end, 0);
2472 if (decl == last_assemble_variable_decl)
2474 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2475 top_level, at_end);
2477 timevar_pop (TV_VARCONST);
2479 else if (DECL_REGISTER (decl) && asmspec != 0)
2481 if (decode_reg_name (asmspec) >= 0)
2483 DECL_RTL (decl) = 0;
2484 make_decl_rtl (decl, asmspec, top_level);
2486 else
2487 error ("invalid register name `%s' for register variable", asmspec);
2489 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2490 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2491 && TREE_CODE (decl) == TYPE_DECL)
2493 timevar_push (TV_SYMOUT);
2494 dbxout_symbol (decl, 0);
2495 timevar_pop (TV_SYMOUT);
2497 #endif
2498 #ifdef SDB_DEBUGGING_INFO
2499 else if (write_symbols == SDB_DEBUG && top_level
2500 && TREE_CODE (decl) == TYPE_DECL)
2502 timevar_push (TV_SYMOUT);
2503 sdbout_symbol (decl, 0);
2504 timevar_pop (TV_SYMOUT);
2506 #endif
2509 /* Called after finishing a record, union or enumeral type. */
2511 void
2512 rest_of_type_compilation (type, toplev)
2513 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2514 tree type;
2515 int toplev;
2516 #else
2517 tree type ATTRIBUTE_UNUSED;
2518 int toplev ATTRIBUTE_UNUSED;
2519 #endif
2521 timevar_push (TV_SYMOUT);
2522 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2523 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2524 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2525 #endif
2526 #ifdef SDB_DEBUGGING_INFO
2527 if (write_symbols == SDB_DEBUG)
2528 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2529 #endif
2530 timevar_pop (TV_SYMOUT);
2533 /* DECL is an inline function, whose body is present, but which is not
2534 being output at this point. (We're putting that off until we need
2535 to do it.) If there are any actions that need to take place,
2536 including the emission of debugging information for the function,
2537 this is where they should go. This function may be called by
2538 language-dependent code for front-ends that do not even generate
2539 RTL for functions that don't need to be put out. */
2541 void
2542 note_deferral_of_defined_inline_function (decl)
2543 tree decl ATTRIBUTE_UNUSED;
2545 #ifdef DWARF_DEBUGGING_INFO
2546 /* Generate the DWARF info for the "abstract" instance of a function
2547 which we may later generate inlined and/or out-of-line instances
2548 of. */
2549 if (write_symbols == DWARF_DEBUG && DECL_INLINE (decl))
2551 /* The front-end may not have set CURRENT_FUNCTION_DECL, but the
2552 DWARF code expects it to be set in this case. Intuitively,
2553 DECL is the function we just finished defining, so setting
2554 CURRENT_FUNCTION_DECL is sensible. */
2555 tree saved_cfd = current_function_decl;
2556 current_function_decl = decl;
2558 /* Let the DWARF code do its work. */
2559 set_decl_abstract_flags (decl, 1);
2560 dwarfout_file_scope_decl (decl, 0);
2561 set_decl_abstract_flags (decl, 0);
2563 /* Reset CURRENT_FUNCTION_DECL. */
2564 current_function_decl = saved_cfd;
2566 #endif
2569 /* This is called from finish_function (within yyparse)
2570 after each top-level definition is parsed.
2571 It is supposed to compile that function or variable
2572 and output the assembler code for it.
2573 After we return, the tree storage is freed. */
2575 void
2576 rest_of_compilation (decl)
2577 tree decl;
2579 register rtx insns;
2580 int tem;
2581 int failure = 0;
2582 int rebuild_label_notes_after_reload;
2584 timevar_push (TV_REST_OF_COMPILATION);
2586 /* When processing delayed functions, prepare_function_start() won't
2587 have been run to re-initialize it. */
2588 cse_not_expected = ! optimize;
2590 /* First, make sure that NOTE_BLOCK is set correctly for each
2591 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2592 if (!cfun->x_whole_function_mode_p)
2593 identify_blocks ();
2595 /* Then remove any notes we don't need. That will make iterating
2596 over the instruction sequence faster, and allow the garbage
2597 collector to reclaim the memory used by the notes. */
2598 remove_unnecessary_notes ();
2600 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2601 tree in sensible shape. So, we just recalculate it here. */
2602 if (cfun->x_whole_function_mode_p)
2603 reorder_blocks ();
2605 /* If we are reconsidering an inline function
2606 at the end of compilation, skip the stuff for making it inline. */
2608 if (DECL_SAVED_INSNS (decl) == 0)
2610 int inlinable = 0;
2611 tree parent;
2612 const char *lose;
2614 /* If this is nested inside an inlined external function, pretend
2615 it was only declared. Since we cannot inline such functions,
2616 generating code for this one is not only not necessary but will
2617 confuse some debugging output writers. */
2618 for (parent = DECL_CONTEXT (current_function_decl);
2619 parent != NULL_TREE;
2620 parent = get_containing_scope (parent))
2621 if (TREE_CODE (parent) == FUNCTION_DECL
2622 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2624 DECL_INITIAL (decl) = 0;
2625 goto exit_rest_of_compilation;
2628 /* If requested, consider whether to make this function inline. */
2629 if (DECL_INLINE (decl) || flag_inline_functions)
2631 timevar_push (TV_INTEGRATION);
2632 lose = function_cannot_inline_p (decl);
2633 timevar_pop (TV_INTEGRATION);
2634 if (lose || ! optimize)
2636 if (warn_inline && DECL_INLINE (decl))
2637 warning_with_decl (decl, lose);
2638 DECL_ABSTRACT_ORIGIN (decl) = 0;
2639 /* Don't really compile an extern inline function.
2640 If we can't make it inline, pretend
2641 it was only declared. */
2642 if (DECL_EXTERNAL (decl))
2644 DECL_INITIAL (decl) = 0;
2645 goto exit_rest_of_compilation;
2648 else
2649 /* ??? Note that this has the effect of making it look
2650 like "inline" was specified for a function if we choose
2651 to inline it. This isn't quite right, but it's
2652 probably not worth the trouble to fix. */
2653 inlinable = DECL_INLINE (decl) = 1;
2656 insns = get_insns ();
2658 /* Dump the rtl code if we are dumping rtl. */
2660 if (open_dump_file (DFI_rtl, decl))
2662 if (DECL_SAVED_INSNS (decl))
2663 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2664 close_dump_file (DFI_rtl, print_rtl, insns);
2667 /* If function is inline, and we don't yet know whether to
2668 compile it by itself, defer decision till end of compilation.
2669 finish_compilation will call rest_of_compilation again
2670 for those functions that need to be output. Also defer those
2671 functions that we are supposed to defer. */
2673 if (inlinable
2674 || (DECL_INLINE (decl)
2675 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2676 && ! flag_keep_inline_functions)
2677 || DECL_EXTERNAL (decl))))
2678 DECL_DEFER_OUTPUT (decl) = 1;
2680 if (DECL_INLINE (decl))
2681 /* DWARF wants seperate debugging info for abstract and
2682 concrete instances of all inline functions, including those
2683 declared inline but not inlined, and those inlined even
2684 though they weren't declared inline. Conveniently, that's
2685 what DECL_INLINE means at this point. */
2686 note_deferral_of_defined_inline_function (decl);
2688 if (DECL_DEFER_OUTPUT (decl))
2690 /* If -Wreturn-type, we have to do a bit of compilation.
2691 However, if we just fall through we will call
2692 save_for_inline_copying() which results in excessive
2693 memory use. Instead, we just want to call
2694 jump_optimize() to figure out whether or not we can fall
2695 off the end of the function; we do the minimum amount of
2696 work necessary to make that safe. And, we set optimize
2697 to zero to keep jump_optimize from working too hard. */
2698 if (warn_return_type)
2700 int saved_optimize = optimize;
2701 optimize = 0;
2702 find_exception_handler_labels ();
2703 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2704 !JUMP_AFTER_REGSCAN);
2705 optimize = saved_optimize;
2708 current_function_nothrow = nothrow_function_p ();
2709 if (current_function_nothrow)
2710 /* Now we know that this can't throw; set the flag for the benefit
2711 of other functions later in this translation unit. */
2712 TREE_NOTHROW (current_function_decl) = 1;
2714 timevar_push (TV_INTEGRATION);
2715 save_for_inline_nocopy (decl);
2716 timevar_pop (TV_INTEGRATION);
2717 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2718 goto exit_rest_of_compilation;
2721 /* If specified extern inline but we aren't inlining it, we are
2722 done. This goes for anything that gets here with DECL_EXTERNAL
2723 set, not just things with DECL_INLINE. */
2724 if (DECL_EXTERNAL (decl))
2725 goto exit_rest_of_compilation;
2728 init_EXPR_INSN_LIST_cache ();
2730 if (ggc_p)
2731 ggc_collect ();
2733 /* Initialize some variables used by the optimizers. */
2734 init_function_for_compilation ();
2736 if (! DECL_DEFER_OUTPUT (decl))
2737 TREE_ASM_WRITTEN (decl) = 1;
2739 /* Now that integrate will no longer see our rtl, we need not distinguish
2740 between the return value of this function and the return value of called
2741 functions. */
2742 rtx_equal_function_value_matters = 0;
2744 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2745 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2746 goto exit_rest_of_compilation;
2748 /* Emit code to get eh context, if needed. */
2749 emit_eh_context ();
2751 /* We may have potential sibling or tail recursion sites. Select one
2752 (of possibly multiple) methods of performing the call. */
2753 if (flag_optimize_sibling_calls)
2755 timevar_push (TV_JUMP);
2756 open_dump_file (DFI_sibling, decl);
2758 optimize_sibling_and_tail_recursive_calls ();
2760 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2761 timevar_pop (TV_JUMP);
2764 #ifdef FINALIZE_PIC
2765 /* If we are doing position-independent code generation, now
2766 is the time to output special prologues and epilogues.
2767 We do not want to do this earlier, because it just clutters
2768 up inline functions with meaningless insns. */
2769 if (flag_pic)
2770 FINALIZE_PIC;
2771 #endif
2773 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2774 Note that that may have been done above, in save_for_inline_copying.
2775 The call to resume_temporary_allocation near the end of this function
2776 goes back to the usual state of affairs. This must be done after
2777 we've built up any unwinders for exception handling, and done
2778 the FINALIZE_PIC work, if necessary. */
2780 rtl_in_current_obstack ();
2782 insns = get_insns ();
2784 /* Copy any shared structure that should not be shared. */
2785 unshare_all_rtl (current_function_decl, insns);
2787 #ifdef SETJMP_VIA_SAVE_AREA
2788 /* This must be performed before virutal register instantiation. */
2789 if (current_function_calls_alloca)
2790 optimize_save_area_alloca (insns);
2791 #endif
2793 /* Instantiate all virtual registers. */
2794 instantiate_virtual_regs (current_function_decl, insns);
2796 /* Find all the EH handlers. */
2797 find_exception_handler_labels ();
2799 open_dump_file (DFI_jump, decl);
2801 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2802 are initialized and to compute whether control can drop off the end
2803 of the function. */
2805 timevar_push (TV_JUMP);
2806 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2807 before jump optimization switches branch directions. */
2808 expected_value_to_br_prob ();
2810 reg_scan (insns, max_reg_num (), 0);
2811 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2812 JUMP_AFTER_REGSCAN);
2814 timevar_pop (TV_JUMP);
2816 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2817 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2819 close_dump_file (DFI_jump, print_rtl, insns);
2820 goto exit_rest_of_compilation;
2823 timevar_push (TV_JUMP);
2825 if (optimize > 0)
2827 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2828 cleanup_cfg (insns);
2830 /* ??? Run if-conversion before delete_null_pointer_checks,
2831 since the later does not preserve the CFG. This should
2832 be changed -- no since converting if's that are going to
2833 be deleted. */
2834 timevar_push (TV_IFCVT);
2835 if_convert (0);
2836 timevar_pop (TV_IFCVT);
2838 /* Try to identify useless null pointer tests and delete them. */
2839 if (flag_delete_null_pointer_checks)
2840 delete_null_pointer_checks (insns);
2843 /* Jump optimization, and the removal of NULL pointer checks, may
2844 have reduced the number of instructions substantially. CSE, and
2845 future passes, allocate arrays whose dimensions involve the
2846 maximum instruction UID, so if we can reduce the maximum UID
2847 we'll save big on memory. */
2848 renumber_insns (rtl_dump_file);
2849 timevar_pop (TV_JUMP);
2851 close_dump_file (DFI_jump, print_rtl, insns);
2853 if (ggc_p)
2854 ggc_collect ();
2856 /* Perform common subexpression elimination.
2857 Nonzero value from `cse_main' means that jumps were simplified
2858 and some code may now be unreachable, so do
2859 jump optimization again. */
2861 if (optimize > 0)
2863 open_dump_file (DFI_cse, decl);
2864 timevar_push (TV_CSE);
2866 reg_scan (insns, max_reg_num (), 1);
2868 if (flag_thread_jumps)
2870 timevar_push (TV_JUMP);
2871 thread_jumps (insns, max_reg_num (), 1);
2872 timevar_pop (TV_JUMP);
2875 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2877 /* If we are not running the second CSE pass, then we are no longer
2878 expecting CSE to be run. */
2879 cse_not_expected = !flag_rerun_cse_after_loop;
2881 if (tem || optimize > 1)
2883 timevar_push (TV_JUMP);
2884 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2885 !JUMP_AFTER_REGSCAN);
2886 timevar_pop (TV_JUMP);
2889 /* Run this after jump optmizations remove all the unreachable code
2890 so that unreachable code will not keep values live. */
2891 delete_trivially_dead_insns (insns, max_reg_num ());
2893 /* Try to identify useless null pointer tests and delete them. */
2894 if (flag_delete_null_pointer_checks)
2896 timevar_push (TV_JUMP);
2897 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2899 cleanup_cfg (insns);
2901 delete_null_pointer_checks (insns);
2902 timevar_pop (TV_JUMP);
2905 /* The second pass of jump optimization is likely to have
2906 removed a bunch more instructions. */
2907 renumber_insns (rtl_dump_file);
2909 timevar_pop (TV_CSE);
2910 close_dump_file (DFI_cse, print_rtl, insns);
2913 open_dump_file (DFI_addressof, decl);
2915 purge_addressof (insns);
2916 reg_scan (insns, max_reg_num (), 1);
2918 close_dump_file (DFI_addressof, print_rtl, insns);
2920 if (ggc_p)
2921 ggc_collect ();
2923 if (optimize > 0 && flag_ssa)
2925 /* Convert to SSA form. */
2927 timevar_push (TV_TO_SSA);
2928 open_dump_file (DFI_ssa, decl);
2930 find_basic_blocks (insns, max_reg_num(), rtl_dump_file);
2931 cleanup_cfg (insns);
2932 convert_to_ssa ();
2934 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2935 timevar_pop (TV_TO_SSA);
2937 /* Currently, there's nothing to do in SSA form. */
2939 /* Convert from SSA form. */
2941 timevar_push (TV_FROM_SSA);
2942 open_dump_file (DFI_ussa, decl);
2944 convert_from_ssa ();
2945 /* New registers have been created. Rescan their usage. */
2946 reg_scan (insns, max_reg_num (), 1);
2947 /* Life analysis used in SSA adds log_links but these
2948 shouldn't be there until the flow stage, so clear
2949 them away. */
2950 clear_log_links (insns);
2952 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
2953 timevar_pop (TV_FROM_SSA);
2955 if (ggc_p)
2956 ggc_collect ();
2959 /* Perform global cse. */
2961 if (optimize > 0 && flag_gcse)
2963 timevar_push (TV_GCSE);
2964 open_dump_file (DFI_gcse, decl);
2966 find_basic_blocks (insns, max_reg_num(), rtl_dump_file);
2967 cleanup_cfg (insns);
2968 tem = gcse_main (insns, rtl_dump_file);
2970 /* If gcse altered any jumps, rerun jump optimizations to clean
2971 things up. */
2972 if (tem)
2974 timevar_push (TV_JUMP);
2975 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2976 !JUMP_AFTER_REGSCAN);
2977 timevar_pop (TV_JUMP);
2980 close_dump_file (DFI_gcse, print_rtl, insns);
2981 timevar_pop (TV_GCSE);
2983 if (ggc_p)
2984 ggc_collect ();
2987 /* Move constant computations out of loops. */
2989 if (optimize > 0)
2991 timevar_push (TV_LOOP);
2992 open_dump_file (DFI_loop, decl);
2994 if (flag_rerun_loop_opt)
2996 /* We only want to perform unrolling once. */
2998 loop_optimize (insns, rtl_dump_file, 0, 0);
3000 /* The first call to loop_optimize makes some instructions
3001 trivially dead. We delete those instructions now in the
3002 hope that doing so will make the heuristics in loop work
3003 better and possibly speed up compilation. */
3004 delete_trivially_dead_insns (insns, max_reg_num ());
3006 /* The regscan pass is currently necessary as the alias
3007 analysis code depends on this information. */
3008 reg_scan (insns, max_reg_num (), 1);
3010 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
3012 close_dump_file (DFI_loop, print_rtl, insns);
3013 timevar_pop (TV_LOOP);
3015 if (ggc_p)
3016 ggc_collect ();
3019 if (optimize > 0)
3021 timevar_push (TV_CSE2);
3022 open_dump_file (DFI_cse2, decl);
3024 if (flag_rerun_cse_after_loop)
3026 /* Running another jump optimization pass before the second
3027 cse pass sometimes simplifies the RTL enough to allow
3028 the second CSE pass to do a better job. Jump_optimize can change
3029 max_reg_num so we must rerun reg_scan afterwards.
3030 ??? Rework to not call reg_scan so often. */
3031 timevar_push (TV_JUMP);
3033 reg_scan (insns, max_reg_num (), 0);
3034 jump_optimize (insns, !JUMP_CROSS_JUMP,
3035 !JUMP_NOOP_MOVES, JUMP_AFTER_REGSCAN);
3037 timevar_push (TV_IFCVT);
3039 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3040 cleanup_cfg (insns);
3041 if_convert (0);
3043 timevar_pop(TV_IFCVT);
3045 timevar_pop (TV_JUMP);
3047 reg_scan (insns, max_reg_num (), 0);
3048 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3050 if (tem)
3052 timevar_push (TV_JUMP);
3053 jump_optimize (insns, !JUMP_CROSS_JUMP,
3054 !JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3055 timevar_pop (TV_JUMP);
3059 if (flag_thread_jumps)
3061 /* This pass of jump threading straightens out code
3062 that was kinked by loop optimization. */
3063 timevar_push (TV_JUMP);
3064 reg_scan (insns, max_reg_num (), 0);
3065 thread_jumps (insns, max_reg_num (), 0);
3066 timevar_pop (TV_JUMP);
3069 close_dump_file (DFI_cse2, print_rtl, insns);
3070 timevar_pop (TV_CSE2);
3072 if (ggc_p)
3073 ggc_collect ();
3076 cse_not_expected = 1;
3078 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3080 timevar_push (TV_BRANCH_PROB);
3081 open_dump_file (DFI_bp, decl);
3083 branch_prob (insns, rtl_dump_file);
3085 close_dump_file (DFI_bp, print_rtl, insns);
3086 timevar_pop (TV_BRANCH_PROB);
3088 if (ggc_p)
3089 ggc_collect ();
3092 regclass_init ();
3094 /* Print function header into flow dump now
3095 because doing the flow analysis makes some of the dump. */
3097 open_dump_file (DFI_flow, decl);
3099 /* Do control and data flow analysis; wrote some of the results to
3100 the dump file. */
3102 timevar_push (TV_FLOW);
3103 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3104 cleanup_cfg (insns);
3105 if (optimize)
3107 struct loops loops;
3109 /* Discover and record the loop depth at the head of each basic
3110 block. The loop infrastructure does the real job for us. */
3111 flow_loops_find (&loops);
3113 /* Estimate using heuristics if no profiling info is available. */
3114 if (! flag_branch_probabilities)
3115 estimate_probability (&loops);
3117 if (rtl_dump_file)
3118 flow_loops_dump (&loops, rtl_dump_file, 0);
3120 flow_loops_free (&loops);
3122 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3123 mark_constant_function ();
3124 timevar_pop (TV_FLOW);
3126 if (warn_uninitialized || extra_warnings)
3128 uninitialized_vars_warning (DECL_INITIAL (decl));
3129 if (extra_warnings)
3130 setjmp_args_warning ();
3133 close_dump_file (DFI_flow, print_rtl_with_bb, insns);
3135 if (ggc_p)
3136 ggc_collect ();
3138 /* If -opt, try combining insns through substitution. */
3140 if (optimize > 0)
3142 int rebuild_jump_labels_after_combine = 0;
3144 timevar_push (TV_COMBINE);
3145 open_dump_file (DFI_combine, decl);
3147 rebuild_jump_labels_after_combine
3148 = combine_instructions (insns, max_reg_num ());
3150 /* Combining insns may have turned an indirect jump into a
3151 direct jump. Rebuid the JUMP_LABEL fields of jumping
3152 instructions. */
3153 if (rebuild_jump_labels_after_combine)
3155 timevar_push (TV_JUMP);
3156 rebuild_jump_labels (insns);
3157 timevar_pop (TV_JUMP);
3159 timevar_push (TV_FLOW);
3160 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3161 cleanup_cfg (insns);
3163 /* Blimey. We've got to have the CFG up to date for the call to
3164 if_convert below. However, the random deletion of blocks
3165 without updating life info can wind up with Wierd Stuff in
3166 global_live_at_end. We then run sched1, which updates things
3167 properly, discovers the wierdness and aborts. */
3168 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
3169 PROP_DEATH_NOTES | PROP_KILL_DEAD_CODE
3170 | PROP_SCAN_DEAD_CODE);
3172 timevar_pop (TV_FLOW);
3175 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3176 timevar_pop (TV_COMBINE);
3178 if (ggc_p)
3179 ggc_collect ();
3182 /* Rerun if-conversion, as combine may have simplified things enough to
3183 now meet sequence length restrictions. */
3184 if (optimize > 0)
3186 timevar_push (TV_IFCVT);
3187 open_dump_file (DFI_ce, decl);
3189 if_convert (1);
3191 close_dump_file (DFI_ce, print_rtl_with_bb, insns);
3192 timevar_pop (TV_IFCVT);
3195 /* Register allocation pre-pass, to reduce number of moves
3196 necessary for two-address machines. */
3197 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3199 timevar_push (TV_REGMOVE);
3200 open_dump_file (DFI_regmove, decl);
3202 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3204 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3205 timevar_pop (TV_REGMOVE);
3207 if (ggc_p)
3208 ggc_collect ();
3211 if (optimize && n_basic_blocks)
3213 timevar_push (TV_GCSE);
3214 optimize_mode_switching (NULL_PTR);
3215 timevar_pop (TV_GCSE);
3218 #ifdef INSN_SCHEDULING
3220 /* Print function header into sched dump now
3221 because doing the sched analysis makes some of the dump. */
3222 if (optimize > 0 && flag_schedule_insns)
3224 timevar_push (TV_SCHED);
3225 open_dump_file (DFI_sched, decl);
3227 /* Do control and data sched analysis,
3228 and write some of the results to dump file. */
3230 schedule_insns (rtl_dump_file);
3232 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3233 timevar_pop (TV_SCHED);
3235 if (ggc_p)
3236 ggc_collect ();
3238 /* Register lifetime information is up to date. From now on
3239 we can not generate any new pseudos. */
3240 no_new_pseudos = 1;
3242 #endif
3244 /* Determine if the current function is a leaf before running reload
3245 since this can impact optimizations done by the prologue and
3246 epilogue thus changing register elimination offsets. */
3247 current_function_is_leaf = leaf_function_p ();
3249 timevar_push (TV_LOCAL_ALLOC);
3250 open_dump_file (DFI_lreg, decl);
3252 /* Allocate pseudo-regs that are used only within 1 basic block.
3254 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3255 jump optimizer after register allocation and reloading are finished. */
3257 /* We recomputed reg usage as part of updating the rest
3258 of life info during sched. */
3259 if (! flag_schedule_insns)
3261 recompute_reg_usage (insns, ! optimize_size);
3263 /* Register lifetime information is up to date. From now on
3264 we can not generate any new pseudos. */
3265 no_new_pseudos = 1;
3267 regclass (insns, max_reg_num (), rtl_dump_file);
3268 rebuild_label_notes_after_reload = local_alloc ();
3270 timevar_pop (TV_LOCAL_ALLOC);
3272 if (dump_file[DFI_lreg].enabled)
3274 timevar_push (TV_DUMP);
3276 dump_flow_info (rtl_dump_file);
3277 dump_local_alloc (rtl_dump_file);
3279 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3280 timevar_pop (TV_DUMP);
3283 if (ggc_p)
3284 ggc_collect ();
3286 timevar_push (TV_GLOBAL_ALLOC);
3287 open_dump_file (DFI_greg, decl);
3289 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3290 pass fixing up any insns that are invalid. */
3292 if (optimize)
3293 failure = global_alloc (rtl_dump_file);
3294 else
3296 build_insn_chain (insns);
3297 failure = reload (insns, 0, rtl_dump_file);
3300 timevar_pop (TV_GLOBAL_ALLOC);
3302 if (failure)
3303 goto exit_rest_of_compilation;
3305 if (ggc_p)
3306 ggc_collect ();
3308 /* Do a very simple CSE pass over just the hard registers. */
3309 if (optimize > 0)
3311 timevar_push (TV_RELOAD_CSE_REGS);
3312 reload_cse_regs (insns);
3313 timevar_pop (TV_RELOAD_CSE_REGS);
3316 /* If optimizing, then go ahead and split insns now since we are about
3317 to recompute flow information anyway. */
3318 if (optimize > 0)
3319 split_all_insns (0);
3321 /* Register allocation and reloading may have turned an indirect jump into
3322 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3323 jumping instructions. */
3324 if (rebuild_label_notes_after_reload)
3326 timevar_push (TV_JUMP);
3328 rebuild_jump_labels (insns);
3330 timevar_pop (TV_JUMP);
3333 if (dump_file[DFI_greg].enabled)
3335 timevar_push (TV_DUMP);
3337 dump_global_regs (rtl_dump_file);
3339 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3340 timevar_pop (TV_DUMP);
3343 /* Re-create the death notes which were deleted during reload. */
3344 timevar_push (TV_FLOW2);
3345 open_dump_file (DFI_flow2, decl);
3347 jump_optimize_minimal (insns);
3348 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3350 /* On some machines, the prologue and epilogue code, or parts thereof,
3351 can be represented as RTL. Doing so lets us schedule insns between
3352 it and the rest of the code and also allows delayed branch
3353 scheduling to operate in the epilogue. */
3354 thread_prologue_and_epilogue_insns (insns);
3356 if (optimize)
3358 cleanup_cfg (insns);
3359 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3361 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3362 even for machines with possibly nonzero RETURN_POPS_ARGS
3363 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3364 push instructions will have popping returns. */
3365 #ifndef PUSH_ROUNDING
3366 if (!ACCUMULATE_OUTGOING_ARGS)
3367 #endif
3368 combine_stack_adjustments ();
3370 if (ggc_p)
3371 ggc_collect ();
3374 flow2_completed = 1;
3376 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3377 timevar_pop (TV_FLOW2);
3379 if (optimize > 0)
3381 timevar_push (TV_IFCVT2);
3382 open_dump_file (DFI_ce2, decl);
3384 if_convert (1);
3386 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3387 timevar_pop (TV_IFCVT2);
3390 #ifdef HAVE_peephole2
3391 if (optimize > 0 && flag_peephole2)
3393 timevar_push (TV_PEEPHOLE2);
3394 open_dump_file (DFI_peephole2, decl);
3396 peephole2_optimize (rtl_dump_file);
3398 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3399 timevar_pop (TV_PEEPHOLE2);
3401 #endif
3403 if (optimize > 0 && flag_rename_registers)
3405 timevar_push (TV_RENAME_REGISTERS);
3406 open_dump_file (DFI_rnreg, decl);
3408 regrename_optimize ();
3410 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3411 timevar_pop (TV_RENAME_REGISTERS);
3414 #ifdef INSN_SCHEDULING
3415 if (optimize > 0 && flag_schedule_insns_after_reload)
3417 timevar_push (TV_SCHED2);
3418 open_dump_file (DFI_sched2, decl);
3420 /* Do control and data sched analysis again,
3421 and write some more of the results to dump file. */
3423 schedule_insns (rtl_dump_file);
3425 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3426 timevar_pop (TV_SCHED2);
3428 if (ggc_p)
3429 ggc_collect ();
3431 #endif
3433 #ifdef LEAF_REGISTERS
3434 current_function_uses_only_leaf_regs
3435 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3436 #endif
3438 if (optimize > 0 && flag_reorder_blocks)
3440 timevar_push (TV_REORDER_BLOCKS);
3441 open_dump_file (DFI_bbro, decl);
3443 reorder_basic_blocks ();
3445 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3446 timevar_pop (TV_REORDER_BLOCKS);
3449 /* One more attempt to remove jumps to .+1 left by dead-store elimination.
3450 Also do cross-jumping this time and delete no-op move insns. */
3452 if (optimize > 0)
3454 timevar_push (TV_JUMP);
3455 open_dump_file (DFI_jump2, decl);
3457 jump_optimize (insns, JUMP_CROSS_JUMP, JUMP_NOOP_MOVES,
3458 !JUMP_AFTER_REGSCAN);
3460 /* CFG no longer kept up to date. */
3462 close_dump_file (DFI_jump2, print_rtl_with_bb, insns);
3463 timevar_pop (TV_JUMP);
3466 /* If a machine dependent reorganization is needed, call it. */
3467 #ifdef MACHINE_DEPENDENT_REORG
3468 open_dump_file (DFI_mach, decl);
3470 MACHINE_DEPENDENT_REORG (insns);
3472 close_dump_file (DFI_mach, print_rtl_with_bb, insns);
3474 if (ggc_p)
3475 ggc_collect ();
3476 #endif
3478 /* If a scheduling pass for delayed branches is to be done,
3479 call the scheduling code. */
3481 #ifdef DELAY_SLOTS
3482 if (optimize > 0 && flag_delayed_branch)
3484 timevar_push (TV_DBR_SCHED);
3485 open_dump_file (DFI_dbr, decl);
3487 dbr_schedule (insns, rtl_dump_file);
3489 close_dump_file (DFI_dbr, print_rtl_with_bb, insns);
3490 timevar_pop (TV_DBR_SCHED);
3492 if (ggc_p)
3493 ggc_collect ();
3495 #endif
3497 /* Shorten branches.
3499 Note this must run before reg-stack because of death note (ab)use
3500 in the ia32 backend. */
3501 timevar_push (TV_SHORTEN_BRANCH);
3502 shorten_branches (get_insns ());
3503 timevar_pop (TV_SHORTEN_BRANCH);
3505 #ifdef STACK_REGS
3506 timevar_push (TV_REG_STACK);
3507 open_dump_file (DFI_stack, decl);
3509 reg_to_stack (insns, rtl_dump_file);
3511 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3512 timevar_pop (TV_REG_STACK);
3514 if (ggc_p)
3515 ggc_collect ();
3516 #endif
3518 current_function_nothrow = nothrow_function_p ();
3519 if (current_function_nothrow)
3520 /* Now we know that this can't throw; set the flag for the benefit
3521 of other functions later in this translation unit. */
3522 TREE_NOTHROW (current_function_decl) = 1;
3524 /* Now turn the rtl into assembler code. */
3526 timevar_push (TV_FINAL);
3528 rtx x;
3529 const char *fnname;
3531 /* Get the function's name, as described by its RTL.
3532 This may be different from the DECL_NAME name used
3533 in the source file. */
3535 x = DECL_RTL (decl);
3536 if (GET_CODE (x) != MEM)
3537 abort ();
3538 x = XEXP (x, 0);
3539 if (GET_CODE (x) != SYMBOL_REF)
3540 abort ();
3541 fnname = XSTR (x, 0);
3543 assemble_start_function (decl, fnname);
3544 final_start_function (insns, asm_out_file, optimize);
3545 final (insns, asm_out_file, optimize, 0);
3546 final_end_function (insns, asm_out_file, optimize);
3547 assemble_end_function (decl, fnname);
3548 if (! quiet_flag)
3549 fflush (asm_out_file);
3551 /* Release all memory allocated by flow. */
3552 free_basic_block_vars (0);
3554 /* Release all memory held by regsets now */
3555 regset_release_memory ();
3557 timevar_pop (TV_FINAL);
3559 if (ggc_p)
3560 ggc_collect ();
3562 /* Write DBX symbols if requested */
3564 /* Note that for those inline functions where we don't initially
3565 know for certain that we will be generating an out-of-line copy,
3566 the first invocation of this routine (rest_of_compilation) will
3567 skip over this code by doing a `goto exit_rest_of_compilation;'.
3568 Later on, finish_compilation will call rest_of_compilation again
3569 for those inline functions that need to have out-of-line copies
3570 generated. During that call, we *will* be routed past here. */
3572 timevar_push (TV_SYMOUT);
3573 #ifdef DBX_DEBUGGING_INFO
3574 if (write_symbols == DBX_DEBUG)
3575 dbxout_function (decl);
3576 #endif
3578 #ifdef DWARF_DEBUGGING_INFO
3579 if (write_symbols == DWARF_DEBUG)
3580 dwarfout_file_scope_decl (decl, 0);
3581 #endif
3583 #ifdef DWARF2_DEBUGGING_INFO
3584 if (write_symbols == DWARF2_DEBUG)
3585 dwarf2out_decl (decl);
3586 #endif
3587 timevar_pop (TV_SYMOUT);
3589 exit_rest_of_compilation:
3591 /* In case the function was not output,
3592 don't leave any temporary anonymous types
3593 queued up for sdb output. */
3594 #ifdef SDB_DEBUGGING_INFO
3595 if (write_symbols == SDB_DEBUG)
3596 sdbout_types (NULL_TREE);
3597 #endif
3599 reload_completed = 0;
3600 flow2_completed = 0;
3601 no_new_pseudos = 0;
3603 timevar_push (TV_FINAL);
3605 /* Clear out the insn_length contents now that they are no
3606 longer valid. */
3607 init_insn_lengths ();
3609 /* Clear out the real_constant_chain before some of the rtx's
3610 it runs through become garbage. */
3611 clear_const_double_mem ();
3613 /* Cancel the effect of rtl_in_current_obstack. */
3614 resume_temporary_allocation ();
3616 /* Show no temporary slots allocated. */
3617 init_temp_slots ();
3619 free_basic_block_vars (0);
3621 timevar_pop (TV_FINAL);
3623 /* Make sure volatile mem refs aren't considered valid operands for
3624 arithmetic insns. We must call this here if this is a nested inline
3625 function, since the above code leaves us in the init_recog state
3626 (from final.c), and the function context push/pop code does not
3627 save/restore volatile_ok.
3629 ??? Maybe it isn't necessary for expand_start_function to call this
3630 anymore if we do it here? */
3632 init_recog_no_volatile ();
3634 /* We're done with this function. Free up memory if we can. */
3635 free_after_parsing (cfun);
3636 if (! DECL_DEFER_OUTPUT (decl))
3637 free_after_compilation (cfun);
3638 cfun = 0;
3640 if (ggc_p)
3641 ggc_collect ();
3643 timevar_pop (TV_REST_OF_COMPILATION);
3646 static void
3647 display_help ()
3649 int undoc;
3650 unsigned long i;
3651 const char * lang;
3653 #ifndef USE_CPPLIB
3654 printf ("Usage: %s input [switches]\n", progname);
3655 printf ("Switches:\n");
3656 #endif
3657 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
3658 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
3659 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
3660 printf (" -finline-limit=<number> Limits the size of inlined functions to <number>\n");
3662 for (i = NUM_ELEM (f_options); i--;)
3664 const char * description = f_options[i].description;
3666 if (description != NULL && * description != 0)
3667 printf (" -f%-21s %s\n",
3668 f_options[i].string, description);
3671 printf (" -O[number] Set optimisation level to [number]\n");
3672 printf (" -Os Optimise for space rather than speed\n");
3673 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
3674 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
3675 printf (" -w Suppress warnings\n");
3676 printf (" -W Enable extra warnings\n");
3678 for (i = NUM_ELEM (W_options); i--;)
3680 const char * description = W_options[i].description;
3682 if (description != NULL && * description != 0)
3683 printf (" -W%-21s %s\n",
3684 W_options[i].string, description);
3687 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
3688 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
3689 printf (" -p Enable function profiling\n");
3690 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3691 printf (" -a Enable block profiling \n");
3692 #endif
3693 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3694 printf (" -ax Enable jump profiling \n");
3695 #endif
3696 printf (" -o <file> Place output into <file> \n");
3697 printf (" -G <number> Put global and static data smaller than <number>\n");
3698 printf (" bytes into a special section (on some targets)\n");
3700 for (i = NUM_ELEM (debug_args); i--;)
3702 if (debug_args[i].description != NULL)
3703 printf (" -g%-21s %s\n", debug_args[i].arg, debug_args[i].description);
3706 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
3707 printf (" -quiet Do not display functions compiled or elapsed time\n");
3708 printf (" -version Display the compiler's version\n");
3709 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
3710 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
3711 #if defined INSN_SCHEDULING
3712 printf (" -fsched-verbose=<number> Set the verbosity level of the scheduler\n");
3713 #endif
3714 printf (" --help Display this information\n");
3716 undoc = 0;
3717 lang = "language";
3719 /* Display descriptions of language specific options.
3720 If there is no description, note that there is an undocumented option.
3721 If the description is empty, do not display anything. (This allows
3722 options to be deliberately undocumented, for whatever reason).
3723 If the option string is missing, then this is a marker, indicating
3724 that the description string is in fact the name of a language, whose
3725 language specific options are to follow. */
3727 if (NUM_ELEM (documented_lang_options) > 1)
3729 printf ("\nLanguage specific options:\n");
3731 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
3733 const char * description = documented_lang_options[i].description;
3734 const char * option = documented_lang_options[i].option;
3736 if (description == NULL)
3738 undoc = 1;
3740 if (extra_warnings)
3741 printf (" %-23.23s [undocumented]\n", option);
3743 else if (* description == 0)
3744 continue;
3745 else if (option == NULL)
3747 if (undoc)
3748 printf
3749 ("\nThere are undocumented %s specific options as well.\n",
3750 lang);
3751 undoc = 0;
3753 printf ("\n Options for %s:\n", description);
3755 lang = description;
3757 else
3758 printf (" %-23.23s %s\n", option, description);
3762 if (undoc)
3763 printf ("\nThere are undocumented %s specific options as well.\n", lang);
3765 if (NUM_ELEM (target_switches) > 1
3766 #ifdef TARGET_OPTIONS
3767 || NUM_ELEM (target_options) > 1
3768 #endif
3771 int doc = 0;
3773 undoc = 0;
3775 printf ("\nTarget specific options:\n");
3777 for (i = NUM_ELEM (target_switches); i--;)
3779 const char * option = target_switches[i].name;
3780 const char * description = target_switches[i].description;
3782 if (option == NULL || * option == 0)
3783 continue;
3784 else if (description == NULL)
3786 undoc = 1;
3788 if (extra_warnings)
3789 printf (" -m%-21.21s [undocumented]\n", option);
3791 else if (* description != 0)
3792 doc += printf (" -m%-21.21s %s\n", option, description);
3795 #ifdef TARGET_OPTIONS
3796 for (i = NUM_ELEM (target_options); i--;)
3798 const char * option = target_options[i].prefix;
3799 const char * description = target_options[i].description;
3801 if (option == NULL || * option == 0)
3802 continue;
3803 else if (description == NULL)
3805 undoc = 1;
3807 if (extra_warnings)
3808 printf (" -m%-21.21s [undocumented]\n", option);
3810 else if (* description != 0)
3811 doc += printf (" -m%-21.21s %s\n", option, description);
3813 #endif
3814 if (undoc)
3816 if (doc)
3817 printf ("\nThere are undocumented target specific options as well.\n");
3818 else
3819 printf (" They exist, but they are not documented.\n");
3824 /* Parse a -d... comand line switch. */
3826 static void
3827 decode_d_option (arg)
3828 const char * arg;
3830 int i, c, matched;
3832 while (*arg)
3833 switch (c = *arg++)
3835 case 'a':
3836 for (i = 0; i < DFI_MAX; ++i)
3837 dump_file[i].enabled = 1;
3838 break;
3839 case 'A':
3840 flag_debug_asm = 1;
3841 break;
3842 case 'm':
3843 flag_print_mem = 1;
3844 break;
3845 case 'p':
3846 flag_print_asm_name = 1;
3847 break;
3848 case 'v':
3849 graph_dump_format = vcg;
3850 break;
3851 case 'x':
3852 rtl_dump_and_exit = 1;
3853 break;
3854 case 'y':
3855 set_yydebug (1);
3856 break;
3857 case 'D': /* These are handled by the preprocessor. */
3858 case 'I':
3859 break;
3861 default:
3862 matched = 0;
3863 for (i = 0; i < DFI_MAX; ++i)
3864 if (c == dump_file[i].debug_switch)
3866 dump_file[i].enabled = 1;
3867 matched = 1;
3870 if (! matched)
3871 warning ("unrecognized gcc debugging option: %c", c);
3872 break;
3876 /* Parse a -f... comand line switch. ARG is the value after the -f.
3877 It is safe to access 'ARG - 2' to generate the full switch name.
3878 Return the number of strings consumed. */
3880 static int
3881 decode_f_option (arg)
3882 const char * arg;
3884 int j;
3886 /* Search for the option in the table of binary f options. */
3887 for (j = sizeof (f_options) / sizeof (f_options[0]); j--;)
3889 if (!strcmp (arg, f_options[j].string))
3891 *f_options[j].variable = f_options[j].on_value;
3892 return 1;
3895 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3896 && ! strcmp (arg + 3, f_options[j].string))
3898 *f_options[j].variable = ! f_options[j].on_value;
3899 return 1;
3903 if (!strncmp (arg, "inline-limit-", 13)
3904 || !strncmp (arg, "inline-limit=", 13))
3905 inline_max_insns =
3906 read_integral_parameter (arg + 13, arg - 2, inline_max_insns);
3907 #ifdef INSN_SCHEDULING
3908 else if (!strncmp (arg, "sched-verbose=", 14))
3909 fix_sched_param ("verbose", (const char *)(arg + 14));
3910 #endif
3911 else if (!strncmp (arg, "fixed-", 6))
3912 fix_register ((const char *)(arg + 6), 1, 1);
3913 else if (!strncmp (arg, "call-used-", 10))
3914 fix_register ((const char *)(arg + 10), 0, 1);
3915 else if (!strncmp (arg, "call-saved-", 11))
3916 fix_register ((const char *)(arg + 11), 0, 0);
3917 else if (!strncmp (arg, "align-loops=", 12))
3918 align_loops = read_integral_parameter (arg + 12, arg - 2, align_loops);
3919 else if (!strncmp (arg, "align-functions=", 16))
3920 align_functions
3921 = read_integral_parameter (arg + 16, arg - 2, align_functions);
3922 else if (!strncmp (arg, "align-jumps=", 12))
3923 align_jumps = read_integral_parameter (arg + 12, arg - 2, align_jumps);
3924 else if (!strncmp (arg, "align-labels=", 13))
3925 align_labels = read_integral_parameter (arg + 13, arg - 2, align_labels);
3926 else if (!strncmp (arg, "stack-limit-register=", 21))
3928 int reg = decode_reg_name (arg + 21);
3929 if (reg < 0)
3930 error ("unrecognized register name `%s'", arg + 21);
3931 else
3932 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
3934 else if (!strncmp (arg, "stack-limit-symbol=", 19))
3936 char *nm;
3937 if (ggc_p)
3938 nm = ggc_alloc_string (arg + 19, strlen (arg + 19));
3939 else
3940 nm = xstrdup (arg + 19);
3941 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
3943 else if (!strcmp (arg, "no-stack-limit"))
3944 stack_limit_rtx = NULL_RTX;
3945 else if (!strcmp (arg, "preprocessed"))
3946 /* Recognise this switch but do nothing. This prevents warnings
3947 about an unrecognized switch if cpplib has not been linked in. */
3949 else
3950 return 0;
3952 return 1;
3955 /* Parse a -W... comand line switch. ARG is the value after the -W.
3956 It is safe to access 'ARG - 2' to generate the full switch name.
3957 Return the number of strings consumed. */
3959 static int
3960 decode_W_option (arg)
3961 const char * arg;
3963 int j;
3965 /* Search for the option in the table of binary W options. */
3967 for (j = sizeof (W_options) / sizeof (W_options[0]); j--;)
3969 if (!strcmp (arg, W_options[j].string))
3971 *W_options[j].variable = W_options[j].on_value;
3972 return 1;
3975 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3976 && ! strcmp (arg + 3, W_options[j].string))
3978 *W_options[j].variable = ! W_options[j].on_value;
3979 return 1;
3983 if (!strncmp (arg, "id-clash-", 9))
3985 id_clash_len = read_integral_parameter (arg + 9, arg - 2, -1);
3987 if (id_clash_len != -1)
3988 warn_id_clash = 1;
3990 else if (!strncmp (arg, "larger-than-", 12))
3992 larger_than_size = read_integral_parameter (arg + 12, arg - 2, -1);
3994 if (larger_than_size != -1)
3995 warn_larger_than = 1;
3997 else
3998 return 0;
4000 return 1;
4003 /* Parse a -g... comand line switch. ARG is the value after the -g.
4004 It is safe to access 'ARG - 2' to generate the full switch name.
4005 Return the number of strings consumed. */
4007 static int
4008 decode_g_option (arg)
4009 const char * arg;
4011 unsigned level;
4012 /* A lot of code assumes write_symbols == NO_DEBUG if the
4013 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4014 of what debugging type has been selected). This records the
4015 selected type. It is an error to specify more than one
4016 debugging type. */
4017 static enum debug_info_type selected_debug_type = NO_DEBUG;
4018 /* Non-zero if debugging format has been explicitly set.
4019 -g and -ggdb don't explicitly set the debugging format so
4020 -gdwarf -g3 is equivalent to -gdwarf3. */
4021 static int type_explicitly_set_p = 0;
4022 /* Indexed by enum debug_info_type. */
4023 static const char * debug_type_names[] =
4025 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4028 /* The maximum admissible debug level value. */
4029 static const unsigned max_debug_level = 3;
4031 /* Look up ARG in the table. */
4032 for (da = debug_args; da->arg; da++)
4034 const int da_len = strlen (da->arg);
4036 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4038 enum debug_info_type type = da->debug_type;
4039 const char * p = arg + da_len;
4041 if (*p && (*p < '0' || *p > '9'))
4042 continue;
4044 /* A debug flag without a level defaults to level 2.
4045 Note we do not want to call read_integral_parameter
4046 for that case since it will call atoi which
4047 will return zero.
4049 ??? We may want to generalize the interface to
4050 read_integral_parameter to better handle this case
4051 if this case shows up often. */
4052 if (*p)
4053 level = read_integral_parameter (p, 0, max_debug_level + 1);
4054 else
4055 level = 2;
4057 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4059 error ("use -gdwarf -g%d for DWARF v1, level %d",
4060 level, level);
4061 if (level == 2)
4062 error ("use -gdwarf-2 for DWARF v2");
4065 if (level > max_debug_level)
4067 warning ("\
4068 ignoring option `%s' due to invalid debug level specification",
4069 arg - 2);
4070 level = debug_info_level;
4073 if (type == NO_DEBUG)
4075 type = PREFERRED_DEBUGGING_TYPE;
4077 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4079 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4080 type = DWARF2_DEBUG;
4081 #else
4082 #ifdef DBX_DEBUGGING_INFO
4083 type = DBX_DEBUG;
4084 #endif
4085 #endif
4089 if (type == NO_DEBUG)
4090 warning ("`%s': unknown or unsupported -g option", arg - 2);
4092 /* Does it conflict with an already selected type? */
4093 if (type_explicitly_set_p
4094 /* -g/-ggdb don't conflict with anything */
4095 && da->debug_type != NO_DEBUG
4096 && type != selected_debug_type)
4097 warning ("`%s' ignored, conflicts with `-g%s'",
4098 arg - 2, debug_type_names[(int) selected_debug_type]);
4099 else
4101 /* If the format has already been set, -g/-ggdb
4102 only change the debug level. */
4103 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4104 ; /* don't change debugging type */
4105 else
4107 selected_debug_type = type;
4108 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4111 write_symbols = (level == 0
4112 ? NO_DEBUG
4113 : selected_debug_type);
4114 use_gnu_debug_info_extensions = da->use_extensions_p;
4115 debug_info_level = (enum debug_info_level) level;
4118 break;
4122 if (! da->arg)
4123 warning ("`%s': unknown or unsupported -g option", arg - 2);
4125 return 1;
4128 /* Decode the first argument in the argv as a language-independent option.
4129 Return the number of strings consumed. 'strings_processed' is the
4130 number of strings that have already been decoded in a language
4131 specific fashion before this function was invoked. */
4133 static unsigned int
4134 independent_decode_option (argc, argv, strings_processed)
4135 int argc;
4136 char **argv;
4137 unsigned int strings_processed;
4139 char *arg = argv[0];
4141 if (arg[0] != '-' || arg[1] == 0)
4143 if (arg[0] == '+')
4144 return 0;
4146 filename = arg;
4148 return 1;
4151 arg ++;
4153 if (!strcmp (arg, "-help"))
4155 display_help ();
4156 exit (0);
4159 if (* arg == 'Y')
4160 arg ++;
4162 switch (*arg)
4164 default:
4165 return 0;
4167 case 'O':
4168 /* Already been treated in main (). Do nothing. */
4169 break;
4171 case 'm':
4172 set_target_switch (arg + 1);
4173 break;
4175 case 'f':
4176 return decode_f_option (arg + 1);
4178 case 'g':
4179 if (strings_processed == 0)
4180 return decode_g_option (arg + 1);
4181 else
4182 return strings_processed;
4184 case 'd':
4185 if (!strcmp (arg, "dumpbase"))
4187 if (argc == 1)
4188 return 0;
4190 dump_base_name = argv[1];
4191 return 2;
4193 else
4194 decode_d_option (arg + 1);
4195 break;
4197 case 'p':
4198 if (!strcmp (arg, "pedantic"))
4199 pedantic = 1;
4200 else if (!strcmp (arg, "pedantic-errors"))
4201 flag_pedantic_errors = pedantic = 1;
4202 else if (arg[1] == 0)
4203 profile_flag = 1;
4204 else
4205 return 0;
4206 break;
4208 case 'q':
4209 if (!strcmp (arg, "quiet"))
4210 quiet_flag = 1;
4211 else
4212 return 0;
4213 break;
4215 case 'v':
4216 if (!strcmp (arg, "version"))
4217 version_flag = 1;
4218 else
4219 return 0;
4220 break;
4222 case 'w':
4223 if (arg[1] == 0)
4224 inhibit_warnings = 1;
4225 else
4226 return 0;
4227 break;
4229 case 'W':
4230 if (arg[1] == 0)
4232 extra_warnings = 1;
4233 /* We save the value of warn_uninitialized, since if they put
4234 -Wuninitialized on the command line, we need to generate a
4235 warning about not using it without also specifying -O. */
4236 if (warn_uninitialized != 1)
4237 warn_uninitialized = 2;
4239 else
4240 return decode_W_option (arg + 1);
4241 break;
4243 case 'a':
4244 if (arg[1] == 0)
4246 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4247 warning ("`-a' option (basic block profile) not supported");
4248 #else
4249 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4250 #endif
4252 else if (!strcmp (arg, "ax"))
4254 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4255 warning ("`-ax' option (jump profiling) not supported");
4256 #else
4257 profile_block_flag = (!profile_block_flag
4258 || profile_block_flag == 2) ? 2 : 3;
4259 #endif
4261 else if (!strncmp (arg, "aux-info", 8))
4263 flag_gen_aux_info = 1;
4264 if (arg[8] == '\0')
4266 if (argc == 1)
4267 return 0;
4269 aux_info_file_name = argv[1];
4270 return 2;
4272 else
4273 aux_info_file_name = arg + 8;
4275 else
4276 return 0;
4277 break;
4279 case 'o':
4280 if (arg[1] == 0)
4282 if (argc == 1)
4283 return 0;
4285 asm_file_name = argv[1];
4286 return 2;
4288 return 0;
4290 case 'G':
4292 int g_switch_val;
4293 int return_val;
4295 if (arg[1] == 0)
4297 if (argc == 1)
4298 return 0;
4300 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4301 return_val = 2;
4303 else
4305 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4306 return_val = 1;
4309 if (g_switch_val == -1)
4310 return_val = 0;
4311 else
4313 g_switch_set = TRUE;
4314 g_switch_value = g_switch_val;
4317 return return_val;
4321 return 1;
4324 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4325 Exit code is 35 if can't open files, 34 if fatal error,
4326 33 if had nonfatal errors, else success. */
4328 extern int main PARAMS ((int, char **));
4331 main (argc, argv)
4332 int argc;
4333 char **argv;
4335 register int i;
4336 char *p;
4338 /* save in case md file wants to emit args as a comment. */
4339 save_argc = argc;
4340 save_argv = argv;
4342 p = argv[0] + strlen (argv[0]);
4343 while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
4344 --p;
4345 progname = p;
4347 #ifdef HAVE_LC_MESSAGES
4348 setlocale (LC_MESSAGES, "");
4349 #endif
4350 (void) bindtextdomain (PACKAGE, localedir);
4351 (void) textdomain (PACKAGE);
4353 signal (SIGFPE, float_signal);
4355 #ifdef SIGPIPE
4356 signal (SIGPIPE, pipe_closed);
4357 #endif
4359 decl_printable_name = decl_name;
4360 lang_expand_expr = (lang_expand_expr_t) do_abort;
4362 /* Initialize whether `char' is signed. */
4363 flag_signed_char = DEFAULT_SIGNED_CHAR;
4364 #ifdef DEFAULT_SHORT_ENUMS
4365 /* Initialize how much space enums occupy, by default. */
4366 flag_short_enums = DEFAULT_SHORT_ENUMS;
4367 #endif
4369 /* Initialize the garbage-collector. */
4370 init_ggc ();
4371 ggc_add_root (&input_file_stack, 1, sizeof input_file_stack,
4372 mark_file_stack);
4373 ggc_add_rtx_root (&stack_limit_rtx, 1);
4374 ggc_add_tree_root (&current_function_decl, 1);
4375 ggc_add_tree_root (&current_function_func_begin_label, 1);
4377 /* Perform language-specific options intialization. */
4378 lang_init_options ();
4380 /* Scan to see what optimization level has been specified. That will
4381 determine the default value of many flags. */
4382 for (i = 1; i < argc; i++)
4384 if (!strcmp (argv[i], "-O"))
4386 optimize = 1;
4387 optimize_size = 0;
4389 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4391 /* Handle -Os, -O2, -O3, -O69, ... */
4392 char *p = &argv[i][2];
4394 if ((p[0] == 's') && (p[1] == 0))
4396 optimize_size = 1;
4398 /* Optimizing for size forces optimize to be 2. */
4399 optimize = 2;
4401 else
4403 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4404 if (optimize_val != -1)
4406 optimize = optimize_val;
4407 optimize_size = 0;
4413 if (optimize >= 1)
4415 flag_defer_pop = 1;
4416 flag_thread_jumps = 1;
4417 #ifdef DELAY_SLOTS
4418 flag_delayed_branch = 1;
4419 #endif
4420 #ifdef CAN_DEBUG_WITHOUT_FP
4421 flag_omit_frame_pointer = 1;
4422 #endif
4425 if (optimize >= 2)
4427 flag_optimize_sibling_calls = 1;
4428 flag_cse_follow_jumps = 1;
4429 flag_cse_skip_blocks = 1;
4430 flag_gcse = 1;
4431 flag_expensive_optimizations = 1;
4432 flag_strength_reduce = 1;
4433 flag_rerun_cse_after_loop = 1;
4434 flag_rerun_loop_opt = 1;
4435 flag_caller_saves = 1;
4436 flag_force_mem = 1;
4437 flag_peephole2 = 1;
4438 #ifdef INSN_SCHEDULING
4439 flag_schedule_insns = 1;
4440 flag_schedule_insns_after_reload = 1;
4441 #endif
4442 flag_regmove = 1;
4443 flag_strict_aliasing = 1;
4444 flag_delete_null_pointer_checks = 1;
4447 if (optimize >= 3)
4449 flag_inline_functions = 1;
4452 if (optimize < 2 || optimize_size)
4454 align_loops = 1;
4455 align_jumps = 1;
4456 align_labels = 1;
4457 align_functions = 1;
4460 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4461 modify it. */
4462 target_flags = 0;
4463 set_target_switch ("");
4465 #ifdef OPTIMIZATION_OPTIONS
4466 /* Allow default optimizations to be specified on a per-machine basis. */
4467 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4468 #endif
4470 /* Initialize register usage now so switches may override. */
4471 init_reg_sets ();
4473 /* Perform normal command line switch decoding. */
4474 for (i = 1; i < argc;)
4476 unsigned int lang_processed;
4477 unsigned int indep_processed;
4479 /* Give the language a chance to decode the option for itself. */
4480 lang_processed = lang_decode_option (argc - i, argv + i);
4482 /* Now see if the option also has a language independent meaning.
4483 Some options are both language specific and language independent,
4484 eg --help. It is possible that there might be options that should
4485 only be decoded in a language independent way if they were not
4486 decoded in a langauge specific way, which is why 'lang_processed'
4487 is passed in. */
4488 indep_processed = independent_decode_option (argc - i, argv + i,
4489 lang_processed);
4491 if (lang_processed || indep_processed)
4492 i += (lang_processed > indep_processed
4493 ? lang_processed : indep_processed);
4494 else
4496 const char * option = NULL;
4497 const char * lang = NULL;
4498 unsigned int j;
4500 /* It is possible that the command line switch is not valid for the
4501 current language, but it is valid for another language. In order
4502 to be compatible with previous versions of the compiler (which
4503 did not issue an error message in this case) we check for this
4504 possibilty here. If we do find a match, then if extra_warnings
4505 is set we generate a warning message, otherwise we will just
4506 ignore the option. */
4507 for (j = 0; j < NUM_ELEM (documented_lang_options); j++)
4509 option = documented_lang_options[j].option;
4511 if (option == NULL)
4512 lang = documented_lang_options[j].description;
4513 else if (! strncmp (argv[i], option, strlen (option)))
4514 break;
4517 if (j != NUM_ELEM (documented_lang_options))
4519 if (extra_warnings)
4521 warning ("Ignoring command line option '%s'", argv[i]);
4522 if (lang)
4523 warning ("\
4524 (It is valid for %s but not the selected langauge)", lang);
4527 else
4528 error ("Unrecognized option `%s'", argv[i]);
4530 i++;
4534 /* Checker uses the frame pointer. */
4535 if (flag_check_memory_usage)
4536 flag_omit_frame_pointer = 0;
4538 if (optimize == 0)
4540 /* Inlining does not work if not optimizing,
4541 so force it not to be done. */
4542 flag_no_inline = 1;
4543 warn_inline = 0;
4545 /* The c_decode_option and lang_decode_option functions set
4546 this to `2' if -Wall is used, so we can avoid giving out
4547 lots of errors for people who don't realize what -Wall does. */
4548 if (warn_uninitialized == 1)
4549 warning ("-Wuninitialized is not supported without -O");
4552 #ifdef OVERRIDE_OPTIONS
4553 /* Some machines may reject certain combinations of options. */
4554 OVERRIDE_OPTIONS;
4555 #endif
4557 if (exceptions_via_longjmp == 2)
4559 #ifdef DWARF2_UNWIND_INFO
4560 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4561 #else
4562 exceptions_via_longjmp = 1;
4563 #endif
4566 /* Set up the align_*_log variables, defaulting them to 1 if they
4567 were still unset. */
4568 if (align_loops <= 0) align_loops = 1;
4569 align_loops_log = floor_log2 (align_loops*2-1);
4570 if (align_jumps <= 0) align_jumps = 1;
4571 align_jumps_log = floor_log2 (align_jumps*2-1);
4572 if (align_labels <= 0) align_labels = 1;
4573 align_labels_log = floor_log2 (align_labels*2-1);
4574 if (align_functions <= 0) align_functions = 1;
4575 align_functions_log = floor_log2 (align_functions*2-1);
4577 if (profile_block_flag == 3)
4579 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4580 profile_block_flag = 2;
4583 /* Unrolling all loops implies that standard loop unrolling must also
4584 be done. */
4585 if (flag_unroll_all_loops)
4586 flag_unroll_loops = 1;
4587 /* Loop unrolling requires that strength_reduction be on also. Silently
4588 turn on strength reduction here if it isn't already on. Also, the loop
4589 unrolling code assumes that cse will be run after loop, so that must
4590 be turned on also. */
4591 if (flag_unroll_loops)
4593 flag_strength_reduce = 1;
4594 flag_rerun_cse_after_loop = 1;
4597 /* Warn about options that are not supported on this machine. */
4598 #ifndef INSN_SCHEDULING
4599 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4600 warning ("instruction scheduling not supported on this target machine");
4601 #endif
4602 #ifndef DELAY_SLOTS
4603 if (flag_delayed_branch)
4604 warning ("this target machine does not have delayed branches");
4605 #endif
4607 user_label_prefix = USER_LABEL_PREFIX;
4608 if (flag_leading_underscore != -1)
4610 /* If the default prefix is more complicated than "" or "_",
4611 issue a warning and ignore this option. */
4612 if (user_label_prefix[0] == 0 ||
4613 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4615 user_label_prefix = flag_leading_underscore ? "_" : "";
4617 else
4618 warning ("-f%sleading-underscore not supported on this target machine",
4619 flag_leading_underscore ? "" : "no-");
4622 /* If we are in verbose mode, write out the version and maybe all the
4623 option flags in use. */
4624 if (version_flag)
4626 print_version (stderr, "");
4627 if (! quiet_flag)
4628 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4631 compile_file (filename);
4633 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
4634 if (flag_print_mem)
4636 char *lim = (char *) sbrk (0);
4638 fnotice (stderr, "Data size %ld.\n", (long) (lim - (char *) &environ));
4639 fflush (stderr);
4641 #ifndef __MSDOS__
4642 #ifdef USG
4643 system ("ps -l 1>&2");
4644 #else /* not USG */
4645 system ("ps v");
4646 #endif /* not USG */
4647 #endif
4649 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
4651 if (errorcount)
4652 return (FATAL_EXIT_CODE);
4653 if (sorrycount)
4654 return (FATAL_EXIT_CODE);
4655 return (SUCCESS_EXIT_CODE);
4658 /* Decode -m switches. */
4659 /* Decode the switch -mNAME. */
4661 static void
4662 set_target_switch (name)
4663 const char *name;
4665 register size_t j;
4666 int valid_target_option = 0;
4668 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4669 if (!strcmp (target_switches[j].name, name))
4671 if (target_switches[j].value < 0)
4672 target_flags &= ~-target_switches[j].value;
4673 else
4674 target_flags |= target_switches[j].value;
4675 valid_target_option = 1;
4678 #ifdef TARGET_OPTIONS
4679 if (!valid_target_option)
4680 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4682 int len = strlen (target_options[j].prefix);
4683 if (!strncmp (target_options[j].prefix, name, len))
4685 *target_options[j].variable = name + len;
4686 valid_target_option = 1;
4689 #endif
4691 if (!valid_target_option)
4692 error ("Invalid option `%s'", name);
4695 /* Print version information to FILE.
4696 Each line begins with INDENT (for the case where FILE is the
4697 assembler output file). */
4699 static void
4700 print_version (file, indent)
4701 FILE *file;
4702 const char *indent;
4704 #ifndef __VERSION__
4705 #define __VERSION__ "[?]"
4706 #endif
4707 fnotice (file,
4708 #ifdef __GNUC__
4709 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
4710 #else
4711 "%s%s%s version %s (%s) compiled by CC.\n"
4712 #endif
4713 , indent, *indent != 0 ? " " : "",
4714 language_string, version_string, TARGET_NAME, __VERSION__);
4717 /* Print an option value and return the adjusted position in the line.
4718 ??? We don't handle error returns from fprintf (disk full); presumably
4719 other code will catch a disk full though. */
4721 static int
4722 print_single_switch (file, pos, max, indent, sep, term, type, name)
4723 FILE *file;
4724 int pos, max;
4725 const char *indent, *sep, *term, *type, *name;
4727 /* The ultrix fprintf returns 0 on success, so compute the result we want
4728 here since we need it for the following test. */
4729 int len = strlen (sep) + strlen (type) + strlen (name);
4731 if (pos != 0
4732 && pos + len > max)
4734 fprintf (file, "%s", term);
4735 pos = 0;
4737 if (pos == 0)
4739 fprintf (file, "%s", indent);
4740 pos = strlen (indent);
4742 fprintf (file, "%s%s%s", sep, type, name);
4743 pos += len;
4744 return pos;
4747 /* Print active target switches to FILE.
4748 POS is the current cursor position and MAX is the size of a "line".
4749 Each line begins with INDENT and ends with TERM.
4750 Each switch is separated from the next by SEP. */
4752 static void
4753 print_switch_values (file, pos, max, indent, sep, term)
4754 FILE *file;
4755 int pos, max;
4756 const char *indent, *sep, *term;
4758 size_t j;
4759 char **p;
4761 /* Print the options as passed. */
4763 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4764 _("options passed: "), "");
4766 for (p = &save_argv[1]; *p != NULL; p++)
4767 if (**p == '-')
4769 /* Ignore these. */
4770 if (strcmp (*p, "-o") == 0)
4772 if (p[1] != NULL)
4773 p++;
4774 continue;
4776 if (strcmp (*p, "-quiet") == 0)
4777 continue;
4778 if (strcmp (*p, "-version") == 0)
4779 continue;
4780 if ((*p)[1] == 'd')
4781 continue;
4783 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4785 if (pos > 0)
4786 fprintf (file, "%s", term);
4788 /* Print the -f and -m options that have been enabled.
4789 We don't handle language specific options but printing argv
4790 should suffice. */
4792 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4793 _("options enabled: "), "");
4795 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4796 if (*f_options[j].variable == f_options[j].on_value)
4797 pos = print_single_switch (file, pos, max, indent, sep, term,
4798 "-f", f_options[j].string);
4800 /* Print target specific options. */
4802 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4803 if (target_switches[j].name[0] != '\0'
4804 && target_switches[j].value > 0
4805 && ((target_switches[j].value & target_flags)
4806 == target_switches[j].value))
4808 pos = print_single_switch (file, pos, max, indent, sep, term,
4809 "-m", target_switches[j].name);
4812 #ifdef TARGET_OPTIONS
4813 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4814 if (*target_options[j].variable != NULL)
4816 char prefix[256];
4817 sprintf (prefix, "-m%s", target_options[j].prefix);
4818 pos = print_single_switch (file, pos, max, indent, sep, term,
4819 prefix, *target_options[j].variable);
4821 #endif
4823 fprintf (file, "%s", term);
4826 /* Record the beginning of a new source file, named FILENAME. */
4828 void
4829 debug_start_source_file (filename)
4830 register const char *filename ATTRIBUTE_UNUSED;
4832 #ifdef DBX_DEBUGGING_INFO
4833 if (write_symbols == DBX_DEBUG)
4834 dbxout_start_new_source_file (filename);
4835 #endif
4836 #ifdef DWARF_DEBUGGING_INFO
4837 if (debug_info_level == DINFO_LEVEL_VERBOSE
4838 && write_symbols == DWARF_DEBUG)
4839 dwarfout_start_new_source_file (filename);
4840 #endif /* DWARF_DEBUGGING_INFO */
4841 #ifdef DWARF2_DEBUGGING_INFO
4842 if (debug_info_level == DINFO_LEVEL_VERBOSE
4843 && write_symbols == DWARF2_DEBUG)
4844 dwarf2out_start_source_file (filename);
4845 #endif /* DWARF2_DEBUGGING_INFO */
4846 #ifdef SDB_DEBUGGING_INFO
4847 if (write_symbols == SDB_DEBUG)
4848 sdbout_start_new_source_file (filename);
4849 #endif
4852 /* Record the resumption of a source file. LINENO is the line number in
4853 the source file we are returning to. */
4855 void
4856 debug_end_source_file (lineno)
4857 register unsigned lineno ATTRIBUTE_UNUSED;
4859 #ifdef DBX_DEBUGGING_INFO
4860 if (write_symbols == DBX_DEBUG)
4861 dbxout_resume_previous_source_file ();
4862 #endif
4863 #ifdef DWARF_DEBUGGING_INFO
4864 if (debug_info_level == DINFO_LEVEL_VERBOSE
4865 && write_symbols == DWARF_DEBUG)
4866 dwarfout_resume_previous_source_file (lineno);
4867 #endif /* DWARF_DEBUGGING_INFO */
4868 #ifdef DWARF2_DEBUGGING_INFO
4869 if (debug_info_level == DINFO_LEVEL_VERBOSE
4870 && write_symbols == DWARF2_DEBUG)
4871 dwarf2out_end_source_file ();
4872 #endif /* DWARF2_DEBUGGING_INFO */
4873 #ifdef SDB_DEBUGGING_INFO
4874 if (write_symbols == SDB_DEBUG)
4875 sdbout_resume_previous_source_file ();
4876 #endif
4879 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4880 the tail part of the directive line, i.e. the part which is past the
4881 initial whitespace, #, whitespace, directive-name, whitespace part. */
4883 void
4884 debug_define (lineno, buffer)
4885 register unsigned lineno ATTRIBUTE_UNUSED;
4886 register char *buffer ATTRIBUTE_UNUSED;
4888 #ifdef DWARF_DEBUGGING_INFO
4889 if (debug_info_level == DINFO_LEVEL_VERBOSE
4890 && write_symbols == DWARF_DEBUG)
4891 dwarfout_define (lineno, buffer);
4892 #endif /* DWARF_DEBUGGING_INFO */
4893 #ifdef DWARF2_DEBUGGING_INFO
4894 if (debug_info_level == DINFO_LEVEL_VERBOSE
4895 && write_symbols == DWARF2_DEBUG)
4896 dwarf2out_define (lineno, buffer);
4897 #endif /* DWARF2_DEBUGGING_INFO */
4900 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4901 the tail part of the directive line, i.e. the part which is past the
4902 initial whitespace, #, whitespace, directive-name, whitespace part. */
4904 void
4905 debug_undef (lineno, buffer)
4906 register unsigned lineno ATTRIBUTE_UNUSED;
4907 register char *buffer ATTRIBUTE_UNUSED;
4909 #ifdef DWARF_DEBUGGING_INFO
4910 if (debug_info_level == DINFO_LEVEL_VERBOSE
4911 && write_symbols == DWARF_DEBUG)
4912 dwarfout_undef (lineno, buffer);
4913 #endif /* DWARF_DEBUGGING_INFO */
4914 #ifdef DWARF2_DEBUGGING_INFO
4915 if (debug_info_level == DINFO_LEVEL_VERBOSE
4916 && write_symbols == DWARF2_DEBUG)
4917 dwarf2out_undef (lineno, buffer);
4918 #endif /* DWARF2_DEBUGGING_INFO */
4921 /* Returns nonzero if it is appropriate not to emit any debugging
4922 information for BLOCK, because it doesn't contain any instructions.
4923 This may not be the case for blocks containing nested functions, since
4924 we may actually call such a function even though the BLOCK information
4925 is messed up. */
4928 debug_ignore_block (block)
4929 tree block ATTRIBUTE_UNUSED;
4931 /* Never delete the BLOCK for the outermost scope
4932 of the function; we can refer to names from
4933 that scope even if the block notes are messed up. */
4934 if (is_body_block (block))
4935 return 0;
4937 #ifdef DWARF2_DEBUGGING_INFO
4938 if (write_symbols == DWARF2_DEBUG)
4939 return dwarf2out_ignore_block (block);
4940 #endif
4942 return 1;