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