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