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