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