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