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