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