OSDN Git Service

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