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