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