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