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