OSDN Git Service

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