OSDN Git Service

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