]> gcc.gnu.org Git - gcc.git/blob - gcc/toplev.c
1f46f35ee744a3a89800b57dc898b33d9072c0d0
[gcc.git] / gcc / toplev.c
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.
4
5 This file is part of GNU CC.
6
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.
11
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.
16
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. */
21
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. */
26
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>
33
34 #ifdef HAVE_SYS_RESOURCE_H
35 # include <sys/resource.h>
36 #endif
37
38 #ifdef HAVE_SYS_TIMES_H
39 # include <sys/times.h>
40 #endif
41
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"
67
68 #ifndef ACCUMULATE_OUTGOING_ARGS
69 #define ACCUMULATE_OUTGOING_ARGS 0
70 #endif
71
72 #ifdef DWARF_DEBUGGING_INFO
73 #include "dwarfout.h"
74 #endif
75
76 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
77 #include "dwarf2out.h"
78 #endif
79
80 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
81 #include "dbxout.h"
82 #endif
83
84 #ifdef SDB_DEBUGGING_INFO
85 #include "sdbout.h"
86 #endif
87
88 #ifdef XCOFF_DEBUGGING_INFO
89 #include "xcoffout.h"
90 #endif
91 \f
92 #ifdef VMS
93 /* The extra parameters substantially improve the I/O performance. */
94
95 static FILE *
96 vms_fopen (fname, type)
97 char *fname;
98 char *type;
99 {
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;
104
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");
110 }
111
112 #define fopen vms_fopen
113 #endif /* VMS */
114
115 #ifndef DEFAULT_GDB_EXTENSIONS
116 #define DEFAULT_GDB_EXTENSIONS 1
117 #endif
118
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.
121
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. */
145
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
151
152 #if defined (HAVE_DECL_ENVIRON) && !HAVE_DECL_ENVIRON
153 extern char **environ;
154 #endif
155
156 /* Carry information from ASM_DECLARE_OBJECT_NAME
157 to ASM_FINISH_DECLARE_OBJECT. */
158
159 extern int size_directive_output;
160 extern tree last_assemble_variable_decl;
161
162 static void set_target_switch PARAMS ((const char *));
163 static const char *decl_name PARAMS ((tree, int));
164
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 *));
175
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 **));
181
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 *));
188
189 /* Length of line when printing switch values. */
190 #define MAX_LINE 75
191
192 /* Name of program invoked, sans directories. */
193
194 const char *progname;
195
196 /* Copy of arguments to main. */
197 int save_argc;
198 char **save_argv;
199 \f
200 /* Name of current original source file (what was input to cpp).
201 This comes from each #-command in the actual input. */
202
203 const char *input_filename;
204
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. */
208
209 const char *main_input_filename;
210
211 /* Current line number in real source file. */
212
213 int lineno;
214
215 /* Nonzero if it is unsafe to create any new pseudo registers. */
216 int no_new_pseudos;
217
218 /* Stack of currently pending input files. */
219
220 struct file_stack *input_file_stack;
221
222 /* Incremented on each change to input_file_stack. */
223 int input_file_stack_tick;
224
225 /* Name to use as base of names for dump output files. */
226
227 const char *dump_base_name;
228
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. */
232
233 extern int target_flags;
234
235 /* Describes a dump file. */
236
237 struct dump_file_info
238 {
239 /* The unique extension to apply, e.g. ".jump". */
240 const char *const extension;
241
242 /* The -d<c> character that enables this dump file. */
243 char const debug_switch;
244
245 /* True if there is a corresponding graph dump file. */
246 char const graph_dump_p;
247
248 /* True if the user selected this dump. */
249 char enabled;
250
251 /* True if the files have been initialized (ie truncated). */
252 char initialized;
253 };
254
255 /* Enumerate the extant dump files. */
256
257 enum dump_file_index
258 {
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_postreload,
280 DFI_flow2,
281 DFI_peephole2,
282 DFI_rnreg,
283 DFI_ce2,
284 DFI_sched2,
285 DFI_bbro,
286 DFI_jump2,
287 DFI_mach,
288 DFI_dbr,
289 DFI_stack,
290 DFI_MAX
291 };
292
293 /* Describes all the dump files. Should be kept in order of the
294 pass and in sync with dump_file_index above.
295
296 Remaining -d letters:
297
298 " h o q u "
299 " H K OPQ TUVW YZ"
300 */
301
302 struct dump_file_info dump_file[DFI_MAX] =
303 {
304 { "rtl", 'r', 0, 0, 0 },
305 { "sibling", 'i', 0, 0, 0 },
306 { "jump", 'j', 0, 0, 0 },
307 { "cse", 's', 0, 0, 0 },
308 { "addressof", 'F', 0, 0, 0 },
309 { "ssa", 'e', 1, 0, 0 },
310 { "dce", 'X', 1, 0, 0 },
311 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
312 { "gcse", 'G', 1, 0, 0 },
313 { "loop", 'L', 1, 0, 0 },
314 { "cse2", 't', 1, 0, 0 },
315 { "cfg", 'f', 1, 0, 0 },
316 { "bp", 'b', 1, 0, 0 },
317 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
318 { "combine", 'c', 1, 0, 0 },
319 { "ce", 'C', 1, 0, 0 },
320 { "regmove", 'N', 1, 0, 0 },
321 { "sched", 'S', 1, 0, 0 },
322 { "lreg", 'l', 1, 0, 0 },
323 { "greg", 'g', 1, 0, 0 },
324 { "postreload", 'o', 1, 0, 0 },
325 { "flow2", 'w', 1, 0, 0 },
326 { "peephole2", 'z', 1, 0, 0 },
327 { "rnreg", 'n', 1, 0, 0 },
328 { "ce2", 'E', 1, 0, 0 },
329 { "sched2", 'R', 1, 0, 0 },
330 { "bbro", 'B', 1, 0, 0 },
331 { "jump2", 'J', 1, 0, 0 },
332 { "mach", 'M', 1, 0, 0 },
333 { "dbr", 'd', 0, 0, 0 },
334 { "stack", 'k', 1, 0, 0 },
335 };
336
337 static int open_dump_file PARAMS ((enum dump_file_index, tree));
338 static void close_dump_file PARAMS ((enum dump_file_index,
339 void (*) (FILE *, rtx), rtx));
340
341 /* Other flags saying which kinds of debugging dump have been requested. */
342
343 int rtl_dump_and_exit;
344 int flag_print_asm_name;
345 static int flag_print_mem;
346 static int version_flag;
347 static char *filename;
348 enum graph_dump_types graph_dump_format;
349
350 /* Name for output file of assembly code, specified with -o. */
351
352 char *asm_file_name;
353
354 /* Value of the -G xx switch, and whether it was passed or not. */
355 int g_switch_value;
356 int g_switch_set;
357
358 /* Type(s) of debugging information we are producing (if any).
359 See flags.h for the definitions of the different possible
360 types of debugging information. */
361 enum debug_info_type write_symbols = NO_DEBUG;
362
363 /* Level of debugging information we are producing. See flags.h
364 for the definitions of the different possible levels. */
365 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
366
367 /* Nonzero means use GNU-only extensions in the generated symbolic
368 debugging information. */
369 /* Currently, this only has an effect when write_symbols is set to
370 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
371 int use_gnu_debug_info_extensions = 0;
372
373 /* Nonzero means do optimizations. -O.
374 Particular numeric values stand for particular amounts of optimization;
375 thus, -O2 stores 2 here. However, the optimizations beyond the basic
376 ones are not controlled directly by this variable. Instead, they are
377 controlled by individual `flag_...' variables that are defaulted
378 based on this variable. */
379
380 int optimize = 0;
381
382 /* Nonzero means optimize for size. -Os.
383 The only valid values are zero and non-zero. When optimize_size is
384 non-zero, optimize defaults to 2, but certain individual code
385 bloating optimizations are disabled. */
386
387 int optimize_size = 0;
388
389 /* Number of error messages and warning messages so far. */
390
391 int errorcount = 0;
392 int warningcount = 0;
393 int sorrycount = 0;
394
395 /* The FUNCTION_DECL for the function currently being compiled,
396 or 0 if between functions. */
397 tree current_function_decl;
398
399 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
400 if none. */
401 tree current_function_func_begin_label;
402
403 /* Pointer to function to compute the name to use to print a declaration.
404 DECL is the declaration in question.
405 VERBOSITY determines what information will be printed:
406 0: DECL_NAME, demangled as necessary.
407 1: and scope information.
408 2: and any other information that might be interesting, such as function
409 parameter types in C++. */
410
411 const char *(*decl_printable_name) PARAMS ((tree, int));
412
413 /* Pointer to function to compute rtl for a language-specific tree code. */
414
415 typedef rtx (*lang_expand_expr_t)
416 PARAMS ((union tree_node *, rtx, enum machine_mode,
417 enum expand_modifier modifier));
418
419 lang_expand_expr_t lang_expand_expr = 0;
420
421 tree (*lang_expand_constant) PARAMS ((tree)) = 0;
422
423 /* Pointer to function to finish handling an incomplete decl at the
424 end of compilation. */
425
426 void (*incomplete_decl_finalize_hook) PARAMS ((tree)) = 0;
427
428 /* Nonzero if doing dwarf2 duplicate elimination. */
429
430 int flag_eliminate_dwarf2_dups = 0;
431
432 /* Nonzero if generating code to do profiling. */
433
434 int profile_flag = 0;
435
436 /* Nonzero if generating code to do profiling on a line-by-line basis. */
437
438 int profile_block_flag;
439
440 /* Nonzero if generating code to profile program flow graph arcs. */
441
442 int profile_arc_flag = 0;
443
444 /* Nonzero if generating info for gcov to calculate line test coverage. */
445
446 int flag_test_coverage = 0;
447
448 /* Nonzero indicates that branch taken probabilities should be calculated. */
449
450 int flag_branch_probabilities = 0;
451
452 /* Nonzero if basic blocks should be reordered. */
453
454 int flag_reorder_blocks = 0;
455
456 /* Nonzero if registers should be renamed. */
457
458 int flag_rename_registers = 0;
459
460 /* Nonzero for -pedantic switch: warn about anything
461 that standard spec forbids. */
462
463 int pedantic = 0;
464
465 /* Temporarily suppress certain warnings.
466 This is set while reading code from a system header file. */
467
468 int in_system_header = 0;
469
470 /* Don't print functions as they are compiled. -quiet. */
471
472 int quiet_flag = 0;
473
474 /* Print times taken by the various passes. -ftime-report. */
475
476 int time_report = 0;
477
478 /* Print memory still in use at end of compilation (which may have little
479 to do with peak memory consumption). -fmem-report. */
480
481 int mem_report = 0;
482
483 /* Non-zero means to collect statistics which might be expensive
484 and to print them when we are done. */
485 int flag_detailed_statistics = 0;
486
487 \f
488 /* -f flags. */
489
490 /* Nonzero means `char' should be signed. */
491
492 int flag_signed_char;
493
494 /* Nonzero means give an enum type only as many bytes as it needs. */
495
496 int flag_short_enums;
497
498 /* Nonzero for -fcaller-saves: allocate values in regs that need to
499 be saved across function calls, if that produces overall better code.
500 Optional now, so people can test it. */
501
502 #ifdef DEFAULT_CALLER_SAVES
503 int flag_caller_saves = 1;
504 #else
505 int flag_caller_saves = 0;
506 #endif
507
508 /* Nonzero if structures and unions should be returned in memory.
509
510 This should only be defined if compatibility with another compiler or
511 with an ABI is needed, because it results in slower code. */
512
513 #ifndef DEFAULT_PCC_STRUCT_RETURN
514 #define DEFAULT_PCC_STRUCT_RETURN 1
515 #endif
516
517 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
518
519 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
520
521 /* Nonzero for -fforce-mem: load memory value into a register
522 before arithmetic on it. This makes better cse but slower compilation. */
523
524 int flag_force_mem = 0;
525
526 /* Nonzero for -fforce-addr: load memory address into a register before
527 reference to memory. This makes better cse but slower compilation. */
528
529 int flag_force_addr = 0;
530
531 /* Nonzero for -fdefer-pop: don't pop args after each function call;
532 instead save them up to pop many calls' args with one insns. */
533
534 int flag_defer_pop = 0;
535
536 /* Nonzero for -ffloat-store: don't allocate floats and doubles
537 in extended-precision registers. */
538
539 int flag_float_store = 0;
540
541 /* Nonzero for -fcse-follow-jumps:
542 have cse follow jumps to do a more extensive job. */
543
544 int flag_cse_follow_jumps;
545
546 /* Nonzero for -fcse-skip-blocks:
547 have cse follow a branch around a block. */
548 int flag_cse_skip_blocks;
549
550 /* Nonzero for -fexpensive-optimizations:
551 perform miscellaneous relatively-expensive optimizations. */
552 int flag_expensive_optimizations;
553
554 /* Nonzero for -fthread-jumps:
555 have jump optimize output of loop. */
556
557 int flag_thread_jumps;
558
559 /* Nonzero enables strength-reduction in loop.c. */
560
561 int flag_strength_reduce = 0;
562
563 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
564 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
565 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
566 unrolled. */
567
568 int flag_unroll_loops;
569
570 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
571 This is generally not a win. */
572
573 int flag_unroll_all_loops;
574
575 /* Nonzero forces all invariant computations in loops to be moved
576 outside the loop. */
577
578 int flag_move_all_movables = 0;
579
580 /* Nonzero forces all general induction variables in loops to be
581 strength reduced. */
582
583 int flag_reduce_all_givs = 0;
584
585 /* Nonzero to perform full register move optimization passes. This is the
586 default for -O2. */
587
588 int flag_regmove = 0;
589
590 /* Nonzero for -fwritable-strings:
591 store string constants in data segment and don't uniquize them. */
592
593 int flag_writable_strings = 0;
594
595 /* Nonzero means don't put addresses of constant functions in registers.
596 Used for compiling the Unix kernel, where strange substitutions are
597 done on the assembly output. */
598
599 int flag_no_function_cse = 0;
600
601 /* Nonzero for -fomit-frame-pointer:
602 don't make a frame pointer in simple functions that don't require one. */
603
604 int flag_omit_frame_pointer = 0;
605
606 /* Nonzero means place each function into its own section on those platforms
607 which support arbitrary section names and unlimited numbers of sections. */
608
609 int flag_function_sections = 0;
610
611 /* ... and similar for data. */
612
613 int flag_data_sections = 0;
614
615 /* Nonzero to inhibit use of define_optimization peephole opts. */
616
617 int flag_no_peephole = 0;
618
619 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
620 operations in the interest of optimization. For example it allows
621 GCC to assume arguments to sqrt are nonnegative numbers, allowing
622 faster code for sqrt to be generated. */
623
624 int flag_fast_math = 0;
625
626 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
627
628 int flag_optimize_sibling_calls = 0;
629
630 /* Nonzero means the front end generally wants `errno' maintained by math
631 operations, like built-in SQRT, unless overridden by flag_fast_math. */
632
633 int flag_errno_math = 1;
634
635 /* 0 means straightforward implementation of complex divide acceptable.
636 1 means wide ranges of inputs must work for complex divide.
637 2 means C99-like requirements for complex divide (not yet implemented). */
638
639 int flag_complex_divide_method = 0;
640
641 /* Nonzero means all references through pointers are volatile. */
642
643 int flag_volatile;
644
645 /* Nonzero means treat all global and extern variables as volatile. */
646
647 int flag_volatile_global;
648
649 /* Nonzero means treat all static variables as volatile. */
650
651 int flag_volatile_static;
652
653 /* Nonzero means just do syntax checking; don't output anything. */
654
655 int flag_syntax_only = 0;
656
657 /* Nonzero means perform global cse. */
658
659 static int flag_gcse;
660
661 /* Nonzero means to use global dataflow analysis to eliminate
662 useless null pointer tests. */
663
664 static int flag_delete_null_pointer_checks;
665
666 /* Nonzero means to rerun cse after loop optimization. This increases
667 compilation time about 20% and picks up a few more common expressions. */
668
669 static int flag_rerun_cse_after_loop;
670
671 /* Nonzero means to run loop optimizations twice. */
672
673 int flag_rerun_loop_opt;
674
675 /* Nonzero for -finline-functions: ok to inline functions that look like
676 good inline candidates. */
677
678 int flag_inline_functions;
679
680 /* Nonzero for -fkeep-inline-functions: even if we make a function
681 go inline everywhere, keep its definition around for debugging
682 purposes. */
683
684 int flag_keep_inline_functions;
685
686 /* Nonzero means that functions will not be inlined. */
687
688 int flag_no_inline;
689
690 /* Nonzero means that we should emit static const variables
691 regardless of whether or not optimization is turned on. */
692
693 int flag_keep_static_consts = 1;
694
695 /* Nonzero means we should be saving declaration info into a .X file. */
696
697 int flag_gen_aux_info = 0;
698
699 /* Specified name of aux-info file. */
700
701 static char *aux_info_file_name;
702
703 /* Nonzero means make the text shared if supported. */
704
705 int flag_shared_data;
706
707 /* Nonzero means schedule into delayed branch slots if supported. */
708
709 int flag_delayed_branch;
710
711 /* Nonzero if we are compiling pure (sharable) code.
712 Value is 1 if we are doing reasonable (i.e. simple
713 offset into offset table) pic. Value is 2 if we can
714 only perform register offsets. */
715
716 int flag_pic;
717
718 /* Nonzero means generate extra code for exception handling and enable
719 exception handling. */
720
721 int flag_exceptions;
722
723 /* Nonzero means use the new model for exception handling. Replaces
724 -DNEW_EH_MODEL as a compile option. */
725
726 int flag_new_exceptions = 1;
727
728 /* Nonzero means generate frame unwind info table when supported. */
729
730 int flag_unwind_tables = 0;
731
732 /* Nonzero means don't place uninitialized global data in common storage
733 by default. */
734
735 int flag_no_common;
736
737 /* Nonzero means pretend it is OK to examine bits of target floats,
738 even if that isn't true. The resulting code will have incorrect constants,
739 but the same series of instructions that the native compiler would make. */
740
741 int flag_pretend_float;
742
743 /* Nonzero means change certain warnings into errors.
744 Usually these are warnings about failure to conform to some standard. */
745
746 int flag_pedantic_errors = 0;
747
748 /* flag_schedule_insns means schedule insns within basic blocks (before
749 local_alloc).
750 flag_schedule_insns_after_reload means schedule insns after
751 global_alloc. */
752
753 int flag_schedule_insns = 0;
754 int flag_schedule_insns_after_reload = 0;
755
756 /* The following flags have effect only for scheduling before register
757 allocation:
758
759 flag_schedule_interblock means schedule insns accross basic blocks.
760 flag_schedule_speculative means allow speculative motion of non-load insns.
761 flag_schedule_speculative_load means allow speculative motion of some
762 load insns.
763 flag_schedule_speculative_load_dangerous allows speculative motion of more
764 load insns. */
765
766 int flag_schedule_interblock = 1;
767 int flag_schedule_speculative = 1;
768 int flag_schedule_speculative_load = 0;
769 int flag_schedule_speculative_load_dangerous = 0;
770
771 int flag_single_precision_constant;
772
773 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
774 by a cheaper branch on a count register. */
775 int flag_branch_on_count_reg = 1;
776
777 /* -finhibit-size-directive inhibits output of .size for ELF.
778 This is used only for compiling crtstuff.c,
779 and it may be extended to other effects
780 needed for crtstuff.c on other systems. */
781 int flag_inhibit_size_directive = 0;
782
783 /* -fverbose-asm causes extra commentary information to be produced in
784 the generated assembly code (to make it more readable). This option
785 is generally only of use to those who actually need to read the
786 generated assembly code (perhaps while debugging the compiler itself).
787 -fno-verbose-asm, the default, causes the extra information
788 to be omitted and is useful when comparing two assembler files. */
789
790 int flag_verbose_asm = 0;
791
792 /* -dA causes debug commentary information to be produced in
793 the generated assembly code (to make it more readable). This option
794 is generally only of use to those who actually need to read the
795 generated assembly code (perhaps while debugging the compiler itself).
796 Currently, this switch is only used by dwarfout.c; however, it is intended
797 to be a catchall for printing debug information in the assembler file. */
798
799 int flag_debug_asm = 0;
800
801 /* -dP causes the rtl to be emitted as a comment in assembly. */
802
803 int flag_dump_rtl_in_asm = 0;
804
805 /* -fgnu-linker specifies use of the GNU linker for initializations.
806 (Or, more generally, a linker that handles initializations.)
807 -fno-gnu-linker says that collect2 will be used. */
808 #ifdef USE_COLLECT2
809 int flag_gnu_linker = 0;
810 #else
811 int flag_gnu_linker = 1;
812 #endif
813
814 /* Enable SSA. */
815 int flag_ssa = 0;
816
817 /* Enable dead code elimination. */
818 int flag_dce = 0;
819
820 /* Tag all structures with __attribute__(packed). */
821 int flag_pack_struct = 0;
822
823 /* Emit code to check for stack overflow; also may cause large objects
824 to be allocated dynamically. */
825 int flag_stack_check;
826
827 /* When non-NULL, indicates that whenever space is allocated on the
828 stack, the resulting stack pointer must not pass this
829 address---that is, for stacks that grow downward, the stack pointer
830 must always be greater than or equal to this address; for stacks
831 that grow upward, the stack pointer must be less than this address.
832 At present, the rtx may be either a REG or a SYMBOL_REF, although
833 the support provided depends on the backend. */
834 rtx stack_limit_rtx;
835
836 /* -fcheck-memory-usage causes extra code to be generated in order to check
837 memory accesses. This is used by a detector of bad memory accesses such
838 as Checker. */
839 int flag_check_memory_usage = 0;
840
841 /* -fprefix-function-name causes function name to be prefixed. This
842 can be used with -fcheck-memory-usage to isolate code compiled with
843 -fcheck-memory-usage. */
844 int flag_prefix_function_name = 0;
845
846 /* 0 if pointer arguments may alias each other. True in C.
847 1 if pointer arguments may not alias each other but may alias
848 global variables.
849 2 if pointer arguments may not alias each other and may not
850 alias global variables. True in Fortran.
851 This defaults to 0 for C. */
852 int flag_argument_noalias = 0;
853
854 /* Nonzero if we should do (language-dependent) alias analysis.
855 Typically, this analysis will assume that expressions of certain
856 types do not alias expressions of certain other types. Only used
857 if alias analysis (in general) is enabled. */
858 int flag_strict_aliasing = 0;
859
860 /* Instrument functions with calls at entry and exit, for profiling. */
861 int flag_instrument_function_entry_exit = 0;
862
863 /* Nonzero means ignore `#ident' directives. 0 means handle them.
864 On SVR4 targets, it also controls whether or not to emit a
865 string identifying the compiler. */
866
867 int flag_no_ident = 0;
868
869 /* This will perform a peephole pass before sched2. */
870 int flag_peephole2 = 0;
871
872 /* -fbounded-pointers causes gcc to compile pointers as composite
873 objects occupying three words: the pointer value, the base address
874 of the referent object, and the address immediately beyond the end
875 of the referent object. The base and extent allow us to perform
876 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
877 int flag_bounded_pointers = 0;
878
879 /* -fcheck-bounds causes gcc to generate array bounds checks.
880 For C, C++: defaults to value of flag_bounded_pointers.
881 For ObjC: defaults to off.
882 For Java: defaults to on.
883 For Fortran: defaults to off.
884 For CHILL: defaults to off. */
885 int flag_bounds_check = 0;
886
887 /* If one, renumber instruction UIDs to reduce the number of
888 unused UIDs if there are a lot of instructions. If greater than
889 one, unconditionally renumber instruction UIDs. */
890 int flag_renumber_insns = 1;
891
892 /* Values of the -falign-* flags: how much to align labels in code.
893 0 means `use default', 1 means `don't align'.
894 For each variable, there is an _log variant which is the power
895 of two not less than the variable, for .align output. */
896
897 int align_loops;
898 int align_loops_log;
899 int align_jumps;
900 int align_jumps_log;
901 int align_labels;
902 int align_labels_log;
903 int align_functions;
904 int align_functions_log;
905
906 /* Table of supported debugging formats. */
907 static struct
908 {
909 const char *arg;
910 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
911 constant expression, we use NO_DEBUG in its place. */
912 enum debug_info_type debug_type;
913 int use_extensions_p;
914 const char *description;
915 } *da,
916 debug_args[] =
917 {
918 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
919 "Generate default debug format output" },
920 { "gdb", NO_DEBUG, 1, "Generate default extended debug format output" },
921 #ifdef DBX_DEBUGGING_INFO
922 { "stabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
923 { "stabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
924 #endif
925 #ifdef DWARF_DEBUGGING_INFO
926 { "dwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
927 { "dwarf+", DWARF_DEBUG, 1,
928 "Generated extended DWARF-1 format debug output" },
929 #endif
930 #ifdef DWARF2_DEBUGGING_INFO
931 { "dwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
932 #endif
933 #ifdef XCOFF_DEBUGGING_INFO
934 { "xcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
935 { "xcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
936 #endif
937 #ifdef SDB_DEBUGGING_INFO
938 { "coff", SDB_DEBUG, 0, "Generate COFF format debug output" },
939 #endif
940 { 0, 0, 0, 0 }
941 };
942
943 typedef struct
944 {
945 const char *string;
946 int *variable;
947 int on_value;
948 const char *description;
949 }
950 lang_independent_options;
951
952 int flag_trapv = 0;
953
954 /* Add or remove a leading underscore from user symbols. */
955 int flag_leading_underscore = -1;
956
957 /* The user symbol prefix after having resolved same. */
958 const char *user_label_prefix;
959
960 /* A default for same. */
961 #ifndef USER_LABEL_PREFIX
962 #define USER_LABEL_PREFIX ""
963 #endif
964
965 /* Table of language-independent -f options.
966 STRING is the option name. VARIABLE is the address of the variable.
967 ON_VALUE is the value to store in VARIABLE
968 if `-fSTRING' is seen as an option.
969 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
970
971 lang_independent_options f_options[] =
972 {
973 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
974 "Perform DWARF2 duplicate elimination"},
975 {"float-store", &flag_float_store, 1,
976 "Do not store floats in registers" },
977 {"volatile", &flag_volatile, 1,
978 "Consider all mem refs through pointers as volatile"},
979 {"volatile-global", &flag_volatile_global, 1,
980 "Consider all mem refs to global data to be volatile" },
981 {"volatile-static", &flag_volatile_static, 1,
982 "Consider all mem refs to static data to be volatile" },
983 {"defer-pop", &flag_defer_pop, 1,
984 "Defer popping functions args from stack until later" },
985 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
986 "When possible do not generate stack frames"},
987 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
988 "Optimize sibling and tail recursive calls" },
989 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
990 "When running CSE, follow jumps to their targets" },
991 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
992 "When running CSE, follow conditional jumps" },
993 {"expensive-optimizations", &flag_expensive_optimizations, 1,
994 "Perform a number of minor, expensive optimisations" },
995 {"thread-jumps", &flag_thread_jumps, 1,
996 "Perform jump threading optimisations"},
997 {"strength-reduce", &flag_strength_reduce, 1,
998 "Perform strength reduction optimisations" },
999 {"unroll-loops", &flag_unroll_loops, 1,
1000 "Perform loop unrolling when iteration count is known" },
1001 {"unroll-all-loops", &flag_unroll_all_loops, 1,
1002 "Perform loop unrolling for all loops" },
1003 {"move-all-movables", &flag_move_all_movables, 1,
1004 "Force all loop invariant computations out of loops" },
1005 {"reduce-all-givs", &flag_reduce_all_givs, 1,
1006 "Strength reduce all loop general induction variables" },
1007 {"writable-strings", &flag_writable_strings, 1,
1008 "Store strings in writable data section" },
1009 {"peephole", &flag_no_peephole, 0,
1010 "Enable machine specific peephole optimisations" },
1011 {"force-mem", &flag_force_mem, 1,
1012 "Copy memory operands into registers before using" },
1013 {"force-addr", &flag_force_addr, 1,
1014 "Copy memory address constants into regs before using" },
1015 {"function-cse", &flag_no_function_cse, 0,
1016 "Allow function addresses to be held in registers" },
1017 {"inline-functions", &flag_inline_functions, 1,
1018 "Integrate simple functions into their callers" },
1019 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1020 "Generate code for funcs even if they are fully inlined" },
1021 {"inline", &flag_no_inline, 0,
1022 "Pay attention to the 'inline' keyword"},
1023 {"keep-static-consts", &flag_keep_static_consts, 1,
1024 "Emit static const variables even if they are not used" },
1025 {"syntax-only", &flag_syntax_only, 1,
1026 "Check for syntax errors, then stop" },
1027 {"shared-data", &flag_shared_data, 1,
1028 "Mark data as shared rather than private" },
1029 {"caller-saves", &flag_caller_saves, 1,
1030 "Enable saving registers around function calls" },
1031 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1032 "Return 'short' aggregates in memory, not registers" },
1033 {"reg-struct-return", &flag_pcc_struct_return, 0,
1034 "Return 'short' aggregates in registers" },
1035 {"delayed-branch", &flag_delayed_branch, 1,
1036 "Attempt to fill delay slots of branch instructions" },
1037 {"gcse", &flag_gcse, 1,
1038 "Perform the global common subexpression elimination" },
1039 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1040 "Run CSE pass after loop optimisations"},
1041 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1042 "Run the loop optimiser twice"},
1043 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1044 "Delete useless null pointer checks" },
1045 {"pretend-float", &flag_pretend_float, 1,
1046 "Pretend that host and target use the same FP format"},
1047 {"schedule-insns", &flag_schedule_insns, 1,
1048 "Reschedule instructions to avoid pipeline stalls"},
1049 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1050 "Run two passes of the instruction scheduler"},
1051 {"sched-interblock",&flag_schedule_interblock, 1,
1052 "Enable scheduling across basic blocks" },
1053 {"sched-spec",&flag_schedule_speculative, 1,
1054 "Allow speculative motion of non-loads" },
1055 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1056 "Allow speculative motion of some loads" },
1057 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1058 "Allow speculative motion of more loads" },
1059 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1060 "Replace add,compare,branch with branch on count reg"},
1061 {"pic", &flag_pic, 1,
1062 "Generate position independent code, if possible"},
1063 {"PIC", &flag_pic, 2, ""},
1064 {"exceptions", &flag_exceptions, 1,
1065 "Enable exception handling" },
1066 {"new-exceptions", &flag_new_exceptions, 1,
1067 "Use the new model for exception handling" },
1068 {"unwind-tables", &flag_unwind_tables, 1,
1069 "Just generate unwind tables for exception handling" },
1070 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
1071 "Use setjmp/longjmp to handle exceptions" },
1072 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
1073 "Support asynchronous exceptions" },
1074 {"profile-arcs", &profile_arc_flag, 1,
1075 "Insert arc based program profiling code" },
1076 {"test-coverage", &flag_test_coverage, 1,
1077 "Create data files needed by gcov" },
1078 {"branch-probabilities", &flag_branch_probabilities, 1,
1079 "Use profiling information for branch probabilities" },
1080 {"reorder-blocks", &flag_reorder_blocks, 1,
1081 "Reorder basic blocks to improve code placement" },
1082 {"rename-registers", &flag_rename_registers, 1,
1083 "Do the register renaming optimization pass"},
1084 {"fast-math", &flag_fast_math, 1,
1085 "Improve FP speed by violating ANSI & IEEE rules" },
1086 {"common", &flag_no_common, 0,
1087 "Do not put unitialised globals in the common section" },
1088 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1089 "Do not generate .size directives" },
1090 {"function-sections", &flag_function_sections, 1,
1091 "place each function into its own section" },
1092 {"data-sections", &flag_data_sections, 1,
1093 "place data items into their own section" },
1094 {"verbose-asm", &flag_verbose_asm, 1,
1095 "Add extra commentry to assembler output"},
1096 {"gnu-linker", &flag_gnu_linker, 1,
1097 "Output GNU ld formatted global initialisers"},
1098 {"regmove", &flag_regmove, 1,
1099 "Enables a register move optimisation"},
1100 {"optimize-register-move", &flag_regmove, 1,
1101 "Do the full regmove optimization pass"},
1102 {"pack-struct", &flag_pack_struct, 1,
1103 "Pack structure members together without holes" },
1104 {"stack-check", &flag_stack_check, 1,
1105 "Insert stack checking code into the program" },
1106 {"argument-alias", &flag_argument_noalias, 0,
1107 "Specify that arguments may alias each other & globals"},
1108 {"argument-noalias", &flag_argument_noalias, 1,
1109 "Assume arguments may alias globals but not each other"},
1110 {"argument-noalias-global", &flag_argument_noalias, 2,
1111 "Assume arguments do not alias each other or globals" },
1112 {"strict-aliasing", &flag_strict_aliasing, 1,
1113 "Assume strict aliasing rules apply" },
1114 {"align-loops", &align_loops, 0,
1115 "Align the start of loops" },
1116 {"align-jumps", &align_jumps, 0,
1117 "Align labels which are only reached by jumping" },
1118 {"align-labels", &align_labels, 0,
1119 "Align all labels" },
1120 {"align-functions", &align_functions, 0,
1121 "Align the start of functions" },
1122 {"check-memory-usage", &flag_check_memory_usage, 1,
1123 "Generate code to check every memory access" },
1124 {"prefix-function-name", &flag_prefix_function_name, 1,
1125 "Add a prefix to all function names" },
1126 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1127 "Suppress output of instruction numbers and line number notes in debugging dumps"},
1128 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1129 "Instrument function entry/exit with profiling calls"},
1130 {"ssa", &flag_ssa, 1,
1131 "Enable SSA optimizations" },
1132 {"dce", &flag_dce, 1,
1133 "Enable dead code elimination" },
1134 {"leading-underscore", &flag_leading_underscore, 1,
1135 "External symbols have a leading underscore" },
1136 {"ident", &flag_no_ident, 0,
1137 "Process #ident directives"},
1138 { "peephole2", &flag_peephole2, 1,
1139 "Enables an rtl peephole pass run before sched2" },
1140 {"math-errno", &flag_errno_math, 1,
1141 "Set errno after built-in math functions"},
1142 {"bounded-pointers", &flag_bounded_pointers, 1,
1143 "Compile pointers as triples: value, base & end" },
1144 {"bounds-check", &flag_bounds_check, 1,
1145 "Generate code to check bounds before dereferencing pointers and arrays" },
1146 {"single-precision-constant", &flag_single_precision_constant, 1,
1147 "Convert floating point constant to single precision constant"},
1148 {"time-report", &time_report, 1,
1149 "Report time taken by each compiler pass at end of run"},
1150 {"mem-report", &mem_report, 1,
1151 "Report on permanent memory allocation at end of run"},
1152 { "trapv", &flag_trapv, 1,
1153 "Trap for signed overflow in addition / subtraction / multiplication." },
1154 };
1155
1156 /* Table of language-specific options. */
1157
1158 static struct lang_opt
1159 {
1160 const char *option;
1161 const char *description;
1162 }
1163 documented_lang_options[] =
1164 {
1165 /* In order not to overload the --help output, the convention
1166 used here is to only describe those options which are not
1167 enabled by default. */
1168
1169 { "-ansi", "Compile just for ISO C89" },
1170 { "-fallow-single-precision",
1171 "Do not promote floats to double if using -traditional" },
1172 { "-std= ", "Determine language standard"},
1173
1174 { "-fsigned-bitfields", "" },
1175 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1176 { "-fno-signed-bitfields", "" },
1177 { "-fno-unsigned-bitfields","" },
1178 { "-fsigned-char", "Make 'char' be signed by default"},
1179 { "-funsigned-char", "Make 'char' be unsigned by default"},
1180 { "-fno-signed-char", "" },
1181 { "-fno-unsigned-char", "" },
1182
1183 { "-ftraditional", "" },
1184 { "-traditional", "Attempt to support traditional K&R style C"},
1185 { "-fnotraditional", "" },
1186 { "-fno-traditional", "" },
1187
1188 { "-fasm", "" },
1189 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1190 { "-fbuiltin", "" },
1191 { "-fno-builtin", "Do not recognise any built in functions" },
1192 { "-fhosted", "Assume normal C execution environment" },
1193 { "-fno-hosted", "" },
1194 { "-ffreestanding",
1195 "Assume that standard libraries & main might not exist" },
1196 { "-fno-freestanding", "" },
1197 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1198 { "-fno-cond-mismatch", "" },
1199 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1200 { "-fno-dollars-in-identifiers", "" },
1201 { "-fpreprocessed", "" },
1202 { "-fno-preprocessed", "" },
1203 { "-fshort-double", "Use the same size for double as for float" },
1204 { "-fno-short-double", "" },
1205 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1206 { "-fno-short-enums", "" },
1207 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1208 { "-fno-short-wchar", "" },
1209
1210 { "-Wall", "Enable most warning messages" },
1211 { "-Wbad-function-cast",
1212 "Warn about casting functions to incompatible types" },
1213 { "-Wno-bad-function-cast", "" },
1214 { "-Wmissing-noreturn",
1215 "Warn about functions which might be candidates for attribute noreturn" },
1216 { "-Wno-missing-noreturn", "" },
1217 { "-Wmissing-format-attribute",
1218 "Warn about functions which might be candidates for format attributes" },
1219 { "-Wno-missing-format-attribute", "" },
1220 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1221 { "-Wno-cast-qual", "" },
1222 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1223 { "-Wno-char-subscripts", "" },
1224 { "-Wcomment", "Warn if nested comments are detected" },
1225 { "-Wno-comment", "" },
1226 { "-Wcomments", "Warn if nested comments are detected" },
1227 { "-Wno-comments", "" },
1228 { "-Wconversion", "Warn about possibly confusing type conversions" },
1229 { "-Wno-conversion", "" },
1230 { "-Wformat", "Warn about printf format anomalies" },
1231 { "-Wno-format", "" },
1232 { "-Wimplicit-function-declaration",
1233 "Warn about implicit function declarations" },
1234 { "-Wno-implicit-function-declaration", "" },
1235 { "-Werror-implicit-function-declaration", "" },
1236 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1237 { "-Wno-implicit-int", "" },
1238 { "-Wimplicit", "" },
1239 { "-Wno-implicit", "" },
1240 { "-Wimport", "Warn about the use of the #import directive" },
1241 { "-Wno-import", "" },
1242 { "-Wlong-long","" },
1243 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1244 { "-Wmain", "Warn about suspicious declarations of main" },
1245 { "-Wno-main", "" },
1246 { "-Wmissing-braces",
1247 "Warn about possibly missing braces around initialisers" },
1248 { "-Wno-missing-braces", "" },
1249 { "-Wmissing-declarations",
1250 "Warn about global funcs without previous declarations"},
1251 { "-Wno-missing-declarations", "" },
1252 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1253 { "-Wno-missing-prototypes", "" },
1254 { "-Wmultichar", "Warn about use of multicharacter literals"},
1255 { "-Wno-multichar", "" },
1256 { "-Wnested-externs", "Warn about externs not at file scope level" },
1257 { "-Wno-nested-externs", "" },
1258 { "-Wparentheses", "Warn about possible missing parentheses" },
1259 { "-Wno-parentheses", "" },
1260 { "-Wsequence-point",
1261 "Warn about possible violations of sequence point rules" },
1262 { "-Wno-sequence-point", "" },
1263 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1264 { "-Wno-pointer-arith", "" },
1265 { "-Wredundant-decls",
1266 "Warn about multiple declarations of the same object" },
1267 { "-Wno-redundant-decls", "" },
1268 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1269 { "-Wno-sign-compare", "" },
1270 { "-Wfloat-equal", "Warn about testing equality of floating point numbers" },
1271 { "-Wno-float-equal", "" },
1272 { "-Wunknown-pragmas", "Warn about unrecognized pragmas" },
1273 { "-Wno-unknown-pragmas", "" },
1274 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1275 { "-Wno-strict-prototypes", "" },
1276 { "-Wtraditional", "Warn about constructs whose meaning change in ISO C"},
1277 { "-Wno-traditional", "" },
1278 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1279 { "-Wno-trigraphs", "" },
1280 { "-Wundef", "" },
1281 { "-Wno-undef", "" },
1282 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1283 { "-Wno-write-strings", "" },
1284
1285 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1286
1287 #include "options.h"
1288
1289 };
1290
1291 /* Here is a table, controlled by the tm.h file, listing each -m switch
1292 and which bits in `target_switches' it should set or clear.
1293 If VALUE is positive, it is bits to set.
1294 If VALUE is negative, -VALUE is bits to clear.
1295 (The sign bit is not used so there is no confusion.) */
1296
1297 struct
1298 {
1299 const char *name;
1300 int value;
1301 const char *description;
1302 }
1303 target_switches [] = TARGET_SWITCHES;
1304
1305 /* This table is similar, but allows the switch to have a value. */
1306
1307 #ifdef TARGET_OPTIONS
1308 struct
1309 {
1310 const char *prefix;
1311 const char **variable;
1312 const char *description;
1313 }
1314 target_options [] = TARGET_OPTIONS;
1315 #endif
1316 \f
1317 /* Options controlling warnings. */
1318
1319 /* Don't print warning messages. -w. */
1320
1321 int inhibit_warnings = 0;
1322
1323 /* Don't suppress warnings from system headers. -Wsystem-headers. */
1324
1325 int warn_system_headers = 0;
1326
1327 /* Print various extra warnings. -W. */
1328
1329 int extra_warnings = 0;
1330
1331 /* Treat warnings as errors. -Werror. */
1332
1333 int warnings_are_errors = 0;
1334
1335 /* Nonzero to warn about unused variables, functions et.al. */
1336
1337 int warn_unused_function;
1338 int warn_unused_label;
1339 int warn_unused_parameter;
1340 int warn_unused_variable;
1341 int warn_unused_value;
1342
1343 void
1344 set_Wunused (setting)
1345 int setting;
1346 {
1347 warn_unused_function = setting;
1348 warn_unused_label = setting;
1349 /* Unused function parameter warnings are reported when either ``-W
1350 -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
1351 -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
1352 if (!setting)
1353 warn_unused_parameter = 0;
1354 else if (!warn_unused_parameter)
1355 warn_unused_parameter = -1;
1356 warn_unused_variable = setting;
1357 warn_unused_value = setting;
1358 }
1359
1360 /* Nonzero to warn about code which is never reached. */
1361
1362 int warn_notreached;
1363
1364 /* Nonzero to warn about variables used before they are initialized. */
1365
1366 int warn_uninitialized;
1367
1368 /* Nonzero means warn about all declarations which shadow others. */
1369
1370 int warn_shadow;
1371
1372 /* Warn if a switch on an enum fails to have a case for every enum value. */
1373
1374 int warn_switch;
1375
1376 /* Nonzero means warn about function definitions that default the return type
1377 or that use a null return and have a return-type other than void. */
1378
1379 int warn_return_type;
1380
1381 /* Nonzero means warn about pointer casts that increase the required
1382 alignment of the target type (and might therefore lead to a crash
1383 due to a misaligned access). */
1384
1385 int warn_cast_align;
1386
1387 /* Nonzero means warn about any identifiers that match in the first N
1388 characters. The value N is in `id_clash_len'. */
1389
1390 int warn_id_clash;
1391 int id_clash_len;
1392
1393 /* Nonzero means warn about any objects definitions whose size is larger
1394 than N bytes. Also want about function definitions whose returned
1395 values are larger than N bytes. The value N is in `larger_than_size'. */
1396
1397 int warn_larger_than;
1398 HOST_WIDE_INT larger_than_size;
1399
1400 /* Nonzero means warn if inline function is too large. */
1401
1402 int warn_inline;
1403
1404 /* Warn if a function returns an aggregate,
1405 since there are often incompatible calling conventions for doing this. */
1406
1407 int warn_aggregate_return;
1408
1409 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1410
1411 int warn_packed;
1412
1413 /* Warn when gcc pads a structure to an alignment boundary. */
1414
1415 int warn_padded;
1416
1417 /* Warn when an optimization pass is disabled. */
1418
1419 int warn_disabled_optimization;
1420
1421 /* Warn about functions which might be candidates for attribute noreturn. */
1422
1423 int warn_missing_noreturn;
1424
1425 /* Likewise for -W. */
1426
1427 lang_independent_options W_options[] =
1428 {
1429 {"unused-function", &warn_unused_function, 1, "Warn when a function is unused" },
1430 {"unused-label", &warn_unused_label, 1, "Warn when a label is unused" },
1431 {"unused-parameter", &warn_unused_parameter, 1, "Warn when a function parameter is unused" },
1432 {"unused-variable", &warn_unused_variable, 1, "Warn when a variable is unused" },
1433 {"unused-value", &warn_unused_value, 1, "Warn when an expression value is unused" },
1434 {"system-headers", &warn_system_headers, 1, "Do not suppress warnings from system headers"},
1435 {"error", &warnings_are_errors, 1, ""},
1436 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1437 {"switch", &warn_switch, 1,
1438 "Warn about enumerated switches missing a specific case" },
1439 {"aggregate-return", &warn_aggregate_return, 1,
1440 "Warn about returning structures, unions or arrays" },
1441 {"cast-align", &warn_cast_align, 1,
1442 "Warn about pointer casts which increase alignment" },
1443 {"unreachable-code", &warn_notreached, 1,
1444 "Warn about code that will never be executed" },
1445 {"uninitialized", &warn_uninitialized, 1,
1446 "Warn about unitialized automatic variables"},
1447 {"inline", &warn_inline, 1,
1448 "Warn when an inlined function cannot be inlined"},
1449 {"packed", &warn_packed, 1,
1450 "Warn when the packed attribute has no effect on struct layout"},
1451 {"padded", &warn_padded, 1,
1452 "Warn when padding is required to align struct members"},
1453 {"disabled-optimization", &warn_disabled_optimization, 1,
1454 "Warn when an optimization pass is disabled"}
1455 };
1456 \f
1457 /* Output files for assembler code (real compiler output)
1458 and debugging dumps. */
1459
1460 FILE *asm_out_file;
1461 FILE *aux_info_file;
1462 FILE *rtl_dump_file = NULL;
1463
1464 /* Decode the string P as an integral parameter.
1465 If the string is indeed an integer return its numeric value else
1466 issue an Invalid Option error for the option PNAME and return DEFVAL.
1467 If PNAME is zero just return DEFVAL, do not call error. */
1468
1469 int
1470 read_integral_parameter (p, pname, defval)
1471 const char *p;
1472 const char *pname;
1473 const int defval;
1474 {
1475 const char *endp = p;
1476
1477 while (*endp)
1478 {
1479 if (*endp >= '0' && *endp <= '9')
1480 endp++;
1481 else
1482 break;
1483 }
1484
1485 if (*endp != 0)
1486 {
1487 if (pname != 0)
1488 error ("Invalid option `%s'", pname);
1489 return defval;
1490 }
1491
1492 return atoi (p);
1493 }
1494
1495 \f
1496 /* This is the default decl_printable_name function. */
1497
1498 static const char *
1499 decl_name (decl, verbosity)
1500 tree decl;
1501 int verbosity ATTRIBUTE_UNUSED;
1502 {
1503 return IDENTIFIER_POINTER (DECL_NAME (decl));
1504 }
1505 \f
1506 /* Mark P for GC. Also mark main_input_filename and input_filename. */
1507
1508 static void
1509 mark_file_stack (p)
1510 void *p;
1511 {
1512 struct file_stack *stack = *(struct file_stack **)p;
1513
1514 /* We're only called for input_file_stack, so we can mark the current
1515 input_filename here as well. */
1516 ggc_mark_string (main_input_filename);
1517 ggc_mark_string (input_filename);
1518
1519 while (stack)
1520 {
1521 ggc_mark_string (stack->name);
1522 stack = stack->next;
1523 }
1524 }
1525 \f
1526
1527 /* This calls abort and is used to avoid problems when abort if a macro.
1528 It is used when we need to pass the address of abort. */
1529
1530 void
1531 do_abort ()
1532 {
1533 abort ();
1534 }
1535
1536 /* When `malloc.c' is compiled with `rcheck' defined,
1537 it calls this function to report clobberage. */
1538
1539 void
1540 botch (s)
1541 const char *s ATTRIBUTE_UNUSED;
1542 {
1543 abort ();
1544 }
1545 \f
1546 /* Return the logarithm of X, base 2, considering X unsigned,
1547 if X is a power of 2. Otherwise, returns -1.
1548
1549 This should be used via the `exact_log2' macro. */
1550
1551 int
1552 exact_log2_wide (x)
1553 register unsigned HOST_WIDE_INT x;
1554 {
1555 register int log = 0;
1556 /* Test for 0 or a power of 2. */
1557 if (x == 0 || x != (x & -x))
1558 return -1;
1559 while ((x >>= 1) != 0)
1560 log++;
1561 return log;
1562 }
1563
1564 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1565 If X is 0, return -1.
1566
1567 This should be used via the floor_log2 macro. */
1568
1569 int
1570 floor_log2_wide (x)
1571 register unsigned HOST_WIDE_INT x;
1572 {
1573 register int log = -1;
1574 while (x != 0)
1575 log++,
1576 x >>= 1;
1577 return log;
1578 }
1579
1580 static int float_handler_set;
1581 int float_handled;
1582 jmp_buf float_handler;
1583
1584 /* Signals actually come here. */
1585
1586 static void
1587 float_signal (signo)
1588 /* If this is missing, some compilers complain. */
1589 int signo ATTRIBUTE_UNUSED;
1590 {
1591 if (float_handled == 0)
1592 crash_signal (signo);
1593 #if defined (USG) || defined (hpux)
1594 /* Re-enable the signal catcher. */
1595 signal (SIGFPE, float_signal);
1596 #endif
1597 float_handled = 0;
1598 signal (SIGFPE, float_signal);
1599 longjmp (float_handler, 1);
1600 }
1601
1602 /* Specify where to longjmp to when a floating arithmetic error happens.
1603 If HANDLER is 0, it means don't handle the errors any more. */
1604
1605 void
1606 set_float_handler (handler)
1607 jmp_buf handler;
1608 {
1609 float_handled = (handler != 0);
1610 if (handler)
1611 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1612
1613 if (float_handled && ! float_handler_set)
1614 {
1615 signal (SIGFPE, float_signal);
1616 float_handler_set = 1;
1617 }
1618 }
1619
1620 /* This is a wrapper function for code which might elicit an
1621 arithmetic exception. That code should be passed in as a function
1622 pointer FN, and one argument DATA. DATA is usually a struct which
1623 contains the real input and output for function FN. This function
1624 returns 0 (failure) if longjmp was called (i.e. an exception
1625 occured.) It returns 1 (success) otherwise. */
1626
1627 int
1628 do_float_handler (fn, data)
1629 void (*fn) PARAMS ((PTR));
1630 PTR data;
1631 {
1632 jmp_buf buf;
1633
1634 if (setjmp (buf))
1635 {
1636 /* We got here via longjmp () caused by an exception in function
1637 fn (). */
1638 set_float_handler (NULL);
1639 return 0;
1640 }
1641
1642 set_float_handler (buf);
1643 (*fn)(data);
1644 set_float_handler (NULL);
1645 return 1;
1646 }
1647
1648 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1649 error happens, pushing the previous specification into OLD_HANDLER.
1650 Return an indication of whether there was a previous handler in effect. */
1651
1652 int
1653 push_float_handler (handler, old_handler)
1654 jmp_buf handler, old_handler;
1655 {
1656 int was_handled = float_handled;
1657
1658 float_handled = 1;
1659 if (was_handled)
1660 memcpy ((char *) old_handler, (char *) float_handler,
1661 sizeof (float_handler));
1662
1663 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
1664 return was_handled;
1665 }
1666
1667 /* Restore the previous specification of whether and where to longjmp to
1668 when a floating arithmetic error happens. */
1669
1670 void
1671 pop_float_handler (handled, handler)
1672 int handled;
1673 jmp_buf handler;
1674 {
1675 float_handled = handled;
1676 if (handled)
1677 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1678 }
1679
1680 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1681 into ICE messages, which is much more user friendly. */
1682
1683 static void
1684 crash_signal (signo)
1685 /* If this is missing, some compilers complain. */
1686 int signo;
1687 {
1688 fatal ("Internal error: %s.\n\
1689 Please submit a full bug report.\n\
1690 See %s for instructions.", strsignal (signo), GCCBUGURL);
1691 }
1692
1693 /* Strip off a legitimate source ending from the input string NAME of
1694 length LEN. Rather than having to know the names used by all of
1695 our front ends, we strip off an ending of a period followed by
1696 up to five characters. (Java uses ".class".) */
1697
1698 void
1699 strip_off_ending (name, len)
1700 char *name;
1701 int len;
1702 {
1703 int i;
1704 for (i = 2; i < 6 && len > i; i++)
1705 {
1706 if (name[len - i] == '.')
1707 {
1708 name[len - i] = '\0';
1709 break;
1710 }
1711 }
1712 }
1713
1714 /* Given a file name X, return the nondirectory portion. */
1715
1716 char *
1717 file_name_nondirectory (x)
1718 const char *x;
1719 {
1720 char *tmp = (char *) strrchr (x, '/');
1721 if (DIR_SEPARATOR != '/' && ! tmp)
1722 tmp = (char *) strrchr (x, DIR_SEPARATOR);
1723 if (tmp)
1724 return (char *) (tmp + 1);
1725 else
1726 return (char *) x;
1727 }
1728
1729 /* Output a quoted string. */
1730
1731 void
1732 output_quoted_string (asm_file, string)
1733 FILE *asm_file;
1734 const char *string;
1735 {
1736 #ifdef OUTPUT_QUOTED_STRING
1737 OUTPUT_QUOTED_STRING (asm_file, string);
1738 #else
1739 char c;
1740
1741 putc ('\"', asm_file);
1742 while ((c = *string++) != 0)
1743 {
1744 if (c == '\"' || c == '\\')
1745 putc ('\\', asm_file);
1746 putc (c, asm_file);
1747 }
1748 putc ('\"', asm_file);
1749 #endif
1750 }
1751
1752 /* Output a file name in the form wanted by System V. */
1753
1754 void
1755 output_file_directive (asm_file, input_name)
1756 FILE *asm_file;
1757 const char *input_name;
1758 {
1759 int len = strlen (input_name);
1760 const char *na = input_name + len;
1761
1762 /* NA gets INPUT_NAME sans directory names. */
1763 while (na > input_name)
1764 {
1765 if (IS_DIR_SEPARATOR (na[-1]))
1766 break;
1767 na--;
1768 }
1769
1770 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1771 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1772 #else
1773 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1774 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1775 #else
1776 fprintf (asm_file, "\t.file\t");
1777 output_quoted_string (asm_file, na);
1778 fputc ('\n', asm_file);
1779 #endif
1780 #endif
1781 }
1782 \f
1783 #ifdef ASM_IDENTIFY_LANGUAGE
1784 /* Routine to build language identifier for object file. */
1785
1786 static void
1787 output_lang_identify (asm_out_file)
1788 FILE *asm_out_file;
1789 {
1790 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1791 char *s = (char *) alloca (len);
1792
1793 sprintf (s, "__gnu_compiled_%s", lang_identify ());
1794 ASM_OUTPUT_LABEL (asm_out_file, s);
1795 }
1796 #endif
1797
1798 /* Routine to open a dump file. Return true if the dump file is enabled. */
1799
1800 static int
1801 open_dump_file (index, decl)
1802 enum dump_file_index index;
1803 tree decl;
1804 {
1805 char *dump_name;
1806 const char *open_arg;
1807 char seq[16];
1808
1809 if (! dump_file[index].enabled)
1810 return 0;
1811
1812 timevar_push (TV_DUMP);
1813 if (rtl_dump_file != NULL)
1814 fclose (rtl_dump_file);
1815
1816 sprintf (seq, ".%02d.", index);
1817
1818 if (! dump_file[index].initialized)
1819 {
1820 /* If we've not initialized the files, do so now. */
1821 if (graph_dump_format != no_graph
1822 && dump_file[index].graph_dump_p)
1823 {
1824 dump_name = concat (seq, dump_file[index].extension, NULL);
1825 clean_graph_dump_file (dump_base_name, dump_name);
1826 free (dump_name);
1827 }
1828 dump_file[index].initialized = 1;
1829 open_arg = "w";
1830 }
1831 else
1832 open_arg = "a";
1833
1834 dump_name = concat (dump_base_name, seq,
1835 dump_file[index].extension, NULL);
1836
1837 rtl_dump_file = fopen (dump_name, open_arg);
1838 if (rtl_dump_file == NULL)
1839 pfatal_with_name (dump_name);
1840
1841 free (dump_name);
1842
1843 if (decl)
1844 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1845 decl_printable_name (decl, 2));
1846
1847 timevar_pop (TV_DUMP);
1848 return 1;
1849 }
1850
1851 /* Routine to close a dump file. */
1852
1853 static void
1854 close_dump_file (index, func, insns)
1855 enum dump_file_index index;
1856 void (*func) PARAMS ((FILE *, rtx));
1857 rtx insns;
1858 {
1859 if (! rtl_dump_file)
1860 return;
1861
1862 timevar_push (TV_DUMP);
1863 if (insns
1864 && graph_dump_format != no_graph
1865 && dump_file[index].graph_dump_p)
1866 {
1867 char seq[16];
1868 char *suffix;
1869
1870 sprintf (seq, ".%02d.", index);
1871 suffix = concat (seq, dump_file[index].extension, NULL);
1872 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1873 free (suffix);
1874 }
1875
1876 if (func && insns)
1877 func (rtl_dump_file, insns);
1878
1879 fflush (rtl_dump_file);
1880 fclose (rtl_dump_file);
1881
1882 rtl_dump_file = NULL;
1883 timevar_pop (TV_DUMP);
1884 }
1885
1886 /* Do any final processing required for the declarations in VEC, of
1887 which there are LEN. We write out inline functions and variables
1888 that have been deferred until this point, but which are required.
1889 Returns non-zero if anything was put out. */
1890
1891 int
1892 wrapup_global_declarations (vec, len)
1893 tree *vec;
1894 int len;
1895 {
1896 tree decl;
1897 int i;
1898 int reconsider;
1899 int output_something = 0;
1900
1901 for (i = 0; i < len; i++)
1902 {
1903 decl = vec[i];
1904
1905 /* We're not deferring this any longer. */
1906 DECL_DEFER_OUTPUT (decl) = 0;
1907
1908 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
1909 && incomplete_decl_finalize_hook != 0)
1910 (*incomplete_decl_finalize_hook) (decl);
1911 }
1912
1913 /* Now emit any global variables or functions that we have been
1914 putting off. We need to loop in case one of the things emitted
1915 here references another one which comes earlier in the list. */
1916 do
1917 {
1918 reconsider = 0;
1919 for (i = 0; i < len; i++)
1920 {
1921 decl = vec[i];
1922
1923 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1924 continue;
1925
1926 /* Don't write out static consts, unless we still need them.
1927
1928 We also keep static consts if not optimizing (for debugging),
1929 unless the user specified -fno-keep-static-consts.
1930 ??? They might be better written into the debug information.
1931 This is possible when using DWARF.
1932
1933 A language processor that wants static constants to be always
1934 written out (even if it is not used) is responsible for
1935 calling rest_of_decl_compilation itself. E.g. the C front-end
1936 calls rest_of_decl_compilation from finish_decl.
1937 One motivation for this is that is conventional in some
1938 environments to write things like:
1939 static const char rcsid[] = "... version string ...";
1940 intending to force the string to be in the executable.
1941
1942 A language processor that would prefer to have unneeded
1943 static constants "optimized away" would just defer writing
1944 them out until here. E.g. C++ does this, because static
1945 constants are often defined in header files.
1946
1947 ??? A tempting alternative (for both C and C++) would be
1948 to force a constant to be written if and only if it is
1949 defined in a main file, as opposed to an include file. */
1950
1951 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1952 && (! TREE_READONLY (decl)
1953 || TREE_PUBLIC (decl)
1954 || (!optimize && flag_keep_static_consts)
1955 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1956 {
1957 reconsider = 1;
1958 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1959 }
1960
1961 if (TREE_CODE (decl) == FUNCTION_DECL
1962 && DECL_INITIAL (decl) != 0
1963 && DECL_SAVED_INSNS (decl) != 0
1964 && (flag_keep_inline_functions
1965 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1966 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1967 {
1968 reconsider = 1;
1969 output_inline_function (decl);
1970 }
1971 }
1972
1973 if (reconsider)
1974 output_something = 1;
1975 }
1976 while (reconsider);
1977
1978 return output_something;
1979 }
1980
1981 /* Issue appropriate warnings for the global declarations in VEC (of
1982 which there are LEN). Output debugging information for them. */
1983
1984 void
1985 check_global_declarations (vec, len)
1986 tree *vec;
1987 int len;
1988 {
1989 tree decl;
1990 int i;
1991
1992 for (i = 0; i < len; i++)
1993 {
1994 decl = vec[i];
1995
1996 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1997 && ! TREE_ASM_WRITTEN (decl))
1998 /* Cancel the RTL for this decl so that, if debugging info
1999 output for global variables is still to come,
2000 this one will be omitted. */
2001 DECL_RTL (decl) = NULL;
2002
2003 /* Warn about any function
2004 declared static but not defined.
2005 We don't warn about variables,
2006 because many programs have static variables
2007 that exist only to get some text into the object file. */
2008 if (TREE_CODE (decl) == FUNCTION_DECL
2009 && (warn_unused_function
2010 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2011 && DECL_INITIAL (decl) == 0
2012 && DECL_EXTERNAL (decl)
2013 && ! DECL_ARTIFICIAL (decl)
2014 && ! TREE_PUBLIC (decl))
2015 {
2016 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2017 pedwarn_with_decl (decl,
2018 "`%s' used but never defined");
2019 else
2020 warning_with_decl (decl,
2021 "`%s' declared `static' but never defined");
2022 /* This symbol is effectively an "extern" declaration now. */
2023 TREE_PUBLIC (decl) = 1;
2024 assemble_external (decl);
2025 }
2026
2027 /* Warn about static fns or vars defined but not used,
2028 but not about inline functions or static consts
2029 since defining those in header files is normal practice. */
2030 if (((warn_unused_function
2031 && TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2032 || (warn_unused_variable
2033 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2034 && ! DECL_IN_SYSTEM_HEADER (decl)
2035 && ! DECL_EXTERNAL (decl)
2036 && ! TREE_PUBLIC (decl)
2037 && ! TREE_USED (decl)
2038 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2039 /* The TREE_USED bit for file-scope decls
2040 is kept in the identifier, to handle multiple
2041 external decls in different scopes. */
2042 && ! TREE_USED (DECL_NAME (decl)))
2043 warning_with_decl (decl, "`%s' defined but not used");
2044
2045 timevar_push (TV_SYMOUT);
2046 #ifdef SDB_DEBUGGING_INFO
2047 /* The COFF linker can move initialized global vars to the end.
2048 And that can screw up the symbol ordering.
2049 By putting the symbols in that order to begin with,
2050 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2051 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2052 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2053 && ! DECL_EXTERNAL (decl)
2054 && DECL_RTL (decl) != 0)
2055 sdbout_symbol (decl, 0);
2056
2057 /* Output COFF information for non-global
2058 file-scope initialized variables. */
2059 if (write_symbols == SDB_DEBUG
2060 && TREE_CODE (decl) == VAR_DECL
2061 && DECL_INITIAL (decl)
2062 && ! DECL_EXTERNAL (decl)
2063 && DECL_RTL (decl) != 0
2064 && GET_CODE (DECL_RTL (decl)) == MEM)
2065 sdbout_toplevel_data (decl);
2066 #endif /* SDB_DEBUGGING_INFO */
2067 #ifdef DWARF_DEBUGGING_INFO
2068 /* Output DWARF information for file-scope tentative data object
2069 declarations, file-scope (extern) function declarations (which
2070 had no corresponding body) and file-scope tagged type declarations
2071 and definitions which have not yet been forced out. */
2072
2073 if (write_symbols == DWARF_DEBUG
2074 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2075 dwarfout_file_scope_decl (decl, 1);
2076 #endif
2077 #ifdef DWARF2_DEBUGGING_INFO
2078 /* Output DWARF2 information for file-scope tentative data object
2079 declarations, file-scope (extern) function declarations (which
2080 had no corresponding body) and file-scope tagged type declarations
2081 and definitions which have not yet been forced out. */
2082
2083 if (write_symbols == DWARF2_DEBUG
2084 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2085 dwarf2out_decl (decl);
2086 #endif
2087 timevar_pop (TV_SYMOUT);
2088 }
2089 }
2090
2091 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2092 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2093 INPUT_FILENAME and LINENO accordingly. */
2094
2095 void
2096 push_srcloc (file, line)
2097 const char *file;
2098 int line;
2099 {
2100 struct file_stack *fs;
2101
2102 if (input_file_stack)
2103 {
2104 input_file_stack->name = input_filename;
2105 input_file_stack->line = lineno;
2106 }
2107
2108 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2109 fs->name = input_filename = file;
2110 fs->line = lineno = line;
2111 fs->indent_level = 0;
2112 fs->next = input_file_stack;
2113 input_file_stack = fs;
2114 input_file_stack_tick++;
2115 }
2116
2117 /* Pop the top entry off the stack of presently open source files.
2118 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2119 the stack. */
2120
2121 void
2122 pop_srcloc ()
2123 {
2124 struct file_stack *fs;
2125
2126 fs = input_file_stack;
2127 input_file_stack = fs->next;
2128 free (fs);
2129 input_file_stack_tick++;
2130 /* The initial souce file is never popped. */
2131 if (!input_file_stack)
2132 abort ();
2133 input_filename = input_file_stack->name;
2134 lineno = input_file_stack->line;
2135 }
2136
2137 /* Compile an entire file of output from cpp, named NAME.
2138 Write a file of assembly output and various debugging dumps. */
2139
2140 static void
2141 compile_file (name)
2142 const char *name;
2143 {
2144 tree globals;
2145
2146 int name_specified = name != 0;
2147
2148 if (dump_base_name == 0)
2149 dump_base_name = name ? name : "gccdump";
2150
2151 if (! quiet_flag)
2152 time_report = 1;
2153
2154 /* Start timing total execution time. */
2155
2156 init_timevar ();
2157 timevar_start (TV_TOTAL);
2158
2159 /* Initialize data in various passes. */
2160
2161 init_obstacks ();
2162 init_tree_codes ();
2163 name = init_parse (name);
2164 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2165 || debug_info_level == DINFO_LEVEL_VERBOSE
2166 || flag_test_coverage
2167 || warn_notreached);
2168 init_regs ();
2169 init_alias_once ();
2170 init_decl_processing ();
2171 init_optabs ();
2172 init_stmt ();
2173 init_eh ();
2174 init_loop ();
2175 init_reload ();
2176 init_function_once ();
2177 init_stor_layout_once ();
2178 init_varasm_once ();
2179
2180 /* The following initialization functions need to generate rtl, so
2181 provide a dummy function context for them. */
2182 init_dummy_function_start ();
2183 init_expmed ();
2184 init_expr_once ();
2185 if (flag_caller_saves)
2186 init_caller_save ();
2187 expand_dummy_function_end ();
2188
2189 /* If auxiliary info generation is desired, open the output file.
2190 This goes in the same directory as the source file--unlike
2191 all the other output files. */
2192 if (flag_gen_aux_info)
2193 {
2194 aux_info_file = fopen (aux_info_file_name, "w");
2195 if (aux_info_file == 0)
2196 pfatal_with_name (aux_info_file_name);
2197 }
2198
2199 /* Open assembler code output file. Do this even if -fsyntax-only is on,
2200 because then the driver will have provided the name of a temporary
2201 file or bit bucket for us. */
2202
2203 if (! name_specified && asm_file_name == 0)
2204 asm_out_file = stdout;
2205 else
2206 {
2207 if (asm_file_name == 0)
2208 {
2209 int len = strlen (dump_base_name);
2210 char *dumpname = (char *) xmalloc (len + 6);
2211 memcpy (dumpname, dump_base_name, len + 1);
2212 strip_off_ending (dumpname, len);
2213 strcat (dumpname, ".s");
2214 asm_file_name = dumpname;
2215 }
2216 if (!strcmp (asm_file_name, "-"))
2217 asm_out_file = stdout;
2218 else
2219 asm_out_file = fopen (asm_file_name, "w");
2220 if (asm_out_file == 0)
2221 pfatal_with_name (asm_file_name);
2222 }
2223
2224 #ifdef IO_BUFFER_SIZE
2225 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2226 _IOFBF, IO_BUFFER_SIZE);
2227 #endif
2228
2229 if (name != 0)
2230 name = ggc_alloc_string (name, strlen (name));
2231
2232 input_filename = name;
2233
2234 /* Put an entry on the input file stack for the main input file. */
2235 push_srcloc (input_filename, 0);
2236
2237 /* Perform language-specific initialization.
2238 This may set main_input_filename. */
2239 lang_init ();
2240
2241 /* If the input doesn't start with a #line, use the input name
2242 as the official input file name. */
2243 if (main_input_filename == 0)
2244 main_input_filename = name;
2245
2246 if (flag_syntax_only)
2247 {
2248 write_symbols = NO_DEBUG;
2249 profile_flag = 0;
2250 profile_block_flag = 0;
2251 }
2252 else
2253 {
2254 ASM_FILE_START (asm_out_file);
2255
2256 #ifdef ASM_COMMENT_START
2257 if (flag_verbose_asm)
2258 {
2259 /* Print the list of options in effect. */
2260 print_version (asm_out_file, ASM_COMMENT_START);
2261 print_switch_values (asm_out_file, 0, MAX_LINE,
2262 ASM_COMMENT_START, " ", "\n");
2263 /* Add a blank line here so it appears in assembler output but not
2264 screen output. */
2265 fprintf (asm_out_file, "\n");
2266 }
2267 #endif
2268
2269 /* Output something to inform GDB that this compilation was by GCC. */
2270 #ifndef ASM_IDENTIFY_GCC
2271 fprintf (asm_out_file, "gcc2_compiled.:\n");
2272 #else
2273 ASM_IDENTIFY_GCC (asm_out_file);
2274 #endif
2275
2276 /* Output something to identify which front-end produced this file. */
2277 #ifdef ASM_IDENTIFY_LANGUAGE
2278 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2279 #endif
2280 } /* ! flag_syntax_only */
2281
2282 #ifndef ASM_OUTPUT_SECTION_NAME
2283 if (flag_function_sections)
2284 {
2285 warning ("-ffunction-sections not supported for this target.");
2286 flag_function_sections = 0;
2287 }
2288 if (flag_data_sections)
2289 {
2290 warning ("-fdata-sections not supported for this target.");
2291 flag_data_sections = 0;
2292 }
2293 #endif
2294
2295 if (flag_function_sections
2296 && (profile_flag || profile_block_flag))
2297 {
2298 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2299 flag_function_sections = 0;
2300 }
2301
2302 #ifndef OBJECT_FORMAT_ELF
2303 if (flag_function_sections && write_symbols != NO_DEBUG)
2304 warning ("-ffunction-sections may affect debugging on some targets.");
2305 #endif
2306
2307 /* ??? Note: There used to be a conditional here
2308 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2309 This was to guarantee separation between gcc_compiled. and
2310 the first function, for the sake of dbx on Suns.
2311 However, having the extra zero here confused the Emacs
2312 code for unexec, and might confuse other programs too.
2313 Therefore, I took out that change.
2314 In future versions we should find another way to solve
2315 that dbx problem. -- rms, 23 May 93. */
2316
2317 /* Don't let the first function fall at the same address
2318 as gcc_compiled., if profiling. */
2319 if (profile_flag || profile_block_flag)
2320 {
2321 /* It's best if we can write a nop here since some
2322 assemblers don't tolerate zeros in the text section. */
2323 output_asm_insn (get_insn_template (CODE_FOR_nop, NULL), NULL_PTR);
2324 }
2325
2326 /* If dbx symbol table desired, initialize writing it
2327 and output the predefined types. */
2328 timevar_push (TV_SYMOUT);
2329 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2330 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2331 dbxout_init (asm_out_file, main_input_filename, getdecls ());
2332 #endif
2333 #ifdef SDB_DEBUGGING_INFO
2334 if (write_symbols == SDB_DEBUG)
2335 sdbout_init (asm_out_file, main_input_filename, getdecls ());
2336 #endif
2337 #ifdef DWARF_DEBUGGING_INFO
2338 if (write_symbols == DWARF_DEBUG)
2339 dwarfout_init (asm_out_file, main_input_filename);
2340 #endif
2341 #ifdef DWARF2_UNWIND_INFO
2342 if (dwarf2out_do_frame ())
2343 dwarf2out_frame_init ();
2344 #endif
2345 #ifdef DWARF2_DEBUGGING_INFO
2346 if (write_symbols == DWARF2_DEBUG)
2347 dwarf2out_init (asm_out_file, main_input_filename);
2348 #endif
2349 timevar_pop (TV_SYMOUT);
2350
2351 /* Initialize yet another pass. */
2352
2353 init_final (main_input_filename);
2354 init_branch_prob (dump_base_name);
2355
2356 timevar_push (TV_PARSE);
2357
2358 /* Call the parser, which parses the entire file
2359 (calling rest_of_compilation for each function). */
2360
2361 if (yyparse () != 0)
2362 {
2363 if (errorcount == 0)
2364 fnotice (stderr, "Errors detected in input file (your bison.simple is out of date)\n");
2365
2366 /* In case there were missing closebraces,
2367 get us back to the global binding level. */
2368 while (! global_bindings_p ())
2369 poplevel (0, 0, 0);
2370 }
2371
2372 /* Compilation is now finished except for writing
2373 what's left of the symbol table output. */
2374
2375 timevar_pop (TV_PARSE);
2376
2377 if (flag_syntax_only)
2378 goto finish_syntax;
2379
2380 globals = getdecls ();
2381
2382 /* Really define vars that have had only a tentative definition.
2383 Really output inline functions that must actually be callable
2384 and have not been output so far. */
2385
2386 {
2387 int len = list_length (globals);
2388 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2389 int i;
2390 tree decl;
2391
2392 /* Process the decls in reverse order--earliest first.
2393 Put them into VEC from back to front, then take out from front. */
2394
2395 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2396 vec[len - i - 1] = decl;
2397
2398 wrapup_global_declarations (vec, len);
2399
2400 /* This must occur after the loop to output deferred functions. Else
2401 the profiler initializer would not be emitted if all the functions
2402 in this compilation unit were deferred.
2403
2404 output_func_start_profiler can not cause any additional functions or
2405 data to need to be output, so it need not be in the deferred function
2406 loop above. */
2407 output_func_start_profiler ();
2408
2409 /* Now that all possible functions have been output, we can dump
2410 the exception table. */
2411
2412 #ifndef IA64_UNWIND_INFO
2413 output_exception_table ();
2414 #endif
2415 free_exception_table ();
2416
2417 check_global_declarations (vec, len);
2418
2419 /* Clean up. */
2420 free (vec);
2421 }
2422
2423 /* Write out any pending weak symbol declarations. */
2424
2425 weak_finish ();
2426
2427 /* Do dbx symbols. */
2428 timevar_push (TV_SYMOUT);
2429 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2430 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2431 dbxout_finish (asm_out_file, main_input_filename);
2432 #endif
2433
2434 #ifdef DWARF_DEBUGGING_INFO
2435 if (write_symbols == DWARF_DEBUG)
2436 dwarfout_finish ();
2437 #endif
2438
2439 #ifdef DWARF2_UNWIND_INFO
2440 if (dwarf2out_do_frame ())
2441 dwarf2out_frame_finish ();
2442 #endif
2443
2444 #ifdef DWARF2_DEBUGGING_INFO
2445 if (write_symbols == DWARF2_DEBUG)
2446 dwarf2out_finish ();
2447 #endif
2448 timevar_pop (TV_SYMOUT);
2449
2450 /* Output some stuff at end of file if nec. */
2451
2452 end_final (dump_base_name);
2453
2454 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2455 {
2456 timevar_push (TV_DUMP);
2457 open_dump_file (DFI_bp, NULL);
2458
2459 end_branch_prob ();
2460
2461 close_dump_file (DFI_bp, NULL, NULL_RTX);
2462 timevar_pop (TV_DUMP);
2463 }
2464
2465 #ifdef ASM_FILE_END
2466 ASM_FILE_END (asm_out_file);
2467 #endif
2468
2469 /* Language-specific end of compilation actions. */
2470 finish_syntax:
2471 lang_finish ();
2472
2473 /* Close the dump files. */
2474
2475 if (flag_gen_aux_info)
2476 {
2477 fclose (aux_info_file);
2478 if (errorcount)
2479 unlink (aux_info_file_name);
2480 }
2481
2482 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2483 {
2484 timevar_push (TV_DUMP);
2485 dump_combine_total_stats (rtl_dump_file);
2486 close_dump_file (DFI_combine, NULL, NULL_RTX);
2487 timevar_pop (TV_DUMP);
2488 }
2489
2490 /* Close non-debugging input and output files. Take special care to note
2491 whether fclose returns an error, since the pages might still be on the
2492 buffer chain while the file is open. */
2493
2494 finish_parse ();
2495
2496 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2497 fatal_io_error (asm_file_name);
2498
2499 /* Do whatever is necessary to finish printing the graphs. */
2500 if (graph_dump_format != no_graph)
2501 {
2502 int i;
2503
2504 for (i = 0; i < DFI_MAX; ++i)
2505 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
2506 {
2507 char seq[16];
2508 char *suffix;
2509
2510 sprintf (seq, ".%02d.", i);
2511 suffix = concat (seq, dump_file[i].extension, NULL);
2512 finish_graph_dump_file (dump_base_name, suffix);
2513 free (suffix);
2514 }
2515 }
2516
2517 if (mem_report)
2518 ggc_print_statistics ();
2519
2520 /* Free up memory for the benefit of leak detectors. */
2521 free_reg_info ();
2522
2523 /* Stop timing total execution time. */
2524 timevar_stop (TV_TOTAL);
2525
2526 /* Print the times. */
2527
2528 timevar_print (stderr);
2529 }
2530 \f
2531 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2532 and TYPE_DECL nodes.
2533
2534 This does nothing for local (non-static) variables, unless the
2535 variable is a register variable with an ASMSPEC. In that case, or
2536 if the variable is not an automatice, it sets up the RTL and
2537 outputs any assembler code (label definition, storage allocation
2538 and initialization).
2539
2540 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2541 the assembler symbol name to be used. TOP_LEVEL is nonzero
2542 if this declaration is not within a function. */
2543
2544 void
2545 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2546 tree decl;
2547 const char *asmspec;
2548 int top_level;
2549 int at_end;
2550 {
2551 /* Declarations of variables, and of functions defined elsewhere. */
2552
2553 /* The most obvious approach, to put an #ifndef around where
2554 this macro is used, doesn't work since it's inside a macro call. */
2555 #ifndef ASM_FINISH_DECLARE_OBJECT
2556 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2557 #endif
2558
2559 /* Forward declarations for nested functions are not "external",
2560 but we need to treat them as if they were. */
2561 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2562 || TREE_CODE (decl) == FUNCTION_DECL)
2563 {
2564 timevar_push (TV_VARCONST);
2565 make_decl_rtl (decl, asmspec, top_level);
2566 /* Initialized extern variable exists to be replaced
2567 with its value, or represents something that will be
2568 output in another file. */
2569 if (! (TREE_CODE (decl) == VAR_DECL
2570 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2571 && DECL_INITIAL (decl) != 0
2572 && DECL_INITIAL (decl) != error_mark_node))
2573 /* Don't output anything
2574 when a tentative file-scope definition is seen.
2575 But at end of compilation, do output code for them. */
2576 if (! (! at_end && top_level
2577 && (DECL_INITIAL (decl) == 0
2578 || DECL_INITIAL (decl) == error_mark_node)))
2579 assemble_variable (decl, top_level, at_end, 0);
2580 if (decl == last_assemble_variable_decl)
2581 {
2582 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2583 top_level, at_end);
2584 }
2585 timevar_pop (TV_VARCONST);
2586 }
2587 else if (DECL_REGISTER (decl) && asmspec != 0)
2588 {
2589 if (decode_reg_name (asmspec) >= 0)
2590 {
2591 DECL_RTL (decl) = 0;
2592 make_decl_rtl (decl, asmspec, top_level);
2593 }
2594 else
2595 {
2596 error ("invalid register name `%s' for register variable", asmspec);
2597 DECL_REGISTER (decl) = 0;
2598 make_decl_rtl (decl, NULL, top_level);
2599 }
2600 }
2601 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2602 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2603 && TREE_CODE (decl) == TYPE_DECL)
2604 {
2605 timevar_push (TV_SYMOUT);
2606 dbxout_symbol (decl, 0);
2607 timevar_pop (TV_SYMOUT);
2608 }
2609 #endif
2610 #ifdef SDB_DEBUGGING_INFO
2611 else if (write_symbols == SDB_DEBUG && top_level
2612 && TREE_CODE (decl) == TYPE_DECL)
2613 {
2614 timevar_push (TV_SYMOUT);
2615 sdbout_symbol (decl, 0);
2616 timevar_pop (TV_SYMOUT);
2617 }
2618 #endif
2619 }
2620
2621 /* Called after finishing a record, union or enumeral type. */
2622
2623 void
2624 rest_of_type_compilation (type, toplev)
2625 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2626 tree type;
2627 int toplev;
2628 #else
2629 tree type ATTRIBUTE_UNUSED;
2630 int toplev ATTRIBUTE_UNUSED;
2631 #endif
2632 {
2633 timevar_push (TV_SYMOUT);
2634 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2635 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2636 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2637 #endif
2638 #ifdef SDB_DEBUGGING_INFO
2639 if (write_symbols == SDB_DEBUG)
2640 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2641 #endif
2642 #ifdef DWARF2_DEBUGGING_INFO
2643 if (write_symbols == DWARF2_DEBUG && toplev)
2644 dwarf2out_decl (TYPE_STUB_DECL (type));
2645 #endif
2646 timevar_pop (TV_SYMOUT);
2647 }
2648
2649 /* DECL is an inline function, whose body is present, but which is not
2650 being output at this point. (We're putting that off until we need
2651 to do it.) If there are any actions that need to take place,
2652 including the emission of debugging information for the function,
2653 this is where they should go. This function may be called by
2654 language-dependent code for front-ends that do not even generate
2655 RTL for functions that don't need to be put out. */
2656
2657 void
2658 note_deferral_of_defined_inline_function (decl)
2659 tree decl ATTRIBUTE_UNUSED;
2660 {
2661 #ifdef DWARF_DEBUGGING_INFO
2662 /* Generate the DWARF info for the "abstract" instance of a function
2663 which we may later generate inlined and/or out-of-line instances
2664 of. */
2665 if (write_symbols == DWARF_DEBUG && DECL_INLINE (decl))
2666 {
2667 /* The front-end may not have set CURRENT_FUNCTION_DECL, but the
2668 DWARF code expects it to be set in this case. Intuitively,
2669 DECL is the function we just finished defining, so setting
2670 CURRENT_FUNCTION_DECL is sensible. */
2671 tree saved_cfd = current_function_decl;
2672 current_function_decl = decl;
2673
2674 /* Let the DWARF code do its work. */
2675 set_decl_abstract_flags (decl, 1);
2676 dwarfout_file_scope_decl (decl, 0);
2677 set_decl_abstract_flags (decl, 0);
2678
2679 /* Reset CURRENT_FUNCTION_DECL. */
2680 current_function_decl = saved_cfd;
2681 }
2682 #endif
2683 }
2684
2685 /* This is called from finish_function (within yyparse)
2686 after each top-level definition is parsed.
2687 It is supposed to compile that function or variable
2688 and output the assembler code for it.
2689 After we return, the tree storage is freed. */
2690
2691 void
2692 rest_of_compilation (decl)
2693 tree decl;
2694 {
2695 register rtx insns;
2696 int tem;
2697 int failure = 0;
2698 int rebuild_label_notes_after_reload;
2699 int register_life_up_to_date;
2700
2701 timevar_push (TV_REST_OF_COMPILATION);
2702
2703 /* Now that we're out of the frontend, we shouldn't have any more
2704 CONCATs anywhere. */
2705 generating_concat_p = 0;
2706
2707 /* When processing delayed functions, prepare_function_start() won't
2708 have been run to re-initialize it. */
2709 cse_not_expected = ! optimize;
2710
2711 /* First, make sure that NOTE_BLOCK is set correctly for each
2712 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2713 if (!cfun->x_whole_function_mode_p)
2714 identify_blocks ();
2715
2716 /* Then remove any notes we don't need. That will make iterating
2717 over the instruction sequence faster, and allow the garbage
2718 collector to reclaim the memory used by the notes. */
2719 remove_unnecessary_notes ();
2720
2721 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2722 tree in sensible shape. So, we just recalculate it here. */
2723 if (cfun->x_whole_function_mode_p)
2724 reorder_blocks ();
2725
2726 init_flow ();
2727
2728 /* If we are reconsidering an inline function
2729 at the end of compilation, skip the stuff for making it inline. */
2730
2731 if (DECL_SAVED_INSNS (decl) == 0)
2732 {
2733 int inlinable = 0;
2734 tree parent;
2735 const char *lose;
2736
2737 /* If this is nested inside an inlined external function, pretend
2738 it was only declared. Since we cannot inline such functions,
2739 generating code for this one is not only not necessary but will
2740 confuse some debugging output writers. */
2741 for (parent = DECL_CONTEXT (current_function_decl);
2742 parent != NULL_TREE;
2743 parent = get_containing_scope (parent))
2744 if (TREE_CODE (parent) == FUNCTION_DECL
2745 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2746 {
2747 DECL_INITIAL (decl) = 0;
2748 goto exit_rest_of_compilation;
2749 }
2750
2751 /* If requested, consider whether to make this function inline. */
2752 if (DECL_INLINE (decl) || flag_inline_functions)
2753 {
2754 timevar_push (TV_INTEGRATION);
2755 lose = function_cannot_inline_p (decl);
2756 timevar_pop (TV_INTEGRATION);
2757 if (lose || ! optimize)
2758 {
2759 if (warn_inline && DECL_INLINE (decl))
2760 warning_with_decl (decl, lose);
2761 DECL_ABSTRACT_ORIGIN (decl) = 0;
2762 /* Don't really compile an extern inline function.
2763 If we can't make it inline, pretend
2764 it was only declared. */
2765 if (DECL_EXTERNAL (decl))
2766 {
2767 DECL_INITIAL (decl) = 0;
2768 goto exit_rest_of_compilation;
2769 }
2770 }
2771 else
2772 /* ??? Note that this has the effect of making it look
2773 like "inline" was specified for a function if we choose
2774 to inline it. This isn't quite right, but it's
2775 probably not worth the trouble to fix. */
2776 inlinable = DECL_INLINE (decl) = 1;
2777 }
2778
2779 insns = get_insns ();
2780
2781 /* Dump the rtl code if we are dumping rtl. */
2782
2783 if (open_dump_file (DFI_rtl, decl))
2784 {
2785 if (DECL_SAVED_INSNS (decl))
2786 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2787 close_dump_file (DFI_rtl, print_rtl, insns);
2788 }
2789
2790 /* If function is inline, and we don't yet know whether to
2791 compile it by itself, defer decision till end of compilation.
2792 finish_compilation will call rest_of_compilation again
2793 for those functions that need to be output. Also defer those
2794 functions that we are supposed to defer. */
2795
2796 if (inlinable
2797 || (DECL_INLINE (decl)
2798 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2799 && ! flag_keep_inline_functions)
2800 || DECL_EXTERNAL (decl))))
2801 DECL_DEFER_OUTPUT (decl) = 1;
2802
2803 if (DECL_INLINE (decl))
2804 /* DWARF wants seperate debugging info for abstract and
2805 concrete instances of all inline functions, including those
2806 declared inline but not inlined, and those inlined even
2807 though they weren't declared inline. Conveniently, that's
2808 what DECL_INLINE means at this point. */
2809 note_deferral_of_defined_inline_function (decl);
2810
2811 if (DECL_DEFER_OUTPUT (decl))
2812 {
2813 /* If -Wreturn-type, we have to do a bit of compilation. We just
2814 want to call jump_optimize to figure out whether or not we can
2815 fall off the end of the function; we do the minimum amount of
2816 work necessary to make that safe. And, we set optimize to zero
2817 to keep jump_optimize from working too hard. */
2818 if (warn_return_type)
2819 {
2820 int saved_optimize = optimize;
2821
2822 optimize = 0;
2823 find_exception_handler_labels ();
2824 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2825 !JUMP_AFTER_REGSCAN);
2826 optimize = saved_optimize;
2827 }
2828
2829 current_function_nothrow = nothrow_function_p ();
2830 if (current_function_nothrow)
2831 /* Now we know that this can't throw; set the flag for the benefit
2832 of other functions later in this translation unit. */
2833 TREE_NOTHROW (current_function_decl) = 1;
2834
2835 timevar_push (TV_INTEGRATION);
2836 save_for_inline (decl);
2837 timevar_pop (TV_INTEGRATION);
2838 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2839 goto exit_rest_of_compilation;
2840 }
2841
2842 /* If specified extern inline but we aren't inlining it, we are
2843 done. This goes for anything that gets here with DECL_EXTERNAL
2844 set, not just things with DECL_INLINE. */
2845 if (DECL_EXTERNAL (decl))
2846 goto exit_rest_of_compilation;
2847 }
2848
2849 init_EXPR_INSN_LIST_cache ();
2850
2851 ggc_collect ();
2852
2853 /* Initialize some variables used by the optimizers. */
2854 init_function_for_compilation ();
2855
2856 if (! DECL_DEFER_OUTPUT (decl))
2857 TREE_ASM_WRITTEN (decl) = 1;
2858
2859 /* Now that integrate will no longer see our rtl, we need not
2860 distinguish between the return value of this function and the
2861 return value of called functions. Also, we can remove all SETs
2862 of subregs of hard registers; they are only here because of
2863 integrate.*/
2864 rtx_equal_function_value_matters = 0;
2865 purge_hard_subreg_sets (get_insns ());
2866
2867 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2868 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2869 goto exit_rest_of_compilation;
2870
2871 /* Emit code to get eh context, if needed. */
2872 emit_eh_context ();
2873
2874 /* We may have potential sibling or tail recursion sites. Select one
2875 (of possibly multiple) methods of performing the call. */
2876 if (flag_optimize_sibling_calls)
2877 {
2878 timevar_push (TV_JUMP);
2879 open_dump_file (DFI_sibling, decl);
2880
2881 optimize_sibling_and_tail_recursive_calls ();
2882
2883 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2884 timevar_pop (TV_JUMP);
2885 }
2886
2887 #ifdef FINALIZE_PIC
2888 /* If we are doing position-independent code generation, now
2889 is the time to output special prologues and epilogues.
2890 We do not want to do this earlier, because it just clutters
2891 up inline functions with meaningless insns. */
2892 if (flag_pic)
2893 FINALIZE_PIC;
2894 #endif
2895
2896 insns = get_insns ();
2897
2898 /* Copy any shared structure that should not be shared. */
2899 unshare_all_rtl (current_function_decl, insns);
2900
2901 #ifdef SETJMP_VIA_SAVE_AREA
2902 /* This must be performed before virutal register instantiation. */
2903 if (current_function_calls_alloca)
2904 optimize_save_area_alloca (insns);
2905 #endif
2906
2907 /* Instantiate all virtual registers. */
2908 instantiate_virtual_regs (current_function_decl, insns);
2909
2910 /* Find all the EH handlers. */
2911 find_exception_handler_labels ();
2912
2913 open_dump_file (DFI_jump, decl);
2914
2915 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2916 are initialized and to compute whether control can drop off the end
2917 of the function. */
2918
2919 timevar_push (TV_JUMP);
2920 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2921 before jump optimization switches branch directions. */
2922 expected_value_to_br_prob ();
2923
2924 reg_scan (insns, max_reg_num (), 0);
2925 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2926 JUMP_AFTER_REGSCAN);
2927
2928 timevar_pop (TV_JUMP);
2929
2930 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2931 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2932 {
2933 close_dump_file (DFI_jump, print_rtl, insns);
2934 goto exit_rest_of_compilation;
2935 }
2936
2937 timevar_push (TV_JUMP);
2938
2939 if (optimize > 0)
2940 {
2941 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2942 cleanup_cfg (insns);
2943
2944 /* ??? Run if-conversion before delete_null_pointer_checks,
2945 since the later does not preserve the CFG. This should
2946 be changed -- no since converting if's that are going to
2947 be deleted. */
2948 timevar_push (TV_IFCVT);
2949 if_convert (0);
2950 timevar_pop (TV_IFCVT);
2951
2952 /* Try to identify useless null pointer tests and delete them. */
2953 if (flag_delete_null_pointer_checks)
2954 delete_null_pointer_checks (insns);
2955 }
2956
2957 /* Jump optimization, and the removal of NULL pointer checks, may
2958 have reduced the number of instructions substantially. CSE, and
2959 future passes, allocate arrays whose dimensions involve the
2960 maximum instruction UID, so if we can reduce the maximum UID
2961 we'll save big on memory. */
2962 renumber_insns (rtl_dump_file);
2963 timevar_pop (TV_JUMP);
2964
2965 close_dump_file (DFI_jump, print_rtl, insns);
2966
2967 ggc_collect ();
2968
2969 /* Perform common subexpression elimination.
2970 Nonzero value from `cse_main' means that jumps were simplified
2971 and some code may now be unreachable, so do
2972 jump optimization again. */
2973
2974 if (optimize > 0)
2975 {
2976 open_dump_file (DFI_cse, decl);
2977 timevar_push (TV_CSE);
2978
2979 reg_scan (insns, max_reg_num (), 1);
2980
2981 if (flag_thread_jumps)
2982 {
2983 timevar_push (TV_JUMP);
2984 thread_jumps (insns, max_reg_num (), 1);
2985 timevar_pop (TV_JUMP);
2986 }
2987
2988 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2989
2990 /* If we are not running the second CSE pass, then we are no longer
2991 expecting CSE to be run. */
2992 cse_not_expected = !flag_rerun_cse_after_loop;
2993
2994 if (tem || optimize > 1)
2995 {
2996 timevar_push (TV_JUMP);
2997 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2998 !JUMP_AFTER_REGSCAN);
2999 timevar_pop (TV_JUMP);
3000 }
3001
3002 /* Run this after jump optmizations remove all the unreachable code
3003 so that unreachable code will not keep values live. */
3004 delete_trivially_dead_insns (insns, max_reg_num ());
3005
3006 /* Try to identify useless null pointer tests and delete them. */
3007 if (flag_delete_null_pointer_checks)
3008 {
3009 timevar_push (TV_JUMP);
3010 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3011
3012 cleanup_cfg (insns);
3013
3014 delete_null_pointer_checks (insns);
3015 timevar_pop (TV_JUMP);
3016 }
3017
3018 /* The second pass of jump optimization is likely to have
3019 removed a bunch more instructions. */
3020 renumber_insns (rtl_dump_file);
3021
3022 timevar_pop (TV_CSE);
3023 close_dump_file (DFI_cse, print_rtl, insns);
3024 }
3025
3026 open_dump_file (DFI_addressof, decl);
3027
3028 purge_addressof (insns);
3029 reg_scan (insns, max_reg_num (), 1);
3030
3031 close_dump_file (DFI_addressof, print_rtl, insns);
3032
3033 ggc_collect ();
3034
3035 if (optimize > 0 && flag_ssa)
3036 {
3037 /* Convert to SSA form. */
3038
3039 timevar_push (TV_TO_SSA);
3040 open_dump_file (DFI_ssa, decl);
3041
3042 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3043 cleanup_cfg (insns);
3044 convert_to_ssa ();
3045
3046 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
3047 timevar_pop (TV_TO_SSA);
3048
3049 /* The SSA implementation uses basic block numbers in its phi
3050 nodes. Thus, changing the control-flow graph or the basic
3051 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
3052 may cause problems. */
3053
3054 if (flag_dce)
3055 {
3056 /* Remove dead code. */
3057
3058 timevar_push (TV_DEAD_CODE_ELIM);
3059 open_dump_file (DFI_dce, decl);
3060
3061 insns = get_insns ();
3062 eliminate_dead_code();
3063
3064 close_dump_file (DFI_dce, print_rtl_with_bb, insns);
3065 timevar_pop (TV_DEAD_CODE_ELIM);
3066 }
3067
3068 /* Convert from SSA form. */
3069
3070 timevar_push (TV_FROM_SSA);
3071 open_dump_file (DFI_ussa, decl);
3072
3073 convert_from_ssa ();
3074 /* New registers have been created. Rescan their usage. */
3075 reg_scan (insns, max_reg_num (), 1);
3076 /* Life analysis used in SSA adds log_links but these
3077 shouldn't be there until the flow stage, so clear
3078 them away. */
3079 clear_log_links (insns);
3080
3081 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
3082 timevar_pop (TV_FROM_SSA);
3083
3084 ggc_collect ();
3085 }
3086
3087 /* Perform global cse. */
3088
3089 if (optimize > 0 && flag_gcse)
3090 {
3091 timevar_push (TV_GCSE);
3092 open_dump_file (DFI_gcse, decl);
3093
3094 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3095 cleanup_cfg (insns);
3096 tem = gcse_main (insns, rtl_dump_file);
3097
3098 /* If gcse altered any jumps, rerun jump optimizations to clean
3099 things up. */
3100 if (tem)
3101 {
3102 timevar_push (TV_JUMP);
3103 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3104 !JUMP_AFTER_REGSCAN);
3105 timevar_pop (TV_JUMP);
3106 }
3107
3108 close_dump_file (DFI_gcse, print_rtl, insns);
3109 timevar_pop (TV_GCSE);
3110
3111 ggc_collect ();
3112 }
3113
3114 /* Move constant computations out of loops. */
3115
3116 if (optimize > 0)
3117 {
3118 timevar_push (TV_LOOP);
3119 open_dump_file (DFI_loop, decl);
3120
3121 if (flag_rerun_loop_opt)
3122 {
3123 /* We only want to perform unrolling once. */
3124
3125 loop_optimize (insns, rtl_dump_file, 0);
3126
3127 /* The first call to loop_optimize makes some instructions
3128 trivially dead. We delete those instructions now in the
3129 hope that doing so will make the heuristics in loop work
3130 better and possibly speed up compilation. */
3131 delete_trivially_dead_insns (insns, max_reg_num ());
3132
3133 /* The regscan pass is currently necessary as the alias
3134 analysis code depends on this information. */
3135 reg_scan (insns, max_reg_num (), 1);
3136 }
3137 loop_optimize (insns, rtl_dump_file,
3138 (flag_unroll_loops ? LOOP_UNROLL : 0) | LOOP_BCT);
3139
3140 close_dump_file (DFI_loop, print_rtl, insns);
3141 timevar_pop (TV_LOOP);
3142
3143 ggc_collect ();
3144 }
3145
3146 if (optimize > 0)
3147 {
3148 timevar_push (TV_CSE2);
3149 open_dump_file (DFI_cse2, decl);
3150
3151 if (flag_rerun_cse_after_loop)
3152 {
3153 /* Running another jump optimization pass before the second
3154 cse pass sometimes simplifies the RTL enough to allow
3155 the second CSE pass to do a better job. Jump_optimize can change
3156 max_reg_num so we must rerun reg_scan afterwards.
3157 ??? Rework to not call reg_scan so often. */
3158 timevar_push (TV_JUMP);
3159
3160 reg_scan (insns, max_reg_num (), 0);
3161 jump_optimize (insns, !JUMP_CROSS_JUMP,
3162 !JUMP_NOOP_MOVES, JUMP_AFTER_REGSCAN);
3163
3164 timevar_push (TV_IFCVT);
3165
3166 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3167 cleanup_cfg (insns);
3168 if_convert (0);
3169
3170 timevar_pop(TV_IFCVT);
3171
3172 timevar_pop (TV_JUMP);
3173
3174 reg_scan (insns, max_reg_num (), 0);
3175 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3176
3177 if (tem)
3178 {
3179 timevar_push (TV_JUMP);
3180 jump_optimize (insns, !JUMP_CROSS_JUMP,
3181 !JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3182 timevar_pop (TV_JUMP);
3183 }
3184 }
3185
3186 if (flag_thread_jumps)
3187 {
3188 /* This pass of jump threading straightens out code
3189 that was kinked by loop optimization. */
3190 timevar_push (TV_JUMP);
3191 reg_scan (insns, max_reg_num (), 0);
3192 thread_jumps (insns, max_reg_num (), 0);
3193 timevar_pop (TV_JUMP);
3194 }
3195
3196 close_dump_file (DFI_cse2, print_rtl, insns);
3197 timevar_pop (TV_CSE2);
3198
3199 ggc_collect ();
3200 }
3201
3202 cse_not_expected = 1;
3203
3204 regclass_init ();
3205
3206 /* Do control and data flow analysis; wrote some of the results to
3207 the dump file. */
3208
3209 timevar_push (TV_FLOW);
3210 open_dump_file (DFI_cfg, decl);
3211
3212 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3213 cleanup_cfg (insns);
3214 check_function_return_warnings ();
3215
3216 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
3217
3218 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3219 {
3220 timevar_push (TV_BRANCH_PROB);
3221 open_dump_file (DFI_bp, decl);
3222
3223 branch_prob ();
3224
3225 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
3226 timevar_pop (TV_BRANCH_PROB);
3227 }
3228
3229 open_dump_file (DFI_life, decl);
3230 if (optimize)
3231 {
3232 struct loops loops;
3233
3234 /* Discover and record the loop depth at the head of each basic
3235 block. The loop infrastructure does the real job for us. */
3236 flow_loops_find (&loops, LOOP_TREE);
3237
3238 /* Estimate using heuristics if no profiling info is available. */
3239 estimate_probability (&loops);
3240
3241 if (rtl_dump_file)
3242 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
3243
3244 flow_loops_free (&loops);
3245 }
3246 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3247 mark_constant_function ();
3248 timevar_pop (TV_FLOW);
3249
3250 register_life_up_to_date = 1;
3251 no_new_pseudos = 1;
3252
3253 if (warn_uninitialized || extra_warnings)
3254 {
3255 uninitialized_vars_warning (DECL_INITIAL (decl));
3256 if (extra_warnings)
3257 setjmp_args_warning ();
3258 }
3259
3260 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3261
3262 ggc_collect ();
3263
3264 /* If -opt, try combining insns through substitution. */
3265
3266 if (optimize > 0)
3267 {
3268 int rebuild_jump_labels_after_combine = 0;
3269
3270 timevar_push (TV_COMBINE);
3271 open_dump_file (DFI_combine, decl);
3272
3273 rebuild_jump_labels_after_combine
3274 = combine_instructions (insns, max_reg_num ());
3275
3276 /* Combining insns may have turned an indirect jump into a
3277 direct jump. Rebuid the JUMP_LABEL fields of jumping
3278 instructions. */
3279 if (rebuild_jump_labels_after_combine)
3280 {
3281 timevar_push (TV_JUMP);
3282 rebuild_jump_labels (insns);
3283 timevar_pop (TV_JUMP);
3284
3285 timevar_push (TV_FLOW);
3286 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3287 cleanup_cfg (insns);
3288
3289 /* Blimey. We've got to have the CFG up to date for the call to
3290 if_convert below. However, the random deletion of blocks
3291 without updating life info can wind up with Wierd Stuff in
3292 global_live_at_end. We then run sched1, which updates things
3293 properly, discovers the wierdness and aborts. */
3294 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
3295 PROP_DEATH_NOTES | PROP_KILL_DEAD_CODE
3296 | PROP_SCAN_DEAD_CODE);
3297
3298 timevar_pop (TV_FLOW);
3299 }
3300
3301 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3302 timevar_pop (TV_COMBINE);
3303
3304 ggc_collect ();
3305 }
3306
3307 /* Rerun if-conversion, as combine may have simplified things enough to
3308 now meet sequence length restrictions. */
3309 if (optimize > 0)
3310 {
3311 timevar_push (TV_IFCVT);
3312 open_dump_file (DFI_ce, decl);
3313
3314 no_new_pseudos = 0;
3315 if_convert (1);
3316 no_new_pseudos = 1;
3317
3318 close_dump_file (DFI_ce, print_rtl_with_bb, insns);
3319 timevar_pop (TV_IFCVT);
3320 }
3321
3322 /* Register allocation pre-pass, to reduce number of moves
3323 necessary for two-address machines. */
3324 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3325 {
3326 timevar_push (TV_REGMOVE);
3327 open_dump_file (DFI_regmove, decl);
3328
3329 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3330
3331 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3332 timevar_pop (TV_REGMOVE);
3333
3334 ggc_collect ();
3335 }
3336
3337 /* Any of the several passes since flow1 will have munged register
3338 lifetime data a bit. */
3339 if (optimize > 0)
3340 register_life_up_to_date = 0;
3341
3342 #ifdef OPTIMIZE_MODE_SWITCHING
3343 if (optimize)
3344 {
3345 timevar_push (TV_GCSE);
3346
3347 if (optimize_mode_switching (NULL_PTR))
3348 {
3349 /* We did work, and so had to regenerate global life information.
3350 Take advantage of this and don't re-recompute register life
3351 information below. */
3352 register_life_up_to_date = 1;
3353 }
3354
3355 timevar_pop (TV_GCSE);
3356 }
3357 #endif
3358
3359 #ifdef INSN_SCHEDULING
3360
3361 /* Print function header into sched dump now
3362 because doing the sched analysis makes some of the dump. */
3363 if (optimize > 0 && flag_schedule_insns)
3364 {
3365 timevar_push (TV_SCHED);
3366 open_dump_file (DFI_sched, decl);
3367
3368 /* Do control and data sched analysis,
3369 and write some of the results to dump file. */
3370
3371 schedule_insns (rtl_dump_file);
3372
3373 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3374 timevar_pop (TV_SCHED);
3375
3376 ggc_collect ();
3377
3378 /* Register lifetime information was updated as part of verifying
3379 the schedule. */
3380 register_life_up_to_date = 1;
3381 }
3382 #endif
3383
3384 /* Determine if the current function is a leaf before running reload
3385 since this can impact optimizations done by the prologue and
3386 epilogue thus changing register elimination offsets. */
3387 current_function_is_leaf = leaf_function_p ();
3388
3389 timevar_push (TV_LOCAL_ALLOC);
3390 open_dump_file (DFI_lreg, decl);
3391
3392 /* Allocate pseudo-regs that are used only within 1 basic block.
3393
3394 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3395 jump optimizer after register allocation and reloading are finished. */
3396
3397 if (! register_life_up_to_date)
3398 recompute_reg_usage (insns, ! optimize_size);
3399 regclass (insns, max_reg_num (), rtl_dump_file);
3400 rebuild_label_notes_after_reload = local_alloc ();
3401
3402 timevar_pop (TV_LOCAL_ALLOC);
3403
3404 if (dump_file[DFI_lreg].enabled)
3405 {
3406 timevar_push (TV_DUMP);
3407
3408 dump_flow_info (rtl_dump_file);
3409 dump_local_alloc (rtl_dump_file);
3410
3411 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3412 timevar_pop (TV_DUMP);
3413 }
3414
3415 ggc_collect ();
3416
3417 timevar_push (TV_GLOBAL_ALLOC);
3418 open_dump_file (DFI_greg, decl);
3419
3420 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3421 pass fixing up any insns that are invalid. */
3422
3423 if (optimize)
3424 failure = global_alloc (rtl_dump_file);
3425 else
3426 {
3427 build_insn_chain (insns);
3428 failure = reload (insns, 0);
3429 }
3430
3431 timevar_pop (TV_GLOBAL_ALLOC);
3432
3433 if (dump_file[DFI_greg].enabled)
3434 {
3435 timevar_push (TV_DUMP);
3436
3437 dump_global_regs (rtl_dump_file);
3438
3439 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3440 timevar_pop (TV_DUMP);
3441 }
3442
3443 if (failure)
3444 goto exit_rest_of_compilation;
3445
3446 ggc_collect ();
3447
3448 open_dump_file (DFI_postreload, decl);
3449
3450 /* Do a very simple CSE pass over just the hard registers. */
3451 if (optimize > 0)
3452 {
3453 timevar_push (TV_RELOAD_CSE_REGS);
3454 reload_cse_regs (insns);
3455 timevar_pop (TV_RELOAD_CSE_REGS);
3456 }
3457
3458 /* If optimizing, then go ahead and split insns now since we are about
3459 to recompute flow information anyway. */
3460 if (optimize > 0)
3461 {
3462 int old_labelnum = max_label_num ();
3463
3464 split_all_insns (0);
3465 rebuild_label_notes_after_reload |= old_labelnum != max_label_num ();
3466 }
3467
3468 /* Register allocation and reloading may have turned an indirect jump into
3469 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3470 jumping instructions. */
3471 if (rebuild_label_notes_after_reload)
3472 {
3473 timevar_push (TV_JUMP);
3474
3475 rebuild_jump_labels (insns);
3476
3477 timevar_pop (TV_JUMP);
3478 }
3479
3480 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3481
3482 /* Re-create the death notes which were deleted during reload. */
3483 timevar_push (TV_FLOW2);
3484 open_dump_file (DFI_flow2, decl);
3485
3486 jump_optimize (insns, !JUMP_CROSS_JUMP,
3487 JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3488 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3489
3490 /* On some machines, the prologue and epilogue code, or parts thereof,
3491 can be represented as RTL. Doing so lets us schedule insns between
3492 it and the rest of the code and also allows delayed branch
3493 scheduling to operate in the epilogue. */
3494 thread_prologue_and_epilogue_insns (insns);
3495
3496 if (optimize)
3497 {
3498 cleanup_cfg (insns);
3499 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3500
3501 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3502 even for machines with possibly nonzero RETURN_POPS_ARGS
3503 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3504 push instructions will have popping returns. */
3505 #ifndef PUSH_ROUNDING
3506 if (!ACCUMULATE_OUTGOING_ARGS)
3507 #endif
3508 combine_stack_adjustments ();
3509
3510 ggc_collect ();
3511 }
3512
3513 flow2_completed = 1;
3514
3515 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3516 timevar_pop (TV_FLOW2);
3517
3518 #ifdef HAVE_peephole2
3519 if (optimize > 0 && flag_peephole2)
3520 {
3521 timevar_push (TV_PEEPHOLE2);
3522 open_dump_file (DFI_peephole2, decl);
3523
3524 peephole2_optimize (rtl_dump_file);
3525
3526 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3527 timevar_pop (TV_PEEPHOLE2);
3528 }
3529 #endif
3530
3531 if (optimize > 0 && flag_rename_registers)
3532 {
3533 timevar_push (TV_RENAME_REGISTERS);
3534 open_dump_file (DFI_rnreg, decl);
3535
3536 regrename_optimize ();
3537
3538 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3539 timevar_pop (TV_RENAME_REGISTERS);
3540 }
3541
3542 if (optimize > 0)
3543 {
3544 timevar_push (TV_IFCVT2);
3545 open_dump_file (DFI_ce2, decl);
3546
3547 if_convert (1);
3548
3549 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3550 timevar_pop (TV_IFCVT2);
3551 }
3552
3553 #ifdef INSN_SCHEDULING
3554 if (optimize > 0 && flag_schedule_insns_after_reload)
3555 {
3556 timevar_push (TV_SCHED2);
3557 open_dump_file (DFI_sched2, decl);
3558
3559 /* Do control and data sched analysis again,
3560 and write some more of the results to dump file. */
3561
3562 schedule_insns (rtl_dump_file);
3563
3564 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3565 timevar_pop (TV_SCHED2);
3566
3567 ggc_collect ();
3568 }
3569 #endif
3570
3571 #ifdef LEAF_REGISTERS
3572 current_function_uses_only_leaf_regs
3573 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3574 #endif
3575
3576 if (optimize > 0 && flag_reorder_blocks)
3577 {
3578 timevar_push (TV_REORDER_BLOCKS);
3579 open_dump_file (DFI_bbro, decl);
3580
3581 reorder_basic_blocks ();
3582
3583 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3584 timevar_pop (TV_REORDER_BLOCKS);
3585 }
3586
3587 /* One more attempt to remove jumps to .+1 left by dead-store elimination.
3588 Also do cross-jumping this time and delete no-op move insns. */
3589
3590 if (optimize > 0)
3591 {
3592 timevar_push (TV_JUMP);
3593 open_dump_file (DFI_jump2, decl);
3594
3595 jump_optimize (insns, JUMP_CROSS_JUMP, JUMP_NOOP_MOVES,
3596 !JUMP_AFTER_REGSCAN);
3597
3598 /* CFG no longer kept up to date. */
3599
3600 close_dump_file (DFI_jump2, print_rtl_with_bb, insns);
3601 timevar_pop (TV_JUMP);
3602 }
3603
3604 /* If a machine dependent reorganization is needed, call it. */
3605 #ifdef MACHINE_DEPENDENT_REORG
3606 open_dump_file (DFI_mach, decl);
3607
3608 MACHINE_DEPENDENT_REORG (insns);
3609
3610 close_dump_file (DFI_mach, print_rtl_with_bb, insns);
3611
3612 ggc_collect ();
3613 #endif
3614
3615 /* If a scheduling pass for delayed branches is to be done,
3616 call the scheduling code. */
3617
3618 #ifdef DELAY_SLOTS
3619 if (optimize > 0 && flag_delayed_branch)
3620 {
3621 timevar_push (TV_DBR_SCHED);
3622 open_dump_file (DFI_dbr, decl);
3623
3624 dbr_schedule (insns, rtl_dump_file);
3625
3626 close_dump_file (DFI_dbr, print_rtl_with_bb, insns);
3627 timevar_pop (TV_DBR_SCHED);
3628
3629 ggc_collect ();
3630 }
3631 #endif
3632
3633 /* Shorten branches.
3634
3635 Note this must run before reg-stack because of death note (ab)use
3636 in the ia32 backend. */
3637 timevar_push (TV_SHORTEN_BRANCH);
3638 shorten_branches (get_insns ());
3639 timevar_pop (TV_SHORTEN_BRANCH);
3640
3641 #ifdef STACK_REGS
3642 timevar_push (TV_REG_STACK);
3643 open_dump_file (DFI_stack, decl);
3644
3645 reg_to_stack (insns, rtl_dump_file);
3646
3647 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3648 timevar_pop (TV_REG_STACK);
3649
3650 ggc_collect ();
3651 #endif
3652
3653 current_function_nothrow = nothrow_function_p ();
3654 if (current_function_nothrow)
3655 /* Now we know that this can't throw; set the flag for the benefit
3656 of other functions later in this translation unit. */
3657 TREE_NOTHROW (current_function_decl) = 1;
3658
3659 /* Now turn the rtl into assembler code. */
3660
3661 timevar_push (TV_FINAL);
3662 {
3663 rtx x;
3664 const char *fnname;
3665
3666 /* Get the function's name, as described by its RTL. This may be
3667 different from the DECL_NAME name used in the source file. */
3668
3669 x = DECL_RTL (decl);
3670 if (GET_CODE (x) != MEM)
3671 abort ();
3672 x = XEXP (x, 0);
3673 if (GET_CODE (x) != SYMBOL_REF)
3674 abort ();
3675 fnname = XSTR (x, 0);
3676
3677 assemble_start_function (decl, fnname);
3678 final_start_function (insns, asm_out_file, optimize);
3679 final (insns, asm_out_file, optimize, 0);
3680 final_end_function (insns, asm_out_file, optimize);
3681 assemble_end_function (decl, fnname);
3682 if (! quiet_flag)
3683 fflush (asm_out_file);
3684
3685 /* Release all memory allocated by flow. */
3686 free_basic_block_vars (0);
3687
3688 /* Release all memory held by regsets now. */
3689 regset_release_memory ();
3690 }
3691 timevar_pop (TV_FINAL);
3692
3693 ggc_collect ();
3694
3695 /* Write DBX symbols if requested. */
3696
3697 /* Note that for those inline functions where we don't initially
3698 know for certain that we will be generating an out-of-line copy,
3699 the first invocation of this routine (rest_of_compilation) will
3700 skip over this code by doing a `goto exit_rest_of_compilation;'.
3701 Later on, finish_compilation will call rest_of_compilation again
3702 for those inline functions that need to have out-of-line copies
3703 generated. During that call, we *will* be routed past here. */
3704
3705 timevar_push (TV_SYMOUT);
3706 #ifdef DBX_DEBUGGING_INFO
3707 if (write_symbols == DBX_DEBUG)
3708 dbxout_function (decl);
3709 #endif
3710
3711 #ifdef DWARF_DEBUGGING_INFO
3712 if (write_symbols == DWARF_DEBUG)
3713 dwarfout_file_scope_decl (decl, 0);
3714 #endif
3715
3716 #ifdef DWARF2_DEBUGGING_INFO
3717 if (write_symbols == DWARF2_DEBUG)
3718 dwarf2out_decl (decl);
3719 #endif
3720 timevar_pop (TV_SYMOUT);
3721
3722 exit_rest_of_compilation:
3723
3724 /* In case the function was not output,
3725 don't leave any temporary anonymous types
3726 queued up for sdb output. */
3727 #ifdef SDB_DEBUGGING_INFO
3728 if (write_symbols == SDB_DEBUG)
3729 sdbout_types (NULL_TREE);
3730 #endif
3731
3732 reload_completed = 0;
3733 flow2_completed = 0;
3734 no_new_pseudos = 0;
3735
3736 timevar_push (TV_FINAL);
3737
3738 /* Clear out the insn_length contents now that they are no
3739 longer valid. */
3740 init_insn_lengths ();
3741
3742 /* Clear out the real_constant_chain before some of the rtx's
3743 it runs through become garbage. */
3744 clear_const_double_mem ();
3745
3746 /* Show no temporary slots allocated. */
3747 init_temp_slots ();
3748
3749 free_basic_block_vars (0);
3750
3751 timevar_pop (TV_FINAL);
3752
3753 /* Make sure volatile mem refs aren't considered valid operands for
3754 arithmetic insns. We must call this here if this is a nested inline
3755 function, since the above code leaves us in the init_recog state
3756 (from final.c), and the function context push/pop code does not
3757 save/restore volatile_ok.
3758
3759 ??? Maybe it isn't necessary for expand_start_function to call this
3760 anymore if we do it here? */
3761
3762 init_recog_no_volatile ();
3763
3764 /* We're done with this function. Free up memory if we can. */
3765 free_after_parsing (cfun);
3766 if (! DECL_DEFER_OUTPUT (decl))
3767 free_after_compilation (cfun);
3768 cfun = 0;
3769
3770 ggc_collect ();
3771
3772 timevar_pop (TV_REST_OF_COMPILATION);
3773 }
3774 \f
3775 static void
3776 display_help ()
3777 {
3778 int undoc;
3779 unsigned long i;
3780 const char *lang;
3781
3782 #ifndef USE_CPPLIB
3783 printf (_("Usage: %s input [switches]\n"), progname);
3784 printf (_("Switches:\n"));
3785 #endif
3786 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3787 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3788 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3789 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3790 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3791 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"));
3792
3793 for (i = ARRAY_SIZE (f_options); i--;)
3794 {
3795 const char *description = f_options[i].description;
3796
3797 if (description != NULL && * description != 0)
3798 printf (" -f%-21s %s\n",
3799 f_options[i].string, description);
3800 }
3801
3802 printf (_(" -O[number] Set optimisation level to [number]\n"));
3803 printf (_(" -Os Optimise for space rather than speed\n"));
3804 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3805 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3806 printf (_(" -w Suppress warnings\n"));
3807 printf (_(" -W Enable extra warnings\n"));
3808
3809 for (i = ARRAY_SIZE (W_options); i--;)
3810 {
3811 const char *description = W_options[i].description;
3812
3813 if (description != NULL && * description != 0)
3814 printf (" -W%-21s %s\n",
3815 W_options[i].string, description);
3816 }
3817
3818 printf (_(" -Wunused Enable unused warnings\n"));
3819 printf (_(" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n"));
3820 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3821 printf (_(" -p Enable function profiling\n"));
3822 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3823 printf (_(" -a Enable block profiling \n"));
3824 #endif
3825 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3826 printf (_(" -ax Enable jump profiling \n"));
3827 #endif
3828 printf (_(" -o <file> Place output into <file> \n"));
3829 printf (_("\
3830 -G <number> Put global and static data smaller than <number>\n\
3831 bytes into a special section (on some targets)\n"));
3832
3833 for (i = ARRAY_SIZE (debug_args); i--;)
3834 {
3835 if (debug_args[i].description != NULL)
3836 printf (" -g%-21s %s\n",
3837 debug_args[i].arg, debug_args[i].description);
3838 }
3839
3840 printf (_(" -aux-info <file> Emit declaration info into <file>.X\n"));
3841 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3842 printf (_(" -version Display the compiler's version\n"));
3843 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3844 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3845 #if defined INSN_SCHEDULING
3846 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3847 #endif
3848 printf (_(" --help Display this information\n"));
3849
3850 undoc = 0;
3851 lang = "language";
3852
3853 /* Display descriptions of language specific options.
3854 If there is no description, note that there is an undocumented option.
3855 If the description is empty, do not display anything. (This allows
3856 options to be deliberately undocumented, for whatever reason).
3857 If the option string is missing, then this is a marker, indicating
3858 that the description string is in fact the name of a language, whose
3859 language specific options are to follow. */
3860
3861 if (ARRAY_SIZE (documented_lang_options) > 1)
3862 {
3863 printf (_("\nLanguage specific options:\n"));
3864
3865 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3866 {
3867 const char *description = documented_lang_options[i].description;
3868 const char *option = documented_lang_options[i].option;
3869
3870 if (description == NULL)
3871 {
3872 undoc = 1;
3873
3874 if (extra_warnings)
3875 printf (_(" %-23.23s [undocumented]\n"), option);
3876 }
3877 else if (*description == 0)
3878 continue;
3879 else if (option == NULL)
3880 {
3881 if (undoc)
3882 printf
3883 (_("\nThere are undocumented %s specific options as well.\n"),
3884 lang);
3885 undoc = 0;
3886
3887 printf (_("\n Options for %s:\n"), description);
3888
3889 lang = description;
3890 }
3891 else
3892 printf (" %-23.23s %s\n", option, description);
3893 }
3894 }
3895
3896 if (undoc)
3897 printf (_("\nThere are undocumented %s specific options as well.\n"),
3898 lang);
3899
3900 display_target_options ();
3901 }
3902
3903 static void
3904 display_target_options ()
3905 {
3906 int undoc,i;
3907
3908 if (ARRAY_SIZE (target_switches) > 1
3909 #ifdef TARGET_OPTIONS
3910 || ARRAY_SIZE (target_options) > 1
3911 #endif
3912 )
3913 {
3914 int doc = 0;
3915
3916 undoc = 0;
3917
3918 printf (_("\nTarget specific options:\n"));
3919
3920 for (i = ARRAY_SIZE (target_switches); i--;)
3921 {
3922 const char *option = target_switches[i].name;
3923 const char *description = target_switches[i].description;
3924
3925 if (option == NULL || *option == 0)
3926 continue;
3927 else if (description == NULL)
3928 {
3929 undoc = 1;
3930
3931 if (extra_warnings)
3932 printf (_(" -m%-23.23s [undocumented]\n"), option);
3933 }
3934 else if (* description != 0)
3935 doc += printf (" -m%-23.23s %s\n", option, description);
3936 }
3937
3938 #ifdef TARGET_OPTIONS
3939 for (i = ARRAY_SIZE (target_options); i--;)
3940 {
3941 const char *option = target_options[i].prefix;
3942 const char *description = target_options[i].description;
3943
3944 if (option == NULL || *option == 0)
3945 continue;
3946 else if (description == NULL)
3947 {
3948 undoc = 1;
3949
3950 if (extra_warnings)
3951 printf (_(" -m%-23.23s [undocumented]\n"), option);
3952 }
3953 else if (* description != 0)
3954 doc += printf (" -m%-23.23s %s\n", option, description);
3955 }
3956 #endif
3957 if (undoc)
3958 {
3959 if (doc)
3960 printf (_("\nThere are undocumented target specific options as well.\n"));
3961 else
3962 printf (_(" They exist, but they are not documented.\n"));
3963 }
3964 }
3965 }
3966 \f
3967 /* Parse a -d... comand line switch. */
3968
3969 static void
3970 decode_d_option (arg)
3971 const char *arg;
3972 {
3973 int i, c, matched;
3974
3975 while (*arg)
3976 switch (c = *arg++)
3977 {
3978 case 'a':
3979 for (i = 0; i < DFI_MAX; ++i)
3980 dump_file[i].enabled = 1;
3981 break;
3982 case 'A':
3983 flag_debug_asm = 1;
3984 break;
3985 case 'm':
3986 flag_print_mem = 1;
3987 break;
3988 case 'p':
3989 flag_print_asm_name = 1;
3990 break;
3991 case 'P':
3992 flag_dump_rtl_in_asm = 1;
3993 flag_print_asm_name = 1;
3994 break;
3995 case 'v':
3996 graph_dump_format = vcg;
3997 break;
3998 case 'x':
3999 rtl_dump_and_exit = 1;
4000 break;
4001 case 'y':
4002 set_yydebug (1);
4003 break;
4004 case 'D': /* These are handled by the preprocessor. */
4005 case 'I':
4006 break;
4007
4008 default:
4009 matched = 0;
4010 for (i = 0; i < DFI_MAX; ++i)
4011 if (c == dump_file[i].debug_switch)
4012 {
4013 dump_file[i].enabled = 1;
4014 matched = 1;
4015 }
4016
4017 if (! matched)
4018 warning ("unrecognized gcc debugging option: %c", c);
4019 break;
4020 }
4021 }
4022
4023 /* Parse a -f... comand line switch. ARG is the value after the -f.
4024 It is safe to access 'ARG - 2' to generate the full switch name.
4025 Return the number of strings consumed. */
4026
4027 static int
4028 decode_f_option (arg)
4029 const char *arg;
4030 {
4031 int j;
4032 const char *option_value = NULL;
4033
4034 /* Search for the option in the table of binary f options. */
4035 for (j = ARRAY_SIZE (f_options); j--;)
4036 {
4037 if (!strcmp (arg, f_options[j].string))
4038 {
4039 *f_options[j].variable = f_options[j].on_value;
4040 return 1;
4041 }
4042
4043 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4044 && ! strcmp (arg + 3, f_options[j].string))
4045 {
4046 *f_options[j].variable = ! f_options[j].on_value;
4047 return 1;
4048 }
4049 }
4050
4051 if ((option_value = skip_leading_substring (arg, "inline-limit-"))
4052 || (option_value = skip_leading_substring (arg, "inline-limit=")))
4053 inline_max_insns =
4054 read_integral_parameter (option_value, arg - 2, inline_max_insns);
4055 #ifdef INSN_SCHEDULING
4056 else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
4057 fix_sched_param ("verbose", option_value);
4058 #endif
4059 else if ((option_value = skip_leading_substring (arg, "fixed-")))
4060 fix_register (option_value, 1, 1);
4061 else if ((option_value = skip_leading_substring (arg, "call-used-")))
4062 fix_register (option_value, 0, 1);
4063 else if ((option_value = skip_leading_substring (arg, "call-saved-")))
4064 fix_register (option_value, 0, 0);
4065 else if ((option_value = skip_leading_substring (arg, "align-loops=")))
4066 align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
4067 else if ((option_value = skip_leading_substring (arg, "align-functions=")))
4068 align_functions
4069 = read_integral_parameter (option_value, arg - 2, align_functions);
4070 else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
4071 align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
4072 else if ((option_value = skip_leading_substring (arg, "align-labels=")))
4073 align_labels
4074 = read_integral_parameter (option_value, arg - 2, align_labels);
4075 else if ((option_value
4076 = skip_leading_substring (arg, "stack-limit-register=")))
4077 {
4078 int reg = decode_reg_name (option_value);
4079 if (reg < 0)
4080 error ("unrecognized register name `%s'", option_value);
4081 else
4082 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
4083 }
4084 else if ((option_value
4085 = skip_leading_substring (arg, "stack-limit-symbol=")))
4086 {
4087 char *nm;
4088 nm = ggc_strdup (option_value);
4089 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
4090 }
4091 else if ((option_value
4092 = skip_leading_substring (arg, "message-length=")))
4093 diagnostic_message_length_per_line =
4094 read_integral_parameter (option_value, arg - 2,
4095 diagnostic_message_length_per_line);
4096 else if ((option_value
4097 = skip_leading_substring (arg, "diagnostics-show-location=")))
4098 {
4099 if (!strcmp (option_value, "once"))
4100 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
4101 else if (!strcmp (option_value, "every-line"))
4102 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE);
4103 else
4104 error ("Unrecognized option `%s'", arg - 2);
4105 }
4106 else if (!strcmp (arg, "no-stack-limit"))
4107 stack_limit_rtx = NULL_RTX;
4108 else if (!strcmp (arg, "preprocessed"))
4109 /* Recognise this switch but do nothing. This prevents warnings
4110 about an unrecognized switch if cpplib has not been linked in. */
4111 ;
4112 else
4113 return 0;
4114
4115 return 1;
4116 }
4117
4118 /* Parse a -W... comand line switch. ARG is the value after the -W.
4119 It is safe to access 'ARG - 2' to generate the full switch name.
4120 Return the number of strings consumed. */
4121
4122 static int
4123 decode_W_option (arg)
4124 const char *arg;
4125 {
4126 const char *option_value = NULL;
4127 int j;
4128
4129 /* Search for the option in the table of binary W options. */
4130
4131 for (j = ARRAY_SIZE (W_options); j--;)
4132 {
4133 if (!strcmp (arg, W_options[j].string))
4134 {
4135 *W_options[j].variable = W_options[j].on_value;
4136 return 1;
4137 }
4138
4139 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4140 && ! strcmp (arg + 3, W_options[j].string))
4141 {
4142 *W_options[j].variable = ! W_options[j].on_value;
4143 return 1;
4144 }
4145 }
4146
4147 if ((option_value = skip_leading_substring (arg, "id-clash-")))
4148 {
4149 id_clash_len = read_integral_parameter (option_value, arg - 2, -1);
4150
4151 if (id_clash_len != -1)
4152 warn_id_clash = 1;
4153 }
4154 else if ((option_value = skip_leading_substring (arg, "larger-than-")))
4155 {
4156 larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
4157
4158 if (larger_than_size != -1)
4159 warn_larger_than = 1;
4160 }
4161 else if (!strcmp (arg, "unused"))
4162 {
4163 set_Wunused (1);
4164 }
4165 else if (!strcmp (arg, "no-unused"))
4166 {
4167 set_Wunused (0);
4168 }
4169 else
4170 return 0;
4171
4172 return 1;
4173 }
4174
4175 /* Parse a -g... comand line switch. ARG is the value after the -g.
4176 It is safe to access 'ARG - 2' to generate the full switch name.
4177 Return the number of strings consumed. */
4178
4179 static int
4180 decode_g_option (arg)
4181 const char *arg;
4182 {
4183 unsigned level;
4184 /* A lot of code assumes write_symbols == NO_DEBUG if the
4185 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4186 of what debugging type has been selected). This records the
4187 selected type. It is an error to specify more than one
4188 debugging type. */
4189 static enum debug_info_type selected_debug_type = NO_DEBUG;
4190 /* Non-zero if debugging format has been explicitly set.
4191 -g and -ggdb don't explicitly set the debugging format so
4192 -gdwarf -g3 is equivalent to -gdwarf3. */
4193 static int type_explicitly_set_p = 0;
4194 /* Indexed by enum debug_info_type. */
4195 static const char *debug_type_names[] =
4196 {
4197 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4198 };
4199
4200 /* The maximum admissible debug level value. */
4201 static const unsigned max_debug_level = 3;
4202
4203 /* Look up ARG in the table. */
4204 for (da = debug_args; da->arg; da++)
4205 {
4206 const int da_len = strlen (da->arg);
4207
4208 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4209 {
4210 enum debug_info_type type = da->debug_type;
4211 const char *p = arg + da_len;
4212
4213 if (*p && (*p < '0' || *p > '9'))
4214 continue;
4215
4216 /* A debug flag without a level defaults to level 2.
4217 Note we do not want to call read_integral_parameter
4218 for that case since it will call atoi which
4219 will return zero.
4220
4221 ??? We may want to generalize the interface to
4222 read_integral_parameter to better handle this case
4223 if this case shows up often. */
4224 if (*p)
4225 level = read_integral_parameter (p, 0, max_debug_level + 1);
4226 else
4227 level = 2;
4228
4229 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4230 {
4231 error ("use -gdwarf -g%d for DWARF v1, level %d",
4232 level, level);
4233 if (level == 2)
4234 error ("use -gdwarf-2 for DWARF v2");
4235 }
4236
4237 if (level > max_debug_level)
4238 {
4239 warning ("\
4240 ignoring option `%s' due to invalid debug level specification",
4241 arg - 2);
4242 level = debug_info_level;
4243 }
4244
4245 if (type == NO_DEBUG)
4246 {
4247 type = PREFERRED_DEBUGGING_TYPE;
4248
4249 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4250 {
4251 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4252 type = DWARF2_DEBUG;
4253 #else
4254 #ifdef DBX_DEBUGGING_INFO
4255 type = DBX_DEBUG;
4256 #endif
4257 #endif
4258 }
4259 }
4260
4261 if (type == NO_DEBUG)
4262 warning ("`%s': unknown or unsupported -g option", arg - 2);
4263
4264 /* Does it conflict with an already selected type? */
4265 if (type_explicitly_set_p
4266 /* -g/-ggdb don't conflict with anything. */
4267 && da->debug_type != NO_DEBUG
4268 && type != selected_debug_type)
4269 warning ("`%s' ignored, conflicts with `-g%s'",
4270 arg - 2, debug_type_names[(int) selected_debug_type]);
4271 else
4272 {
4273 /* If the format has already been set, -g/-ggdb
4274 only change the debug level. */
4275 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4276 /* Don't change debugging type. */
4277 ;
4278 else
4279 {
4280 selected_debug_type = type;
4281 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4282 }
4283
4284 write_symbols = (level == 0
4285 ? NO_DEBUG
4286 : selected_debug_type);
4287 use_gnu_debug_info_extensions = da->use_extensions_p;
4288 debug_info_level = (enum debug_info_level) level;
4289 }
4290
4291 break;
4292 }
4293 }
4294
4295 if (! da->arg)
4296 return 0;
4297
4298 return 1;
4299 }
4300
4301 /* Decode the first argument in the argv as a language-independent option.
4302 Return the number of strings consumed. */
4303
4304 static unsigned int
4305 independent_decode_option (argc, argv)
4306 int argc;
4307 char **argv;
4308 {
4309 char *arg = argv[0];
4310
4311 if (arg[0] != '-' || arg[1] == 0)
4312 {
4313 if (arg[0] == '+')
4314 return 0;
4315
4316 filename = arg;
4317
4318 return 1;
4319 }
4320
4321 arg++;
4322
4323 if (!strcmp (arg, "-help"))
4324 {
4325 display_help ();
4326 exit (0);
4327 }
4328
4329 if (!strcmp (arg, "-target-help"))
4330 {
4331 display_target_options ();
4332 exit (0);
4333 }
4334
4335 if (*arg == 'Y')
4336 arg++;
4337
4338 switch (*arg)
4339 {
4340 default:
4341 return 0;
4342
4343 case 'O':
4344 /* Already been treated in main (). Do nothing. */
4345 break;
4346
4347 case 'm':
4348 set_target_switch (arg + 1);
4349 break;
4350
4351 case 'f':
4352 return decode_f_option (arg + 1);
4353
4354 case 'g':
4355 return decode_g_option (arg + 1);
4356
4357 case 'd':
4358 if (!strcmp (arg, "dumpbase"))
4359 {
4360 if (argc == 1)
4361 return 0;
4362
4363 dump_base_name = argv[1];
4364 return 2;
4365 }
4366 else
4367 decode_d_option (arg + 1);
4368 break;
4369
4370 case 'p':
4371 if (!strcmp (arg, "pedantic"))
4372 pedantic = 1;
4373 else if (!strcmp (arg, "pedantic-errors"))
4374 flag_pedantic_errors = pedantic = 1;
4375 else if (arg[1] == 0)
4376 profile_flag = 1;
4377 else
4378 return 0;
4379 break;
4380
4381 case 'q':
4382 if (!strcmp (arg, "quiet"))
4383 quiet_flag = 1;
4384 else
4385 return 0;
4386 break;
4387
4388 case 'v':
4389 if (!strcmp (arg, "version"))
4390 version_flag = 1;
4391 else
4392 return 0;
4393 break;
4394
4395 case 'w':
4396 if (arg[1] == 0)
4397 inhibit_warnings = 1;
4398 else
4399 return 0;
4400 break;
4401
4402 case 'W':
4403 if (arg[1] == 0)
4404 {
4405 extra_warnings = 1;
4406 /* We save the value of warn_uninitialized, since if they put
4407 -Wuninitialized on the command line, we need to generate a
4408 warning about not using it without also specifying -O. */
4409 if (warn_uninitialized != 1)
4410 warn_uninitialized = 2;
4411 }
4412 else
4413 return decode_W_option (arg + 1);
4414 break;
4415
4416 case 'a':
4417 if (arg[1] == 0)
4418 {
4419 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4420 warning ("`-a' option (basic block profile) not supported");
4421 #else
4422 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4423 #endif
4424 }
4425 else if (!strcmp (arg, "ax"))
4426 {
4427 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4428 warning ("`-ax' option (jump profiling) not supported");
4429 #else
4430 profile_block_flag = (!profile_block_flag
4431 || profile_block_flag == 2) ? 2 : 3;
4432 #endif
4433 }
4434 else if (!strncmp (arg, "aux-info", 8))
4435 {
4436 flag_gen_aux_info = 1;
4437 if (arg[8] == '\0')
4438 {
4439 if (argc == 1)
4440 return 0;
4441
4442 aux_info_file_name = argv[1];
4443 return 2;
4444 }
4445 else
4446 aux_info_file_name = arg + 8;
4447 }
4448 else
4449 return 0;
4450 break;
4451
4452 case 'o':
4453 if (arg[1] == 0)
4454 {
4455 if (argc == 1)
4456 return 0;
4457
4458 asm_file_name = argv[1];
4459 return 2;
4460 }
4461 return 0;
4462
4463 case 'G':
4464 {
4465 int g_switch_val;
4466 int return_val;
4467
4468 if (arg[1] == 0)
4469 {
4470 if (argc == 1)
4471 return 0;
4472
4473 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4474 return_val = 2;
4475 }
4476 else
4477 {
4478 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4479 return_val = 1;
4480 }
4481
4482 if (g_switch_val == -1)
4483 return_val = 0;
4484 else
4485 {
4486 g_switch_set = TRUE;
4487 g_switch_value = g_switch_val;
4488 }
4489
4490 return return_val;
4491 }
4492 }
4493
4494 return 1;
4495 }
4496 \f
4497 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4498 Exit code is 35 if can't open files, 34 if fatal error,
4499 33 if had nonfatal errors, else success. */
4500
4501 extern int main PARAMS ((int, char **));
4502
4503 int
4504 main (argc, argv)
4505 int argc;
4506 char **argv;
4507 {
4508 register int i;
4509 char *p;
4510
4511 /* save in case md file wants to emit args as a comment. */
4512 save_argc = argc;
4513 save_argv = argv;
4514
4515 p = argv[0] + strlen (argv[0]);
4516 while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
4517 --p;
4518 progname = p;
4519
4520 #ifdef HAVE_LC_MESSAGES
4521 setlocale (LC_MESSAGES, "");
4522 #endif
4523 (void) bindtextdomain (PACKAGE, localedir);
4524 (void) textdomain (PACKAGE);
4525
4526 /* Install handler for SIGFPE, which may be received while we do
4527 compile-time floating point arithmetic. */
4528 signal (SIGFPE, float_signal);
4529
4530 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4531 #ifdef SIGSEGV
4532 signal (SIGSEGV, crash_signal);
4533 #endif
4534 #ifdef SIGILL
4535 signal (SIGILL, crash_signal);
4536 #endif
4537 #ifdef SIGBUS
4538 signal (SIGBUS, crash_signal);
4539 #endif
4540 #ifdef SIGABRT
4541 signal (SIGABRT, crash_signal);
4542 #endif
4543 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4544 signal (SIGIOT, crash_signal);
4545 #endif
4546
4547 decl_printable_name = decl_name;
4548 lang_expand_expr = (lang_expand_expr_t) do_abort;
4549
4550 /* Initialize whether `char' is signed. */
4551 flag_signed_char = DEFAULT_SIGNED_CHAR;
4552 #ifdef DEFAULT_SHORT_ENUMS
4553 /* Initialize how much space enums occupy, by default. */
4554 flag_short_enums = DEFAULT_SHORT_ENUMS;
4555 #endif
4556
4557 /* Initialize the garbage-collector. */
4558 init_ggc ();
4559 ggc_add_root (&input_file_stack, 1, sizeof input_file_stack,
4560 mark_file_stack);
4561 ggc_add_rtx_root (&stack_limit_rtx, 1);
4562 ggc_add_tree_root (&current_function_decl, 1);
4563 ggc_add_tree_root (&current_function_func_begin_label, 1);
4564
4565 /* Initialize the diagnostics reporting machinery. */
4566 initialize_diagnostics ();
4567
4568 /* Perform language-specific options intialization. */
4569 lang_init_options ();
4570
4571 /* Scan to see what optimization level has been specified. That will
4572 determine the default value of many flags. */
4573 for (i = 1; i < argc; i++)
4574 {
4575 if (!strcmp (argv[i], "-O"))
4576 {
4577 optimize = 1;
4578 optimize_size = 0;
4579 }
4580 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4581 {
4582 /* Handle -Os, -O2, -O3, -O69, ... */
4583 char *p = &argv[i][2];
4584
4585 if ((p[0] == 's') && (p[1] == 0))
4586 {
4587 optimize_size = 1;
4588
4589 /* Optimizing for size forces optimize to be 2. */
4590 optimize = 2;
4591 }
4592 else
4593 {
4594 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4595 if (optimize_val != -1)
4596 {
4597 optimize = optimize_val;
4598 optimize_size = 0;
4599 }
4600 }
4601 }
4602 }
4603
4604 if (optimize >= 1)
4605 {
4606 flag_defer_pop = 1;
4607 flag_thread_jumps = 1;
4608 #ifdef DELAY_SLOTS
4609 flag_delayed_branch = 1;
4610 #endif
4611 #ifdef CAN_DEBUG_WITHOUT_FP
4612 flag_omit_frame_pointer = 1;
4613 #endif
4614 }
4615
4616 if (optimize >= 2)
4617 {
4618 flag_optimize_sibling_calls = 1;
4619 flag_cse_follow_jumps = 1;
4620 flag_cse_skip_blocks = 1;
4621 flag_gcse = 1;
4622 flag_expensive_optimizations = 1;
4623 flag_strength_reduce = 1;
4624 flag_rerun_cse_after_loop = 1;
4625 flag_rerun_loop_opt = 1;
4626 flag_caller_saves = 1;
4627 flag_force_mem = 1;
4628 flag_peephole2 = 1;
4629 #ifdef INSN_SCHEDULING
4630 flag_schedule_insns = 1;
4631 flag_schedule_insns_after_reload = 1;
4632 #endif
4633 flag_regmove = 1;
4634 flag_strict_aliasing = 1;
4635 flag_delete_null_pointer_checks = 1;
4636 flag_reorder_blocks = 1;
4637 }
4638
4639 if (optimize >= 3)
4640 {
4641 flag_inline_functions = 1;
4642 flag_rename_registers = 1;
4643 }
4644
4645 if (optimize < 2 || optimize_size)
4646 {
4647 align_loops = 1;
4648 align_jumps = 1;
4649 align_labels = 1;
4650 align_functions = 1;
4651 }
4652
4653 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4654 modify it. */
4655 target_flags = 0;
4656 set_target_switch ("");
4657
4658 /* Unwind tables are always present in an ABI-conformant IA-64
4659 object file, so the default should be ON. */
4660 #ifdef IA64_UNWIND_INFO
4661 flag_unwind_tables = IA64_UNWIND_INFO;
4662 #endif
4663
4664 #ifdef OPTIMIZATION_OPTIONS
4665 /* Allow default optimizations to be specified on a per-machine basis. */
4666 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4667 #endif
4668
4669 /* Initialize register usage now so switches may override. */
4670 init_reg_sets ();
4671
4672 /* Perform normal command line switch decoding. */
4673 for (i = 1; i < argc;)
4674 {
4675 unsigned int lang_processed;
4676 unsigned int indep_processed;
4677
4678 /* Give the language a chance to decode the option for itself. */
4679 lang_processed = lang_decode_option (argc - i, argv + i);
4680
4681 /* Now see if the option also has a language independent meaning.
4682 Some options are both language specific and language independent,
4683 eg --help. */
4684 indep_processed = independent_decode_option (argc - i, argv + i);
4685
4686 if (lang_processed || indep_processed)
4687 i += MAX (lang_processed, indep_processed);
4688 else
4689 {
4690 const char *option = NULL;
4691 const char *lang = NULL;
4692 unsigned int j;
4693
4694 /* It is possible that the command line switch is not valid for the
4695 current language, but it is valid for another language. In order
4696 to be compatible with previous versions of the compiler (which
4697 did not issue an error message in this case) we check for this
4698 possibility here. If we do find a match, then if extra_warnings
4699 is set we generate a warning message, otherwise we will just
4700 ignore the option. */
4701 for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4702 {
4703 option = documented_lang_options[j].option;
4704
4705 if (option == NULL)
4706 lang = documented_lang_options[j].description;
4707 else if (! strncmp (argv[i], option, strlen (option)))
4708 break;
4709 }
4710
4711 if (j != ARRAY_SIZE (documented_lang_options))
4712 {
4713 if (extra_warnings)
4714 {
4715 warning ("Ignoring command line option '%s'", argv[i]);
4716 if (lang)
4717 warning
4718 ("(It is valid for %s but not the selected language)",
4719 lang);
4720 }
4721 }
4722 else if (argv[i][0] == '-' && argv[i][1] == 'g')
4723 warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
4724 else
4725 error ("Unrecognized option `%s'", argv[i]);
4726
4727 i++;
4728 }
4729 }
4730
4731 /* Reflect any language-specific diagnostic option setting. */
4732 reshape_diagnostic_buffer ();
4733
4734 /* Checker uses the frame pointer. */
4735 if (flag_check_memory_usage)
4736 flag_omit_frame_pointer = 0;
4737
4738 if (optimize == 0)
4739 {
4740 /* Inlining does not work if not optimizing,
4741 so force it not to be done. */
4742 flag_no_inline = 1;
4743 warn_inline = 0;
4744
4745 /* The c_decode_option and lang_decode_option functions set
4746 this to `2' if -Wall is used, so we can avoid giving out
4747 lots of errors for people who don't realize what -Wall does. */
4748 if (warn_uninitialized == 1)
4749 warning ("-Wuninitialized is not supported without -O");
4750 }
4751
4752 #ifdef OVERRIDE_OPTIONS
4753 /* Some machines may reject certain combinations of options. */
4754 OVERRIDE_OPTIONS;
4755 #endif
4756
4757 if (exceptions_via_longjmp == 2)
4758 {
4759 #ifdef DWARF2_UNWIND_INFO
4760 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4761 #else
4762 #ifdef IA64_UNWIND_INFO
4763 exceptions_via_longjmp = ! IA64_UNWIND_INFO;
4764 #else
4765 exceptions_via_longjmp = 1;
4766 #endif
4767 #endif
4768 }
4769
4770 /* Since each function gets its own handler data, we can't support the
4771 new model currently, since it depend on a specific rethrow label
4772 which is declared at the front of the table, and we can only
4773 have one such symbol in a file. */
4774 #ifdef IA64_UNWIND_INFO
4775 flag_new_exceptions = 0;
4776 #endif
4777
4778 /* Set up the align_*_log variables, defaulting them to 1 if they
4779 were still unset. */
4780 if (align_loops <= 0) align_loops = 1;
4781 align_loops_log = floor_log2 (align_loops * 2 - 1);
4782 if (align_jumps <= 0) align_jumps = 1;
4783 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4784 if (align_labels <= 0) align_labels = 1;
4785 align_labels_log = floor_log2 (align_labels * 2 - 1);
4786 if (align_functions <= 0) align_functions = 1;
4787 align_functions_log = floor_log2 (align_functions * 2 - 1);
4788
4789 if (profile_block_flag == 3)
4790 {
4791 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4792 profile_block_flag = 2;
4793 }
4794
4795 /* Unrolling all loops implies that standard loop unrolling must also
4796 be done. */
4797 if (flag_unroll_all_loops)
4798 flag_unroll_loops = 1;
4799 /* Loop unrolling requires that strength_reduction be on also. Silently
4800 turn on strength reduction here if it isn't already on. Also, the loop
4801 unrolling code assumes that cse will be run after loop, so that must
4802 be turned on also. */
4803 if (flag_unroll_loops)
4804 {
4805 flag_strength_reduce = 1;
4806 flag_rerun_cse_after_loop = 1;
4807 }
4808
4809 /* Warn about options that are not supported on this machine. */
4810 #ifndef INSN_SCHEDULING
4811 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4812 warning ("instruction scheduling not supported on this target machine");
4813 #endif
4814 #ifndef DELAY_SLOTS
4815 if (flag_delayed_branch)
4816 warning ("this target machine does not have delayed branches");
4817 #endif
4818
4819 user_label_prefix = USER_LABEL_PREFIX;
4820 if (flag_leading_underscore != -1)
4821 {
4822 /* If the default prefix is more complicated than "" or "_",
4823 issue a warning and ignore this option. */
4824 if (user_label_prefix[0] == 0 ||
4825 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4826 {
4827 user_label_prefix = flag_leading_underscore ? "_" : "";
4828 }
4829 else
4830 warning ("-f%sleading-underscore not supported on this target machine",
4831 flag_leading_underscore ? "" : "no-");
4832 }
4833
4834 /* If we are in verbose mode, write out the version and maybe all the
4835 option flags in use. */
4836 if (version_flag)
4837 {
4838 print_version (stderr, "");
4839 if (! quiet_flag)
4840 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4841 }
4842
4843 compile_file (filename);
4844
4845 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
4846 if (flag_print_mem)
4847 {
4848 char *lim = (char *) sbrk (0);
4849
4850 fnotice (stderr, "Data size %ld.\n", (long) (lim - (char *) &environ));
4851 fflush (stderr);
4852
4853 #ifndef __MSDOS__
4854 #ifdef USG
4855 system ("ps -l 1>&2");
4856 #else /* not USG */
4857 system ("ps v");
4858 #endif /* not USG */
4859 #endif
4860 }
4861 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
4862
4863 if (errorcount)
4864 return (FATAL_EXIT_CODE);
4865 if (sorrycount)
4866 return (FATAL_EXIT_CODE);
4867 return (SUCCESS_EXIT_CODE);
4868 }
4869 \f
4870 /* Decode -m switches. */
4871 /* Decode the switch -mNAME. */
4872
4873 static void
4874 set_target_switch (name)
4875 const char *name;
4876 {
4877 register size_t j;
4878 int valid_target_option = 0;
4879
4880 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4881 if (!strcmp (target_switches[j].name, name))
4882 {
4883 if (target_switches[j].value < 0)
4884 target_flags &= ~-target_switches[j].value;
4885 else
4886 target_flags |= target_switches[j].value;
4887 valid_target_option = 1;
4888 }
4889
4890 #ifdef TARGET_OPTIONS
4891 if (!valid_target_option)
4892 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4893 {
4894 int len = strlen (target_options[j].prefix);
4895 if (!strncmp (target_options[j].prefix, name, len))
4896 {
4897 *target_options[j].variable = name + len;
4898 valid_target_option = 1;
4899 }
4900 }
4901 #endif
4902
4903 if (!valid_target_option)
4904 error ("Invalid option `%s'", name);
4905 }
4906 \f
4907 /* Print version information to FILE.
4908 Each line begins with INDENT (for the case where FILE is the
4909 assembler output file). */
4910
4911 static void
4912 print_version (file, indent)
4913 FILE *file;
4914 const char *indent;
4915 {
4916 #ifndef __VERSION__
4917 #define __VERSION__ "[?]"
4918 #endif
4919 fnotice (file,
4920 #ifdef __GNUC__
4921 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
4922 #else
4923 "%s%s%s version %s (%s) compiled by CC.\n"
4924 #endif
4925 , indent, *indent != 0 ? " " : "",
4926 language_string, version_string, TARGET_NAME, __VERSION__);
4927 }
4928
4929 /* Print an option value and return the adjusted position in the line.
4930 ??? We don't handle error returns from fprintf (disk full); presumably
4931 other code will catch a disk full though. */
4932
4933 static int
4934 print_single_switch (file, pos, max, indent, sep, term, type, name)
4935 FILE *file;
4936 int pos, max;
4937 const char *indent, *sep, *term, *type, *name;
4938 {
4939 /* The ultrix fprintf returns 0 on success, so compute the result we want
4940 here since we need it for the following test. */
4941 int len = strlen (sep) + strlen (type) + strlen (name);
4942
4943 if (pos != 0
4944 && pos + len > max)
4945 {
4946 fprintf (file, "%s", term);
4947 pos = 0;
4948 }
4949 if (pos == 0)
4950 {
4951 fprintf (file, "%s", indent);
4952 pos = strlen (indent);
4953 }
4954 fprintf (file, "%s%s%s", sep, type, name);
4955 pos += len;
4956 return pos;
4957 }
4958
4959 /* Print active target switches to FILE.
4960 POS is the current cursor position and MAX is the size of a "line".
4961 Each line begins with INDENT and ends with TERM.
4962 Each switch is separated from the next by SEP. */
4963
4964 static void
4965 print_switch_values (file, pos, max, indent, sep, term)
4966 FILE *file;
4967 int pos, max;
4968 const char *indent, *sep, *term;
4969 {
4970 size_t j;
4971 char **p;
4972
4973 /* Print the options as passed. */
4974
4975 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4976 _("options passed: "), "");
4977
4978 for (p = &save_argv[1]; *p != NULL; p++)
4979 if (**p == '-')
4980 {
4981 /* Ignore these. */
4982 if (strcmp (*p, "-o") == 0)
4983 {
4984 if (p[1] != NULL)
4985 p++;
4986 continue;
4987 }
4988 if (strcmp (*p, "-quiet") == 0)
4989 continue;
4990 if (strcmp (*p, "-version") == 0)
4991 continue;
4992 if ((*p)[1] == 'd')
4993 continue;
4994
4995 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4996 }
4997 if (pos > 0)
4998 fprintf (file, "%s", term);
4999
5000 /* Print the -f and -m options that have been enabled.
5001 We don't handle language specific options but printing argv
5002 should suffice. */
5003
5004 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5005 _("options enabled: "), "");
5006
5007 for (j = 0; j < ARRAY_SIZE (f_options); j++)
5008 if (*f_options[j].variable == f_options[j].on_value)
5009 pos = print_single_switch (file, pos, max, indent, sep, term,
5010 "-f", f_options[j].string);
5011
5012 /* Print target specific options. */
5013
5014 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
5015 if (target_switches[j].name[0] != '\0'
5016 && target_switches[j].value > 0
5017 && ((target_switches[j].value & target_flags)
5018 == target_switches[j].value))
5019 {
5020 pos = print_single_switch (file, pos, max, indent, sep, term,
5021 "-m", target_switches[j].name);
5022 }
5023
5024 #ifdef TARGET_OPTIONS
5025 for (j = 0; j < ARRAY_SIZE (target_options); j++)
5026 if (*target_options[j].variable != NULL)
5027 {
5028 char prefix[256];
5029 sprintf (prefix, "-m%s", target_options[j].prefix);
5030 pos = print_single_switch (file, pos, max, indent, sep, term,
5031 prefix, *target_options[j].variable);
5032 }
5033 #endif
5034
5035 fprintf (file, "%s", term);
5036 }
5037
5038 /* Record the beginning of a new source file, named FILENAME. */
5039
5040 void
5041 debug_start_source_file (filename)
5042 register const char *filename ATTRIBUTE_UNUSED;
5043 {
5044 #ifdef DBX_DEBUGGING_INFO
5045 if (write_symbols == DBX_DEBUG)
5046 dbxout_start_new_source_file (filename);
5047 #endif
5048 #ifdef DWARF_DEBUGGING_INFO
5049 if (debug_info_level == DINFO_LEVEL_VERBOSE
5050 && write_symbols == DWARF_DEBUG)
5051 dwarfout_start_new_source_file (filename);
5052 #endif /* DWARF_DEBUGGING_INFO */
5053 #ifdef DWARF2_DEBUGGING_INFO
5054 if (write_symbols == DWARF2_DEBUG)
5055 dwarf2out_start_source_file (filename);
5056 #endif /* DWARF2_DEBUGGING_INFO */
5057 #ifdef SDB_DEBUGGING_INFO
5058 if (write_symbols == SDB_DEBUG)
5059 sdbout_start_new_source_file (filename);
5060 #endif
5061 }
5062
5063 /* Record the resumption of a source file. LINENO is the line number in
5064 the source file we are returning to. */
5065
5066 void
5067 debug_end_source_file (lineno)
5068 register unsigned lineno ATTRIBUTE_UNUSED;
5069 {
5070 #ifdef DBX_DEBUGGING_INFO
5071 if (write_symbols == DBX_DEBUG)
5072 dbxout_resume_previous_source_file ();
5073 #endif
5074 #ifdef DWARF_DEBUGGING_INFO
5075 if (debug_info_level == DINFO_LEVEL_VERBOSE
5076 && write_symbols == DWARF_DEBUG)
5077 dwarfout_resume_previous_source_file (lineno);
5078 #endif /* DWARF_DEBUGGING_INFO */
5079 #ifdef DWARF2_DEBUGGING_INFO
5080 if (write_symbols == DWARF2_DEBUG)
5081 dwarf2out_end_source_file ();
5082 #endif /* DWARF2_DEBUGGING_INFO */
5083 #ifdef SDB_DEBUGGING_INFO
5084 if (write_symbols == SDB_DEBUG)
5085 sdbout_resume_previous_source_file ();
5086 #endif
5087 }
5088
5089 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5090 the tail part of the directive line, i.e. the part which is past the
5091 initial whitespace, #, whitespace, directive-name, whitespace part. */
5092
5093 void
5094 debug_define (lineno, buffer)
5095 register unsigned lineno ATTRIBUTE_UNUSED;
5096 register char *buffer ATTRIBUTE_UNUSED;
5097 {
5098 #ifdef DWARF_DEBUGGING_INFO
5099 if (debug_info_level == DINFO_LEVEL_VERBOSE
5100 && write_symbols == DWARF_DEBUG)
5101 dwarfout_define (lineno, buffer);
5102 #endif /* DWARF_DEBUGGING_INFO */
5103 #ifdef DWARF2_DEBUGGING_INFO
5104 if (debug_info_level == DINFO_LEVEL_VERBOSE
5105 && write_symbols == DWARF2_DEBUG)
5106 dwarf2out_define (lineno, buffer);
5107 #endif /* DWARF2_DEBUGGING_INFO */
5108 }
5109
5110 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5111 the tail part of the directive line, i.e. the part which is past the
5112 initial whitespace, #, whitespace, directive-name, whitespace part. */
5113
5114 void
5115 debug_undef (lineno, buffer)
5116 register unsigned lineno ATTRIBUTE_UNUSED;
5117 register char *buffer ATTRIBUTE_UNUSED;
5118 {
5119 #ifdef DWARF_DEBUGGING_INFO
5120 if (debug_info_level == DINFO_LEVEL_VERBOSE
5121 && write_symbols == DWARF_DEBUG)
5122 dwarfout_undef (lineno, buffer);
5123 #endif /* DWARF_DEBUGGING_INFO */
5124 #ifdef DWARF2_DEBUGGING_INFO
5125 if (debug_info_level == DINFO_LEVEL_VERBOSE
5126 && write_symbols == DWARF2_DEBUG)
5127 dwarf2out_undef (lineno, buffer);
5128 #endif /* DWARF2_DEBUGGING_INFO */
5129 }
5130
5131 /* Returns nonzero if it is appropriate not to emit any debugging
5132 information for BLOCK, because it doesn't contain any instructions.
5133 This may not be the case for blocks containing nested functions, since
5134 we may actually call such a function even though the BLOCK information
5135 is messed up. */
5136
5137 int
5138 debug_ignore_block (block)
5139 tree block ATTRIBUTE_UNUSED;
5140 {
5141 /* Never delete the BLOCK for the outermost scope
5142 of the function; we can refer to names from
5143 that scope even if the block notes are messed up. */
5144 if (is_body_block (block))
5145 return 0;
5146
5147 #ifdef DWARF2_DEBUGGING_INFO
5148 if (write_symbols == DWARF2_DEBUG)
5149 return dwarf2out_ignore_block (block);
5150 #endif
5151
5152 return 1;
5153 }
This page took 0.240794 seconds and 4 git commands to generate.