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