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