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