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