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