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