OSDN Git Service

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