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