* tree.h (TYPE_IS_SIZETYPE): Add more documentation.
[official-gcc.git] / gcc / toplev.c
blob83653119a4b84e3cfd30b835cddce697abb0d0f2
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 "hard-reg-set.h"
51 #include "recog.h"
52 #include "defaults.h"
53 #include "output.h"
54 #include "except.h"
55 #include "function.h"
56 #include "toplev.h"
57 #include "expr.h"
58 #include "basic-block.h"
59 #include "intl.h"
60 #include "ggc.h"
61 #include "graph.h"
62 #include "loop.h"
63 #include "regs.h"
64 #include "timevar.h"
65 #include "diagnostic.h"
66 #include "ssa.h"
68 #ifndef ACCUMULATE_OUTGOING_ARGS
69 #define ACCUMULATE_OUTGOING_ARGS 0
70 #endif
72 #ifdef DWARF_DEBUGGING_INFO
73 #include "dwarfout.h"
74 #endif
76 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
77 #include "dwarf2out.h"
78 #endif
80 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
81 #include "dbxout.h"
82 #endif
84 #ifdef SDB_DEBUGGING_INFO
85 #include "sdbout.h"
86 #endif
88 #ifdef XCOFF_DEBUGGING_INFO
89 #include "xcoffout.h"
90 #endif
92 #ifdef VMS
93 /* The extra parameters substantially improve the I/O performance. */
95 static FILE *
96 vms_fopen (fname, type)
97 char *fname;
98 char *type;
100 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
101 fixed arguments, which matches ANSI's specification but not VAXCRTL's
102 pre-ANSI implementation. This hack circumvents the mismatch problem. */
103 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
105 if (*type == 'w')
106 return (*vmslib_fopen) (fname, type, "mbc=32",
107 "deq=64", "fop=tef", "shr=nil");
108 else
109 return (*vmslib_fopen) (fname, type, "mbc=32");
112 #define fopen vms_fopen
113 #endif /* VMS */
115 #ifndef DEFAULT_GDB_EXTENSIONS
116 #define DEFAULT_GDB_EXTENSIONS 1
117 #endif
119 /* If more than one debugging type is supported, you must define
120 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
122 This is one long line cause VAXC can't handle a \-newline. */
123 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
124 #ifndef PREFERRED_DEBUGGING_TYPE
125 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
126 #endif /* no PREFERRED_DEBUGGING_TYPE */
127 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
128 so the following code needn't care. */
129 #ifdef DBX_DEBUGGING_INFO
130 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
131 #endif
132 #ifdef SDB_DEBUGGING_INFO
133 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
134 #endif
135 #ifdef DWARF_DEBUGGING_INFO
136 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
137 #endif
138 #ifdef DWARF2_DEBUGGING_INFO
139 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
140 #endif
141 #ifdef XCOFF_DEBUGGING_INFO
142 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
143 #endif
144 #endif /* More than one debugger format enabled. */
146 /* If still not defined, must have been because no debugging formats
147 are supported. */
148 #ifndef PREFERRED_DEBUGGING_TYPE
149 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
150 #endif
152 #if defined (HAVE_DECL_ENVIRON) && !HAVE_DECL_ENVIRON
153 extern char **environ;
154 #endif
156 /* Carry information from ASM_DECLARE_OBJECT_NAME
157 to ASM_FINISH_DECLARE_OBJECT. */
159 extern int size_directive_output;
160 extern tree last_assemble_variable_decl;
162 static void set_target_switch PARAMS ((const char *));
163 static const char *decl_name PARAMS ((tree, int));
165 static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
166 static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
167 #ifdef ASM_IDENTIFY_LANGUAGE
168 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
169 static void output_lang_identify PARAMS ((FILE *)) ATTRIBUTE_UNUSED;
170 #endif
171 static void compile_file PARAMS ((const char *));
172 static void display_help PARAMS ((void));
173 static void display_target_options PARAMS ((void));
174 static void mark_file_stack PARAMS ((void *));
176 static void decode_d_option PARAMS ((const char *));
177 static int decode_f_option PARAMS ((const char *));
178 static int decode_W_option PARAMS ((const char *));
179 static int decode_g_option PARAMS ((const char *));
180 static unsigned int independent_decode_option PARAMS ((int, char **));
182 static void print_version PARAMS ((FILE *, const char *));
183 static int print_single_switch PARAMS ((FILE *, int, int, const char *,
184 const char *, const char *,
185 const char *, const char *));
186 static void print_switch_values PARAMS ((FILE *, int, int, const char *,
187 const char *, const char *));
189 /* Length of line when printing switch values. */
190 #define MAX_LINE 75
192 /* Name of program invoked, sans directories. */
194 const char *progname;
196 /* Copy of arguments to main. */
197 int save_argc;
198 char **save_argv;
200 /* Name of current original source file (what was input to cpp).
201 This comes from each #-command in the actual input. */
203 const char *input_filename;
205 /* Name of top-level original source file (what was input to cpp).
206 This comes from the #-command at the beginning of the actual input.
207 If there isn't any there, then this is the cc1 input file name. */
209 const char *main_input_filename;
211 /* Current line number in real source file. */
213 int lineno;
215 /* Nonzero if it is unsafe to create any new pseudo registers. */
216 int no_new_pseudos;
218 /* Stack of currently pending input files. */
220 struct file_stack *input_file_stack;
222 /* Incremented on each change to input_file_stack. */
223 int input_file_stack_tick;
225 /* Name to use as base of names for dump output files. */
227 const char *dump_base_name;
229 /* Bit flags that specify the machine subtype we are compiling for.
230 Bits are tested using macros TARGET_... defined in the tm.h file
231 and set by `-m...' switches. Must be defined in rtlanal.c. */
233 extern int target_flags;
235 /* Describes a dump file. */
237 struct dump_file_info
239 /* The unique extension to apply, e.g. ".jump". */
240 const char *const extension;
242 /* The -d<c> character that enables this dump file. */
243 char const debug_switch;
245 /* True if there is a corresponding graph dump file. */
246 char const graph_dump_p;
248 /* True if the user selected this dump. */
249 char enabled;
251 /* True if the files have been initialized (ie truncated). */
252 char initialized;
255 /* Enumerate the extant dump files. */
257 enum dump_file_index
259 DFI_rtl,
260 DFI_sibling,
261 DFI_jump,
262 DFI_cse,
263 DFI_addressof,
264 DFI_ssa,
265 DFI_dce,
266 DFI_ussa,
267 DFI_gcse,
268 DFI_loop,
269 DFI_cse2,
270 DFI_cfg,
271 DFI_bp,
272 DFI_life,
273 DFI_combine,
274 DFI_ce,
275 DFI_regmove,
276 DFI_sched,
277 DFI_lreg,
278 DFI_greg,
279 DFI_flow2,
280 DFI_ce2,
281 DFI_peephole2,
282 DFI_rnreg,
283 DFI_sched2,
284 DFI_bbro,
285 DFI_jump2,
286 DFI_mach,
287 DFI_dbr,
288 DFI_stack,
289 DFI_MAX
292 /* Describes all the dump files. Should be kept in order of the
293 pass and in sync with dump_file_index above.
295 Remaining -d letters:
297 " h o q u "
298 " H K OPQ TUVW YZ"
301 struct dump_file_info dump_file[DFI_MAX] =
303 { "rtl", 'r', 0, 0, 0 },
304 { "sibling", 'i', 0, 0, 0 },
305 { "jump", 'j', 0, 0, 0 },
306 { "cse", 's', 0, 0, 0 },
307 { "addressof", 'F', 0, 0, 0 },
308 { "ssa", 'e', 1, 0, 0 },
309 { "dce", 'X', 1, 0, 0 },
310 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
311 { "gcse", 'G', 1, 0, 0 },
312 { "loop", 'L', 1, 0, 0 },
313 { "cse2", 't', 1, 0, 0 },
314 { "cfg", 'f', 1, 0, 0 },
315 { "bp", 'b', 1, 0, 0 },
316 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
317 { "combine", 'c', 1, 0, 0 },
318 { "ce", 'C', 1, 0, 0 },
319 { "regmove", 'N', 1, 0, 0 },
320 { "sched", 'S', 1, 0, 0 },
321 { "lreg", 'l', 1, 0, 0 },
322 { "greg", 'g', 1, 0, 0 },
323 { "flow2", 'w', 1, 0, 0 },
324 { "ce2", 'E', 1, 0, 0 },
325 { "peephole2", 'z', 1, 0, 0 },
326 { "rnreg", 'n', 1, 0, 0 },
327 { "sched2", 'R', 1, 0, 0 },
328 { "bbro", 'B', 1, 0, 0 },
329 { "jump2", 'J', 1, 0, 0 },
330 { "mach", 'M', 1, 0, 0 },
331 { "dbr", 'd', 0, 0, 0 },
332 { "stack", 'k', 1, 0, 0 },
335 static int open_dump_file PARAMS ((enum dump_file_index, tree));
336 static void close_dump_file PARAMS ((enum dump_file_index,
337 void (*) (FILE *, rtx), rtx));
339 /* Other flags saying which kinds of debugging dump have been requested. */
341 int rtl_dump_and_exit;
342 int flag_print_asm_name;
343 static int flag_print_mem;
344 static int version_flag;
345 static char *filename;
346 enum graph_dump_types graph_dump_format;
348 /* Name for output file of assembly code, specified with -o. */
350 char *asm_file_name;
352 /* Value of the -G xx switch, and whether it was passed or not. */
353 int g_switch_value;
354 int g_switch_set;
356 /* Type(s) of debugging information we are producing (if any).
357 See flags.h for the definitions of the different possible
358 types of debugging information. */
359 enum debug_info_type write_symbols = NO_DEBUG;
361 /* Level of debugging information we are producing. See flags.h
362 for the definitions of the different possible levels. */
363 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
365 /* Nonzero means use GNU-only extensions in the generated symbolic
366 debugging information. */
367 /* Currently, this only has an effect when write_symbols is set to
368 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
369 int use_gnu_debug_info_extensions = 0;
371 /* Nonzero means do optimizations. -O.
372 Particular numeric values stand for particular amounts of optimization;
373 thus, -O2 stores 2 here. However, the optimizations beyond the basic
374 ones are not controlled directly by this variable. Instead, they are
375 controlled by individual `flag_...' variables that are defaulted
376 based on this variable. */
378 int optimize = 0;
380 /* Nonzero means optimize for size. -Os.
381 The only valid values are zero and non-zero. When optimize_size is
382 non-zero, optimize defaults to 2, but certain individual code
383 bloating optimizations are disabled. */
385 int optimize_size = 0;
387 /* Number of error messages and warning messages so far. */
389 int errorcount = 0;
390 int warningcount = 0;
391 int sorrycount = 0;
393 /* The FUNCTION_DECL for the function currently being compiled,
394 or 0 if between functions. */
395 tree current_function_decl;
397 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
398 if none. */
399 tree current_function_func_begin_label;
401 /* Pointer to function to compute the name to use to print a declaration.
402 DECL is the declaration in question.
403 VERBOSITY determines what information will be printed:
404 0: DECL_NAME, demangled as necessary.
405 1: and scope information.
406 2: and any other information that might be interesting, such as function
407 parameter types in C++. */
409 const char *(*decl_printable_name) PARAMS ((tree, int));
411 /* Pointer to function to compute rtl for a language-specific tree code. */
413 typedef rtx (*lang_expand_expr_t)
414 PARAMS ((union tree_node *, rtx, enum machine_mode,
415 enum expand_modifier modifier));
417 lang_expand_expr_t lang_expand_expr = 0;
419 tree (*lang_expand_constant) PARAMS ((tree)) = 0;
421 /* Pointer to function to finish handling an incomplete decl at the
422 end of compilation. */
424 void (*incomplete_decl_finalize_hook) PARAMS ((tree)) = 0;
426 /* Nonzero if doing dwarf2 duplicate elimination. */
428 int flag_eliminate_dwarf2_dups = 0;
430 /* Nonzero if generating code to do profiling. */
432 int profile_flag = 0;
434 /* Nonzero if generating code to do profiling on a line-by-line basis. */
436 int profile_block_flag;
438 /* Nonzero if generating code to profile program flow graph arcs. */
440 int profile_arc_flag = 0;
442 /* Nonzero if generating info for gcov to calculate line test coverage. */
444 int flag_test_coverage = 0;
446 /* Nonzero indicates that branch taken probabilities should be calculated. */
448 int flag_branch_probabilities = 0;
450 /* Nonzero if basic blocks should be reordered. */
452 int flag_reorder_blocks = 0;
454 /* Nonzero if registers should be renamed. */
456 int flag_rename_registers = 0;
458 /* Nonzero for -pedantic switch: warn about anything
459 that standard spec forbids. */
461 int pedantic = 0;
463 /* Temporarily suppress certain warnings.
464 This is set while reading code from a system header file. */
466 int in_system_header = 0;
468 /* Don't print functions as they are compiled. -quiet. */
470 int quiet_flag = 0;
472 /* Print times taken by the various passes. -ftime-report. */
474 int time_report = 0;
476 /* Print memory still in use at end of compilation (which may have little
477 to do with peak memory consumption). -fmem-report. */
479 int mem_report = 0;
481 /* Non-zero means to collect statistics which might be expensive
482 and to print them when we are done. */
483 int flag_detailed_statistics = 0;
486 /* -f flags. */
488 /* Nonzero means `char' should be signed. */
490 int flag_signed_char;
492 /* Nonzero means give an enum type only as many bytes as it needs. */
494 int flag_short_enums;
496 /* Nonzero for -fcaller-saves: allocate values in regs that need to
497 be saved across function calls, if that produces overall better code.
498 Optional now, so people can test it. */
500 #ifdef DEFAULT_CALLER_SAVES
501 int flag_caller_saves = 1;
502 #else
503 int flag_caller_saves = 0;
504 #endif
506 /* Nonzero if structures and unions should be returned in memory.
508 This should only be defined if compatibility with another compiler or
509 with an ABI is needed, because it results in slower code. */
511 #ifndef DEFAULT_PCC_STRUCT_RETURN
512 #define DEFAULT_PCC_STRUCT_RETURN 1
513 #endif
515 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
517 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
519 /* Nonzero for -fforce-mem: load memory value into a register
520 before arithmetic on it. This makes better cse but slower compilation. */
522 int flag_force_mem = 0;
524 /* Nonzero for -fforce-addr: load memory address into a register before
525 reference to memory. This makes better cse but slower compilation. */
527 int flag_force_addr = 0;
529 /* Nonzero for -fdefer-pop: don't pop args after each function call;
530 instead save them up to pop many calls' args with one insns. */
532 int flag_defer_pop = 0;
534 /* Nonzero for -ffloat-store: don't allocate floats and doubles
535 in extended-precision registers. */
537 int flag_float_store = 0;
539 /* Nonzero for -fcse-follow-jumps:
540 have cse follow jumps to do a more extensive job. */
542 int flag_cse_follow_jumps;
544 /* Nonzero for -fcse-skip-blocks:
545 have cse follow a branch around a block. */
546 int flag_cse_skip_blocks;
548 /* Nonzero for -fexpensive-optimizations:
549 perform miscellaneous relatively-expensive optimizations. */
550 int flag_expensive_optimizations;
552 /* Nonzero for -fthread-jumps:
553 have jump optimize output of loop. */
555 int flag_thread_jumps;
557 /* Nonzero enables strength-reduction in loop.c. */
559 int flag_strength_reduce = 0;
561 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
562 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
563 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
564 unrolled. */
566 int flag_unroll_loops;
568 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
569 This is generally not a win. */
571 int flag_unroll_all_loops;
573 /* Nonzero forces all invariant computations in loops to be moved
574 outside the loop. */
576 int flag_move_all_movables = 0;
578 /* Nonzero forces all general induction variables in loops to be
579 strength reduced. */
581 int flag_reduce_all_givs = 0;
583 /* Nonzero to perform full register move optimization passes. This is the
584 default for -O2. */
586 int flag_regmove = 0;
588 /* Nonzero for -fwritable-strings:
589 store string constants in data segment and don't uniquize them. */
591 int flag_writable_strings = 0;
593 /* Nonzero means don't put addresses of constant functions in registers.
594 Used for compiling the Unix kernel, where strange substitutions are
595 done on the assembly output. */
597 int flag_no_function_cse = 0;
599 /* Nonzero for -fomit-frame-pointer:
600 don't make a frame pointer in simple functions that don't require one. */
602 int flag_omit_frame_pointer = 0;
604 /* Nonzero means place each function into its own section on those platforms
605 which support arbitrary section names and unlimited numbers of sections. */
607 int flag_function_sections = 0;
609 /* ... and similar for data. */
611 int flag_data_sections = 0;
613 /* Nonzero to inhibit use of define_optimization peephole opts. */
615 int flag_no_peephole = 0;
617 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
618 operations in the interest of optimization. For example it allows
619 GCC to assume arguments to sqrt are nonnegative numbers, allowing
620 faster code for sqrt to be generated. */
622 int flag_fast_math = 0;
624 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
626 int flag_optimize_sibling_calls = 0;
628 /* Nonzero means the front end generally wants `errno' maintained by math
629 operations, like built-in SQRT, unless overridden by flag_fast_math. */
631 int flag_errno_math = 1;
633 /* 0 means straightforward implementation of complex divide acceptable.
634 1 means wide ranges of inputs must work for complex divide.
635 2 means C9X-like requirements for complex divide (not yet implemented). */
637 int flag_complex_divide_method = 0;
639 /* Nonzero means all references through pointers are volatile. */
641 int flag_volatile;
643 /* Nonzero means treat all global and extern variables as volatile. */
645 int flag_volatile_global;
647 /* Nonzero means treat all static variables as volatile. */
649 int flag_volatile_static;
651 /* Nonzero means just do syntax checking; don't output anything. */
653 int flag_syntax_only = 0;
655 /* Nonzero means perform global cse. */
657 static int flag_gcse;
659 /* Nonzero means to use global dataflow analysis to eliminate
660 useless null pointer tests. */
662 static int flag_delete_null_pointer_checks;
664 /* Nonzero means to rerun cse after loop optimization. This increases
665 compilation time about 20% and picks up a few more common expressions. */
667 static int flag_rerun_cse_after_loop;
669 /* Nonzero means to run loop optimizations twice. */
671 int flag_rerun_loop_opt;
673 /* Nonzero for -finline-functions: ok to inline functions that look like
674 good inline candidates. */
676 int flag_inline_functions;
678 /* Nonzero for -fkeep-inline-functions: even if we make a function
679 go inline everywhere, keep its definition around for debugging
680 purposes. */
682 int flag_keep_inline_functions;
684 /* Nonzero means that functions will not be inlined. */
686 int flag_no_inline;
688 /* Nonzero means that we should emit static const variables
689 regardless of whether or not optimization is turned on. */
691 int flag_keep_static_consts = 1;
693 /* Nonzero means we should be saving declaration info into a .X file. */
695 int flag_gen_aux_info = 0;
697 /* Specified name of aux-info file. */
699 static char *aux_info_file_name;
701 /* Nonzero means make the text shared if supported. */
703 int flag_shared_data;
705 /* Nonzero means schedule into delayed branch slots if supported. */
707 int flag_delayed_branch;
709 /* Nonzero if we are compiling pure (sharable) code.
710 Value is 1 if we are doing reasonable (i.e. simple
711 offset into offset table) pic. Value is 2 if we can
712 only perform register offsets. */
714 int flag_pic;
716 /* Nonzero means generate extra code for exception handling and enable
717 exception handling. */
719 int flag_exceptions;
721 /* Nonzero means use the new model for exception handling. Replaces
722 -DNEW_EH_MODEL as a compile option. */
724 int flag_new_exceptions = 1;
726 /* Nonzero means generate frame unwind info table when supported. */
728 int flag_unwind_tables = 0;
730 /* Nonzero means don't place uninitialized global data in common storage
731 by default. */
733 int flag_no_common;
735 /* Nonzero means pretend it is OK to examine bits of target floats,
736 even if that isn't true. The resulting code will have incorrect constants,
737 but the same series of instructions that the native compiler would make. */
739 int flag_pretend_float;
741 /* Nonzero means change certain warnings into errors.
742 Usually these are warnings about failure to conform to some standard. */
744 int flag_pedantic_errors = 0;
746 /* flag_schedule_insns means schedule insns within basic blocks (before
747 local_alloc).
748 flag_schedule_insns_after_reload means schedule insns after
749 global_alloc. */
751 int flag_schedule_insns = 0;
752 int flag_schedule_insns_after_reload = 0;
754 /* The following flags have effect only for scheduling before register
755 allocation:
757 flag_schedule_interblock means schedule insns accross basic blocks.
758 flag_schedule_speculative means allow speculative motion of non-load insns.
759 flag_schedule_speculative_load means allow speculative motion of some
760 load insns.
761 flag_schedule_speculative_load_dangerous allows speculative motion of more
762 load insns. */
764 int flag_schedule_interblock = 1;
765 int flag_schedule_speculative = 1;
766 int flag_schedule_speculative_load = 0;
767 int flag_schedule_speculative_load_dangerous = 0;
769 int flag_single_precision_constant;
771 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
772 by a cheaper branch on a count register. */
773 int flag_branch_on_count_reg = 1;
775 /* -finhibit-size-directive inhibits output of .size for ELF.
776 This is used only for compiling crtstuff.c,
777 and it may be extended to other effects
778 needed for crtstuff.c on other systems. */
779 int flag_inhibit_size_directive = 0;
781 /* -fverbose-asm causes extra commentary information to be produced in
782 the generated assembly code (to make it more readable). This option
783 is generally only of use to those who actually need to read the
784 generated assembly code (perhaps while debugging the compiler itself).
785 -fno-verbose-asm, the default, causes the extra information
786 to be omitted and is useful when comparing two assembler files. */
788 int flag_verbose_asm = 0;
790 /* -dA causes debug commentary information to be produced in
791 the generated assembly code (to make it more readable). This option
792 is generally only of use to those who actually need to read the
793 generated assembly code (perhaps while debugging the compiler itself).
794 Currently, this switch is only used by dwarfout.c; however, it is intended
795 to be a catchall for printing debug information in the assembler file. */
797 int flag_debug_asm = 0;
799 /* -dP causes the rtl to be emitted as a comment in assembly. */
801 int flag_dump_rtl_in_asm = 0;
803 /* -fgnu-linker specifies use of the GNU linker for initializations.
804 (Or, more generally, a linker that handles initializations.)
805 -fno-gnu-linker says that collect2 will be used. */
806 #ifdef USE_COLLECT2
807 int flag_gnu_linker = 0;
808 #else
809 int flag_gnu_linker = 1;
810 #endif
812 /* Enable SSA. */
813 int flag_ssa = 0;
815 /* Enable dead code elimination. */
816 int flag_dce = 0;
818 /* Tag all structures with __attribute__(packed). */
819 int flag_pack_struct = 0;
821 /* Emit code to check for stack overflow; also may cause large objects
822 to be allocated dynamically. */
823 int flag_stack_check;
825 /* When non-NULL, indicates that whenever space is allocated on the
826 stack, the resulting stack pointer must not pass this
827 address---that is, for stacks that grow downward, the stack pointer
828 must always be greater than or equal to this address; for stacks
829 that grow upward, the stack pointer must be less than this address.
830 At present, the rtx may be either a REG or a SYMBOL_REF, although
831 the support provided depends on the backend. */
832 rtx stack_limit_rtx;
834 /* -fcheck-memory-usage causes extra code to be generated in order to check
835 memory accesses. This is used by a detector of bad memory accesses such
836 as Checker. */
837 int flag_check_memory_usage = 0;
839 /* -fprefix-function-name causes function name to be prefixed. This
840 can be used with -fcheck-memory-usage to isolate code compiled with
841 -fcheck-memory-usage. */
842 int flag_prefix_function_name = 0;
844 /* 0 if pointer arguments may alias each other. True in C.
845 1 if pointer arguments may not alias each other but may alias
846 global variables.
847 2 if pointer arguments may not alias each other and may not
848 alias global variables. True in Fortran.
849 This defaults to 0 for C. */
850 int flag_argument_noalias = 0;
852 /* Nonzero if we should do (language-dependent) alias analysis.
853 Typically, this analysis will assume that expressions of certain
854 types do not alias expressions of certain other types. Only used
855 if alias analysis (in general) is enabled. */
856 int flag_strict_aliasing = 0;
858 /* Instrument functions with calls at entry and exit, for profiling. */
859 int flag_instrument_function_entry_exit = 0;
861 /* Nonzero means ignore `#ident' directives. 0 means handle them.
862 On SVR4 targets, it also controls whether or not to emit a
863 string identifying the compiler. */
865 int flag_no_ident = 0;
867 /* This will perform a peephole pass before sched2. */
868 int flag_peephole2 = 0;
870 /* -fbounded-pointers causes gcc to compile pointers as composite
871 objects occupying three words: the pointer value, the base address
872 of the referent object, and the address immediately beyond the end
873 of the referent object. The base and extent allow us to perform
874 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
875 int flag_bounded_pointers = 0;
877 /* -fcheck-bounds causes gcc to generate array bounds checks.
878 For C, C++: defaults to value of flag_bounded_pointers.
879 For ObjC: defaults to off.
880 For Java: defaults to on.
881 For Fortran: defaults to off.
882 For CHILL: defaults to off. */
883 int flag_bounds_check = 0;
885 /* If one, renumber instruction UIDs to reduce the number of
886 unused UIDs if there are a lot of instructions. If greater than
887 one, unconditionally renumber instruction UIDs. */
888 int flag_renumber_insns = 1;
890 /* Values of the -falign-* flags: how much to align labels in code.
891 0 means `use default', 1 means `don't align'.
892 For each variable, there is an _log variant which is the power
893 of two not less than the variable, for .align output. */
895 int align_loops;
896 int align_loops_log;
897 int align_jumps;
898 int align_jumps_log;
899 int align_labels;
900 int align_labels_log;
901 int align_functions;
902 int align_functions_log;
904 /* Table of supported debugging formats. */
905 static struct
907 const char *arg;
908 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
909 constant expression, we use NO_DEBUG in its place. */
910 enum debug_info_type debug_type;
911 int use_extensions_p;
912 const char *description;
913 } *da,
914 debug_args[] =
916 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
917 "Generate default debug format output" },
918 { "gdb", NO_DEBUG, 1, "Generate default extended debug format output" },
919 #ifdef DBX_DEBUGGING_INFO
920 { "stabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
921 { "stabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
922 #endif
923 #ifdef DWARF_DEBUGGING_INFO
924 { "dwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
925 { "dwarf+", DWARF_DEBUG, 1,
926 "Generated extended DWARF-1 format debug output" },
927 #endif
928 #ifdef DWARF2_DEBUGGING_INFO
929 { "dwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
930 #endif
931 #ifdef XCOFF_DEBUGGING_INFO
932 { "xcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
933 { "xcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
934 #endif
935 #ifdef SDB_DEBUGGING_INFO
936 { "coff", SDB_DEBUG, 0, "Generate COFF format debug output" },
937 #endif
938 { 0, 0, 0, 0 }
941 typedef struct
943 const char *string;
944 int *variable;
945 int on_value;
946 const char *description;
948 lang_independent_options;
950 int flag_trapv = 0;
952 /* Add or remove a leading underscore from user symbols. */
953 int flag_leading_underscore = -1;
955 /* The user symbol prefix after having resolved same. */
956 const char *user_label_prefix;
958 /* A default for same. */
959 #ifndef USER_LABEL_PREFIX
960 #define USER_LABEL_PREFIX ""
961 #endif
963 /* Table of language-independent -f options.
964 STRING is the option name. VARIABLE is the address of the variable.
965 ON_VALUE is the value to store in VARIABLE
966 if `-fSTRING' is seen as an option.
967 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
969 lang_independent_options f_options[] =
971 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
972 "Perform DWARF2 duplicate elimination"},
973 {"float-store", &flag_float_store, 1,
974 "Do not store floats in registers" },
975 {"volatile", &flag_volatile, 1,
976 "Consider all mem refs through pointers as volatile"},
977 {"volatile-global", &flag_volatile_global, 1,
978 "Consider all mem refs to global data to be volatile" },
979 {"volatile-static", &flag_volatile_static, 1,
980 "Consider all mem refs to static data to be volatile" },
981 {"defer-pop", &flag_defer_pop, 1,
982 "Defer popping functions args from stack until later" },
983 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
984 "When possible do not generate stack frames"},
985 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
986 "Optimize sibling and tail recursive calls" },
987 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
988 "When running CSE, follow jumps to their targets" },
989 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
990 "When running CSE, follow conditional jumps" },
991 {"expensive-optimizations", &flag_expensive_optimizations, 1,
992 "Perform a number of minor, expensive optimisations" },
993 {"thread-jumps", &flag_thread_jumps, 1,
994 "Perform jump threading optimisations"},
995 {"strength-reduce", &flag_strength_reduce, 1,
996 "Perform strength reduction optimisations" },
997 {"unroll-loops", &flag_unroll_loops, 1,
998 "Perform loop unrolling when iteration count is known" },
999 {"unroll-all-loops", &flag_unroll_all_loops, 1,
1000 "Perform loop unrolling for all loops" },
1001 {"move-all-movables", &flag_move_all_movables, 1,
1002 "Force all loop invariant computations out of loops" },
1003 {"reduce-all-givs", &flag_reduce_all_givs, 1,
1004 "Strength reduce all loop general induction variables" },
1005 {"writable-strings", &flag_writable_strings, 1,
1006 "Store strings in writable data section" },
1007 {"peephole", &flag_no_peephole, 0,
1008 "Enable machine specific peephole optimisations" },
1009 {"force-mem", &flag_force_mem, 1,
1010 "Copy memory operands into registers before using" },
1011 {"force-addr", &flag_force_addr, 1,
1012 "Copy memory address constants into regs before using" },
1013 {"function-cse", &flag_no_function_cse, 0,
1014 "Allow function addresses to be held in registers" },
1015 {"inline-functions", &flag_inline_functions, 1,
1016 "Integrate simple functions into their callers" },
1017 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1018 "Generate code for funcs even if they are fully inlined" },
1019 {"inline", &flag_no_inline, 0,
1020 "Pay attention to the 'inline' keyword"},
1021 {"keep-static-consts", &flag_keep_static_consts, 1,
1022 "Emit static const variables even if they are not used" },
1023 {"syntax-only", &flag_syntax_only, 1,
1024 "Check for syntax errors, then stop" },
1025 {"shared-data", &flag_shared_data, 1,
1026 "Mark data as shared rather than private" },
1027 {"caller-saves", &flag_caller_saves, 1,
1028 "Enable saving registers around function calls" },
1029 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1030 "Return 'short' aggregates in memory, not registers" },
1031 {"reg-struct-return", &flag_pcc_struct_return, 0,
1032 "Return 'short' aggregates in registers" },
1033 {"delayed-branch", &flag_delayed_branch, 1,
1034 "Attempt to fill delay slots of branch instructions" },
1035 {"gcse", &flag_gcse, 1,
1036 "Perform the global common subexpression elimination" },
1037 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1038 "Run CSE pass after loop optimisations"},
1039 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1040 "Run the loop optimiser twice"},
1041 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1042 "Delete useless null pointer checks" },
1043 {"pretend-float", &flag_pretend_float, 1,
1044 "Pretend that host and target use the same FP format"},
1045 {"schedule-insns", &flag_schedule_insns, 1,
1046 "Reschedule instructions to avoid pipeline stalls"},
1047 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1048 "Run two passes of the instruction scheduler"},
1049 {"sched-interblock",&flag_schedule_interblock, 1,
1050 "Enable scheduling across basic blocks" },
1051 {"sched-spec",&flag_schedule_speculative, 1,
1052 "Allow speculative motion of non-loads" },
1053 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1054 "Allow speculative motion of some loads" },
1055 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1056 "Allow speculative motion of more loads" },
1057 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1058 "Replace add,compare,branch with branch on count reg"},
1059 {"pic", &flag_pic, 1,
1060 "Generate position independent code, if possible"},
1061 {"PIC", &flag_pic, 2, ""},
1062 {"exceptions", &flag_exceptions, 1,
1063 "Enable exception handling" },
1064 {"new-exceptions", &flag_new_exceptions, 1,
1065 "Use the new model for exception handling" },
1066 {"unwind-tables", &flag_unwind_tables, 1,
1067 "Just generate unwind tables for exception handling" },
1068 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
1069 "Use setjmp/longjmp to handle exceptions" },
1070 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
1071 "Support asynchronous exceptions" },
1072 {"profile-arcs", &profile_arc_flag, 1,
1073 "Insert arc based program profiling code" },
1074 {"test-coverage", &flag_test_coverage, 1,
1075 "Create data files needed by gcov" },
1076 {"branch-probabilities", &flag_branch_probabilities, 1,
1077 "Use profiling information for branch probabilities" },
1078 {"reorder-blocks", &flag_reorder_blocks, 1,
1079 "Reorder basic blocks to improve code placement" },
1080 {"rename-registers", &flag_rename_registers, 1,
1081 "Do the register renaming optimization pass"},
1082 {"fast-math", &flag_fast_math, 1,
1083 "Improve FP speed by violating ANSI & IEEE rules" },
1084 {"common", &flag_no_common, 0,
1085 "Do not put unitialised globals in the common section" },
1086 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1087 "Do not generate .size directives" },
1088 {"function-sections", &flag_function_sections, 1,
1089 "place each function into its own section" },
1090 {"data-sections", &flag_data_sections, 1,
1091 "place data items into their own section" },
1092 {"verbose-asm", &flag_verbose_asm, 1,
1093 "Add extra commentry to assembler output"},
1094 {"gnu-linker", &flag_gnu_linker, 1,
1095 "Output GNU ld formatted global initialisers"},
1096 {"regmove", &flag_regmove, 1,
1097 "Enables a register move optimisation"},
1098 {"optimize-register-move", &flag_regmove, 1,
1099 "Do the full regmove optimization pass"},
1100 {"pack-struct", &flag_pack_struct, 1,
1101 "Pack structure members together without holes" },
1102 {"stack-check", &flag_stack_check, 1,
1103 "Insert stack checking code into the program" },
1104 {"argument-alias", &flag_argument_noalias, 0,
1105 "Specify that arguments may alias each other & globals"},
1106 {"argument-noalias", &flag_argument_noalias, 1,
1107 "Assume arguments may alias globals but not each other"},
1108 {"argument-noalias-global", &flag_argument_noalias, 2,
1109 "Assume arguments do not alias each other or globals" },
1110 {"strict-aliasing", &flag_strict_aliasing, 1,
1111 "Assume strict aliasing rules apply" },
1112 {"align-loops", &align_loops, 0,
1113 "Align the start of loops" },
1114 {"align-jumps", &align_jumps, 0,
1115 "Align labels which are only reached by jumping" },
1116 {"align-labels", &align_labels, 0,
1117 "Align all labels" },
1118 {"align-functions", &align_functions, 0,
1119 "Align the start of functions" },
1120 {"check-memory-usage", &flag_check_memory_usage, 1,
1121 "Generate code to check every memory access" },
1122 {"prefix-function-name", &flag_prefix_function_name, 1,
1123 "Add a prefix to all function names" },
1124 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1125 "Suppress output of instruction numbers and line number notes in debugging dumps"},
1126 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1127 "Instrument function entry/exit with profiling calls"},
1128 {"ssa", &flag_ssa, 1,
1129 "Enable SSA optimizations" },
1130 {"dce", &flag_dce, 1,
1131 "Enable dead code elimination" },
1132 {"leading-underscore", &flag_leading_underscore, 1,
1133 "External symbols have a leading underscore" },
1134 {"ident", &flag_no_ident, 0,
1135 "Process #ident directives"},
1136 { "peephole2", &flag_peephole2, 1,
1137 "Enables an rtl peephole pass run before sched2" },
1138 {"math-errno", &flag_errno_math, 1,
1139 "Set errno after built-in math functions"},
1140 {"bounded-pointers", &flag_bounded_pointers, 1,
1141 "Compile pointers as triples: value, base & end" },
1142 {"bounds-check", &flag_bounds_check, 1,
1143 "Generate code to check bounds before dereferencing pointers and arrays" },
1144 {"single-precision-constant", &flag_single_precision_constant, 1,
1145 "Convert floating point constant to single precision constant"},
1146 {"time-report", &time_report, 1,
1147 "Report time taken by each compiler pass at end of run"},
1148 {"mem-report", &mem_report, 1,
1149 "Report on permanent memory allocation at end of run"},
1150 { "trapv", &flag_trapv, 1,
1151 "Trap for signed overflow in addition / subtraction / multiplication." },
1154 /* Table of language-specific options. */
1156 static struct lang_opt
1158 const char *option;
1159 const char *description;
1161 documented_lang_options[] =
1163 /* In order not to overload the --help output, the convention
1164 used here is to only describe those options which are not
1165 enabled by default. */
1167 { "-ansi", "Compile just for ISO C89" },
1168 { "-fallow-single-precision",
1169 "Do not promote floats to double if using -traditional" },
1170 { "-std= ", "Determine language standard"},
1172 { "-fsigned-bitfields", "" },
1173 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1174 { "-fno-signed-bitfields", "" },
1175 { "-fno-unsigned-bitfields","" },
1176 { "-fsigned-char", "Make 'char' be signed by default"},
1177 { "-funsigned-char", "Make 'char' be unsigned by default"},
1178 { "-fno-signed-char", "" },
1179 { "-fno-unsigned-char", "" },
1181 { "-ftraditional", "" },
1182 { "-traditional", "Attempt to support traditional K&R style C"},
1183 { "-fnotraditional", "" },
1184 { "-fno-traditional", "" },
1186 { "-fasm", "" },
1187 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1188 { "-fbuiltin", "" },
1189 { "-fno-builtin", "Do not recognise any built in functions" },
1190 { "-fhosted", "Assume normal C execution environment" },
1191 { "-fno-hosted", "" },
1192 { "-ffreestanding",
1193 "Assume that standard libraries & main might not exist" },
1194 { "-fno-freestanding", "" },
1195 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1196 { "-fno-cond-mismatch", "" },
1197 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1198 { "-fno-dollars-in-identifiers", "" },
1199 { "-fpreprocessed", "" },
1200 { "-fno-preprocessed", "" },
1201 { "-fshort-double", "Use the same size for double as for float" },
1202 { "-fno-short-double", "" },
1203 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1204 { "-fno-short-enums", "" },
1205 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1206 { "-fno-short-wchar", "" },
1208 { "-Wall", "Enable most warning messages" },
1209 { "-Wbad-function-cast",
1210 "Warn about casting functions to incompatible types" },
1211 { "-Wno-bad-function-cast", "" },
1212 { "-Wmissing-noreturn",
1213 "Warn about functions which might be candidates for attribute noreturn" },
1214 { "-Wno-missing-noreturn", "" },
1215 { "-Wmissing-format-attribute",
1216 "Warn about functions which might be candidates for format attributes" },
1217 { "-Wno-missing-format-attribute", "" },
1218 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1219 { "-Wno-cast-qual", "" },
1220 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1221 { "-Wno-char-subscripts", "" },
1222 { "-Wcomment", "Warn if nested comments are detected" },
1223 { "-Wno-comment", "" },
1224 { "-Wcomments", "Warn if nested comments are detected" },
1225 { "-Wno-comments", "" },
1226 { "-Wconversion", "Warn about possibly confusing type conversions" },
1227 { "-Wno-conversion", "" },
1228 { "-Wformat", "Warn about printf format anomalies" },
1229 { "-Wno-format", "" },
1230 { "-Wimplicit-function-declaration",
1231 "Warn about implicit function declarations" },
1232 { "-Wno-implicit-function-declaration", "" },
1233 { "-Werror-implicit-function-declaration", "" },
1234 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1235 { "-Wno-implicit-int", "" },
1236 { "-Wimplicit", "" },
1237 { "-Wno-implicit", "" },
1238 { "-Wimport", "Warn about the use of the #import directive" },
1239 { "-Wno-import", "" },
1240 { "-Wlong-long","" },
1241 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1242 { "-Wmain", "Warn about suspicious declarations of main" },
1243 { "-Wno-main", "" },
1244 { "-Wmissing-braces",
1245 "Warn about possibly missing braces around initialisers" },
1246 { "-Wno-missing-braces", "" },
1247 { "-Wmissing-declarations",
1248 "Warn about global funcs without previous declarations"},
1249 { "-Wno-missing-declarations", "" },
1250 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1251 { "-Wno-missing-prototypes", "" },
1252 { "-Wmultichar", "Warn about use of multicharacter literals"},
1253 { "-Wno-multichar", "" },
1254 { "-Wnested-externs", "Warn about externs not at file scope level" },
1255 { "-Wno-nested-externs", "" },
1256 { "-Wparentheses", "Warn about possible missing parentheses" },
1257 { "-Wno-parentheses", "" },
1258 { "-Wsequence-point",
1259 "Warn about possible violations of sequence point rules" },
1260 { "-Wno-sequence-point", "" },
1261 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1262 { "-Wno-pointer-arith", "" },
1263 { "-Wredundant-decls",
1264 "Warn about multiple declarations of the same object" },
1265 { "-Wno-redundant-decls", "" },
1266 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1267 { "-Wno-sign-compare", "" },
1268 { "-Wfloat-equal", "Warn about testing equality of floating point numbers" },
1269 { "-Wno-float-equal", "" },
1270 { "-Wunknown-pragmas", "Warn about unrecognized pragmas" },
1271 { "-Wno-unknown-pragmas", "" },
1272 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1273 { "-Wno-strict-prototypes", "" },
1274 { "-Wtraditional", "Warn about constructs whose meaning change in ISO C"},
1275 { "-Wno-traditional", "" },
1276 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1277 { "-Wno-trigraphs", "" },
1278 { "-Wundef", "" },
1279 { "-Wno-undef", "" },
1280 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1281 { "-Wno-write-strings", "" },
1283 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1285 #include "options.h"
1289 /* Here is a table, controlled by the tm.h file, listing each -m switch
1290 and which bits in `target_switches' it should set or clear.
1291 If VALUE is positive, it is bits to set.
1292 If VALUE is negative, -VALUE is bits to clear.
1293 (The sign bit is not used so there is no confusion.) */
1295 struct
1297 const char *name;
1298 int value;
1299 const char *description;
1301 target_switches [] = TARGET_SWITCHES;
1303 /* This table is similar, but allows the switch to have a value. */
1305 #ifdef TARGET_OPTIONS
1306 struct
1308 const char *prefix;
1309 const char **variable;
1310 const char *description;
1312 target_options [] = TARGET_OPTIONS;
1313 #endif
1315 /* Options controlling warnings. */
1317 /* Don't print warning messages. -w. */
1319 int inhibit_warnings = 0;
1321 /* Don't suppress warnings from system headers. -Wsystem-headers. */
1323 int warn_system_headers = 0;
1325 /* Print various extra warnings. -W. */
1327 int extra_warnings = 0;
1329 /* Treat warnings as errors. -Werror. */
1331 int warnings_are_errors = 0;
1333 /* Nonzero to warn about unused variables, functions et.al. */
1335 int warn_unused_function;
1336 int warn_unused_label;
1337 int warn_unused_parameter;
1338 int warn_unused_variable;
1339 int warn_unused_value;
1341 void
1342 set_Wunused (setting)
1343 int setting;
1345 warn_unused_function = setting;
1346 warn_unused_label = setting;
1347 /* Unused function parameter warnings are reported when either ``-W
1348 -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
1349 -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
1350 if (!setting)
1351 warn_unused_parameter = 0;
1352 else if (!warn_unused_parameter)
1353 warn_unused_parameter = -1;
1354 warn_unused_variable = setting;
1355 warn_unused_value = setting;
1358 /* Nonzero to warn about code which is never reached. */
1360 int warn_notreached;
1362 /* Nonzero to warn about variables used before they are initialized. */
1364 int warn_uninitialized;
1366 /* Nonzero means warn about all declarations which shadow others. */
1368 int warn_shadow;
1370 /* Warn if a switch on an enum fails to have a case for every enum value. */
1372 int warn_switch;
1374 /* Nonzero means warn about function definitions that default the return type
1375 or that use a null return and have a return-type other than void. */
1377 int warn_return_type;
1379 /* Nonzero means warn about pointer casts that increase the required
1380 alignment of the target type (and might therefore lead to a crash
1381 due to a misaligned access). */
1383 int warn_cast_align;
1385 /* Nonzero means warn about any identifiers that match in the first N
1386 characters. The value N is in `id_clash_len'. */
1388 int warn_id_clash;
1389 int id_clash_len;
1391 /* Nonzero means warn about any objects definitions whose size is larger
1392 than N bytes. Also want about function definitions whose returned
1393 values are larger than N bytes. The value N is in `larger_than_size'. */
1395 int warn_larger_than;
1396 HOST_WIDE_INT larger_than_size;
1398 /* Nonzero means warn if inline function is too large. */
1400 int warn_inline;
1402 /* Warn if a function returns an aggregate,
1403 since there are often incompatible calling conventions for doing this. */
1405 int warn_aggregate_return;
1407 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1409 int warn_packed;
1411 /* Warn when gcc pads a structure to an alignment boundary. */
1413 int warn_padded;
1415 /* Warn when an optimization pass is disabled. */
1417 int warn_disabled_optimization;
1419 /* Warn about functions which might be candidates for attribute noreturn. */
1421 int warn_missing_noreturn;
1423 /* Likewise for -W. */
1425 lang_independent_options W_options[] =
1427 {"unused-function", &warn_unused_function, 1, "Warn when a function is unused" },
1428 {"unused-label", &warn_unused_label, 1, "Warn when a label is unused" },
1429 {"unused-parameter", &warn_unused_parameter, 1, "Warn when a function parameter is unused" },
1430 {"unused-variable", &warn_unused_variable, 1, "Warn when a variable is unused" },
1431 {"unused-value", &warn_unused_value, 1, "Warn when an expression value is unused" },
1432 {"system-headers", &warn_system_headers, 1, "Do not suppress warnings from system headers"},
1433 {"error", &warnings_are_errors, 1, ""},
1434 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1435 {"switch", &warn_switch, 1,
1436 "Warn about enumerated switches missing a specific case" },
1437 {"aggregate-return", &warn_aggregate_return, 1,
1438 "Warn about returning structures, unions or arrays" },
1439 {"cast-align", &warn_cast_align, 1,
1440 "Warn about pointer casts which increase alignment" },
1441 {"unreachable-code", &warn_notreached, 1,
1442 "Warn about code that will never be executed" },
1443 {"uninitialized", &warn_uninitialized, 1,
1444 "Warn about unitialized automatic variables"},
1445 {"inline", &warn_inline, 1,
1446 "Warn when an inlined function cannot be inlined"},
1447 {"packed", &warn_packed, 1,
1448 "Warn when the packed attribute has no effect on struct layout"},
1449 {"padded", &warn_padded, 1,
1450 "Warn when padding is required to align struct members"},
1451 {"disabled-optimization", &warn_disabled_optimization, 1,
1452 "Warn when an optimization pass is disabled"}
1455 /* Output files for assembler code (real compiler output)
1456 and debugging dumps. */
1458 FILE *asm_out_file;
1459 FILE *aux_info_file;
1460 FILE *rtl_dump_file = NULL;
1462 /* Decode the string P as an integral parameter.
1463 If the string is indeed an integer return its numeric value else
1464 issue an Invalid Option error for the option PNAME and return DEFVAL.
1465 If PNAME is zero just return DEFVAL, do not call error. */
1468 read_integral_parameter (p, pname, defval)
1469 const char *p;
1470 const char *pname;
1471 const int defval;
1473 const char *endp = p;
1475 while (*endp)
1477 if (*endp >= '0' && *endp <= '9')
1478 endp++;
1479 else
1480 break;
1483 if (*endp != 0)
1485 if (pname != 0)
1486 error ("Invalid option `%s'", pname);
1487 return defval;
1490 return atoi (p);
1494 /* This is the default decl_printable_name function. */
1496 static const char *
1497 decl_name (decl, verbosity)
1498 tree decl;
1499 int verbosity ATTRIBUTE_UNUSED;
1501 return IDENTIFIER_POINTER (DECL_NAME (decl));
1504 /* Mark P for GC. Also mark main_input_filename and input_filename. */
1506 static void
1507 mark_file_stack (p)
1508 void *p;
1510 struct file_stack *stack = *(struct file_stack **)p;
1512 /* We're only called for input_file_stack, so we can mark the current
1513 input_filename here as well. */
1514 ggc_mark_string (main_input_filename);
1515 ggc_mark_string (input_filename);
1517 while (stack)
1519 ggc_mark_string (stack->name);
1520 stack = stack->next;
1525 /* This calls abort and is used to avoid problems when abort if a macro.
1526 It is used when we need to pass the address of abort. */
1528 void
1529 do_abort ()
1531 abort ();
1534 /* When `malloc.c' is compiled with `rcheck' defined,
1535 it calls this function to report clobberage. */
1537 void
1538 botch (s)
1539 const char *s ATTRIBUTE_UNUSED;
1541 abort ();
1544 /* Return the logarithm of X, base 2, considering X unsigned,
1545 if X is a power of 2. Otherwise, returns -1.
1547 This should be used via the `exact_log2' macro. */
1550 exact_log2_wide (x)
1551 register unsigned HOST_WIDE_INT x;
1553 register int log = 0;
1554 /* Test for 0 or a power of 2. */
1555 if (x == 0 || x != (x & -x))
1556 return -1;
1557 while ((x >>= 1) != 0)
1558 log++;
1559 return log;
1562 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1563 If X is 0, return -1.
1565 This should be used via the floor_log2 macro. */
1568 floor_log2_wide (x)
1569 register unsigned HOST_WIDE_INT x;
1571 register int log = -1;
1572 while (x != 0)
1573 log++,
1574 x >>= 1;
1575 return log;
1578 static int float_handler_set;
1579 int float_handled;
1580 jmp_buf float_handler;
1582 /* Signals actually come here. */
1584 static void
1585 float_signal (signo)
1586 /* If this is missing, some compilers complain. */
1587 int signo ATTRIBUTE_UNUSED;
1589 if (float_handled == 0)
1590 crash_signal (signo);
1591 #if defined (USG) || defined (hpux)
1592 /* Re-enable the signal catcher. */
1593 signal (SIGFPE, float_signal);
1594 #endif
1595 float_handled = 0;
1596 signal (SIGFPE, float_signal);
1597 longjmp (float_handler, 1);
1600 /* Specify where to longjmp to when a floating arithmetic error happens.
1601 If HANDLER is 0, it means don't handle the errors any more. */
1603 void
1604 set_float_handler (handler)
1605 jmp_buf handler;
1607 float_handled = (handler != 0);
1608 if (handler)
1609 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1611 if (float_handled && ! float_handler_set)
1613 signal (SIGFPE, float_signal);
1614 float_handler_set = 1;
1618 /* This is a wrapper function for code which might elicit an
1619 arithmetic exception. That code should be passed in as a function
1620 pointer FN, and one argument DATA. DATA is usually a struct which
1621 contains the real input and output for function FN. This function
1622 returns 0 (failure) if longjmp was called (i.e. an exception
1623 occured.) It returns 1 (success) otherwise. */
1626 do_float_handler (fn, data)
1627 void (*fn) PARAMS ((PTR));
1628 PTR data;
1630 jmp_buf buf;
1632 if (setjmp (buf))
1634 /* We got here via longjmp () caused by an exception in function
1635 fn (). */
1636 set_float_handler (NULL);
1637 return 0;
1640 set_float_handler (buf);
1641 (*fn)(data);
1642 set_float_handler (NULL);
1643 return 1;
1646 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1647 error happens, pushing the previous specification into OLD_HANDLER.
1648 Return an indication of whether there was a previous handler in effect. */
1651 push_float_handler (handler, old_handler)
1652 jmp_buf handler, old_handler;
1654 int was_handled = float_handled;
1656 float_handled = 1;
1657 if (was_handled)
1658 memcpy ((char *) old_handler, (char *) float_handler,
1659 sizeof (float_handler));
1661 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
1662 return was_handled;
1665 /* Restore the previous specification of whether and where to longjmp to
1666 when a floating arithmetic error happens. */
1668 void
1669 pop_float_handler (handled, handler)
1670 int handled;
1671 jmp_buf handler;
1673 float_handled = handled;
1674 if (handled)
1675 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1678 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1679 into ICE messages, which is much more user friendly. */
1681 static void
1682 crash_signal (signo)
1683 /* If this is missing, some compilers complain. */
1684 int signo;
1686 fatal ("Internal error: %s.\n\
1687 Please submit a full bug report.\n\
1688 See %s for instructions.", strsignal (signo), GCCBUGURL);
1691 /* Strip off a legitimate source ending from the input string NAME of
1692 length LEN. Rather than having to know the names used by all of
1693 our front ends, we strip off an ending of a period followed by
1694 up to five characters. (Java uses ".class".) */
1696 void
1697 strip_off_ending (name, len)
1698 char *name;
1699 int len;
1701 int i;
1702 for (i = 2; i < 6 && len > i; i++)
1704 if (name[len - i] == '.')
1706 name[len - i] = '\0';
1707 break;
1712 /* Given a file name X, return the nondirectory portion. */
1714 char *
1715 file_name_nondirectory (x)
1716 const char *x;
1718 char *tmp = (char *) rindex (x, '/');
1719 if (DIR_SEPARATOR != '/' && ! tmp)
1720 tmp = (char *) rindex (x, DIR_SEPARATOR);
1721 if (tmp)
1722 return (char *) (tmp + 1);
1723 else
1724 return (char *) x;
1727 /* Output a quoted string. */
1729 void
1730 output_quoted_string (asm_file, string)
1731 FILE *asm_file;
1732 const char *string;
1734 #ifdef OUTPUT_QUOTED_STRING
1735 OUTPUT_QUOTED_STRING (asm_file, string);
1736 #else
1737 char c;
1739 putc ('\"', asm_file);
1740 while ((c = *string++) != 0)
1742 if (c == '\"' || c == '\\')
1743 putc ('\\', asm_file);
1744 putc (c, asm_file);
1746 putc ('\"', asm_file);
1747 #endif
1750 /* Output a file name in the form wanted by System V. */
1752 void
1753 output_file_directive (asm_file, input_name)
1754 FILE *asm_file;
1755 const char *input_name;
1757 int len = strlen (input_name);
1758 const char *na = input_name + len;
1760 /* NA gets INPUT_NAME sans directory names. */
1761 while (na > input_name)
1763 if (IS_DIR_SEPARATOR (na[-1]))
1764 break;
1765 na--;
1768 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1769 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1770 #else
1771 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1772 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1773 #else
1774 fprintf (asm_file, "\t.file\t");
1775 output_quoted_string (asm_file, na);
1776 fputc ('\n', asm_file);
1777 #endif
1778 #endif
1781 #ifdef ASM_IDENTIFY_LANGUAGE
1782 /* Routine to build language identifier for object file. */
1784 static void
1785 output_lang_identify (asm_out_file)
1786 FILE *asm_out_file;
1788 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1789 char *s = (char *) alloca (len);
1791 sprintf (s, "__gnu_compiled_%s", lang_identify ());
1792 ASM_OUTPUT_LABEL (asm_out_file, s);
1794 #endif
1796 /* Routine to open a dump file. Return true if the dump file is enabled. */
1798 static int
1799 open_dump_file (index, decl)
1800 enum dump_file_index index;
1801 tree decl;
1803 char *dump_name;
1804 const char *open_arg;
1805 char seq[16];
1807 if (! dump_file[index].enabled)
1808 return 0;
1810 timevar_push (TV_DUMP);
1811 if (rtl_dump_file != NULL)
1812 fclose (rtl_dump_file);
1814 sprintf (seq, ".%02d.", index);
1816 if (! dump_file[index].initialized)
1818 /* If we've not initialized the files, do so now. */
1819 if (graph_dump_format != no_graph
1820 && dump_file[index].graph_dump_p)
1822 dump_name = concat (seq, dump_file[index].extension, NULL);
1823 clean_graph_dump_file (dump_base_name, dump_name);
1824 free (dump_name);
1826 dump_file[index].initialized = 1;
1827 open_arg = "w";
1829 else
1830 open_arg = "a";
1832 dump_name = concat (dump_base_name, seq,
1833 dump_file[index].extension, NULL);
1835 rtl_dump_file = fopen (dump_name, open_arg);
1836 if (rtl_dump_file == NULL)
1837 pfatal_with_name (dump_name);
1839 free (dump_name);
1841 if (decl)
1842 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1843 decl_printable_name (decl, 2));
1845 timevar_pop (TV_DUMP);
1846 return 1;
1849 /* Routine to close a dump file. */
1851 static void
1852 close_dump_file (index, func, insns)
1853 enum dump_file_index index;
1854 void (*func) PARAMS ((FILE *, rtx));
1855 rtx insns;
1857 if (! rtl_dump_file)
1858 return;
1860 timevar_push (TV_DUMP);
1861 if (insns
1862 && graph_dump_format != no_graph
1863 && dump_file[index].graph_dump_p)
1865 char seq[16];
1866 char *suffix;
1868 sprintf (seq, ".%02d.", index);
1869 suffix = concat (seq, dump_file[index].extension, NULL);
1870 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1871 free (suffix);
1874 if (func && insns)
1875 func (rtl_dump_file, insns);
1877 fflush (rtl_dump_file);
1878 fclose (rtl_dump_file);
1880 rtl_dump_file = NULL;
1881 timevar_pop (TV_DUMP);
1884 /* Do any final processing required for the declarations in VEC, of
1885 which there are LEN. We write out inline functions and variables
1886 that have been deferred until this point, but which are required.
1887 Returns non-zero if anything was put out. */
1890 wrapup_global_declarations (vec, len)
1891 tree *vec;
1892 int len;
1894 tree decl;
1895 int i;
1896 int reconsider;
1897 int output_something = 0;
1899 for (i = 0; i < len; i++)
1901 decl = vec[i];
1903 /* We're not deferring this any longer. */
1904 DECL_DEFER_OUTPUT (decl) = 0;
1906 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
1907 && incomplete_decl_finalize_hook != 0)
1908 (*incomplete_decl_finalize_hook) (decl);
1911 /* Now emit any global variables or functions that we have been
1912 putting off. We need to loop in case one of the things emitted
1913 here references another one which comes earlier in the list. */
1916 reconsider = 0;
1917 for (i = 0; i < len; i++)
1919 decl = vec[i];
1921 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1922 continue;
1924 /* Don't write out static consts, unless we still need them.
1926 We also keep static consts if not optimizing (for debugging),
1927 unless the user specified -fno-keep-static-consts.
1928 ??? They might be better written into the debug information.
1929 This is possible when using DWARF.
1931 A language processor that wants static constants to be always
1932 written out (even if it is not used) is responsible for
1933 calling rest_of_decl_compilation itself. E.g. the C front-end
1934 calls rest_of_decl_compilation from finish_decl.
1935 One motivation for this is that is conventional in some
1936 environments to write things like:
1937 static const char rcsid[] = "... version string ...";
1938 intending to force the string to be in the executable.
1940 A language processor that would prefer to have unneeded
1941 static constants "optimized away" would just defer writing
1942 them out until here. E.g. C++ does this, because static
1943 constants are often defined in header files.
1945 ??? A tempting alternative (for both C and C++) would be
1946 to force a constant to be written if and only if it is
1947 defined in a main file, as opposed to an include file. */
1949 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1950 && (! TREE_READONLY (decl)
1951 || TREE_PUBLIC (decl)
1952 || (!optimize && flag_keep_static_consts)
1953 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1955 reconsider = 1;
1956 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1959 if (TREE_CODE (decl) == FUNCTION_DECL
1960 && DECL_INITIAL (decl) != 0
1961 && DECL_SAVED_INSNS (decl) != 0
1962 && (flag_keep_inline_functions
1963 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1964 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1966 reconsider = 1;
1967 output_inline_function (decl);
1971 if (reconsider)
1972 output_something = 1;
1974 while (reconsider);
1976 return output_something;
1979 /* Issue appropriate warnings for the global declarations in VEC (of
1980 which there are LEN). Output debugging information for them. */
1982 void
1983 check_global_declarations (vec, len)
1984 tree *vec;
1985 int len;
1987 tree decl;
1988 int i;
1990 for (i = 0; i < len; i++)
1992 decl = vec[i];
1994 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1995 && ! TREE_ASM_WRITTEN (decl))
1996 /* Cancel the RTL for this decl so that, if debugging info
1997 output for global variables is still to come,
1998 this one will be omitted. */
1999 DECL_RTL (decl) = NULL;
2001 /* Warn about any function
2002 declared static but not defined.
2003 We don't warn about variables,
2004 because many programs have static variables
2005 that exist only to get some text into the object file. */
2006 if (TREE_CODE (decl) == FUNCTION_DECL
2007 && (warn_unused_function
2008 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2009 && DECL_INITIAL (decl) == 0
2010 && DECL_EXTERNAL (decl)
2011 && ! DECL_ARTIFICIAL (decl)
2012 && ! TREE_PUBLIC (decl))
2014 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2015 pedwarn_with_decl (decl,
2016 "`%s' used but never defined");
2017 else
2018 warning_with_decl (decl,
2019 "`%s' declared `static' but never defined");
2020 /* This symbol is effectively an "extern" declaration now. */
2021 TREE_PUBLIC (decl) = 1;
2022 assemble_external (decl);
2025 /* Warn about static fns or vars defined but not used,
2026 but not about inline functions or static consts
2027 since defining those in header files is normal practice. */
2028 if (((warn_unused_function
2029 && TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2030 || (warn_unused_variable
2031 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2032 && ! DECL_IN_SYSTEM_HEADER (decl)
2033 && ! DECL_EXTERNAL (decl)
2034 && ! TREE_PUBLIC (decl)
2035 && ! TREE_USED (decl)
2036 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2037 /* The TREE_USED bit for file-scope decls
2038 is kept in the identifier, to handle multiple
2039 external decls in different scopes. */
2040 && ! TREE_USED (DECL_NAME (decl)))
2041 warning_with_decl (decl, "`%s' defined but not used");
2043 timevar_push (TV_SYMOUT);
2044 #ifdef SDB_DEBUGGING_INFO
2045 /* The COFF linker can move initialized global vars to the end.
2046 And that can screw up the symbol ordering.
2047 By putting the symbols in that order to begin with,
2048 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2049 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2050 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2051 && ! DECL_EXTERNAL (decl)
2052 && DECL_RTL (decl) != 0)
2053 sdbout_symbol (decl, 0);
2055 /* Output COFF information for non-global
2056 file-scope initialized variables. */
2057 if (write_symbols == SDB_DEBUG
2058 && TREE_CODE (decl) == VAR_DECL
2059 && DECL_INITIAL (decl)
2060 && ! DECL_EXTERNAL (decl)
2061 && DECL_RTL (decl) != 0
2062 && GET_CODE (DECL_RTL (decl)) == MEM)
2063 sdbout_toplevel_data (decl);
2064 #endif /* SDB_DEBUGGING_INFO */
2065 #ifdef DWARF_DEBUGGING_INFO
2066 /* Output DWARF information for file-scope tentative data object
2067 declarations, file-scope (extern) function declarations (which
2068 had no corresponding body) and file-scope tagged type declarations
2069 and definitions which have not yet been forced out. */
2071 if (write_symbols == DWARF_DEBUG
2072 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2073 dwarfout_file_scope_decl (decl, 1);
2074 #endif
2075 #ifdef DWARF2_DEBUGGING_INFO
2076 /* Output DWARF2 information for file-scope tentative data object
2077 declarations, file-scope (extern) function declarations (which
2078 had no corresponding body) and file-scope tagged type declarations
2079 and definitions which have not yet been forced out. */
2081 if (write_symbols == DWARF2_DEBUG
2082 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2083 dwarf2out_decl (decl);
2084 #endif
2085 timevar_pop (TV_SYMOUT);
2089 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2090 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2091 INPUT_FILENAME and LINENO accordingly. */
2093 void
2094 push_srcloc (file, line)
2095 const char *file;
2096 int line;
2098 struct file_stack *fs;
2100 if (input_file_stack)
2102 input_file_stack->name = input_filename;
2103 input_file_stack->line = lineno;
2106 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2107 fs->name = input_filename = file;
2108 fs->line = lineno = line;
2109 fs->indent_level = 0;
2110 fs->next = input_file_stack;
2111 input_file_stack = fs;
2112 input_file_stack_tick++;
2115 /* Pop the top entry off the stack of presently open source files.
2116 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2117 the stack. */
2119 void
2120 pop_srcloc ()
2122 struct file_stack *fs;
2124 fs = input_file_stack;
2125 input_file_stack = fs->next;
2126 free (fs);
2127 input_file_stack_tick++;
2128 /* The initial souce file is never popped. */
2129 if (!input_file_stack)
2130 abort ();
2131 input_filename = input_file_stack->name;
2132 lineno = input_file_stack->line;
2135 /* Compile an entire file of output from cpp, named NAME.
2136 Write a file of assembly output and various debugging dumps. */
2138 static void
2139 compile_file (name)
2140 const char *name;
2142 tree globals;
2144 int name_specified = name != 0;
2146 if (dump_base_name == 0)
2147 dump_base_name = name ? name : "gccdump";
2149 if (! quiet_flag)
2150 time_report = 1;
2152 /* Start timing total execution time. */
2154 init_timevar ();
2155 timevar_start (TV_TOTAL);
2157 /* Initialize data in various passes. */
2159 init_obstacks ();
2160 init_tree_codes ();
2161 name = init_parse (name);
2162 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2163 || debug_info_level == DINFO_LEVEL_VERBOSE
2164 || flag_test_coverage
2165 || warn_notreached);
2166 init_regs ();
2167 init_alias_once ();
2168 init_decl_processing ();
2169 init_optabs ();
2170 init_stmt ();
2171 init_eh ();
2172 init_loop ();
2173 init_reload ();
2174 init_function_once ();
2175 init_stor_layout_once ();
2176 init_varasm_once ();
2178 /* The following initialization functions need to generate rtl, so
2179 provide a dummy function context for them. */
2180 init_dummy_function_start ();
2181 init_expmed ();
2182 init_expr_once ();
2183 if (flag_caller_saves)
2184 init_caller_save ();
2185 expand_dummy_function_end ();
2187 /* If auxiliary info generation is desired, open the output file.
2188 This goes in the same directory as the source file--unlike
2189 all the other output files. */
2190 if (flag_gen_aux_info)
2192 aux_info_file = fopen (aux_info_file_name, "w");
2193 if (aux_info_file == 0)
2194 pfatal_with_name (aux_info_file_name);
2197 /* Open assembler code output file. Do this even if -fsyntax-only is on,
2198 because then the driver will have provided the name of a temporary
2199 file or bit bucket for us. */
2201 if (! name_specified && asm_file_name == 0)
2202 asm_out_file = stdout;
2203 else
2205 if (asm_file_name == 0)
2207 int len = strlen (dump_base_name);
2208 char *dumpname = (char *) xmalloc (len + 6);
2209 memcpy (dumpname, dump_base_name, len + 1);
2210 strip_off_ending (dumpname, len);
2211 strcat (dumpname, ".s");
2212 asm_file_name = dumpname;
2214 if (!strcmp (asm_file_name, "-"))
2215 asm_out_file = stdout;
2216 else
2217 asm_out_file = fopen (asm_file_name, "w");
2218 if (asm_out_file == 0)
2219 pfatal_with_name (asm_file_name);
2222 #ifdef IO_BUFFER_SIZE
2223 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2224 _IOFBF, IO_BUFFER_SIZE);
2225 #endif
2227 if (name != 0)
2228 name = ggc_alloc_string (name, strlen (name));
2230 input_filename = name;
2232 /* Put an entry on the input file stack for the main input file. */
2233 push_srcloc (input_filename, 0);
2235 /* Perform language-specific initialization.
2236 This may set main_input_filename. */
2237 lang_init ();
2239 /* If the input doesn't start with a #line, use the input name
2240 as the official input file name. */
2241 if (main_input_filename == 0)
2242 main_input_filename = name;
2244 if (flag_syntax_only)
2246 write_symbols = NO_DEBUG;
2247 profile_flag = 0;
2248 profile_block_flag = 0;
2250 else
2252 ASM_FILE_START (asm_out_file);
2254 #ifdef ASM_COMMENT_START
2255 if (flag_verbose_asm)
2257 /* Print the list of options in effect. */
2258 print_version (asm_out_file, ASM_COMMENT_START);
2259 print_switch_values (asm_out_file, 0, MAX_LINE,
2260 ASM_COMMENT_START, " ", "\n");
2261 /* Add a blank line here so it appears in assembler output but not
2262 screen output. */
2263 fprintf (asm_out_file, "\n");
2265 #endif
2267 /* Output something to inform GDB that this compilation was by GCC. */
2268 #ifndef ASM_IDENTIFY_GCC
2269 fprintf (asm_out_file, "gcc2_compiled.:\n");
2270 #else
2271 ASM_IDENTIFY_GCC (asm_out_file);
2272 #endif
2274 /* Output something to identify which front-end produced this file. */
2275 #ifdef ASM_IDENTIFY_LANGUAGE
2276 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2277 #endif
2278 } /* ! flag_syntax_only */
2280 #ifndef ASM_OUTPUT_SECTION_NAME
2281 if (flag_function_sections)
2283 warning ("-ffunction-sections not supported for this target.");
2284 flag_function_sections = 0;
2286 if (flag_data_sections)
2288 warning ("-fdata-sections not supported for this target.");
2289 flag_data_sections = 0;
2291 #endif
2293 if (flag_function_sections
2294 && (profile_flag || profile_block_flag))
2296 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2297 flag_function_sections = 0;
2300 #ifndef OBJECT_FORMAT_ELF
2301 if (flag_function_sections && write_symbols != NO_DEBUG)
2302 warning ("-ffunction-sections may affect debugging on some targets.");
2303 #endif
2305 /* ??? Note: There used to be a conditional here
2306 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2307 This was to guarantee separation between gcc_compiled. and
2308 the first function, for the sake of dbx on Suns.
2309 However, having the extra zero here confused the Emacs
2310 code for unexec, and might confuse other programs too.
2311 Therefore, I took out that change.
2312 In future versions we should find another way to solve
2313 that dbx problem. -- rms, 23 May 93. */
2315 /* Don't let the first function fall at the same address
2316 as gcc_compiled., if profiling. */
2317 if (profile_flag || profile_block_flag)
2319 /* It's best if we can write a nop here since some
2320 assemblers don't tolerate zeros in the text section. */
2321 output_asm_insn (get_insn_template (CODE_FOR_nop, NULL), NULL_PTR);
2324 /* If dbx symbol table desired, initialize writing it
2325 and output the predefined types. */
2326 timevar_push (TV_SYMOUT);
2327 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2328 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2329 dbxout_init (asm_out_file, main_input_filename, getdecls ());
2330 #endif
2331 #ifdef SDB_DEBUGGING_INFO
2332 if (write_symbols == SDB_DEBUG)
2333 sdbout_init (asm_out_file, main_input_filename, getdecls ());
2334 #endif
2335 #ifdef DWARF_DEBUGGING_INFO
2336 if (write_symbols == DWARF_DEBUG)
2337 dwarfout_init (asm_out_file, main_input_filename);
2338 #endif
2339 #ifdef DWARF2_UNWIND_INFO
2340 if (dwarf2out_do_frame ())
2341 dwarf2out_frame_init ();
2342 #endif
2343 #ifdef DWARF2_DEBUGGING_INFO
2344 if (write_symbols == DWARF2_DEBUG)
2345 dwarf2out_init (asm_out_file, main_input_filename);
2346 #endif
2347 timevar_pop (TV_SYMOUT);
2349 /* Initialize yet another pass. */
2351 init_final (main_input_filename);
2352 init_branch_prob (dump_base_name);
2354 timevar_push (TV_PARSE);
2356 /* Call the parser, which parses the entire file
2357 (calling rest_of_compilation for each function). */
2359 if (yyparse () != 0)
2361 if (errorcount == 0)
2362 fnotice (stderr, "Errors detected in input file (your bison.simple is out of date)\n");
2364 /* In case there were missing closebraces,
2365 get us back to the global binding level. */
2366 while (! global_bindings_p ())
2367 poplevel (0, 0, 0);
2370 /* Compilation is now finished except for writing
2371 what's left of the symbol table output. */
2373 timevar_pop (TV_PARSE);
2375 if (flag_syntax_only)
2376 goto finish_syntax;
2378 globals = getdecls ();
2380 /* Really define vars that have had only a tentative definition.
2381 Really output inline functions that must actually be callable
2382 and have not been output so far. */
2385 int len = list_length (globals);
2386 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2387 int i;
2388 tree decl;
2390 /* Process the decls in reverse order--earliest first.
2391 Put them into VEC from back to front, then take out from front. */
2393 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2394 vec[len - i - 1] = decl;
2396 wrapup_global_declarations (vec, len);
2398 /* This must occur after the loop to output deferred functions. Else
2399 the profiler initializer would not be emitted if all the functions
2400 in this compilation unit were deferred.
2402 output_func_start_profiler can not cause any additional functions or
2403 data to need to be output, so it need not be in the deferred function
2404 loop above. */
2405 output_func_start_profiler ();
2407 /* Now that all possible functions have been output, we can dump
2408 the exception table. */
2410 #ifndef IA64_UNWIND_INFO
2411 output_exception_table ();
2412 #endif
2413 free_exception_table ();
2415 check_global_declarations (vec, len);
2417 /* Clean up. */
2418 free (vec);
2421 /* Write out any pending weak symbol declarations. */
2423 weak_finish ();
2425 /* Do dbx symbols. */
2426 timevar_push (TV_SYMOUT);
2427 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2428 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2429 dbxout_finish (asm_out_file, main_input_filename);
2430 #endif
2432 #ifdef DWARF_DEBUGGING_INFO
2433 if (write_symbols == DWARF_DEBUG)
2434 dwarfout_finish ();
2435 #endif
2437 #ifdef DWARF2_UNWIND_INFO
2438 if (dwarf2out_do_frame ())
2439 dwarf2out_frame_finish ();
2440 #endif
2442 #ifdef DWARF2_DEBUGGING_INFO
2443 if (write_symbols == DWARF2_DEBUG)
2444 dwarf2out_finish ();
2445 #endif
2446 timevar_pop (TV_SYMOUT);
2448 /* Output some stuff at end of file if nec. */
2450 end_final (dump_base_name);
2452 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2454 timevar_push (TV_DUMP);
2455 open_dump_file (DFI_bp, NULL);
2457 end_branch_prob ();
2459 close_dump_file (DFI_bp, NULL, NULL_RTX);
2460 timevar_pop (TV_DUMP);
2463 #ifdef ASM_FILE_END
2464 ASM_FILE_END (asm_out_file);
2465 #endif
2467 /* Language-specific end of compilation actions. */
2468 finish_syntax:
2469 lang_finish ();
2471 /* Close the dump files. */
2473 if (flag_gen_aux_info)
2475 fclose (aux_info_file);
2476 if (errorcount)
2477 unlink (aux_info_file_name);
2480 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2482 timevar_push (TV_DUMP);
2483 dump_combine_total_stats (rtl_dump_file);
2484 close_dump_file (DFI_combine, NULL, NULL_RTX);
2485 timevar_pop (TV_DUMP);
2488 /* Close non-debugging input and output files. Take special care to note
2489 whether fclose returns an error, since the pages might still be on the
2490 buffer chain while the file is open. */
2492 finish_parse ();
2494 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2495 fatal_io_error (asm_file_name);
2497 /* Do whatever is necessary to finish printing the graphs. */
2498 if (graph_dump_format != no_graph)
2500 int i;
2502 for (i = 0; i < DFI_MAX; ++i)
2503 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
2505 char seq[16];
2506 char *suffix;
2508 sprintf (seq, ".%02d.", i);
2509 suffix = concat (seq, dump_file[i].extension, NULL);
2510 finish_graph_dump_file (dump_base_name, suffix);
2511 free (suffix);
2515 if (mem_report)
2516 ggc_print_statistics ();
2518 /* Free up memory for the benefit of leak detectors. */
2519 free_reg_info ();
2521 /* Stop timing total execution time. */
2522 timevar_stop (TV_TOTAL);
2524 /* Print the times. */
2526 timevar_print (stderr);
2529 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2530 and TYPE_DECL nodes.
2532 This does nothing for local (non-static) variables, unless the
2533 variable is a register variable with an ASMSPEC. In that case, or
2534 if the variable is not an automatice, it sets up the RTL and
2535 outputs any assembler code (label definition, storage allocation
2536 and initialization).
2538 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2539 the assembler symbol name to be used. TOP_LEVEL is nonzero
2540 if this declaration is not within a function. */
2542 void
2543 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2544 tree decl;
2545 const char *asmspec;
2546 int top_level;
2547 int at_end;
2549 /* Declarations of variables, and of functions defined elsewhere. */
2551 /* The most obvious approach, to put an #ifndef around where
2552 this macro is used, doesn't work since it's inside a macro call. */
2553 #ifndef ASM_FINISH_DECLARE_OBJECT
2554 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2555 #endif
2557 /* Forward declarations for nested functions are not "external",
2558 but we need to treat them as if they were. */
2559 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2560 || TREE_CODE (decl) == FUNCTION_DECL)
2562 timevar_push (TV_VARCONST);
2563 make_decl_rtl (decl, asmspec, top_level);
2564 /* Initialized extern variable exists to be replaced
2565 with its value, or represents something that will be
2566 output in another file. */
2567 if (! (TREE_CODE (decl) == VAR_DECL
2568 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2569 && DECL_INITIAL (decl) != 0
2570 && DECL_INITIAL (decl) != error_mark_node))
2571 /* Don't output anything
2572 when a tentative file-scope definition is seen.
2573 But at end of compilation, do output code for them. */
2574 if (! (! at_end && top_level
2575 && (DECL_INITIAL (decl) == 0
2576 || DECL_INITIAL (decl) == error_mark_node)))
2577 assemble_variable (decl, top_level, at_end, 0);
2578 if (decl == last_assemble_variable_decl)
2580 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2581 top_level, at_end);
2583 timevar_pop (TV_VARCONST);
2585 else if (DECL_REGISTER (decl) && asmspec != 0)
2587 if (decode_reg_name (asmspec) >= 0)
2589 DECL_RTL (decl) = 0;
2590 make_decl_rtl (decl, asmspec, top_level);
2592 else
2594 error ("invalid register name `%s' for register variable", asmspec);
2595 DECL_REGISTER (decl) = 0;
2596 make_decl_rtl (decl, NULL, top_level);
2599 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2600 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2601 && TREE_CODE (decl) == TYPE_DECL)
2603 timevar_push (TV_SYMOUT);
2604 dbxout_symbol (decl, 0);
2605 timevar_pop (TV_SYMOUT);
2607 #endif
2608 #ifdef SDB_DEBUGGING_INFO
2609 else if (write_symbols == SDB_DEBUG && top_level
2610 && TREE_CODE (decl) == TYPE_DECL)
2612 timevar_push (TV_SYMOUT);
2613 sdbout_symbol (decl, 0);
2614 timevar_pop (TV_SYMOUT);
2616 #endif
2619 /* Called after finishing a record, union or enumeral type. */
2621 void
2622 rest_of_type_compilation (type, toplev)
2623 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2624 tree type;
2625 int toplev;
2626 #else
2627 tree type ATTRIBUTE_UNUSED;
2628 int toplev ATTRIBUTE_UNUSED;
2629 #endif
2631 timevar_push (TV_SYMOUT);
2632 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2633 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2634 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2635 #endif
2636 #ifdef SDB_DEBUGGING_INFO
2637 if (write_symbols == SDB_DEBUG)
2638 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2639 #endif
2640 #ifdef DWARF2_DEBUGGING_INFO
2641 if (write_symbols == DWARF2_DEBUG && toplev)
2642 dwarf2out_decl (TYPE_STUB_DECL (type));
2643 #endif
2644 timevar_pop (TV_SYMOUT);
2647 /* DECL is an inline function, whose body is present, but which is not
2648 being output at this point. (We're putting that off until we need
2649 to do it.) If there are any actions that need to take place,
2650 including the emission of debugging information for the function,
2651 this is where they should go. This function may be called by
2652 language-dependent code for front-ends that do not even generate
2653 RTL for functions that don't need to be put out. */
2655 void
2656 note_deferral_of_defined_inline_function (decl)
2657 tree decl ATTRIBUTE_UNUSED;
2659 #ifdef DWARF_DEBUGGING_INFO
2660 /* Generate the DWARF info for the "abstract" instance of a function
2661 which we may later generate inlined and/or out-of-line instances
2662 of. */
2663 if (write_symbols == DWARF_DEBUG && DECL_INLINE (decl))
2665 /* The front-end may not have set CURRENT_FUNCTION_DECL, but the
2666 DWARF code expects it to be set in this case. Intuitively,
2667 DECL is the function we just finished defining, so setting
2668 CURRENT_FUNCTION_DECL is sensible. */
2669 tree saved_cfd = current_function_decl;
2670 current_function_decl = decl;
2672 /* Let the DWARF code do its work. */
2673 set_decl_abstract_flags (decl, 1);
2674 dwarfout_file_scope_decl (decl, 0);
2675 set_decl_abstract_flags (decl, 0);
2677 /* Reset CURRENT_FUNCTION_DECL. */
2678 current_function_decl = saved_cfd;
2680 #endif
2683 /* This is called from finish_function (within yyparse)
2684 after each top-level definition is parsed.
2685 It is supposed to compile that function or variable
2686 and output the assembler code for it.
2687 After we return, the tree storage is freed. */
2689 void
2690 rest_of_compilation (decl)
2691 tree decl;
2693 register rtx insns;
2694 int tem;
2695 int failure = 0;
2696 int rebuild_label_notes_after_reload;
2697 int register_life_up_to_date;
2699 timevar_push (TV_REST_OF_COMPILATION);
2701 /* Now that we're out of the frontend, we shouldn't have any more
2702 CONCATs anywhere. */
2703 generating_concat_p = 0;
2705 /* When processing delayed functions, prepare_function_start() won't
2706 have been run to re-initialize it. */
2707 cse_not_expected = ! optimize;
2709 /* First, make sure that NOTE_BLOCK is set correctly for each
2710 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2711 if (!cfun->x_whole_function_mode_p)
2712 identify_blocks ();
2714 /* Then remove any notes we don't need. That will make iterating
2715 over the instruction sequence faster, and allow the garbage
2716 collector to reclaim the memory used by the notes. */
2717 remove_unnecessary_notes ();
2719 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2720 tree in sensible shape. So, we just recalculate it here. */
2721 if (cfun->x_whole_function_mode_p)
2722 reorder_blocks ();
2724 init_flow ();
2726 /* If we are reconsidering an inline function
2727 at the end of compilation, skip the stuff for making it inline. */
2729 if (DECL_SAVED_INSNS (decl) == 0)
2731 int inlinable = 0;
2732 tree parent;
2733 const char *lose;
2735 /* If this is nested inside an inlined external function, pretend
2736 it was only declared. Since we cannot inline such functions,
2737 generating code for this one is not only not necessary but will
2738 confuse some debugging output writers. */
2739 for (parent = DECL_CONTEXT (current_function_decl);
2740 parent != NULL_TREE;
2741 parent = get_containing_scope (parent))
2742 if (TREE_CODE (parent) == FUNCTION_DECL
2743 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2745 DECL_INITIAL (decl) = 0;
2746 goto exit_rest_of_compilation;
2749 /* If requested, consider whether to make this function inline. */
2750 if (DECL_INLINE (decl) || flag_inline_functions)
2752 timevar_push (TV_INTEGRATION);
2753 lose = function_cannot_inline_p (decl);
2754 timevar_pop (TV_INTEGRATION);
2755 if (lose || ! optimize)
2757 if (warn_inline && DECL_INLINE (decl))
2758 warning_with_decl (decl, lose);
2759 DECL_ABSTRACT_ORIGIN (decl) = 0;
2760 /* Don't really compile an extern inline function.
2761 If we can't make it inline, pretend
2762 it was only declared. */
2763 if (DECL_EXTERNAL (decl))
2765 DECL_INITIAL (decl) = 0;
2766 goto exit_rest_of_compilation;
2769 else
2770 /* ??? Note that this has the effect of making it look
2771 like "inline" was specified for a function if we choose
2772 to inline it. This isn't quite right, but it's
2773 probably not worth the trouble to fix. */
2774 inlinable = DECL_INLINE (decl) = 1;
2777 insns = get_insns ();
2779 /* Dump the rtl code if we are dumping rtl. */
2781 if (open_dump_file (DFI_rtl, decl))
2783 if (DECL_SAVED_INSNS (decl))
2784 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2785 close_dump_file (DFI_rtl, print_rtl, insns);
2788 /* If function is inline, and we don't yet know whether to
2789 compile it by itself, defer decision till end of compilation.
2790 finish_compilation will call rest_of_compilation again
2791 for those functions that need to be output. Also defer those
2792 functions that we are supposed to defer. */
2794 if (inlinable
2795 || (DECL_INLINE (decl)
2796 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2797 && ! flag_keep_inline_functions)
2798 || DECL_EXTERNAL (decl))))
2799 DECL_DEFER_OUTPUT (decl) = 1;
2801 if (DECL_INLINE (decl))
2802 /* DWARF wants seperate debugging info for abstract and
2803 concrete instances of all inline functions, including those
2804 declared inline but not inlined, and those inlined even
2805 though they weren't declared inline. Conveniently, that's
2806 what DECL_INLINE means at this point. */
2807 note_deferral_of_defined_inline_function (decl);
2809 if (DECL_DEFER_OUTPUT (decl))
2811 /* If -Wreturn-type, we have to do a bit of compilation. We just
2812 want to call jump_optimize to figure out whether or not we can
2813 fall off the end of the function; we do the minimum amount of
2814 work necessary to make that safe. And, we set optimize to zero
2815 to keep jump_optimize from working too hard. */
2816 if (warn_return_type)
2818 int saved_optimize = optimize;
2820 optimize = 0;
2821 find_exception_handler_labels ();
2822 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2823 !JUMP_AFTER_REGSCAN);
2824 optimize = saved_optimize;
2827 current_function_nothrow = nothrow_function_p ();
2828 if (current_function_nothrow)
2829 /* Now we know that this can't throw; set the flag for the benefit
2830 of other functions later in this translation unit. */
2831 TREE_NOTHROW (current_function_decl) = 1;
2833 timevar_push (TV_INTEGRATION);
2834 save_for_inline (decl);
2835 timevar_pop (TV_INTEGRATION);
2836 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2837 goto exit_rest_of_compilation;
2840 /* If specified extern inline but we aren't inlining it, we are
2841 done. This goes for anything that gets here with DECL_EXTERNAL
2842 set, not just things with DECL_INLINE. */
2843 if (DECL_EXTERNAL (decl))
2844 goto exit_rest_of_compilation;
2847 init_EXPR_INSN_LIST_cache ();
2849 ggc_collect ();
2851 /* Initialize some variables used by the optimizers. */
2852 init_function_for_compilation ();
2854 if (! DECL_DEFER_OUTPUT (decl))
2855 TREE_ASM_WRITTEN (decl) = 1;
2857 /* Now that integrate will no longer see our rtl, we need not
2858 distinguish between the return value of this function and the
2859 return value of called functions. Also, we can remove all SETs
2860 of subregs of hard registers; they are only here because of
2861 integrate.*/
2862 rtx_equal_function_value_matters = 0;
2863 purge_hard_subreg_sets (get_insns ());
2865 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2866 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2867 goto exit_rest_of_compilation;
2869 /* Emit code to get eh context, if needed. */
2870 emit_eh_context ();
2872 /* We may have potential sibling or tail recursion sites. Select one
2873 (of possibly multiple) methods of performing the call. */
2874 if (flag_optimize_sibling_calls)
2876 timevar_push (TV_JUMP);
2877 open_dump_file (DFI_sibling, decl);
2879 optimize_sibling_and_tail_recursive_calls ();
2881 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2882 timevar_pop (TV_JUMP);
2885 #ifdef FINALIZE_PIC
2886 /* If we are doing position-independent code generation, now
2887 is the time to output special prologues and epilogues.
2888 We do not want to do this earlier, because it just clutters
2889 up inline functions with meaningless insns. */
2890 if (flag_pic)
2891 FINALIZE_PIC;
2892 #endif
2894 insns = get_insns ();
2896 /* Copy any shared structure that should not be shared. */
2897 unshare_all_rtl (current_function_decl, insns);
2899 #ifdef SETJMP_VIA_SAVE_AREA
2900 /* This must be performed before virutal register instantiation. */
2901 if (current_function_calls_alloca)
2902 optimize_save_area_alloca (insns);
2903 #endif
2905 /* Instantiate all virtual registers. */
2906 instantiate_virtual_regs (current_function_decl, insns);
2908 /* Find all the EH handlers. */
2909 find_exception_handler_labels ();
2911 open_dump_file (DFI_jump, decl);
2913 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2914 are initialized and to compute whether control can drop off the end
2915 of the function. */
2917 timevar_push (TV_JUMP);
2918 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2919 before jump optimization switches branch directions. */
2920 expected_value_to_br_prob ();
2922 reg_scan (insns, max_reg_num (), 0);
2923 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2924 JUMP_AFTER_REGSCAN);
2926 timevar_pop (TV_JUMP);
2928 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2929 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2931 close_dump_file (DFI_jump, print_rtl, insns);
2932 goto exit_rest_of_compilation;
2935 timevar_push (TV_JUMP);
2937 if (optimize > 0)
2939 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2940 cleanup_cfg (insns);
2942 /* ??? Run if-conversion before delete_null_pointer_checks,
2943 since the later does not preserve the CFG. This should
2944 be changed -- no since converting if's that are going to
2945 be deleted. */
2946 timevar_push (TV_IFCVT);
2947 if_convert (0);
2948 timevar_pop (TV_IFCVT);
2950 /* Try to identify useless null pointer tests and delete them. */
2951 if (flag_delete_null_pointer_checks)
2952 delete_null_pointer_checks (insns);
2955 /* Jump optimization, and the removal of NULL pointer checks, may
2956 have reduced the number of instructions substantially. CSE, and
2957 future passes, allocate arrays whose dimensions involve the
2958 maximum instruction UID, so if we can reduce the maximum UID
2959 we'll save big on memory. */
2960 renumber_insns (rtl_dump_file);
2961 timevar_pop (TV_JUMP);
2963 close_dump_file (DFI_jump, print_rtl, insns);
2965 ggc_collect ();
2967 /* Perform common subexpression elimination.
2968 Nonzero value from `cse_main' means that jumps were simplified
2969 and some code may now be unreachable, so do
2970 jump optimization again. */
2972 if (optimize > 0)
2974 open_dump_file (DFI_cse, decl);
2975 timevar_push (TV_CSE);
2977 reg_scan (insns, max_reg_num (), 1);
2979 if (flag_thread_jumps)
2981 timevar_push (TV_JUMP);
2982 thread_jumps (insns, max_reg_num (), 1);
2983 timevar_pop (TV_JUMP);
2986 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2988 /* If we are not running the second CSE pass, then we are no longer
2989 expecting CSE to be run. */
2990 cse_not_expected = !flag_rerun_cse_after_loop;
2992 if (tem || optimize > 1)
2994 timevar_push (TV_JUMP);
2995 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2996 !JUMP_AFTER_REGSCAN);
2997 timevar_pop (TV_JUMP);
3000 /* Run this after jump optmizations remove all the unreachable code
3001 so that unreachable code will not keep values live. */
3002 delete_trivially_dead_insns (insns, max_reg_num ());
3004 /* Try to identify useless null pointer tests and delete them. */
3005 if (flag_delete_null_pointer_checks)
3007 timevar_push (TV_JUMP);
3008 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3010 cleanup_cfg (insns);
3012 delete_null_pointer_checks (insns);
3013 timevar_pop (TV_JUMP);
3016 /* The second pass of jump optimization is likely to have
3017 removed a bunch more instructions. */
3018 renumber_insns (rtl_dump_file);
3020 timevar_pop (TV_CSE);
3021 close_dump_file (DFI_cse, print_rtl, insns);
3024 open_dump_file (DFI_addressof, decl);
3026 purge_addressof (insns);
3027 reg_scan (insns, max_reg_num (), 1);
3029 close_dump_file (DFI_addressof, print_rtl, insns);
3031 ggc_collect ();
3033 if (optimize > 0 && flag_ssa)
3035 /* Convert to SSA form. */
3037 timevar_push (TV_TO_SSA);
3038 open_dump_file (DFI_ssa, decl);
3040 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3041 cleanup_cfg (insns);
3042 convert_to_ssa ();
3044 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
3045 timevar_pop (TV_TO_SSA);
3047 /* The SSA implementation uses basic block numbers in its phi
3048 nodes. Thus, changing the control-flow graph or the basic
3049 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
3050 may cause problems. */
3052 if (flag_dce)
3054 /* Remove dead code. */
3056 timevar_push (TV_DEAD_CODE_ELIM);
3057 open_dump_file (DFI_dce, decl);
3059 insns = get_insns ();
3060 eliminate_dead_code();
3062 close_dump_file (DFI_dce, print_rtl_with_bb, insns);
3063 timevar_pop (TV_DEAD_CODE_ELIM);
3066 /* Convert from SSA form. */
3068 timevar_push (TV_FROM_SSA);
3069 open_dump_file (DFI_ussa, decl);
3071 convert_from_ssa ();
3072 /* New registers have been created. Rescan their usage. */
3073 reg_scan (insns, max_reg_num (), 1);
3074 /* Life analysis used in SSA adds log_links but these
3075 shouldn't be there until the flow stage, so clear
3076 them away. */
3077 clear_log_links (insns);
3079 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
3080 timevar_pop (TV_FROM_SSA);
3082 ggc_collect ();
3085 /* Perform global cse. */
3087 if (optimize > 0 && flag_gcse)
3089 timevar_push (TV_GCSE);
3090 open_dump_file (DFI_gcse, decl);
3092 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3093 cleanup_cfg (insns);
3094 tem = gcse_main (insns, rtl_dump_file);
3096 /* If gcse altered any jumps, rerun jump optimizations to clean
3097 things up. */
3098 if (tem)
3100 timevar_push (TV_JUMP);
3101 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3102 !JUMP_AFTER_REGSCAN);
3103 timevar_pop (TV_JUMP);
3106 close_dump_file (DFI_gcse, print_rtl, insns);
3107 timevar_pop (TV_GCSE);
3109 ggc_collect ();
3112 /* Move constant computations out of loops. */
3114 if (optimize > 0)
3116 timevar_push (TV_LOOP);
3117 open_dump_file (DFI_loop, decl);
3119 if (flag_rerun_loop_opt)
3121 /* We only want to perform unrolling once. */
3123 loop_optimize (insns, rtl_dump_file, 0);
3125 /* The first call to loop_optimize makes some instructions
3126 trivially dead. We delete those instructions now in the
3127 hope that doing so will make the heuristics in loop work
3128 better and possibly speed up compilation. */
3129 delete_trivially_dead_insns (insns, max_reg_num ());
3131 /* The regscan pass is currently necessary as the alias
3132 analysis code depends on this information. */
3133 reg_scan (insns, max_reg_num (), 1);
3135 loop_optimize (insns, rtl_dump_file,
3136 (flag_unroll_loops ? LOOP_UNROLL : 0) | LOOP_BCT);
3138 close_dump_file (DFI_loop, print_rtl, insns);
3139 timevar_pop (TV_LOOP);
3141 ggc_collect ();
3144 if (optimize > 0)
3146 timevar_push (TV_CSE2);
3147 open_dump_file (DFI_cse2, decl);
3149 if (flag_rerun_cse_after_loop)
3151 /* Running another jump optimization pass before the second
3152 cse pass sometimes simplifies the RTL enough to allow
3153 the second CSE pass to do a better job. Jump_optimize can change
3154 max_reg_num so we must rerun reg_scan afterwards.
3155 ??? Rework to not call reg_scan so often. */
3156 timevar_push (TV_JUMP);
3158 reg_scan (insns, max_reg_num (), 0);
3159 jump_optimize (insns, !JUMP_CROSS_JUMP,
3160 !JUMP_NOOP_MOVES, JUMP_AFTER_REGSCAN);
3162 timevar_push (TV_IFCVT);
3164 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3165 cleanup_cfg (insns);
3166 if_convert (0);
3168 timevar_pop(TV_IFCVT);
3170 timevar_pop (TV_JUMP);
3172 reg_scan (insns, max_reg_num (), 0);
3173 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3175 if (tem)
3177 timevar_push (TV_JUMP);
3178 jump_optimize (insns, !JUMP_CROSS_JUMP,
3179 !JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3180 timevar_pop (TV_JUMP);
3184 if (flag_thread_jumps)
3186 /* This pass of jump threading straightens out code
3187 that was kinked by loop optimization. */
3188 timevar_push (TV_JUMP);
3189 reg_scan (insns, max_reg_num (), 0);
3190 thread_jumps (insns, max_reg_num (), 0);
3191 timevar_pop (TV_JUMP);
3194 close_dump_file (DFI_cse2, print_rtl, insns);
3195 timevar_pop (TV_CSE2);
3197 ggc_collect ();
3200 cse_not_expected = 1;
3202 regclass_init ();
3204 /* Do control and data flow analysis; wrote some of the results to
3205 the dump file. */
3207 timevar_push (TV_FLOW);
3208 open_dump_file (DFI_cfg, decl);
3210 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3211 cleanup_cfg (insns);
3212 check_function_return_warnings ();
3214 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
3216 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3218 timevar_push (TV_BRANCH_PROB);
3219 open_dump_file (DFI_bp, decl);
3221 branch_prob ();
3223 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
3224 timevar_pop (TV_BRANCH_PROB);
3227 open_dump_file (DFI_life, decl);
3228 if (optimize)
3230 struct loops loops;
3232 /* Discover and record the loop depth at the head of each basic
3233 block. The loop infrastructure does the real job for us. */
3234 flow_loops_find (&loops, LOOP_TREE);
3236 /* Estimate using heuristics if no profiling info is available. */
3237 estimate_probability (&loops);
3239 if (rtl_dump_file)
3240 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
3242 flow_loops_free (&loops);
3244 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3245 mark_constant_function ();
3246 timevar_pop (TV_FLOW);
3248 register_life_up_to_date = 1;
3249 no_new_pseudos = 1;
3251 if (warn_uninitialized || extra_warnings)
3253 uninitialized_vars_warning (DECL_INITIAL (decl));
3254 if (extra_warnings)
3255 setjmp_args_warning ();
3258 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3260 ggc_collect ();
3262 /* If -opt, try combining insns through substitution. */
3264 if (optimize > 0)
3266 int rebuild_jump_labels_after_combine = 0;
3268 timevar_push (TV_COMBINE);
3269 open_dump_file (DFI_combine, decl);
3271 rebuild_jump_labels_after_combine
3272 = combine_instructions (insns, max_reg_num ());
3274 /* Combining insns may have turned an indirect jump into a
3275 direct jump. Rebuid the JUMP_LABEL fields of jumping
3276 instructions. */
3277 if (rebuild_jump_labels_after_combine)
3279 timevar_push (TV_JUMP);
3280 rebuild_jump_labels (insns);
3281 timevar_pop (TV_JUMP);
3283 timevar_push (TV_FLOW);
3284 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3285 cleanup_cfg (insns);
3287 /* Blimey. We've got to have the CFG up to date for the call to
3288 if_convert below. However, the random deletion of blocks
3289 without updating life info can wind up with Wierd Stuff in
3290 global_live_at_end. We then run sched1, which updates things
3291 properly, discovers the wierdness and aborts. */
3292 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
3293 PROP_DEATH_NOTES | PROP_KILL_DEAD_CODE
3294 | PROP_SCAN_DEAD_CODE);
3296 timevar_pop (TV_FLOW);
3299 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3300 timevar_pop (TV_COMBINE);
3302 ggc_collect ();
3305 /* Rerun if-conversion, as combine may have simplified things enough to
3306 now meet sequence length restrictions. */
3307 if (optimize > 0)
3309 timevar_push (TV_IFCVT);
3310 open_dump_file (DFI_ce, decl);
3312 no_new_pseudos = 0;
3313 if_convert (1);
3314 no_new_pseudos = 1;
3316 close_dump_file (DFI_ce, print_rtl_with_bb, insns);
3317 timevar_pop (TV_IFCVT);
3320 /* Register allocation pre-pass, to reduce number of moves
3321 necessary for two-address machines. */
3322 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3324 timevar_push (TV_REGMOVE);
3325 open_dump_file (DFI_regmove, decl);
3327 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3329 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3330 timevar_pop (TV_REGMOVE);
3332 ggc_collect ();
3335 /* Any of the several passes since flow1 will have munged register
3336 lifetime data a bit. */
3337 if (optimize > 0)
3338 register_life_up_to_date = 0;
3340 #ifdef OPTIMIZE_MODE_SWITCHING
3341 if (optimize)
3343 timevar_push (TV_GCSE);
3345 if (optimize_mode_switching (NULL_PTR))
3347 /* We did work, and so had to regenerate global life information.
3348 Take advantage of this and don't re-recompute register life
3349 information below. */
3350 register_life_up_to_date = 1;
3353 timevar_pop (TV_GCSE);
3355 #endif
3357 #ifdef INSN_SCHEDULING
3359 /* Print function header into sched dump now
3360 because doing the sched analysis makes some of the dump. */
3361 if (optimize > 0 && flag_schedule_insns)
3363 timevar_push (TV_SCHED);
3364 open_dump_file (DFI_sched, decl);
3366 /* Do control and data sched analysis,
3367 and write some of the results to dump file. */
3369 schedule_insns (rtl_dump_file);
3371 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3372 timevar_pop (TV_SCHED);
3374 ggc_collect ();
3376 /* Register lifetime information was updated as part of verifying
3377 the schedule. */
3378 register_life_up_to_date = 1;
3380 #endif
3382 /* Determine if the current function is a leaf before running reload
3383 since this can impact optimizations done by the prologue and
3384 epilogue thus changing register elimination offsets. */
3385 current_function_is_leaf = leaf_function_p ();
3387 timevar_push (TV_LOCAL_ALLOC);
3388 open_dump_file (DFI_lreg, decl);
3390 /* Allocate pseudo-regs that are used only within 1 basic block.
3392 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3393 jump optimizer after register allocation and reloading are finished. */
3395 if (! register_life_up_to_date)
3396 recompute_reg_usage (insns, ! optimize_size);
3397 regclass (insns, max_reg_num (), rtl_dump_file);
3398 rebuild_label_notes_after_reload = local_alloc ();
3400 timevar_pop (TV_LOCAL_ALLOC);
3402 if (dump_file[DFI_lreg].enabled)
3404 timevar_push (TV_DUMP);
3406 dump_flow_info (rtl_dump_file);
3407 dump_local_alloc (rtl_dump_file);
3409 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3410 timevar_pop (TV_DUMP);
3413 ggc_collect ();
3415 timevar_push (TV_GLOBAL_ALLOC);
3416 open_dump_file (DFI_greg, decl);
3418 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3419 pass fixing up any insns that are invalid. */
3421 if (optimize)
3422 failure = global_alloc (rtl_dump_file);
3423 else
3425 build_insn_chain (insns);
3426 failure = reload (insns, 0);
3429 timevar_pop (TV_GLOBAL_ALLOC);
3431 if (failure)
3432 goto exit_rest_of_compilation;
3434 ggc_collect ();
3436 /* Do a very simple CSE pass over just the hard registers. */
3437 if (optimize > 0)
3439 timevar_push (TV_RELOAD_CSE_REGS);
3440 reload_cse_regs (insns);
3441 timevar_pop (TV_RELOAD_CSE_REGS);
3444 /* If optimizing, then go ahead and split insns now since we are about
3445 to recompute flow information anyway. */
3446 if (optimize > 0)
3448 int old_labelnum = max_label_num ();
3450 split_all_insns (0);
3451 rebuild_label_notes_after_reload |= old_labelnum != max_label_num ();
3454 /* Register allocation and reloading may have turned an indirect jump into
3455 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3456 jumping instructions. */
3457 if (rebuild_label_notes_after_reload)
3459 timevar_push (TV_JUMP);
3461 rebuild_jump_labels (insns);
3463 timevar_pop (TV_JUMP);
3466 if (dump_file[DFI_greg].enabled)
3468 timevar_push (TV_DUMP);
3470 dump_global_regs (rtl_dump_file);
3472 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3473 timevar_pop (TV_DUMP);
3476 /* Re-create the death notes which were deleted during reload. */
3477 timevar_push (TV_FLOW2);
3478 open_dump_file (DFI_flow2, decl);
3480 jump_optimize (insns, !JUMP_CROSS_JUMP,
3481 !JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3482 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3484 /* On some machines, the prologue and epilogue code, or parts thereof,
3485 can be represented as RTL. Doing so lets us schedule insns between
3486 it and the rest of the code and also allows delayed branch
3487 scheduling to operate in the epilogue. */
3488 thread_prologue_and_epilogue_insns (insns);
3490 if (optimize)
3492 cleanup_cfg (insns);
3493 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3495 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3496 even for machines with possibly nonzero RETURN_POPS_ARGS
3497 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3498 push instructions will have popping returns. */
3499 #ifndef PUSH_ROUNDING
3500 if (!ACCUMULATE_OUTGOING_ARGS)
3501 #endif
3502 combine_stack_adjustments ();
3504 ggc_collect ();
3507 flow2_completed = 1;
3509 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3510 timevar_pop (TV_FLOW2);
3512 if (optimize > 0)
3514 timevar_push (TV_IFCVT2);
3515 open_dump_file (DFI_ce2, decl);
3517 if_convert (1);
3519 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3520 timevar_pop (TV_IFCVT2);
3523 #ifdef HAVE_peephole2
3524 if (optimize > 0 && flag_peephole2)
3526 timevar_push (TV_PEEPHOLE2);
3527 open_dump_file (DFI_peephole2, decl);
3529 peephole2_optimize (rtl_dump_file);
3531 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3532 timevar_pop (TV_PEEPHOLE2);
3534 #endif
3536 if (optimize > 0 && flag_rename_registers)
3538 timevar_push (TV_RENAME_REGISTERS);
3539 open_dump_file (DFI_rnreg, decl);
3541 regrename_optimize ();
3543 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3544 timevar_pop (TV_RENAME_REGISTERS);
3547 #ifdef INSN_SCHEDULING
3548 if (optimize > 0 && flag_schedule_insns_after_reload)
3550 timevar_push (TV_SCHED2);
3551 open_dump_file (DFI_sched2, decl);
3553 /* Do control and data sched analysis again,
3554 and write some more of the results to dump file. */
3556 schedule_insns (rtl_dump_file);
3558 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3559 timevar_pop (TV_SCHED2);
3561 ggc_collect ();
3563 #endif
3565 #ifdef LEAF_REGISTERS
3566 current_function_uses_only_leaf_regs
3567 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3568 #endif
3570 if (optimize > 0 && flag_reorder_blocks)
3572 timevar_push (TV_REORDER_BLOCKS);
3573 open_dump_file (DFI_bbro, decl);
3575 reorder_basic_blocks ();
3577 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3578 timevar_pop (TV_REORDER_BLOCKS);
3581 /* One more attempt to remove jumps to .+1 left by dead-store elimination.
3582 Also do cross-jumping this time and delete no-op move insns. */
3584 if (optimize > 0)
3586 timevar_push (TV_JUMP);
3587 open_dump_file (DFI_jump2, decl);
3589 jump_optimize (insns, JUMP_CROSS_JUMP, JUMP_NOOP_MOVES,
3590 !JUMP_AFTER_REGSCAN);
3592 /* CFG no longer kept up to date. */
3594 close_dump_file (DFI_jump2, print_rtl_with_bb, insns);
3595 timevar_pop (TV_JUMP);
3598 /* If a machine dependent reorganization is needed, call it. */
3599 #ifdef MACHINE_DEPENDENT_REORG
3600 open_dump_file (DFI_mach, decl);
3602 MACHINE_DEPENDENT_REORG (insns);
3604 close_dump_file (DFI_mach, print_rtl_with_bb, insns);
3606 ggc_collect ();
3607 #endif
3609 /* If a scheduling pass for delayed branches is to be done,
3610 call the scheduling code. */
3612 #ifdef DELAY_SLOTS
3613 if (optimize > 0 && flag_delayed_branch)
3615 timevar_push (TV_DBR_SCHED);
3616 open_dump_file (DFI_dbr, decl);
3618 dbr_schedule (insns, rtl_dump_file);
3620 close_dump_file (DFI_dbr, print_rtl_with_bb, insns);
3621 timevar_pop (TV_DBR_SCHED);
3623 ggc_collect ();
3625 #endif
3627 /* Shorten branches.
3629 Note this must run before reg-stack because of death note (ab)use
3630 in the ia32 backend. */
3631 timevar_push (TV_SHORTEN_BRANCH);
3632 shorten_branches (get_insns ());
3633 timevar_pop (TV_SHORTEN_BRANCH);
3635 #ifdef STACK_REGS
3636 timevar_push (TV_REG_STACK);
3637 open_dump_file (DFI_stack, decl);
3639 reg_to_stack (insns, rtl_dump_file);
3641 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3642 timevar_pop (TV_REG_STACK);
3644 ggc_collect ();
3645 #endif
3647 current_function_nothrow = nothrow_function_p ();
3648 if (current_function_nothrow)
3649 /* Now we know that this can't throw; set the flag for the benefit
3650 of other functions later in this translation unit. */
3651 TREE_NOTHROW (current_function_decl) = 1;
3653 /* Now turn the rtl into assembler code. */
3655 timevar_push (TV_FINAL);
3657 rtx x;
3658 const char *fnname;
3660 /* Get the function's name, as described by its RTL. This may be
3661 different from the DECL_NAME name used in the source file. */
3663 x = DECL_RTL (decl);
3664 if (GET_CODE (x) != MEM)
3665 abort ();
3666 x = XEXP (x, 0);
3667 if (GET_CODE (x) != SYMBOL_REF)
3668 abort ();
3669 fnname = XSTR (x, 0);
3671 assemble_start_function (decl, fnname);
3672 final_start_function (insns, asm_out_file, optimize);
3673 final (insns, asm_out_file, optimize, 0);
3674 final_end_function (insns, asm_out_file, optimize);
3675 assemble_end_function (decl, fnname);
3676 if (! quiet_flag)
3677 fflush (asm_out_file);
3679 /* Release all memory allocated by flow. */
3680 free_basic_block_vars (0);
3682 /* Release all memory held by regsets now. */
3683 regset_release_memory ();
3685 timevar_pop (TV_FINAL);
3687 ggc_collect ();
3689 /* Write DBX symbols if requested. */
3691 /* Note that for those inline functions where we don't initially
3692 know for certain that we will be generating an out-of-line copy,
3693 the first invocation of this routine (rest_of_compilation) will
3694 skip over this code by doing a `goto exit_rest_of_compilation;'.
3695 Later on, finish_compilation will call rest_of_compilation again
3696 for those inline functions that need to have out-of-line copies
3697 generated. During that call, we *will* be routed past here. */
3699 timevar_push (TV_SYMOUT);
3700 #ifdef DBX_DEBUGGING_INFO
3701 if (write_symbols == DBX_DEBUG)
3702 dbxout_function (decl);
3703 #endif
3705 #ifdef DWARF_DEBUGGING_INFO
3706 if (write_symbols == DWARF_DEBUG)
3707 dwarfout_file_scope_decl (decl, 0);
3708 #endif
3710 #ifdef DWARF2_DEBUGGING_INFO
3711 if (write_symbols == DWARF2_DEBUG)
3712 dwarf2out_decl (decl);
3713 #endif
3714 timevar_pop (TV_SYMOUT);
3716 exit_rest_of_compilation:
3718 /* In case the function was not output,
3719 don't leave any temporary anonymous types
3720 queued up for sdb output. */
3721 #ifdef SDB_DEBUGGING_INFO
3722 if (write_symbols == SDB_DEBUG)
3723 sdbout_types (NULL_TREE);
3724 #endif
3726 reload_completed = 0;
3727 flow2_completed = 0;
3728 no_new_pseudos = 0;
3730 timevar_push (TV_FINAL);
3732 /* Clear out the insn_length contents now that they are no
3733 longer valid. */
3734 init_insn_lengths ();
3736 /* Clear out the real_constant_chain before some of the rtx's
3737 it runs through become garbage. */
3738 clear_const_double_mem ();
3740 /* Show no temporary slots allocated. */
3741 init_temp_slots ();
3743 free_basic_block_vars (0);
3745 timevar_pop (TV_FINAL);
3747 /* Make sure volatile mem refs aren't considered valid operands for
3748 arithmetic insns. We must call this here if this is a nested inline
3749 function, since the above code leaves us in the init_recog state
3750 (from final.c), and the function context push/pop code does not
3751 save/restore volatile_ok.
3753 ??? Maybe it isn't necessary for expand_start_function to call this
3754 anymore if we do it here? */
3756 init_recog_no_volatile ();
3758 /* We're done with this function. Free up memory if we can. */
3759 free_after_parsing (cfun);
3760 if (! DECL_DEFER_OUTPUT (decl))
3761 free_after_compilation (cfun);
3762 cfun = 0;
3764 ggc_collect ();
3766 timevar_pop (TV_REST_OF_COMPILATION);
3769 static void
3770 display_help ()
3772 int undoc;
3773 unsigned long i;
3774 const char *lang;
3776 #ifndef USE_CPPLIB
3777 printf (_("Usage: %s input [switches]\n"), progname);
3778 printf (_("Switches:\n"));
3779 #endif
3780 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3781 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3782 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3783 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3784 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3785 printf (_(" -fdiagnostics-show-location=[once | every-line] Indicates how often source location information should be emitted, as prefix, at the beginning of diagnostics when line-wrapping\n"));
3787 for (i = ARRAY_SIZE (f_options); i--;)
3789 const char *description = f_options[i].description;
3791 if (description != NULL && * description != 0)
3792 printf (" -f%-21s %s\n",
3793 f_options[i].string, description);
3796 printf (_(" -O[number] Set optimisation level to [number]\n"));
3797 printf (_(" -Os Optimise for space rather than speed\n"));
3798 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3799 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3800 printf (_(" -w Suppress warnings\n"));
3801 printf (_(" -W Enable extra warnings\n"));
3803 for (i = ARRAY_SIZE (W_options); i--;)
3805 const char *description = W_options[i].description;
3807 if (description != NULL && * description != 0)
3808 printf (" -W%-21s %s\n",
3809 W_options[i].string, description);
3812 printf (_(" -Wunused Enable unused warnings\n"));
3813 printf (_(" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n"));
3814 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3815 printf (_(" -p Enable function profiling\n"));
3816 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3817 printf (_(" -a Enable block profiling \n"));
3818 #endif
3819 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3820 printf (_(" -ax Enable jump profiling \n"));
3821 #endif
3822 printf (_(" -o <file> Place output into <file> \n"));
3823 printf (_("\
3824 -G <number> Put global and static data smaller than <number>\n\
3825 bytes into a special section (on some targets)\n"));
3827 for (i = ARRAY_SIZE (debug_args); i--;)
3829 if (debug_args[i].description != NULL)
3830 printf (" -g%-21s %s\n",
3831 debug_args[i].arg, debug_args[i].description);
3834 printf (_(" -aux-info <file> Emit declaration info into <file>.X\n"));
3835 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3836 printf (_(" -version Display the compiler's version\n"));
3837 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3838 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3839 #if defined INSN_SCHEDULING
3840 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3841 #endif
3842 printf (_(" --help Display this information\n"));
3844 undoc = 0;
3845 lang = "language";
3847 /* Display descriptions of language specific options.
3848 If there is no description, note that there is an undocumented option.
3849 If the description is empty, do not display anything. (This allows
3850 options to be deliberately undocumented, for whatever reason).
3851 If the option string is missing, then this is a marker, indicating
3852 that the description string is in fact the name of a language, whose
3853 language specific options are to follow. */
3855 if (ARRAY_SIZE (documented_lang_options) > 1)
3857 printf (_("\nLanguage specific options:\n"));
3859 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3861 const char *description = documented_lang_options[i].description;
3862 const char *option = documented_lang_options[i].option;
3864 if (description == NULL)
3866 undoc = 1;
3868 if (extra_warnings)
3869 printf (_(" %-23.23s [undocumented]\n"), option);
3871 else if (*description == 0)
3872 continue;
3873 else if (option == NULL)
3875 if (undoc)
3876 printf
3877 (_("\nThere are undocumented %s specific options as well.\n"),
3878 lang);
3879 undoc = 0;
3881 printf (_("\n Options for %s:\n"), description);
3883 lang = description;
3885 else
3886 printf (" %-23.23s %s\n", option, description);
3890 if (undoc)
3891 printf (_("\nThere are undocumented %s specific options as well.\n"),
3892 lang);
3894 display_target_options ();
3897 static void
3898 display_target_options ()
3900 int undoc,i;
3902 if (ARRAY_SIZE (target_switches) > 1
3903 #ifdef TARGET_OPTIONS
3904 || ARRAY_SIZE (target_options) > 1
3905 #endif
3908 int doc = 0;
3910 undoc = 0;
3912 printf (_("\nTarget specific options:\n"));
3914 for (i = ARRAY_SIZE (target_switches); i--;)
3916 const char *option = target_switches[i].name;
3917 const char *description = target_switches[i].description;
3919 if (option == NULL || *option == 0)
3920 continue;
3921 else if (description == NULL)
3923 undoc = 1;
3925 if (extra_warnings)
3926 printf (_(" -m%-23.23s [undocumented]\n"), option);
3928 else if (* description != 0)
3929 doc += printf (" -m%-23.23s %s\n", option, description);
3932 #ifdef TARGET_OPTIONS
3933 for (i = ARRAY_SIZE (target_options); i--;)
3935 const char *option = target_options[i].prefix;
3936 const char *description = target_options[i].description;
3938 if (option == NULL || *option == 0)
3939 continue;
3940 else if (description == NULL)
3942 undoc = 1;
3944 if (extra_warnings)
3945 printf (_(" -m%-23.23s [undocumented]\n"), option);
3947 else if (* description != 0)
3948 doc += printf (" -m%-23.23s %s\n", option, description);
3950 #endif
3951 if (undoc)
3953 if (doc)
3954 printf (_("\nThere are undocumented target specific options as well.\n"));
3955 else
3956 printf (_(" They exist, but they are not documented.\n"));
3961 /* Parse a -d... comand line switch. */
3963 static void
3964 decode_d_option (arg)
3965 const char *arg;
3967 int i, c, matched;
3969 while (*arg)
3970 switch (c = *arg++)
3972 case 'a':
3973 for (i = 0; i < DFI_MAX; ++i)
3974 dump_file[i].enabled = 1;
3975 break;
3976 case 'A':
3977 flag_debug_asm = 1;
3978 break;
3979 case 'm':
3980 flag_print_mem = 1;
3981 break;
3982 case 'p':
3983 flag_print_asm_name = 1;
3984 break;
3985 case 'P':
3986 flag_dump_rtl_in_asm = 1;
3987 flag_print_asm_name = 1;
3988 break;
3989 case 'v':
3990 graph_dump_format = vcg;
3991 break;
3992 case 'x':
3993 rtl_dump_and_exit = 1;
3994 break;
3995 case 'y':
3996 set_yydebug (1);
3997 break;
3998 case 'D': /* These are handled by the preprocessor. */
3999 case 'I':
4000 break;
4002 default:
4003 matched = 0;
4004 for (i = 0; i < DFI_MAX; ++i)
4005 if (c == dump_file[i].debug_switch)
4007 dump_file[i].enabled = 1;
4008 matched = 1;
4011 if (! matched)
4012 warning ("unrecognized gcc debugging option: %c", c);
4013 break;
4017 /* Parse a -f... comand line switch. ARG is the value after the -f.
4018 It is safe to access 'ARG - 2' to generate the full switch name.
4019 Return the number of strings consumed. */
4021 static int
4022 decode_f_option (arg)
4023 const char *arg;
4025 int j;
4026 const char *option_value = NULL;
4028 /* Search for the option in the table of binary f options. */
4029 for (j = ARRAY_SIZE (f_options); j--;)
4031 if (!strcmp (arg, f_options[j].string))
4033 *f_options[j].variable = f_options[j].on_value;
4034 return 1;
4037 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4038 && ! strcmp (arg + 3, f_options[j].string))
4040 *f_options[j].variable = ! f_options[j].on_value;
4041 return 1;
4045 if ((option_value = skip_leading_substring (arg, "inline-limit-"))
4046 || (option_value = skip_leading_substring (arg, "inline-limit=")))
4047 inline_max_insns =
4048 read_integral_parameter (option_value, arg - 2, inline_max_insns);
4049 #ifdef INSN_SCHEDULING
4050 else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
4051 fix_sched_param ("verbose", option_value);
4052 #endif
4053 else if ((option_value = skip_leading_substring (arg, "fixed-")))
4054 fix_register (option_value, 1, 1);
4055 else if ((option_value = skip_leading_substring (arg, "call-used-")))
4056 fix_register (option_value, 0, 1);
4057 else if ((option_value = skip_leading_substring (arg, "call-saved-")))
4058 fix_register (option_value, 0, 0);
4059 else if ((option_value = skip_leading_substring (arg, "align-loops=")))
4060 align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
4061 else if ((option_value = skip_leading_substring (arg, "align-functions=")))
4062 align_functions
4063 = read_integral_parameter (option_value, arg - 2, align_functions);
4064 else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
4065 align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
4066 else if ((option_value = skip_leading_substring (arg, "align-labels=")))
4067 align_labels
4068 = read_integral_parameter (option_value, arg - 2, align_labels);
4069 else if ((option_value
4070 = skip_leading_substring (arg, "stack-limit-register=")))
4072 int reg = decode_reg_name (option_value);
4073 if (reg < 0)
4074 error ("unrecognized register name `%s'", option_value);
4075 else
4076 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
4078 else if ((option_value
4079 = skip_leading_substring (arg, "stack-limit-symbol=")))
4081 char *nm;
4082 nm = ggc_strdup (option_value);
4083 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
4085 else if ((option_value
4086 = skip_leading_substring (arg, "message-length=")))
4087 diagnostic_message_length_per_line =
4088 read_integral_parameter (option_value, arg - 2,
4089 diagnostic_message_length_per_line);
4090 else if ((option_value
4091 = skip_leading_substring (arg, "diagnostics-show-location=")))
4093 if (!strcmp (option_value, "once"))
4094 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
4095 else if (!strcmp (option_value, "every-line"))
4096 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE);
4097 else
4098 error ("Unrecognized option `%s'", arg - 2);
4100 else if (!strcmp (arg, "no-stack-limit"))
4101 stack_limit_rtx = NULL_RTX;
4102 else if (!strcmp (arg, "preprocessed"))
4103 /* Recognise this switch but do nothing. This prevents warnings
4104 about an unrecognized switch if cpplib has not been linked in. */
4106 else
4107 return 0;
4109 return 1;
4112 /* Parse a -W... comand line switch. ARG is the value after the -W.
4113 It is safe to access 'ARG - 2' to generate the full switch name.
4114 Return the number of strings consumed. */
4116 static int
4117 decode_W_option (arg)
4118 const char *arg;
4120 const char *option_value = NULL;
4121 int j;
4123 /* Search for the option in the table of binary W options. */
4125 for (j = ARRAY_SIZE (W_options); j--;)
4127 if (!strcmp (arg, W_options[j].string))
4129 *W_options[j].variable = W_options[j].on_value;
4130 return 1;
4133 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4134 && ! strcmp (arg + 3, W_options[j].string))
4136 *W_options[j].variable = ! W_options[j].on_value;
4137 return 1;
4141 if ((option_value = skip_leading_substring (arg, "id-clash-")))
4143 id_clash_len = read_integral_parameter (option_value, arg - 2, -1);
4145 if (id_clash_len != -1)
4146 warn_id_clash = 1;
4148 else if ((option_value = skip_leading_substring (arg, "larger-than-")))
4150 larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
4152 if (larger_than_size != -1)
4153 warn_larger_than = 1;
4155 else if (!strcmp (arg, "unused"))
4157 set_Wunused (1);
4159 else if (!strcmp (arg, "no-unused"))
4161 set_Wunused (0);
4163 else
4164 return 0;
4166 return 1;
4169 /* Parse a -g... comand line switch. ARG is the value after the -g.
4170 It is safe to access 'ARG - 2' to generate the full switch name.
4171 Return the number of strings consumed. */
4173 static int
4174 decode_g_option (arg)
4175 const char *arg;
4177 unsigned level;
4178 /* A lot of code assumes write_symbols == NO_DEBUG if the
4179 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4180 of what debugging type has been selected). This records the
4181 selected type. It is an error to specify more than one
4182 debugging type. */
4183 static enum debug_info_type selected_debug_type = NO_DEBUG;
4184 /* Non-zero if debugging format has been explicitly set.
4185 -g and -ggdb don't explicitly set the debugging format so
4186 -gdwarf -g3 is equivalent to -gdwarf3. */
4187 static int type_explicitly_set_p = 0;
4188 /* Indexed by enum debug_info_type. */
4189 static const char *debug_type_names[] =
4191 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4194 /* The maximum admissible debug level value. */
4195 static const unsigned max_debug_level = 3;
4197 /* Look up ARG in the table. */
4198 for (da = debug_args; da->arg; da++)
4200 const int da_len = strlen (da->arg);
4202 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4204 enum debug_info_type type = da->debug_type;
4205 const char *p = arg + da_len;
4207 if (*p && (*p < '0' || *p > '9'))
4208 continue;
4210 /* A debug flag without a level defaults to level 2.
4211 Note we do not want to call read_integral_parameter
4212 for that case since it will call atoi which
4213 will return zero.
4215 ??? We may want to generalize the interface to
4216 read_integral_parameter to better handle this case
4217 if this case shows up often. */
4218 if (*p)
4219 level = read_integral_parameter (p, 0, max_debug_level + 1);
4220 else
4221 level = 2;
4223 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4225 error ("use -gdwarf -g%d for DWARF v1, level %d",
4226 level, level);
4227 if (level == 2)
4228 error ("use -gdwarf-2 for DWARF v2");
4231 if (level > max_debug_level)
4233 warning ("\
4234 ignoring option `%s' due to invalid debug level specification",
4235 arg - 2);
4236 level = debug_info_level;
4239 if (type == NO_DEBUG)
4241 type = PREFERRED_DEBUGGING_TYPE;
4243 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4245 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4246 type = DWARF2_DEBUG;
4247 #else
4248 #ifdef DBX_DEBUGGING_INFO
4249 type = DBX_DEBUG;
4250 #endif
4251 #endif
4255 if (type == NO_DEBUG)
4256 warning ("`%s': unknown or unsupported -g option", arg - 2);
4258 /* Does it conflict with an already selected type? */
4259 if (type_explicitly_set_p
4260 /* -g/-ggdb don't conflict with anything. */
4261 && da->debug_type != NO_DEBUG
4262 && type != selected_debug_type)
4263 warning ("`%s' ignored, conflicts with `-g%s'",
4264 arg - 2, debug_type_names[(int) selected_debug_type]);
4265 else
4267 /* If the format has already been set, -g/-ggdb
4268 only change the debug level. */
4269 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4270 /* Don't change debugging type. */
4272 else
4274 selected_debug_type = type;
4275 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4278 write_symbols = (level == 0
4279 ? NO_DEBUG
4280 : selected_debug_type);
4281 use_gnu_debug_info_extensions = da->use_extensions_p;
4282 debug_info_level = (enum debug_info_level) level;
4285 break;
4289 if (! da->arg)
4290 return 0;
4292 return 1;
4295 /* Decode the first argument in the argv as a language-independent option.
4296 Return the number of strings consumed. */
4298 static unsigned int
4299 independent_decode_option (argc, argv)
4300 int argc;
4301 char **argv;
4303 char *arg = argv[0];
4305 if (arg[0] != '-' || arg[1] == 0)
4307 if (arg[0] == '+')
4308 return 0;
4310 filename = arg;
4312 return 1;
4315 arg++;
4317 if (!strcmp (arg, "-help"))
4319 display_help ();
4320 exit (0);
4323 if (!strcmp (arg, "-target-help"))
4325 display_target_options ();
4326 exit (0);
4329 if (*arg == 'Y')
4330 arg++;
4332 switch (*arg)
4334 default:
4335 return 0;
4337 case 'O':
4338 /* Already been treated in main (). Do nothing. */
4339 break;
4341 case 'm':
4342 set_target_switch (arg + 1);
4343 break;
4345 case 'f':
4346 return decode_f_option (arg + 1);
4348 case 'g':
4349 return decode_g_option (arg + 1);
4351 case 'd':
4352 if (!strcmp (arg, "dumpbase"))
4354 if (argc == 1)
4355 return 0;
4357 dump_base_name = argv[1];
4358 return 2;
4360 else
4361 decode_d_option (arg + 1);
4362 break;
4364 case 'p':
4365 if (!strcmp (arg, "pedantic"))
4366 pedantic = 1;
4367 else if (!strcmp (arg, "pedantic-errors"))
4368 flag_pedantic_errors = pedantic = 1;
4369 else if (arg[1] == 0)
4370 profile_flag = 1;
4371 else
4372 return 0;
4373 break;
4375 case 'q':
4376 if (!strcmp (arg, "quiet"))
4377 quiet_flag = 1;
4378 else
4379 return 0;
4380 break;
4382 case 'v':
4383 if (!strcmp (arg, "version"))
4384 version_flag = 1;
4385 else
4386 return 0;
4387 break;
4389 case 'w':
4390 if (arg[1] == 0)
4391 inhibit_warnings = 1;
4392 else
4393 return 0;
4394 break;
4396 case 'W':
4397 if (arg[1] == 0)
4399 extra_warnings = 1;
4400 /* We save the value of warn_uninitialized, since if they put
4401 -Wuninitialized on the command line, we need to generate a
4402 warning about not using it without also specifying -O. */
4403 if (warn_uninitialized != 1)
4404 warn_uninitialized = 2;
4406 else
4407 return decode_W_option (arg + 1);
4408 break;
4410 case 'a':
4411 if (arg[1] == 0)
4413 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4414 warning ("`-a' option (basic block profile) not supported");
4415 #else
4416 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4417 #endif
4419 else if (!strcmp (arg, "ax"))
4421 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4422 warning ("`-ax' option (jump profiling) not supported");
4423 #else
4424 profile_block_flag = (!profile_block_flag
4425 || profile_block_flag == 2) ? 2 : 3;
4426 #endif
4428 else if (!strncmp (arg, "aux-info", 8))
4430 flag_gen_aux_info = 1;
4431 if (arg[8] == '\0')
4433 if (argc == 1)
4434 return 0;
4436 aux_info_file_name = argv[1];
4437 return 2;
4439 else
4440 aux_info_file_name = arg + 8;
4442 else
4443 return 0;
4444 break;
4446 case 'o':
4447 if (arg[1] == 0)
4449 if (argc == 1)
4450 return 0;
4452 asm_file_name = argv[1];
4453 return 2;
4455 return 0;
4457 case 'G':
4459 int g_switch_val;
4460 int return_val;
4462 if (arg[1] == 0)
4464 if (argc == 1)
4465 return 0;
4467 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4468 return_val = 2;
4470 else
4472 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4473 return_val = 1;
4476 if (g_switch_val == -1)
4477 return_val = 0;
4478 else
4480 g_switch_set = TRUE;
4481 g_switch_value = g_switch_val;
4484 return return_val;
4488 return 1;
4491 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4492 Exit code is 35 if can't open files, 34 if fatal error,
4493 33 if had nonfatal errors, else success. */
4495 extern int main PARAMS ((int, char **));
4498 main (argc, argv)
4499 int argc;
4500 char **argv;
4502 register int i;
4503 char *p;
4505 /* save in case md file wants to emit args as a comment. */
4506 save_argc = argc;
4507 save_argv = argv;
4509 p = argv[0] + strlen (argv[0]);
4510 while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
4511 --p;
4512 progname = p;
4514 #ifdef HAVE_LC_MESSAGES
4515 setlocale (LC_MESSAGES, "");
4516 #endif
4517 (void) bindtextdomain (PACKAGE, localedir);
4518 (void) textdomain (PACKAGE);
4520 /* Install handler for SIGFPE, which may be received while we do
4521 compile-time floating point arithmetic. */
4522 signal (SIGFPE, float_signal);
4524 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4525 #ifdef SIGSEGV
4526 signal (SIGSEGV, crash_signal);
4527 #endif
4528 #ifdef SIGILL
4529 signal (SIGILL, crash_signal);
4530 #endif
4531 #ifdef SIGBUS
4532 signal (SIGBUS, crash_signal);
4533 #endif
4534 #ifdef SIGABRT
4535 signal (SIGABRT, crash_signal);
4536 #endif
4537 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4538 signal (SIGIOT, crash_signal);
4539 #endif
4541 decl_printable_name = decl_name;
4542 lang_expand_expr = (lang_expand_expr_t) do_abort;
4544 /* Initialize whether `char' is signed. */
4545 flag_signed_char = DEFAULT_SIGNED_CHAR;
4546 #ifdef DEFAULT_SHORT_ENUMS
4547 /* Initialize how much space enums occupy, by default. */
4548 flag_short_enums = DEFAULT_SHORT_ENUMS;
4549 #endif
4551 /* Initialize the garbage-collector. */
4552 init_ggc ();
4553 ggc_add_root (&input_file_stack, 1, sizeof input_file_stack,
4554 mark_file_stack);
4555 ggc_add_rtx_root (&stack_limit_rtx, 1);
4556 ggc_add_tree_root (&current_function_decl, 1);
4557 ggc_add_tree_root (&current_function_func_begin_label, 1);
4559 /* Initialize the diagnostics reporting machinery. */
4560 initialize_diagnostics ();
4562 /* Perform language-specific options intialization. */
4563 lang_init_options ();
4565 /* Scan to see what optimization level has been specified. That will
4566 determine the default value of many flags. */
4567 for (i = 1; i < argc; i++)
4569 if (!strcmp (argv[i], "-O"))
4571 optimize = 1;
4572 optimize_size = 0;
4574 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4576 /* Handle -Os, -O2, -O3, -O69, ... */
4577 char *p = &argv[i][2];
4579 if ((p[0] == 's') && (p[1] == 0))
4581 optimize_size = 1;
4583 /* Optimizing for size forces optimize to be 2. */
4584 optimize = 2;
4586 else
4588 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4589 if (optimize_val != -1)
4591 optimize = optimize_val;
4592 optimize_size = 0;
4598 if (optimize >= 1)
4600 flag_defer_pop = 1;
4601 flag_thread_jumps = 1;
4602 #ifdef DELAY_SLOTS
4603 flag_delayed_branch = 1;
4604 #endif
4605 #ifdef CAN_DEBUG_WITHOUT_FP
4606 flag_omit_frame_pointer = 1;
4607 #endif
4610 if (optimize >= 2)
4612 flag_optimize_sibling_calls = 1;
4613 flag_cse_follow_jumps = 1;
4614 flag_cse_skip_blocks = 1;
4615 flag_gcse = 1;
4616 flag_expensive_optimizations = 1;
4617 flag_strength_reduce = 1;
4618 flag_rerun_cse_after_loop = 1;
4619 flag_rerun_loop_opt = 1;
4620 flag_caller_saves = 1;
4621 flag_force_mem = 1;
4622 flag_peephole2 = 1;
4623 #ifdef INSN_SCHEDULING
4624 flag_schedule_insns = 1;
4625 flag_schedule_insns_after_reload = 1;
4626 #endif
4627 flag_regmove = 1;
4628 flag_strict_aliasing = 1;
4629 flag_delete_null_pointer_checks = 1;
4630 flag_reorder_blocks = 1;
4633 if (optimize >= 3)
4635 flag_inline_functions = 1;
4638 if (optimize < 2 || optimize_size)
4640 align_loops = 1;
4641 align_jumps = 1;
4642 align_labels = 1;
4643 align_functions = 1;
4646 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4647 modify it. */
4648 target_flags = 0;
4649 set_target_switch ("");
4651 /* Unwind tables are always present in an ABI-conformant IA-64
4652 object file, so the default should be ON. */
4653 #ifdef IA64_UNWIND_INFO
4654 flag_unwind_tables = IA64_UNWIND_INFO;
4655 #endif
4657 #ifdef OPTIMIZATION_OPTIONS
4658 /* Allow default optimizations to be specified on a per-machine basis. */
4659 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4660 #endif
4662 /* Initialize register usage now so switches may override. */
4663 init_reg_sets ();
4665 /* Perform normal command line switch decoding. */
4666 for (i = 1; i < argc;)
4668 unsigned int lang_processed;
4669 unsigned int indep_processed;
4671 /* Give the language a chance to decode the option for itself. */
4672 lang_processed = lang_decode_option (argc - i, argv + i);
4674 /* Now see if the option also has a language independent meaning.
4675 Some options are both language specific and language independent,
4676 eg --help. */
4677 indep_processed = independent_decode_option (argc - i, argv + i);
4679 if (lang_processed || indep_processed)
4680 i += MAX (lang_processed, indep_processed);
4681 else
4683 const char *option = NULL;
4684 const char *lang = NULL;
4685 unsigned int j;
4687 /* It is possible that the command line switch is not valid for the
4688 current language, but it is valid for another language. In order
4689 to be compatible with previous versions of the compiler (which
4690 did not issue an error message in this case) we check for this
4691 possibility here. If we do find a match, then if extra_warnings
4692 is set we generate a warning message, otherwise we will just
4693 ignore the option. */
4694 for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4696 option = documented_lang_options[j].option;
4698 if (option == NULL)
4699 lang = documented_lang_options[j].description;
4700 else if (! strncmp (argv[i], option, strlen (option)))
4701 break;
4704 if (j != ARRAY_SIZE (documented_lang_options))
4706 if (extra_warnings)
4708 warning ("Ignoring command line option '%s'", argv[i]);
4709 if (lang)
4710 warning
4711 ("(It is valid for %s but not the selected language)",
4712 lang);
4715 else if (argv[i][0] == '-' && argv[i][1] == 'g')
4716 warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
4717 else
4718 error ("Unrecognized option `%s'", argv[i]);
4720 i++;
4724 /* Reflect any language-specific diagnostic option setting. */
4725 reshape_diagnostic_buffer ();
4727 /* Checker uses the frame pointer. */
4728 if (flag_check_memory_usage)
4729 flag_omit_frame_pointer = 0;
4731 if (optimize == 0)
4733 /* Inlining does not work if not optimizing,
4734 so force it not to be done. */
4735 flag_no_inline = 1;
4736 warn_inline = 0;
4738 /* The c_decode_option and lang_decode_option functions set
4739 this to `2' if -Wall is used, so we can avoid giving out
4740 lots of errors for people who don't realize what -Wall does. */
4741 if (warn_uninitialized == 1)
4742 warning ("-Wuninitialized is not supported without -O");
4745 #ifdef OVERRIDE_OPTIONS
4746 /* Some machines may reject certain combinations of options. */
4747 OVERRIDE_OPTIONS;
4748 #endif
4750 if (exceptions_via_longjmp == 2)
4752 #ifdef DWARF2_UNWIND_INFO
4753 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4754 #else
4755 #ifdef IA64_UNWIND_INFO
4756 exceptions_via_longjmp = ! IA64_UNWIND_INFO;
4757 #else
4758 exceptions_via_longjmp = 1;
4759 #endif
4760 #endif
4763 /* Since each function gets its own handler data, we can't support the
4764 new model currently, since it depend on a specific rethrow label
4765 which is declared at the front of the table, and we can only
4766 have one such symbol in a file. */
4767 #ifdef IA64_UNWIND_INFO
4768 flag_new_exceptions = 0;
4769 #endif
4771 /* Set up the align_*_log variables, defaulting them to 1 if they
4772 were still unset. */
4773 if (align_loops <= 0) align_loops = 1;
4774 align_loops_log = floor_log2 (align_loops * 2 - 1);
4775 if (align_jumps <= 0) align_jumps = 1;
4776 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4777 if (align_labels <= 0) align_labels = 1;
4778 align_labels_log = floor_log2 (align_labels * 2 - 1);
4779 if (align_functions <= 0) align_functions = 1;
4780 align_functions_log = floor_log2 (align_functions * 2 - 1);
4782 if (profile_block_flag == 3)
4784 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4785 profile_block_flag = 2;
4788 /* Unrolling all loops implies that standard loop unrolling must also
4789 be done. */
4790 if (flag_unroll_all_loops)
4791 flag_unroll_loops = 1;
4792 /* Loop unrolling requires that strength_reduction be on also. Silently
4793 turn on strength reduction here if it isn't already on. Also, the loop
4794 unrolling code assumes that cse will be run after loop, so that must
4795 be turned on also. */
4796 if (flag_unroll_loops)
4798 flag_strength_reduce = 1;
4799 flag_rerun_cse_after_loop = 1;
4802 /* Warn about options that are not supported on this machine. */
4803 #ifndef INSN_SCHEDULING
4804 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4805 warning ("instruction scheduling not supported on this target machine");
4806 #endif
4807 #ifndef DELAY_SLOTS
4808 if (flag_delayed_branch)
4809 warning ("this target machine does not have delayed branches");
4810 #endif
4812 user_label_prefix = USER_LABEL_PREFIX;
4813 if (flag_leading_underscore != -1)
4815 /* If the default prefix is more complicated than "" or "_",
4816 issue a warning and ignore this option. */
4817 if (user_label_prefix[0] == 0 ||
4818 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4820 user_label_prefix = flag_leading_underscore ? "_" : "";
4822 else
4823 warning ("-f%sleading-underscore not supported on this target machine",
4824 flag_leading_underscore ? "" : "no-");
4827 /* If we are in verbose mode, write out the version and maybe all the
4828 option flags in use. */
4829 if (version_flag)
4831 print_version (stderr, "");
4832 if (! quiet_flag)
4833 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4836 compile_file (filename);
4838 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
4839 if (flag_print_mem)
4841 char *lim = (char *) sbrk (0);
4843 fnotice (stderr, "Data size %ld.\n", (long) (lim - (char *) &environ));
4844 fflush (stderr);
4846 #ifndef __MSDOS__
4847 #ifdef USG
4848 system ("ps -l 1>&2");
4849 #else /* not USG */
4850 system ("ps v");
4851 #endif /* not USG */
4852 #endif
4854 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
4856 if (errorcount)
4857 return (FATAL_EXIT_CODE);
4858 if (sorrycount)
4859 return (FATAL_EXIT_CODE);
4860 return (SUCCESS_EXIT_CODE);
4863 /* Decode -m switches. */
4864 /* Decode the switch -mNAME. */
4866 static void
4867 set_target_switch (name)
4868 const char *name;
4870 register size_t j;
4871 int valid_target_option = 0;
4873 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4874 if (!strcmp (target_switches[j].name, name))
4876 if (target_switches[j].value < 0)
4877 target_flags &= ~-target_switches[j].value;
4878 else
4879 target_flags |= target_switches[j].value;
4880 valid_target_option = 1;
4883 #ifdef TARGET_OPTIONS
4884 if (!valid_target_option)
4885 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4887 int len = strlen (target_options[j].prefix);
4888 if (!strncmp (target_options[j].prefix, name, len))
4890 *target_options[j].variable = name + len;
4891 valid_target_option = 1;
4894 #endif
4896 if (!valid_target_option)
4897 error ("Invalid option `%s'", name);
4900 /* Print version information to FILE.
4901 Each line begins with INDENT (for the case where FILE is the
4902 assembler output file). */
4904 static void
4905 print_version (file, indent)
4906 FILE *file;
4907 const char *indent;
4909 #ifndef __VERSION__
4910 #define __VERSION__ "[?]"
4911 #endif
4912 fnotice (file,
4913 #ifdef __GNUC__
4914 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
4915 #else
4916 "%s%s%s version %s (%s) compiled by CC.\n"
4917 #endif
4918 , indent, *indent != 0 ? " " : "",
4919 language_string, version_string, TARGET_NAME, __VERSION__);
4922 /* Print an option value and return the adjusted position in the line.
4923 ??? We don't handle error returns from fprintf (disk full); presumably
4924 other code will catch a disk full though. */
4926 static int
4927 print_single_switch (file, pos, max, indent, sep, term, type, name)
4928 FILE *file;
4929 int pos, max;
4930 const char *indent, *sep, *term, *type, *name;
4932 /* The ultrix fprintf returns 0 on success, so compute the result we want
4933 here since we need it for the following test. */
4934 int len = strlen (sep) + strlen (type) + strlen (name);
4936 if (pos != 0
4937 && pos + len > max)
4939 fprintf (file, "%s", term);
4940 pos = 0;
4942 if (pos == 0)
4944 fprintf (file, "%s", indent);
4945 pos = strlen (indent);
4947 fprintf (file, "%s%s%s", sep, type, name);
4948 pos += len;
4949 return pos;
4952 /* Print active target switches to FILE.
4953 POS is the current cursor position and MAX is the size of a "line".
4954 Each line begins with INDENT and ends with TERM.
4955 Each switch is separated from the next by SEP. */
4957 static void
4958 print_switch_values (file, pos, max, indent, sep, term)
4959 FILE *file;
4960 int pos, max;
4961 const char *indent, *sep, *term;
4963 size_t j;
4964 char **p;
4966 /* Print the options as passed. */
4968 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4969 _("options passed: "), "");
4971 for (p = &save_argv[1]; *p != NULL; p++)
4972 if (**p == '-')
4974 /* Ignore these. */
4975 if (strcmp (*p, "-o") == 0)
4977 if (p[1] != NULL)
4978 p++;
4979 continue;
4981 if (strcmp (*p, "-quiet") == 0)
4982 continue;
4983 if (strcmp (*p, "-version") == 0)
4984 continue;
4985 if ((*p)[1] == 'd')
4986 continue;
4988 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4990 if (pos > 0)
4991 fprintf (file, "%s", term);
4993 /* Print the -f and -m options that have been enabled.
4994 We don't handle language specific options but printing argv
4995 should suffice. */
4997 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4998 _("options enabled: "), "");
5000 for (j = 0; j < ARRAY_SIZE (f_options); j++)
5001 if (*f_options[j].variable == f_options[j].on_value)
5002 pos = print_single_switch (file, pos, max, indent, sep, term,
5003 "-f", f_options[j].string);
5005 /* Print target specific options. */
5007 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
5008 if (target_switches[j].name[0] != '\0'
5009 && target_switches[j].value > 0
5010 && ((target_switches[j].value & target_flags)
5011 == target_switches[j].value))
5013 pos = print_single_switch (file, pos, max, indent, sep, term,
5014 "-m", target_switches[j].name);
5017 #ifdef TARGET_OPTIONS
5018 for (j = 0; j < ARRAY_SIZE (target_options); j++)
5019 if (*target_options[j].variable != NULL)
5021 char prefix[256];
5022 sprintf (prefix, "-m%s", target_options[j].prefix);
5023 pos = print_single_switch (file, pos, max, indent, sep, term,
5024 prefix, *target_options[j].variable);
5026 #endif
5028 fprintf (file, "%s", term);
5031 /* Record the beginning of a new source file, named FILENAME. */
5033 void
5034 debug_start_source_file (filename)
5035 register const char *filename ATTRIBUTE_UNUSED;
5037 #ifdef DBX_DEBUGGING_INFO
5038 if (write_symbols == DBX_DEBUG)
5039 dbxout_start_new_source_file (filename);
5040 #endif
5041 #ifdef DWARF_DEBUGGING_INFO
5042 if (debug_info_level == DINFO_LEVEL_VERBOSE
5043 && write_symbols == DWARF_DEBUG)
5044 dwarfout_start_new_source_file (filename);
5045 #endif /* DWARF_DEBUGGING_INFO */
5046 #ifdef DWARF2_DEBUGGING_INFO
5047 if (write_symbols == DWARF2_DEBUG)
5048 dwarf2out_start_source_file (filename);
5049 #endif /* DWARF2_DEBUGGING_INFO */
5050 #ifdef SDB_DEBUGGING_INFO
5051 if (write_symbols == SDB_DEBUG)
5052 sdbout_start_new_source_file (filename);
5053 #endif
5056 /* Record the resumption of a source file. LINENO is the line number in
5057 the source file we are returning to. */
5059 void
5060 debug_end_source_file (lineno)
5061 register unsigned lineno ATTRIBUTE_UNUSED;
5063 #ifdef DBX_DEBUGGING_INFO
5064 if (write_symbols == DBX_DEBUG)
5065 dbxout_resume_previous_source_file ();
5066 #endif
5067 #ifdef DWARF_DEBUGGING_INFO
5068 if (debug_info_level == DINFO_LEVEL_VERBOSE
5069 && write_symbols == DWARF_DEBUG)
5070 dwarfout_resume_previous_source_file (lineno);
5071 #endif /* DWARF_DEBUGGING_INFO */
5072 #ifdef DWARF2_DEBUGGING_INFO
5073 if (write_symbols == DWARF2_DEBUG)
5074 dwarf2out_end_source_file ();
5075 #endif /* DWARF2_DEBUGGING_INFO */
5076 #ifdef SDB_DEBUGGING_INFO
5077 if (write_symbols == SDB_DEBUG)
5078 sdbout_resume_previous_source_file ();
5079 #endif
5082 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5083 the tail part of the directive line, i.e. the part which is past the
5084 initial whitespace, #, whitespace, directive-name, whitespace part. */
5086 void
5087 debug_define (lineno, buffer)
5088 register unsigned lineno ATTRIBUTE_UNUSED;
5089 register char *buffer ATTRIBUTE_UNUSED;
5091 #ifdef DWARF_DEBUGGING_INFO
5092 if (debug_info_level == DINFO_LEVEL_VERBOSE
5093 && write_symbols == DWARF_DEBUG)
5094 dwarfout_define (lineno, buffer);
5095 #endif /* DWARF_DEBUGGING_INFO */
5096 #ifdef DWARF2_DEBUGGING_INFO
5097 if (debug_info_level == DINFO_LEVEL_VERBOSE
5098 && write_symbols == DWARF2_DEBUG)
5099 dwarf2out_define (lineno, buffer);
5100 #endif /* DWARF2_DEBUGGING_INFO */
5103 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5104 the tail part of the directive line, i.e. the part which is past the
5105 initial whitespace, #, whitespace, directive-name, whitespace part. */
5107 void
5108 debug_undef (lineno, buffer)
5109 register unsigned lineno ATTRIBUTE_UNUSED;
5110 register char *buffer ATTRIBUTE_UNUSED;
5112 #ifdef DWARF_DEBUGGING_INFO
5113 if (debug_info_level == DINFO_LEVEL_VERBOSE
5114 && write_symbols == DWARF_DEBUG)
5115 dwarfout_undef (lineno, buffer);
5116 #endif /* DWARF_DEBUGGING_INFO */
5117 #ifdef DWARF2_DEBUGGING_INFO
5118 if (debug_info_level == DINFO_LEVEL_VERBOSE
5119 && write_symbols == DWARF2_DEBUG)
5120 dwarf2out_undef (lineno, buffer);
5121 #endif /* DWARF2_DEBUGGING_INFO */
5124 /* Returns nonzero if it is appropriate not to emit any debugging
5125 information for BLOCK, because it doesn't contain any instructions.
5126 This may not be the case for blocks containing nested functions, since
5127 we may actually call such a function even though the BLOCK information
5128 is messed up. */
5131 debug_ignore_block (block)
5132 tree block ATTRIBUTE_UNUSED;
5134 /* Never delete the BLOCK for the outermost scope
5135 of the function; we can refer to names from
5136 that scope even if the block notes are messed up. */
5137 if (is_body_block (block))
5138 return 0;
5140 #ifdef DWARF2_DEBUGGING_INFO
5141 if (write_symbols == DWARF2_DEBUG)
5142 return dwarf2out_ignore_block (block);
5143 #endif
5145 return 1;