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