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