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