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