OSDN Git Service

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