OSDN Git Service

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