]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/toplev.c
89ed389168e2d42bc457994aba9131551d9c9ac3
[thirdparty/gcc.git] / gcc / toplev.c
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-98, 1999 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 #undef FLOAT /* This is for hpux. They should change hpux. */
28 #undef FFS /* Some systems define this in param.h. */
29 #include "system.h"
30 #include <signal.h>
31 #include <setjmp.h>
32
33 #ifdef HAVE_SYS_RESOURCE_H
34 # include <sys/resource.h>
35 #endif
36
37 #ifdef HAVE_SYS_TIMES_H
38 # include <sys/times.h>
39 #endif
40
41 #include "input.h"
42 #include "tree.h"
43 #include "rtl.h"
44 #include "flags.h"
45 #include "insn-attr.h"
46 #include "insn-codes.h"
47 #include "insn-config.h"
48 #include "recog.h"
49 #include "defaults.h"
50 #include "output.h"
51 #include "except.h"
52 #include "function.h"
53 #include "toplev.h"
54 #include "expr.h"
55 #include "basic-block.h"
56 #include "intl.h"
57 #include "ggc.h"
58
59 #ifdef DWARF_DEBUGGING_INFO
60 #include "dwarfout.h"
61 #endif
62
63 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
64 #include "dwarf2out.h"
65 #endif
66
67 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
68 #include "dbxout.h"
69 #endif
70
71 #ifdef SDB_DEBUGGING_INFO
72 #include "sdbout.h"
73 #endif
74
75 #ifdef XCOFF_DEBUGGING_INFO
76 #include "xcoffout.h"
77 #endif
78 \f
79 #ifdef VMS
80 /* The extra parameters substantially improve the I/O performance. */
81 static FILE *
82 vms_fopen (fname, type)
83 char * fname;
84 char * type;
85 {
86 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
87 fixed arguments, which matches ANSI's specification but not VAXCRTL's
88 pre-ANSI implementation. This hack circumvents the mismatch problem. */
89 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
90
91 if (*type == 'w')
92 return (*vmslib_fopen) (fname, type, "mbc=32",
93 "deq=64", "fop=tef", "shr=nil");
94 else
95 return (*vmslib_fopen) (fname, type, "mbc=32");
96 }
97 #define fopen vms_fopen
98 #endif /* VMS */
99
100 #ifndef DEFAULT_GDB_EXTENSIONS
101 #define DEFAULT_GDB_EXTENSIONS 1
102 #endif
103
104 /* If more than one debugging type is supported, you must define
105 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
106
107 This is one long line cause VAXC can't handle a \-newline. */
108 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
109 #ifndef PREFERRED_DEBUGGING_TYPE
110 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
111 #endif /* no PREFERRED_DEBUGGING_TYPE */
112 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
113 so the following code needn't care. */
114 #ifdef DBX_DEBUGGING_INFO
115 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
116 #endif
117 #ifdef SDB_DEBUGGING_INFO
118 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
119 #endif
120 #ifdef DWARF_DEBUGGING_INFO
121 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
122 #endif
123 #ifdef DWARF2_DEBUGGING_INFO
124 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
125 #endif
126 #ifdef XCOFF_DEBUGGING_INFO
127 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
128 #endif
129 #endif /* More than one debugger format enabled. */
130
131 /* If still not defined, must have been because no debugging formats
132 are supported. */
133 #ifndef PREFERRED_DEBUGGING_TYPE
134 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
135 #endif
136
137 #ifndef DIR_SEPARATOR
138 #define DIR_SEPARATOR '/'
139 #endif
140
141 #if ! (defined (VMS) || defined (OS2))
142 extern char **environ;
143 #endif
144 extern char *version_string;
145
146 /* Carry information from ASM_DECLARE_OBJECT_NAME
147 to ASM_FINISH_DECLARE_OBJECT. */
148
149 extern int size_directive_output;
150 extern tree last_assemble_variable_decl;
151
152 extern void init_decl_processing ();
153 extern void init_obstacks ();
154 extern void init_tree_codes ();
155 extern void init_regs ();
156 extern void init_optabs ();
157 extern void init_stmt ();
158 extern void init_reg_sets ();
159 extern void dump_flow_info ();
160 extern void dump_sched_info ();
161 extern void dump_local_alloc ();
162 extern void regset_release_memory ();
163
164 extern void print_rtl ();
165 extern void print_rtl_with_bb ();
166
167 void rest_of_decl_compilation ();
168 void error_with_file_and_line PVPROTO((const char *file,
169 int line, const char *s, ...));
170 void error_with_decl PVPROTO((tree decl, const char *s, ...));
171 void error_for_asm PVPROTO((rtx insn, const char *s, ...));
172 void notice PVPROTO((const char *s, ...));
173 void error PVPROTO((const char *s, ...));
174 void fatal PVPROTO((const char *s, ...));
175 void warning_with_file_and_line PVPROTO((const char *file,
176 int line, const char *s, ...));
177 void warning_with_decl PVPROTO((tree decl, const char *s, ...));
178 void warning PVPROTO((const char *s, ...));
179 void pedwarn PVPROTO((const char *s, ...));
180 void pedwarn_with_decl PVPROTO((tree decl, const char *s, ...));
181 void pedwarn_with_file_and_line PVPROTO((const char *file,
182 int line, const char *s, ...));
183 void sorry PVPROTO((const char *s, ...));
184 static void set_target_switch PROTO((const char *));
185 static const char *decl_name PROTO((tree, int));
186 static void vmessage PROTO((const char *, const char *, va_list));
187 static void v_message_with_file_and_line PROTO((const char *, int, int,
188 const char *, va_list));
189 static void v_message_with_decl PROTO((tree, int, const char *, va_list));
190 static void file_and_line_for_asm PROTO((rtx, char **, int *));
191 static void v_error_with_file_and_line PROTO((const char *, int,
192 const char *, va_list));
193 static void v_error_with_decl PROTO((tree, const char *, va_list));
194 static void v_error_for_asm PROTO((rtx, const char *, va_list));
195 static void verror PROTO((const char *, va_list));
196 static void vfatal PROTO((const char *, va_list)) ATTRIBUTE_NORETURN;
197 static void v_warning_with_file_and_line PROTO ((const char *, int,
198 const char *, va_list));
199 static void v_warning_with_decl PROTO((tree, const char *, va_list));
200 static void v_warning_for_asm PROTO((rtx, const char *, va_list));
201 static void vwarning PROTO((const char *, va_list));
202 static void vpedwarn PROTO((const char *, va_list));
203 static void v_pedwarn_with_decl PROTO((tree, const char *, va_list));
204 static void v_pedwarn_with_file_and_line PROTO((const char *, int,
205 const char *, va_list));
206 static void vsorry PROTO((const char *, va_list));
207 static void float_signal PROTO((int)) ATTRIBUTE_NORETURN;
208 static void pipe_closed PROTO((int)) ATTRIBUTE_NORETURN;
209 #ifdef ASM_IDENTIFY_LANGUAGE
210 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
211 static void output_lang_identify PROTO((FILE *)) ATTRIBUTE_UNUSED;
212 #endif
213 static void open_dump_file PROTO((const char *, const char *));
214 static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
215 static void dump_rtl PROTO((const char *, tree, void (*) (FILE *, rtx), rtx));
216 static void clean_dump_file PROTO((const char *));
217 static void compile_file PROTO((char *));
218 static void display_help PROTO ((void));
219
220 static void print_version PROTO((FILE *, const char *));
221 static int print_single_switch PROTO((FILE *, int, int, const char *,
222 const char *, const char *,
223 const char *, const char *));
224 static void print_switch_values PROTO((FILE *, int, int, const char *,
225 const char *, const char *));
226
227 void print_rtl_graph_with_bb PROTO ((const char *, const char *, rtx));
228 void clean_graph_dump_file PROTO ((const char *, const char *));
229 void finish_graph_dump_file PROTO ((const char *, const char *));
230 /* Length of line when printing switch values. */
231 #define MAX_LINE 75
232
233 /* Name of program invoked, sans directories. */
234
235 char *progname;
236
237 /* Copy of arguments to main. */
238 int save_argc;
239 char **save_argv;
240 \f
241 /* Name of current original source file (what was input to cpp).
242 This comes from each #-command in the actual input. */
243
244 char *input_filename;
245
246 /* Name of top-level original source file (what was input to cpp).
247 This comes from the #-command at the beginning of the actual input.
248 If there isn't any there, then this is the cc1 input file name. */
249
250 char *main_input_filename;
251
252 /* Current line number in real source file. */
253
254 int lineno;
255
256 /* Nonzero if it is unsafe to create any new pseudo registers. */
257 int no_new_pseudos;
258
259 /* Stack of currently pending input files. */
260
261 struct file_stack *input_file_stack;
262
263 /* Incremented on each change to input_file_stack. */
264 int input_file_stack_tick;
265
266 /* Name to use as base of names for dump output files. */
267
268 const char *dump_base_name;
269
270 /* Bit flags that specify the machine subtype we are compiling for.
271 Bits are tested using macros TARGET_... defined in the tm.h file
272 and set by `-m...' switches. Must be defined in rtlanal.c. */
273
274 extern int target_flags;
275
276 /* Flags saying which kinds of debugging dump have been requested. */
277
278 int rtl_dump = 0;
279 int rtl_dump_and_exit = 0;
280 int jump_opt_dump = 0;
281 int addressof_dump = 0;
282 int cse_dump = 0;
283 int gcse_dump = 0;
284 int loop_dump = 0;
285 int cse2_dump = 0;
286 int branch_prob_dump = 0;
287 int flow_dump = 0;
288 int combine_dump = 0;
289 int regmove_dump = 0;
290 int sched_dump = 0;
291 int local_reg_dump = 0;
292 int global_reg_dump = 0;
293 int flow2_dump = 0;
294 int peephole2_dump = 0;
295 int sched2_dump = 0;
296 int jump2_opt_dump = 0;
297 #ifdef DELAY_SLOTS
298 int dbr_sched_dump = 0;
299 #endif
300 int flag_print_asm_name = 0;
301 #ifdef STACK_REGS
302 int stack_reg_dump = 0;
303 #endif
304 #ifdef MACHINE_DEPENDENT_REORG
305 int mach_dep_reorg_dump = 0;
306 #endif
307 enum graph_dump_types graph_dump_format;
308
309 /* Name for output file of assembly code, specified with -o. */
310
311 char *asm_file_name;
312
313 /* Value of the -G xx switch, and whether it was passed or not. */
314 int g_switch_value;
315 int g_switch_set;
316
317 /* Type(s) of debugging information we are producing (if any).
318 See flags.h for the definitions of the different possible
319 types of debugging information. */
320 enum debug_info_type write_symbols = NO_DEBUG;
321
322 /* Level of debugging information we are producing. See flags.h
323 for the definitions of the different possible levels. */
324 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
325
326 /* Nonzero means use GNU-only extensions in the generated symbolic
327 debugging information. */
328 /* Currently, this only has an effect when write_symbols is set to
329 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
330 int use_gnu_debug_info_extensions = 0;
331
332 /* Nonzero means do optimizations. -O.
333 Particular numeric values stand for particular amounts of optimization;
334 thus, -O2 stores 2 here. However, the optimizations beyond the basic
335 ones are not controlled directly by this variable. Instead, they are
336 controlled by individual `flag_...' variables that are defaulted
337 based on this variable. */
338
339 int optimize = 0;
340
341 /* Nonzero means optimize for size. -Os.
342 The only valid values are zero and non-zero. When optimize_size is
343 non-zero, optimize defaults to 2, but certain individual code
344 bloating optimizations are disabled. */
345
346 int optimize_size = 0;
347
348 /* Number of error messages and warning messages so far. */
349
350 int errorcount = 0;
351 int warningcount = 0;
352 int sorrycount = 0;
353
354 /* Pointer to function to compute the name to use to print a declaration.
355 DECL is the declaration in question.
356 VERBOSITY determines what information will be printed:
357 0: DECL_NAME, demangled as necessary.
358 1: and scope information.
359 2: and any other information that might be interesting, such as function
360 parameter types in C++. */
361
362 const char *(*decl_printable_name) PROTO ((tree, int));
363
364 /* Pointer to function to compute rtl for a language-specific tree code. */
365
366 typedef rtx (*lang_expand_expr_t)
367 PROTO ((union tree_node *, rtx, enum machine_mode,
368 enum expand_modifier modifier));
369
370 lang_expand_expr_t lang_expand_expr = 0;
371
372 tree (*lang_expand_constant) PROTO((tree)) = 0;
373
374 /* Pointer to function to finish handling an incomplete decl at the
375 end of compilation. */
376
377 void (*incomplete_decl_finalize_hook) PROTO((tree)) = 0;
378
379 /* Nonzero if generating code to do profiling. */
380
381 int profile_flag = 0;
382
383 /* Nonzero if generating code to do profiling on a line-by-line basis. */
384
385 int profile_block_flag;
386
387 /* Nonzero if generating code to profile program flow graph arcs. */
388
389 int profile_arc_flag = 0;
390
391 /* Nonzero if generating info for gcov to calculate line test coverage. */
392
393 int flag_test_coverage = 0;
394
395 /* Nonzero indicates that branch taken probabilities should be calculated. */
396
397 int flag_branch_probabilities = 0;
398
399 /* Nonzero for -pedantic switch: warn about anything
400 that standard spec forbids. */
401
402 int pedantic = 0;
403
404 /* Temporarily suppress certain warnings.
405 This is set while reading code from a system header file. */
406
407 int in_system_header = 0;
408
409 /* Nonzero means do stupid register allocation.
410 Currently, this is 1 if `optimize' is 0. */
411
412 int obey_regdecls = 0;
413
414 /* Don't print functions as they are compiled and don't print
415 times taken by the various passes. -quiet. */
416
417 int quiet_flag = 0;
418 \f
419 /* -f flags. */
420
421 /* Nonzero means `char' should be signed. */
422
423 int flag_signed_char;
424
425 /* Nonzero means give an enum type only as many bytes as it needs. */
426
427 int flag_short_enums;
428
429 /* Nonzero for -fcaller-saves: allocate values in regs that need to
430 be saved across function calls, if that produces overall better code.
431 Optional now, so people can test it. */
432
433 #ifdef DEFAULT_CALLER_SAVES
434 int flag_caller_saves = 1;
435 #else
436 int flag_caller_saves = 0;
437 #endif
438
439 /* Nonzero if structures and unions should be returned in memory.
440
441 This should only be defined if compatibility with another compiler or
442 with an ABI is needed, because it results in slower code. */
443
444 #ifndef DEFAULT_PCC_STRUCT_RETURN
445 #define DEFAULT_PCC_STRUCT_RETURN 1
446 #endif
447
448 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
449
450 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
451
452 /* Nonzero for -fforce-mem: load memory value into a register
453 before arithmetic on it. This makes better cse but slower compilation. */
454
455 int flag_force_mem = 0;
456
457 /* Nonzero for -fforce-addr: load memory address into a register before
458 reference to memory. This makes better cse but slower compilation. */
459
460 int flag_force_addr = 0;
461
462 /* Nonzero for -fdefer-pop: don't pop args after each function call;
463 instead save them up to pop many calls' args with one insns. */
464
465 int flag_defer_pop = 0;
466
467 /* Nonzero for -ffloat-store: don't allocate floats and doubles
468 in extended-precision registers. */
469
470 int flag_float_store = 0;
471
472 /* Nonzero for -fcse-follow-jumps:
473 have cse follow jumps to do a more extensive job. */
474
475 int flag_cse_follow_jumps;
476
477 /* Nonzero for -fcse-skip-blocks:
478 have cse follow a branch around a block. */
479 int flag_cse_skip_blocks;
480
481 /* Nonzero for -fexpensive-optimizations:
482 perform miscellaneous relatively-expensive optimizations. */
483 int flag_expensive_optimizations;
484
485 /* Nonzero for -fthread-jumps:
486 have jump optimize output of loop. */
487
488 int flag_thread_jumps;
489
490 /* Nonzero enables strength-reduction in loop.c. */
491
492 int flag_strength_reduce = 0;
493
494 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
495 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
496 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
497 unrolled. */
498
499 int flag_unroll_loops;
500
501 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
502 This is generally not a win. */
503
504 int flag_unroll_all_loops;
505
506 /* Nonzero forces all invariant computations in loops to be moved
507 outside the loop. */
508
509 int flag_move_all_movables = 0;
510
511 /* Nonzero forces all general induction variables in loops to be
512 strength reduced. */
513
514 int flag_reduce_all_givs = 0;
515
516 /* Nonzero to perform full register move optimization passes. This is the
517 default for -O2. */
518
519 int flag_regmove = 0;
520
521 /* Nonzero for -fwritable-strings:
522 store string constants in data segment and don't uniquize them. */
523
524 int flag_writable_strings = 0;
525
526 /* Nonzero means don't put addresses of constant functions in registers.
527 Used for compiling the Unix kernel, where strange substitutions are
528 done on the assembly output. */
529
530 int flag_no_function_cse = 0;
531
532 /* Nonzero for -fomit-frame-pointer:
533 don't make a frame pointer in simple functions that don't require one. */
534
535 int flag_omit_frame_pointer = 0;
536
537 /* Nonzero means place each function into its own section on those platforms
538 which support arbitrary section names and unlimited numbers of sections. */
539
540 int flag_function_sections = 0;
541
542 /* ... and similar for data. */
543
544 int flag_data_sections = 0;
545
546 /* Nonzero to inhibit use of define_optimization peephole opts. */
547
548 int flag_no_peephole = 0;
549
550 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
551 operations in the interest of optimization. For example it allows
552 GCC to assume arguments to sqrt are nonnegative numbers, allowing
553 faster code for sqrt to be generated. */
554
555 int flag_fast_math = 0;
556
557 /* Nonzero means the front end generally wants `errno' maintained by math
558 operations, like built-in SQRT, unless overridden by flag_fast_math. */
559
560 int flag_errno_math = 1;
561
562 /* 0 means straightforward implementation of complex divide acceptable.
563 1 means wide ranges of inputs must work for complex divide.
564 2 means C9X-like requirements for complex divide (not yet implemented). */
565
566 int flag_complex_divide_method = 0;
567
568 /* Nonzero means all references through pointers are volatile. */
569
570 int flag_volatile;
571
572 /* Nonzero means treat all global and extern variables as volatile. */
573
574 int flag_volatile_global;
575
576 /* Nonzero means treat all static variables as volatile. */
577
578 int flag_volatile_static;
579
580 /* Nonzero means just do syntax checking; don't output anything. */
581
582 int flag_syntax_only = 0;
583
584 /* Nonzero means perform global cse. */
585
586 static int flag_gcse;
587
588 /* Nonzero means to rerun cse after loop optimization. This increases
589 compilation time about 20% and picks up a few more common expressions. */
590
591 static int flag_rerun_cse_after_loop;
592
593 /* Nonzero means to run loop optimizations twice. */
594
595 int flag_rerun_loop_opt;
596
597 /* Nonzero for -finline-functions: ok to inline functions that look like
598 good inline candidates. */
599
600 int flag_inline_functions;
601
602 /* Nonzero for -fkeep-inline-functions: even if we make a function
603 go inline everywhere, keep its definition around for debugging
604 purposes. */
605
606 int flag_keep_inline_functions;
607
608 /* Nonzero means that functions will not be inlined. */
609
610 int flag_no_inline;
611
612 /* Nonzero means that we should emit static const variables
613 regardless of whether or not optimization is turned on. */
614
615 int flag_keep_static_consts = 1;
616
617 /* Nonzero means we should be saving declaration info into a .X file. */
618
619 int flag_gen_aux_info = 0;
620
621 /* Specified name of aux-info file. */
622
623 static char *aux_info_file_name;
624
625 /* Nonzero means make the text shared if supported. */
626
627 int flag_shared_data;
628
629 /* Nonzero means schedule into delayed branch slots if supported. */
630
631 int flag_delayed_branch;
632
633 /* Nonzero if we are compiling pure (sharable) code.
634 Value is 1 if we are doing reasonable (i.e. simple
635 offset into offset table) pic. Value is 2 if we can
636 only perform register offsets. */
637
638 int flag_pic;
639
640 /* Nonzero means generate extra code for exception handling and enable
641 exception handling. */
642
643 int flag_exceptions;
644
645 /* Nonzero means use the new model for exception handling. Replaces
646 -DNEW_EH_MODEL as a compile option. */
647
648 int flag_new_exceptions = 1;
649
650 /* Nonzero means don't place uninitialized global data in common storage
651 by default. */
652
653 int flag_no_common;
654
655 /* Nonzero means pretend it is OK to examine bits of target floats,
656 even if that isn't true. The resulting code will have incorrect constants,
657 but the same series of instructions that the native compiler would make. */
658
659 int flag_pretend_float;
660
661 /* Nonzero means change certain warnings into errors.
662 Usually these are warnings about failure to conform to some standard. */
663
664 int flag_pedantic_errors = 0;
665
666 /* flag_schedule_insns means schedule insns within basic blocks (before
667 local_alloc).
668 flag_schedule_insns_after_reload means schedule insns after
669 global_alloc. */
670
671 int flag_schedule_insns = 0;
672 int flag_schedule_insns_after_reload = 0;
673
674 /* The following flags have effect only for scheduling before register
675 allocation:
676
677 flag_schedule_interblock means schedule insns accross basic blocks.
678 flag_schedule_speculative means allow speculative motion of non-load insns.
679 flag_schedule_speculative_load means allow speculative motion of some
680 load insns.
681 flag_schedule_speculative_load_dangerous allows speculative motion of more
682 load insns. */
683
684 int flag_schedule_interblock = 1;
685 int flag_schedule_speculative = 1;
686 int flag_schedule_speculative_load = 0;
687 int flag_schedule_speculative_load_dangerous = 0;
688
689 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
690 by a cheaper branch, on a count register. */
691 int flag_branch_on_count_reg;
692
693 /* -finhibit-size-directive inhibits output of .size for ELF.
694 This is used only for compiling crtstuff.c,
695 and it may be extended to other effects
696 needed for crtstuff.c on other systems. */
697 int flag_inhibit_size_directive = 0;
698
699 /* -fverbose-asm causes extra commentary information to be produced in
700 the generated assembly code (to make it more readable). This option
701 is generally only of use to those who actually need to read the
702 generated assembly code (perhaps while debugging the compiler itself).
703 -fno-verbose-asm, the default, causes the extra information
704 to be omitted and is useful when comparing two assembler files. */
705
706 int flag_verbose_asm = 0;
707
708 /* -dA causes debug commentary information to be produced in
709 the generated assembly code (to make it more readable). This option
710 is generally only of use to those who actually need to read the
711 generated assembly code (perhaps while debugging the compiler itself).
712 Currently, this switch is only used by dwarfout.c; however, it is intended
713 to be a catchall for printing debug information in the assembler file. */
714
715 int flag_debug_asm = 0;
716
717 /* -fgnu-linker specifies use of the GNU linker for initializations.
718 (Or, more generally, a linker that handles initializations.)
719 -fno-gnu-linker says that collect2 will be used. */
720 #ifdef USE_COLLECT2
721 int flag_gnu_linker = 0;
722 #else
723 int flag_gnu_linker = 1;
724 #endif
725
726 /* Tag all structures with __attribute__(packed) */
727 int flag_pack_struct = 0;
728
729 /* Emit code to check for stack overflow; also may cause large objects
730 to be allocated dynamically. */
731 int flag_stack_check;
732
733 /* -fcheck-memory-usage causes extra code to be generated in order to check
734 memory accesses. This is used by a detector of bad memory accesses such
735 as Checker. */
736 int flag_check_memory_usage = 0;
737
738 /* -fprefix-function-name causes function name to be prefixed. This
739 can be used with -fcheck-memory-usage to isolate code compiled with
740 -fcheck-memory-usage. */
741 int flag_prefix_function_name = 0;
742
743 /* 0 if pointer arguments may alias each other. True in C.
744 1 if pointer arguments may not alias each other but may alias
745 global variables.
746 2 if pointer arguments may not alias each other and may not
747 alias global variables. True in Fortran.
748 This defaults to 0 for C. */
749 int flag_argument_noalias = 0;
750
751 /* Nonzero if we should do (language-dependent) alias analysis.
752 Typically, this analysis will assume that expressions of certain
753 types do not alias expressions of certain other types. Only used
754 if alias analysis (in general) is enabled. */
755 int flag_strict_aliasing = 0;
756
757 /* Instrument functions with calls at entry and exit, for profiling. */
758 int flag_instrument_function_entry_exit = 0;
759
760 /* Nonzero means ignore `#ident' directives. 0 means handle them.
761 On SVR4 targets, it also controls whether or not to emit a
762 string identifying the compiler. */
763
764 int flag_no_ident = 0;
765
766 /* This will perform a peephole pass before sched2. */
767 int flag_peephole2 = 0;
768
769 /* Values of the -falign-* flags: how much to align labels in code.
770 0 means `use default', 1 means `don't align'.
771 For each variable, there is an _log variant which is the power
772 of two not less than the variable, for .align output. */
773
774 int align_loops;
775 int align_loops_log;
776 int align_jumps;
777 int align_jumps_log;
778 int align_labels;
779 int align_labels_log;
780 int align_functions;
781 int align_functions_log;
782
783 /* Table of supported debugging formats. */
784 static struct
785 {
786 const char * arg;
787 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
788 constant expression, we use NO_DEBUG in its place. */
789 enum debug_info_type debug_type;
790 int use_extensions_p;
791 const char * description;
792 } *da,
793 debug_args[] =
794 {
795 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
796 "Generate default debug format output" },
797 { "ggdb", NO_DEBUG, 1, "Generate default extended debug format output" },
798 #ifdef DBX_DEBUGGING_INFO
799 { "gstabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
800 { "gstabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
801 #endif
802 #ifdef DWARF_DEBUGGING_INFO
803 { "gdwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
804 { "gdwarf+", DWARF_DEBUG, 1,
805 "Generated extended DWARF-1 format debug output" },
806 #endif
807 #ifdef DWARF2_DEBUGGING_INFO
808 { "gdwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
809 #endif
810 #ifdef XCOFF_DEBUGGING_INFO
811 { "gxcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
812 { "gxcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
813 #endif
814 #ifdef SDB_DEBUGGING_INFO
815 { "gcoff", SDB_DEBUG, 0, "Generate COFF format debug output" },
816 #endif
817 { 0, 0, 0, 0 }
818 };
819
820 typedef struct
821 {
822 const char * string;
823 int * variable;
824 int on_value;
825 const char * description;
826 }
827 lang_independent_options;
828
829 /* Add or remove a leading underscore from user symbols. */
830 int flag_leading_underscore = -1;
831
832 /* The user symbol prefix after having resolved same. */
833 const char *user_label_prefix;
834
835 /* A default for same. */
836 #ifndef USER_LABEL_PREFIX
837 #define USER_LABEL_PREFIX ""
838 #endif
839
840 /* Table of language-independent -f options.
841 STRING is the option name. VARIABLE is the address of the variable.
842 ON_VALUE is the value to store in VARIABLE
843 if `-fSTRING' is seen as an option.
844 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
845
846 lang_independent_options f_options[] =
847 {
848 {"float-store", &flag_float_store, 1,
849 "Do not store floats in registers" },
850 {"volatile", &flag_volatile, 1,
851 "Consider all mem refs through pointers as volatile"},
852 {"volatile-global", &flag_volatile_global, 1,
853 "Consider all mem refs to global data to be volatile" },
854 {"volatile-static", &flag_volatile_static, 1,
855 "Consider all mem refs to static data to be volatile" },
856 {"defer-pop", &flag_defer_pop, 1,
857 "Defer popping functions args from stack until later" },
858 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
859 "When possible do not generate stack frames"},
860 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
861 "When running CSE, follow jumps to their targets" },
862 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
863 "When running CSE, follow conditional jumps" },
864 {"expensive-optimizations", &flag_expensive_optimizations, 1,
865 "Perform a number of minor, expensive optimisations" },
866 {"thread-jumps", &flag_thread_jumps, 1,
867 "Perform jump threading optimisations"},
868 {"strength-reduce", &flag_strength_reduce, 1,
869 "Perform strength reduction optimisations" },
870 {"unroll-loops", &flag_unroll_loops, 1,
871 "Perform loop unrolling when iteration count is known" },
872 {"unroll-all-loops", &flag_unroll_all_loops, 1,
873 "Perform loop unrolling for all loops" },
874 {"move-all-movables", &flag_move_all_movables, 1,
875 "Force all loop invariant computations out of loops" },
876 {"reduce-all-givs", &flag_reduce_all_givs, 1,
877 "Strength reduce all loop general induction variables" },
878 {"writable-strings", &flag_writable_strings, 1,
879 "Store strings in writable data section" },
880 {"peephole", &flag_no_peephole, 0,
881 "Enable machine specific peephole optimisations" },
882 {"force-mem", &flag_force_mem, 1,
883 "Copy memory operands into registers before using" },
884 {"force-addr", &flag_force_addr, 1,
885 "Copy memory address constants into regs before using" },
886 {"function-cse", &flag_no_function_cse, 0,
887 "Allow function addresses to be held in registers" },
888 {"inline-functions", &flag_inline_functions, 1,
889 "Integrate simple functions into their callers" },
890 {"keep-inline-functions", &flag_keep_inline_functions, 1,
891 "Generate code for funcs even if they are fully inlined" },
892 {"inline", &flag_no_inline, 0,
893 "Pay attention to the 'inline' keyword"},
894 {"keep-static-consts", &flag_keep_static_consts, 1,
895 "Emit static const variables even if they are not used" },
896 {"syntax-only", &flag_syntax_only, 1,
897 "Check for syntax errors, then stop" },
898 {"shared-data", &flag_shared_data, 1,
899 "Mark data as shared rather than private" },
900 {"caller-saves", &flag_caller_saves, 1,
901 "Enable saving registers around function calls" },
902 {"pcc-struct-return", &flag_pcc_struct_return, 1,
903 "Return 'short' aggregates in memory, not registers" },
904 {"reg-struct-return", &flag_pcc_struct_return, 0,
905 "Return 'short' aggregates in registers" },
906 {"delayed-branch", &flag_delayed_branch, 1,
907 "Attempt to fill delay slots of branch instructions" },
908 {"gcse", &flag_gcse, 1,
909 "Perform the global common subexpression elimination" },
910 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
911 "Run CSE pass after loop optimisations"},
912 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
913 "Run the loop optimiser twice"},
914 {"pretend-float", &flag_pretend_float, 1,
915 "Pretend that host and target use the same FP format"},
916 {"schedule-insns", &flag_schedule_insns, 1,
917 "Reschedule instructions to avoid pipeline stalls"},
918 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
919 "Run two passes of the instruction scheduler"},
920 {"sched-interblock",&flag_schedule_interblock, 1,
921 "Enable scheduling across basic blocks" },
922 {"sched-spec",&flag_schedule_speculative, 1,
923 "Allow speculative motion of non-loads" },
924 {"sched-spec-load",&flag_schedule_speculative_load, 1,
925 "Allow speculative motion of some loads" },
926 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
927 "Allow speculative motion of more loads" },
928 {"branch-count-reg",&flag_branch_on_count_reg, 1,
929 "Replace add,compare,branch with branch on count reg"},
930 {"pic", &flag_pic, 1,
931 "Generate position independent code, if possible"},
932 {"PIC", &flag_pic, 2, ""},
933 {"exceptions", &flag_exceptions, 1,
934 "Enable exception handling" },
935 {"new-exceptions", &flag_new_exceptions, 1,
936 "Use the new model for exception handling" },
937 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
938 "Use setjmp/longjmp to handle exceptions" },
939 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
940 "Support asynchronous exceptions" },
941 {"profile-arcs", &profile_arc_flag, 1,
942 "Insert arc based program profiling code" },
943 {"test-coverage", &flag_test_coverage, 1,
944 "Create data files needed by gcov" },
945 {"branch-probabilities", &flag_branch_probabilities, 1,
946 "Use profiling information for branch probabilities" },
947 {"fast-math", &flag_fast_math, 1,
948 "Improve FP speed by violating ANSI & IEEE rules" },
949 {"common", &flag_no_common, 0,
950 "Do not put unitialised globals in the common section" },
951 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
952 "Do not generate .size directives" },
953 {"function-sections", &flag_function_sections, 1,
954 "place each function into its own section" },
955 {"data-sections", &flag_data_sections, 1,
956 "place data items into their own section" },
957 {"verbose-asm", &flag_verbose_asm, 1,
958 "Add extra commentry to assembler output"},
959 {"gnu-linker", &flag_gnu_linker, 1,
960 "Output GNU ld formatted global initialisers"},
961 {"regmove", &flag_regmove, 1,
962 "Enables a register move optimisation"},
963 {"optimize-register-move", &flag_regmove, 1,
964 "Do the full regmove optimization pass"},
965 {"pack-struct", &flag_pack_struct, 1,
966 "Pack structure members together without holes" },
967 {"stack-check", &flag_stack_check, 1,
968 "Insert stack checking code into the program" },
969 {"argument-alias", &flag_argument_noalias, 0,
970 "Specify that arguments may alias each other & globals"},
971 {"argument-noalias", &flag_argument_noalias, 1,
972 "Assume arguments may alias globals but not each other"},
973 {"argument-noalias-global", &flag_argument_noalias, 2,
974 "Assume arguments do not alias each other or globals" },
975 {"strict-aliasing", &flag_strict_aliasing, 1,
976 "Assume strict aliasing rules apply" },
977 {"align-loops", &align_loops, 0,
978 "Align the start of loops" },
979 {"align-jumps", &align_jumps, 0,
980 "Align labels which are only reached by jumping" },
981 {"align-labels", &align_labels, 0,
982 "Align all labels" },
983 {"align-functions", &align_functions, 0,
984 "Align the start of functions" },
985 {"check-memory-usage", &flag_check_memory_usage, 1,
986 "Generate code to check every memory access" },
987 {"prefix-function-name", &flag_prefix_function_name, 1,
988 "Add a prefix to all function names" },
989 {"dump-unnumbered", &flag_dump_unnumbered, 1,
990 "Suppress output of instruction numbers and line number notes in debugging dumps"},
991 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
992 "Instrument function entry/exit with profiling calls"},
993 {"leading-underscore", &flag_leading_underscore, 1,
994 "External symbols have a leading underscore" },
995 {"ident", &flag_no_ident, 0,
996 "Process #ident directives"},
997 { "peephole2", &flag_peephole2, 1,
998 "Enables an rtl peephole pass run before sched2" }
999 };
1000
1001 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
1002
1003 /* Table of language-specific options. */
1004
1005 static struct lang_opt
1006 {
1007 const char * option;
1008 const char * description;
1009 }
1010 documented_lang_options[] =
1011 {
1012 /* In order not to overload the --help output, the convention
1013 used here is to only describe those options which are not
1014 enabled by default. */
1015
1016 { "-ansi", "Compile just for ANSI C" },
1017 { "-fallow-single-precision",
1018 "Do not promote floats to double if using -traditional" },
1019 { "-std= ", "Determine language standard"},
1020
1021 { "-fsigned-bitfields", "" },
1022 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1023 { "-fno-signed-bitfields", "" },
1024 { "-fno-unsigned-bitfields","" },
1025 { "-fsigned-char", "Make 'char' be signed by default"},
1026 { "-funsigned-char", "Make 'char' be unsigned by default"},
1027 { "-fno-signed-char", "" },
1028 { "-fno-unsigned-char", "" },
1029
1030 { "-ftraditional", "" },
1031 { "-traditional", "Attempt to support traditional K&R style C"},
1032 { "-fnotraditional", "" },
1033 { "-fno-traditional", "" },
1034
1035 { "-fasm", "" },
1036 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1037 { "-fbuiltin", "" },
1038 { "-fno-builtin", "Do not recognise any built in functions" },
1039 { "-fhosted", "Assume normal C execution environment" },
1040 { "-fno-hosted", "" },
1041 { "-ffreestanding",
1042 "Assume that standard libraries & main might not exist" },
1043 { "-fno-freestanding", "" },
1044 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1045 { "-fno-cond-mismatch", "" },
1046 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1047 { "-fno-dollars-in-identifiers", "" },
1048 { "-fpreprocessed", "" },
1049 { "-fno-preprocessed", "" },
1050 { "-fshort-double", "Use the same size for double as for float" },
1051 { "-fno-short-double", "" },
1052 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1053 { "-fno-short-enums", "" },
1054
1055 { "-Wall", "Enable most warning messages" },
1056 { "-Wbad-function-cast",
1057 "Warn about casting functions to incompatible types" },
1058 { "-Wno-bad-function-cast", "" },
1059 { "-Wmissing-noreturn",
1060 "Warn about functions which might be candidates for attribute noreturn" },
1061 { "-Wno-missing-noreturn", "" },
1062 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1063 { "-Wno-cast-qual", "" },
1064 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1065 { "-Wno-char-subscripts", "" },
1066 { "-Wcomment", "Warn if nested comments are detected" },
1067 { "-Wno-comment", "" },
1068 { "-Wcomments", "Warn if nested comments are detected" },
1069 { "-Wno-comments", "" },
1070 { "-Wconversion", "Warn about possibly confusing type conversions" },
1071 { "-Wno-conversion", "" },
1072 { "-Wformat", "Warn about printf format anomalies" },
1073 { "-Wno-format", "" },
1074 { "-Wimplicit-function-declaration",
1075 "Warn about implicit function declarations" },
1076 { "-Wno-implicit-function-declaration", "" },
1077 { "-Werror-implicit-function-declaration", "" },
1078 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1079 { "-Wno-implicit-int", "" },
1080 { "-Wimplicit", "" },
1081 { "-Wno-implicit", "" },
1082 { "-Wimport", "Warn about the use of the #import directive" },
1083 { "-Wno-import", "" },
1084 { "-Wlong-long","" },
1085 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1086 { "-Wmain", "Warn about suspicious declarations of main" },
1087 { "-Wno-main", "" },
1088 { "-Wmissing-braces",
1089 "Warn about possibly missing braces around initialisers" },
1090 { "-Wno-missing-braces", "" },
1091 { "-Wmissing-declarations",
1092 "Warn about global funcs without previous declarations"},
1093 { "-Wno-missing-declarations", "" },
1094 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1095 { "-Wno-missing-prototypes", "" },
1096 { "-Wmultichar", "Warn about use of multicharacter literals"},
1097 { "-Wno-multichar", "" },
1098 { "-Wnested-externs", "Warn about externs not at file scope level" },
1099 { "-Wno-nested-externs", "" },
1100 { "-Wparentheses", "Warn about possible missing parentheses" },
1101 { "-Wno-parentheses", "" },
1102 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1103 { "-Wno-pointer-arith", "" },
1104 { "-Wredundant-decls",
1105 "Warn about multiple declarations of the same object" },
1106 { "-Wno-redundant-decls", "" },
1107 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1108 { "-Wno-sign-compare", "" },
1109 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1110 { "-Wno-unknown-pragmas", "" },
1111 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1112 { "-Wno-strict-prototypes", "" },
1113 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1114 { "-Wno-traditional", "" },
1115 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1116 { "-Wno-trigraphs", "" },
1117 { "-Wundef", "" },
1118 { "-Wno-undef", "" },
1119 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1120 { "-Wno-write-strings", "" },
1121
1122 /* These are for languages with USE_CPPLIB. */
1123 /* These options are already documented in cpplib.c */
1124 { "--help", "" },
1125 { "-A", "" },
1126 { "-D", "" },
1127 { "-I", "" },
1128 #if USE_CPPLIB
1129 { "-MD", "Print dependencies to FILE.d" },
1130 { "-MMD", "Print dependencies to FILE.d" },
1131 { "-M", "Print dependencies to stdout" },
1132 { "-MM", "Print dependencies to stdout" },
1133 #endif /* USE_CPPLIB */
1134 { "-U", "" },
1135 { "-H", "" },
1136 { "-idirafter", "" },
1137 { "-imacros", "" },
1138 { "-include", "" },
1139 { "-iprefix", "" },
1140 { "-isystem", "" },
1141 { "-iwithprefix", "" },
1142 { "-iwithprefixbefore", "" },
1143 { "-lang-c", "" },
1144 { "-lang-c89", "" },
1145 { "-lang-c++", "" },
1146 { "-remap", "" },
1147 { "-nostdinc", "" },
1148 { "-nostdinc++", "" },
1149 { "-trigraphs", "" },
1150 { "-undef", "" },
1151
1152 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1153
1154 /* These are for obj c. */
1155 DEFINE_LANG_NAME ("Objective C")
1156
1157 { "-lang-objc", "" },
1158 { "-gen-decls", "Dump decls to a .decl file" },
1159 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1160 { "-fno-gnu-runtime", "" },
1161 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1162 { "-fno-next-runtime", "" },
1163 { "-Wselector", "Warn if a selector has multiple methods" },
1164 { "-Wno-selector", "" },
1165 { "-Wprotocol", "" },
1166 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1167 { "-print-objc-runtime-info",
1168 "Generate C header of platform specific features" },
1169
1170 #include "options.h"
1171
1172 };
1173
1174 /* Here is a table, controlled by the tm.h file, listing each -m switch
1175 and which bits in `target_switches' it should set or clear.
1176 If VALUE is positive, it is bits to set.
1177 If VALUE is negative, -VALUE is bits to clear.
1178 (The sign bit is not used so there is no confusion.) */
1179
1180 struct
1181 {
1182 const char * name;
1183 int value;
1184 const char * description;
1185 }
1186 target_switches [] = TARGET_SWITCHES;
1187
1188 /* This table is similar, but allows the switch to have a value. */
1189
1190 #ifdef TARGET_OPTIONS
1191 struct
1192 {
1193 const char * prefix;
1194 const char ** variable;
1195 const char * description;
1196 }
1197 target_options [] = TARGET_OPTIONS;
1198 #endif
1199 \f
1200 /* Options controlling warnings */
1201
1202 /* Don't print warning messages. -w. */
1203
1204 int inhibit_warnings = 0;
1205
1206 /* Print various extra warnings. -W. */
1207
1208 int extra_warnings = 0;
1209
1210 /* Treat warnings as errors. -Werror. */
1211
1212 int warnings_are_errors = 0;
1213
1214 /* Nonzero to warn about unused local variables. */
1215
1216 int warn_unused;
1217
1218 /* Nonzero to warn about code which is never reached. */
1219
1220 int warn_notreached;
1221
1222 /* Nonzero to warn about variables used before they are initialized. */
1223
1224 int warn_uninitialized;
1225
1226 /* Nonzero means warn about all declarations which shadow others. */
1227
1228 int warn_shadow;
1229
1230 /* Warn if a switch on an enum fails to have a case for every enum value. */
1231
1232 int warn_switch;
1233
1234 /* Nonzero means warn about function definitions that default the return type
1235 or that use a null return and have a return-type other than void. */
1236
1237 int warn_return_type;
1238
1239 /* Nonzero means warn about pointer casts that increase the required
1240 alignment of the target type (and might therefore lead to a crash
1241 due to a misaligned access). */
1242
1243 int warn_cast_align;
1244
1245 /* Nonzero means warn about any identifiers that match in the first N
1246 characters. The value N is in `id_clash_len'. */
1247
1248 int warn_id_clash;
1249 unsigned id_clash_len;
1250
1251 /* Nonzero means warn about any objects definitions whose size is larger
1252 than N bytes. Also want about function definitions whose returned
1253 values are larger than N bytes. The value N is in `larger_than_size'. */
1254
1255 int warn_larger_than;
1256 unsigned larger_than_size;
1257
1258 /* Nonzero means warn if inline function is too large. */
1259
1260 int warn_inline;
1261
1262 /* Warn if a function returns an aggregate,
1263 since there are often incompatible calling conventions for doing this. */
1264
1265 int warn_aggregate_return;
1266
1267 /* Likewise for -W. */
1268
1269 lang_independent_options W_options[] =
1270 {
1271 {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1272 {"error", &warnings_are_errors, 1, ""},
1273 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1274 {"switch", &warn_switch, 1,
1275 "Warn about enumerated switches missing a specific case" },
1276 {"aggregate-return", &warn_aggregate_return, 1,
1277 "Warn about returning structures, unions or arrays" },
1278 {"cast-align", &warn_cast_align, 1,
1279 "Warn about pointer casts which increase alignment" },
1280 {"unreachable-code", &warn_notreached, 1,
1281 "Warn about code that will never be executed" },
1282 {"uninitialized", &warn_uninitialized, 1,
1283 "Warn about unitialized automatic variables"},
1284 {"inline", &warn_inline, 1,
1285 "Warn when an inlined function cannot be inlined"}
1286 };
1287 \f
1288 /* Output files for assembler code (real compiler output)
1289 and debugging dumps. */
1290
1291 FILE *asm_out_file;
1292 FILE *aux_info_file;
1293 FILE *rtl_dump_file = NULL;
1294
1295 /* Decode the string P as an integral parameter.
1296 If the string is indeed an integer return its numeric value else
1297 issue an Invalid Option error for the option PNAME and return DEFVAL.
1298 If PNAME is zero just return DEFVAL, do not call error. */
1299
1300 int
1301 read_integral_parameter (p, pname, defval)
1302 const char *p;
1303 const char *pname;
1304 const int defval;
1305 {
1306 const char *endp = p;
1307
1308 while (*endp)
1309 {
1310 if (*endp >= '0' && *endp <= '9')
1311 endp++;
1312 else
1313 break;
1314 }
1315
1316 if (*endp != 0)
1317 {
1318 if (pname != 0)
1319 error ("Invalid option `%s'", pname);
1320 return defval;
1321 }
1322
1323 return atoi (p);
1324 }
1325
1326
1327 /* Time accumulators, to count the total time spent in various passes. */
1328
1329 int parse_time;
1330 int varconst_time;
1331 int integration_time;
1332 int jump_time;
1333 int cse_time;
1334 int gcse_time;
1335 int loop_time;
1336 int cse2_time;
1337 int branch_prob_time;
1338 int flow_time;
1339 int combine_time;
1340 int regmove_time;
1341 int sched_time;
1342 int local_alloc_time;
1343 int global_alloc_time;
1344 int flow2_time;
1345 int sched2_time;
1346 #ifdef DELAY_SLOTS
1347 int dbr_sched_time;
1348 #endif
1349 int shorten_branch_time;
1350 int stack_reg_time;
1351 int final_time;
1352 int symout_time;
1353 int dump_time;
1354 int gc_time;
1355 int all_time;
1356 \f
1357 /* Return time used so far, in microseconds. */
1358
1359 long
1360 get_run_time ()
1361 {
1362 if (quiet_flag)
1363 return 0;
1364
1365 #ifdef __BEOS__
1366 return 0;
1367 #else /* not BeOS */
1368 #if defined (_WIN32) && !defined (__CYGWIN__)
1369 if (clock() < 0)
1370 return 0;
1371 else
1372 return (clock() * 1000);
1373 #else /* not _WIN32 */
1374 #ifdef _SC_CLK_TCK
1375 {
1376 static int tick;
1377 struct tms tms;
1378 if (tick == 0)
1379 tick = 1000000 / sysconf(_SC_CLK_TCK);
1380 times (&tms);
1381 return (tms.tms_utime + tms.tms_stime) * tick;
1382 }
1383 #else
1384 #ifdef USG
1385 {
1386 struct tms tms;
1387 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1388 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1389 # else
1390 # ifdef CLK_TCK
1391 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1392 # else
1393 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1394 # endif
1395 # endif
1396 times (&tms);
1397 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1398 }
1399 #else
1400 #ifndef VMS
1401 {
1402 struct rusage rusage;
1403 getrusage (0, &rusage);
1404 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1405 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1406 }
1407 #else /* VMS */
1408 {
1409 struct
1410 {
1411 int proc_user_time;
1412 int proc_system_time;
1413 int child_user_time;
1414 int child_system_time;
1415 } vms_times;
1416 times ((void *) &vms_times);
1417 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1418 }
1419 #endif /* VMS */
1420 #endif /* USG */
1421 #endif /* _SC_CLK_TCK */
1422 #endif /* _WIN32 */
1423 #endif /* __BEOS__ */
1424 }
1425
1426 #define TIMEVAR(VAR, BODY) \
1427 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1428
1429 void
1430 print_time (str, total)
1431 const char *str;
1432 int total;
1433 {
1434 fprintf (stderr,
1435 "time in %s: %d.%06d (%.0f%%)\n",
1436 str, total / 1000000, total % 1000000,
1437 (double)total / (double)all_time * 100.0);
1438 }
1439
1440 /* Count an error or warning. Return 1 if the message should be printed. */
1441
1442 int
1443 count_error (warningp)
1444 int warningp;
1445 {
1446 if (warningp && inhibit_warnings)
1447 return 0;
1448
1449 if (warningp && !warnings_are_errors)
1450 warningcount++;
1451 else
1452 {
1453 static int warning_message = 0;
1454
1455 if (warningp && !warning_message)
1456 {
1457 notice ("%s: warnings being treated as errors\n", progname);
1458 warning_message = 1;
1459 }
1460 errorcount++;
1461 }
1462
1463 return 1;
1464 }
1465
1466 /* Print a fatal error message. NAME is the text.
1467 Also include a system error message based on `errno'. */
1468
1469 void
1470 pfatal_with_name (name)
1471 const char *name;
1472 {
1473 fprintf (stderr, "%s: ", progname);
1474 perror (name);
1475 exit (FATAL_EXIT_CODE);
1476 }
1477
1478 void
1479 fatal_io_error (name)
1480 const char *name;
1481 {
1482 notice ("%s: %s: I/O error\n", progname, name);
1483 exit (FATAL_EXIT_CODE);
1484 }
1485
1486 /* This is the default decl_printable_name function. */
1487
1488 static const char *
1489 decl_name (decl, verbosity)
1490 tree decl;
1491 int verbosity ATTRIBUTE_UNUSED;
1492 {
1493 return IDENTIFIER_POINTER (DECL_NAME (decl));
1494 }
1495 \f
1496 static int need_error_newline;
1497
1498 /* Function of last error message;
1499 more generally, function such that if next error message is in it
1500 then we don't have to mention the function name. */
1501 static tree last_error_function = NULL;
1502
1503 /* Used to detect when input_file_stack has changed since last described. */
1504 static int last_error_tick;
1505
1506 /* Called when the start of a function definition is parsed,
1507 this function prints on stderr the name of the function. */
1508
1509 void
1510 announce_function (decl)
1511 tree decl;
1512 {
1513 if (! quiet_flag)
1514 {
1515 if (rtl_dump_and_exit)
1516 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1517 else
1518 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1519 fflush (stderr);
1520 need_error_newline = 1;
1521 last_error_function = current_function_decl;
1522 }
1523 }
1524
1525 /* The default function to print out name of current function that caused
1526 an error. */
1527
1528 void
1529 default_print_error_function (file)
1530 const char *file;
1531 {
1532 if (last_error_function != current_function_decl)
1533 {
1534 if (file)
1535 fprintf (stderr, "%s: ", file);
1536
1537 if (current_function_decl == NULL)
1538 notice ("At top level:\n");
1539 else
1540 notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE
1541 ? "In method `%s':\n"
1542 : "In function `%s':\n"),
1543 (*decl_printable_name) (current_function_decl, 2));
1544
1545 last_error_function = current_function_decl;
1546 }
1547 }
1548
1549 /* Called by report_error_function to print out function name.
1550 * Default may be overridden by language front-ends. */
1551
1552 void (*print_error_function) PROTO((const char *)) =
1553 default_print_error_function;
1554
1555 /* Prints out, if necessary, the name of the current function
1556 that caused an error. Called from all error and warning functions.
1557 We ignore the FILE parameter, as it cannot be relied upon. */
1558
1559 void
1560 report_error_function (file)
1561 const char *file ATTRIBUTE_UNUSED;
1562 {
1563 struct file_stack *p;
1564
1565 if (need_error_newline)
1566 {
1567 fprintf (stderr, "\n");
1568 need_error_newline = 0;
1569 }
1570
1571 if (input_file_stack && input_file_stack->next != 0
1572 && input_file_stack_tick != last_error_tick)
1573 {
1574 for (p = input_file_stack->next; p; p = p->next)
1575 notice ((p == input_file_stack->next
1576 ? "In file included from %s:%d"
1577 : ",\n from %s:%d"),
1578 p->name, p->line);
1579 fprintf (stderr, ":\n");
1580 last_error_tick = input_file_stack_tick;
1581 }
1582
1583 (*print_error_function) (input_filename);
1584 }
1585 \f
1586 /* Print a message. */
1587
1588 static void
1589 vnotice (file, msgid, ap)
1590 FILE *file;
1591 char *msgid;
1592 va_list ap;
1593 {
1594 vfprintf (file, _(msgid), ap);
1595 }
1596
1597 void
1598 notice VPROTO((const char *msgid, ...))
1599 {
1600 #ifndef ANSI_PROTOTYPES
1601 char *msgid;
1602 #endif
1603 va_list ap;
1604
1605 VA_START (ap, msgid);
1606
1607 #ifndef ANSI_PROTOTYPES
1608 msgid = va_arg (ap, char *);
1609 #endif
1610
1611 vnotice (stderr, msgid, ap);
1612 va_end (ap);
1613 }
1614
1615 void
1616 fnotice VPROTO((FILE *file, const char *msgid, ...))
1617 {
1618 #ifndef ANSI_PROTOTYPES
1619 FILE *file;
1620 const char *msgid;
1621 #endif
1622 va_list ap;
1623
1624 VA_START (ap, msgid);
1625
1626 #ifndef ANSI_PROTOTYPES
1627 file = va_arg (ap, FILE *);
1628 msgid = va_arg (ap, const char *);
1629 #endif
1630
1631 vnotice (file, msgid, ap);
1632 va_end (ap);
1633 }
1634
1635 /* Report FILE and LINE (or program name), and optionally just WARN. */
1636
1637 static void
1638 report_file_and_line (file, line, warn)
1639 char *file;
1640 int line;
1641 int warn;
1642 {
1643 if (file)
1644 fprintf (stderr, "%s:%d: ", file, line);
1645 else
1646 fprintf (stderr, "%s: ", progname);
1647
1648 if (warn)
1649 notice ("warning: ");
1650 }
1651
1652 /* Print a message. */
1653
1654 static void
1655 vmessage (prefix, msgid, ap)
1656 const char *prefix;
1657 const char *msgid;
1658 va_list ap;
1659 {
1660 if (prefix)
1661 fprintf (stderr, "%s: ", prefix);
1662
1663 vfprintf (stderr, msgid, ap);
1664 }
1665
1666 /* Print a message relevant to line LINE of file FILE. */
1667
1668 static void
1669 v_message_with_file_and_line (file, line, warn, msgid, ap)
1670 const char *file;
1671 int line;
1672 int warn;
1673 const char *msgid;
1674 va_list ap;
1675 {
1676 report_file_and_line (file, line, warn);
1677 vnotice (stderr, msgid, ap);
1678 fputc ('\n', stderr);
1679 }
1680
1681 /* Print a message relevant to the given DECL. */
1682
1683 static void
1684 v_message_with_decl (decl, warn, msgid, ap)
1685 tree decl;
1686 int warn;
1687 const char *msgid;
1688 va_list ap;
1689 {
1690 const char *p;
1691
1692 report_file_and_line (DECL_SOURCE_FILE (decl),
1693 DECL_SOURCE_LINE (decl), warn);
1694
1695 /* Do magic to get around lack of varargs support for insertion
1696 of arguments into existing list. We know that the decl is first;
1697 we ass_u_me that it will be printed with "%s". */
1698
1699 for (p = _(msgid); *p; ++p)
1700 {
1701 if (*p == '%')
1702 {
1703 if (*(p + 1) == '%')
1704 ++p;
1705 else if (*(p + 1) != 's')
1706 abort ();
1707 else
1708 break;
1709 }
1710 }
1711
1712 if (p > _(msgid)) /* Print the left-hand substring. */
1713 {
1714 char fmt[sizeof "%.255s"];
1715 long width = p - _(msgid);
1716
1717 if (width > 255L) width = 255L; /* arbitrary */
1718 sprintf (fmt, "%%.%lds", width);
1719 fprintf (stderr, fmt, _(msgid));
1720 }
1721
1722 if (*p == '%') /* Print the name. */
1723 {
1724 const char *n = (DECL_NAME (decl)
1725 ? (*decl_printable_name) (decl, 2)
1726 : "((anonymous))");
1727 fputs (n, stderr);
1728 while (*p)
1729 {
1730 ++p;
1731 if (ISALPHA (*(p - 1) & 0xFF))
1732 break;
1733 }
1734 }
1735
1736 if (*p) /* Print the rest of the message. */
1737 vmessage ((char *)NULL, p, ap);
1738
1739 fputc ('\n', stderr);
1740 }
1741
1742 /* Figure file and line of the given INSN. */
1743
1744 static void
1745 file_and_line_for_asm (insn, pfile, pline)
1746 rtx insn;
1747 char **pfile;
1748 int *pline;
1749 {
1750 rtx body = PATTERN (insn);
1751 rtx asmop;
1752
1753 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1754 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1755 asmop = SET_SRC (body);
1756 else if (GET_CODE (body) == ASM_OPERANDS)
1757 asmop = body;
1758 else if (GET_CODE (body) == PARALLEL
1759 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1760 asmop = SET_SRC (XVECEXP (body, 0, 0));
1761 else if (GET_CODE (body) == PARALLEL
1762 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1763 asmop = XVECEXP (body, 0, 0);
1764 else
1765 asmop = NULL;
1766
1767 if (asmop)
1768 {
1769 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1770 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1771 }
1772 else
1773 {
1774 *pfile = input_filename;
1775 *pline = lineno;
1776 }
1777 }
1778
1779 /* Report an error at line LINE of file FILE. */
1780
1781 static void
1782 v_error_with_file_and_line (file, line, msgid, ap)
1783 const char *file;
1784 int line;
1785 const char *msgid;
1786 va_list ap;
1787 {
1788 count_error (0);
1789 report_error_function (file);
1790 v_message_with_file_and_line (file, line, 0, msgid, ap);
1791 }
1792
1793 void
1794 error_with_file_and_line VPROTO((const char *file, int line,
1795 const char *msgid, ...))
1796 {
1797 #ifndef ANSI_PROTOTYPES
1798 const char *file;
1799 int line;
1800 const char *msgid;
1801 #endif
1802 va_list ap;
1803
1804 VA_START (ap, msgid);
1805
1806 #ifndef ANSI_PROTOTYPES
1807 file = va_arg (ap, const char *);
1808 line = va_arg (ap, int);
1809 msgid = va_arg (ap, const char *);
1810 #endif
1811
1812 v_error_with_file_and_line (file, line, msgid, ap);
1813 va_end (ap);
1814 }
1815
1816 /* Report an error at the declaration DECL.
1817 MSGID is a format string which uses %s to substitute the declaration
1818 name; subsequent substitutions are a la printf. */
1819
1820 static void
1821 v_error_with_decl (decl, msgid, ap)
1822 tree decl;
1823 const char *msgid;
1824 va_list ap;
1825 {
1826 count_error (0);
1827 report_error_function (DECL_SOURCE_FILE (decl));
1828 v_message_with_decl (decl, 0, msgid, ap);
1829 }
1830
1831 void
1832 error_with_decl VPROTO((tree decl, const char *msgid, ...))
1833 {
1834 #ifndef ANSI_PROTOTYPES
1835 tree decl;
1836 const char *msgid;
1837 #endif
1838 va_list ap;
1839
1840 VA_START (ap, msgid);
1841
1842 #ifndef ANSI_PROTOTYPES
1843 decl = va_arg (ap, tree);
1844 msgid = va_arg (ap, const char *);
1845 #endif
1846
1847 v_error_with_decl (decl, msgid, ap);
1848 va_end (ap);
1849 }
1850
1851 /* Report an error at the line number of the insn INSN.
1852 This is used only when INSN is an `asm' with operands,
1853 and each ASM_OPERANDS records its own source file and line. */
1854
1855 static void
1856 v_error_for_asm (insn, msgid, ap)
1857 rtx insn;
1858 const char *msgid;
1859 va_list ap;
1860 {
1861 char *file;
1862 int line;
1863
1864 count_error (0);
1865 file_and_line_for_asm (insn, &file, &line);
1866 report_error_function (file);
1867 v_message_with_file_and_line (file, line, 0, msgid, ap);
1868 }
1869
1870 void
1871 error_for_asm VPROTO((rtx insn, const char *msgid, ...))
1872 {
1873 #ifndef ANSI_PROTOTYPES
1874 rtx insn;
1875 const char *msgid;
1876 #endif
1877 va_list ap;
1878
1879 VA_START (ap, msgid);
1880
1881 #ifndef ANSI_PROTOTYPES
1882 insn = va_arg (ap, rtx);
1883 msgid = va_arg (ap, const char *);
1884 #endif
1885
1886 v_error_for_asm (insn, msgid, ap);
1887 va_end (ap);
1888 }
1889
1890 /* Report an error at the current line number. */
1891
1892 static void
1893 verror (msgid, ap)
1894 const char *msgid;
1895 va_list ap;
1896 {
1897 v_error_with_file_and_line (input_filename, lineno, msgid, ap);
1898 }
1899
1900 void
1901 error VPROTO((const char *msgid, ...))
1902 {
1903 #ifndef ANSI_PROTOTYPES
1904 const char *msgid;
1905 #endif
1906 va_list ap;
1907
1908 VA_START (ap, msgid);
1909
1910 #ifndef ANSI_PROTOTYPES
1911 msgid = va_arg (ap, const char *);
1912 #endif
1913
1914 verror (msgid, ap);
1915 va_end (ap);
1916 }
1917
1918 /* Report a fatal error at the current line number. */
1919
1920 static void
1921 vfatal (msgid, ap)
1922 const char *msgid;
1923 va_list ap;
1924 {
1925 verror (msgid, ap);
1926 exit (FATAL_EXIT_CODE);
1927 }
1928
1929 void
1930 fatal VPROTO((const char *msgid, ...))
1931 {
1932 #ifndef ANSI_PROTOTYPES
1933 const char *msgid;
1934 #endif
1935 va_list ap;
1936
1937 VA_START (ap, msgid);
1938
1939 #ifndef ANSI_PROTOTYPES
1940 msgid = va_arg (ap, const char *);
1941 #endif
1942
1943 vfatal (msgid, ap);
1944 va_end (ap);
1945 }
1946
1947 void
1948 _fatal_insn (msgid, insn, file, line, function)
1949 const char *msgid;
1950 rtx insn;
1951 const char *file;
1952 int line;
1953 const char *function;
1954 {
1955 error (msgid);
1956 debug_rtx (insn);
1957 fancy_abort (file, line, function);
1958 }
1959
1960 void
1961 _fatal_insn_not_found (insn, file, line, function)
1962 rtx insn;
1963 const char *file;
1964 int line;
1965 const char *function;
1966 {
1967 if (INSN_CODE (insn) < 0)
1968 _fatal_insn ("Unrecognizable insn:", insn, file, line, function);
1969 else
1970 _fatal_insn ("Insn does not satisfy its constraints:",
1971 insn, file, line, function);
1972 }
1973
1974 /* Report a warning at line LINE of file FILE. */
1975
1976 static void
1977 v_warning_with_file_and_line (file, line, msgid, ap)
1978 const char *file;
1979 int line;
1980 const char *msgid;
1981 va_list ap;
1982 {
1983 if (count_error (1))
1984 {
1985 report_error_function (file);
1986 v_message_with_file_and_line (file, line, 1, msgid, ap);
1987 }
1988 }
1989
1990 void
1991 warning_with_file_and_line VPROTO((const char *file, int line,
1992 const char *msgid, ...))
1993 {
1994 #ifndef ANSI_PROTOTYPES
1995 const char *file;
1996 int line;
1997 const char *msgid;
1998 #endif
1999 va_list ap;
2000
2001 VA_START (ap, msgid);
2002
2003 #ifndef ANSI_PROTOTYPES
2004 file = va_arg (ap, const char *);
2005 line = va_arg (ap, int);
2006 msgid = va_arg (ap, const char *);
2007 #endif
2008
2009 v_warning_with_file_and_line (file, line, msgid, ap);
2010 va_end (ap);
2011 }
2012
2013 /* Report a warning at the declaration DECL.
2014 MSGID is a format string which uses %s to substitute the declaration
2015 name; subsequent substitutions are a la printf. */
2016
2017 static void
2018 v_warning_with_decl (decl, msgid, ap)
2019 tree decl;
2020 const char *msgid;
2021 va_list ap;
2022 {
2023 if (count_error (1))
2024 {
2025 report_error_function (DECL_SOURCE_FILE (decl));
2026 v_message_with_decl (decl, 1, msgid, ap);
2027 }
2028 }
2029
2030 void
2031 warning_with_decl VPROTO((tree decl, const char *msgid, ...))
2032 {
2033 #ifndef ANSI_PROTOTYPES
2034 tree decl;
2035 const char *msgid;
2036 #endif
2037 va_list ap;
2038
2039 VA_START (ap, msgid);
2040
2041 #ifndef ANSI_PROTOTYPES
2042 decl = va_arg (ap, tree);
2043 msgid = va_arg (ap, const char *);
2044 #endif
2045
2046 v_warning_with_decl (decl, msgid, ap);
2047 va_end (ap);
2048 }
2049
2050 /* Report a warning at the line number of the insn INSN.
2051 This is used only when INSN is an `asm' with operands,
2052 and each ASM_OPERANDS records its own source file and line. */
2053
2054 static void
2055 v_warning_for_asm (insn, msgid, ap)
2056 rtx insn;
2057 const char *msgid;
2058 va_list ap;
2059 {
2060 if (count_error (1))
2061 {
2062 char *file;
2063 int line;
2064
2065 file_and_line_for_asm (insn, &file, &line);
2066 report_error_function (file);
2067 v_message_with_file_and_line (file, line, 1, msgid, ap);
2068 }
2069 }
2070
2071 void
2072 warning_for_asm VPROTO((rtx insn, const char *msgid, ...))
2073 {
2074 #ifndef ANSI_PROTOTYPES
2075 rtx insn;
2076 const char *msgid;
2077 #endif
2078 va_list ap;
2079
2080 VA_START (ap, msgid);
2081
2082 #ifndef ANSI_PROTOTYPES
2083 insn = va_arg (ap, rtx);
2084 msgid = va_arg (ap, const char *);
2085 #endif
2086
2087 v_warning_for_asm (insn, msgid, ap);
2088 va_end (ap);
2089 }
2090
2091 /* Report a warning at the current line number. */
2092
2093 static void
2094 vwarning (msgid, ap)
2095 const char *msgid;
2096 va_list ap;
2097 {
2098 v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
2099 }
2100
2101 void
2102 warning VPROTO((const char *msgid, ...))
2103 {
2104 #ifndef ANSI_PROTOTYPES
2105 const char *msgid;
2106 #endif
2107 va_list ap;
2108
2109 VA_START (ap, msgid);
2110
2111 #ifndef ANSI_PROTOTYPES
2112 msgid = va_arg (ap, const char *);
2113 #endif
2114
2115 vwarning (msgid, ap);
2116 va_end (ap);
2117 }
2118
2119 /* These functions issue either warnings or errors depending on
2120 -pedantic-errors. */
2121
2122 static void
2123 vpedwarn (msgid, ap)
2124 const char *msgid;
2125 va_list ap;
2126 {
2127 if (flag_pedantic_errors)
2128 verror (msgid, ap);
2129 else
2130 vwarning (msgid, ap);
2131 }
2132
2133 void
2134 pedwarn VPROTO((const char *msgid, ...))
2135 {
2136 #ifndef ANSI_PROTOTYPES
2137 const char *msgid;
2138 #endif
2139 va_list ap;
2140
2141 VA_START (ap, msgid);
2142
2143 #ifndef ANSI_PROTOTYPES
2144 msgid = va_arg (ap, const char *);
2145 #endif
2146
2147 vpedwarn (msgid, ap);
2148 va_end (ap);
2149 }
2150
2151 static void
2152 v_pedwarn_with_decl (decl, msgid, ap)
2153 tree decl;
2154 const char *msgid;
2155 va_list ap;
2156 {
2157 /* We don't want -pedantic-errors to cause the compilation to fail from
2158 "errors" in system header files. Sometimes fixincludes can't fix what's
2159 broken (eg: unsigned char bitfields - fixing it may change the alignment
2160 which will cause programs to mysteriously fail because the C library
2161 or kernel uses the original layout). There's no point in issuing a
2162 warning either, it's just unnecessary noise. */
2163
2164 if (! DECL_IN_SYSTEM_HEADER (decl))
2165 {
2166 if (flag_pedantic_errors)
2167 v_error_with_decl (decl, msgid, ap);
2168 else
2169 v_warning_with_decl (decl, msgid, ap);
2170 }
2171 }
2172
2173 void
2174 pedwarn_with_decl VPROTO((tree decl, const char *msgid, ...))
2175 {
2176 #ifndef ANSI_PROTOTYPES
2177 tree decl;
2178 const char *msgid;
2179 #endif
2180 va_list ap;
2181
2182 VA_START (ap, msgid);
2183
2184 #ifndef ANSI_PROTOTYPES
2185 decl = va_arg (ap, tree);
2186 msgid = va_arg (ap, const char *);
2187 #endif
2188
2189 v_pedwarn_with_decl (decl, msgid, ap);
2190 va_end (ap);
2191 }
2192
2193 static void
2194 v_pedwarn_with_file_and_line (file, line, msgid, ap)
2195 const char *file;
2196 int line;
2197 const char *msgid;
2198 va_list ap;
2199 {
2200 if (flag_pedantic_errors)
2201 v_error_with_file_and_line (file, line, msgid, ap);
2202 else
2203 v_warning_with_file_and_line (file, line, msgid, ap);
2204 }
2205
2206 void
2207 pedwarn_with_file_and_line VPROTO((const char *file, int line,
2208 const char *msgid, ...))
2209 {
2210 #ifndef ANSI_PROTOTYPES
2211 const char *file;
2212 int line;
2213 const char *msgid;
2214 #endif
2215 va_list ap;
2216
2217 VA_START (ap, msgid);
2218
2219 #ifndef ANSI_PROTOTYPES
2220 file = va_arg (ap, const char *);
2221 line = va_arg (ap, int);
2222 msgid = va_arg (ap, const char *);
2223 #endif
2224
2225 v_pedwarn_with_file_and_line (file, line, msgid, ap);
2226 va_end (ap);
2227 }
2228
2229 /* Apologize for not implementing some feature. */
2230
2231 static void
2232 vsorry (msgid, ap)
2233 const char *msgid;
2234 va_list ap;
2235 {
2236 sorrycount++;
2237 if (input_filename)
2238 fprintf (stderr, "%s:%d: ", input_filename, lineno);
2239 else
2240 fprintf (stderr, "%s: ", progname);
2241 notice ("sorry, not implemented: ");
2242 vnotice (stderr, msgid, ap);
2243 fputc ('\n', stderr);
2244 }
2245
2246 void
2247 sorry VPROTO((const char *msgid, ...))
2248 {
2249 #ifndef ANSI_PROTOTYPES
2250 const char *msgid;
2251 #endif
2252 va_list ap;
2253
2254 VA_START (ap, msgid);
2255
2256 #ifndef ANSI_PROTOTYPES
2257 msgid = va_arg (ap, const char *);
2258 #endif
2259
2260 vsorry (msgid, ap);
2261 va_end (ap);
2262 }
2263 \f
2264
2265 /* This calls abort and is used to avoid problems when abort if a macro.
2266 It is used when we need to pass the address of abort. */
2267
2268 void
2269 do_abort ()
2270 {
2271 abort ();
2272 }
2273
2274 /* When `malloc.c' is compiled with `rcheck' defined,
2275 it calls this function to report clobberage. */
2276
2277 void
2278 botch (s)
2279 const char * s ATTRIBUTE_UNUSED;
2280 {
2281 abort ();
2282 }
2283 \f
2284 /* Return the logarithm of X, base 2, considering X unsigned,
2285 if X is a power of 2. Otherwise, returns -1.
2286
2287 This should be used via the `exact_log2' macro. */
2288
2289 int
2290 exact_log2_wide (x)
2291 register unsigned HOST_WIDE_INT x;
2292 {
2293 register int log = 0;
2294 /* Test for 0 or a power of 2. */
2295 if (x == 0 || x != (x & -x))
2296 return -1;
2297 while ((x >>= 1) != 0)
2298 log++;
2299 return log;
2300 }
2301
2302 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2303 If X is 0, return -1.
2304
2305 This should be used via the floor_log2 macro. */
2306
2307 int
2308 floor_log2_wide (x)
2309 register unsigned HOST_WIDE_INT x;
2310 {
2311 register int log = -1;
2312 while (x != 0)
2313 log++,
2314 x >>= 1;
2315 return log;
2316 }
2317
2318 static int float_handler_set;
2319 int float_handled;
2320 jmp_buf float_handler;
2321
2322 /* Signals actually come here. */
2323
2324 static void
2325 float_signal (signo)
2326 /* If this is missing, some compilers complain. */
2327 int signo ATTRIBUTE_UNUSED;
2328 {
2329 if (float_handled == 0)
2330 abort ();
2331 #if defined (USG) || defined (hpux)
2332 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2333 #endif
2334 float_handled = 0;
2335 signal (SIGFPE, float_signal);
2336 longjmp (float_handler, 1);
2337 }
2338
2339 /* Specify where to longjmp to when a floating arithmetic error happens.
2340 If HANDLER is 0, it means don't handle the errors any more. */
2341
2342 void
2343 set_float_handler (handler)
2344 jmp_buf handler;
2345 {
2346 float_handled = (handler != 0);
2347 if (handler)
2348 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2349
2350 if (float_handled && ! float_handler_set)
2351 {
2352 signal (SIGFPE, float_signal);
2353 float_handler_set = 1;
2354 }
2355 }
2356
2357 /* This is a wrapper function for code which might elicit an
2358 arithmetic exception. That code should be passed in as a function
2359 pointer FN, and one argument DATA. DATA is usually a struct which
2360 contains the real input and output for function FN. This function
2361 returns 0 (failure) if longjmp was called (i.e. an exception
2362 occured.) It returns 1 (success) otherwise. */
2363
2364 int
2365 do_float_handler (fn, data)
2366 void (*fn) PROTO ((PTR));
2367 PTR data;
2368 {
2369 jmp_buf buf;
2370
2371 if (setjmp (buf))
2372 {
2373 /* We got here via longjmp() caused by an exception in function fn() */
2374 set_float_handler (NULL);
2375 return 0;
2376 }
2377
2378 set_float_handler (buf);
2379 (*fn)(data);
2380 set_float_handler (NULL);
2381 return 1;
2382 }
2383
2384 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2385 error happens, pushing the previous specification into OLD_HANDLER.
2386 Return an indication of whether there was a previous handler in effect. */
2387
2388 int
2389 push_float_handler (handler, old_handler)
2390 jmp_buf handler, old_handler;
2391 {
2392 int was_handled = float_handled;
2393
2394 float_handled = 1;
2395 if (was_handled)
2396 memcpy ((char *) old_handler, (char *) float_handler,
2397 sizeof (float_handler));
2398
2399 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
2400 return was_handled;
2401 }
2402
2403 /* Restore the previous specification of whether and where to longjmp to
2404 when a floating arithmetic error happens. */
2405
2406 void
2407 pop_float_handler (handled, handler)
2408 int handled;
2409 jmp_buf handler;
2410 {
2411 float_handled = handled;
2412 if (handled)
2413 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2414 }
2415
2416 /* Handler for SIGPIPE. */
2417
2418 static void
2419 pipe_closed (signo)
2420 /* If this is missing, some compilers complain. */
2421 int signo ATTRIBUTE_UNUSED;
2422 {
2423 fatal ("output pipe has been closed");
2424 }
2425
2426 /* Strip off a legitimate source ending from the input string NAME of
2427 length LEN. Rather than having to know the names used by all of
2428 our front ends, we strip off an ending of a period followed by
2429 up to five characters. (Java uses ".class".) */
2430
2431 void
2432 strip_off_ending (name, len)
2433 char *name;
2434 int len;
2435 {
2436 int i;
2437 for (i = 2; i < 6 && len > i; i++)
2438 {
2439 if (name[len - i] == '.')
2440 {
2441 name[len - i] = '\0';
2442 break;
2443 }
2444 }
2445 }
2446
2447 /* Output a quoted string. */
2448
2449 void
2450 output_quoted_string (asm_file, string)
2451 FILE *asm_file;
2452 const char *string;
2453 {
2454 #ifdef OUTPUT_QUOTED_STRING
2455 OUTPUT_QUOTED_STRING (asm_file, string);
2456 #else
2457 char c;
2458
2459 putc ('\"', asm_file);
2460 while ((c = *string++) != 0)
2461 {
2462 if (c == '\"' || c == '\\')
2463 putc ('\\', asm_file);
2464 putc (c, asm_file);
2465 }
2466 putc ('\"', asm_file);
2467 #endif
2468 }
2469
2470 /* Output a file name in the form wanted by System V. */
2471
2472 void
2473 output_file_directive (asm_file, input_name)
2474 FILE *asm_file;
2475 const char *input_name;
2476 {
2477 int len = strlen (input_name);
2478 const char *na = input_name + len;
2479
2480 /* NA gets INPUT_NAME sans directory names. */
2481 while (na > input_name)
2482 {
2483 if (na[-1] == '/')
2484 break;
2485 #ifdef DIR_SEPARATOR
2486 if (na[-1] == DIR_SEPARATOR)
2487 break;
2488 #endif
2489 na--;
2490 }
2491
2492 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2493 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2494 #else
2495 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2496 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2497 #else
2498 fprintf (asm_file, "\t.file\t");
2499 output_quoted_string (asm_file, na);
2500 fputc ('\n', asm_file);
2501 #endif
2502 #endif
2503 }
2504 \f
2505 #ifdef ASM_IDENTIFY_LANGUAGE
2506 /* Routine to build language identifier for object file. */
2507 static void
2508 output_lang_identify (asm_out_file)
2509 FILE *asm_out_file;
2510 {
2511 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2512 char *s = (char *) alloca (len);
2513 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2514 ASM_OUTPUT_LABEL (asm_out_file, s);
2515 }
2516 #endif
2517
2518 /* Routine to open a dump file. */
2519 static void
2520 open_dump_file (suffix, function_name)
2521 const char *suffix;
2522 const char *function_name;
2523 {
2524 char *dumpname;
2525
2526 TIMEVAR
2527 (dump_time,
2528 {
2529 dumpname = concat (dump_base_name, suffix, NULL);
2530
2531 if (rtl_dump_file != NULL)
2532 fclose (rtl_dump_file);
2533
2534 rtl_dump_file = fopen (dumpname, "a");
2535
2536 if (rtl_dump_file == NULL)
2537 pfatal_with_name (dumpname);
2538
2539 free (dumpname);
2540
2541 if (function_name)
2542 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2543 });
2544
2545 return;
2546 }
2547
2548 /* Routine to close a dump file. */
2549 static void
2550 close_dump_file (func, insns)
2551 void (*func) PROTO ((FILE *, rtx));
2552 rtx insns;
2553 {
2554 TIMEVAR
2555 (dump_time,
2556 {
2557 if (func)
2558 func (rtl_dump_file, insns);
2559
2560 fflush (rtl_dump_file);
2561 fclose (rtl_dump_file);
2562
2563 rtl_dump_file = NULL;
2564 });
2565
2566 return;
2567 }
2568
2569 /* Routine to dump rtl into a file. */
2570 static void
2571 dump_rtl (suffix, decl, func, insns)
2572 const char *suffix;
2573 tree decl;
2574 void (*func) PROTO ((FILE *, rtx));
2575 rtx insns;
2576 {
2577 open_dump_file (suffix, decl_printable_name (decl, 2));
2578 close_dump_file (func, insns);
2579 }
2580
2581 /* Routine to empty a dump file. */
2582 static void
2583 clean_dump_file (suffix)
2584 const char *suffix;
2585 {
2586 char * const dumpname = concat (dump_base_name, suffix, NULL);
2587
2588 rtl_dump_file = fopen (dumpname, "w");
2589
2590 if (rtl_dump_file == NULL)
2591 pfatal_with_name (dumpname);
2592
2593 free (dumpname);
2594
2595 fclose (rtl_dump_file);
2596 rtl_dump_file = NULL;
2597
2598 return;
2599 }
2600
2601 /* Do any final processing required for the declarations in VEC, of
2602 which there are LEN. We write out inline functions and variables
2603 that have been deferred until this point, but which are required.
2604 Returns non-zero if anything was put out. */
2605 int
2606 wrapup_global_declarations (vec, len)
2607 tree *vec;
2608 int len;
2609 {
2610 tree decl;
2611 int i;
2612 int reconsider;
2613 int output_something = 0;
2614
2615 for (i = 0; i < len; i++)
2616 {
2617 decl = vec[i];
2618
2619 /* We're not deferring this any longer. */
2620 DECL_DEFER_OUTPUT (decl) = 0;
2621
2622 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2623 && incomplete_decl_finalize_hook != 0)
2624 (*incomplete_decl_finalize_hook) (decl);
2625 }
2626
2627 /* Now emit any global variables or functions that we have been
2628 putting off. We need to loop in case one of the things emitted
2629 here references another one which comes earlier in the list. */
2630 do
2631 {
2632 reconsider = 0;
2633 for (i = 0; i < len; i++)
2634 {
2635 decl = vec[i];
2636
2637 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2638 continue;
2639
2640 /* Don't write out static consts, unless we still need them.
2641
2642 We also keep static consts if not optimizing (for debugging),
2643 unless the user specified -fno-keep-static-consts.
2644 ??? They might be better written into the debug information.
2645 This is possible when using DWARF.
2646
2647 A language processor that wants static constants to be always
2648 written out (even if it is not used) is responsible for
2649 calling rest_of_decl_compilation itself. E.g. the C front-end
2650 calls rest_of_decl_compilation from finish_decl.
2651 One motivation for this is that is conventional in some
2652 environments to write things like:
2653 static const char rcsid[] = "... version string ...";
2654 intending to force the string to be in the executable.
2655
2656 A language processor that would prefer to have unneeded
2657 static constants "optimized away" would just defer writing
2658 them out until here. E.g. C++ does this, because static
2659 constants are often defined in header files.
2660
2661 ??? A tempting alternative (for both C and C++) would be
2662 to force a constant to be written if and only if it is
2663 defined in a main file, as opposed to an include file. */
2664
2665 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2666 && (! TREE_READONLY (decl)
2667 || TREE_PUBLIC (decl)
2668 || (!optimize && flag_keep_static_consts)
2669 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2670 {
2671 reconsider = 1;
2672 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2673 }
2674
2675 if (TREE_CODE (decl) == FUNCTION_DECL
2676 && DECL_INITIAL (decl) != 0
2677 && DECL_SAVED_INSNS (decl) != 0
2678 && (flag_keep_inline_functions
2679 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2680 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2681 {
2682 reconsider = 1;
2683 temporary_allocation ();
2684 output_inline_function (decl);
2685 permanent_allocation (1);
2686 }
2687 }
2688
2689 if (reconsider)
2690 output_something = 1;
2691 }
2692 while (reconsider);
2693
2694 return output_something;
2695 }
2696
2697 /* Issue appropriate warnings for the global declarations in VEC (of
2698 which there are LEN). Output debugging information for them. */
2699 void
2700 check_global_declarations (vec, len)
2701 tree *vec;
2702 int len;
2703 {
2704 tree decl;
2705 int i;
2706
2707 for (i = 0; i < len; i++)
2708 {
2709 decl = vec[i];
2710
2711 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2712 && ! TREE_ASM_WRITTEN (decl))
2713 /* Cancel the RTL for this decl so that, if debugging info
2714 output for global variables is still to come,
2715 this one will be omitted. */
2716 DECL_RTL (decl) = NULL;
2717
2718 /* Warn about any function
2719 declared static but not defined.
2720 We don't warn about variables,
2721 because many programs have static variables
2722 that exist only to get some text into the object file. */
2723 if (TREE_CODE (decl) == FUNCTION_DECL
2724 && (warn_unused
2725 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2726 && DECL_INITIAL (decl) == 0
2727 && DECL_EXTERNAL (decl)
2728 && ! DECL_ARTIFICIAL (decl)
2729 && ! TREE_PUBLIC (decl))
2730 {
2731 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2732 pedwarn_with_decl (decl,
2733 "`%s' used but never defined");
2734 else
2735 warning_with_decl (decl,
2736 "`%s' declared `static' but never defined");
2737 /* This symbol is effectively an "extern" declaration now. */
2738 TREE_PUBLIC (decl) = 1;
2739 assemble_external (decl);
2740 }
2741
2742 /* Warn about static fns or vars defined but not used,
2743 but not about inline functions or static consts
2744 since defining those in header files is normal practice. */
2745 if (warn_unused
2746 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2747 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2748 && ! DECL_IN_SYSTEM_HEADER (decl)
2749 && ! DECL_EXTERNAL (decl)
2750 && ! TREE_PUBLIC (decl)
2751 && ! TREE_USED (decl)
2752 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2753 /* The TREE_USED bit for file-scope decls
2754 is kept in the identifier, to handle multiple
2755 external decls in different scopes. */
2756 && ! TREE_USED (DECL_NAME (decl)))
2757 warning_with_decl (decl, "`%s' defined but not used");
2758
2759 #ifdef SDB_DEBUGGING_INFO
2760 /* The COFF linker can move initialized global vars to the end.
2761 And that can screw up the symbol ordering.
2762 By putting the symbols in that order to begin with,
2763 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2764 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2765 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2766 && ! DECL_EXTERNAL (decl)
2767 && DECL_RTL (decl) != 0)
2768 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2769
2770 /* Output COFF information for non-global
2771 file-scope initialized variables. */
2772 if (write_symbols == SDB_DEBUG
2773 && TREE_CODE (decl) == VAR_DECL
2774 && DECL_INITIAL (decl)
2775 && ! DECL_EXTERNAL (decl)
2776 && DECL_RTL (decl) != 0
2777 && GET_CODE (DECL_RTL (decl)) == MEM)
2778 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2779 #endif /* SDB_DEBUGGING_INFO */
2780 #ifdef DWARF_DEBUGGING_INFO
2781 /* Output DWARF information for file-scope tentative data object
2782 declarations, file-scope (extern) function declarations (which
2783 had no corresponding body) and file-scope tagged type declarations
2784 and definitions which have not yet been forced out. */
2785
2786 if (write_symbols == DWARF_DEBUG
2787 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2788 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2789 #endif
2790 #ifdef DWARF2_DEBUGGING_INFO
2791 /* Output DWARF2 information for file-scope tentative data object
2792 declarations, file-scope (extern) function declarations (which
2793 had no corresponding body) and file-scope tagged type declarations
2794 and definitions which have not yet been forced out. */
2795
2796 if (write_symbols == DWARF2_DEBUG
2797 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2798 TIMEVAR (symout_time, dwarf2out_decl (decl));
2799 #endif
2800 }
2801 }
2802
2803 /* Compile an entire file of output from cpp, named NAME.
2804 Write a file of assembly output and various debugging dumps. */
2805
2806 static void
2807 compile_file (name)
2808 char *name;
2809 {
2810 tree globals;
2811 int start_time;
2812
2813 int name_specified = name != 0;
2814
2815 if (dump_base_name == 0)
2816 dump_base_name = name ? name : "gccdump";
2817
2818 parse_time = 0;
2819 varconst_time = 0;
2820 integration_time = 0;
2821 jump_time = 0;
2822 cse_time = 0;
2823 gcse_time = 0;
2824 loop_time = 0;
2825 cse2_time = 0;
2826 branch_prob_time = 0;
2827 flow_time = 0;
2828 combine_time = 0;
2829 regmove_time = 0;
2830 sched_time = 0;
2831 local_alloc_time = 0;
2832 global_alloc_time = 0;
2833 flow2_time = 0;
2834 sched2_time = 0;
2835 #ifdef DELAY_SLOTS
2836 dbr_sched_time = 0;
2837 #endif
2838 shorten_branch_time = 0;
2839 stack_reg_time = 0;
2840 final_time = 0;
2841 symout_time = 0;
2842 dump_time = 0;
2843
2844 /* Initialize data in various passes. */
2845
2846 init_obstacks ();
2847 init_tree_codes ();
2848 name = init_parse (name);
2849 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2850 || debug_info_level == DINFO_LEVEL_VERBOSE
2851 || flag_test_coverage
2852 || warn_notreached);
2853 init_regs ();
2854 init_decl_processing ();
2855 init_optabs ();
2856 init_stmt ();
2857 init_loop ();
2858 init_reload ();
2859 init_alias_once ();
2860 init_function_once ();
2861 init_stor_layout_once ();
2862
2863 /* The following initialization functions need to generate rtl, so
2864 provide a dummy function context for them. */
2865 init_dummy_function_start ();
2866 init_expmed ();
2867 init_expr_once ();
2868 if (flag_caller_saves)
2869 init_caller_save ();
2870 expand_dummy_function_end ();
2871
2872 /* If auxiliary info generation is desired, open the output file.
2873 This goes in the same directory as the source file--unlike
2874 all the other output files. */
2875 if (flag_gen_aux_info)
2876 {
2877 aux_info_file = fopen (aux_info_file_name, "w");
2878 if (aux_info_file == 0)
2879 pfatal_with_name (aux_info_file_name);
2880 }
2881
2882 /* Clear the dump files. */
2883 if (rtl_dump)
2884 clean_dump_file (".rtl");
2885 if (jump_opt_dump)
2886 {
2887 clean_dump_file (".jump");
2888 if (graph_dump_format != no_graph)
2889 clean_graph_dump_file (dump_base_name, ".jump");
2890 }
2891 if (addressof_dump)
2892 {
2893 clean_dump_file (".addressof");
2894 if (graph_dump_format != no_graph)
2895 clean_graph_dump_file (dump_base_name, ".addressof");
2896 }
2897 if (cse_dump)
2898 {
2899 clean_dump_file (".cse");
2900 if (graph_dump_format != no_graph)
2901 clean_graph_dump_file (dump_base_name, ".cse");
2902 }
2903 if (loop_dump)
2904 {
2905 clean_dump_file (".loop");
2906 if (graph_dump_format != no_graph)
2907 clean_graph_dump_file (dump_base_name, ".loop");
2908 }
2909 if (cse2_dump)
2910 {
2911 clean_dump_file (".cse2");
2912 if (graph_dump_format != no_graph)
2913 clean_graph_dump_file (dump_base_name, ".cse2");
2914 }
2915 if (branch_prob_dump)
2916 {
2917 clean_dump_file (".bp");
2918 if (graph_dump_format != no_graph)
2919 clean_graph_dump_file (dump_base_name, ".bp");
2920 }
2921 if (flow_dump)
2922 {
2923 clean_dump_file (".flow");
2924 if (graph_dump_format != no_graph)
2925 clean_graph_dump_file (dump_base_name, ".flow");
2926 }
2927 if (combine_dump)
2928 {
2929 clean_dump_file (".combine");
2930 if (graph_dump_format != no_graph)
2931 clean_graph_dump_file (dump_base_name, ".combine");
2932 }
2933 if (regmove_dump)
2934 {
2935 clean_dump_file (".regmove");
2936 if (graph_dump_format != no_graph)
2937 clean_graph_dump_file (dump_base_name, ".regmove");
2938 }
2939 if (sched_dump)
2940 {
2941 clean_dump_file (".sched");
2942 if (graph_dump_format != no_graph)
2943 clean_graph_dump_file (dump_base_name, ".sched");
2944 }
2945 if (local_reg_dump)
2946 {
2947 clean_dump_file (".lreg");
2948 if (graph_dump_format != no_graph)
2949 clean_graph_dump_file (dump_base_name, ".lreg");
2950 }
2951 if (global_reg_dump)
2952 {
2953 clean_dump_file (".greg");
2954 if (graph_dump_format != no_graph)
2955 clean_graph_dump_file (dump_base_name, ".greg");
2956 }
2957 if (flow2_dump)
2958 {
2959 clean_dump_file (".flow2");
2960 if (graph_dump_format != no_graph)
2961 clean_graph_dump_file (dump_base_name, ".flow2");
2962 }
2963 if (peephole2_dump)
2964 {
2965 clean_dump_file (".peephole2");
2966 if (graph_dump_format != no_graph)
2967 clean_graph_dump_file (dump_base_name, ".peephole2");
2968 }
2969 if (sched2_dump)
2970 {
2971 clean_dump_file (".sched2");
2972 if (graph_dump_format != no_graph)
2973 clean_graph_dump_file (dump_base_name, ".sched2");
2974 }
2975 if (jump2_opt_dump)
2976 {
2977 clean_dump_file (".jump2");
2978 if (graph_dump_format != no_graph)
2979 clean_graph_dump_file (dump_base_name, ".jump2");
2980 }
2981 #ifdef DELAY_SLOTS
2982 if (dbr_sched_dump)
2983 {
2984 clean_dump_file (".dbr");
2985 if (graph_dump_format != no_graph)
2986 clean_graph_dump_file (dump_base_name, ".dbr");
2987 }
2988 #endif
2989 if (gcse_dump)
2990 {
2991 clean_dump_file (".gcse");
2992 if (graph_dump_format != no_graph)
2993 clean_graph_dump_file (dump_base_name, ".gcse");
2994 }
2995 #ifdef STACK_REGS
2996 if (stack_reg_dump)
2997 {
2998 clean_dump_file (".stack");
2999 if (graph_dump_format != no_graph)
3000 clean_graph_dump_file (dump_base_name, ".stack");
3001 }
3002 #endif
3003 #ifdef MACHINE_DEPENDENT_REORG
3004 if (mach_dep_reorg_dump)
3005 {
3006 clean_dump_file (".mach");
3007 if (graph_dump_format != no_graph)
3008 clean_graph_dump_file (dump_base_name, ".mach");
3009 }
3010 #endif
3011
3012 /* Open assembler code output file. */
3013
3014 if (flag_syntax_only)
3015 asm_out_file = NULL;
3016 else
3017 {
3018 if (! name_specified && asm_file_name == 0)
3019 asm_out_file = stdout;
3020 else
3021 {
3022 int len = strlen (dump_base_name);
3023 register char *dumpname = (char *) xmalloc (len + 6);
3024 strcpy (dumpname, dump_base_name);
3025 strip_off_ending (dumpname, len);
3026 strcat (dumpname, ".s");
3027 if (asm_file_name == 0)
3028 asm_file_name = xstrdup (dumpname);
3029 if (!strcmp (asm_file_name, "-"))
3030 asm_out_file = stdout;
3031 else
3032 asm_out_file = fopen (asm_file_name, "w");
3033 if (asm_out_file == 0)
3034 pfatal_with_name (asm_file_name);
3035 }
3036
3037 #ifdef IO_BUFFER_SIZE
3038 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
3039 _IOFBF, IO_BUFFER_SIZE);
3040 #endif
3041 }
3042
3043 input_filename = name;
3044
3045 /* Put an entry on the input file stack for the main input file. */
3046 input_file_stack
3047 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
3048 input_file_stack->next = 0;
3049 input_file_stack->name = input_filename;
3050
3051 /* Perform language-specific initialization.
3052 This may set main_input_filename. */
3053 lang_init ();
3054
3055 /* If the input doesn't start with a #line, use the input name
3056 as the official input file name. */
3057 if (main_input_filename == 0)
3058 main_input_filename = name;
3059
3060 if (flag_syntax_only)
3061 {
3062 write_symbols = NO_DEBUG;
3063 profile_flag = 0;
3064 profile_block_flag = 0;
3065 }
3066 else
3067 {
3068 ASM_FILE_START (asm_out_file);
3069
3070 #ifdef ASM_COMMENT_START
3071 if (flag_verbose_asm)
3072 {
3073 /* Print the list of options in effect. */
3074 print_version (asm_out_file, ASM_COMMENT_START);
3075 print_switch_values (asm_out_file, 0, MAX_LINE,
3076 ASM_COMMENT_START, " ", "\n");
3077 /* Add a blank line here so it appears in assembler output but not
3078 screen output. */
3079 fprintf (asm_out_file, "\n");
3080 }
3081 #endif
3082
3083 /* Output something to inform GDB that this compilation was by GCC. */
3084 #ifndef ASM_IDENTIFY_GCC
3085 fprintf (asm_out_file, "gcc2_compiled.:\n");
3086 #else
3087 ASM_IDENTIFY_GCC (asm_out_file);
3088 #endif
3089
3090 /* Output something to identify which front-end produced this file. */
3091 #ifdef ASM_IDENTIFY_LANGUAGE
3092 ASM_IDENTIFY_LANGUAGE (asm_out_file);
3093 #endif
3094 } /* ! flag_syntax_only */
3095
3096 #ifndef ASM_OUTPUT_SECTION_NAME
3097 if (flag_function_sections)
3098 {
3099 warning ("-ffunction-sections not supported for this target.");
3100 flag_function_sections = 0;
3101 }
3102 if (flag_data_sections)
3103 {
3104 warning ("-fdata-sections not supported for this target.");
3105 flag_data_sections = 0;
3106 }
3107 #endif
3108
3109 if (flag_function_sections
3110 && (profile_flag || profile_block_flag))
3111 {
3112 warning ("-ffunction-sections disabled; it makes profiling impossible.");
3113 flag_function_sections = 0;
3114 }
3115
3116 #ifndef OBJECT_FORMAT_ELF
3117 if (flag_function_sections && write_symbols != NO_DEBUG)
3118 warning ("-ffunction-sections may affect debugging on some targets.");
3119 #endif
3120
3121 /* ??? Note: There used to be a conditional here
3122 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
3123 This was to guarantee separation between gcc_compiled. and
3124 the first function, for the sake of dbx on Suns.
3125 However, having the extra zero here confused the Emacs
3126 code for unexec, and might confuse other programs too.
3127 Therefore, I took out that change.
3128 In future versions we should find another way to solve
3129 that dbx problem. -- rms, 23 May 93. */
3130
3131 /* Don't let the first function fall at the same address
3132 as gcc_compiled., if profiling. */
3133 if (profile_flag || profile_block_flag)
3134 {
3135 /* It's best if we can write a nop here since some
3136 assemblers don't tolerate zeros in the text section. */
3137 if (insn_template[CODE_FOR_nop] != 0)
3138 output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR);
3139 else
3140 assemble_zeros (UNITS_PER_WORD);
3141 }
3142
3143 /* If dbx symbol table desired, initialize writing it
3144 and output the predefined types. */
3145 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3146 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3147 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
3148 getdecls ()));
3149 #endif
3150 #ifdef SDB_DEBUGGING_INFO
3151 if (write_symbols == SDB_DEBUG)
3152 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
3153 getdecls ()));
3154 #endif
3155 #ifdef DWARF_DEBUGGING_INFO
3156 if (write_symbols == DWARF_DEBUG)
3157 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
3158 #endif
3159 #ifdef DWARF2_UNWIND_INFO
3160 if (dwarf2out_do_frame ())
3161 dwarf2out_frame_init ();
3162 #endif
3163 #ifdef DWARF2_DEBUGGING_INFO
3164 if (write_symbols == DWARF2_DEBUG)
3165 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
3166 #endif
3167
3168 /* Initialize yet another pass. */
3169
3170 init_final (main_input_filename);
3171 init_branch_prob (dump_base_name);
3172
3173 start_time = get_run_time ();
3174
3175 /* Call the parser, which parses the entire file
3176 (calling rest_of_compilation for each function). */
3177
3178 if (yyparse () != 0)
3179 {
3180 if (errorcount == 0)
3181 notice ("Errors detected in input file (your bison.simple is out of date)\n");
3182
3183 /* In case there were missing closebraces,
3184 get us back to the global binding level. */
3185 while (! global_bindings_p ())
3186 poplevel (0, 0, 0);
3187 }
3188
3189 /* Compilation is now finished except for writing
3190 what's left of the symbol table output. */
3191
3192 parse_time += get_run_time () - start_time;
3193
3194 parse_time -= integration_time;
3195 parse_time -= varconst_time;
3196
3197 if (flag_syntax_only)
3198 goto finish_syntax;
3199
3200 globals = getdecls ();
3201
3202 /* Really define vars that have had only a tentative definition.
3203 Really output inline functions that must actually be callable
3204 and have not been output so far. */
3205
3206 {
3207 int len = list_length (globals);
3208 tree *vec = (tree *) alloca (sizeof (tree) * len);
3209 int i;
3210 tree decl;
3211
3212 /* Process the decls in reverse order--earliest first.
3213 Put them into VEC from back to front, then take out from front. */
3214
3215 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
3216 vec[len - i - 1] = decl;
3217
3218 wrapup_global_declarations (vec, len);
3219
3220 /* This must occur after the loop to output deferred functions. Else
3221 the profiler initializer would not be emitted if all the functions
3222 in this compilation unit were deferred.
3223
3224 output_func_start_profiler can not cause any additional functions or
3225 data to need to be output, so it need not be in the deferred function
3226 loop above. */
3227 output_func_start_profiler ();
3228
3229 /* Now that all possible functions have been output, we can dump
3230 the exception table. */
3231
3232 output_exception_table ();
3233
3234 check_global_declarations (vec, len);
3235 }
3236
3237 /* Write out any pending weak symbol declarations. */
3238
3239 weak_finish ();
3240
3241 /* Do dbx symbols */
3242 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3243 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3244 TIMEVAR (symout_time,
3245 {
3246 dbxout_finish (asm_out_file, main_input_filename);
3247 });
3248 #endif
3249
3250 #ifdef DWARF_DEBUGGING_INFO
3251 if (write_symbols == DWARF_DEBUG)
3252 TIMEVAR (symout_time,
3253 {
3254 dwarfout_finish ();
3255 });
3256 #endif
3257
3258 #ifdef DWARF2_UNWIND_INFO
3259 if (dwarf2out_do_frame ())
3260 dwarf2out_frame_finish ();
3261 #endif
3262
3263 #ifdef DWARF2_DEBUGGING_INFO
3264 if (write_symbols == DWARF2_DEBUG)
3265 TIMEVAR (symout_time,
3266 {
3267 dwarf2out_finish ();
3268 });
3269 #endif
3270
3271 /* Output some stuff at end of file if nec. */
3272
3273 end_final (dump_base_name);
3274
3275 if (branch_prob_dump)
3276 open_dump_file (".bp", NULL);
3277
3278 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
3279
3280 if (branch_prob_dump)
3281 close_dump_file (NULL, NULL_RTX);
3282
3283 #ifdef ASM_FILE_END
3284 ASM_FILE_END (asm_out_file);
3285 #endif
3286
3287
3288 /* Language-specific end of compilation actions. */
3289 finish_syntax:
3290 lang_finish ();
3291
3292 /* Close the dump files. */
3293
3294 if (flag_gen_aux_info)
3295 {
3296 fclose (aux_info_file);
3297 if (errorcount)
3298 unlink (aux_info_file_name);
3299 }
3300
3301 if (combine_dump)
3302 {
3303 open_dump_file (".combine", NULL);
3304 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
3305 close_dump_file (NULL, NULL_RTX);
3306 }
3307
3308 /* Close non-debugging input and output files. Take special care to note
3309 whether fclose returns an error, since the pages might still be on the
3310 buffer chain while the file is open. */
3311
3312 finish_parse ();
3313
3314 if (! flag_syntax_only
3315 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
3316 fatal_io_error (asm_file_name);
3317
3318 /* Do whatever is necessary to finish printing the graphs. */
3319 if (graph_dump_format != no_graph)
3320 {
3321 if (jump_opt_dump)
3322 finish_graph_dump_file (dump_base_name, ".jump");
3323 if (addressof_dump)
3324 finish_graph_dump_file (dump_base_name, ".addressof");
3325 if (cse_dump)
3326 finish_graph_dump_file (dump_base_name, ".cse");
3327 if (loop_dump)
3328 finish_graph_dump_file (dump_base_name, ".loop");
3329 if (cse2_dump)
3330 finish_graph_dump_file (dump_base_name, ".cse2");
3331 if (branch_prob_dump)
3332 finish_graph_dump_file (dump_base_name, ".bp");
3333 if (flow_dump)
3334 finish_graph_dump_file (dump_base_name, ".flow");
3335 if (combine_dump)
3336 finish_graph_dump_file (dump_base_name, ".combine");
3337 if (regmove_dump)
3338 finish_graph_dump_file (dump_base_name, ".regmove");
3339 if (sched_dump)
3340 finish_graph_dump_file (dump_base_name, ".sched");
3341 if (local_reg_dump)
3342 finish_graph_dump_file (dump_base_name, ".lreg");
3343 if (global_reg_dump)
3344 finish_graph_dump_file (dump_base_name, ".greg");
3345 if (flow2_dump)
3346 finish_graph_dump_file (dump_base_name, ".flow2");
3347 if (sched2_dump)
3348 finish_graph_dump_file (dump_base_name, ".sched2");
3349 if (jump2_opt_dump)
3350 finish_graph_dump_file (dump_base_name, ".jump2");
3351 #ifdef DELAY_SLOTS
3352 if (dbr_sched_dump)
3353 finish_graph_dump_file (dump_base_name, ".dbr");
3354 #endif
3355 if (gcse_dump)
3356 finish_graph_dump_file (dump_base_name, ".gcse");
3357 #ifdef STACK_REGS
3358 if (stack_reg_dump)
3359 finish_graph_dump_file (dump_base_name, ".stack");
3360 #endif
3361 #ifdef MACHINE_DEPENDENT_REORG
3362 if (mach_dep_reorg_dump)
3363 finish_graph_dump_file (dump_base_name, ".mach");
3364 #endif
3365 }
3366
3367 /* Free up memory for the benefit of leak detectors. */
3368 free_reg_info ();
3369
3370 /* Print the times. */
3371
3372 if (! quiet_flag)
3373 {
3374 all_time = get_run_time ();
3375
3376 fprintf (stderr,"\n");
3377
3378 print_time ("parse", parse_time);
3379 print_time ("integration", integration_time);
3380 print_time ("jump", jump_time);
3381 print_time ("cse", cse_time);
3382 print_time ("gcse", gcse_time);
3383 print_time ("loop", loop_time);
3384 print_time ("cse2", cse2_time);
3385 print_time ("branch-prob", branch_prob_time);
3386 print_time ("flow", flow_time);
3387 print_time ("combine", combine_time);
3388 print_time ("regmove", regmove_time);
3389 print_time ("sched", sched_time);
3390 print_time ("local-alloc", local_alloc_time);
3391 print_time ("global-alloc", global_alloc_time);
3392 print_time ("flow2", flow2_time);
3393 print_time ("sched2", sched2_time);
3394 #ifdef DELAY_SLOTS
3395 print_time ("dbranch", dbr_sched_time);
3396 #endif
3397 print_time ("shorten-branch", shorten_branch_time);
3398 print_time ("stack-reg", stack_reg_time);
3399 print_time ("final", final_time);
3400 print_time ("varconst", varconst_time);
3401 print_time ("symout", symout_time);
3402 print_time ("dump", dump_time);
3403 print_time ("gc", gc_time);
3404 }
3405 }
3406 \f
3407 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3408 and TYPE_DECL nodes.
3409
3410 This does nothing for local (non-static) variables.
3411 Otherwise, it sets up the RTL and outputs any assembler code
3412 (label definition, storage allocation and initialization).
3413
3414 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3415 the assembler symbol name to be used. TOP_LEVEL is nonzero
3416 if this declaration is not within a function. */
3417
3418 void
3419 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
3420 tree decl;
3421 const char *asmspec;
3422 int top_level;
3423 int at_end;
3424 {
3425 /* Declarations of variables, and of functions defined elsewhere. */
3426
3427 /* The most obvious approach, to put an #ifndef around where
3428 this macro is used, doesn't work since it's inside a macro call. */
3429 #ifndef ASM_FINISH_DECLARE_OBJECT
3430 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3431 #endif
3432
3433 /* Forward declarations for nested functions are not "external",
3434 but we need to treat them as if they were. */
3435 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
3436 || TREE_CODE (decl) == FUNCTION_DECL)
3437 TIMEVAR (varconst_time,
3438 {
3439 make_decl_rtl (decl, asmspec, top_level);
3440 /* Initialized extern variable exists to be replaced
3441 with its value, or represents something that will be
3442 output in another file. */
3443 if (! (TREE_CODE (decl) == VAR_DECL
3444 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
3445 && DECL_INITIAL (decl) != 0
3446 && DECL_INITIAL (decl) != error_mark_node))
3447 /* Don't output anything
3448 when a tentative file-scope definition is seen.
3449 But at end of compilation, do output code for them. */
3450 if (! (! at_end && top_level
3451 && (DECL_INITIAL (decl) == 0
3452 || DECL_INITIAL (decl) == error_mark_node)))
3453 assemble_variable (decl, top_level, at_end, 0);
3454 if (decl == last_assemble_variable_decl)
3455 {
3456 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
3457 top_level, at_end);
3458 }
3459 });
3460 else if (DECL_REGISTER (decl) && asmspec != 0)
3461 {
3462 if (decode_reg_name (asmspec) >= 0)
3463 {
3464 DECL_RTL (decl) = 0;
3465 make_decl_rtl (decl, asmspec, top_level);
3466 }
3467 else
3468 error ("invalid register name `%s' for register variable", asmspec);
3469 }
3470 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3471 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3472 && TREE_CODE (decl) == TYPE_DECL)
3473 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
3474 #endif
3475 #ifdef SDB_DEBUGGING_INFO
3476 else if (write_symbols == SDB_DEBUG && top_level
3477 && TREE_CODE (decl) == TYPE_DECL)
3478 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
3479 #endif
3480 }
3481
3482 /* Called after finishing a record, union or enumeral type. */
3483
3484 void
3485 rest_of_type_compilation (type, toplev)
3486 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3487 tree type;
3488 int toplev;
3489 #else
3490 tree type ATTRIBUTE_UNUSED;
3491 int toplev ATTRIBUTE_UNUSED;
3492 #endif
3493 {
3494 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3495 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3496 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3497 #endif
3498 #ifdef SDB_DEBUGGING_INFO
3499 if (write_symbols == SDB_DEBUG)
3500 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3501 #endif
3502 }
3503
3504 /* This is called from finish_function (within yyparse)
3505 after each top-level definition is parsed.
3506 It is supposed to compile that function or variable
3507 and output the assembler code for it.
3508 After we return, the tree storage is freed. */
3509
3510 void
3511 rest_of_compilation (decl)
3512 tree decl;
3513 {
3514 register rtx insns;
3515 int start_time = get_run_time ();
3516 int tem;
3517 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3518 to be restored after we finish compiling the function
3519 (for use when compiling inline calls to this function). */
3520 tree saved_block_tree = 0;
3521 /* Likewise, for DECL_ARGUMENTS. */
3522 tree saved_arguments = 0;
3523 int failure = 0;
3524 int rebuild_label_notes_after_reload;
3525
3526 /* If we are reconsidering an inline function
3527 at the end of compilation, skip the stuff for making it inline. */
3528
3529 if (DECL_SAVED_INSNS (decl) == 0)
3530 {
3531 int inlinable = 0;
3532 const char *lose;
3533
3534 /* If requested, consider whether to make this function inline. */
3535 if (DECL_INLINE (decl) || flag_inline_functions)
3536 TIMEVAR (integration_time,
3537 {
3538 lose = function_cannot_inline_p (decl);
3539 if (lose || ! optimize)
3540 {
3541 if (warn_inline && DECL_INLINE (decl))
3542 warning_with_decl (decl, lose);
3543 DECL_ABSTRACT_ORIGIN (decl) = 0;
3544 /* Don't really compile an extern inline function.
3545 If we can't make it inline, pretend
3546 it was only declared. */
3547 if (DECL_EXTERNAL (decl))
3548 {
3549 DECL_INITIAL (decl) = 0;
3550 goto exit_rest_of_compilation;
3551 }
3552 }
3553 else
3554 /* ??? Note that this has the effect of making it look
3555 like "inline" was specified for a function if we choose
3556 to inline it. This isn't quite right, but it's
3557 probably not worth the trouble to fix. */
3558 inlinable = DECL_INLINE (decl) = 1;
3559 });
3560
3561 insns = get_insns ();
3562
3563 /* Dump the rtl code if we are dumping rtl. */
3564
3565 if (rtl_dump)
3566 {
3567 open_dump_file (".rtl", decl_printable_name (decl, 2));
3568
3569 if (DECL_SAVED_INSNS (decl))
3570 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3571
3572 close_dump_file (print_rtl, insns);
3573 }
3574
3575 /* If function is inline, and we don't yet know whether to
3576 compile it by itself, defer decision till end of compilation.
3577 finish_compilation will call rest_of_compilation again
3578 for those functions that need to be output. Also defer those
3579 functions that we are supposed to defer. */
3580
3581 if (inlinable)
3582 DECL_DEFER_OUTPUT (decl) = 1;
3583
3584 if (DECL_DEFER_OUTPUT (decl)
3585 || (DECL_INLINE (decl)
3586 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3587 && ! flag_keep_inline_functions)
3588 || DECL_EXTERNAL (decl))))
3589 {
3590 DECL_DEFER_OUTPUT (decl) = 1;
3591
3592 /* If -Wreturn-type, we have to do a bit of compilation.
3593 However, if we just fall through we will call
3594 save_for_inline_copying() which results in excessive
3595 memory use. Instead, we just want to call
3596 jump_optimize() to figure out whether or not we can fall
3597 off the end of the function; we do the minimum amount of
3598 work necessary to make that safe. And, we set optimize
3599 to zero to keep jump_optimize from working too hard. */
3600 if (warn_return_type)
3601 {
3602 int saved_optimize = optimize;
3603 optimize = 0;
3604 find_exception_handler_labels ();
3605 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3606 !JUMP_AFTER_REGSCAN);
3607 optimize = saved_optimize;
3608 }
3609
3610 #ifdef DWARF_DEBUGGING_INFO
3611 /* Generate the DWARF info for the "abstract" instance
3612 of a function which we may later generate inlined and/or
3613 out-of-line instances of. */
3614 if (write_symbols == DWARF_DEBUG)
3615 {
3616 set_decl_abstract_flags (decl, 1);
3617 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3618 set_decl_abstract_flags (decl, 0);
3619 }
3620 #endif
3621 #ifdef DWARF2_DEBUGGING_INFO
3622 /* Generate the DWARF2 info for the "abstract" instance
3623 of a function which we may later generate inlined and/or
3624 out-of-line instances of. */
3625 if (write_symbols == DWARF2_DEBUG)
3626 {
3627 set_decl_abstract_flags (decl, 1);
3628 TIMEVAR (symout_time, dwarf2out_decl (decl));
3629 set_decl_abstract_flags (decl, 0);
3630 }
3631 #endif
3632 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3633 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
3634 goto exit_rest_of_compilation;
3635 }
3636
3637 /* If specified extern inline but we aren't inlining it, we are
3638 done. This goes for anything that gets here with DECL_EXTERNAL
3639 set, not just things with DECL_INLINE. */
3640 if (DECL_EXTERNAL (decl))
3641 goto exit_rest_of_compilation;
3642 }
3643
3644 /* Initialize some variables used by the optimizers. */
3645 init_function_for_compilation ();
3646
3647 if (! DECL_DEFER_OUTPUT (decl))
3648 TREE_ASM_WRITTEN (decl) = 1;
3649
3650 /* Now that integrate will no longer see our rtl, we need not distinguish
3651 between the return value of this function and the return value of called
3652 functions. */
3653 rtx_equal_function_value_matters = 0;
3654
3655 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3656 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3657 {
3658 goto exit_rest_of_compilation;
3659 }
3660
3661 /* Emit code to get eh context, if needed. */
3662 emit_eh_context ();
3663
3664 #ifdef FINALIZE_PIC
3665 /* If we are doing position-independent code generation, now
3666 is the time to output special prologues and epilogues.
3667 We do not want to do this earlier, because it just clutters
3668 up inline functions with meaningless insns. */
3669 if (flag_pic)
3670 FINALIZE_PIC;
3671 #endif
3672
3673 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3674 Note that that may have been done above, in save_for_inline_copying.
3675 The call to resume_temporary_allocation near the end of this function
3676 goes back to the usual state of affairs. This must be done after
3677 we've built up any unwinders for exception handling, and done
3678 the FINALIZE_PIC work, if necessary. */
3679
3680 rtl_in_current_obstack ();
3681
3682 insns = get_insns ();
3683
3684 /* Copy any shared structure that should not be shared. */
3685
3686 unshare_all_rtl (insns);
3687
3688 init_EXPR_INSN_LIST_cache ();
3689
3690 #ifdef SETJMP_VIA_SAVE_AREA
3691 /* This must be performed before virutal register instantiation. */
3692 if (current_function_calls_alloca)
3693 optimize_save_area_alloca (insns);
3694 #endif
3695
3696 /* Instantiate all virtual registers. */
3697
3698 instantiate_virtual_regs (current_function_decl, get_insns ());
3699
3700 /* See if we have allocated stack slots that are not directly addressable.
3701 If so, scan all the insns and create explicit address computation
3702 for all references to such slots. */
3703 /* fixup_stack_slots (); */
3704
3705 /* Find all the EH handlers. */
3706 find_exception_handler_labels ();
3707
3708 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3709 are initialized and to compute whether control can drop off the end
3710 of the function. */
3711 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3712 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3713 JUMP_AFTER_REGSCAN));
3714
3715 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3716 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3717 goto exit_rest_of_compilation;
3718
3719 /* Dump rtl code after jump, if we are doing that. */
3720 if (jump_opt_dump)
3721 dump_rtl (".jump", decl, print_rtl, insns);
3722
3723 if (ggc_p)
3724 ggc_collect ();
3725
3726 /* Perform common subexpression elimination.
3727 Nonzero value from `cse_main' means that jumps were simplified
3728 and some code may now be unreachable, so do
3729 jump optimization again. */
3730
3731 if (optimize > 0)
3732 {
3733 if (cse_dump)
3734 open_dump_file (".cse", decl_printable_name (decl, 2));
3735
3736 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3737
3738 if (flag_thread_jumps)
3739 /* Hacks by tiemann & kenner. */
3740 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3741
3742 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3743 0, rtl_dump_file));
3744 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3745
3746 if (tem || optimize > 1)
3747 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3748 !JUMP_NOOP_MOVES,
3749 !JUMP_AFTER_REGSCAN));
3750
3751 /* Dump rtl code after cse, if we are doing that. */
3752
3753 if (cse_dump)
3754 {
3755 close_dump_file (print_rtl, insns);
3756 if (graph_dump_format != no_graph)
3757 print_rtl_graph_with_bb (dump_base_name, ".cse", insns);
3758 }
3759 }
3760
3761 purge_addressof (insns);
3762 reg_scan (insns, max_reg_num (), 1);
3763
3764 if (addressof_dump)
3765 {
3766 dump_rtl (".addressof", decl, print_rtl, insns);
3767 if (graph_dump_format != no_graph)
3768 print_rtl_graph_with_bb (dump_base_name, ".addressof", insns);
3769 }
3770
3771 if (ggc_p)
3772 ggc_collect ();
3773
3774 /* Perform global cse. */
3775
3776 if (optimize > 0 && flag_gcse)
3777 {
3778 if (gcse_dump)
3779 open_dump_file (".gcse", decl_printable_name (decl, 2));
3780
3781 TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file));
3782
3783 /* If gcse altered any jumps, rerun jump optimizations to clean
3784 things up. */
3785 if (tem)
3786 {
3787 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3788 !JUMP_NOOP_MOVES,
3789 !JUMP_AFTER_REGSCAN));
3790 }
3791
3792 if (gcse_dump)
3793 {
3794 close_dump_file (print_rtl, insns);
3795 if (graph_dump_format != no_graph)
3796 print_rtl_graph_with_bb (dump_base_name, ".gcse", insns);
3797 }
3798
3799 if (ggc_p)
3800 ggc_collect ();
3801 }
3802 /* Move constant computations out of loops. */
3803
3804 if (optimize > 0)
3805 {
3806 if (loop_dump)
3807 open_dump_file (".loop", decl_printable_name (decl, 2));
3808
3809 TIMEVAR
3810 (loop_time,
3811 {
3812 if (flag_rerun_loop_opt)
3813 {
3814 /* We only want to perform unrolling once. */
3815
3816 loop_optimize (insns, rtl_dump_file, 0, 0);
3817
3818
3819 /* The first call to loop_optimize makes some instructions
3820 trivially dead. We delete those instructions now in the
3821 hope that doing so will make the heuristics in loop work
3822 better and possibly speed up compilation. */
3823 delete_trivially_dead_insns (insns, max_reg_num ());
3824
3825 /* The regscan pass is currently necessary as the alias
3826 analysis code depends on this information. */
3827 reg_scan (insns, max_reg_num (), 1);
3828 }
3829 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
3830 });
3831
3832 /* Dump rtl code after loop opt, if we are doing that. */
3833
3834 if (loop_dump)
3835 {
3836 close_dump_file (print_rtl, insns);
3837 if (graph_dump_format != no_graph)
3838 print_rtl_graph_with_bb (dump_base_name, ".loop", insns);
3839 }
3840
3841 if (ggc_p)
3842 ggc_collect ();
3843 }
3844
3845 if (optimize > 0)
3846 {
3847 if (cse2_dump)
3848 open_dump_file (".cse2", decl_printable_name (decl, 2));
3849
3850 if (flag_rerun_cse_after_loop)
3851 {
3852 /* Running another jump optimization pass before the second
3853 cse pass sometimes simplifies the RTL enough to allow
3854 the second CSE pass to do a better job. Jump_optimize can change
3855 max_reg_num so we must rerun reg_scan afterwards.
3856 ??? Rework to not call reg_scan so often. */
3857 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3858 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3859 !JUMP_NOOP_MOVES,
3860 JUMP_AFTER_REGSCAN));
3861
3862 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3863 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3864 1, rtl_dump_file));
3865 if (tem)
3866 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3867 !JUMP_NOOP_MOVES,
3868 !JUMP_AFTER_REGSCAN));
3869 }
3870
3871 if (flag_thread_jumps)
3872 {
3873 /* This pass of jump threading straightens out code
3874 that was kinked by loop optimization. */
3875 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3876 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3877 }
3878
3879 /* Dump rtl code after cse, if we are doing that. */
3880
3881 if (cse2_dump)
3882 {
3883 close_dump_file (print_rtl, insns);
3884 if (graph_dump_format != no_graph)
3885 print_rtl_graph_with_bb (dump_base_name, ".cse2", insns);
3886 }
3887
3888 if (ggc_p)
3889 ggc_collect ();
3890 }
3891
3892 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3893 {
3894 if (branch_prob_dump)
3895 open_dump_file (".bp", decl_printable_name (decl, 2));
3896
3897 TIMEVAR
3898 (branch_prob_time,
3899 {
3900 branch_prob (insns, rtl_dump_file);
3901 });
3902
3903 if (branch_prob_dump)
3904 {
3905 close_dump_file (print_rtl, insns);
3906 if (graph_dump_format != no_graph)
3907 print_rtl_graph_with_bb (dump_base_name, ".bp", insns);
3908 }
3909
3910 if (ggc_p)
3911 ggc_collect ();
3912 }
3913
3914 /* We are no longer anticipating cse in this function, at least. */
3915
3916 cse_not_expected = 1;
3917
3918 /* Now we choose between stupid (pcc-like) register allocation
3919 (if we got the -noreg switch and not -opt)
3920 and smart register allocation. */
3921
3922 if (optimize > 0) /* Stupid allocation probably won't work */
3923 obey_regdecls = 0; /* if optimizations being done. */
3924
3925 regclass_init ();
3926
3927 /* Print function header into flow dump now
3928 because doing the flow analysis makes some of the dump. */
3929
3930 if (flow_dump)
3931 open_dump_file (".flow", decl_printable_name (decl, 2));
3932
3933 if (obey_regdecls)
3934 {
3935 TIMEVAR (flow_time,
3936 {
3937 regclass (insns, max_reg_num ());
3938 stupid_life_analysis (insns, max_reg_num (),
3939 rtl_dump_file);
3940 });
3941 }
3942 else
3943 {
3944 /* Do control and data flow analysis,
3945 and write some of the results to dump file. */
3946
3947 TIMEVAR
3948 (flow_time,
3949 {
3950 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
3951 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
3952 });
3953
3954 if (warn_uninitialized)
3955 {
3956 uninitialized_vars_warning (DECL_INITIAL (decl));
3957 setjmp_args_warning ();
3958 }
3959 }
3960
3961 /* Dump rtl after flow analysis. */
3962
3963 if (flow_dump)
3964 {
3965 close_dump_file (print_rtl_with_bb, insns);
3966 if (graph_dump_format != no_graph)
3967 print_rtl_graph_with_bb (dump_base_name, ".flow", insns);
3968 }
3969
3970 if (ggc_p)
3971 ggc_collect ();
3972
3973 /* The first life analysis pass has finished. From now on we can not
3974 generate any new pseudos. */
3975 no_new_pseudos = 1;
3976
3977 /* If -opt, try combining insns through substitution. */
3978
3979 if (optimize > 0)
3980 {
3981 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3982
3983 /* Dump rtl code after insn combination. */
3984
3985 if (combine_dump)
3986 {
3987 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
3988 if (graph_dump_format != no_graph)
3989 print_rtl_graph_with_bb (dump_base_name, ".combine", insns);
3990 }
3991
3992 if (ggc_p)
3993 ggc_collect ();
3994 }
3995
3996 /* Register allocation pre-pass, to reduce number of moves
3997 necessary for two-address machines. */
3998 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3999 {
4000 if (regmove_dump)
4001 open_dump_file (".regmove", decl_printable_name (decl, 2));
4002
4003 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
4004 rtl_dump_file));
4005
4006 if (regmove_dump)
4007 {
4008 close_dump_file (print_rtl_with_bb, insns);
4009 if (graph_dump_format != no_graph)
4010 print_rtl_graph_with_bb (dump_base_name, ".regmove", insns);
4011 }
4012
4013 if (ggc_p)
4014 ggc_collect ();
4015 }
4016
4017 /* Print function header into sched dump now
4018 because doing the sched analysis makes some of the dump. */
4019
4020 if (optimize > 0 && flag_schedule_insns)
4021 {
4022 if (sched_dump)
4023 open_dump_file (".sched", decl_printable_name (decl, 2));
4024
4025 /* Do control and data sched analysis,
4026 and write some of the results to dump file. */
4027
4028 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
4029
4030 /* Dump rtl after instruction scheduling. */
4031
4032 if (sched_dump)
4033 {
4034 close_dump_file (print_rtl_with_bb, insns);
4035 if (graph_dump_format != no_graph)
4036 print_rtl_graph_with_bb (dump_base_name, ".sched", insns);
4037 }
4038
4039 if (ggc_p)
4040 ggc_collect ();
4041 }
4042
4043 /* Determine if the current function is a leaf before running reload
4044 since this can impact optimizations done by the prologue and
4045 epilogue thus changing register elimination offsets. */
4046 current_function_is_leaf = leaf_function_p ();
4047
4048 /* Unless we did stupid register allocation,
4049 allocate pseudo-regs that are used only within 1 basic block.
4050
4051 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
4052 jump optimizer after register allocation and reloading are finished. */
4053
4054 if (!obey_regdecls)
4055 TIMEVAR (local_alloc_time,
4056 {
4057 recompute_reg_usage (insns, ! optimize_size);
4058 regclass (insns, max_reg_num ());
4059 rebuild_label_notes_after_reload = local_alloc ();
4060 });
4061 else
4062 rebuild_label_notes_after_reload = 0;
4063
4064 /* Dump rtl code after allocating regs within basic blocks. */
4065
4066 if (local_reg_dump)
4067 {
4068 open_dump_file (".lreg", decl_printable_name (decl, 2));
4069
4070 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
4071 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
4072
4073 close_dump_file (print_rtl_with_bb, insns);
4074 if (graph_dump_format != no_graph)
4075 print_rtl_graph_with_bb (dump_base_name, ".lreg", insns);
4076 }
4077
4078 if (ggc_p)
4079 ggc_collect ();
4080
4081 if (global_reg_dump)
4082 open_dump_file (".greg", decl_printable_name (decl, 2));
4083
4084 /* Unless we did stupid register allocation,
4085 allocate remaining pseudo-regs, then do the reload pass
4086 fixing up any insns that are invalid. */
4087
4088 TIMEVAR (global_alloc_time,
4089 {
4090 if (!obey_regdecls)
4091 failure = global_alloc (rtl_dump_file);
4092 else
4093 failure = reload (insns, 0, rtl_dump_file);
4094 });
4095
4096
4097 if (failure)
4098 goto exit_rest_of_compilation;
4099
4100 if (ggc_p)
4101 ggc_collect ();
4102
4103 /* Do a very simple CSE pass over just the hard registers. */
4104 if (optimize > 0)
4105 reload_cse_regs (insns);
4106
4107 /* Register allocation and reloading may have turned an indirect jump into
4108 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
4109 jumping instructions. */
4110 if (rebuild_label_notes_after_reload)
4111 TIMEVAR (jump_time, rebuild_jump_labels (insns));
4112
4113 /* If optimizing and we are performing instruction scheduling after
4114 reload, then go ahead and split insns now since we are about to
4115 recompute flow information anyway.
4116
4117 reload_cse_regs may expose more splitting opportunities, expecially
4118 for double-word operations. */
4119 if (optimize > 0 && flag_schedule_insns_after_reload)
4120 {
4121 rtx insn;
4122
4123 for (insn = insns; insn; insn = NEXT_INSN (insn))
4124 {
4125 rtx last;
4126
4127 if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
4128 continue;
4129
4130 last = try_split (PATTERN (insn), insn, 1);
4131
4132 if (last != insn)
4133 {
4134 PUT_CODE (insn, NOTE);
4135 NOTE_SOURCE_FILE (insn) = 0;
4136 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
4137 }
4138 }
4139 }
4140
4141 if (global_reg_dump)
4142 {
4143 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
4144 close_dump_file (print_rtl_with_bb, insns);
4145 if (graph_dump_format != no_graph)
4146 print_rtl_graph_with_bb (dump_base_name, ".greg", insns);
4147 }
4148
4149 /* Re-create the death notes which were deleted during reload. */
4150 if (flow2_dump)
4151 open_dump_file (".flow2", decl_printable_name (decl, 2));
4152
4153 if (optimize)
4154 {
4155 TIMEVAR
4156 (flow2_time,
4157 {
4158 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4159 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4160 });
4161
4162 if (ggc_p)
4163 ggc_collect ();
4164 }
4165
4166 flow2_completed = 1;
4167
4168 /* On some machines, the prologue and epilogue code, or parts thereof,
4169 can be represented as RTL. Doing so lets us schedule insns between
4170 it and the rest of the code and also allows delayed branch
4171 scheduling to operate in the epilogue. */
4172
4173 thread_prologue_and_epilogue_insns (insns);
4174
4175 if (flow2_dump)
4176 {
4177 close_dump_file (print_rtl_with_bb, insns);
4178 if (graph_dump_format != no_graph)
4179 print_rtl_graph_with_bb (dump_base_name, ".flow2", insns);
4180 }
4181
4182 #ifdef HAVE_peephole2
4183 if (optimize > 0 && flag_peephole2)
4184 {
4185 if (peephole2_dump)
4186 open_dump_file (".peephole2", decl_printable_name (decl, 2));
4187
4188 peephole2_optimize (rtl_dump_file);
4189
4190 if (peephole2_dump)
4191 {
4192 close_dump_file (print_rtl_with_bb, insns);
4193 if (graph_dump_format != no_graph)
4194 print_rtl_graph_with_bb (dump_base_name, ".peephole2", insns);
4195 }
4196 }
4197 #endif
4198
4199 if (optimize > 0 && flag_schedule_insns_after_reload)
4200 {
4201 if (sched2_dump)
4202 open_dump_file (".sched2", decl_printable_name (decl, 2));
4203
4204 /* Do control and data sched analysis again,
4205 and write some more of the results to dump file. */
4206
4207 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
4208
4209 /* Dump rtl after post-reorder instruction scheduling. */
4210
4211 if (sched2_dump)
4212 {
4213 close_dump_file (print_rtl_with_bb, insns);
4214 if (graph_dump_format != no_graph)
4215 print_rtl_graph_with_bb (dump_base_name, ".sched2", insns);
4216 }
4217
4218 if (ggc_p)
4219 ggc_collect ();
4220 }
4221
4222 #ifdef LEAF_REGISTERS
4223 current_function_uses_only_leaf_regs
4224 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
4225 #endif
4226
4227 /* One more attempt to remove jumps to .+1
4228 left by dead-store-elimination.
4229 Also do cross-jumping this time
4230 and delete no-op move insns. */
4231
4232 if (optimize > 0)
4233 {
4234 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
4235 JUMP_NOOP_MOVES,
4236 !JUMP_AFTER_REGSCAN));
4237
4238 /* Dump rtl code after jump, if we are doing that. */
4239
4240 if (jump2_opt_dump)
4241 {
4242 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
4243 if (graph_dump_format != no_graph)
4244 print_rtl_graph_with_bb (dump_base_name, ".jump2", insns);
4245 }
4246 }
4247
4248 /* If a machine dependent reorganization is needed, call it. */
4249 #ifdef MACHINE_DEPENDENT_REORG
4250 if (mach_dep_reorg_dump)
4251 open_dump_file (".mach", decl_printable_name (decl, 2));
4252
4253 MACHINE_DEPENDENT_REORG (insns);
4254
4255 if (mach_dep_reorg_dump)
4256 {
4257 close_dump_file (print_rtl_with_bb, insns);
4258 if (graph_dump_format != no_graph)
4259 print_rtl_graph_with_bb (dump_base_name, ".mach", insns);
4260 }
4261
4262 if (ggc_p)
4263 ggc_collect ();
4264 #endif
4265
4266 /* If a scheduling pass for delayed branches is to be done,
4267 call the scheduling code. */
4268
4269 #ifdef DELAY_SLOTS
4270 if (optimize > 0 && flag_delayed_branch)
4271 {
4272 if (dbr_sched_dump)
4273 open_dump_file (".dbr", decl_printable_name (decl, 2));
4274
4275 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
4276
4277 if (dbr_sched_dump)
4278 {
4279 close_dump_file (print_rtl_with_bb, insns);
4280 if (graph_dump_format != no_graph)
4281 print_rtl_graph_with_bb (dump_base_name, ".dbr", insns);
4282 }
4283 }
4284
4285 if (ggc_p)
4286 ggc_collect ();
4287 #endif
4288
4289 /* Shorten branches. */
4290 TIMEVAR (shorten_branch_time,
4291 {
4292 shorten_branches (get_insns ());
4293 });
4294
4295 #ifdef STACK_REGS
4296 if (stack_reg_dump)
4297 open_dump_file (".stack", decl_printable_name (decl, 2));
4298
4299 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
4300
4301 if (stack_reg_dump)
4302 {
4303 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
4304 if (graph_dump_format != no_graph)
4305 print_rtl_graph_with_bb (dump_base_name, ".stack", insns);
4306 }
4307
4308 if (ggc_p)
4309 ggc_collect ();
4310 #endif
4311
4312 /* Now turn the rtl into assembler code. */
4313
4314 TIMEVAR (final_time,
4315 {
4316 rtx x;
4317 char *fnname;
4318
4319 /* Get the function's name, as described by its RTL.
4320 This may be different from the DECL_NAME name used
4321 in the source file. */
4322
4323 x = DECL_RTL (decl);
4324 if (GET_CODE (x) != MEM)
4325 abort ();
4326 x = XEXP (x, 0);
4327 if (GET_CODE (x) != SYMBOL_REF)
4328 abort ();
4329 fnname = XSTR (x, 0);
4330
4331 assemble_start_function (decl, fnname);
4332 final_start_function (insns, asm_out_file, optimize);
4333 final (insns, asm_out_file, optimize, 0);
4334 final_end_function (insns, asm_out_file, optimize);
4335 assemble_end_function (decl, fnname);
4336 if (! quiet_flag)
4337 fflush (asm_out_file);
4338
4339 /* Release all memory allocated by flow. */
4340 free_basic_block_vars (0);
4341
4342 /* Release all memory held by regsets now */
4343 regset_release_memory ();
4344 });
4345
4346 if (ggc_p)
4347 ggc_collect ();
4348
4349 /* Write DBX symbols if requested */
4350
4351 /* Note that for those inline functions where we don't initially
4352 know for certain that we will be generating an out-of-line copy,
4353 the first invocation of this routine (rest_of_compilation) will
4354 skip over this code by doing a `goto exit_rest_of_compilation;'.
4355 Later on, finish_compilation will call rest_of_compilation again
4356 for those inline functions that need to have out-of-line copies
4357 generated. During that call, we *will* be routed past here. */
4358
4359 #ifdef DBX_DEBUGGING_INFO
4360 if (write_symbols == DBX_DEBUG)
4361 TIMEVAR (symout_time, dbxout_function (decl));
4362 #endif
4363
4364 #ifdef DWARF_DEBUGGING_INFO
4365 if (write_symbols == DWARF_DEBUG)
4366 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
4367 #endif
4368
4369 #ifdef DWARF2_DEBUGGING_INFO
4370 if (write_symbols == DWARF2_DEBUG)
4371 TIMEVAR (symout_time, dwarf2out_decl (decl));
4372 #endif
4373
4374 exit_rest_of_compilation:
4375
4376 free_bb_mem ();
4377
4378 /* In case the function was not output,
4379 don't leave any temporary anonymous types
4380 queued up for sdb output. */
4381 #ifdef SDB_DEBUGGING_INFO
4382 if (write_symbols == SDB_DEBUG)
4383 sdbout_types (NULL_TREE);
4384 #endif
4385
4386 /* Put back the tree of subblocks and list of arguments
4387 from before we copied them.
4388 Code generation and the output of debugging info may have modified
4389 the copy, but the original is unchanged. */
4390
4391 if (saved_block_tree != 0)
4392 {
4393 DECL_INITIAL (decl) = saved_block_tree;
4394 DECL_ARGUMENTS (decl) = saved_arguments;
4395 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
4396 }
4397
4398 reload_completed = 0;
4399 flow2_completed = 0;
4400 no_new_pseudos = 0;
4401
4402 TIMEVAR (final_time,
4403 {
4404 /* Clear out the insn_length contents now that they are no
4405 longer valid. */
4406 init_insn_lengths ();
4407
4408 /* Clear out the real_constant_chain before some of the rtx's
4409 it runs through become garbage. */
4410 clear_const_double_mem ();
4411
4412 /* Cancel the effect of rtl_in_current_obstack. */
4413 resume_temporary_allocation ();
4414
4415 /* Show no temporary slots allocated. */
4416 init_temp_slots ();
4417 });
4418
4419 /* Make sure volatile mem refs aren't considered valid operands for
4420 arithmetic insns. We must call this here if this is a nested inline
4421 function, since the above code leaves us in the init_recog state
4422 (from final.c), and the function context push/pop code does not
4423 save/restore volatile_ok.
4424
4425 ??? Maybe it isn't necessary for expand_start_function to call this
4426 anymore if we do it here? */
4427
4428 init_recog_no_volatile ();
4429
4430 /* We're done with this function. */
4431 if (! DECL_DEFER_OUTPUT (decl))
4432 free_after_compilation (current_function);
4433
4434 current_function = 0;
4435
4436 ggc_collect ();
4437
4438 /* The parsing time is all the time spent in yyparse
4439 *except* what is spent in this function. */
4440
4441 parse_time -= get_run_time () - start_time;
4442
4443 /* Reset global variables. */
4444 free_basic_block_vars (0);
4445 }
4446 \f
4447 static void
4448 display_help ()
4449 {
4450 int undoc;
4451 unsigned long i;
4452 const char * lang;
4453
4454 #ifndef USE_CPPLIB
4455 printf ("Usage: %s input [switches]\n", progname);
4456 printf ("Switches:\n");
4457 #endif
4458 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
4459 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
4460 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4461 printf (" -finline-limit=<number> Limits the size of inlined functions to <number>\n");
4462
4463 for (i = NUM_ELEM (f_options); i--;)
4464 {
4465 const char * description = f_options[i].description;
4466
4467 if (description != NULL && * description != 0)
4468 printf (" -f%-21s %s\n",
4469 f_options[i].string, description);
4470 }
4471
4472 printf (" -O[number] Set optimisation level to [number]\n");
4473 printf (" -Os Optimise for space rather than speed\n");
4474 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
4475 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
4476 printf (" -w Suppress warnings\n");
4477 printf (" -W Enable extra warnings\n");
4478
4479 for (i = NUM_ELEM (W_options); i--;)
4480 {
4481 const char * description = W_options[i].description;
4482
4483 if (description != NULL && * description != 0)
4484 printf (" -W%-21s %s\n",
4485 W_options[i].string, description);
4486 }
4487
4488 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4489 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4490 printf (" -p Enable function profiling\n");
4491 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4492 printf (" -a Enable block profiling \n");
4493 #endif
4494 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4495 printf (" -ax Enable jump profiling \n");
4496 #endif
4497 printf (" -o <file> Place output into <file> \n");
4498 printf (" -G <number> Put global and static data smaller than <number>\n");
4499 printf (" bytes into a special section (on some targets)\n");
4500
4501 for (i = NUM_ELEM (debug_args); i--;)
4502 {
4503 if (debug_args[i].description != NULL)
4504 printf (" -%-22s %s\n", debug_args[i].arg, debug_args[i].description);
4505 }
4506
4507 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4508 printf (" -quiet Do not display functions compiled or elapsed time\n");
4509 printf (" -version Display the compiler's version\n");
4510 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4511 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4512 #if defined INSN_SCHEDULING
4513 printf (" -sched-verbose=<number> Set the verbosity level of the scheduler\n");
4514 #endif
4515 printf (" --help Display this information\n");
4516
4517 undoc = 0;
4518 lang = "language";
4519
4520 /* Display descriptions of language specific options.
4521 If there is no description, note that there is an undocumented option.
4522 If the description is empty, do not display anything. (This allows
4523 options to be deliberately undocumented, for whatever reason).
4524 If the option string is missing, then this is a marker, indicating
4525 that the description string is in fact the name of a language, whose
4526 language specific options are to follow. */
4527
4528 if (NUM_ELEM (documented_lang_options) > 1)
4529 {
4530 printf ("\nLanguage specific options:\n");
4531
4532 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
4533 {
4534 const char * description = documented_lang_options[i].description;
4535 const char * option = documented_lang_options[i].option;
4536
4537 if (description == NULL)
4538 {
4539 undoc = 1;
4540
4541 if (extra_warnings)
4542 printf (" %-23.23s [undocumented]\n", option);
4543 }
4544 else if (* description == 0)
4545 continue;
4546 else if (option == NULL)
4547 {
4548 if (undoc)
4549 printf
4550 ("\nThere are undocumented %s specific options as well.\n",
4551 lang);
4552 undoc = 0;
4553
4554 printf ("\n Options for %s:\n", description);
4555
4556 lang = description;
4557 }
4558 else
4559 printf (" %-23.23s %s\n", option, description);
4560 }
4561 }
4562
4563 if (undoc)
4564 printf ("\nThere are undocumented %s specific options as well.\n", lang);
4565
4566 if (NUM_ELEM (target_switches) > 1
4567 #ifdef TARGET_OPTIONS
4568 || NUM_ELEM (target_options) > 1
4569 #endif
4570 )
4571 {
4572 int doc = 0;
4573
4574 undoc = 0;
4575
4576 printf ("\nTarget specific options:\n");
4577
4578 for (i = NUM_ELEM (target_switches); i--;)
4579 {
4580 const char * option = target_switches[i].name;
4581 const char * description = target_switches[i].description;
4582
4583 if (option == NULL || * option == 0)
4584 continue;
4585 else if (description == NULL)
4586 {
4587 undoc = 1;
4588
4589 if (extra_warnings)
4590 printf (" -m%-21.21s [undocumented]\n", option);
4591 }
4592 else if (* description != 0)
4593 doc += printf (" -m%-21.21s %s\n", option, description);
4594 }
4595
4596 #ifdef TARGET_OPTIONS
4597 for (i = NUM_ELEM (target_options); i--;)
4598 {
4599 const char * option = target_options[i].prefix;
4600 const char * description = target_options[i].description;
4601
4602 if (option == NULL || * option == 0)
4603 continue;
4604 else if (description == NULL)
4605 {
4606 undoc = 1;
4607
4608 if (extra_warnings)
4609 printf (" -m%-21.21s [undocumented]\n", option);
4610 }
4611 else if (* description != 0)
4612 doc += printf (" -m%-21.21s %s\n", option, description);
4613 }
4614 #endif
4615 if (undoc)
4616 {
4617 if (doc)
4618 printf ("\nThere are undocumented target specific options as well.\n");
4619 else
4620 printf (" They exist, but they are not documented.\n");
4621 }
4622 }
4623 }
4624
4625 /* Compare the user specified 'option' with the language
4626 specific 'lang_option'. Return true if they match, or
4627 if 'option' is a viable prefix of 'lang_option'. */
4628
4629 static int
4630 check_lang_option (option, lang_option)
4631 char * option;
4632 char * lang_option;
4633 {
4634 lang_independent_options * indep_options;
4635 int len;
4636 long k;
4637 char * space;
4638
4639 /* Ignore NULL entries. */
4640 if (option == NULL || lang_option == NULL)
4641 return 0;
4642
4643 if ((space = strchr (lang_option, ' ')) != NULL)
4644 len = space - lang_option;
4645 else
4646 len = strlen (lang_option);
4647
4648 /* If they do not match to the first n characters then fail. */
4649 if (strncmp (option, lang_option, len) != 0)
4650 return 0;
4651
4652 /* Do not accept a lang option, if it matches a normal -f or -W
4653 option. Chill defines a -fpack, but we want to support
4654 -fpack-struct. */
4655
4656 /* An exact match is OK */
4657 if ((int) strlen (option) == len)
4658 return 1;
4659
4660 /* If it is not an -f or -W option allow the match */
4661 if (option[0] != '-')
4662 return 1;
4663
4664 switch (option[1])
4665 {
4666 case 'f': indep_options = f_options; break;
4667 case 'W': indep_options = W_options; break;
4668 default: return 1;
4669 }
4670
4671 /* The option is a -f or -W option.
4672 Skip past the prefix and search for the remainder in the
4673 appropriate table of options. */
4674 option += 2;
4675
4676 if (option[0] == 'n' && option[1] == 'o' && option[2] == '-')
4677 option += 3;
4678
4679 for (k = NUM_ELEM (indep_options); k--;)
4680 {
4681 if (!strcmp (option, indep_options[k].string))
4682 {
4683 /* The option matched a language independent option,
4684 do not allow the language specific match. */
4685
4686 return 0;
4687 }
4688 }
4689
4690 /* The option matches the start of the langauge specific option
4691 and it is not an exact match for a language independent option. */
4692 return 1;
4693 }
4694 \f
4695 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4696 Exit code is 35 if can't open files, 34 if fatal error,
4697 33 if had nonfatal errors, else success. */
4698
4699 int
4700 main (argc, argv)
4701 int argc;
4702 char **argv;
4703 {
4704 register int i;
4705 char *filename = 0;
4706 int flag_print_mem = 0;
4707 int version_flag = 0;
4708 char *p;
4709
4710 /* save in case md file wants to emit args as a comment. */
4711 save_argc = argc;
4712 save_argv = argv;
4713
4714 p = argv[0] + strlen (argv[0]);
4715 while (p != argv[0] && p[-1] != '/'
4716 #ifdef DIR_SEPARATOR
4717 && p[-1] != DIR_SEPARATOR
4718 #endif
4719 )
4720 --p;
4721 progname = p;
4722
4723 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
4724 /* Get rid of any avoidable limit on stack size. */
4725 {
4726 struct rlimit rlim;
4727
4728 /* Set the stack limit huge so that alloca does not fail. */
4729 getrlimit (RLIMIT_STACK, &rlim);
4730 rlim.rlim_cur = rlim.rlim_max;
4731 setrlimit (RLIMIT_STACK, &rlim);
4732 }
4733 #endif
4734
4735 #ifdef HAVE_LC_MESSAGES
4736 setlocale (LC_MESSAGES, "");
4737 #endif
4738 (void) bindtextdomain (PACKAGE, localedir);
4739 (void) textdomain (PACKAGE);
4740
4741 signal (SIGFPE, float_signal);
4742
4743 #ifdef SIGPIPE
4744 signal (SIGPIPE, pipe_closed);
4745 #endif
4746
4747 decl_printable_name = decl_name;
4748 lang_expand_expr = (lang_expand_expr_t) do_abort;
4749
4750 /* Initialize whether `char' is signed. */
4751 flag_signed_char = DEFAULT_SIGNED_CHAR;
4752 #ifdef DEFAULT_SHORT_ENUMS
4753 /* Initialize how much space enums occupy, by default. */
4754 flag_short_enums = DEFAULT_SHORT_ENUMS;
4755 #endif
4756
4757 /* Perform language-specific options intialization. */
4758 lang_init_options ();
4759
4760 /* Scan to see what optimization level has been specified. That will
4761 determine the default value of many flags. */
4762 for (i = 1; i < argc; i++)
4763 {
4764 if (!strcmp (argv[i], "-O"))
4765 {
4766 optimize = 1;
4767 optimize_size = 0;
4768 }
4769 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4770 {
4771 /* Handle -Os, -O2, -O3, -O69, ... */
4772 char *p = &argv[i][2];
4773
4774 if ((p[0] == 's') && (p[1] == 0))
4775 {
4776 optimize_size = 1;
4777
4778 /* Optimizing for size forces optimize to be 2. */
4779 optimize = 2;
4780 }
4781 else
4782 {
4783 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4784 if (optimize_val != -1)
4785 {
4786 optimize = optimize_val;
4787 optimize_size = 0;
4788 }
4789 }
4790 }
4791 }
4792
4793 obey_regdecls = (optimize == 0);
4794
4795 if (optimize >= 1)
4796 {
4797 flag_defer_pop = 1;
4798 flag_thread_jumps = 1;
4799 #ifdef DELAY_SLOTS
4800 flag_delayed_branch = 1;
4801 #endif
4802 #ifdef CAN_DEBUG_WITHOUT_FP
4803 flag_omit_frame_pointer = 1;
4804 #endif
4805 }
4806
4807 if (optimize >= 2)
4808 {
4809 flag_cse_follow_jumps = 1;
4810 flag_cse_skip_blocks = 1;
4811 flag_gcse = 1;
4812 flag_expensive_optimizations = 1;
4813 flag_strength_reduce = 1;
4814 flag_rerun_cse_after_loop = 1;
4815 flag_rerun_loop_opt = 1;
4816 flag_caller_saves = 1;
4817 flag_force_mem = 1;
4818 flag_peephole2 = 1;
4819 #ifdef INSN_SCHEDULING
4820 flag_schedule_insns = 1;
4821 flag_schedule_insns_after_reload = 1;
4822 #endif
4823 flag_regmove = 1;
4824 flag_strict_aliasing = 1;
4825 }
4826
4827 if (optimize >= 3)
4828 {
4829 flag_inline_functions = 1;
4830 }
4831
4832 if (optimize < 2 || optimize_size)
4833 {
4834 align_loops = 1;
4835 align_jumps = 1;
4836 align_labels = 1;
4837 align_functions = 1;
4838 }
4839
4840 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4841 modify it. */
4842 target_flags = 0;
4843 set_target_switch ("");
4844
4845 #ifdef OPTIMIZATION_OPTIONS
4846 /* Allow default optimizations to be specified on a per-machine basis. */
4847 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4848 #endif
4849
4850 /* Initialize register usage now so switches may override. */
4851 init_reg_sets ();
4852
4853 for (i = 1; i < argc; i++)
4854 {
4855 size_t j;
4856
4857 /* If this is a language-specific option,
4858 decode it in a language-specific way. */
4859 for (j = NUM_ELEM (documented_lang_options); j--;)
4860 if (check_lang_option (argv[i], documented_lang_options[j].option))
4861 break;
4862
4863 if (j != (size_t)-1)
4864 {
4865 /* If the option is valid for *some* language,
4866 treat it as valid even if this language doesn't understand it. */
4867 int strings_processed = lang_decode_option (argc - i, argv + i);
4868
4869 if (!strcmp (argv[i], "--help"))
4870 {
4871 display_help ();
4872 exit (0);
4873 }
4874
4875 if (strings_processed != 0)
4876 i += strings_processed - 1;
4877 }
4878 else if (argv[i][0] == '-' && argv[i][1] != 0)
4879 {
4880 register char *str = argv[i] + 1;
4881 if (str[0] == 'Y')
4882 str++;
4883
4884 if (str[0] == 'm')
4885 set_target_switch (&str[1]);
4886 else if (!strcmp (str, "dumpbase"))
4887 {
4888 dump_base_name = argv[++i];
4889 }
4890 else if (str[0] == 'd')
4891 {
4892 register char *p = &str[1];
4893 while (*p)
4894 switch (*p++)
4895 {
4896 case 'a':
4897 branch_prob_dump = 1;
4898 combine_dump = 1;
4899 #ifdef DELAY_SLOTS
4900 dbr_sched_dump = 1;
4901 #endif
4902 flow_dump = 1;
4903 flow2_dump = 1;
4904 global_reg_dump = 1;
4905 jump_opt_dump = 1;
4906 addressof_dump = 1;
4907 jump2_opt_dump = 1;
4908 local_reg_dump = 1;
4909 loop_dump = 1;
4910 regmove_dump = 1;
4911 rtl_dump = 1;
4912 cse_dump = 1, cse2_dump = 1;
4913 gcse_dump = 1;
4914 sched_dump = 1;
4915 sched2_dump = 1;
4916 #ifdef STACK_REGS
4917 stack_reg_dump = 1;
4918 #endif
4919 #ifdef MACHINE_DEPENDENT_REORG
4920 mach_dep_reorg_dump = 1;
4921 #endif
4922 peephole2_dump = 1;
4923 break;
4924 case 'A':
4925 flag_debug_asm = 1;
4926 break;
4927 case 'b':
4928 branch_prob_dump = 1;
4929 break;
4930 case 'c':
4931 combine_dump = 1;
4932 break;
4933 #ifdef DELAY_SLOTS
4934 case 'd':
4935 dbr_sched_dump = 1;
4936 break;
4937 #endif
4938 case 'f':
4939 flow_dump = 1;
4940 break;
4941 case 'F':
4942 addressof_dump = 1;
4943 break;
4944 case 'g':
4945 global_reg_dump = 1;
4946 break;
4947 case 'G':
4948 gcse_dump = 1;
4949 break;
4950 case 'j':
4951 jump_opt_dump = 1;
4952 break;
4953 case 'J':
4954 jump2_opt_dump = 1;
4955 break;
4956 #ifdef STACK_REGS
4957 case 'k':
4958 stack_reg_dump = 1;
4959 break;
4960 #endif
4961 case 'l':
4962 local_reg_dump = 1;
4963 break;
4964 case 'L':
4965 loop_dump = 1;
4966 break;
4967 case 'm':
4968 flag_print_mem = 1;
4969 break;
4970 #ifdef MACHINE_DEPENDENT_REORG
4971 case 'M':
4972 mach_dep_reorg_dump = 1;
4973 break;
4974 #endif
4975 case 'p':
4976 flag_print_asm_name = 1;
4977 break;
4978 case 'r':
4979 rtl_dump = 1;
4980 break;
4981 case 'R':
4982 sched2_dump = 1;
4983 break;
4984 case 's':
4985 cse_dump = 1;
4986 break;
4987 case 'S':
4988 sched_dump = 1;
4989 break;
4990 case 't':
4991 cse2_dump = 1;
4992 break;
4993 case 'N':
4994 regmove_dump = 1;
4995 break;
4996 case 'v':
4997 graph_dump_format = vcg;
4998 break;
4999 case 'w':
5000 flow2_dump = 1;
5001 break;
5002 case 'x':
5003 rtl_dump_and_exit = 1;
5004 break;
5005 case 'y':
5006 set_yydebug (1);
5007 break;
5008 case 'z':
5009 peephole2_dump = 1;
5010 break;
5011 case 'D': /* these are handled by the preprocessor */
5012 case 'I':
5013 break;
5014 default:
5015 warning ("unrecognised gcc debugging option: %c", p[-1]);
5016 break;
5017 }
5018 }
5019 else if (str[0] == 'f')
5020 {
5021 register char *p = &str[1];
5022 int found = 0;
5023
5024 /* Some kind of -f option.
5025 P's value is the option sans `-f'.
5026 Search for it in the table of options. */
5027
5028 for (j = 0;
5029 !found && j < sizeof (f_options) / sizeof (f_options[0]);
5030 j++)
5031 {
5032 if (!strcmp (p, f_options[j].string))
5033 {
5034 *f_options[j].variable = f_options[j].on_value;
5035 /* A goto here would be cleaner,
5036 but breaks the vax pcc. */
5037 found = 1;
5038 }
5039 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
5040 && ! strcmp (p+3, f_options[j].string))
5041 {
5042 *f_options[j].variable = ! f_options[j].on_value;
5043 found = 1;
5044 }
5045 }
5046
5047 if (found)
5048 ;
5049 else if (!strncmp (p, "inline-limit-", 13)
5050 || !strncmp (p, "inline-limit=", 13))
5051 inline_max_insns =
5052 read_integral_parameter (p + 13, p - 2, inline_max_insns);
5053 #ifdef INSN_SCHEDULING
5054 else if (!strncmp (p, "sched-verbose=",14))
5055 fix_sched_param("verbose",&p[14]);
5056 #endif
5057 else if (!strncmp (p, "fixed-", 6))
5058 fix_register (&p[6], 1, 1);
5059 else if (!strncmp (p, "call-used-", 10))
5060 fix_register (&p[10], 0, 1);
5061 else if (!strncmp (p, "call-saved-", 11))
5062 fix_register (&p[11], 0, 0);
5063 else if (!strncmp (p, "align-loops=", 12))
5064 align_loops = read_integral_parameter (p + 12, p - 2,
5065 align_loops);
5066 else if (!strncmp (p, "align-functions=", 16))
5067 align_functions = read_integral_parameter (p + 16, p - 2,
5068 align_functions);
5069 else if (!strncmp (p, "align-jumps=", 12))
5070 align_jumps = read_integral_parameter (p + 12, p - 2,
5071 align_jumps);
5072 else if (!strncmp (p, "align-labels=", 13))
5073 align_labels = read_integral_parameter (p + 13, p - 2,
5074 align_labels);
5075 else
5076 error ("Invalid option `%s'", argv[i]);
5077 }
5078 else if (str[0] == 'O')
5079 {
5080 /* Already been treated above. Do nothing. */
5081 }
5082 else if (!strcmp (str, "pedantic"))
5083 pedantic = 1;
5084 else if (!strcmp (str, "pedantic-errors"))
5085 flag_pedantic_errors = pedantic = 1;
5086 else if (!strcmp (str, "quiet"))
5087 quiet_flag = 1;
5088 else if (!strcmp (str, "version"))
5089 version_flag = 1;
5090 else if (!strcmp (str, "w"))
5091 inhibit_warnings = 1;
5092 else if (!strcmp (str, "W"))
5093 {
5094 extra_warnings = 1;
5095 /* We save the value of warn_uninitialized, since if they put
5096 -Wuninitialized on the command line, we need to generate a
5097 warning about not using it without also specifying -O. */
5098 if (warn_uninitialized != 1)
5099 warn_uninitialized = 2;
5100 }
5101 else if (str[0] == 'W')
5102 {
5103 register char *p = &str[1];
5104 int found = 0;
5105
5106 /* Some kind of -W option.
5107 P's value is the option sans `-W'.
5108 Search for it in the table of options. */
5109
5110 for (j = 0;
5111 !found && j < sizeof (W_options) / sizeof (W_options[0]);
5112 j++)
5113 {
5114 if (!strcmp (p, W_options[j].string))
5115 {
5116 *W_options[j].variable = W_options[j].on_value;
5117 /* A goto here would be cleaner,
5118 but breaks the vax pcc. */
5119 found = 1;
5120 }
5121 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
5122 && ! strcmp (p+3, W_options[j].string))
5123 {
5124 *W_options[j].variable = ! W_options[j].on_value;
5125 found = 1;
5126 }
5127 }
5128
5129 if (found)
5130 ;
5131 else if (!strncmp (p, "id-clash-", 9))
5132 {
5133 const int id_clash_val
5134 = read_integral_parameter (p + 9, p - 2, -1);
5135 if (id_clash_val != -1)
5136 {
5137 id_clash_len = id_clash_val;
5138 warn_id_clash = 1;
5139 }
5140 }
5141 else if (!strncmp (p, "larger-than-", 12))
5142 {
5143 const int larger_than_val
5144 = read_integral_parameter (p + 12, p - 2, -1);
5145 if (larger_than_val != -1)
5146 {
5147 larger_than_size = larger_than_val;
5148 warn_larger_than = 1;
5149 }
5150 }
5151 else
5152 error ("Invalid option `%s'", argv[i]);
5153 }
5154 else if (!strcmp (str, "p"))
5155 {
5156 profile_flag = 1;
5157 }
5158 else if (!strcmp (str, "a"))
5159 {
5160 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5161 warning ("`-a' option (basic block profile) not supported");
5162 #else
5163 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
5164 #endif
5165 }
5166 else if (!strcmp (str, "ax"))
5167 {
5168 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5169 warning ("`-ax' option (jump profiling) not supported");
5170 #else
5171 profile_block_flag = (!profile_block_flag
5172 || profile_block_flag == 2) ? 2 : 3;
5173 #endif
5174 }
5175 else if (str[0] == 'g')
5176 {
5177 unsigned level;
5178 /* A lot of code assumes write_symbols == NO_DEBUG if the
5179 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
5180 of what debugging type has been selected). This records the
5181 selected type. It is an error to specify more than one
5182 debugging type. */
5183 static enum debug_info_type selected_debug_type = NO_DEBUG;
5184 /* Non-zero if debugging format has been explicitly set.
5185 -g and -ggdb don't explicitly set the debugging format so
5186 -gdwarf -g3 is equivalent to -gdwarf3. */
5187 static int type_explicitly_set_p = 0;
5188 /* Indexed by enum debug_info_type. */
5189 static const char *debug_type_names[] =
5190 {
5191 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
5192 };
5193
5194 /* The maximum admissible debug level value. */
5195 static const unsigned max_debug_level = 3;
5196
5197 /* Look up STR in the table. */
5198 for (da = debug_args; da->arg; da++)
5199 {
5200 const int da_len = strlen (da->arg);
5201
5202 if (! strncmp (str, da->arg, da_len))
5203 {
5204 enum debug_info_type type = da->debug_type;
5205 const char *p = str + da_len;
5206
5207 if (*p && (*p < '0' || *p > '9'))
5208 continue;
5209
5210 /* A debug flag without a level defaults to level 2.
5211 Note we do not want to call read_integral_parameter
5212 for that case since it will call atoi which
5213 will return zero.
5214
5215 ??? We may want to generalize the interface to
5216 read_integral_parameter to better handle this case
5217 if this case shows up often. */
5218 if (*p)
5219 level = read_integral_parameter (p, 0,
5220 max_debug_level + 1);
5221 else
5222 level = 2;
5223
5224 if (da_len > 1 && *p && !strncmp (str, "gdwarf", da_len))
5225 {
5226 error ("use -gdwarf -g%d for DWARF v1, level %d",
5227 level, level);
5228 if (level == 2)
5229 error ("use -gdwarf-2 for DWARF v2");
5230 }
5231
5232 if (level > max_debug_level)
5233 {
5234 warning ("ignoring option `%s' due to invalid debug level specification",
5235 str - 1);
5236 level = debug_info_level;
5237 }
5238
5239 if (type == NO_DEBUG)
5240 {
5241 type = PREFERRED_DEBUGGING_TYPE;
5242 if (da_len > 1 && strncmp (str, "ggdb", da_len) == 0)
5243 {
5244 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
5245 type = DWARF2_DEBUG;
5246 #else
5247 #ifdef DBX_DEBUGGING_INFO
5248 type = DBX_DEBUG;
5249 #endif
5250 #endif
5251 }
5252 }
5253
5254 if (type == NO_DEBUG)
5255 warning ("`-%s' not supported by this configuration of GCC",
5256 str);
5257
5258 /* Does it conflict with an already selected type? */
5259 if (type_explicitly_set_p
5260 /* -g/-ggdb don't conflict with anything */
5261 && da->debug_type != NO_DEBUG
5262 && type != selected_debug_type)
5263 warning ("`-%s' ignored, conflicts with `-g%s'",
5264 str, debug_type_names[(int) selected_debug_type]);
5265 else
5266 {
5267 /* If the format has already been set, -g/-ggdb
5268 only change the debug level. */
5269 if (type_explicitly_set_p
5270 && da->debug_type == NO_DEBUG)
5271 ; /* don't change debugging type */
5272 else
5273 {
5274 selected_debug_type = type;
5275 type_explicitly_set_p = da->debug_type != NO_DEBUG;
5276 }
5277 write_symbols = (level == 0
5278 ? NO_DEBUG
5279 : selected_debug_type);
5280 use_gnu_debug_info_extensions = da->use_extensions_p;
5281 debug_info_level = (enum debug_info_level) level;
5282 }
5283 break;
5284 }
5285 }
5286 if (! da->arg)
5287 warning ("`-%s' not supported by this configuration of GCC",
5288 str);
5289 }
5290 else if (!strcmp (str, "o"))
5291 {
5292 asm_file_name = argv[++i];
5293 }
5294 else if (str[0] == 'G')
5295 {
5296 const int g_switch_val = (str[1] != '\0') ?
5297 read_integral_parameter(str + 1, 0, -1) :
5298 read_integral_parameter(argv[++i], 0, -1);
5299
5300 if (g_switch_val != -1)
5301 {
5302 g_switch_set = TRUE;
5303 g_switch_value = g_switch_val;
5304 }
5305 else
5306 {
5307 error("Invalid option `-%s'",str);
5308 }
5309 }
5310 else if (!strncmp (str, "aux-info", 8))
5311 {
5312 flag_gen_aux_info = 1;
5313 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
5314 }
5315 else if (!strcmp (str, "-help"))
5316 {
5317 display_help ();
5318 exit (0);
5319 }
5320 else
5321 error ("Invalid option `%s'", argv[i]);
5322 }
5323 else if (argv[i][0] == '+')
5324 error ("Invalid option `%s'", argv[i]);
5325 else
5326 filename = argv[i];
5327 }
5328
5329 /* Checker uses the frame pointer. */
5330 if (flag_check_memory_usage)
5331 flag_omit_frame_pointer = 0;
5332
5333 if (optimize == 0)
5334 {
5335 /* Inlining does not work if not optimizing,
5336 so force it not to be done. */
5337 flag_no_inline = 1;
5338 warn_inline = 0;
5339
5340 /* The c_decode_option and lang_decode_option functions set
5341 this to `2' if -Wall is used, so we can avoid giving out
5342 lots of errors for people who don't realize what -Wall does. */
5343 if (warn_uninitialized == 1)
5344 warning ("-Wuninitialized is not supported without -O");
5345 }
5346
5347 #ifdef OVERRIDE_OPTIONS
5348 /* Some machines may reject certain combinations of options. */
5349 OVERRIDE_OPTIONS;
5350 #endif
5351
5352 if (exceptions_via_longjmp == 2)
5353 {
5354 #ifdef DWARF2_UNWIND_INFO
5355 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
5356 #else
5357 exceptions_via_longjmp = 1;
5358 #endif
5359 }
5360
5361 /* Set up the align_*_log variables, defaulting them to 1 if they
5362 were still unset. */
5363 if (align_loops <= 0) align_loops = 1;
5364 align_loops_log = floor_log2 (align_loops*2-1);
5365 if (align_jumps <= 0) align_jumps = 1;
5366 align_jumps_log = floor_log2 (align_jumps*2-1);
5367 if (align_labels <= 0) align_labels = 1;
5368 align_labels_log = floor_log2 (align_labels*2-1);
5369 if (align_functions <= 0) align_functions = 1;
5370 align_functions_log = floor_log2 (align_functions*2-1);
5371
5372 if (profile_block_flag == 3)
5373 {
5374 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
5375 profile_block_flag = 2;
5376 }
5377
5378 /* Unrolling all loops implies that standard loop unrolling must also
5379 be done. */
5380 if (flag_unroll_all_loops)
5381 flag_unroll_loops = 1;
5382 /* Loop unrolling requires that strength_reduction be on also. Silently
5383 turn on strength reduction here if it isn't already on. Also, the loop
5384 unrolling code assumes that cse will be run after loop, so that must
5385 be turned on also. */
5386 if (flag_unroll_loops)
5387 {
5388 flag_strength_reduce = 1;
5389 flag_rerun_cse_after_loop = 1;
5390 }
5391
5392 /* Warn about options that are not supported on this machine. */
5393 #ifndef INSN_SCHEDULING
5394 if (flag_schedule_insns || flag_schedule_insns_after_reload)
5395 warning ("instruction scheduling not supported on this target machine");
5396 #endif
5397 #ifndef DELAY_SLOTS
5398 if (flag_delayed_branch)
5399 warning ("this target machine does not have delayed branches");
5400 #endif
5401
5402 user_label_prefix = USER_LABEL_PREFIX;
5403 if (flag_leading_underscore != -1)
5404 {
5405 /* If the default prefix is more complicated than "" or "_",
5406 issue a warning and ignore this option. */
5407 if (user_label_prefix[0] == 0 ||
5408 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5409 {
5410 user_label_prefix = flag_leading_underscore ? "_" : "";
5411 }
5412 else
5413 warning ("-f%sleading-underscore not supported on this target machine",
5414 flag_leading_underscore ? "" : "no-");
5415 }
5416
5417 /* If we are in verbose mode, write out the version and maybe all the
5418 option flags in use. */
5419 if (version_flag)
5420 {
5421 print_version (stderr, "");
5422 if (! quiet_flag)
5423 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5424 }
5425
5426 compile_file (filename);
5427
5428 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
5429 if (flag_print_mem)
5430 {
5431 char *lim = (char *) sbrk (0);
5432
5433 notice ("Data size %ld.\n", (long) (lim - (char *) &environ));
5434 fflush (stderr);
5435
5436 #ifndef __MSDOS__
5437 #ifdef USG
5438 system ("ps -l 1>&2");
5439 #else /* not USG */
5440 system ("ps v");
5441 #endif /* not USG */
5442 #endif
5443 }
5444 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
5445
5446 if (errorcount)
5447 exit (FATAL_EXIT_CODE);
5448 if (sorrycount)
5449 exit (FATAL_EXIT_CODE);
5450 exit (SUCCESS_EXIT_CODE);
5451 return 0;
5452 }
5453 \f
5454 /* Decode -m switches. */
5455 /* Decode the switch -mNAME. */
5456
5457 static void
5458 set_target_switch (name)
5459 const char *name;
5460 {
5461 register size_t j;
5462 int valid_target_option = 0;
5463
5464 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5465 if (!strcmp (target_switches[j].name, name))
5466 {
5467 if (target_switches[j].value < 0)
5468 target_flags &= ~-target_switches[j].value;
5469 else
5470 target_flags |= target_switches[j].value;
5471 valid_target_option = 1;
5472 }
5473
5474 #ifdef TARGET_OPTIONS
5475 if (!valid_target_option)
5476 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5477 {
5478 int len = strlen (target_options[j].prefix);
5479 if (!strncmp (target_options[j].prefix, name, len))
5480 {
5481 *target_options[j].variable = name + len;
5482 valid_target_option = 1;
5483 }
5484 }
5485 #endif
5486
5487 if (!valid_target_option)
5488 error ("Invalid option `%s'", name);
5489 }
5490 \f
5491 /* Print version information to FILE.
5492 Each line begins with INDENT (for the case where FILE is the
5493 assembler output file). */
5494
5495 static void
5496 print_version (file, indent)
5497 FILE *file;
5498 const char *indent;
5499 {
5500 #ifndef __VERSION__
5501 #define __VERSION__ "[?]"
5502 #endif
5503 fnotice (file,
5504 #ifdef __GNUC__
5505 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
5506 #else
5507 "%s%s%s version %s (%s) compiled by CC.\n"
5508 #endif
5509 , indent, *indent != 0 ? " " : "",
5510 language_string, version_string, TARGET_NAME, __VERSION__);
5511 }
5512
5513 /* Print an option value and return the adjusted position in the line.
5514 ??? We don't handle error returns from fprintf (disk full); presumably
5515 other code will catch a disk full though. */
5516
5517 static int
5518 print_single_switch (file, pos, max, indent, sep, term, type, name)
5519 FILE *file;
5520 int pos, max;
5521 const char *indent, *sep, *term, *type, *name;
5522 {
5523 /* The ultrix fprintf returns 0 on success, so compute the result we want
5524 here since we need it for the following test. */
5525 int len = strlen (sep) + strlen (type) + strlen (name);
5526
5527 if (pos != 0
5528 && pos + len > max)
5529 {
5530 fprintf (file, "%s", term);
5531 pos = 0;
5532 }
5533 if (pos == 0)
5534 {
5535 fprintf (file, "%s", indent);
5536 pos = strlen (indent);
5537 }
5538 fprintf (file, "%s%s%s", sep, type, name);
5539 pos += len;
5540 return pos;
5541 }
5542
5543 /* Print active target switches to FILE.
5544 POS is the current cursor position and MAX is the size of a "line".
5545 Each line begins with INDENT and ends with TERM.
5546 Each switch is separated from the next by SEP. */
5547
5548 static void
5549 print_switch_values (file, pos, max, indent, sep, term)
5550 FILE *file;
5551 int pos, max;
5552 const char *indent, *sep, *term;
5553 {
5554 size_t j;
5555 char **p;
5556
5557 /* Print the options as passed. */
5558
5559 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5560 _("options passed: "), "");
5561
5562 for (p = &save_argv[1]; *p != NULL; p++)
5563 if (**p == '-')
5564 {
5565 /* Ignore these. */
5566 if (strcmp (*p, "-o") == 0)
5567 {
5568 if (p[1] != NULL)
5569 p++;
5570 continue;
5571 }
5572 if (strcmp (*p, "-quiet") == 0)
5573 continue;
5574 if (strcmp (*p, "-version") == 0)
5575 continue;
5576 if ((*p)[1] == 'd')
5577 continue;
5578
5579 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5580 }
5581 if (pos > 0)
5582 fprintf (file, "%s", term);
5583
5584 /* Print the -f and -m options that have been enabled.
5585 We don't handle language specific options but printing argv
5586 should suffice. */
5587
5588 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5589 _("options enabled: "), "");
5590
5591 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
5592 if (*f_options[j].variable == f_options[j].on_value)
5593 pos = print_single_switch (file, pos, max, indent, sep, term,
5594 "-f", f_options[j].string);
5595
5596 /* Print target specific options. */
5597
5598 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5599 if (target_switches[j].name[0] != '\0'
5600 && target_switches[j].value > 0
5601 && ((target_switches[j].value & target_flags)
5602 == target_switches[j].value))
5603 {
5604 pos = print_single_switch (file, pos, max, indent, sep, term,
5605 "-m", target_switches[j].name);
5606 }
5607
5608 #ifdef TARGET_OPTIONS
5609 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5610 if (*target_options[j].variable != NULL)
5611 {
5612 char prefix[256];
5613 sprintf (prefix, "-m%s", target_options[j].prefix);
5614 pos = print_single_switch (file, pos, max, indent, sep, term,
5615 prefix, *target_options[j].variable);
5616 }
5617 #endif
5618
5619 fprintf (file, "%s", term);
5620 }
5621
5622 /* Record the beginning of a new source file, named FILENAME. */
5623
5624 void
5625 debug_start_source_file (filename)
5626 register char *filename ATTRIBUTE_UNUSED;
5627 {
5628 #ifdef DBX_DEBUGGING_INFO
5629 if (write_symbols == DBX_DEBUG)
5630 dbxout_start_new_source_file (filename);
5631 #endif
5632 #ifdef DWARF_DEBUGGING_INFO
5633 if (debug_info_level == DINFO_LEVEL_VERBOSE
5634 && write_symbols == DWARF_DEBUG)
5635 dwarfout_start_new_source_file (filename);
5636 #endif /* DWARF_DEBUGGING_INFO */
5637 #ifdef DWARF2_DEBUGGING_INFO
5638 if (debug_info_level == DINFO_LEVEL_VERBOSE
5639 && write_symbols == DWARF2_DEBUG)
5640 dwarf2out_start_source_file (filename);
5641 #endif /* DWARF2_DEBUGGING_INFO */
5642 #ifdef SDB_DEBUGGING_INFO
5643 if (write_symbols == SDB_DEBUG)
5644 sdbout_start_new_source_file (filename);
5645 #endif
5646 }
5647
5648 /* Record the resumption of a source file. LINENO is the line number in
5649 the source file we are returning to. */
5650
5651 void
5652 debug_end_source_file (lineno)
5653 register unsigned lineno ATTRIBUTE_UNUSED;
5654 {
5655 #ifdef DBX_DEBUGGING_INFO
5656 if (write_symbols == DBX_DEBUG)
5657 dbxout_resume_previous_source_file ();
5658 #endif
5659 #ifdef DWARF_DEBUGGING_INFO
5660 if (debug_info_level == DINFO_LEVEL_VERBOSE
5661 && write_symbols == DWARF_DEBUG)
5662 dwarfout_resume_previous_source_file (lineno);
5663 #endif /* DWARF_DEBUGGING_INFO */
5664 #ifdef DWARF2_DEBUGGING_INFO
5665 if (debug_info_level == DINFO_LEVEL_VERBOSE
5666 && write_symbols == DWARF2_DEBUG)
5667 dwarf2out_end_source_file ();
5668 #endif /* DWARF2_DEBUGGING_INFO */
5669 #ifdef SDB_DEBUGGING_INFO
5670 if (write_symbols == SDB_DEBUG)
5671 sdbout_resume_previous_source_file ();
5672 #endif
5673 }
5674
5675 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5676 the tail part of the directive line, i.e. the part which is past the
5677 initial whitespace, #, whitespace, directive-name, whitespace part. */
5678
5679 void
5680 debug_define (lineno, buffer)
5681 register unsigned lineno ATTRIBUTE_UNUSED;
5682 register char *buffer ATTRIBUTE_UNUSED;
5683 {
5684 #ifdef DWARF_DEBUGGING_INFO
5685 if (debug_info_level == DINFO_LEVEL_VERBOSE
5686 && write_symbols == DWARF_DEBUG)
5687 dwarfout_define (lineno, buffer);
5688 #endif /* DWARF_DEBUGGING_INFO */
5689 #ifdef DWARF2_DEBUGGING_INFO
5690 if (debug_info_level == DINFO_LEVEL_VERBOSE
5691 && write_symbols == DWARF2_DEBUG)
5692 dwarf2out_define (lineno, buffer);
5693 #endif /* DWARF2_DEBUGGING_INFO */
5694 }
5695
5696 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5697 the tail part of the directive line, i.e. the part which is past the
5698 initial whitespace, #, whitespace, directive-name, whitespace part. */
5699
5700 void
5701 debug_undef (lineno, buffer)
5702 register unsigned lineno ATTRIBUTE_UNUSED;
5703 register char *buffer ATTRIBUTE_UNUSED;
5704 {
5705 #ifdef DWARF_DEBUGGING_INFO
5706 if (debug_info_level == DINFO_LEVEL_VERBOSE
5707 && write_symbols == DWARF_DEBUG)
5708 dwarfout_undef (lineno, buffer);
5709 #endif /* DWARF_DEBUGGING_INFO */
5710 #ifdef DWARF2_DEBUGGING_INFO
5711 if (debug_info_level == DINFO_LEVEL_VERBOSE
5712 && write_symbols == DWARF2_DEBUG)
5713 dwarf2out_undef (lineno, buffer);
5714 #endif /* DWARF2_DEBUGGING_INFO */
5715 }