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