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