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