]> gcc.gnu.org Git - gcc.git/blame - gcc/toplev.c
(note_addr_stored): A SET or CLOBBER of a BLKmode MEM means that all
[gcc.git] / gcc / toplev.c
CommitLineData
4291d9c8 1/* Top level of GNU C compiler
16411ea6 2 Copyright (C) 1987, 88, 89, 92, 93, 1994 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
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
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"
e0e2a8da 27#ifdef __STDC__
04fe4385 28#include <stdarg.h>
e0e2a8da 29#else
04fe4385 30#include <varargs.h>
e0e2a8da 31#endif
4291d9c8
RS
32#include <stdio.h>
33#include <signal.h>
34#include <setjmp.h>
eb711c86 35#include <sys/types.h>
ea9182cd 36#include <ctype.h>
4291d9c8
RS
37#include <sys/stat.h>
38
39#ifdef USG
40#undef FLOAT
41#include <sys/param.h>
42/* This is for hpux. It is a real screw. They should change hpux. */
43#undef FLOAT
44#include <sys/times.h>
45#include <time.h> /* Correct for hpux at least. Is it good on other USG? */
46#undef FFS /* Some systems define this in param.h. */
47#else
48#ifndef VMS
49#include <sys/time.h>
50#include <sys/resource.h>
51#endif
52#endif
53
54#include "input.h"
55#include "tree.h"
56/* #include "c-tree.h" */
57#include "rtl.h"
58#include "flags.h"
59#include "insn-attr.h"
d0d4af87 60#include "defaults.h"
f246a305
RS
61
62#ifdef XCOFF_DEBUGGING_INFO
63#include "xcoffout.h"
64#endif
ca695ac9
JB
65
66#include "bytecode.h"
67#include "bc-emit.h"
4291d9c8
RS
68\f
69#ifdef VMS
70/* The extra parameters substantially improve the I/O performance. */
71static FILE *
72VMS_fopen (fname, type)
73 char * fname;
74 char * type;
75{
76 if (strcmp (type, "w") == 0)
77 return fopen (fname, type, "mbc=16", "deq=64", "fop=tef", "shr=nil");
78 return fopen (fname, type, "mbc=16");
79}
80#define fopen VMS_fopen
81#endif
82
83#ifndef DEFAULT_GDB_EXTENSIONS
84#define DEFAULT_GDB_EXTENSIONS 1
85#endif
86
87extern int rtx_equal_function_value_matters;
88
72c8bb7f 89#if ! (defined (VMS) || defined (OS2))
4291d9c8 90extern char **environ;
4d7e336b 91#endif
4291d9c8
RS
92extern char *version_string, *language_string;
93
b0316e35
RS
94/* Carry information from ASM_DECLARE_OBJECT_NAME
95 to ASM_FINISH_DECLARE_OBJECT. */
96
97extern int size_directive_output;
5e10b3cc 98extern tree last_assemble_variable_decl;
b0316e35 99
4291d9c8
RS
100extern void init_lex ();
101extern void init_decl_processing ();
102extern void init_obstacks ();
103extern void init_tree_codes ();
104extern void init_rtl ();
34d0205f 105extern void init_regs ();
4291d9c8
RS
106extern void init_optabs ();
107extern void init_stmt ();
108extern void init_reg_sets ();
109extern void dump_flow_info ();
110extern void dump_sched_info ();
111extern void dump_local_alloc ();
112
113void rest_of_decl_compilation ();
d18225c4
RK
114void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
115void error_with_decl PVPROTO((tree decl, char *s, ...));
116void error_for_asm PVPROTO((rtx insn, char *s, ...));
117void error PVPROTO((char *s, ...));
118void fatal PVPROTO((char *s, ...));
119void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
120void warning_with_decl PVPROTO((tree decl, char *s, ...));
121void warning_for_asm PVPROTO((rtx insn, char *s, ...));
122void warning PVPROTO((char *s, ...));
123void pedwarn PVPROTO((char *s, ...));
124void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
125void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
126void sorry PVPROTO((char *s, ...));
127void really_sorry PVPROTO((char *s, ...));
4291d9c8
RS
128void fancy_abort ();
129#ifndef abort
130void abort ();
131#endif
132void set_target_switch ();
133static void print_switch_values ();
134static char *decl_name ();
135
136/* Name of program invoked, sans directories. */
137
138char *progname;
139
140/* Copy of arguments to main. */
141int save_argc;
142char **save_argv;
143\f
144/* Name of current original source file (what was input to cpp).
145 This comes from each #-command in the actual input. */
146
147char *input_filename;
148
149/* Name of top-level original source file (what was input to cpp).
150 This comes from the #-command at the beginning of the actual input.
151 If there isn't any there, then this is the cc1 input file name. */
152
153char *main_input_filename;
154
155/* Stream for reading from the input file. */
156
157FILE *finput;
158
159/* Current line number in real source file. */
160
161int lineno;
162
163/* Stack of currently pending input files. */
164
165struct file_stack *input_file_stack;
166
167/* Incremented on each change to input_file_stack. */
168int input_file_stack_tick;
169
170/* FUNCTION_DECL for function now being parsed or compiled. */
171
172extern tree current_function_decl;
173
174/* Name to use as base of names for dump output files. */
175
176char *dump_base_name;
177
178/* Bit flags that specify the machine subtype we are compiling for.
179 Bits are tested using macros TARGET_... defined in the tm.h file
180 and set by `-m...' switches. Must be defined in rtlanal.c. */
181
182extern int target_flags;
183
184/* Flags saying which kinds of debugging dump have been requested. */
185
186int rtl_dump = 0;
187int rtl_dump_and_exit = 0;
188int jump_opt_dump = 0;
189int cse_dump = 0;
190int loop_dump = 0;
191int cse2_dump = 0;
192int flow_dump = 0;
193int combine_dump = 0;
194int sched_dump = 0;
195int local_reg_dump = 0;
196int global_reg_dump = 0;
197int sched2_dump = 0;
198int jump2_opt_dump = 0;
199int dbr_sched_dump = 0;
200int flag_print_asm_name = 0;
201int stack_reg_dump = 0;
202
203/* Name for output file of assembly code, specified with -o. */
204
205char *asm_file_name;
206
207/* Value of the -G xx switch, and whether it was passed or not. */
208int g_switch_value;
209int g_switch_set;
210
211/* Type(s) of debugging information we are producing (if any).
212 See flags.h for the definitions of the different possible
213 types of debugging information. */
214enum debug_info_type write_symbols = NO_DEBUG;
215
216/* Level of debugging information we are producing. See flags.h
217 for the definitions of the different possible levels. */
218enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
219
a53d0bcc
RS
220/* Nonzero means use GNU-only extensions in the generated symbolic
221 debugging information. */
222/* Currently, this only has an effect when write_symbols is set to
223 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
224int use_gnu_debug_info_extensions = 0;
4291d9c8
RS
225
226/* Nonzero means do optimizations. -O.
227 Particular numeric values stand for particular amounts of optimization;
228 thus, -O2 stores 2 here. However, the optimizations beyond the basic
229 ones are not controlled directly by this variable. Instead, they are
230 controlled by individual `flag_...' variables that are defaulted
231 based on this variable. */
232
233int optimize = 0;
234
235/* Number of error messages and warning messages so far. */
236
237int errorcount = 0;
238int warningcount = 0;
239int sorrycount = 0;
240
ca695ac9
JB
241/* Flag to output bytecode instead of native assembler */
242int output_bytecode = 0;
243
4291d9c8
RS
244/* Pointer to function to compute the name to use to print a declaration. */
245
246char *(*decl_printable_name) ();
247
248/* Pointer to function to compute rtl for a language-specific tree code. */
249
250struct rtx_def *(*lang_expand_expr) ();
251
2b599527
RS
252/* Pointer to function to finish handling an incomplete decl at the
253 end of compilation. */
254
255void (*incomplete_decl_finalize_hook) () = 0;
256
4291d9c8
RS
257/* Nonzero if generating code to do profiling. */
258
259int profile_flag = 0;
260
261/* Nonzero if generating code to do profiling on a line-by-line basis. */
262
263int profile_block_flag;
264
265/* Nonzero for -pedantic switch: warn about anything
266 that standard spec forbids. */
267
268int pedantic = 0;
269
270/* Temporarily suppress certain warnings.
271 This is set while reading code from a system header file. */
272
273int in_system_header = 0;
274
275/* Nonzero means do stupid register allocation.
276 Currently, this is 1 if `optimize' is 0. */
277
278int obey_regdecls = 0;
279
280/* Don't print functions as they are compiled and don't print
281 times taken by the various passes. -quiet. */
282
283int quiet_flag = 0;
284\f
285/* -f flags. */
286
287/* Nonzero means `char' should be signed. */
288
289int flag_signed_char;
290
291/* Nonzero means give an enum type only as many bytes as it needs. */
292
293int flag_short_enums;
294
295/* Nonzero for -fcaller-saves: allocate values in regs that need to
296 be saved across function calls, if that produces overall better code.
297 Optional now, so people can test it. */
298
299#ifdef DEFAULT_CALLER_SAVES
300int flag_caller_saves = 1;
301#else
302int flag_caller_saves = 0;
303#endif
304
958ec8ca
JW
305/* Nonzero if structures and unions should be returned in memory.
306
307 This should only be defined if compatibility with another compiler or
308 with an ABI is needed, because it results in slower code. */
309
310#ifndef DEFAULT_PCC_STRUCT_RETURN
311#define DEFAULT_PCC_STRUCT_RETURN 1
312#endif
313
4291d9c8
RS
314/* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
315
958ec8ca 316int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
4291d9c8
RS
317
318/* Nonzero for -fforce-mem: load memory value into a register
319 before arithmetic on it. This makes better cse but slower compilation. */
320
321int flag_force_mem = 0;
322
323/* Nonzero for -fforce-addr: load memory address into a register before
324 reference to memory. This makes better cse but slower compilation. */
325
326int flag_force_addr = 0;
327
328/* Nonzero for -fdefer-pop: don't pop args after each function call;
329 instead save them up to pop many calls' args with one insns. */
330
6731a3e3 331int flag_defer_pop = 0;
4291d9c8
RS
332
333/* Nonzero for -ffloat-store: don't allocate floats and doubles
334 in extended-precision registers. */
335
336int flag_float_store = 0;
337
338/* Nonzero for -fcse-follow-jumps:
339 have cse follow jumps to do a more extensive job. */
340
341int flag_cse_follow_jumps;
342
8b3686ed
RK
343/* Nonzero for -fcse-skip-blocks:
344 have cse follow a branch around a block. */
345int flag_cse_skip_blocks;
346
4291d9c8
RS
347/* Nonzero for -fexpensive-optimizations:
348 perform miscellaneous relatively-expensive optimizations. */
349int flag_expensive_optimizations;
350
351/* Nonzero for -fthread-jumps:
352 have jump optimize output of loop. */
353
354int flag_thread_jumps;
355
356/* Nonzero enables strength-reduction in loop.c. */
357
358int flag_strength_reduce = 0;
359
360/* Nonzero enables loop unrolling in unroll.c. Only loops for which the
361 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
362 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
363 unrolled. */
364
365int flag_unroll_loops;
366
367/* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
368 This is generally not a win. */
369
370int flag_unroll_all_loops;
371
372/* Nonzero for -fwritable-strings:
373 store string constants in data segment and don't uniquize them. */
374
375int flag_writable_strings = 0;
376
377/* Nonzero means don't put addresses of constant functions in registers.
378 Used for compiling the Unix kernel, where strange substitutions are
379 done on the assembly output. */
380
381int flag_no_function_cse = 0;
382
383/* Nonzero for -fomit-frame-pointer:
384 don't make a frame pointer in simple functions that don't require one. */
385
386int flag_omit_frame_pointer = 0;
387
388/* Nonzero to inhibit use of define_optimization peephole opts. */
389
390int flag_no_peephole = 0;
391
43855b28
JL
392/* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
393 operations in the interest of optimization. For example it allows
394 GCC to assume arguments to sqrt are nonnegative numbers, allowing
395 faster code for sqrt to be generated. */
396
397int flag_fast_math = 0;
398
4291d9c8
RS
399/* Nonzero means all references through pointers are volatile. */
400
401int flag_volatile;
c6e75897
RS
402
403/* Nonzero means treat all global and extern variables as global. */
404
38d4d0c2 405int flag_volatile_global;
4291d9c8
RS
406
407/* Nonzero means just do syntax checking; don't output anything. */
408
409int flag_syntax_only = 0;
410
411/* Nonzero means to rerun cse after loop optimization. This increases
412 compilation time about 20% and picks up a few more common expressions. */
413
414static int flag_rerun_cse_after_loop;
415
416/* Nonzero for -finline-functions: ok to inline functions that look like
417 good inline candidates. */
418
419int flag_inline_functions;
420
421/* Nonzero for -fkeep-inline-functions: even if we make a function
ac2a9454 422 go inline everywhere, keep its definition around for debugging
4291d9c8
RS
423 purposes. */
424
425int flag_keep_inline_functions;
426
427/* Nonzero means that functions declared `inline' will be treated
428 as `static'. Prevents generation of zillions of copies of unused
429 static inline functions; instead, `inlines' are written out
430 only when actually used. Used in conjunction with -g. Also
431 does the right thing with #pragma interface. */
432
433int flag_no_inline;
434
435/* Nonzero means we should be saving declaration info into a .X file. */
436
437int flag_gen_aux_info = 0;
438
f246a305
RS
439/* Specified name of aux-info file. */
440
441static char *aux_info_file_name;
442
4291d9c8
RS
443/* Nonzero means make the text shared if supported. */
444
445int flag_shared_data;
446
447/* Nonzero means schedule into delayed branch slots if supported. */
448
449int flag_delayed_branch;
450
5dab5552
MS
451/* Nonzero means to run cleanups after CALL_EXPRs. */
452
453int flag_short_temps;
454
4291d9c8
RS
455/* Nonzero if we are compiling pure (sharable) code.
456 Value is 1 if we are doing reasonable (i.e. simple
457 offset into offset table) pic. Value is 2 if we can
458 only perform register offsets. */
459
460int flag_pic;
461
0382002b 462/* Nonzero means place uninitialized global data in the bss section. */
4291d9c8
RS
463
464int flag_no_common;
465
466/* Nonzero means pretend it is OK to examine bits of target floats,
467 even if that isn't true. The resulting code will have incorrect constants,
468 but the same series of instructions that the native compiler would make. */
469
470int flag_pretend_float;
471
472/* Nonzero means change certain warnings into errors.
473 Usually these are warnings about failure to conform to some standard. */
474
475int flag_pedantic_errors = 0;
476
477/* flag_schedule_insns means schedule insns within basic blocks (before
478 local_alloc).
479 flag_schedule_insns_after_reload means schedule insns after
480 global_alloc. */
481
482int flag_schedule_insns = 0;
483int flag_schedule_insns_after_reload = 0;
484
485/* -finhibit-size-directive inhibits output of .size for ELF.
486 This is used only for compiling crtstuff.c,
487 and it may be extended to other effects
488 needed for crtstuff.c on other systems. */
489int flag_inhibit_size_directive = 0;
490
9a631e8e
RS
491/* -fverbose-asm causes extra commentary information to be produced in
492 the generated assembly code (to make it more readable). This option
493 is generally only of use to those who actually need to read the
494 generated assembly code (perhaps while debugging the compiler itself). */
495
496int flag_verbose_asm = 0;
497
4291d9c8 498/* -fgnu-linker specifies use of the GNU linker for initializations.
d68c507d
RS
499 (Or, more generally, a linker that handles initializations.)
500 -fno-gnu-linker says that collect2 will be used. */
501#ifdef USE_COLLECT2
502int flag_gnu_linker = 0;
503#else
4291d9c8 504int flag_gnu_linker = 1;
d68c507d 505#endif
4291d9c8
RS
506
507/* Table of language-independent -f options.
508 STRING is the option name. VARIABLE is the address of the variable.
509 ON_VALUE is the value to store in VARIABLE
510 if `-fSTRING' is seen as an option.
511 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
512
513struct { char *string; int *variable; int on_value;} f_options[] =
514{
515 {"float-store", &flag_float_store, 1},
516 {"volatile", &flag_volatile, 1},
38d4d0c2 517 {"volatile-global", &flag_volatile_global, 1},
4291d9c8
RS
518 {"defer-pop", &flag_defer_pop, 1},
519 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
520 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
8b3686ed 521 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
4291d9c8
RS
522 {"expensive-optimizations", &flag_expensive_optimizations, 1},
523 {"thread-jumps", &flag_thread_jumps, 1},
524 {"strength-reduce", &flag_strength_reduce, 1},
525 {"unroll-loops", &flag_unroll_loops, 1},
526 {"unroll-all-loops", &flag_unroll_all_loops, 1},
527 {"writable-strings", &flag_writable_strings, 1},
528 {"peephole", &flag_no_peephole, 0},
529 {"force-mem", &flag_force_mem, 1},
530 {"force-addr", &flag_force_addr, 1},
531 {"function-cse", &flag_no_function_cse, 0},
532 {"inline-functions", &flag_inline_functions, 1},
533 {"keep-inline-functions", &flag_keep_inline_functions, 1},
534 {"inline", &flag_no_inline, 0},
535 {"syntax-only", &flag_syntax_only, 1},
4291d9c8
RS
536 {"shared-data", &flag_shared_data, 1},
537 {"caller-saves", &flag_caller_saves, 1},
538 {"pcc-struct-return", &flag_pcc_struct_return, 1},
958ec8ca 539 {"reg-struct-return", &flag_pcc_struct_return, 0},
4291d9c8
RS
540 {"delayed-branch", &flag_delayed_branch, 1},
541 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
542 {"pretend-float", &flag_pretend_float, 1},
543 {"schedule-insns", &flag_schedule_insns, 1},
544 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
545 {"pic", &flag_pic, 1},
546 {"PIC", &flag_pic, 2},
43855b28 547 {"fast-math", &flag_fast_math, 1},
4291d9c8
RS
548 {"common", &flag_no_common, 0},
549 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
9a631e8e 550 {"verbose-asm", &flag_verbose_asm, 1},
422e2ed3 551 {"gnu-linker", &flag_gnu_linker, 1},
ca695ac9 552 {"bytecode", &output_bytecode, 1}
4291d9c8 553};
b99933c7
RS
554
555/* Table of language-specific options. */
556
557char *lang_options[] =
558{
4200c8de 559 "-ansi",
8305445b 560 "-fallow-single-precision",
4200c8de 561
b99933c7
RS
562 "-fsigned-bitfields",
563 "-funsigned-bitfields",
564 "-fno-signed-bitfields",
565 "-fno-unsigned-bitfields",
4200c8de
RK
566 "-fsigned-char",
567 "-funsigned-char",
568 "-fno-signed-char",
569 "-fno-unsigned-char",
570
571 "-ftraditional",
572 "-traditional",
573 "-fnotraditional",
574 "-fno-traditional",
575
b99933c7
RS
576 "-fasm",
577 "-fno-asm",
578 "-fbuiltin",
579 "-fno-builtin",
4200c8de
RK
580 "-fcond-mismatch",
581 "-fno-cond-mismatch",
c7daad38 582 "-fdollars-in-identifiers",
57f0a224 583 "-fno-dollars-in-identifiers",
4200c8de
RK
584 "-fident",
585 "-fno-ident",
586 "-fshort-double",
587 "-fno-short-double",
588 "-fshort-enums",
589 "-fno-short-enums",
590
591 "-Wall",
b99933c7
RS
592 "-Wcast-qual",
593 "-Wno-cast-qual",
b99933c7
RS
594 "-Wchar-subscripts",
595 "-Wno-char-subscripts",
b99933c7
RS
596 "-Wcomment",
597 "-Wno-comment",
598 "-Wcomments",
599 "-Wno-comments",
4200c8de
RK
600 "-Wconversion",
601 "-Wno-conversion",
602 "-Wformat",
603 "-Wno-format",
b99933c7
RS
604 "-Wimport",
605 "-Wno-import",
4200c8de
RK
606 "-Wimplicit",
607 "-Wno-implicit",
f41372d4
RS
608 "-Wmissing-braces",
609 "-Wno-missing-braces",
4200c8de
RK
610 "-Wmissing-declarations",
611 "-Wno-missing-declarations",
612 "-Wmissing-prototypes",
613 "-Wno-missing-prototypes",
614 "-Wnested-externs",
615 "-Wno-nested-externs",
616 "-Wparentheses",
617 "-Wno-parentheses",
618 "-Wpointer-arith",
619 "-Wno-pointer-arith",
620 "-Wredundant-decls",
621 "-Wno-redundant-decls",
622 "-Wstrict-prototypes",
623 "-Wno-strict-prototypes",
624 "-Wtraditional",
625 "-Wno-traditional",
626 "-Wtrigraphs",
627 "-Wno-trigraphs",
628 "-Wwrite-strings",
629 "-Wno-write-strings",
b99933c7
RS
630
631 /* These are for C++. */
6419d860
RS
632 "-+e0", /* gcc.c tacks the `-' on the front. */
633 "-+e1",
634 "-+e2",
b99933c7
RS
635 "-fall-virtual",
636 "-fno-all-virtual",
ceb90aa7
RK
637 "-falt-external-templates",
638 "-fno-alt-external-templates",
ceb90aa7
RK
639 "-fansi-overloading",
640 "-fno-ansi-overloading",
641 "-fcadillac",
642 "-fno-cadillac",
643 "-fconserve-space",
644 "-fno-conserve-space",
b99933c7
RS
645 "-fdefault-inline",
646 "-fno-default-inline",
b99933c7
RS
647 "-fdossier",
648 "-fno-dossier",
ceb90aa7
RK
649 "-felide-constructors",
650 "-fno-elide-constructors",
651 "-fenum-int-equiv",
652 "-fno-enum-int-equiv",
e701d556
BK
653 "-fexternal-templates",
654 "-fno-external-templates",
ceb90aa7
RK
655 "-fgc",
656 "-fno-gc",
657 "-fhandle-exceptions",
658 "-fno-handle-exceptions",
e1d9c157
MS
659 "-fhandle-signatures",
660 "-fno-handle-signatures",
2c0d84d6
MS
661 "-fhuge-objects",
662 "-fno-huge-objects",
ceb90aa7
RK
663 "-fimplement-inlines",
664 "-fno-implement-inlines",
665 "-flabels-ok",
666 "-fno-labels-ok",
667 "-fmemoize-lookups",
668 "-fno-memoize-lookups",
669 "-fnonnull-objects",
670 "-fno-nonnull-objects",
671 "-fsave-memoized",
672 "-fno-save-memoized",
5dab5552
MS
673 "-fshort-temps",
674 "-fno-short-temps",
ceb90aa7
RK
675 "-fstats",
676 "-fno-stats",
677 "-fstrict-prototype",
678 "-fno-strict-prototype",
679 "-fthis-is-variable",
680 "-fno-this-is-variable",
151f13be
PB
681 "-fvtable-thunks",
682 "-fno-vtable-thunks",
ceb90aa7
RK
683 "-fxref",
684 "-fno-xref",
b99933c7
RS
685
686 "-Wreturn-type",
687 "-Wno-return-type",
688 "-Woverloaded-virtual",
689 "-Wno-overloaded-virtual",
690 "-Wenum-clash",
691 "-Wno-enum-clash",
a2468e45
BK
692 "-Wtemplate-debugging",
693 "-Wno-template-debugging",
e701d556
BK
694 "-Wctor-dtor-privacy",
695 "-Wno-ctor-dtor-privacy",
cb1fcd8c
RK
696 "-Wextern-inline",
697 "-Wno-extern-inline",
65faa6a4
RS
698
699 /* these are for obj c */
700 "-lang-objc",
701 "-gen-decls",
f5309ddf
TW
702 "-fgnu-runtime",
703 "-fno-gnu-runtime",
704 "-fnext-runtime",
705 "-fno-next-runtime",
65faa6a4
RS
706 "-Wselector",
707 "-Wno-selector",
b800a01b
KKT
708 "-Wprotocol",
709 "-Wno-protocol",
a457294f
RK
710
711 /* This is for GNAT and is temporary. */
712 "-gnat",
b99933c7
RS
713 0
714};
4291d9c8
RS
715\f
716/* Options controlling warnings */
717
718/* Don't print warning messages. -w. */
719
720int inhibit_warnings = 0;
721
722/* Print various extra warnings. -W. */
723
724int extra_warnings = 0;
725
726/* Treat warnings as errors. -Werror. */
727
728int warnings_are_errors = 0;
729
730/* Nonzero to warn about unused local variables. */
731
732int warn_unused;
733
734/* Nonzero to warn about variables used before they are initialized. */
735
736int warn_uninitialized;
737
738/* Nonzero means warn about all declarations which shadow others. */
739
740int warn_shadow;
741
742/* Warn if a switch on an enum fails to have a case for every enum value. */
743
744int warn_switch;
745
746/* Nonzero means warn about function definitions that default the return type
747 or that use a null return and have a return-type other than void. */
748
749int warn_return_type;
750
751/* Nonzero means warn about pointer casts that increase the required
752 alignment of the target type (and might therefore lead to a crash
753 due to a misaligned access). */
754
755int warn_cast_align;
756
757/* Nonzero means warn about any identifiers that match in the first N
758 characters. The value N is in `id_clash_len'. */
759
760int warn_id_clash;
b51e9c62
RK
761unsigned id_clash_len;
762
763/* Nonzero means warn about any objects definitions whose size is larger
764 than N bytes. Also want about function definitions whose returned
765 values are larger than N bytes. The value N is in `larger_than_size'. */
766
767int warn_larger_than;
768unsigned larger_than_size;
4291d9c8
RS
769
770/* Nonzero means warn if inline function is too large. */
771
772int warn_inline;
773
774/* Warn if a function returns an aggregate,
775 since there are often incompatible calling conventions for doing this. */
776
777int warn_aggregate_return;
778
779/* Likewise for -W. */
780
781struct { char *string; int *variable; int on_value;} W_options[] =
782{
783 {"unused", &warn_unused, 1},
784 {"error", &warnings_are_errors, 1},
785 {"shadow", &warn_shadow, 1},
786 {"switch", &warn_switch, 1},
4291d9c8
RS
787 {"aggregate-return", &warn_aggregate_return, 1},
788 {"cast-align", &warn_cast_align, 1},
f246a305
RS
789 {"uninitialized", &warn_uninitialized, 1},
790 {"inline", &warn_inline, 1}
4291d9c8
RS
791};
792\f
793/* Output files for assembler code (real compiler output)
794 and debugging dumps. */
795
796FILE *asm_out_file;
797FILE *aux_info_file;
798FILE *rtl_dump_file;
799FILE *jump_opt_dump_file;
800FILE *cse_dump_file;
801FILE *loop_dump_file;
802FILE *cse2_dump_file;
803FILE *flow_dump_file;
804FILE *combine_dump_file;
805FILE *sched_dump_file;
806FILE *local_reg_dump_file;
807FILE *global_reg_dump_file;
808FILE *sched2_dump_file;
809FILE *jump2_opt_dump_file;
810FILE *dbr_sched_dump_file;
811FILE *stack_reg_dump_file;
812
813/* Time accumulators, to count the total time spent in various passes. */
814
815int parse_time;
816int varconst_time;
817int integration_time;
818int jump_time;
819int cse_time;
820int loop_time;
821int cse2_time;
822int flow_time;
823int combine_time;
824int sched_time;
825int local_alloc_time;
826int global_alloc_time;
827int sched2_time;
828int dbr_sched_time;
829int shorten_branch_time;
830int stack_reg_time;
831int final_time;
832int symout_time;
833int dump_time;
834\f
835/* Return time used so far, in microseconds. */
836
837int
838get_run_time ()
839{
840#ifdef USG
841 struct tms tms;
842#else
843#ifndef VMS
844 struct rusage rusage;
845#else /* VMS */
846 struct
847 {
848 int proc_user_time;
849 int proc_system_time;
850 int child_user_time;
851 int child_system_time;
852 } vms_times;
853#endif
854#endif
855
856 if (quiet_flag)
857 return 0;
858
859#ifdef USG
860 times (&tms);
861 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
862#else
863#ifndef VMS
864 getrusage (0, &rusage);
865 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
866 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
867#else /* VMS */
868 times (&vms_times);
869 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
870#endif
871#endif
872}
873
874#define TIMEVAR(VAR, BODY) \
875do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
876
877void
878print_time (str, total)
879 char *str;
880 int total;
881{
882 fprintf (stderr,
883 "time in %s: %d.%06d\n",
884 str, total / 1000000, total % 1000000);
885}
886
887/* Count an error or warning. Return 1 if the message should be printed. */
888
889int
890count_error (warningp)
891 int warningp;
892{
893 if (warningp && inhibit_warnings)
894 return 0;
895
896 if (warningp && !warnings_are_errors)
897 warningcount++;
898 else
899 {
900 static int warning_message = 0;
901
902 if (warningp && !warning_message)
903 {
904 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
905 warning_message = 1;
906 }
907 errorcount++;
908 }
909
910 return 1;
911}
912
913/* Print a fatal error message. NAME is the text.
914 Also include a system error message based on `errno'. */
915
916void
917pfatal_with_name (name)
918 char *name;
919{
920 fprintf (stderr, "%s: ", progname);
921 perror (name);
922 exit (35);
923}
924
925void
926fatal_io_error (name)
927 char *name;
928{
929 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
930 exit (35);
931}
932
4291d9c8
RS
933/* Called to give a better error message when we don't have an insn to match
934 what we are looking for or if the insn's constraints aren't satisfied,
935 rather than just calling abort(). */
936
937void
938fatal_insn_not_found (insn)
939 rtx insn;
940{
ca695ac9
JB
941 if (!output_bytecode)
942 {
943 if (INSN_CODE (insn) < 0)
eb711c86 944 error ("internal error--unrecognizable insn:");
ca695ac9 945 else
eb711c86 946 error ("internal error--insn does not satisfy its constraints:");
ca695ac9
JB
947 debug_rtx (insn);
948 }
4291d9c8
RS
949 if (asm_out_file)
950 fflush (asm_out_file);
951 if (aux_info_file)
952 fflush (aux_info_file);
953 if (rtl_dump_file)
954 fflush (rtl_dump_file);
955 if (jump_opt_dump_file)
956 fflush (jump_opt_dump_file);
957 if (cse_dump_file)
958 fflush (cse_dump_file);
959 if (loop_dump_file)
960 fflush (loop_dump_file);
961 if (cse2_dump_file)
962 fflush (cse2_dump_file);
963 if (flow_dump_file)
964 fflush (flow_dump_file);
965 if (combine_dump_file)
966 fflush (combine_dump_file);
967 if (sched_dump_file)
968 fflush (sched_dump_file);
969 if (local_reg_dump_file)
970 fflush (local_reg_dump_file);
971 if (global_reg_dump_file)
972 fflush (global_reg_dump_file);
973 if (sched2_dump_file)
974 fflush (sched2_dump_file);
975 if (jump2_opt_dump_file)
976 fflush (jump2_opt_dump_file);
977 if (dbr_sched_dump_file)
978 fflush (dbr_sched_dump_file);
979 if (stack_reg_dump_file)
980 fflush (stack_reg_dump_file);
981 abort ();
982}
983
984/* This is the default decl_printable_name function. */
985
986static char *
987decl_name (decl, kind)
988 tree decl;
989 char **kind;
990{
991 return IDENTIFIER_POINTER (DECL_NAME (decl));
992}
993\f
994static int need_error_newline;
995
996/* Function of last error message;
997 more generally, function such that if next error message is in it
998 then we don't have to mention the function name. */
999static tree last_error_function = NULL;
1000
1001/* Used to detect when input_file_stack has changed since last described. */
1002static int last_error_tick;
1003
1004/* Called when the start of a function definition is parsed,
1005 this function prints on stderr the name of the function. */
1006
1007void
1008announce_function (decl)
1009 tree decl;
1010{
1011 if (! quiet_flag)
1012 {
1013 char *junk;
1014 if (rtl_dump_and_exit)
1015 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1016 else
1017 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
1018 fflush (stderr);
1019 need_error_newline = 1;
1020 last_error_function = current_function_decl;
1021 }
1022}
1023
1024/* Prints out, if necessary, the name of the current function
1025 which caused an error. Called from all error and warning functions. */
1026
1027void
1028report_error_function (file)
1029 char *file;
1030{
1031 struct file_stack *p;
1032
1033 if (need_error_newline)
1034 {
1035 fprintf (stderr, "\n");
1036 need_error_newline = 0;
1037 }
1038
1039 if (last_error_function != current_function_decl)
1040 {
1041 char *kind = "function";
1042 if (current_function_decl != 0
1043 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1044 kind = "method";
1045
1046 if (file)
1047 fprintf (stderr, "%s: ", file);
1048
1049 if (current_function_decl == NULL)
1050 fprintf (stderr, "At top level:\n");
1051 else
1052 {
1053 char *name = (*decl_printable_name) (current_function_decl, &kind);
1054 fprintf (stderr, "In %s `%s':\n", kind, name);
1055 }
1056
1057 last_error_function = current_function_decl;
1058 }
1059 if (input_file_stack && input_file_stack->next != 0
1060 && input_file_stack_tick != last_error_tick)
1061 {
1062 fprintf (stderr, "In file included");
1063 for (p = input_file_stack->next; p; p = p->next)
1064 {
1065 fprintf (stderr, " from %s:%d", p->name, p->line);
1066 if (p->next)
e5301904 1067 fprintf (stderr, ",\n ");
4291d9c8
RS
1068 }
1069 fprintf (stderr, ":\n");
1070 last_error_tick = input_file_stack_tick;
1071 }
1072}
eb711c86
RK
1073\f
1074/* Print a message. */
4291d9c8 1075
eb711c86
RK
1076static void
1077vmessage (prefix, s, ap)
1078 char *prefix;
4291d9c8 1079 char *s;
eb711c86 1080 va_list ap;
4291d9c8 1081{
eb711c86
RK
1082 if (prefix)
1083 fprintf (stderr, "%s: ", prefix);
1084
1085#ifdef HAVE_VPRINTF
1086 vfprintf (stderr, s, ap);
1087#else
1088 {
1089 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1090 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1091 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1092 fprintf (stderr, s, v1, v2, v3);
1093 }
1094#endif
4291d9c8
RS
1095}
1096
eb711c86 1097/* Print a message relevant to line LINE of file FILE. */
4291d9c8 1098
eb711c86
RK
1099static void
1100v_message_with_file_and_line (file, line, prefix, s, ap)
4291d9c8
RS
1101 char *file;
1102 int line;
eb711c86 1103 char *prefix;
4291d9c8 1104 char *s;
eb711c86 1105 va_list ap;
4291d9c8 1106{
4291d9c8
RS
1107 if (file)
1108 fprintf (stderr, "%s:%d: ", file, line);
1109 else
1110 fprintf (stderr, "%s: ", progname);
d78c6ad5 1111
eb711c86
RK
1112 vmessage (prefix, s, ap);
1113 fputc ('\n', stderr);
4291d9c8
RS
1114}
1115
eb711c86 1116/* Print a message relevant to the given DECL. */
4291d9c8 1117
eb711c86
RK
1118static void
1119v_message_with_decl (decl, prefix, s, ap)
4291d9c8 1120 tree decl;
eb711c86 1121 char *prefix;
4291d9c8 1122 char *s;
eb711c86 1123 va_list ap;
4291d9c8 1124{
eb711c86 1125 char *n, *p, *junk;
4291d9c8
RS
1126
1127 fprintf (stderr, "%s:%d: ",
1128 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1129
eb711c86
RK
1130 if (prefix)
1131 fprintf (stderr, "%s: ", prefix);
1132
1133 /* Do magic to get around lack of varargs support for insertion
1134 of arguments into existing list. We know that the decl is first;
1135 we ass_u_me that it will be printed with "%s". */
1136
1137 for (p = s; *p; ++p)
1138 {
1139 if (*p == '%')
1140 {
1141 if (*(p + 1) == '%')
1142 ++p;
1143 else
1144 break;
1145 }
1146 }
1147
1148 if (p > s)
1149 fwrite (s, p - s, 1, stderr);
1150
1151 if (*p == '%')
1152 {
1153 char *n = (DECL_NAME (decl)
1154 ? (*decl_printable_name) (decl, &junk)
1155 : "((anonymous))");
1156 fputs (n, stderr);
1157 while (*p)
1158 {
1159 ++p;
1160 if (isalpha (*(p - 1) & 0xFF))
1161 break;
1162 }
1163 }
1164
1165 if (*p)
1166 vmessage ((char *)NULL, p, ap);
1167
1168 fputc ('\n', stderr);
4291d9c8
RS
1169}
1170
eb711c86 1171/* Figure file and line of the given INSN. */
4291d9c8 1172
eb711c86
RK
1173static void
1174file_and_line_for_asm (insn, pfile, pline)
4291d9c8 1175 rtx insn;
eb711c86
RK
1176 char **pfile;
1177 int *pline;
4291d9c8 1178{
4291d9c8
RS
1179 rtx body = PATTERN (insn);
1180 rtx asmop;
1181
1182 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1183 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1184 asmop = SET_SRC (body);
1185 else if (GET_CODE (body) == ASM_OPERANDS)
1186 asmop = body;
1187 else if (GET_CODE (body) == PARALLEL
1188 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1189 asmop = SET_SRC (XVECEXP (body, 0, 0));
1190 else if (GET_CODE (body) == PARALLEL
1191 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1192 asmop = XVECEXP (body, 0, 0);
eb711c86
RK
1193 else
1194 asmop = NULL;
1195
1196 if (asmop)
1197 {
1198 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1199 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1200 }
1201 else
1202 {
1203 *pfile = input_filename;
1204 *pline = lineno;
1205 }
1206}
4291d9c8 1207
eb711c86 1208/* Report an error at line LINE of file FILE. */
4291d9c8 1209
eb711c86
RK
1210static void
1211v_error_with_file_and_line (file, line, s, ap)
1212 char *file;
1213 int line;
1214 char *s;
1215 va_list ap;
1216{
1217 count_error (0);
1218 report_error_function (file);
1219 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
d78c6ad5
RK
1220}
1221
1222void
e0e2a8da 1223error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
d78c6ad5 1224{
e0e2a8da 1225#ifndef __STDC__
eb711c86
RK
1226 char *file;
1227 int line;
1228 char *s;
e0e2a8da
RK
1229#endif
1230 va_list ap;
1231
1232 VA_START (ap, s);
eb711c86 1233
e0e2a8da 1234#ifndef __STDC__
eb711c86
RK
1235 file = va_arg (ap, char *);
1236 line = va_arg (ap, int);
1237 s = va_arg (ap, char *);
e0e2a8da
RK
1238#endif
1239
eb711c86
RK
1240 v_error_with_file_and_line (file, line, s, ap);
1241 va_end (ap);
4291d9c8
RS
1242}
1243
eb711c86
RK
1244/* Report an error at the declaration DECL.
1245 S is a format string which uses %s to substitute the declaration
1246 name; subsequent substitutions are a la printf. */
1247
1248static void
1249v_error_with_decl (decl, s, ap)
1250 tree decl;
1251 char *s;
1252 va_list ap;
1253{
1254 count_error (0);
1255 report_error_function (DECL_SOURCE_FILE (decl));
1256 v_message_with_decl (decl, (char *)NULL, s, ap);
1257}
4291d9c8
RS
1258
1259void
e0e2a8da 1260error_with_decl VPROTO((tree decl, char *s, ...))
eb711c86 1261{
e0e2a8da 1262#ifndef __STDC__
eb711c86
RK
1263 tree decl;
1264 char *s;
e0e2a8da
RK
1265#endif
1266 va_list ap;
eb711c86 1267
e0e2a8da
RK
1268 VA_START (ap, s);
1269
1270#ifndef __STDC__
eb711c86
RK
1271 decl = va_arg (ap, tree);
1272 s = va_arg (ap, char *);
e0e2a8da
RK
1273#endif
1274
eb711c86
RK
1275 v_error_with_decl (decl, s, ap);
1276 va_end (ap);
1277}
1278
1279/* Report an error at the line number of the insn INSN.
1280 This is used only when INSN is an `asm' with operands,
1281 and each ASM_OPERANDS records its own source file and line. */
1282
1283static void
1284v_error_for_asm (insn, s, ap)
1285 rtx insn;
4291d9c8 1286 char *s;
eb711c86 1287 va_list ap;
4291d9c8 1288{
eb711c86
RK
1289 char *file;
1290 int line;
4291d9c8 1291
eb711c86
RK
1292 count_error (0);
1293 file_and_line_for_asm (insn, &file, &line);
4291d9c8 1294 report_error_function (file);
eb711c86
RK
1295 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1296}
4291d9c8 1297
eb711c86 1298void
e0e2a8da 1299error_for_asm VPROTO((rtx insn, char *s, ...))
eb711c86 1300{
e0e2a8da 1301#ifndef __STDC__
eb711c86
RK
1302 rtx insn;
1303 char *s;
e0e2a8da
RK
1304#endif
1305 va_list ap;
eb711c86 1306
e0e2a8da
RK
1307 VA_START (ap, s);
1308
1309#ifndef __STDC__
eb711c86
RK
1310 insn = va_arg (ap, rtx);
1311 s = va_arg (ap, char *);
e0e2a8da
RK
1312#endif
1313
eb711c86
RK
1314 v_error_for_asm (insn, s, ap);
1315 va_end (ap);
4291d9c8
RS
1316}
1317
eb711c86 1318/* Report an error at the current line number. */
4291d9c8 1319
eb711c86
RK
1320static void
1321verror (s, ap)
4291d9c8 1322 char *s;
eb711c86 1323 va_list ap;
4291d9c8 1324{
eb711c86 1325 v_error_with_file_and_line (input_filename, lineno, s, ap);
4291d9c8
RS
1326}
1327
eb711c86 1328void
e0e2a8da 1329error VPROTO((char *s, ...))
eb711c86 1330{
e0e2a8da 1331#ifndef __STDC__
eb711c86 1332 char *s;
e0e2a8da
RK
1333#endif
1334 va_list ap;
1335
1336 VA_START (ap, s);
eb711c86 1337
e0e2a8da 1338#ifndef __STDC__
eb711c86 1339 s = va_arg (ap, char *);
e0e2a8da
RK
1340#endif
1341
eb711c86
RK
1342 verror (s, ap);
1343 va_end (ap);
1344}
1345
1346/* Report a fatal error at the current line number. */
1347
1348static void
1349vfatal (s, ap)
1350 char *s;
1351 va_list ap;
1352{
1353 verror (s, ap);
1354 exit (34);
1355}
4291d9c8
RS
1356
1357void
e0e2a8da 1358fatal VPROTO((char *s, ...))
eb711c86 1359{
e0e2a8da 1360#ifndef __STDC__
eb711c86 1361 char *s;
e0e2a8da
RK
1362#endif
1363 va_list ap;
1364
1365 VA_START (ap, s);
eb711c86 1366
e0e2a8da 1367#ifndef __STDC__
eb711c86 1368 s = va_arg (ap, char *);
e0e2a8da
RK
1369#endif
1370
eb711c86
RK
1371 vfatal (s, ap);
1372 va_end (ap);
1373}
1374
1375/* Report a warning at line LINE of file FILE. */
1376
1377static void
1378v_warning_with_file_and_line (file, line, s, ap)
1379 char *file;
1380 int line;
4291d9c8 1381 char *s;
eb711c86 1382 va_list ap;
4291d9c8 1383{
eb711c86
RK
1384 if (count_error (1))
1385 {
1386 report_error_function (file);
1387 v_message_with_file_and_line (file, line, "warning", s, ap);
1388 }
1389}
4291d9c8 1390
eb711c86 1391void
e0e2a8da 1392warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
eb711c86 1393{
e0e2a8da 1394#ifndef __STDC__
eb711c86
RK
1395 char *file;
1396 int line;
1397 char *s;
e0e2a8da
RK
1398#endif
1399 va_list ap;
1400
1401 VA_START (ap, s);
eb711c86 1402
e0e2a8da 1403#ifndef __STDC__
eb711c86
RK
1404 file = va_arg (ap, char *);
1405 line = va_arg (ap, int);
1406 s = va_arg (ap, char *);
e0e2a8da
RK
1407#endif
1408
eb711c86
RK
1409 v_warning_with_file_and_line (file, line, s, ap);
1410 va_end (ap);
1411}
4291d9c8 1412
eb711c86
RK
1413/* Report a warning at the declaration DECL.
1414 S is a format string which uses %s to substitute the declaration
1415 name; subsequent substitutions are a la printf. */
4291d9c8 1416
eb711c86
RK
1417static void
1418v_warning_with_decl (decl, s, ap)
1419 tree decl;
1420 char *s;
1421 va_list ap;
1422{
1423 if (count_error (1))
1424 {
1425 report_error_function (DECL_SOURCE_FILE (decl));
1426 v_message_with_decl (decl, "warning", s, ap);
1427 }
1428}
4291d9c8 1429
eb711c86 1430void
e0e2a8da 1431warning_with_decl VPROTO((tree decl, char *s, ...))
eb711c86 1432{
e0e2a8da 1433#ifndef __STDC__
eb711c86
RK
1434 tree decl;
1435 char *s;
e0e2a8da
RK
1436#endif
1437 va_list ap;
eb711c86 1438
e0e2a8da
RK
1439 VA_START (ap, s);
1440
1441#ifndef __STDC__
eb711c86
RK
1442 decl = va_arg (ap, tree);
1443 s = va_arg (ap, char *);
e0e2a8da
RK
1444#endif
1445
eb711c86
RK
1446 v_warning_with_decl (decl, s, ap);
1447 va_end (ap);
4291d9c8
RS
1448}
1449
1450/* Report a warning at the line number of the insn INSN.
4291d9c8
RS
1451 This is used only when INSN is an `asm' with operands,
1452 and each ASM_OPERANDS records its own source file and line. */
1453
eb711c86
RK
1454static void
1455v_warning_for_asm (insn, s, ap)
4291d9c8
RS
1456 rtx insn;
1457 char *s;
eb711c86 1458 va_list ap;
4291d9c8 1459{
eb711c86
RK
1460 if (count_error (1))
1461 {
1462 char *file;
1463 int line;
4291d9c8 1464
eb711c86
RK
1465 file_and_line_for_asm (insn, &file, &line);
1466 report_error_function (file);
1467 v_message_with_file_and_line (file, line, "warning", s, ap);
1468 }
1469}
4291d9c8 1470
eb711c86 1471void
e0e2a8da 1472warning_for_asm VPROTO((rtx insn, char *s, ...))
eb711c86 1473{
e0e2a8da 1474#ifndef __STDC__
eb711c86
RK
1475 rtx insn;
1476 char *s;
e0e2a8da
RK
1477#endif
1478 va_list ap;
1479
1480 VA_START (ap, s);
eb711c86 1481
e0e2a8da 1482#ifndef __STDC__
eb711c86
RK
1483 insn = va_arg (ap, rtx);
1484 s = va_arg (ap, char *);
e0e2a8da
RK
1485#endif
1486
eb711c86
RK
1487 v_warning_for_asm (insn, s, ap);
1488 va_end (ap);
1489}
4291d9c8 1490
eb711c86
RK
1491/* Report a warning at the current line number. */
1492
1493static void
1494vwarning (s, ap)
1495 char *s;
1496 va_list ap;
1497{
1498 v_warning_with_file_and_line (input_filename, lineno, s, ap);
4291d9c8 1499}
eb711c86
RK
1500
1501void
e0e2a8da 1502warning VPROTO((char *s, ...))
eb711c86 1503{
e0e2a8da 1504#ifndef __STDC__
eb711c86 1505 char *s;
e0e2a8da
RK
1506#endif
1507 va_list ap;
1508
1509 VA_START (ap, s);
eb711c86 1510
e0e2a8da 1511#ifndef __STDC__
eb711c86 1512 s = va_arg (ap, char *);
e0e2a8da
RK
1513#endif
1514
eb711c86
RK
1515 vwarning (s, ap);
1516 va_end (ap);
1517}
1518
4291d9c8
RS
1519/* These functions issue either warnings or errors depending on
1520 -pedantic-errors. */
1521
eb711c86
RK
1522static void
1523vpedwarn (s, ap)
4291d9c8 1524 char *s;
eb711c86 1525 va_list ap;
4291d9c8
RS
1526{
1527 if (flag_pedantic_errors)
eb711c86 1528 verror (s, ap);
4291d9c8 1529 else
eb711c86 1530 vwarning (s, ap);
4291d9c8
RS
1531}
1532
1533void
e0e2a8da 1534pedwarn VPROTO((char *s, ...))
eb711c86 1535{
e0e2a8da 1536#ifndef __STDC__
eb711c86 1537 char *s;
e0e2a8da
RK
1538#endif
1539 va_list ap;
1540
1541 VA_START (ap, s);
eb711c86 1542
e0e2a8da 1543#ifndef __STDC__
eb711c86 1544 s = va_arg (ap, char *);
e0e2a8da
RK
1545#endif
1546
eb711c86
RK
1547 vpedwarn (s, ap);
1548 va_end (ap);
1549}
1550
1551static void
1552v_pedwarn_with_decl (decl, s, ap)
4291d9c8
RS
1553 tree decl;
1554 char *s;
eb711c86 1555 va_list ap;
4291d9c8 1556{
1554cdf5
DE
1557 /* We don't want -pedantic-errors to cause the compilation to fail from
1558 "errors" in system header files. Sometimes fixincludes can't fix what's
1559 broken (eg: unsigned char bitfields - fixing it may change the alignment
1560 which will cause programs to mysteriously fail because the C library
1561 or kernel uses the original layout).
1562
1563 ??? In fact, we may wish not to issue any message in this case. */
1564
1565 if (flag_pedantic_errors && ! DECL_IN_SYSTEM_HEADER (decl))
eb711c86 1566 v_error_with_decl (decl, s, ap);
4291d9c8 1567 else
eb711c86 1568 v_warning_with_decl (decl, s, ap);
4291d9c8
RS
1569}
1570
1571void
e0e2a8da 1572pedwarn_with_decl VPROTO((tree decl, char *s, ...))
eb711c86 1573{
e0e2a8da 1574#ifndef __STDC__
eb711c86
RK
1575 tree decl;
1576 char *s;
e0e2a8da
RK
1577#endif
1578 va_list ap;
eb711c86 1579
e0e2a8da
RK
1580 VA_START (ap, s);
1581
1582#ifndef __STDC__
eb711c86
RK
1583 decl = va_arg (ap, tree);
1584 s = va_arg (ap, char *);
e0e2a8da
RK
1585#endif
1586
eb711c86
RK
1587 v_pedwarn_with_decl (decl, s, ap);
1588 va_end (ap);
1589}
1590
1591static void
1592v_pedwarn_with_file_and_line (file, line, s, ap)
4291d9c8
RS
1593 char *file;
1594 int line;
1595 char *s;
eb711c86 1596 va_list ap;
4291d9c8
RS
1597{
1598 if (flag_pedantic_errors)
eb711c86 1599 v_error_with_file_and_line (file, line, s, ap);
4291d9c8 1600 else
eb711c86 1601 v_warning_with_file_and_line (file, line, s, ap);
4291d9c8
RS
1602}
1603
4291d9c8 1604void
e0e2a8da 1605pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
eb711c86 1606{
e0e2a8da 1607#ifndef __STDC__
eb711c86
RK
1608 char *file;
1609 int line;
1610 char *s;
e0e2a8da
RK
1611#endif
1612 va_list ap;
eb711c86 1613
e0e2a8da
RK
1614 VA_START (ap, s);
1615
1616#ifndef __STDC__
eb711c86
RK
1617 file = va_arg (ap, char *);
1618 line = va_arg (ap, int);
1619 s = va_arg (ap, char *);
e0e2a8da
RK
1620#endif
1621
eb711c86
RK
1622 v_pedwarn_with_file_and_line (file, line, s, ap);
1623 va_end (ap);
1624}
1625
1626/* Apologize for not implementing some feature. */
1627
1628static void
1629vsorry (s, ap)
4291d9c8 1630 char *s;
eb711c86 1631 va_list ap;
4291d9c8
RS
1632{
1633 sorrycount++;
1634 if (input_filename)
1635 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1636 else
1637 fprintf (stderr, "%s: ", progname);
eb711c86
RK
1638 vmessage ("sorry, not implemented", s, ap);
1639 fputc ('\n', stderr);
1640}
4291d9c8 1641
eb711c86 1642void
e0e2a8da 1643sorry VPROTO((char *s, ...))
eb711c86 1644{
e0e2a8da 1645#ifndef __STDC__
eb711c86 1646 char *s;
e0e2a8da
RK
1647#endif
1648 va_list ap;
1649
1650 VA_START (ap, s);
eb711c86 1651
e0e2a8da 1652#ifndef __STDC__
eb711c86 1653 s = va_arg (ap, char *);
e0e2a8da
RK
1654#endif
1655
eb711c86
RK
1656 vsorry (s, ap);
1657 va_end (ap);
4291d9c8
RS
1658}
1659
eb711c86 1660/* Apologize for not implementing some feature, then quit. */
4291d9c8 1661
eb711c86
RK
1662static void
1663v_really_sorry (s, ap)
4291d9c8 1664 char *s;
eb711c86 1665 va_list ap;
4291d9c8 1666{
eb711c86 1667 sorrycount++;
4291d9c8
RS
1668 if (input_filename)
1669 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1670 else
c10afc44 1671 fprintf (stderr, "%s: ", progname);
eb711c86 1672 vmessage ("sorry, not implemented", s, ap);
4291d9c8
RS
1673 fatal (" (fatal)\n");
1674}
eb711c86
RK
1675
1676void
e0e2a8da 1677really_sorry VPROTO((char *s, ...))
eb711c86 1678{
e0e2a8da 1679#ifndef __STDC__
eb711c86 1680 char *s;
e0e2a8da
RK
1681#endif
1682 va_list ap;
1683
1684 VA_START (ap, s);
eb711c86 1685
e0e2a8da 1686#ifndef __STDC__
eb711c86 1687 s = va_arg (ap, char *);
e0e2a8da
RK
1688#endif
1689
eb711c86
RK
1690 v_really_sorry (s, ap);
1691 va_end (ap);
1692}
4291d9c8
RS
1693\f
1694/* More 'friendly' abort that prints the line and file.
1695 config.h can #define abort fancy_abort if you like that sort of thing.
1696
1697 I don't think this is actually a good idea.
1698 Other sorts of crashes will look a certain way.
1699 It is a good thing if crashes from calling abort look the same way.
1700 -- RMS */
1701
1702void
1703fancy_abort ()
1704{
1705 fatal ("internal gcc abort");
1706}
1707
1708/* This calls abort and is used to avoid problems when abort if a macro.
1709 It is used when we need to pass the address of abort. */
1710
1711void
1712do_abort ()
1713{
1714 abort ();
1715}
1716
1717/* When `malloc.c' is compiled with `rcheck' defined,
1718 it calls this function to report clobberage. */
1719
1720void
1721botch (s)
1722{
1723 abort ();
1724}
1725
1726/* Same as `malloc' but report error if no memory available. */
1727
4b980e20 1728char *
4291d9c8
RS
1729xmalloc (size)
1730 unsigned size;
1731{
4b980e20 1732 register char *value = (char *) malloc (size);
4291d9c8
RS
1733 if (value == 0)
1734 fatal ("virtual memory exhausted");
1735 return value;
1736}
1737
1738/* Same as `realloc' but report error if no memory available. */
1739
4b980e20 1740char *
4291d9c8
RS
1741xrealloc (ptr, size)
1742 char *ptr;
1743 int size;
1744{
4b980e20 1745 char *result = (char *) realloc (ptr, size);
4291d9c8
RS
1746 if (!result)
1747 fatal ("virtual memory exhausted");
1748 return result;
1749}
1750\f
1751/* Return the logarithm of X, base 2, considering X unsigned,
37366632
RK
1752 if X is a power of 2. Otherwise, returns -1.
1753
1754 This should be used via the `exact_log2' macro. */
4291d9c8
RS
1755
1756int
37366632
RK
1757exact_log2_wide (x)
1758 register unsigned HOST_WIDE_INT x;
4291d9c8
RS
1759{
1760 register int log = 0;
1761 /* Test for 0 or a power of 2. */
1762 if (x == 0 || x != (x & -x))
1763 return -1;
1764 while ((x >>= 1) != 0)
1765 log++;
1766 return log;
1767}
1768
1769/* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
37366632
RK
1770 If X is 0, return -1.
1771
1772 This should be used via the floor_log2 macro. */
4291d9c8
RS
1773
1774int
37366632
RK
1775floor_log2_wide (x)
1776 register unsigned HOST_WIDE_INT x;
4291d9c8
RS
1777{
1778 register int log = -1;
1779 while (x != 0)
1780 log++,
1781 x >>= 1;
1782 return log;
1783}
1784
1785int float_handled;
1786jmp_buf float_handler;
1787
1788/* Specify where to longjmp to when a floating arithmetic error happens.
1789 If HANDLER is 0, it means don't handle the errors any more. */
1790
1791void
1792set_float_handler (handler)
1793 jmp_buf handler;
1794{
1795 float_handled = (handler != 0);
1796 if (handler)
1797 bcopy (handler, float_handler, sizeof (float_handler));
1798}
1799
bff4b641
RS
1800/* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1801 error happens, pushing the previous specification into OLD_HANDLER.
1802 Return an indication of whether there was a previous handler in effect. */
1803
1804int
1805push_float_handler (handler, old_handler)
dc2b15dc 1806 jmp_buf handler, old_handler;
bff4b641
RS
1807{
1808 int was_handled = float_handled;
1809
1810 float_handled = 1;
1811 if (was_handled)
1812 bcopy (float_handler, old_handler, sizeof (float_handler));
1813 bcopy (handler, float_handler, sizeof (float_handler));
1814 return was_handled;
1815}
1816
1817/* Restore the previous specification of whether and where to longjmp to
1818 when a floating arithmetic error happens. */
1819
1820void
1821pop_float_handler (handled, handler)
1822 int handled;
1823 jmp_buf handler;
1824{
1825 float_handled = handled;
1826 if (handled)
1827 bcopy (handler, float_handler, sizeof (float_handler));
1828}
1829
4291d9c8
RS
1830/* Signals actually come here. */
1831
1832static void
1833float_signal (signo)
1834 /* If this is missing, some compilers complain. */
1835 int signo;
1836{
1837 if (float_handled == 0)
1838 abort ();
1839#if defined (USG) || defined (hpux)
1840 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1841#endif
1842 float_handled = 0;
1843 signal (SIGFPE, float_signal);
1844 longjmp (float_handler, 1);
1845}
1846
1847/* Handler for SIGPIPE. */
1848
1849static void
1850pipe_closed (signo)
1851 /* If this is missing, some compilers complain. */
1852 int signo;
1853{
1854 fatal ("output pipe has been closed");
1855}
1856
1857/* Strip off a legitimate source ending from the input string NAME of
1858 length LEN. */
1859
1860void
1861strip_off_ending (name, len)
1862 char *name;
1863 int len;
1864{
1865 if (len > 2 && ! strcmp (".c", name + len - 2))
1866 name[len - 2] = 0;
1867 else if (len > 2 && ! strcmp (".m", name + len - 2))
1868 name[len - 2] = 0;
1869 else if (len > 2 && ! strcmp (".i", name + len - 2))
1870 name[len - 2] = 0;
1871 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1872 name[len - 3] = 0;
1873 else if (len > 3 && ! strcmp (".co", name + len - 3))
1874 name[len - 3] = 0;
1875 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1876 name[len - 3] = 0;
9cc00e36
RS
1877 else if (len > 2 && ! strcmp (".C", name + len - 2))
1878 name[len - 2] = 0;
1879 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1880 name[len - 4] = 0;
4da617d8
RK
1881 else if (len > 4 && ! strcmp (".cpp", name + len - 4))
1882 name[len - 4] = 0;
4291d9c8
RS
1883 else if (len > 2 && ! strcmp (".f", name + len - 2))
1884 name[len - 2] = 0;
d3984356
RK
1885 /* Ada will use extensions like .ada, .adb, and .ads, so just test
1886 for "ad". */
1887 else if (len > 4 && ! strncmp (".ad", name + len - 4, 3))
4291d9c8 1888 name[len - 4] = 0;
be07ab12
RK
1889 else if (len > 4 && ! strcmp (".atr", name + len - 4))
1890 name[len - 4] = 0;
4291d9c8
RS
1891}
1892
7dce5088
PE
1893/* Output a quoted string. */
1894void
1895output_quoted_string (asm_file, string)
1896 FILE *asm_file;
1897 char *string;
1898{
1899 char c;
1900
1901 putc ('\"', asm_file);
1902 while ((c = *string++) != 0)
1903 {
1904 if (c == '\"' || c == '\\')
1905 putc ('\\', asm_file);
1906 putc (c, asm_file);
1907 }
1908 putc ('\"', asm_file);
1909}
1910
4291d9c8
RS
1911/* Output a file name in the form wanted by System V. */
1912
1913void
1914output_file_directive (asm_file, input_name)
1915 FILE *asm_file;
1916 char *input_name;
1917{
1918 int len = strlen (input_name);
1919 char *na = input_name + len;
1920
1921 /* NA gets INPUT_NAME sans directory names. */
1922 while (na > input_name)
1923 {
1924 if (na[-1] == '/')
1925 break;
1926 na--;
1927 }
1928
1929#ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1930 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1931#else
1932#ifdef ASM_OUTPUT_SOURCE_FILENAME
1933 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1934#else
7dce5088
PE
1935 fprintf (asm_file, "\t.file\t");
1936 output_quoted_string (asm_file, na);
1937 fputc ('\n', asm_file);
4291d9c8
RS
1938#endif
1939#endif
1940}
1941\f
d0d4af87
MS
1942/* Routine to build language identifier for object file. */
1943static void
1944output_lang_identify (asm_out_file)
1945 FILE *asm_out_file;
1946{
1947 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1948 char *s = (char *) alloca (len);
1949 sprintf (s, "__gnu_compiled_%s", lang_identify ());
1950 ASM_OUTPUT_LABEL (asm_out_file, s);
1951}
1952
dfe1a916
DE
1953/* Routine to open a dump file. */
1954static FILE *
1955open_dump_file (base_name, suffix)
1956 char *base_name;
1957 char *suffix;
1958{
1959 FILE *f;
1960 char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1);
1961
1962 strcpy (dumpname, base_name);
1963 strcat (dumpname, suffix);
1964 f = fopen (dumpname, "w");
1965 if (f == 0)
1966 pfatal_with_name (dumpname);
1967 return f;
1968}
1969
4291d9c8
RS
1970/* Compile an entire file of output from cpp, named NAME.
1971 Write a file of assembly output and various debugging dumps. */
1972
1973static void
1974compile_file (name)
1975 char *name;
1976{
1977 tree globals;
1978 int start_time;
4291d9c8
RS
1979
1980 int name_specified = name != 0;
1981
1982 if (dump_base_name == 0)
1983 dump_base_name = name ? name : "gccdump";
4291d9c8
RS
1984
1985 parse_time = 0;
1986 varconst_time = 0;
1987 integration_time = 0;
1988 jump_time = 0;
1989 cse_time = 0;
1990 loop_time = 0;
1991 cse2_time = 0;
1992 flow_time = 0;
1993 combine_time = 0;
1994 sched_time = 0;
1995 local_alloc_time = 0;
1996 global_alloc_time = 0;
1997 sched2_time = 0;
1998 dbr_sched_time = 0;
1999 shorten_branch_time = 0;
2000 stack_reg_time = 0;
2001 final_time = 0;
2002 symout_time = 0;
2003 dump_time = 0;
2004
2005 /* Open input file. */
2006
2007 if (name == 0 || !strcmp (name, "-"))
2008 {
2009 finput = stdin;
2010 name = "stdin";
2011 }
2012 else
2013 finput = fopen (name, "r");
2014 if (finput == 0)
2015 pfatal_with_name (name);
2016
282ea52a 2017#ifdef IO_BUFFER_SIZE
d7cedf4b 2018 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
282ea52a
RS
2019#endif
2020
4291d9c8
RS
2021 /* Initialize data in various passes. */
2022
2023 init_obstacks ();
2024 init_tree_codes ();
2025 init_lex ();
ca695ac9
JB
2026 /* Some of these really don't need to be called when generating bytecode,
2027 but the options would have to be parsed first to know that. -bson */
4291d9c8
RS
2028 init_rtl ();
2029 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2030 || debug_info_level == DINFO_LEVEL_VERBOSE);
7f21d440 2031 init_regs ();
4291d9c8
RS
2032 init_decl_processing ();
2033 init_optabs ();
2034 init_stmt ();
2035 init_expmed ();
4fa52007 2036 init_expr_once ();
4291d9c8
RS
2037 init_loop ();
2038 init_reload ();
2039
2040 if (flag_caller_saves)
2041 init_caller_save ();
2042
f246a305
RS
2043 /* If auxiliary info generation is desired, open the output file.
2044 This goes in the same directory as the source file--unlike
2045 all the other output files. */
4291d9c8
RS
2046 if (flag_gen_aux_info)
2047 {
4291d9c8
RS
2048 aux_info_file = fopen (aux_info_file_name, "w");
2049 if (aux_info_file == 0)
2050 pfatal_with_name (aux_info_file_name);
2051 }
2052
2053 /* If rtl dump desired, open the output file. */
2054 if (rtl_dump)
dfe1a916 2055 rtl_dump_file = open_dump_file (dump_base_name, ".rtl");
4291d9c8
RS
2056
2057 /* If jump_opt dump desired, open the output file. */
2058 if (jump_opt_dump)
dfe1a916 2059 jump_opt_dump_file = open_dump_file (dump_base_name, ".jump");
4291d9c8
RS
2060
2061 /* If cse dump desired, open the output file. */
2062 if (cse_dump)
dfe1a916 2063 cse_dump_file = open_dump_file (dump_base_name, ".cse");
4291d9c8
RS
2064
2065 /* If loop dump desired, open the output file. */
2066 if (loop_dump)
dfe1a916 2067 loop_dump_file = open_dump_file (dump_base_name, ".loop");
4291d9c8
RS
2068
2069 /* If cse2 dump desired, open the output file. */
2070 if (cse2_dump)
dfe1a916 2071 cse2_dump_file = open_dump_file (dump_base_name, ".cse2");
4291d9c8
RS
2072
2073 /* If flow dump desired, open the output file. */
2074 if (flow_dump)
dfe1a916 2075 flow_dump_file = open_dump_file (dump_base_name, ".flow");
4291d9c8
RS
2076
2077 /* If combine dump desired, open the output file. */
2078 if (combine_dump)
dfe1a916 2079 combine_dump_file = open_dump_file (dump_base_name, ".combine");
4291d9c8
RS
2080
2081 /* If scheduling dump desired, open the output file. */
2082 if (sched_dump)
dfe1a916 2083 sched_dump_file = open_dump_file (dump_base_name, ".sched");
4291d9c8
RS
2084
2085 /* If local_reg dump desired, open the output file. */
2086 if (local_reg_dump)
dfe1a916 2087 local_reg_dump_file = open_dump_file (dump_base_name, ".lreg");
4291d9c8
RS
2088
2089 /* If global_reg dump desired, open the output file. */
2090 if (global_reg_dump)
dfe1a916 2091 global_reg_dump_file = open_dump_file (dump_base_name, ".greg");
4291d9c8
RS
2092
2093 /* If 2nd scheduling dump desired, open the output file. */
2094 if (sched2_dump)
dfe1a916 2095 sched2_dump_file = open_dump_file (dump_base_name, ".sched2");
4291d9c8
RS
2096
2097 /* If jump2_opt dump desired, open the output file. */
2098 if (jump2_opt_dump)
dfe1a916 2099 jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2");
4291d9c8
RS
2100
2101 /* If dbr_sched dump desired, open the output file. */
2102 if (dbr_sched_dump)
dfe1a916 2103 dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr");
4291d9c8
RS
2104
2105#ifdef STACK_REGS
2106
2107 /* If stack_reg dump desired, open the output file. */
2108 if (stack_reg_dump)
dfe1a916 2109 stack_reg_dump_file = open_dump_file (dump_base_name, ".stack");
4291d9c8
RS
2110
2111#endif
2112
2113 /* Open assembler code output file. */
2114
2115 if (! name_specified && asm_file_name == 0)
2116 asm_out_file = stdout;
2117 else
2118 {
4291d9c8 2119 int len = strlen (dump_base_name);
dfe1a916 2120 register char *dumpname = (char *) xmalloc (len + 6);
4291d9c8
RS
2121 strcpy (dumpname, dump_base_name);
2122 strip_off_ending (dumpname, len);
2123 strcat (dumpname, ".s");
2124 if (asm_file_name == 0)
2125 {
2126 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2127 strcpy (asm_file_name, dumpname);
2128 }
2129 if (!strcmp (asm_file_name, "-"))
2130 asm_out_file = stdout;
2131 else
2132 asm_out_file = fopen (asm_file_name, "w");
2133 if (asm_out_file == 0)
2134 pfatal_with_name (asm_file_name);
2135 }
2136
f246a305 2137#ifdef IO_BUFFER_SIZE
d7cedf4b
RS
2138 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2139 _IOFBF, IO_BUFFER_SIZE);
f246a305
RS
2140#endif
2141
4291d9c8
RS
2142 input_filename = name;
2143
2144 /* Perform language-specific initialization.
2145 This may set main_input_filename. */
2146 lang_init ();
2147
2148 /* If the input doesn't start with a #line, use the input name
2149 as the official input file name. */
2150 if (main_input_filename == 0)
2151 main_input_filename = name;
2152
2153 /* Put an entry on the input file stack for the main input file. */
2154 input_file_stack
2155 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2156 input_file_stack->next = 0;
2157 input_file_stack->name = input_filename;
2158
ca695ac9
JB
2159 if (!output_bytecode)
2160 {
2161 ASM_FILE_START (asm_out_file);
2162 }
4291d9c8 2163
ca695ac9
JB
2164 /* Output something to inform GDB that this compilation was by GCC. Also
2165 serves to tell GDB file consists of bytecodes. */
2166 if (output_bytecode)
2167 fprintf (asm_out_file, "bc_gcc2_compiled.:\n");
2168 else
2169 {
4291d9c8 2170#ifndef ASM_IDENTIFY_GCC
ca695ac9 2171 fprintf (asm_out_file, "gcc2_compiled.:\n");
4291d9c8 2172#else
ca695ac9 2173 ASM_IDENTIFY_GCC (asm_out_file);
4291d9c8 2174#endif
ca695ac9 2175 }
d0d4af87
MS
2176
2177 /* Output something to identify which front-end produced this file. */
2178#ifdef ASM_IDENTIFY_LANGUAGE
2179 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2180#endif
2181
ca695ac9
JB
2182 if (output_bytecode)
2183 {
2184 if (profile_flag || profile_block_flag)
2185 error ("profiling not supported in bytecode compilation");
2186 }
2187 else
2188 {
2189 /* ??? Note: There used to be a conditional here
2190 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2191 This was to guarantee separation between gcc_compiled. and
2192 the first function, for the sake of dbx on Suns.
2193 However, having the extra zero here confused the Emacs
2194 code for unexec, and might confuse other programs too.
2195 Therefore, I took out that change.
2196 In future versions we should find another way to solve
2197 that dbx problem. -- rms, 23 May 93. */
2198
2199 /* Don't let the first function fall at the same address
2200 as gcc_compiled., if profiling. */
2201 if (profile_flag || profile_block_flag)
2202 assemble_zeros (UNITS_PER_WORD);
2203 }
4291d9c8
RS
2204
2205 /* If dbx symbol table desired, initialize writing it
2206 and output the predefined types. */
f246a305
RS
2207#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2208 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
4291d9c8
RS
2209 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2210 getdecls ()));
2211#endif
2212#ifdef SDB_DEBUGGING_INFO
2213 if (write_symbols == SDB_DEBUG)
2214 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2215 getdecls ()));
2216#endif
2217#ifdef DWARF_DEBUGGING_INFO
2218 if (write_symbols == DWARF_DEBUG)
2219 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2220#endif
2221
2222 /* Initialize yet another pass. */
2223
ca695ac9
JB
2224 if (!output_bytecode)
2225 init_final (main_input_filename);
4291d9c8
RS
2226
2227 start_time = get_run_time ();
2228
2229 /* Call the parser, which parses the entire file
2230 (calling rest_of_compilation for each function). */
2231
2232 if (yyparse () != 0)
453dfc78
JW
2233 {
2234 if (errorcount == 0)
2235 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2236
2237 /* In case there were missing closebraces,
2238 get us back to the global binding level. */
2239 while (! global_bindings_p ())
2240 poplevel (0, 0, 0);
2241 }
4291d9c8
RS
2242
2243 /* Compilation is now finished except for writing
2244 what's left of the symbol table output. */
2245
2246 parse_time += get_run_time () - start_time;
2247
2248 parse_time -= integration_time;
2249 parse_time -= varconst_time;
2250
2251 globals = getdecls ();
2252
2253 /* Really define vars that have had only a tentative definition.
2254 Really output inline functions that must actually be callable
2255 and have not been output so far. */
2256
2257 {
2258 int len = list_length (globals);
2259 tree *vec = (tree *) alloca (sizeof (tree) * len);
2260 int i;
2261 tree decl;
2262
2263 /* Process the decls in reverse order--earliest first.
2264 Put them into VEC from back to front, then take out from front. */
2265
2266 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2267 vec[len - i - 1] = decl;
2268
2269 for (i = 0; i < len; i++)
2270 {
2271 decl = vec[i];
488b1f4f
RS
2272 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2273 && incomplete_decl_finalize_hook != 0)
2b599527
RS
2274 (*incomplete_decl_finalize_hook) (decl);
2275
4291d9c8
RS
2276 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2277 && ! TREE_ASM_WRITTEN (decl))
2278 {
6b2bd61e
PB
2279 /* Don't write out static consts, unless we still need them.
2280
2281 We also keep static consts if not optimizing (for debugging).
2282 ??? They might be better written into the debug information.
2283 This is possible when using DWARF.
2284
2285 A language processor that wants static constants to be always
2286 written out (even if it is not used) is responsible for
2287 calling rest_of_decl_compilation itself. E.g. the C front-end
2288 calls rest_of_decl_compilation from finish_decl.
2289 One motivation for this is that is conventional in some
2290 environments to write things like:
2291 static const char rcsid[] = "... version string ...";
2292 intending to force the string to be in the executable.
2293
2294 A language processor that would prefer to have unneeded
2295 static constants "optimized away" would just defer writing
2296 them out until here. E.g. C++ does this, because static
2297 constants are often defined in header files.
2298
2299 ??? A tempting alternative (for both C and C++) would be
2300 to force a constant to be written if and only if it is
2301 defined in a main file, as opposed to an include file. */
2302
4291d9c8
RS
2303 if (! TREE_READONLY (decl)
2304 || TREE_PUBLIC (decl)
6b2bd61e 2305 || !optimize
4291d9c8
RS
2306 || TREE_ADDRESSABLE (decl)
2307 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
37366632 2308 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
4291d9c8
RS
2309 else
2310 /* Cancel the RTL for this decl so that, if debugging info
2311 output for global variables is still to come,
2312 this one will be omitted. */
2313 DECL_RTL (decl) = NULL;
2314 }
2315
2316 if (TREE_CODE (decl) == FUNCTION_DECL
2317 && ! TREE_ASM_WRITTEN (decl)
2318 && DECL_INITIAL (decl) != 0
2319 && (TREE_ADDRESSABLE (decl)
2320 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
216d5cdd 2321 && ! DECL_EXTERNAL (decl))
86ef2ef9
RK
2322 {
2323 temporary_allocation ();
2324 output_inline_function (decl);
f030d6e6 2325 permanent_allocation (1);
86ef2ef9 2326 }
4291d9c8 2327
ac266247
RS
2328 /* Warn about any function
2329 declared static but not defined.
2330 We don't warn about variables,
2331 because many programs have static variables
2332 that exist only to get some text into the object file. */
4291d9c8
RS
2333 if ((warn_unused
2334 || TREE_USED (decl)
2335 || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))))
ac266247 2336 && TREE_CODE (decl) == FUNCTION_DECL
4291d9c8 2337 && DECL_INITIAL (decl) == 0
216d5cdd 2338 && DECL_EXTERNAL (decl)
4291d9c8 2339 && ! TREE_PUBLIC (decl))
7d429c41 2340 {
aaf44ca2
RS
2341 /* This should be a pedwarn, except that there is
2342 no easy way to prevent it from happening when the
2343 name is used only inside a sizeof.
2344 This at least avoids being incorrect. */
2345 warning_with_decl (decl,
7d429c41
RS
2346 "`%s' declared `static' but never defined");
2347 /* This symbol is effectively an "extern" declaration now. */
2348 TREE_PUBLIC (decl) = 1;
2349 assemble_external (decl);
2350
2351 }
4291d9c8 2352 /* Warn about static fns or vars defined but not used,
7062b881
PB
2353 but not about inline functions or static consts
2354 since defining those in header files is normal practice. */
4291d9c8 2355 if (warn_unused
7062b881
PB
2356 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2357 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
0c20aabf 2358 && ! DECL_IN_SYSTEM_HEADER (decl)
216d5cdd 2359 && ! DECL_EXTERNAL (decl)
4291d9c8
RS
2360 && ! TREE_PUBLIC (decl)
2361 && ! TREE_USED (decl)
f2dabd38 2362 && ! DECL_REGISTER (decl)
4291d9c8
RS
2363 /* The TREE_USED bit for file-scope decls
2364 is kept in the identifier, to handle multiple
2365 external decls in different scopes. */
2366 && ! TREE_USED (DECL_NAME (decl)))
2367 warning_with_decl (decl, "`%s' defined but not used");
2368
2369#ifdef SDB_DEBUGGING_INFO
2370 /* The COFF linker can move initialized global vars to the end.
2371 And that can screw up the symbol ordering.
2372 By putting the symbols in that order to begin with,
2373 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2374 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2375 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2376 && DECL_RTL (decl) != 0)
2377 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2378
2379 /* Output COFF information for non-global
2380 file-scope initialized variables. */
2381 if (write_symbols == SDB_DEBUG
2382 && TREE_CODE (decl) == VAR_DECL
2383 && DECL_INITIAL (decl)
2384 && DECL_RTL (decl) != 0
2385 && GET_CODE (DECL_RTL (decl)) == MEM)
2386 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2387#endif /* SDB_DEBUGGING_INFO */
2388#ifdef DWARF_DEBUGGING_INFO
6dc42e49 2389 /* Output DWARF information for file-scope tentative data object
4291d9c8
RS
2390 declarations, file-scope (extern) function declarations (which
2391 had no corresponding body) and file-scope tagged type declarations
2392 and definitions which have not yet been forced out. */
2393
2394 if (write_symbols == DWARF_DEBUG
2395 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2396 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2397#endif
2398 }
2399 }
2400
2401 /* Do dbx symbols */
f246a305
RS
2402#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2403 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
4291d9c8
RS
2404 TIMEVAR (symout_time,
2405 {
2406 dbxout_finish (asm_out_file, main_input_filename);
2407 });
2408#endif
2409
2410#ifdef DWARF_DEBUGGING_INFO
2411 if (write_symbols == DWARF_DEBUG)
2412 TIMEVAR (symout_time,
2413 {
2414 dwarfout_finish ();
2415 });
2416#endif
2417
2418 /* Output some stuff at end of file if nec. */
2419
ca695ac9
JB
2420 if (!output_bytecode)
2421 {
2422 end_final (main_input_filename);
4291d9c8
RS
2423
2424#ifdef ASM_FILE_END
ca695ac9 2425 ASM_FILE_END (asm_out_file);
4291d9c8 2426#endif
ca695ac9 2427 }
4291d9c8 2428
4291d9c8
RS
2429 /* Language-specific end of compilation actions. */
2430
2431 lang_finish ();
2432
0207ea82
RK
2433 if (output_bytecode)
2434 bc_write_file (asm_out_file);
2435
4291d9c8
RS
2436 /* Close the dump files. */
2437
2438 if (flag_gen_aux_info)
2439 {
2440 fclose (aux_info_file);
2441 if (errorcount)
2442 unlink (aux_info_file_name);
2443 }
2444
2445 if (rtl_dump)
2446 fclose (rtl_dump_file);
2447
2448 if (jump_opt_dump)
2449 fclose (jump_opt_dump_file);
2450
2451 if (cse_dump)
2452 fclose (cse_dump_file);
2453
2454 if (loop_dump)
2455 fclose (loop_dump_file);
2456
2457 if (cse2_dump)
2458 fclose (cse2_dump_file);
2459
2460 if (flow_dump)
2461 fclose (flow_dump_file);
2462
2463 if (combine_dump)
2464 {
2465 dump_combine_total_stats (combine_dump_file);
2466 fclose (combine_dump_file);
2467 }
2468
2469 if (sched_dump)
2470 fclose (sched_dump_file);
2471
2472 if (local_reg_dump)
2473 fclose (local_reg_dump_file);
2474
2475 if (global_reg_dump)
2476 fclose (global_reg_dump_file);
2477
2478 if (sched2_dump)
2479 fclose (sched2_dump_file);
2480
2481 if (jump2_opt_dump)
2482 fclose (jump2_opt_dump_file);
2483
2484 if (dbr_sched_dump)
2485 fclose (dbr_sched_dump_file);
2486
2487#ifdef STACK_REGS
2488 if (stack_reg_dump)
2489 fclose (stack_reg_dump_file);
2490#endif
2491
2492 /* Close non-debugging input and output files. Take special care to note
2493 whether fclose returns an error, since the pages might still be on the
2494 buffer chain while the file is open. */
2495
2496 fclose (finput);
2497 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2498 fatal_io_error (asm_file_name);
2499
2500 /* Print the times. */
2501
2502 if (! quiet_flag)
2503 {
2504 fprintf (stderr,"\n");
2505 print_time ("parse", parse_time);
ca695ac9
JB
2506
2507 if (!output_bytecode)
2508 {
2509 print_time ("integration", integration_time);
2510 print_time ("jump", jump_time);
2511 print_time ("cse", cse_time);
2512 print_time ("loop", loop_time);
2513 print_time ("cse2", cse2_time);
2514 print_time ("flow", flow_time);
2515 print_time ("combine", combine_time);
2516 print_time ("sched", sched_time);
2517 print_time ("local-alloc", local_alloc_time);
2518 print_time ("global-alloc", global_alloc_time);
2519 print_time ("sched2", sched2_time);
2520 print_time ("dbranch", dbr_sched_time);
2521 print_time ("shorten-branch", shorten_branch_time);
2522 print_time ("stack-reg", stack_reg_time);
2523 print_time ("final", final_time);
2524 print_time ("varconst", varconst_time);
2525 print_time ("symout", symout_time);
2526 print_time ("dump", dump_time);
2527 }
4291d9c8
RS
2528 }
2529}
2530\f
2531/* This is called from various places for FUNCTION_DECL, VAR_DECL,
2532 and TYPE_DECL nodes.
2533
2534 This does nothing for local (non-static) variables.
2535 Otherwise, it sets up the RTL and outputs any assembler code
2536 (label definition, storage allocation and initialization).
2537
2538 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2539 the assembler symbol name to be used. TOP_LEVEL is nonzero
2540 if this declaration is not within a function. */
2541
2542void
2543rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2544 tree decl;
2545 char *asmspec;
2546 int top_level;
2547 int at_end;
2548{
2549 /* Declarations of variables, and of functions defined elsewhere. */
2550
928eb380
RS
2551/* The most obvious approach, to put an #ifndef around where
2552 this macro is used, doesn't work since it's inside a macro call. */
2553#ifndef ASM_FINISH_DECLARE_OBJECT
2554#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2555#endif
2556
4291d9c8
RS
2557 /* Forward declarations for nested functions are not "external",
2558 but we need to treat them as if they were. */
216d5cdd 2559 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
4291d9c8
RS
2560 || TREE_CODE (decl) == FUNCTION_DECL)
2561 TIMEVAR (varconst_time,
2562 {
2563 make_decl_rtl (decl, asmspec, top_level);
9a9a9643
RS
2564 /* Initialized extern variable exists to be replaced
2565 with its value, or represents something that will be
2566 output in another file. */
6dbf678a 2567 if (! (TREE_CODE (decl) == VAR_DECL
9a9a9643
RS
2568 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2569 && DECL_INITIAL (decl) != 0
5b272d50 2570 && DECL_INITIAL (decl) != error_mark_node))
6dbf678a
RS
2571 /* Don't output anything
2572 when a tentative file-scope definition is seen.
2573 But at end of compilation, do output code for them. */
2574 if (! (! at_end && top_level
2575 && (DECL_INITIAL (decl) == 0
9a9a9643 2576 || DECL_INITIAL (decl) == error_mark_node)))
8380e2f2 2577 assemble_variable (decl, top_level, at_end, 0);
5e10b3cc
RS
2578 if (decl == last_assemble_variable_decl)
2579 {
2580 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2581 top_level, at_end);
2582 }
4291d9c8 2583 });
216d5cdd 2584 else if (DECL_REGISTER (decl) && asmspec != 0)
4291d9c8
RS
2585 {
2586 if (decode_reg_name (asmspec) >= 0)
2587 {
2588 DECL_RTL (decl) = 0;
2589 make_decl_rtl (decl, asmspec, top_level);
2590 }
2591 else
2592 error ("invalid register name `%s' for register variable", asmspec);
2593 }
f246a305
RS
2594#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2595 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2596 && TREE_CODE (decl) == TYPE_DECL)
4291d9c8
RS
2597 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2598#endif
2599#ifdef SDB_DEBUGGING_INFO
2600 else if (write_symbols == SDB_DEBUG && top_level
2601 && TREE_CODE (decl) == TYPE_DECL)
2602 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2603#endif
2604}
2605
2606/* Called after finishing a record, union or enumeral type. */
2607
2608void
2609rest_of_type_compilation (type, toplev)
2610 tree type;
2611 int toplev;
2612{
f246a305
RS
2613#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2614 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
4291d9c8
RS
2615 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2616#endif
2617#ifdef SDB_DEBUGGING_INFO
2618 if (write_symbols == SDB_DEBUG)
2619 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2620#endif
2621}
2622
2623/* This is called from finish_function (within yyparse)
2624 after each top-level definition is parsed.
2625 It is supposed to compile that function or variable
2626 and output the assembler code for it.
2627 After we return, the tree storage is freed. */
2628
2629void
2630rest_of_compilation (decl)
2631 tree decl;
2632{
2633 register rtx insns;
2634 int start_time = get_run_time ();
2635 int tem;
2636 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2637 to be restored after we finish compiling the function
2638 (for use when compiling inline calls to this function). */
2639 tree saved_block_tree = 0;
8a958768
RS
2640 /* Likewise, for DECL_ARGUMENTS. */
2641 tree saved_arguments = 0;
ab40ad2b 2642 int failure = 0;
4291d9c8 2643
ca695ac9
JB
2644 if (output_bytecode)
2645 return;
2646
4291d9c8
RS
2647 /* If we are reconsidering an inline function
2648 at the end of compilation, skip the stuff for making it inline. */
2649
2650 if (DECL_SAVED_INSNS (decl) == 0)
2651 {
216d5cdd 2652 int specd = DECL_INLINE (decl);
4291d9c8
RS
2653 char *lose;
2654
2655 /* If requested, consider whether to make this function inline. */
2656 if (specd || flag_inline_functions)
2657 TIMEVAR (integration_time,
2658 {
2659 lose = function_cannot_inline_p (decl);
caa0eccd
JL
2660 /* If not optimzing, then make sure the DECL_INLINE
2661 bit is off. */
2662 if (lose || ! optimize)
4291d9c8
RS
2663 {
2664 if (warn_inline && specd)
2665 warning_with_decl (decl, lose);
216d5cdd 2666 DECL_INLINE (decl) = 0;
46dbb914
RS
2667 /* Don't really compile an extern inline function.
2668 If we can't make it inline, pretend
2669 it was only declared. */
2670 if (DECL_EXTERNAL (decl))
27937f46
RS
2671 {
2672 DECL_INITIAL (decl) = 0;
2673 goto exit_rest_of_compilation;
2674 }
4291d9c8
RS
2675 }
2676 else
216d5cdd 2677 DECL_INLINE (decl) = 1;
4291d9c8
RS
2678 });
2679
2680 insns = get_insns ();
2681
2682 /* Dump the rtl code if we are dumping rtl. */
2683
2684 if (rtl_dump)
2685 TIMEVAR (dump_time,
2686 {
2687 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2688 IDENTIFIER_POINTER (DECL_NAME (decl)));
2689 if (DECL_SAVED_INSNS (decl))
2690 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2691 print_rtl (rtl_dump_file, insns);
2692 fflush (rtl_dump_file);
2693 });
2694
2695 /* If function is inline, and we don't yet know whether to
2696 compile it by itself, defer decision till end of compilation.
2697 finish_compilation will call rest_of_compilation again
16411ea6
RK
2698 for those functions that need to be output. Also defer those
2699 functions that were marked inline but weren't inlined; they
2700 may never be used. */
4291d9c8 2701
16411ea6 2702 if ((specd || DECL_INLINE (decl))
4291d9c8
RS
2703 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2704 && ! flag_keep_inline_functions)
216d5cdd 2705 || DECL_EXTERNAL (decl)))
4291d9c8 2706 {
937522b5
RS
2707#ifdef DWARF_DEBUGGING_INFO
2708 /* Generate the DWARF info for the "abstract" instance
2709 of a function which we may later generate inlined and/or
2710 out-of-line instances of. */
2711 if (write_symbols == DWARF_DEBUG)
2712 {
2713 set_decl_abstract_flags (decl, 1);
2714 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2715 set_decl_abstract_flags (decl, 0);
2716 }
2717#endif
4291d9c8
RS
2718 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2719 goto exit_rest_of_compilation;
2720 }
2721
8a958768 2722 /* If we have to compile the function now, save its rtl and subdecls
4291d9c8 2723 so that its compilation will not affect what others get. */
216d5cdd 2724 if (DECL_INLINE (decl))
4291d9c8 2725 {
937522b5
RS
2726#ifdef DWARF_DEBUGGING_INFO
2727 /* Generate the DWARF info for the "abstract" instance of
2728 a function which we will generate an out-of-line instance
2729 of almost immediately (and which we may also later generate
2730 various inlined instances of). */
2731 if (write_symbols == DWARF_DEBUG)
2732 {
2733 set_decl_abstract_flags (decl, 1);
2734 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2735 set_decl_abstract_flags (decl, 0);
2736 }
2737#endif
4291d9c8 2738 saved_block_tree = DECL_INITIAL (decl);
8a958768 2739 saved_arguments = DECL_ARGUMENTS (decl);
4291d9c8
RS
2740 TIMEVAR (integration_time, save_for_inline_copying (decl));
2741 }
2742 }
2743
4291d9c8
RS
2744 TREE_ASM_WRITTEN (decl) = 1;
2745
2746 /* Now that integrate will no longer see our rtl, we need not distinguish
2747 between the return value of this function and the return value of called
2748 functions. */
2749 rtx_equal_function_value_matters = 0;
2750
32235b30
RS
2751 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2752 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
4291d9c8
RS
2753 {
2754 goto exit_rest_of_compilation;
2755 }
2756
2757 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2758 Note that that may have been done above, in save_for_inline_copying.
2759 The call to resume_temporary_allocation near the end of this function
2760 goes back to the usual state of affairs. */
2761
2762 rtl_in_current_obstack ();
2763
2764#ifdef FINALIZE_PIC
2765 /* If we are doing position-independent code generation, now
2766 is the time to output special prologues and epilogues.
2767 We do not want to do this earlier, because it just clutters
2768 up inline functions with meaningless insns. */
2769 if (flag_pic)
2770 FINALIZE_PIC;
2771#endif
2772
2773 insns = get_insns ();
2774
2775 /* Copy any shared structure that should not be shared. */
2776
2777 unshare_all_rtl (insns);
2778
2779 /* Instantiate all virtual registers. */
2780
2781 instantiate_virtual_regs (current_function_decl, get_insns ());
2782
2783 /* See if we have allocated stack slots that are not directly addressable.
2784 If so, scan all the insns and create explicit address computation
2785 for all references to such slots. */
2786/* fixup_stack_slots (); */
2787
2788 /* Do jump optimization the first time, if -opt.
2789 Also do it if -W, but in that case it doesn't change the rtl code,
2790 it only computes whether control can drop off the end of the function. */
2791
2792 if (optimize > 0 || extra_warnings || warn_return_type
8e158db4 2793 /* If function is `noreturn', we should warn if it tries to return. */
4291d9c8
RS
2794 || TREE_THIS_VOLATILE (decl))
2795 {
2796 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2797 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2798 }
2799
32235b30
RS
2800 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2801 if (rtl_dump_and_exit || flag_syntax_only)
2802 goto exit_rest_of_compilation;
2803
4291d9c8
RS
2804 /* Dump rtl code after jump, if we are doing that. */
2805
2806 if (jump_opt_dump)
2807 TIMEVAR (dump_time,
2808 {
2809 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2810 IDENTIFIER_POINTER (DECL_NAME (decl)));
2811 print_rtl (jump_opt_dump_file, insns);
2812 fflush (jump_opt_dump_file);
2813 });
2814
2815 /* Perform common subexpression elimination.
2816 Nonzero value from `cse_main' means that jumps were simplified
2817 and some code may now be unreachable, so do
2818 jump optimization again. */
2819
2820 if (cse_dump)
2821 TIMEVAR (dump_time,
2822 {
2823 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2824 IDENTIFIER_POINTER (DECL_NAME (decl)));
2825 });
2826
2827 if (optimize > 0)
2828 {
2829 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2830
2831 if (flag_thread_jumps)
2832 /* Hacks by tiemann & kenner. */
6f606d63 2833 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
4291d9c8
RS
2834
2835 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2836 0, cse_dump_file));
2837 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2838
2839 if (tem)
2840 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2841 }
2842
2843 /* Dump rtl code after cse, if we are doing that. */
2844
2845 if (cse_dump)
2846 TIMEVAR (dump_time,
2847 {
2848 print_rtl (cse_dump_file, insns);
2849 fflush (cse_dump_file);
2850 });
2851
2852 if (loop_dump)
2853 TIMEVAR (dump_time,
2854 {
2855 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2856 IDENTIFIER_POINTER (DECL_NAME (decl)));
2857 });
2858
2859 /* Move constant computations out of loops. */
2860
2861 if (optimize > 0)
2862 {
2863 TIMEVAR (loop_time,
2864 {
37366632 2865 loop_optimize (insns, loop_dump_file);
4291d9c8
RS
2866 });
2867 }
2868
2869 /* Dump rtl code after loop opt, if we are doing that. */
2870
2871 if (loop_dump)
2872 TIMEVAR (dump_time,
2873 {
2874 print_rtl (loop_dump_file, insns);
2875 fflush (loop_dump_file);
2876 });
2877
2878 if (cse2_dump)
2879 TIMEVAR (dump_time,
2880 {
2881 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2882 IDENTIFIER_POINTER (DECL_NAME (decl)));
2883 });
2884
2885 if (optimize > 0 && flag_rerun_cse_after_loop)
2886 {
44333223
JL
2887 /* Running another jump optimization pass before the second
2888 cse pass sometimes simplifies the RTL enough to allow
9e9b48a4
DE
2889 the second CSE pass to do a better job. Jump_optimize can change
2890 max_reg_num so we must rerun reg_scan afterwards.
2891 ??? Rework to not call reg_scan so often. */
2892 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
44333223 2893 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
4291d9c8 2894
9e9b48a4 2895 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
4291d9c8
RS
2896 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2897 1, cse2_dump_file));
2898 if (tem)
2899 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2900 }
2901
2902 if (optimize > 0 && flag_thread_jumps)
2903 /* This pass of jump threading straightens out code
2904 that was kinked by loop optimization. */
2905 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2906
2907 /* Dump rtl code after cse, if we are doing that. */
2908
2909 if (cse2_dump)
2910 TIMEVAR (dump_time,
2911 {
2912 print_rtl (cse2_dump_file, insns);
2913 fflush (cse2_dump_file);
2914 });
2915
2916 /* We are no longer anticipating cse in this function, at least. */
2917
2918 cse_not_expected = 1;
2919
2920 /* Now we choose between stupid (pcc-like) register allocation
2921 (if we got the -noreg switch and not -opt)
2922 and smart register allocation. */
2923
2924 if (optimize > 0) /* Stupid allocation probably won't work */
2925 obey_regdecls = 0; /* if optimizations being done. */
2926
2927 regclass_init ();
2928
2929 /* Print function header into flow dump now
2930 because doing the flow analysis makes some of the dump. */
2931
2932 if (flow_dump)
2933 TIMEVAR (dump_time,
2934 {
2935 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2936 IDENTIFIER_POINTER (DECL_NAME (decl)));
2937 });
2938
2939 if (obey_regdecls)
2940 {
2941 TIMEVAR (flow_time,
2942 {
2943 regclass (insns, max_reg_num ());
2944 stupid_life_analysis (insns, max_reg_num (),
2945 flow_dump_file);
2946 });
2947 }
2948 else
2949 {
2950 /* Do control and data flow analysis,
2951 and write some of the results to dump file. */
2952
2953 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2954 flow_dump_file));
2955 if (warn_uninitialized)
2956 {
2957 uninitialized_vars_warning (DECL_INITIAL (decl));
2958 setjmp_args_warning ();
2959 }
2960 }
2961
2962 /* Dump rtl after flow analysis. */
2963
2964 if (flow_dump)
2965 TIMEVAR (dump_time,
2966 {
2967 print_rtl (flow_dump_file, insns);
2968 fflush (flow_dump_file);
2969 });
2970
2971 /* If -opt, try combining insns through substitution. */
2972
2973 if (optimize > 0)
2974 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2975
2976 /* Dump rtl code after insn combination. */
2977
2978 if (combine_dump)
2979 TIMEVAR (dump_time,
2980 {
2981 fprintf (combine_dump_file, "\n;; Function %s\n\n",
2982 IDENTIFIER_POINTER (DECL_NAME (decl)));
2983 dump_combine_stats (combine_dump_file);
2984 print_rtl (combine_dump_file, insns);
2985 fflush (combine_dump_file);
2986 });
2987
2988 /* Print function header into sched dump now
2989 because doing the sched analysis makes some of the dump. */
2990
2991 if (sched_dump)
2992 TIMEVAR (dump_time,
2993 {
2994 fprintf (sched_dump_file, "\n;; Function %s\n\n",
2995 IDENTIFIER_POINTER (DECL_NAME (decl)));
2996 });
2997
2998 if (optimize > 0 && flag_schedule_insns)
2999 {
3000 /* Do control and data sched analysis,
3001 and write some of the results to dump file. */
3002
3003 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
3004 }
3005
3006 /* Dump rtl after instruction scheduling. */
3007
3008 if (sched_dump)
3009 TIMEVAR (dump_time,
3010 {
3011 print_rtl (sched_dump_file, insns);
3012 fflush (sched_dump_file);
3013 });
3014
3015 /* Unless we did stupid register allocation,
3016 allocate pseudo-regs that are used only within 1 basic block. */
3017
3018 if (!obey_regdecls)
3019 TIMEVAR (local_alloc_time,
3020 {
3021 regclass (insns, max_reg_num ());
3022 local_alloc ();
3023 });
3024
3025 /* Dump rtl code after allocating regs within basic blocks. */
3026
3027 if (local_reg_dump)
3028 TIMEVAR (dump_time,
3029 {
3030 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
3031 IDENTIFIER_POINTER (DECL_NAME (decl)));
3032 dump_flow_info (local_reg_dump_file);
3033 dump_local_alloc (local_reg_dump_file);
3034 print_rtl (local_reg_dump_file, insns);
3035 fflush (local_reg_dump_file);
3036 });
3037
3038 if (global_reg_dump)
3039 TIMEVAR (dump_time,
3040 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
3041 IDENTIFIER_POINTER (DECL_NAME (decl))));
3042
3043 /* Unless we did stupid register allocation,
3044 allocate remaining pseudo-regs, then do the reload pass
3045 fixing up any insns that are invalid. */
3046
3047 TIMEVAR (global_alloc_time,
3048 {
3049 if (!obey_regdecls)
37366632 3050 failure = global_alloc (global_reg_dump_file);
4291d9c8 3051 else
37366632 3052 failure = reload (insns, 0, global_reg_dump_file);
4291d9c8
RS
3053 });
3054
3055 if (global_reg_dump)
3056 TIMEVAR (dump_time,
3057 {
3058 dump_global_regs (global_reg_dump_file);
3059 print_rtl (global_reg_dump_file, insns);
3060 fflush (global_reg_dump_file);
3061 });
3062
ab40ad2b
RS
3063 if (failure)
3064 goto exit_rest_of_compilation;
3065
4291d9c8
RS
3066 reload_completed = 1;
3067
bdac5f58
TW
3068 /* On some machines, the prologue and epilogue code, or parts thereof,
3069 can be represented as RTL. Doing so lets us schedule insns between
3070 it and the rest of the code and also allows delayed branch
3071 scheduling to operate in the epilogue. */
3072
3073 thread_prologue_and_epilogue_insns (insns);
3074
4291d9c8
RS
3075 if (optimize > 0 && flag_schedule_insns_after_reload)
3076 {
3077 if (sched2_dump)
3078 TIMEVAR (dump_time,
3079 {
3080 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
3081 IDENTIFIER_POINTER (DECL_NAME (decl)));
3082 });
3083
3084 /* Do control and data sched analysis again,
3085 and write some more of the results to dump file. */
3086
3087 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
3088
3089 /* Dump rtl after post-reorder instruction scheduling. */
3090
3091 if (sched2_dump)
3092 TIMEVAR (dump_time,
3093 {
3094 print_rtl (sched2_dump_file, insns);
3095 fflush (sched2_dump_file);
3096 });
3097 }
3098
3099#ifdef LEAF_REGISTERS
3100 leaf_function = 0;
3101 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
ab40ad2b 3102 leaf_function = 1;
4291d9c8
RS
3103#endif
3104
3105 /* One more attempt to remove jumps to .+1
3106 left by dead-store-elimination.
3107 Also do cross-jumping this time
3108 and delete no-op move insns. */
3109
3110 if (optimize > 0)
3111 {
3112 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3113 }
3114
3115 /* Dump rtl code after jump, if we are doing that. */
3116
3117 if (jump2_opt_dump)
3118 TIMEVAR (dump_time,
3119 {
3120 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
3121 IDENTIFIER_POINTER (DECL_NAME (decl)));
3122 print_rtl (jump2_opt_dump_file, insns);
3123 fflush (jump2_opt_dump_file);
3124 });
3125
2c65021a
RK
3126 /* If a machine dependent reorganization is needed, call it. */
3127#ifdef MACHINE_DEPENDENT_REORG
3128 MACHINE_DEPENDENT_REORG (insns);
3129#endif
3130
4291d9c8
RS
3131 /* If a scheduling pass for delayed branches is to be done,
3132 call the scheduling code. */
3133
3134#ifdef DELAY_SLOTS
3135 if (optimize > 0 && flag_delayed_branch)
3136 {
3137 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3138 if (dbr_sched_dump)
3139 {
3140 TIMEVAR (dump_time,
3141 {
3142 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
3143 IDENTIFIER_POINTER (DECL_NAME (decl)));
3144 print_rtl (dbr_sched_dump_file, insns);
3145 fflush (dbr_sched_dump_file);
3146 });
3147 }
3148 }
3149#endif
3150
3151 if (optimize > 0)
3152 /* Shorten branches. */
3153 TIMEVAR (shorten_branch_time,
3154 {
3155 shorten_branches (get_insns ());
3156 });
3157
3158#ifdef STACK_REGS
3159 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3160 if (stack_reg_dump)
3161 {
3162 TIMEVAR (dump_time,
3163 {
3164 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
3165 IDENTIFIER_POINTER (DECL_NAME (decl)));
3166 print_rtl (stack_reg_dump_file, insns);
3167 fflush (stack_reg_dump_file);
3168 });
3169 }
3170#endif
3171
3172 /* Now turn the rtl into assembler code. */
3173
3174 TIMEVAR (final_time,
3175 {
3176 rtx x;
3177 char *fnname;
3178
3179 /* Get the function's name, as described by its RTL.
3180 This may be different from the DECL_NAME name used
3181 in the source file. */
3182
3183 x = DECL_RTL (decl);
3184 if (GET_CODE (x) != MEM)
3185 abort ();
3186 x = XEXP (x, 0);
3187 if (GET_CODE (x) != SYMBOL_REF)
3188 abort ();
3189 fnname = XSTR (x, 0);
3190
3191 assemble_start_function (decl, fnname);
3192 final_start_function (insns, asm_out_file, optimize);
3193 final (insns, asm_out_file, optimize, 0);
3194 final_end_function (insns, asm_out_file, optimize);
3195 assemble_end_function (decl, fnname);
3196 fflush (asm_out_file);
3197 });
3198
3199 /* Write DBX symbols if requested */
3200
3201 /* Note that for those inline functions where we don't initially
3202 know for certain that we will be generating an out-of-line copy,
3203 the first invocation of this routine (rest_of_compilation) will
3204 skip over this code by doing a `goto exit_rest_of_compilation;'.
3205 Later on, finish_compilation will call rest_of_compilation again
3206 for those inline functions that need to have out-of-line copies
3207 generated. During that call, we *will* be routed past here. */
3208
3209#ifdef DBX_DEBUGGING_INFO
3210 if (write_symbols == DBX_DEBUG)
3211 TIMEVAR (symout_time, dbxout_function (decl));
3212#endif
3213
3214#ifdef DWARF_DEBUGGING_INFO
3215 if (write_symbols == DWARF_DEBUG)
3216 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3217#endif
3218
3219 exit_rest_of_compilation:
3220
f246a305
RS
3221 /* In case the function was not output,
3222 don't leave any temporary anonymous types
3223 queued up for sdb output. */
3224#ifdef SDB_DEBUGGING_INFO
3225 if (write_symbols == SDB_DEBUG)
37366632 3226 sdbout_types (NULL_TREE);
f246a305
RS
3227#endif
3228
8a958768
RS
3229 /* Put back the tree of subblocks and list of arguments
3230 from before we copied them.
4291d9c8
RS
3231 Code generation and the output of debugging info may have modified
3232 the copy, but the original is unchanged. */
3233
3234 if (saved_block_tree != 0)
3235 DECL_INITIAL (decl) = saved_block_tree;
8a958768
RS
3236 if (saved_arguments != 0)
3237 DECL_ARGUMENTS (decl) = saved_arguments;
4291d9c8
RS
3238
3239 reload_completed = 0;
3240
3241 /* Clear out the real_constant_chain before some of the rtx's
3242 it runs through become garbage. */
3243
3244 clear_const_double_mem ();
3245
3246 /* Cancel the effect of rtl_in_current_obstack. */
3247
3248 resume_temporary_allocation ();
3249
3250 /* The parsing time is all the time spent in yyparse
3251 *except* what is spent in this function. */
3252
3253 parse_time -= get_run_time () - start_time;
3254}
3255\f
3256/* Entry point of cc1/c++. Decode command args, then call compile_file.
3257 Exit code is 35 if can't open files, 34 if fatal error,
3258 33 if had nonfatal errors, else success. */
3259
3260int
3261main (argc, argv, envp)
3262 int argc;
3263 char **argv;
3264 char **envp;
3265{
3266 register int i;
3267 char *filename = 0;
3268 int flag_print_mem = 0;
3269 int version_flag = 0;
3270 char *p;
3271
3272 /* save in case md file wants to emit args as a comment. */
3273 save_argc = argc;
3274 save_argv = argv;
3275
3276 p = argv[0] + strlen (argv[0]);
3277 while (p != argv[0] && p[-1] != '/') --p;
3278 progname = p;
3279
3280#ifdef RLIMIT_STACK
3281 /* Get rid of any avoidable limit on stack size. */
3282 {
3283 struct rlimit rlim;
3284
3285 /* Set the stack limit huge so that alloca does not fail. */
3286 getrlimit (RLIMIT_STACK, &rlim);
3287 rlim.rlim_cur = rlim.rlim_max;
3288 setrlimit (RLIMIT_STACK, &rlim);
3289 }
3290#endif /* RLIMIT_STACK */
3291
3292 signal (SIGFPE, float_signal);
3293
935d4b07 3294#ifdef SIGPIPE
4291d9c8 3295 signal (SIGPIPE, pipe_closed);
935d4b07 3296#endif
4291d9c8
RS
3297
3298 decl_printable_name = decl_name;
3299 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3300
3301 /* Initialize whether `char' is signed. */
3302 flag_signed_char = DEFAULT_SIGNED_CHAR;
3303#ifdef DEFAULT_SHORT_ENUMS
3304 /* Initialize how much space enums occupy, by default. */
3305 flag_short_enums = DEFAULT_SHORT_ENUMS;
3306#endif
3307
3308 /* Scan to see what optimization level has been specified. That will
3309 determine the default value of many flags. */
3310 for (i = 1; i < argc; i++)
3311 {
3312 if (!strcmp (argv[i], "-O"))
3313 {
3314 optimize = 1;
3315 }
3316 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3317 {
3318 /* Handle -O2, -O3, -O69, ... */
3319 char *p = &argv[i][2];
3320 int c;
3321
3322 while (c = *p++)
3323 if (! (c >= '0' && c <= '9'))
3324 break;
3325 if (c == 0)
3326 optimize = atoi (&argv[i][2]);
3327 }
3328 }
3329
3330 obey_regdecls = (optimize == 0);
f246a305
RS
3331 if (optimize == 0)
3332 {
3333 flag_no_inline = 1;
3334 warn_inline = 0;
3335 }
4291d9c8
RS
3336
3337 if (optimize >= 1)
3338 {
6731a3e3 3339 flag_defer_pop = 1;
4291d9c8
RS
3340 flag_thread_jumps = 1;
3341#ifdef DELAY_SLOTS
3342 flag_delayed_branch = 1;
7e89c3a3
RK
3343#endif
3344#ifdef CAN_DEBUG_WITHOUT_FP
3345 flag_omit_frame_pointer = 1;
4291d9c8
RS
3346#endif
3347 }
3348
3349 if (optimize >= 2)
3350 {
3351 flag_cse_follow_jumps = 1;
8b3686ed 3352 flag_cse_skip_blocks = 1;
4291d9c8
RS
3353 flag_expensive_optimizations = 1;
3354 flag_strength_reduce = 1;
3355 flag_rerun_cse_after_loop = 1;
ac266247 3356 flag_caller_saves = 1;
4291d9c8
RS
3357#ifdef INSN_SCHEDULING
3358 flag_schedule_insns = 1;
3359 flag_schedule_insns_after_reload = 1;
3360#endif
3361 }
3362
7e89c3a3
RK
3363 if (optimize >= 3)
3364 {
3365 flag_inline_functions = 1;
3366 }
3367
4291d9c8
RS
3368#ifdef OPTIMIZATION_OPTIONS
3369 /* Allow default optimizations to be specified on a per-machine basis. */
3370 OPTIMIZATION_OPTIONS (optimize);
3371#endif
3372
3373 /* Initialize register usage now so switches may override. */
3374 init_reg_sets ();
3375
3376 target_flags = 0;
3377 set_target_switch ("");
3378
3379 for (i = 1; i < argc; i++)
3380 {
b99933c7
RS
3381 int j;
3382 /* If this is a language-specific option,
3383 decode it in a language-specific way. */
3384 for (j = 0; lang_options[j] != 0; j++)
3385 if (!strncmp (argv[i], lang_options[j],
3386 strlen (lang_options[j])))
3387 break;
3388 if (lang_options[j] != 0)
3389 /* If the option is valid for *some* language,
3390 treat it as valid even if this language doesn't understand it. */
3391 lang_decode_option (argv[i]);
3392 else if (argv[i][0] == '-' && argv[i][1] != 0)
4291d9c8
RS
3393 {
3394 register char *str = argv[i] + 1;
3395 if (str[0] == 'Y')
3396 str++;
3397
3398 if (str[0] == 'm')
3399 set_target_switch (&str[1]);
3400 else if (!strcmp (str, "dumpbase"))
3401 {
3402 dump_base_name = argv[++i];
3403 }
3404 else if (str[0] == 'd')
3405 {
3406 register char *p = &str[1];
3407 while (*p)
3408 switch (*p++)
3409 {
3410 case 'a':
3411 combine_dump = 1;
3412 dbr_sched_dump = 1;
3413 flow_dump = 1;
3414 global_reg_dump = 1;
3415 jump_opt_dump = 1;
3416 jump2_opt_dump = 1;
3417 local_reg_dump = 1;
3418 loop_dump = 1;
3419 rtl_dump = 1;
3420 cse_dump = 1, cse2_dump = 1;
3421 sched_dump = 1;
3422 sched2_dump = 1;
3423 stack_reg_dump = 1;
3424 break;
3425 case 'k':
3426 stack_reg_dump = 1;
3427 break;
3428 case 'c':
3429 combine_dump = 1;
3430 break;
3431 case 'd':
3432 dbr_sched_dump = 1;
3433 break;
3434 case 'f':
3435 flow_dump = 1;
3436 break;
3437 case 'g':
3438 global_reg_dump = 1;
3439 break;
3440 case 'j':
3441 jump_opt_dump = 1;
3442 break;
3443 case 'J':
3444 jump2_opt_dump = 1;
3445 break;
3446 case 'l':
3447 local_reg_dump = 1;
3448 break;
3449 case 'L':
3450 loop_dump = 1;
3451 break;
3452 case 'm':
3453 flag_print_mem = 1;
3454 break;
3455 case 'p':
3456 flag_print_asm_name = 1;
3457 break;
3458 case 'r':
3459 rtl_dump = 1;
3460 break;
3461 case 's':
3462 cse_dump = 1;
3463 break;
3464 case 't':
3465 cse2_dump = 1;
3466 break;
3467 case 'S':
3468 sched_dump = 1;
3469 break;
3470 case 'R':
3471 sched2_dump = 1;
3472 break;
3473 case 'y':
3474 set_yydebug (1);
3475 break;
3476
3477 case 'x':
3478 rtl_dump_and_exit = 1;
3479 break;
3480 }
3481 }
3482 else if (str[0] == 'f')
3483 {
4291d9c8
RS
3484 register char *p = &str[1];
3485 int found = 0;
3486
3487 /* Some kind of -f option.
3488 P's value is the option sans `-f'.
3489 Search for it in the table of options. */
3490
3491 for (j = 0;
3492 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3493 j++)
3494 {
3495 if (!strcmp (p, f_options[j].string))
3496 {
3497 *f_options[j].variable = f_options[j].on_value;
3498 /* A goto here would be cleaner,
3499 but breaks the vax pcc. */
3500 found = 1;
3501 }
3502 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3503 && ! strcmp (p+3, f_options[j].string))
3504 {
3505 *f_options[j].variable = ! f_options[j].on_value;
3506 found = 1;
3507 }
3508 }
3509
3510 if (found)
3511 ;
3512 else if (!strncmp (p, "fixed-", 6))
3513 fix_register (&p[6], 1, 1);
3514 else if (!strncmp (p, "call-used-", 10))
3515 fix_register (&p[10], 0, 1);
3516 else if (!strncmp (p, "call-saved-", 11))
3517 fix_register (&p[11], 0, 0);
b99933c7 3518 else
4291d9c8
RS
3519 error ("Invalid option `%s'", argv[i]);
3520 }
3521 else if (str[0] == 'O')
3522 {
3523 register char *p = str+1;
3524 while (*p && *p >= '0' && *p <= '9')
3525 p++;
3526 if (*p == '\0')
3527 ;
3528 else
3529 error ("Invalid option `%s'", argv[i]);
3530 }
3531 else if (!strcmp (str, "pedantic"))
3532 pedantic = 1;
3533 else if (!strcmp (str, "pedantic-errors"))
3534 flag_pedantic_errors = pedantic = 1;
4291d9c8
RS
3535 else if (!strcmp (str, "quiet"))
3536 quiet_flag = 1;
3537 else if (!strcmp (str, "version"))
3538 version_flag = 1;
3539 else if (!strcmp (str, "w"))
3540 inhibit_warnings = 1;
3541 else if (!strcmp (str, "W"))
3542 {
3543 extra_warnings = 1;
fa1a4543
RS
3544 /* We save the value of warn_uninitialized, since if they put
3545 -Wuninitialized on the command line, we need to generate a
3546 warning about not using it without also specifying -O. */
3547 if (warn_uninitialized != 1)
3548 warn_uninitialized = 2;
4291d9c8
RS
3549 }
3550 else if (str[0] == 'W')
3551 {
4291d9c8
RS
3552 register char *p = &str[1];
3553 int found = 0;
3554
3555 /* Some kind of -W option.
3556 P's value is the option sans `-W'.
3557 Search for it in the table of options. */
3558
3559 for (j = 0;
3560 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3561 j++)
3562 {
3563 if (!strcmp (p, W_options[j].string))
3564 {
3565 *W_options[j].variable = W_options[j].on_value;
3566 /* A goto here would be cleaner,
3567 but breaks the vax pcc. */
3568 found = 1;
3569 }
3570 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3571 && ! strcmp (p+3, W_options[j].string))
3572 {
3573 *W_options[j].variable = ! W_options[j].on_value;
3574 found = 1;
3575 }
3576 }
3577
3578 if (found)
3579 ;
3580 else if (!strncmp (p, "id-clash-", 9))
3581 {
3582 char *endp = p + 9;
3583
3584 while (*endp)
3585 {
3586 if (*endp >= '0' && *endp <= '9')
3587 endp++;
3588 else
7085b873
RS
3589 {
3590 error ("Invalid option `%s'", argv[i]);
3591 goto id_clash_lose;
3592 }
4291d9c8
RS
3593 }
3594 warn_id_clash = 1;
3595 id_clash_len = atoi (str + 10);
7085b873 3596 id_clash_lose: ;
4291d9c8 3597 }
b51e9c62
RK
3598 else if (!strncmp (p, "larger-than-", 12))
3599 {
3600 char *endp = p + 12;
3601
3602 while (*endp)
3603 {
3604 if (*endp >= '0' && *endp <= '9')
3605 endp++;
3606 else
3607 {
3608 error ("Invalid option `%s'", argv[i]);
3609 goto larger_than_lose;
3610 }
3611 }
3612 warn_larger_than = 1;
3613 larger_than_size = atoi (str + 13);
3614 larger_than_lose: ;
3615 }
4291d9c8
RS
3616 else
3617 error ("Invalid option `%s'", argv[i]);
3618 }
3619 else if (!strcmp (str, "p"))
ca695ac9
JB
3620 {
3621 if (!output_bytecode)
3622 profile_flag = 1;
3623 else
3624 error ("profiling not supported in bytecode compilation");
3625 }
4291d9c8
RS
3626 else if (!strcmp (str, "a"))
3627 {
3628#if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3629 warning ("`-a' option (basic block profile) not supported");
3630#else
3631 profile_block_flag = 1;
3632#endif
3633 }
3634 else if (str[0] == 'g')
3635 {
3636 char *p = str + 1;
3637 char *q;
3638 unsigned len;
3639 unsigned level;
3640
3641 while (*p && (*p < '0' || *p > '9'))
3642 p++;
3643 len = p - str;
3644 q = p;
3645 while (*q && (*q >= '0' && *q <= '9'))
3646 q++;
3647 if (*p)
3648 level = atoi (p);
3649 else
3650 level = 2; /* default debugging info level */
3651 if (*q || level > 3)
3652 {
3653 warning ("invalid debug level specification in option: `-%s'",
3654 str);
3655 warning ("no debugging information will be generated");
3656 level = 0;
3657 }
3658
3659 /* If more than one debugging type is supported,
3660 you must define PREFERRED_DEBUGGING_TYPE
3661 to choose a format in a system-dependent way. */
4d7e336b
RS
3662 /* This is one long line cause VAXC can't handle a \-newline. */
3663#if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
4291d9c8
RS
3664#ifdef PREFERRED_DEBUGGING_TYPE
3665 if (!strncmp (str, "ggdb", len))
3666 write_symbols = PREFERRED_DEBUGGING_TYPE;
3667#else /* no PREFERRED_DEBUGGING_TYPE */
3668You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3669#endif /* no PREFERRED_DEBUGGING_TYPE */
3670#endif /* More than one debugger format enabled. */
3671#ifdef DBX_DEBUGGING_INFO
3672 if (write_symbols != NO_DEBUG)
3673 ;
3674 else if (!strncmp (str, "ggdb", len))
3675 write_symbols = DBX_DEBUG;
3676 else if (!strncmp (str, "gstabs", len))
3677 write_symbols = DBX_DEBUG;
efa89fb3
RS
3678 else if (!strncmp (str, "gstabs+", len))
3679 write_symbols = DBX_DEBUG;
4291d9c8
RS
3680
3681 /* Always enable extensions for -ggdb or -gstabs+,
3682 always disable for -gstabs.
3683 For plain -g, use system-specific default. */
3684 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3685 && len >= 2)
a53d0bcc 3686 use_gnu_debug_info_extensions = 1;
166792f0
RS
3687 else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
3688 && len >= 7)
a53d0bcc 3689 use_gnu_debug_info_extensions = 1;
4291d9c8
RS
3690 else if (write_symbols == DBX_DEBUG
3691 && !strncmp (str, "gstabs", len) && len >= 2)
a53d0bcc 3692 use_gnu_debug_info_extensions = 0;
4291d9c8 3693 else
a53d0bcc 3694 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
4291d9c8
RS
3695#endif /* DBX_DEBUGGING_INFO */
3696#ifdef DWARF_DEBUGGING_INFO
3697 if (write_symbols != NO_DEBUG)
3698 ;
a53d0bcc
RS
3699 else if (!strncmp (str, "g", len))
3700 write_symbols = DWARF_DEBUG;
4291d9c8
RS
3701 else if (!strncmp (str, "ggdb", len))
3702 write_symbols = DWARF_DEBUG;
4291d9c8
RS
3703 else if (!strncmp (str, "gdwarf", len))
3704 write_symbols = DWARF_DEBUG;
a53d0bcc
RS
3705
3706 /* Always enable extensions for -ggdb or -gdwarf+,
3707 always disable for -gdwarf.
3708 For plain -g, use system-specific default. */
3709 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3710 && len >= 2)
3711 use_gnu_debug_info_extensions = 1;
3712 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3713 use_gnu_debug_info_extensions = 1;
3714 else if (write_symbols == DWARF_DEBUG
3715 && !strncmp (str, "gdwarf", len) && len >= 2)
3716 use_gnu_debug_info_extensions = 0;
3717 else
3718 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
4291d9c8
RS
3719#endif
3720#ifdef SDB_DEBUGGING_INFO
3721 if (write_symbols != NO_DEBUG)
3722 ;
a53d0bcc
RS
3723 else if (!strncmp (str, "g", len))
3724 write_symbols = SDB_DEBUG;
3725 else if (!strncmp (str, "gdb", len))
4291d9c8
RS
3726 write_symbols = SDB_DEBUG;
3727 else if (!strncmp (str, "gcoff", len))
3728 write_symbols = SDB_DEBUG;
3729#endif /* SDB_DEBUGGING_INFO */
f246a305
RS
3730#ifdef XCOFF_DEBUGGING_INFO
3731 if (write_symbols != NO_DEBUG)
3732 ;
a53d0bcc
RS
3733 else if (!strncmp (str, "g", len))
3734 write_symbols = XCOFF_DEBUG;
f246a305
RS
3735 else if (!strncmp (str, "ggdb", len))
3736 write_symbols = XCOFF_DEBUG;
3737 else if (!strncmp (str, "gxcoff", len))
3738 write_symbols = XCOFF_DEBUG;
3739
a53d0bcc 3740 /* Always enable extensions for -ggdb or -gxcoff+,
f246a305
RS
3741 always disable for -gxcoff.
3742 For plain -g, use system-specific default. */
3743 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3744 && len >= 2)
a53d0bcc
RS
3745 use_gnu_debug_info_extensions = 1;
3746 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3747 use_gnu_debug_info_extensions = 1;
a56addeb 3748 else if (write_symbols == XCOFF_DEBUG
f246a305 3749 && !strncmp (str, "gxcoff", len) && len >= 2)
a53d0bcc 3750 use_gnu_debug_info_extensions = 0;
f246a305 3751 else
a53d0bcc 3752 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
f246a305 3753#endif
4291d9c8
RS
3754 if (write_symbols == NO_DEBUG)
3755 warning ("`-%s' option not supported on this version of GCC", str);
3756 else if (level == 0)
3757 write_symbols = NO_DEBUG;
3758 else
d68c507d 3759 debug_info_level = (enum debug_info_level) level;
4291d9c8
RS
3760 }
3761 else if (!strcmp (str, "o"))
3762 {
3763 asm_file_name = argv[++i];
3764 }
3765 else if (str[0] == 'G')
3766 {
3767 g_switch_set = TRUE;
3768 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3769 }
f246a305
RS
3770 else if (!strncmp (str, "aux-info", 8))
3771 {
3772 flag_gen_aux_info = 1;
3773 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3774 }
4291d9c8
RS
3775 else
3776 error ("Invalid option `%s'", argv[i]);
3777 }
3778 else if (argv[i][0] == '+')
b99933c7 3779 error ("Invalid option `%s'", argv[i]);
4291d9c8
RS
3780 else
3781 filename = argv[i];
3782 }
3783
ca695ac9
JB
3784 /* Initialize for bytecode output. A good idea to do this as soon as
3785 possible after the "-f" options have been parsed. */
3786 if (output_bytecode)
3787 {
3788#ifndef TARGET_SUPPORTS_BYTECODE
3789 /* Just die with a fatal error if not supported */
0207ea82 3790 fatal ("-fbytecode not supporter for this target");
ca695ac9
JB
3791#else
3792 bc_initialize ();
3793#endif
3794 }
3795
f246a305
RS
3796 if (optimize == 0)
3797 {
a2468e45
BK
3798 /* Inlining does not work if not optimizing,
3799 so force it not to be done. */
f246a305
RS
3800 flag_no_inline = 1;
3801 warn_inline = 0;
a2468e45
BK
3802
3803 /* The c_decode_option and lang_decode_option functions set
3804 this to `2' if -Wall is used, so we can avoid giving out
3805 lots of errors for people who don't realize what -Wall does. */
3806 if (warn_uninitialized == 1)
3807 warning ("-Wuninitialized is not supported without -O");
f246a305
RS
3808 }
3809
7877bbb3
RS
3810#if defined(DWARF_DEBUGGING_INFO)
3811 if (write_symbols == DWARF_DEBUG
3812 && strcmp (language_string, "GNU C++") == 0)
3813 {
2b5ddaab 3814 warning ("-g option not supported for C++ on SVR4 systems");
7877bbb3
RS
3815 write_symbols = NO_DEBUG;
3816 }
3817#endif /* defined(DWARF_DEBUGGING_INFO) */
3818
4291d9c8
RS
3819#ifdef OVERRIDE_OPTIONS
3820 /* Some machines may reject certain combinations of options. */
3821 OVERRIDE_OPTIONS;
3822#endif
3823
3824 /* Unrolling all loops implies that standard loop unrolling must also
3825 be done. */
3826 if (flag_unroll_all_loops)
3827 flag_unroll_loops = 1;
3828 /* Loop unrolling requires that strength_reduction be on also. Silently
3829 turn on strength reduction here if it isn't already on. Also, the loop
3830 unrolling code assumes that cse will be run after loop, so that must
3831 be turned on also. */
3832 if (flag_unroll_loops)
3833 {
3834 flag_strength_reduce = 1;
3835 flag_rerun_cse_after_loop = 1;
3836 }
3837
3838 /* Warn about options that are not supported on this machine. */
3839#ifndef INSN_SCHEDULING
3840 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3841 warning ("instruction scheduling not supported on this target machine");
3842#endif
3843#ifndef DELAY_SLOTS
3844 if (flag_delayed_branch)
3845 warning ("this target machine does not have delayed branches");
3846#endif
3847
3848 /* If we are in verbose mode, write out the version and maybe all the
3849 option flags in use. */
3850 if (version_flag)
3851 {
3852 fprintf (stderr, "%s version %s", language_string, version_string);
3853#ifdef TARGET_VERSION
3854 TARGET_VERSION;
3855#endif
3856#ifdef __GNUC__
3857#ifndef __VERSION__
3858#define __VERSION__ "[unknown]"
3859#endif
3860 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3861#else
3862 fprintf (stderr, " compiled by CC.\n");
3863#endif
3864 if (! quiet_flag)
3865 print_switch_values ();
3866 }
3867
4291d9c8
RS
3868 compile_file (filename);
3869
a56addeb 3870#ifndef OS2
4291d9c8
RS
3871#ifndef VMS
3872 if (flag_print_mem)
3873 {
3874 char *lim = (char *) sbrk (0);
3875
3876 fprintf (stderr, "Data size %d.\n",
b61b1c91 3877 lim - (char *) &environ);
4291d9c8
RS
3878 fflush (stderr);
3879
3880#ifdef USG
3881 system ("ps -l 1>&2");
3882#else /* not USG */
3883 system ("ps v");
3884#endif /* not USG */
3885 }
3886#endif /* not VMS */
a56addeb 3887#endif /* not OS2 */
4291d9c8
RS
3888
3889 if (errorcount)
3890 exit (FATAL_EXIT_CODE);
3891 if (sorrycount)
3892 exit (FATAL_EXIT_CODE);
3893 exit (SUCCESS_EXIT_CODE);
3894 return 34;
3895}
3896\f
3897/* Decode -m switches. */
3898
3899/* Here is a table, controlled by the tm.h file, listing each -m switch
3900 and which bits in `target_switches' it should set or clear.
3901 If VALUE is positive, it is bits to set.
3902 If VALUE is negative, -VALUE is bits to clear.
3903 (The sign bit is not used so there is no confusion.) */
3904
3905struct {char *name; int value;} target_switches []
3906 = TARGET_SWITCHES;
3907
3908/* This table is similar, but allows the switch to have a value. */
3909
3910#ifdef TARGET_OPTIONS
3911struct {char *prefix; char ** variable;} target_options []
3912 = TARGET_OPTIONS;
3913#endif
3914
3915/* Decode the switch -mNAME. */
3916
3917void
3918set_target_switch (name)
3919 char *name;
3920{
3921 register int j;
3922 int valid = 0;
3923
3924 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3925 if (!strcmp (target_switches[j].name, name))
3926 {
3927 if (target_switches[j].value < 0)
3928 target_flags &= ~-target_switches[j].value;
3929 else
3930 target_flags |= target_switches[j].value;
3931 valid = 1;
3932 }
3933
3934#ifdef TARGET_OPTIONS
3935 if (!valid)
3936 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3937 {
3938 int len = strlen (target_options[j].prefix);
3939 if (!strncmp (target_options[j].prefix, name, len))
3940 {
3941 *target_options[j].variable = name + len;
3942 valid = 1;
3943 }
3944 }
3945#endif
3946
3947 if (!valid)
3948 error ("Invalid option `%s'", name);
3949}
3950\f
3951/* Variable used for communication between the following two routines. */
3952
3953static int line_position;
3954
3955/* Print an option value and adjust the position in the line. */
3956
3957static void
3958print_single_switch (type, name)
3959 char *type, *name;
3960{
3961 fprintf (stderr, " %s%s", type, name);
3962
3963 line_position += strlen (type) + strlen (name) + 1;
3964
3965 if (line_position > 65)
3966 {
3967 fprintf (stderr, "\n\t");
3968 line_position = 8;
3969 }
3970}
3971
3972/* Print default target switches for -version. */
3973
3974static void
3975print_switch_values ()
3976{
3977 register int j;
3978
3979 fprintf (stderr, "enabled:");
3980 line_position = 8;
3981
3982 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3983 if (*f_options[j].variable == f_options[j].on_value)
3984 print_single_switch ("-f", f_options[j].string);
3985
3986 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
3987 if (*W_options[j].variable == W_options[j].on_value)
3988 print_single_switch ("-W", W_options[j].string);
3989
3990 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3991 if (target_switches[j].name[0] != '\0'
3992 && target_switches[j].value > 0
3993 && ((target_switches[j].value & target_flags)
3994 == target_switches[j].value))
3995 print_single_switch ("-m", target_switches[j].name);
3996
3997 fprintf (stderr, "\n");
3998}
This page took 0.754308 seconds and 5 git commands to generate.