1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
4 This file is part of GNU CC.
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)
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.
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
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. */
27 #include <sys/types.h>
36 #include <sys/param.h>
37 /* This is for hpux. It is a real screw. They should change hpux. */
39 #include <sys/times.h>
40 #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
41 #undef FFS /* Some systems define this in param.h. */
45 #include <sys/resource.h>
51 /* #include "c-tree.h" */
54 #include "insn-attr.h"
57 /* The extra parameters substantially improve the I/O performance. */
59 VMS_fopen (fname
, type
)
63 if (strcmp (type
, "w") == 0)
64 return fopen (fname
, type
, "mbc=16", "deq=64", "fop=tef", "shr=nil");
65 return fopen (fname
, type
, "mbc=16");
67 #define fopen VMS_fopen
70 #ifndef DEFAULT_GDB_EXTENSIONS
71 #define DEFAULT_GDB_EXTENSIONS 1
74 extern int rtx_equal_function_value_matters
;
76 extern char **environ
;
77 extern char *version_string
, *language_string
;
79 extern void init_lex ();
80 extern void init_decl_processing ();
81 extern void init_obstacks ();
82 extern void init_tree_codes ();
83 extern void init_rtl ();
84 extern void init_optabs ();
85 extern void init_stmt ();
86 extern void init_reg_sets ();
87 extern void dump_flow_info ();
88 extern void dump_sched_info ();
89 extern void dump_local_alloc ();
91 void rest_of_decl_compilation ();
93 void error_with_file_and_line ();
98 void set_target_switch ();
99 static void print_switch_values ();
100 static char *decl_name ();
102 /* Name of program invoked, sans directories. */
106 /* Copy of arguments to main. */
110 /* Name of current original source file (what was input to cpp).
111 This comes from each #-command in the actual input. */
113 char *input_filename
;
115 /* Name of top-level original source file (what was input to cpp).
116 This comes from the #-command at the beginning of the actual input.
117 If there isn't any there, then this is the cc1 input file name. */
119 char *main_input_filename
;
121 /* Stream for reading from the input file. */
125 /* Current line number in real source file. */
129 /* Stack of currently pending input files. */
131 struct file_stack
*input_file_stack
;
133 /* Incremented on each change to input_file_stack. */
134 int input_file_stack_tick
;
136 /* FUNCTION_DECL for function now being parsed or compiled. */
138 extern tree current_function_decl
;
140 /* Name to use as base of names for dump output files. */
142 char *dump_base_name
;
144 /* Bit flags that specify the machine subtype we are compiling for.
145 Bits are tested using macros TARGET_... defined in the tm.h file
146 and set by `-m...' switches. Must be defined in rtlanal.c. */
148 extern int target_flags
;
150 /* Flags saying which kinds of debugging dump have been requested. */
153 int rtl_dump_and_exit
= 0;
154 int jump_opt_dump
= 0;
159 int combine_dump
= 0;
161 int local_reg_dump
= 0;
162 int global_reg_dump
= 0;
164 int jump2_opt_dump
= 0;
165 int dbr_sched_dump
= 0;
166 int flag_print_asm_name
= 0;
167 int stack_reg_dump
= 0;
169 /* Name for output file of assembly code, specified with -o. */
173 /* Value of the -G xx switch, and whether it was passed or not. */
177 /* Type(s) of debugging information we are producing (if any).
178 See flags.h for the definitions of the different possible
179 types of debugging information. */
180 enum debug_info_type write_symbols
= NO_DEBUG
;
182 /* Level of debugging information we are producing. See flags.h
183 for the definitions of the different possible levels. */
184 enum debug_info_level debug_info_level
= DINFO_LEVEL_NONE
;
186 #ifdef DBX_DEBUGGING_INFO
187 /* Nonzero means can use our own extensions to DBX format.
188 Relevant only when write_symbols == DBX_DEBUG. */
189 int use_gdb_dbx_extensions
= 0;
192 /* Nonzero means do optimizations. -O.
193 Particular numeric values stand for particular amounts of optimization;
194 thus, -O2 stores 2 here. However, the optimizations beyond the basic
195 ones are not controlled directly by this variable. Instead, they are
196 controlled by individual `flag_...' variables that are defaulted
197 based on this variable. */
201 /* Number of error messages and warning messages so far. */
204 int warningcount
= 0;
207 /* Pointer to function to compute the name to use to print a declaration. */
209 char *(*decl_printable_name
) ();
211 /* Pointer to function to compute rtl for a language-specific tree code. */
213 struct rtx_def
*(*lang_expand_expr
) ();
215 /* Nonzero if generating code to do profiling. */
217 int profile_flag
= 0;
219 /* Nonzero if generating code to do profiling on a line-by-line basis. */
221 int profile_block_flag
;
223 /* Nonzero for -pedantic switch: warn about anything
224 that standard spec forbids. */
228 /* Temporarily suppress certain warnings.
229 This is set while reading code from a system header file. */
231 int in_system_header
= 0;
233 /* Nonzero means do stupid register allocation.
234 Currently, this is 1 if `optimize' is 0. */
236 int obey_regdecls
= 0;
238 /* Don't print functions as they are compiled and don't print
239 times taken by the various passes. -quiet. */
245 /* Nonzero means `char' should be signed. */
247 int flag_signed_char
;
249 /* Nonzero means give an enum type only as many bytes as it needs. */
251 int flag_short_enums
;
253 /* Nonzero for -fcaller-saves: allocate values in regs that need to
254 be saved across function calls, if that produces overall better code.
255 Optional now, so people can test it. */
257 #ifdef DEFAULT_CALLER_SAVES
258 int flag_caller_saves
= 1;
260 int flag_caller_saves
= 0;
263 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
265 int flag_pcc_struct_return
= 0;
267 /* Nonzero for -fforce-mem: load memory value into a register
268 before arithmetic on it. This makes better cse but slower compilation. */
270 int flag_force_mem
= 0;
272 /* Nonzero for -fforce-addr: load memory address into a register before
273 reference to memory. This makes better cse but slower compilation. */
275 int flag_force_addr
= 0;
277 /* Nonzero for -fdefer-pop: don't pop args after each function call;
278 instead save them up to pop many calls' args with one insns. */
280 int flag_defer_pop
= 1;
282 /* Nonzero for -ffloat-store: don't allocate floats and doubles
283 in extended-precision registers. */
285 int flag_float_store
= 0;
287 /* Nonzero for -fcse-follow-jumps:
288 have cse follow jumps to do a more extensive job. */
290 int flag_cse_follow_jumps
;
292 /* Nonzero for -fexpensive-optimizations:
293 perform miscellaneous relatively-expensive optimizations. */
294 int flag_expensive_optimizations
;
296 /* Nonzero for -fthread-jumps:
297 have jump optimize output of loop. */
299 int flag_thread_jumps
;
301 /* Nonzero enables strength-reduction in loop.c. */
303 int flag_strength_reduce
= 0;
305 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
306 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
307 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
310 int flag_unroll_loops
;
312 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
313 This is generally not a win. */
315 int flag_unroll_all_loops
;
317 /* Nonzero for -fwritable-strings:
318 store string constants in data segment and don't uniquize them. */
320 int flag_writable_strings
= 0;
322 /* Nonzero means don't put addresses of constant functions in registers.
323 Used for compiling the Unix kernel, where strange substitutions are
324 done on the assembly output. */
326 int flag_no_function_cse
= 0;
328 /* Nonzero for -fomit-frame-pointer:
329 don't make a frame pointer in simple functions that don't require one. */
331 int flag_omit_frame_pointer
= 0;
333 /* Nonzero to inhibit use of define_optimization peephole opts. */
335 int flag_no_peephole
= 0;
337 /* Nonzero means all references through pointers are volatile. */
341 /* Nonzero means just do syntax checking; don't output anything. */
343 int flag_syntax_only
= 0;
345 /* Nonzero means to rerun cse after loop optimization. This increases
346 compilation time about 20% and picks up a few more common expressions. */
348 static int flag_rerun_cse_after_loop
;
350 /* Nonzero for -finline-functions: ok to inline functions that look like
351 good inline candidates. */
353 int flag_inline_functions
;
355 /* Nonzero for -fkeep-inline-functions: even if we make a function
356 go inline everywhere, keep its defintion around for debugging
359 int flag_keep_inline_functions
;
361 /* Nonzero means that functions declared `inline' will be treated
362 as `static'. Prevents generation of zillions of copies of unused
363 static inline functions; instead, `inlines' are written out
364 only when actually used. Used in conjunction with -g. Also
365 does the right thing with #pragma interface. */
369 /* Nonzero means we should be saving declaration info into a .X file. */
371 int flag_gen_aux_info
= 0;
373 /* Nonzero means make the text shared if supported. */
375 int flag_shared_data
;
377 /* Nonzero means schedule into delayed branch slots if supported. */
379 int flag_delayed_branch
;
381 /* Nonzero if we are compiling pure (sharable) code.
382 Value is 1 if we are doing reasonable (i.e. simple
383 offset into offset table) pic. Value is 2 if we can
384 only perform register offsets. */
388 /* Nonzero means place uninitialized global data in the bss section. */
392 /* Nonzero means pretend it is OK to examine bits of target floats,
393 even if that isn't true. The resulting code will have incorrect constants,
394 but the same series of instructions that the native compiler would make. */
396 int flag_pretend_float
;
398 /* Nonzero means change certain warnings into errors.
399 Usually these are warnings about failure to conform to some standard. */
401 int flag_pedantic_errors
= 0;
403 /* flag_schedule_insns means schedule insns within basic blocks (before
405 flag_schedule_insns_after_reload means schedule insns after
408 int flag_schedule_insns
= 0;
409 int flag_schedule_insns_after_reload
= 0;
411 /* -finhibit-size-directive inhibits output of .size for ELF.
412 This is used only for compiling crtstuff.c,
413 and it may be extended to other effects
414 needed for crtstuff.c on other systems. */
415 int flag_inhibit_size_directive
= 0;
417 /* -fgnu-linker specifies use of the GNU linker for initializations.
418 -fno-gnu-linker says that collect will be used. */
419 int flag_gnu_linker
= 1;
421 /* Table of language-independent -f options.
422 STRING is the option name. VARIABLE is the address of the variable.
423 ON_VALUE is the value to store in VARIABLE
424 if `-fSTRING' is seen as an option.
425 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
427 struct { char *string
; int *variable
; int on_value
;} f_options
[] =
429 {"float-store", &flag_float_store
, 1},
430 {"volatile", &flag_volatile
, 1},
431 {"defer-pop", &flag_defer_pop
, 1},
432 {"omit-frame-pointer", &flag_omit_frame_pointer
, 1},
433 {"cse-follow-jumps", &flag_cse_follow_jumps
, 1},
434 {"expensive-optimizations", &flag_expensive_optimizations
, 1},
435 {"thread-jumps", &flag_thread_jumps
, 1},
436 {"strength-reduce", &flag_strength_reduce
, 1},
437 {"unroll-loops", &flag_unroll_loops
, 1},
438 {"unroll-all-loops", &flag_unroll_all_loops
, 1},
439 {"writable-strings", &flag_writable_strings
, 1},
440 {"peephole", &flag_no_peephole
, 0},
441 {"force-mem", &flag_force_mem
, 1},
442 {"force-addr", &flag_force_addr
, 1},
443 {"function-cse", &flag_no_function_cse
, 0},
444 {"inline-functions", &flag_inline_functions
, 1},
445 {"keep-inline-functions", &flag_keep_inline_functions
, 1},
446 {"inline", &flag_no_inline
, 0},
447 {"syntax-only", &flag_syntax_only
, 1},
448 {"gen-aux-info", &flag_gen_aux_info
, 1},
449 {"shared-data", &flag_shared_data
, 1},
450 {"caller-saves", &flag_caller_saves
, 1},
451 {"pcc-struct-return", &flag_pcc_struct_return
, 1},
452 {"delayed-branch", &flag_delayed_branch
, 1},
453 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop
, 1},
454 {"pretend-float", &flag_pretend_float
, 1},
455 {"schedule-insns", &flag_schedule_insns
, 1},
456 {"schedule-insns2", &flag_schedule_insns_after_reload
, 1},
457 {"pic", &flag_pic
, 1},
458 {"PIC", &flag_pic
, 2},
459 {"common", &flag_no_common
, 0},
460 {"inhibit-size-directive", &flag_inhibit_size_directive
, 1},
461 {"gnu-linker", &flag_gnu_linker
, 1}
464 /* Options controlling warnings */
466 /* Don't print warning messages. -w. */
468 int inhibit_warnings
= 0;
470 /* Print various extra warnings. -W. */
472 int extra_warnings
= 0;
474 /* Treat warnings as errors. -Werror. */
476 int warnings_are_errors
= 0;
478 /* Nonzero to warn about unused local variables. */
482 /* Nonzero to warn about variables used before they are initialized. */
484 int warn_uninitialized
;
486 /* Nonzero means warn about all declarations which shadow others. */
490 /* Warn if a switch on an enum fails to have a case for every enum value. */
494 /* Nonzero means warn about function definitions that default the return type
495 or that use a null return and have a return-type other than void. */
497 int warn_return_type
;
499 /* Nonzero means warn about pointer casts that increase the required
500 alignment of the target type (and might therefore lead to a crash
501 due to a misaligned access). */
505 /* Nonzero means warn about any identifiers that match in the first N
506 characters. The value N is in `id_clash_len'. */
511 /* Nonzero means warn if inline function is too large. */
515 /* Warn if a function returns an aggregate,
516 since there are often incompatible calling conventions for doing this. */
518 int warn_aggregate_return
;
520 /* Likewise for -W. */
522 struct { char *string
; int *variable
; int on_value
;} W_options
[] =
524 {"unused", &warn_unused
, 1},
525 {"error", &warnings_are_errors
, 1},
526 {"shadow", &warn_shadow
, 1},
527 {"switch", &warn_switch
, 1},
528 {"return-type", &warn_return_type
, 1},
529 {"aggregate-return", &warn_aggregate_return
, 1},
530 {"cast-align", &warn_cast_align
, 1},
531 {"uninitialized", &warn_uninitialized
, 1}
534 /* Output files for assembler code (real compiler output)
535 and debugging dumps. */
540 FILE *jump_opt_dump_file
;
542 FILE *loop_dump_file
;
543 FILE *cse2_dump_file
;
544 FILE *flow_dump_file
;
545 FILE *combine_dump_file
;
546 FILE *sched_dump_file
;
547 FILE *local_reg_dump_file
;
548 FILE *global_reg_dump_file
;
549 FILE *sched2_dump_file
;
550 FILE *jump2_opt_dump_file
;
551 FILE *dbr_sched_dump_file
;
552 FILE *stack_reg_dump_file
;
554 /* Time accumulators, to count the total time spent in various passes. */
558 int integration_time
;
566 int local_alloc_time
;
567 int global_alloc_time
;
570 int shorten_branch_time
;
576 /* Return time used so far, in microseconds. */
585 struct rusage rusage
;
590 int proc_system_time
;
592 int child_system_time
;
602 return (tms
.tms_utime
+ tms
.tms_stime
) * (1000000 / HZ
);
605 getrusage (0, &rusage
);
606 return (rusage
.ru_utime
.tv_sec
* 1000000 + rusage
.ru_utime
.tv_usec
607 + rusage
.ru_stime
.tv_sec
* 1000000 + rusage
.ru_stime
.tv_usec
);
610 return (vms_times
.proc_user_time
+ vms_times
.proc_system_time
) * 10000;
615 #define TIMEVAR(VAR, BODY) \
616 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
619 print_time (str
, total
)
624 "time in %s: %d.%06d\n",
625 str
, total
/ 1000000, total
% 1000000);
628 /* Count an error or warning. Return 1 if the message should be printed. */
631 count_error (warningp
)
634 if (warningp
&& inhibit_warnings
)
637 if (warningp
&& !warnings_are_errors
)
641 static int warning_message
= 0;
643 if (warningp
&& !warning_message
)
645 fprintf (stderr
, "%s: warnings being treated as errors\n", progname
);
654 /* Print a fatal error message. NAME is the text.
655 Also include a system error message based on `errno'. */
658 pfatal_with_name (name
)
661 fprintf (stderr
, "%s: ", progname
);
667 fatal_io_error (name
)
670 fprintf (stderr
, "%s: %s: I/O error\n", progname
, name
);
683 /* Called to give a better error message when we don't have an insn to match
684 what we are looking for or if the insn's constraints aren't satisfied,
685 rather than just calling abort(). */
688 fatal_insn_not_found (insn
)
691 if (INSN_CODE (insn
) < 0)
692 error ("internal error--unrecognizable insn:", 0);
694 error ("internal error--insn does not satisfy its constraints:", 0);
697 fflush (asm_out_file
);
699 fflush (aux_info_file
);
701 fflush (rtl_dump_file
);
702 if (jump_opt_dump_file
)
703 fflush (jump_opt_dump_file
);
705 fflush (cse_dump_file
);
707 fflush (loop_dump_file
);
709 fflush (cse2_dump_file
);
711 fflush (flow_dump_file
);
712 if (combine_dump_file
)
713 fflush (combine_dump_file
);
715 fflush (sched_dump_file
);
716 if (local_reg_dump_file
)
717 fflush (local_reg_dump_file
);
718 if (global_reg_dump_file
)
719 fflush (global_reg_dump_file
);
720 if (sched2_dump_file
)
721 fflush (sched2_dump_file
);
722 if (jump2_opt_dump_file
)
723 fflush (jump2_opt_dump_file
);
724 if (dbr_sched_dump_file
)
725 fflush (dbr_sched_dump_file
);
726 if (stack_reg_dump_file
)
727 fflush (stack_reg_dump_file
);
731 /* This is the default decl_printable_name function. */
734 decl_name (decl
, kind
)
738 return IDENTIFIER_POINTER (DECL_NAME (decl
));
741 static int need_error_newline
;
743 /* Function of last error message;
744 more generally, function such that if next error message is in it
745 then we don't have to mention the function name. */
746 static tree last_error_function
= NULL
;
748 /* Used to detect when input_file_stack has changed since last described. */
749 static int last_error_tick
;
751 /* Called when the start of a function definition is parsed,
752 this function prints on stderr the name of the function. */
755 announce_function (decl
)
761 if (rtl_dump_and_exit
)
762 fprintf (stderr
, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl
)));
764 fprintf (stderr
, " %s", (*decl_printable_name
) (decl
, &junk
));
766 need_error_newline
= 1;
767 last_error_function
= current_function_decl
;
771 /* Prints out, if necessary, the name of the current function
772 which caused an error. Called from all error and warning functions. */
775 report_error_function (file
)
778 struct file_stack
*p
;
780 if (need_error_newline
)
782 fprintf (stderr
, "\n");
783 need_error_newline
= 0;
786 if (last_error_function
!= current_function_decl
)
788 char *kind
= "function";
789 if (current_function_decl
!= 0
790 && TREE_CODE (TREE_TYPE (current_function_decl
)) == METHOD_TYPE
)
794 fprintf (stderr
, "%s: ", file
);
796 if (current_function_decl
== NULL
)
797 fprintf (stderr
, "At top level:\n");
800 char *name
= (*decl_printable_name
) (current_function_decl
, &kind
);
801 fprintf (stderr
, "In %s `%s':\n", kind
, name
);
804 last_error_function
= current_function_decl
;
806 if (input_file_stack
&& input_file_stack
->next
!= 0
807 && input_file_stack_tick
!= last_error_tick
)
809 fprintf (stderr
, "In file included");
810 for (p
= input_file_stack
->next
; p
; p
= p
->next
)
812 fprintf (stderr
, " from %s:%d", p
->name
, p
->line
);
814 fprintf (stderr
, ",");
816 fprintf (stderr
, ":\n");
817 last_error_tick
= input_file_stack_tick
;
821 /* Report an error at the current line number.
822 S and V are a string and an arg for `printf'. */
827 int v
; /* @@also used as pointer */
828 int v2
; /* @@also used as pointer */
830 error_with_file_and_line (input_filename
, lineno
, s
, v
, v2
);
833 /* Report an error at line LINE of file FILE.
834 S and V are a string and an arg for `printf'. */
837 error_with_file_and_line (file
, line
, s
, v
, v2
)
846 report_error_function (file
);
849 fprintf (stderr
, "%s:%d: ", file
, line
);
851 fprintf (stderr
, "%s: ", progname
);
852 fprintf (stderr
, s
, v
, v2
);
853 fprintf (stderr
, "\n");
856 /* Report an error at the declaration DECL.
857 S and V are a string and an arg which uses %s to substitute the declaration name. */
860 error_with_decl (decl
, s
, v
)
868 report_error_function (DECL_SOURCE_FILE (decl
));
870 fprintf (stderr
, "%s:%d: ",
871 DECL_SOURCE_FILE (decl
), DECL_SOURCE_LINE (decl
));
873 if (DECL_NAME (decl
))
874 fprintf (stderr
, s
, (*decl_printable_name
) (decl
, &junk
), v
);
876 fprintf (stderr
, s
, "((anonymous))", v
);
877 fprintf (stderr
, "\n");
880 /* Report an error at the line number of the insn INSN.
881 S and V are a string and an arg for `printf'.
882 This is used only when INSN is an `asm' with operands,
883 and each ASM_OPERANDS records its own source file and line. */
886 error_for_asm (insn
, s
, v
, v2
)
889 int v
; /* @@also used as pointer */
890 int v2
; /* @@also used as pointer */
894 rtx body
= PATTERN (insn
);
897 /* Find the (or one of the) ASM_OPERANDS in the insn. */
898 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
899 asmop
= SET_SRC (body
);
900 else if (GET_CODE (body
) == ASM_OPERANDS
)
902 else if (GET_CODE (body
) == PARALLEL
903 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
)
904 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
905 else if (GET_CODE (body
) == PARALLEL
906 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
907 asmop
= XVECEXP (body
, 0, 0);
909 filename
= ASM_OPERANDS_SOURCE_FILE (asmop
);
910 line
= ASM_OPERANDS_SOURCE_LINE (asmop
);
912 error_with_file_and_line (filename
, line
, s
, v
, v2
);
915 /* Report a warning at line LINE.
916 S and V are a string and an arg for `printf'. */
919 warning_with_file_and_line (file
, line
, s
, v
, v2
, v3
)
927 if (count_error (1) == 0)
930 report_error_function (file
);
933 fprintf (stderr
, "%s:%d: ", file
, line
);
935 fprintf (stderr
, "%s: ", progname
);
937 fprintf (stderr
, "warning: ");
938 fprintf (stderr
, s
, v
, v2
, v3
);
939 fprintf (stderr
, "\n");
942 /* Report a warning at the current line number.
943 S and V are a string and an arg for `printf'. */
946 warning (s
, v
, v2
, v3
)
948 int v
; /* @@also used as pointer */
952 warning_with_file_and_line (input_filename
, lineno
, s
, v
, v2
, v3
);
955 /* Report a warning at the declaration DECL.
956 S is string which uses %s to substitute the declaration name.
957 V is a second parameter that S can refer to. */
960 warning_with_decl (decl
, s
, v
)
967 if (count_error (1) == 0)
970 report_error_function (DECL_SOURCE_FILE (decl
));
972 fprintf (stderr
, "%s:%d: ",
973 DECL_SOURCE_FILE (decl
), DECL_SOURCE_LINE (decl
));
975 fprintf (stderr
, "warning: ");
976 if (DECL_NAME (decl
))
977 fprintf (stderr
, s
, (*decl_printable_name
) (decl
, &junk
), v
);
979 fprintf (stderr
, s
, "((anonymous))", v
);
980 fprintf (stderr
, "\n");
983 /* Report a warning at the line number of the insn INSN.
984 S and V are a string and an arg for `printf'.
985 This is used only when INSN is an `asm' with operands,
986 and each ASM_OPERANDS records its own source file and line. */
989 warning_for_asm (insn
, s
, v
, v2
)
992 int v
; /* @@also used as pointer */
993 int v2
; /* @@also used as pointer */
997 rtx body
= PATTERN (insn
);
1000 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1001 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
1002 asmop
= SET_SRC (body
);
1003 else if (GET_CODE (body
) == ASM_OPERANDS
)
1005 else if (GET_CODE (body
) == PARALLEL
1006 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
)
1007 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
1008 else if (GET_CODE (body
) == PARALLEL
1009 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
1010 asmop
= XVECEXP (body
, 0, 0);
1012 filename
= ASM_OPERANDS_SOURCE_FILE (asmop
);
1013 line
= ASM_OPERANDS_SOURCE_LINE (asmop
);
1015 warning_with_file_and_line (filename
, line
, s
, v
, v2
);
1018 /* These functions issue either warnings or errors depending on
1019 -pedantic-errors. */
1024 int v
; /* @@also used as pointer */
1027 if (flag_pedantic_errors
)
1034 pedwarn_with_decl (decl
, s
, v
)
1039 if (flag_pedantic_errors
)
1040 error_with_decl (decl
, s
, v
);
1042 warning_with_decl (decl
, s
, v
);
1046 pedwarn_with_file_and_line (file
, line
, s
, v
, v2
)
1053 if (flag_pedantic_errors
)
1054 error_with_file_and_line (file
, line
, s
, v
, v2
);
1056 warning_with_file_and_line (file
, line
, s
, v
, v2
);
1059 /* Apologize for not implementing some feature.
1060 S, V, and V2 are a string and args for `printf'. */
1069 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
1071 fprintf (stderr
, "%s: ", progname
);
1073 fprintf (stderr
, "sorry, not implemented: ");
1074 fprintf (stderr
, s
, v
, v2
);
1075 fprintf (stderr
, "\n");
1078 /* Apologize for not implementing some feature, then quit.
1079 S, V, and V2 are a string and args for `printf'. */
1082 really_sorry (s
, v
, v2
)
1087 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
1089 fprintf (stderr
, "c++: ");
1091 fprintf (stderr
, "sorry, not implemented: ");
1092 fprintf (stderr
, s
, v
, v2
);
1093 fatal (" (fatal)\n");
1096 /* More 'friendly' abort that prints the line and file.
1097 config.h can #define abort fancy_abort if you like that sort of thing.
1099 I don't think this is actually a good idea.
1100 Other sorts of crashes will look a certain way.
1101 It is a good thing if crashes from calling abort look the same way.
1107 fatal ("internal gcc abort");
1110 /* This calls abort and is used to avoid problems when abort if a macro.
1111 It is used when we need to pass the address of abort. */
1119 /* When `malloc.c' is compiled with `rcheck' defined,
1120 it calls this function to report clobberage. */
1128 /* Same as `malloc' but report error if no memory available. */
1134 register int value
= (int) malloc (size
);
1136 fatal ("virtual memory exhausted");
1140 /* Same as `realloc' but report error if no memory available. */
1143 xrealloc (ptr
, size
)
1147 int result
= realloc (ptr
, size
);
1149 fatal ("virtual memory exhausted");
1153 /* Return the logarithm of X, base 2, considering X unsigned,
1154 if X is a power of 2. Otherwise, returns -1. */
1158 register unsigned int x
;
1160 register int log
= 0;
1161 /* Test for 0 or a power of 2. */
1162 if (x
== 0 || x
!= (x
& -x
))
1164 while ((x
>>= 1) != 0)
1169 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1170 If X is 0, return -1. */
1174 register unsigned int x
;
1176 register int log
= -1;
1184 jmp_buf float_handler
;
1186 /* Specify where to longjmp to when a floating arithmetic error happens.
1187 If HANDLER is 0, it means don't handle the errors any more. */
1190 set_float_handler (handler
)
1193 float_handled
= (handler
!= 0);
1195 bcopy (handler
, float_handler
, sizeof (float_handler
));
1198 /* Signals actually come here. */
1201 float_signal (signo
)
1202 /* If this is missing, some compilers complain. */
1205 if (float_handled
== 0)
1207 #if defined (USG) || defined (hpux)
1208 signal (SIGFPE
, float_signal
); /* re-enable the signal catcher */
1211 signal (SIGFPE
, float_signal
);
1212 longjmp (float_handler
, 1);
1215 /* Handler for SIGPIPE. */
1219 /* If this is missing, some compilers complain. */
1222 fatal ("output pipe has been closed");
1225 /* Strip off a legitimate source ending from the input string NAME of
1229 strip_off_ending (name
, len
)
1233 if (len
> 2 && ! strcmp (".c", name
+ len
- 2))
1235 else if (len
> 2 && ! strcmp (".m", name
+ len
- 2))
1237 else if (len
> 2 && ! strcmp (".i", name
+ len
- 2))
1239 else if (len
> 3 && ! strcmp (".ii", name
+ len
- 3))
1241 else if (len
> 3 && ! strcmp (".co", name
+ len
- 3))
1243 else if (len
> 3 && ! strcmp (".cc", name
+ len
- 3))
1245 else if (len
> 2 && ! strcmp (".f", name
+ len
- 2))
1247 else if (len
> 4 && ! strcmp (".ada", name
+ len
- 4))
1251 /* Output a file name in the form wanted by System V. */
1254 output_file_directive (asm_file
, input_name
)
1258 int len
= strlen (input_name
);
1259 char *na
= input_name
+ len
;
1261 /* NA gets INPUT_NAME sans directory names. */
1262 while (na
> input_name
)
1269 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1270 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file
, na
);
1272 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1273 ASM_OUTPUT_SOURCE_FILENAME (asm_file
, na
);
1275 fprintf (asm_file
, "\t.file\t\"%s\"\n", na
);
1280 /* Compile an entire file of output from cpp, named NAME.
1281 Write a file of assembly output and various debugging dumps. */
1289 int dump_base_name_length
;
1290 char *aux_info_file_name
;
1292 int name_specified
= name
!= 0;
1294 if (dump_base_name
== 0)
1295 dump_base_name
= name
? name
: "gccdump";
1296 dump_base_name_length
= strlen (dump_base_name
);
1300 integration_time
= 0;
1308 local_alloc_time
= 0;
1309 global_alloc_time
= 0;
1312 shorten_branch_time
= 0;
1318 /* Open input file. */
1320 if (name
== 0 || !strcmp (name
, "-"))
1326 finput
= fopen (name
, "r");
1328 pfatal_with_name (name
);
1330 /* Initialize data in various passes. */
1336 init_emit_once (debug_info_level
== DINFO_LEVEL_NORMAL
1337 || debug_info_level
== DINFO_LEVEL_VERBOSE
);
1338 init_decl_processing ();
1345 if (flag_caller_saves
)
1346 init_caller_save ();
1348 /* If auxilliary info generation is desired, open the output file. */
1349 if (flag_gen_aux_info
)
1351 aux_info_file_name
= (char *) xmalloc (dump_base_name_length
+ 6);
1352 strcpy (aux_info_file_name
, dump_base_name
);
1353 strcat (aux_info_file_name
, ".X");
1354 aux_info_file
= fopen (aux_info_file_name
, "w");
1355 if (aux_info_file
== 0)
1356 pfatal_with_name (aux_info_file_name
);
1359 /* If rtl dump desired, open the output file. */
1362 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1363 strcpy (dumpname
, dump_base_name
);
1364 strcat (dumpname
, ".rtl");
1365 rtl_dump_file
= fopen (dumpname
, "w");
1366 if (rtl_dump_file
== 0)
1367 pfatal_with_name (dumpname
);
1370 /* If jump_opt dump desired, open the output file. */
1373 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1374 strcpy (dumpname
, dump_base_name
);
1375 strcat (dumpname
, ".jump");
1376 jump_opt_dump_file
= fopen (dumpname
, "w");
1377 if (jump_opt_dump_file
== 0)
1378 pfatal_with_name (dumpname
);
1381 /* If cse dump desired, open the output file. */
1384 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1385 strcpy (dumpname
, dump_base_name
);
1386 strcat (dumpname
, ".cse");
1387 cse_dump_file
= fopen (dumpname
, "w");
1388 if (cse_dump_file
== 0)
1389 pfatal_with_name (dumpname
);
1392 /* If loop dump desired, open the output file. */
1395 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1396 strcpy (dumpname
, dump_base_name
);
1397 strcat (dumpname
, ".loop");
1398 loop_dump_file
= fopen (dumpname
, "w");
1399 if (loop_dump_file
== 0)
1400 pfatal_with_name (dumpname
);
1403 /* If cse2 dump desired, open the output file. */
1406 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1407 strcpy (dumpname
, dump_base_name
);
1408 strcat (dumpname
, ".cse2");
1409 cse2_dump_file
= fopen (dumpname
, "w");
1410 if (cse2_dump_file
== 0)
1411 pfatal_with_name (dumpname
);
1414 /* If flow dump desired, open the output file. */
1417 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1418 strcpy (dumpname
, dump_base_name
);
1419 strcat (dumpname
, ".flow");
1420 flow_dump_file
= fopen (dumpname
, "w");
1421 if (flow_dump_file
== 0)
1422 pfatal_with_name (dumpname
);
1425 /* If combine dump desired, open the output file. */
1428 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 10);
1429 strcpy (dumpname
, dump_base_name
);
1430 strcat (dumpname
, ".combine");
1431 combine_dump_file
= fopen (dumpname
, "w");
1432 if (combine_dump_file
== 0)
1433 pfatal_with_name (dumpname
);
1436 /* If scheduling dump desired, open the output file. */
1439 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 7);
1440 strcpy (dumpname
, dump_base_name
);
1441 strcat (dumpname
, ".sched");
1442 sched_dump_file
= fopen (dumpname
, "w");
1443 if (sched_dump_file
== 0)
1444 pfatal_with_name (dumpname
);
1447 /* If local_reg dump desired, open the output file. */
1450 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1451 strcpy (dumpname
, dump_base_name
);
1452 strcat (dumpname
, ".lreg");
1453 local_reg_dump_file
= fopen (dumpname
, "w");
1454 if (local_reg_dump_file
== 0)
1455 pfatal_with_name (dumpname
);
1458 /* If global_reg dump desired, open the output file. */
1459 if (global_reg_dump
)
1461 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1462 strcpy (dumpname
, dump_base_name
);
1463 strcat (dumpname
, ".greg");
1464 global_reg_dump_file
= fopen (dumpname
, "w");
1465 if (global_reg_dump_file
== 0)
1466 pfatal_with_name (dumpname
);
1469 /* If 2nd scheduling dump desired, open the output file. */
1472 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 8);
1473 strcpy (dumpname
, dump_base_name
);
1474 strcat (dumpname
, ".sched2");
1475 sched2_dump_file
= fopen (dumpname
, "w");
1476 if (sched2_dump_file
== 0)
1477 pfatal_with_name (dumpname
);
1480 /* If jump2_opt dump desired, open the output file. */
1483 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 7);
1484 strcpy (dumpname
, dump_base_name
);
1485 strcat (dumpname
, ".jump2");
1486 jump2_opt_dump_file
= fopen (dumpname
, "w");
1487 if (jump2_opt_dump_file
== 0)
1488 pfatal_with_name (dumpname
);
1491 /* If dbr_sched dump desired, open the output file. */
1494 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 7);
1495 strcpy (dumpname
, dump_base_name
);
1496 strcat (dumpname
, ".dbr");
1497 dbr_sched_dump_file
= fopen (dumpname
, "w");
1498 if (dbr_sched_dump_file
== 0)
1499 pfatal_with_name (dumpname
);
1504 /* If stack_reg dump desired, open the output file. */
1507 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 10);
1508 strcpy (dumpname
, dump_base_name
);
1509 strcat (dumpname
, ".stack");
1510 stack_reg_dump_file
= fopen (dumpname
, "w");
1511 if (stack_reg_dump_file
== 0)
1512 pfatal_with_name (dumpname
);
1517 /* Open assembler code output file. */
1519 if (! name_specified
&& asm_file_name
== 0)
1520 asm_out_file
= stdout
;
1523 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1524 int len
= strlen (dump_base_name
);
1525 strcpy (dumpname
, dump_base_name
);
1526 strip_off_ending (dumpname
, len
);
1527 strcat (dumpname
, ".s");
1528 if (asm_file_name
== 0)
1530 asm_file_name
= (char *) xmalloc (strlen (dumpname
) + 1);
1531 strcpy (asm_file_name
, dumpname
);
1533 if (!strcmp (asm_file_name
, "-"))
1534 asm_out_file
= stdout
;
1536 asm_out_file
= fopen (asm_file_name
, "w");
1537 if (asm_out_file
== 0)
1538 pfatal_with_name (asm_file_name
);
1541 input_filename
= name
;
1543 /* Perform language-specific initialization.
1544 This may set main_input_filename. */
1547 /* If the input doesn't start with a #line, use the input name
1548 as the official input file name. */
1549 if (main_input_filename
== 0)
1550 main_input_filename
= name
;
1552 /* Put an entry on the input file stack for the main input file. */
1554 = (struct file_stack
*) xmalloc (sizeof (struct file_stack
));
1555 input_file_stack
->next
= 0;
1556 input_file_stack
->name
= input_filename
;
1558 ASM_FILE_START (asm_out_file
);
1560 /* Output something to inform GDB that this compilation was by GCC. */
1561 #ifndef ASM_IDENTIFY_GCC
1562 fprintf (asm_out_file
, "gcc2_compiled.:\n");
1564 ASM_IDENTIFY_GCC (asm_out_file
);
1566 /* Don't let the first function fall at the same address
1567 as gcc_compiled., if profiling. */
1568 if (profile_flag
|| profile_block_flag
)
1569 assemble_zeros (UNITS_PER_WORD
);
1571 /* If dbx symbol table desired, initialize writing it
1572 and output the predefined types. */
1573 #ifdef DBX_DEBUGGING_INFO
1574 if (write_symbols
== DBX_DEBUG
)
1575 TIMEVAR (symout_time
, dbxout_init (asm_out_file
, main_input_filename
,
1578 #ifdef SDB_DEBUGGING_INFO
1579 if (write_symbols
== SDB_DEBUG
)
1580 TIMEVAR (symout_time
, sdbout_init (asm_out_file
, main_input_filename
,
1583 #ifdef DWARF_DEBUGGING_INFO
1584 if (write_symbols
== DWARF_DEBUG
)
1585 TIMEVAR (symout_time
, dwarfout_init (asm_out_file
, main_input_filename
));
1588 /* Initialize yet another pass. */
1590 init_final (main_input_filename
);
1592 start_time
= get_run_time ();
1594 /* Call the parser, which parses the entire file
1595 (calling rest_of_compilation for each function). */
1597 if (yyparse () != 0)
1598 if (errorcount
== 0)
1599 fprintf (stderr
, "Errors detected in input file (your bison.simple is out of date)");
1601 /* Compilation is now finished except for writing
1602 what's left of the symbol table output. */
1604 parse_time
+= get_run_time () - start_time
;
1606 parse_time
-= integration_time
;
1607 parse_time
-= varconst_time
;
1609 globals
= getdecls ();
1611 /* Really define vars that have had only a tentative definition.
1612 Really output inline functions that must actually be callable
1613 and have not been output so far. */
1616 int len
= list_length (globals
);
1617 tree
*vec
= (tree
*) alloca (sizeof (tree
) * len
);
1621 /* Process the decls in reverse order--earliest first.
1622 Put them into VEC from back to front, then take out from front. */
1624 for (i
= 0, decl
= globals
; i
< len
; i
++, decl
= TREE_CHAIN (decl
))
1625 vec
[len
- i
- 1] = decl
;
1627 for (i
= 0; i
< len
; i
++)
1630 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
1631 && ! TREE_ASM_WRITTEN (decl
))
1633 /* Don't write out static consts, unless we used them.
1634 (This used to write them out only if the address was
1635 taken, but that was wrong; if the variable was simply
1636 referred to, it still needs to exist or else it will
1637 be undefined in the linker.) */
1638 if (! TREE_READONLY (decl
)
1639 || TREE_PUBLIC (decl
)
1641 || TREE_ADDRESSABLE (decl
)
1642 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl
)))
1643 rest_of_decl_compilation (decl
, 0, 1, 1);
1645 /* Cancel the RTL for this decl so that, if debugging info
1646 output for global variables is still to come,
1647 this one will be omitted. */
1648 DECL_RTL (decl
) = NULL
;
1651 if (TREE_CODE (decl
) == FUNCTION_DECL
1652 && ! TREE_ASM_WRITTEN (decl
)
1653 && DECL_INITIAL (decl
) != 0
1654 && (TREE_ADDRESSABLE (decl
)
1655 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl
)))
1656 && ! TREE_EXTERNAL (decl
))
1657 output_inline_function (decl
);
1659 /* Warn about any function or variable
1660 declared static but not defined. */
1663 || (DECL_NAME (decl
) && TREE_USED (DECL_NAME (decl
))))
1664 /* && TREE_CODE (decl) == FUNCTION_DECL */
1665 && DECL_INITIAL (decl
) == 0
1666 && TREE_EXTERNAL (decl
)
1667 && ! TREE_PUBLIC (decl
))
1668 warning_with_decl (decl
, "`%s' declared `static' but never defined");
1669 /* Warn about static fns or vars defined but not used,
1670 but not about inline functions
1671 since unused inline statics is normal practice. */
1673 && (TREE_CODE (decl
) == FUNCTION_DECL
1674 || TREE_CODE (decl
) == VAR_DECL
)
1675 && ! TREE_EXTERNAL (decl
)
1676 && ! TREE_PUBLIC (decl
)
1677 && ! TREE_USED (decl
)
1678 && ! TREE_INLINE (decl
)
1679 /* The TREE_USED bit for file-scope decls
1680 is kept in the identifier, to handle multiple
1681 external decls in different scopes. */
1682 && ! TREE_USED (DECL_NAME (decl
)))
1683 warning_with_decl (decl
, "`%s' defined but not used");
1685 #ifdef SDB_DEBUGGING_INFO
1686 /* The COFF linker can move initialized global vars to the end.
1687 And that can screw up the symbol ordering.
1688 By putting the symbols in that order to begin with,
1689 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1690 if (write_symbols
== SDB_DEBUG
&& TREE_CODE (decl
) == VAR_DECL
1691 && TREE_PUBLIC (decl
) && DECL_INITIAL (decl
)
1692 && DECL_RTL (decl
) != 0)
1693 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
1695 /* Output COFF information for non-global
1696 file-scope initialized variables. */
1697 if (write_symbols
== SDB_DEBUG
1698 && TREE_CODE (decl
) == VAR_DECL
1699 && DECL_INITIAL (decl
)
1700 && DECL_RTL (decl
) != 0
1701 && GET_CODE (DECL_RTL (decl
)) == MEM
)
1702 TIMEVAR (symout_time
, sdbout_toplevel_data (decl
));
1703 #endif /* SDB_DEBUGGING_INFO */
1704 #ifdef DWARF_DEBUGGING_INFO
1705 /* Output DWARF information for file-scope tenative data object
1706 declarations, file-scope (extern) function declarations (which
1707 had no corresponding body) and file-scope tagged type declarations
1708 and definitions which have not yet been forced out. */
1710 if (write_symbols
== DWARF_DEBUG
1711 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
1712 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 1));
1717 /* Do dbx symbols */
1718 #ifdef DBX_DEBUGGING_INFO
1719 if (write_symbols
== DBX_DEBUG
)
1720 TIMEVAR (symout_time
,
1722 dbxout_finish (asm_out_file
, main_input_filename
);
1726 #ifdef DWARF_DEBUGGING_INFO
1727 if (write_symbols
== DWARF_DEBUG
)
1728 TIMEVAR (symout_time
,
1734 /* Output some stuff at end of file if nec. */
1736 end_final (main_input_filename
);
1739 ASM_FILE_END (asm_out_file
);
1742 after_finish_compilation
:
1744 /* Language-specific end of compilation actions. */
1748 /* Close the dump files. */
1750 if (flag_gen_aux_info
)
1752 fclose (aux_info_file
);
1754 unlink (aux_info_file_name
);
1758 fclose (rtl_dump_file
);
1761 fclose (jump_opt_dump_file
);
1764 fclose (cse_dump_file
);
1767 fclose (loop_dump_file
);
1770 fclose (cse2_dump_file
);
1773 fclose (flow_dump_file
);
1777 dump_combine_total_stats (combine_dump_file
);
1778 fclose (combine_dump_file
);
1782 fclose (sched_dump_file
);
1785 fclose (local_reg_dump_file
);
1787 if (global_reg_dump
)
1788 fclose (global_reg_dump_file
);
1791 fclose (sched2_dump_file
);
1794 fclose (jump2_opt_dump_file
);
1797 fclose (dbr_sched_dump_file
);
1801 fclose (stack_reg_dump_file
);
1804 /* Close non-debugging input and output files. Take special care to note
1805 whether fclose returns an error, since the pages might still be on the
1806 buffer chain while the file is open. */
1809 if (ferror (asm_out_file
) != 0 || fclose (asm_out_file
) != 0)
1810 fatal_io_error (asm_file_name
);
1812 /* Print the times. */
1816 fprintf (stderr
,"\n");
1817 print_time ("parse", parse_time
);
1818 print_time ("integration", integration_time
);
1819 print_time ("jump", jump_time
);
1820 print_time ("cse", cse_time
);
1821 print_time ("loop", loop_time
);
1822 print_time ("cse2", cse2_time
);
1823 print_time ("flow", flow_time
);
1824 print_time ("combine", combine_time
);
1825 print_time ("sched", sched_time
);
1826 print_time ("local-alloc", local_alloc_time
);
1827 print_time ("global-alloc", global_alloc_time
);
1828 print_time ("sched2", sched2_time
);
1829 print_time ("dbranch", dbr_sched_time
);
1830 print_time ("shorten-branch", shorten_branch_time
);
1831 print_time ("stack-reg", stack_reg_time
);
1832 print_time ("final", final_time
);
1833 print_time ("varconst", varconst_time
);
1834 print_time ("symout", symout_time
);
1835 print_time ("dump", dump_time
);
1839 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
1840 and TYPE_DECL nodes.
1842 This does nothing for local (non-static) variables.
1843 Otherwise, it sets up the RTL and outputs any assembler code
1844 (label definition, storage allocation and initialization).
1846 DECL is the declaration. If ASMSPEC is nonzero, it specifies
1847 the assembler symbol name to be used. TOP_LEVEL is nonzero
1848 if this declaration is not within a function. */
1851 rest_of_decl_compilation (decl
, asmspec
, top_level
, at_end
)
1857 /* Declarations of variables, and of functions defined elsewhere. */
1859 /* Forward declarations for nested functions are not "external",
1860 but we need to treat them as if they were. */
1861 if (TREE_STATIC (decl
) || TREE_EXTERNAL (decl
)
1862 || TREE_CODE (decl
) == FUNCTION_DECL
)
1863 TIMEVAR (varconst_time
,
1865 make_decl_rtl (decl
, asmspec
, top_level
);
1866 /* Don't output anything
1867 when a tentative file-scope definition is seen.
1868 But at end of compilation, do output code for them. */
1869 if (! (! at_end
&& top_level
1870 && (DECL_INITIAL (decl
) == 0
1871 || DECL_INITIAL (decl
) == error_mark_node
)))
1872 assemble_variable (decl
, top_level
, at_end
);
1874 else if (TREE_REGDECL (decl
) && asmspec
!= 0)
1876 if (decode_reg_name (asmspec
) >= 0)
1878 DECL_RTL (decl
) = 0;
1879 make_decl_rtl (decl
, asmspec
, top_level
);
1882 error ("invalid register name `%s' for register variable", asmspec
);
1884 #ifdef DBX_DEBUGGING_INFO
1885 else if (write_symbols
== DBX_DEBUG
&& TREE_CODE (decl
) == TYPE_DECL
)
1886 TIMEVAR (symout_time
, dbxout_symbol (decl
, 0));
1888 #ifdef SDB_DEBUGGING_INFO
1889 else if (write_symbols
== SDB_DEBUG
&& top_level
1890 && TREE_CODE (decl
) == TYPE_DECL
)
1891 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
1895 /* Called after finishing a record, union or enumeral type. */
1898 rest_of_type_compilation (type
, toplev
)
1902 #ifdef DBX_DEBUGGING_INFO
1903 if (write_symbols
== DBX_DEBUG
)
1904 TIMEVAR (symout_time
, dbxout_symbol (TYPE_STUB_DECL (type
), !toplev
));
1906 #ifdef SDB_DEBUGGING_INFO
1907 if (write_symbols
== SDB_DEBUG
)
1908 TIMEVAR (symout_time
, sdbout_symbol (TYPE_STUB_DECL (type
), !toplev
));
1912 /* This is called from finish_function (within yyparse)
1913 after each top-level definition is parsed.
1914 It is supposed to compile that function or variable
1915 and output the assembler code for it.
1916 After we return, the tree storage is freed. */
1919 rest_of_compilation (decl
)
1923 int start_time
= get_run_time ();
1925 /* Nonzero if we have saved the original DECL_INITIAL of the function,
1926 to be restored after we finish compiling the function
1927 (for use when compiling inline calls to this function). */
1928 tree saved_block_tree
= 0;
1930 /* If we are reconsidering an inline function
1931 at the end of compilation, skip the stuff for making it inline. */
1933 if (DECL_SAVED_INSNS (decl
) == 0)
1935 int specd
= TREE_INLINE (decl
);
1938 /* If requested, consider whether to make this function inline. */
1939 if (specd
|| flag_inline_functions
)
1940 TIMEVAR (integration_time
,
1942 lose
= function_cannot_inline_p (decl
);
1945 if (warn_inline
&& specd
)
1946 warning_with_decl (decl
, lose
);
1947 TREE_INLINE (decl
) = 0;
1950 TREE_INLINE (decl
) = 1;
1953 insns
= get_insns ();
1955 /* Dump the rtl code if we are dumping rtl. */
1960 fprintf (rtl_dump_file
, "\n;; Function %s\n\n",
1961 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1962 if (DECL_SAVED_INSNS (decl
))
1963 fprintf (rtl_dump_file
, ";; (integrable)\n\n");
1964 print_rtl (rtl_dump_file
, insns
);
1965 fflush (rtl_dump_file
);
1968 /* If function is inline, and we don't yet know whether to
1969 compile it by itself, defer decision till end of compilation.
1970 finish_compilation will call rest_of_compilation again
1971 for those functions that need to be output. */
1973 if (TREE_INLINE (decl
)
1974 && ((! TREE_PUBLIC (decl
) && ! TREE_ADDRESSABLE (decl
)
1975 && ! flag_keep_inline_functions
)
1976 || TREE_EXTERNAL (decl
)))
1978 TIMEVAR (integration_time
, save_for_inline_nocopy (decl
));
1979 goto exit_rest_of_compilation
;
1982 /* If we have to compile the function now, save its rtl
1983 so that its compilation will not affect what others get. */
1984 if (TREE_INLINE (decl
))
1986 saved_block_tree
= DECL_INITIAL (decl
);
1987 TIMEVAR (integration_time
, save_for_inline_copying (decl
));
1991 /* Suppress warnings for unused static functions
1992 defined (not just declared) in system headers. */
1993 if (in_system_header
&& TREE_STATIC (decl
) && !TREE_INLINE (decl
))
1994 TREE_USED (decl
) = 1;
1996 TREE_ASM_WRITTEN (decl
) = 1;
1998 /* Now that integrate will no longer see our rtl, we need not distinguish
1999 between the return value of this function and the return value of called
2001 rtx_equal_function_value_matters
= 0;
2003 if (rtl_dump_and_exit
|| flag_syntax_only
)
2005 goto exit_rest_of_compilation
;
2008 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2009 Note that that may have been done above, in save_for_inline_copying.
2010 The call to resume_temporary_allocation near the end of this function
2011 goes back to the usual state of affairs. */
2013 rtl_in_current_obstack ();
2016 /* If we are doing position-independent code generation, now
2017 is the time to output special prologues and epilogues.
2018 We do not want to do this earlier, because it just clutters
2019 up inline functions with meaningless insns. */
2024 insns
= get_insns ();
2026 /* Copy any shared structure that should not be shared. */
2028 unshare_all_rtl (insns
);
2030 /* Instantiate all virtual registers. */
2032 instantiate_virtual_regs (current_function_decl
, get_insns ());
2034 /* See if we have allocated stack slots that are not directly addressable.
2035 If so, scan all the insns and create explicit address computation
2036 for all references to such slots. */
2037 /* fixup_stack_slots (); */
2039 /* Do jump optimization the first time, if -opt.
2040 Also do it if -W, but in that case it doesn't change the rtl code,
2041 it only computes whether control can drop off the end of the function. */
2043 if (optimize
> 0 || extra_warnings
|| warn_return_type
2044 /* If function is `volatile', we should warn if it tries to return. */
2045 || TREE_THIS_VOLATILE (decl
))
2047 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
2048 TIMEVAR (jump_time
, jump_optimize (insns
, 0, 0, 1));
2051 /* Dump rtl code after jump, if we are doing that. */
2056 fprintf (jump_opt_dump_file
, "\n;; Function %s\n\n",
2057 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2058 print_rtl (jump_opt_dump_file
, insns
);
2059 fflush (jump_opt_dump_file
);
2062 /* Perform common subexpression elimination.
2063 Nonzero value from `cse_main' means that jumps were simplified
2064 and some code may now be unreachable, so do
2065 jump optimization again. */
2070 fprintf (cse_dump_file
, "\n;; Function %s\n\n",
2071 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2076 TIMEVAR (cse_time
, reg_scan (insns
, max_reg_num (), 1));
2078 if (flag_thread_jumps
)
2079 /* Hacks by tiemann & kenner. */
2080 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 0));
2082 TIMEVAR (cse_time
, tem
= cse_main (insns
, max_reg_num (),
2084 TIMEVAR (cse_time
, delete_dead_from_cse (insns
, max_reg_num ()));
2087 TIMEVAR (jump_time
, jump_optimize (insns
, 0, 0, 0));
2090 /* Dump rtl code after cse, if we are doing that. */
2095 print_rtl (cse_dump_file
, insns
);
2096 fflush (cse_dump_file
);
2102 fprintf (loop_dump_file
, "\n;; Function %s\n\n",
2103 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2106 /* Move constant computations out of loops. */
2112 loop_optimize (insns
, loop_dump
? loop_dump_file
: 0);
2116 /* Dump rtl code after loop opt, if we are doing that. */
2121 print_rtl (loop_dump_file
, insns
);
2122 fflush (loop_dump_file
);
2128 fprintf (cse2_dump_file
, "\n;; Function %s\n\n",
2129 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2132 if (optimize
> 0 && flag_rerun_cse_after_loop
)
2134 TIMEVAR (cse2_time
, reg_scan (insns
, max_reg_num (), 0));
2136 TIMEVAR (cse2_time
, tem
= cse_main (insns
, max_reg_num (),
2137 1, cse2_dump_file
));
2139 TIMEVAR (jump_time
, jump_optimize (insns
, 0, 0, 0));
2142 if (optimize
> 0 && flag_thread_jumps
)
2143 /* This pass of jump threading straightens out code
2144 that was kinked by loop optimization. */
2145 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 0));
2147 /* Dump rtl code after cse, if we are doing that. */
2152 print_rtl (cse2_dump_file
, insns
);
2153 fflush (cse2_dump_file
);
2156 /* We are no longer anticipating cse in this function, at least. */
2158 cse_not_expected
= 1;
2160 /* Now we choose between stupid (pcc-like) register allocation
2161 (if we got the -noreg switch and not -opt)
2162 and smart register allocation. */
2164 if (optimize
> 0) /* Stupid allocation probably won't work */
2165 obey_regdecls
= 0; /* if optimizations being done. */
2169 /* Print function header into flow dump now
2170 because doing the flow analysis makes some of the dump. */
2175 fprintf (flow_dump_file
, "\n;; Function %s\n\n",
2176 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2183 regclass (insns
, max_reg_num ());
2184 stupid_life_analysis (insns
, max_reg_num (),
2190 /* Do control and data flow analysis,
2191 and write some of the results to dump file. */
2193 TIMEVAR (flow_time
, flow_analysis (insns
, max_reg_num (),
2195 if (warn_uninitialized
)
2197 uninitialized_vars_warning (DECL_INITIAL (decl
));
2198 setjmp_args_warning ();
2202 /* Dump rtl after flow analysis. */
2207 print_rtl (flow_dump_file
, insns
);
2208 fflush (flow_dump_file
);
2211 /* If -opt, try combining insns through substitution. */
2214 TIMEVAR (combine_time
, combine_instructions (insns
, max_reg_num ()));
2216 /* Dump rtl code after insn combination. */
2221 fprintf (combine_dump_file
, "\n;; Function %s\n\n",
2222 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2223 dump_combine_stats (combine_dump_file
);
2224 print_rtl (combine_dump_file
, insns
);
2225 fflush (combine_dump_file
);
2228 /* Print function header into sched dump now
2229 because doing the sched analysis makes some of the dump. */
2234 fprintf (sched_dump_file
, "\n;; Function %s\n\n",
2235 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2238 if (optimize
> 0 && flag_schedule_insns
)
2240 /* Do control and data sched analysis,
2241 and write some of the results to dump file. */
2243 TIMEVAR (sched_time
, schedule_insns (sched_dump_file
));
2246 /* Dump rtl after instruction scheduling. */
2251 print_rtl (sched_dump_file
, insns
);
2252 fflush (sched_dump_file
);
2255 /* Unless we did stupid register allocation,
2256 allocate pseudo-regs that are used only within 1 basic block. */
2259 TIMEVAR (local_alloc_time
,
2261 regclass (insns
, max_reg_num ());
2265 /* Dump rtl code after allocating regs within basic blocks. */
2270 fprintf (local_reg_dump_file
, "\n;; Function %s\n\n",
2271 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2272 dump_flow_info (local_reg_dump_file
);
2273 dump_local_alloc (local_reg_dump_file
);
2274 print_rtl (local_reg_dump_file
, insns
);
2275 fflush (local_reg_dump_file
);
2278 if (global_reg_dump
)
2280 fprintf (global_reg_dump_file
, "\n;; Function %s\n\n",
2281 IDENTIFIER_POINTER (DECL_NAME (decl
))));
2283 /* Unless we did stupid register allocation,
2284 allocate remaining pseudo-regs, then do the reload pass
2285 fixing up any insns that are invalid. */
2287 TIMEVAR (global_alloc_time
,
2290 global_alloc (global_reg_dump
? global_reg_dump_file
: 0);
2293 global_reg_dump
? global_reg_dump_file
: 0);
2296 if (global_reg_dump
)
2299 dump_global_regs (global_reg_dump_file
);
2300 print_rtl (global_reg_dump_file
, insns
);
2301 fflush (global_reg_dump_file
);
2304 reload_completed
= 1;
2306 if (optimize
> 0 && flag_schedule_insns_after_reload
)
2311 fprintf (sched2_dump_file
, "\n;; Function %s\n\n",
2312 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2315 /* Do control and data sched analysis again,
2316 and write some more of the results to dump file. */
2318 TIMEVAR (sched2_time
, schedule_insns (sched2_dump_file
));
2320 /* Dump rtl after post-reorder instruction scheduling. */
2325 print_rtl (sched2_dump_file
, insns
);
2326 fflush (sched2_dump_file
);
2330 #ifdef LEAF_REGISTERS
2332 if (optimize
> 0 && only_leaf_regs_used () && leaf_function_p ())
2336 /* One more attempt to remove jumps to .+1
2337 left by dead-store-elimination.
2338 Also do cross-jumping this time
2339 and delete no-op move insns. */
2343 TIMEVAR (jump_time
, jump_optimize (insns
, 1, 1, 0));
2346 /* Dump rtl code after jump, if we are doing that. */
2351 fprintf (jump2_opt_dump_file
, "\n;; Function %s\n\n",
2352 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2353 print_rtl (jump2_opt_dump_file
, insns
);
2354 fflush (jump2_opt_dump_file
);
2357 /* If a scheduling pass for delayed branches is to be done,
2358 call the scheduling code. */
2361 if (optimize
> 0 && flag_delayed_branch
)
2363 TIMEVAR (dbr_sched_time
, dbr_schedule (insns
, dbr_sched_dump_file
));
2368 fprintf (dbr_sched_dump_file
, "\n;; Function %s\n\n",
2369 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2370 print_rtl (dbr_sched_dump_file
, insns
);
2371 fflush (dbr_sched_dump_file
);
2378 /* Shorten branches. */
2379 TIMEVAR (shorten_branch_time
,
2381 shorten_branches (get_insns ());
2385 TIMEVAR (stack_reg_time
, reg_to_stack (insns
, stack_reg_dump_file
));
2390 fprintf (stack_reg_dump_file
, "\n;; Function %s\n\n",
2391 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2392 print_rtl (stack_reg_dump_file
, insns
);
2393 fflush (stack_reg_dump_file
);
2398 /* Now turn the rtl into assembler code. */
2400 TIMEVAR (final_time
,
2405 /* Get the function's name, as described by its RTL.
2406 This may be different from the DECL_NAME name used
2407 in the source file. */
2409 x
= DECL_RTL (decl
);
2410 if (GET_CODE (x
) != MEM
)
2413 if (GET_CODE (x
) != SYMBOL_REF
)
2415 fnname
= XSTR (x
, 0);
2417 assemble_start_function (decl
, fnname
);
2418 final_start_function (insns
, asm_out_file
, optimize
);
2419 final (insns
, asm_out_file
, optimize
, 0);
2420 final_end_function (insns
, asm_out_file
, optimize
);
2421 assemble_end_function (decl
, fnname
);
2422 fflush (asm_out_file
);
2425 /* Write DBX symbols if requested */
2427 /* Note that for those inline functions where we don't initially
2428 know for certain that we will be generating an out-of-line copy,
2429 the first invocation of this routine (rest_of_compilation) will
2430 skip over this code by doing a `goto exit_rest_of_compilation;'.
2431 Later on, finish_compilation will call rest_of_compilation again
2432 for those inline functions that need to have out-of-line copies
2433 generated. During that call, we *will* be routed past here. */
2435 #ifdef DBX_DEBUGGING_INFO
2436 if (write_symbols
== DBX_DEBUG
)
2437 TIMEVAR (symout_time
, dbxout_function (decl
));
2440 #ifdef DWARF_DEBUGGING_INFO
2441 if (write_symbols
== DWARF_DEBUG
)
2442 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
2445 exit_rest_of_compilation
:
2447 /* Put back the tree of subblocks from before we copied it.
2448 Code generation and the output of debugging info may have modified
2449 the copy, but the original is unchanged. */
2451 if (saved_block_tree
!= 0)
2452 DECL_INITIAL (decl
) = saved_block_tree
;
2454 reload_completed
= 0;
2456 /* Clear out the real_constant_chain before some of the rtx's
2457 it runs through become garbage. */
2459 clear_const_double_mem ();
2461 /* Cancel the effect of rtl_in_current_obstack. */
2463 resume_temporary_allocation ();
2465 /* The parsing time is all the time spent in yyparse
2466 *except* what is spent in this function. */
2468 parse_time
-= get_run_time () - start_time
;
2471 /* Entry point of cc1/c++. Decode command args, then call compile_file.
2472 Exit code is 35 if can't open files, 34 if fatal error,
2473 33 if had nonfatal errors, else success. */
2476 main (argc
, argv
, envp
)
2483 int flag_print_mem
= 0;
2484 int version_flag
= 0;
2487 /* save in case md file wants to emit args as a comment. */
2491 p
= argv
[0] + strlen (argv
[0]);
2492 while (p
!= argv
[0] && p
[-1] != '/') --p
;
2496 /* Get rid of any avoidable limit on stack size. */
2500 /* Set the stack limit huge so that alloca does not fail. */
2501 getrlimit (RLIMIT_STACK
, &rlim
);
2502 rlim
.rlim_cur
= rlim
.rlim_max
;
2503 setrlimit (RLIMIT_STACK
, &rlim
);
2505 #endif /* RLIMIT_STACK */
2507 signal (SIGFPE
, float_signal
);
2509 signal (SIGPIPE
, pipe_closed
);
2511 decl_printable_name
= decl_name
;
2512 lang_expand_expr
= (struct rtx_def
*(*)()) do_abort
;
2514 /* Initialize whether `char' is signed. */
2515 flag_signed_char
= DEFAULT_SIGNED_CHAR
;
2516 #ifdef DEFAULT_SHORT_ENUMS
2517 /* Initialize how much space enums occupy, by default. */
2518 flag_short_enums
= DEFAULT_SHORT_ENUMS
;
2521 /* Scan to see what optimization level has been specified. That will
2522 determine the default value of many flags. */
2523 for (i
= 1; i
< argc
; i
++)
2525 if (!strcmp (argv
[i
], "-O"))
2529 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'O')
2531 /* Handle -O2, -O3, -O69, ... */
2532 char *p
= &argv
[i
][2];
2536 if (! (c
>= '0' && c
<= '9'))
2539 optimize
= atoi (&argv
[i
][2]);
2543 obey_regdecls
= (optimize
== 0);
2544 flag_no_inline
= (optimize
== 0);
2550 flag_thread_jumps
= 1;
2552 flag_delayed_branch
= 1;
2558 flag_cse_follow_jumps
= 1;
2559 flag_expensive_optimizations
= 1;
2560 flag_strength_reduce
= 1;
2561 flag_rerun_cse_after_loop
= 1;
2562 #ifdef INSN_SCHEDULING
2563 flag_schedule_insns
= 1;
2564 flag_schedule_insns_after_reload
= 1;
2568 #ifdef OPTIMIZATION_OPTIONS
2569 /* Allow default optimizations to be specified on a per-machine basis. */
2570 OPTIMIZATION_OPTIONS (optimize
);
2573 /* Initialize register usage now so switches may override. */
2577 set_target_switch ("");
2579 for (i
= 1; i
< argc
; i
++)
2581 if (argv
[i
][0] == '-' && argv
[i
][1] != 0)
2583 register char *str
= argv
[i
] + 1;
2588 set_target_switch (&str
[1]);
2589 else if (!strcmp (str
, "dumpbase"))
2591 dump_base_name
= argv
[++i
];
2593 else if (str
[0] == 'd')
2595 register char *p
= &str
[1];
2603 global_reg_dump
= 1;
2609 cse_dump
= 1, cse2_dump
= 1;
2627 global_reg_dump
= 1;
2645 flag_print_asm_name
= 1;
2667 rtl_dump_and_exit
= 1;
2671 else if (str
[0] == 'f')
2674 register char *p
= &str
[1];
2677 /* Some kind of -f option.
2678 P's value is the option sans `-f'.
2679 Search for it in the table of options. */
2682 !found
&& j
< sizeof (f_options
) / sizeof (f_options
[0]);
2685 if (!strcmp (p
, f_options
[j
].string
))
2687 *f_options
[j
].variable
= f_options
[j
].on_value
;
2688 /* A goto here would be cleaner,
2689 but breaks the vax pcc. */
2692 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
2693 && ! strcmp (p
+3, f_options
[j
].string
))
2695 *f_options
[j
].variable
= ! f_options
[j
].on_value
;
2702 else if (!strncmp (p
, "fixed-", 6))
2703 fix_register (&p
[6], 1, 1);
2704 else if (!strncmp (p
, "call-used-", 10))
2705 fix_register (&p
[10], 0, 1);
2706 else if (!strncmp (p
, "call-saved-", 11))
2707 fix_register (&p
[11], 0, 0);
2708 else if (! lang_decode_option (argv
[i
]))
2709 error ("Invalid option `%s'", argv
[i
]);
2711 else if (str
[0] == 'O')
2713 register char *p
= str
+1;
2714 while (*p
&& *p
>= '0' && *p
<= '9')
2719 error ("Invalid option `%s'", argv
[i
]);
2721 else if (!strcmp (str
, "pedantic"))
2723 else if (!strcmp (str
, "pedantic-errors"))
2724 flag_pedantic_errors
= pedantic
= 1;
2725 else if (lang_decode_option (argv
[i
]))
2727 else if (!strcmp (str
, "quiet"))
2729 else if (!strcmp (str
, "version"))
2731 else if (!strcmp (str
, "w"))
2732 inhibit_warnings
= 1;
2733 else if (!strcmp (str
, "W"))
2736 warn_uninitialized
= 1;
2738 else if (str
[0] == 'W')
2741 register char *p
= &str
[1];
2744 /* Some kind of -W option.
2745 P's value is the option sans `-W'.
2746 Search for it in the table of options. */
2749 !found
&& j
< sizeof (W_options
) / sizeof (W_options
[0]);
2752 if (!strcmp (p
, W_options
[j
].string
))
2754 *W_options
[j
].variable
= W_options
[j
].on_value
;
2755 /* A goto here would be cleaner,
2756 but breaks the vax pcc. */
2759 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
2760 && ! strcmp (p
+3, W_options
[j
].string
))
2762 *W_options
[j
].variable
= ! W_options
[j
].on_value
;
2769 else if (!strncmp (p
, "id-clash-", 9))
2775 if (*endp
>= '0' && *endp
<= '9')
2778 error ("Invalid option `%s'", argv
[i
]);
2781 id_clash_len
= atoi (str
+ 10);
2784 error ("Invalid option `%s'", argv
[i
]);
2786 else if (!strcmp (str
, "p"))
2788 else if (!strcmp (str
, "a"))
2790 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
2791 warning ("`-a' option (basic block profile) not supported");
2793 profile_block_flag
= 1;
2796 else if (str
[0] == 'g')
2803 while (*p
&& (*p
< '0' || *p
> '9'))
2807 while (*q
&& (*q
>= '0' && *q
<= '9'))
2812 level
= 2; /* default debugging info level */
2813 if (*q
|| level
> 3)
2815 warning ("invalid debug level specification in option: `-%s'",
2817 warning ("no debugging information will be generated");
2821 /* If more than one debugging type is supported,
2822 you must define PREFERRED_DEBUGGING_TYPE
2823 to choose a format in a system-dependent way. */
2824 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) \
2825 + defined (DWARF_DEBUGGING_INFO))
2826 #ifdef PREFERRED_DEBUGGING_TYPE
2827 if (!strncmp (str
, "ggdb", len
))
2828 write_symbols
= PREFERRED_DEBUGGING_TYPE
;
2829 #else /* no PREFERRED_DEBUGGING_TYPE */
2830 You Lose
! You must define PREFERRED_DEBUGGING_TYPE
!
2831 #endif /* no PREFERRED_DEBUGGING_TYPE */
2832 #endif /* More than one debugger format enabled. */
2833 #ifdef DBX_DEBUGGING_INFO
2834 if (write_symbols
!= NO_DEBUG
)
2836 else if (!strncmp (str
, "ggdb", len
))
2837 write_symbols
= DBX_DEBUG
;
2838 else if (!strncmp (str
, "gstabs", len
))
2839 write_symbols
= DBX_DEBUG
;
2841 /* Always enable extensions for -ggdb or -gstabs+,
2842 always disable for -gstabs.
2843 For plain -g, use system-specific default. */
2844 if (write_symbols
== DBX_DEBUG
&& !strncmp (str
, "ggdb", len
)
2846 use_gdb_dbx_extensions
= 1;
2847 else if (write_symbols
== DBX_DEBUG
&& !strcmp (str
, "gstabs+"))
2848 use_gdb_dbx_extensions
= 1;
2849 else if (write_symbols
== DBX_DEBUG
2850 && !strncmp (str
, "gstabs", len
) && len
>= 2)
2851 use_gdb_dbx_extensions
= 0;
2853 use_gdb_dbx_extensions
= DEFAULT_GDB_EXTENSIONS
;
2854 #endif /* DBX_DEBUGGING_INFO */
2855 #ifdef DWARF_DEBUGGING_INFO
2856 if (write_symbols
!= NO_DEBUG
)
2858 else if (!strncmp (str
, "ggdb", len
))
2859 write_symbols
= DWARF_DEBUG
;
2860 /* For orthogonality. */
2861 else if (!strncmp (str
, "gdwarf", len
))
2862 write_symbols
= DWARF_DEBUG
;
2864 #ifdef SDB_DEBUGGING_INFO
2865 if (write_symbols
!= NO_DEBUG
)
2867 else if (!strncmp (str
, "ggdb", len
))
2868 write_symbols
= SDB_DEBUG
;
2869 else if (!strncmp (str
, "gcoff", len
))
2870 write_symbols
= SDB_DEBUG
;
2871 #endif /* SDB_DEBUGGING_INFO */
2872 if (write_symbols
== NO_DEBUG
)
2873 warning ("`-%s' option not supported on this version of GCC", str
);
2874 else if (level
== 0)
2875 write_symbols
= NO_DEBUG
;
2877 debug_info_level
= level
;
2879 else if (!strcmp (str
, "o"))
2881 asm_file_name
= argv
[++i
];
2883 else if (str
[0] == 'G')
2885 g_switch_set
= TRUE
;
2886 g_switch_value
= atoi ((str
[1] != '\0') ? str
+1 : argv
[++i
]);
2889 error ("Invalid option `%s'", argv
[i
]);
2891 else if (argv
[i
][0] == '+')
2893 if (lang_decode_option (argv
[i
]))
2896 error ("Invalid option `%s'", argv
[i
]);
2902 #ifdef OVERRIDE_OPTIONS
2903 /* Some machines may reject certain combinations of options. */
2907 /* Unrolling all loops implies that standard loop unrolling must also
2909 if (flag_unroll_all_loops
)
2910 flag_unroll_loops
= 1;
2911 /* Loop unrolling requires that strength_reduction be on also. Silently
2912 turn on strength reduction here if it isn't already on. Also, the loop
2913 unrolling code assumes that cse will be run after loop, so that must
2914 be turned on also. */
2915 if (flag_unroll_loops
)
2917 flag_strength_reduce
= 1;
2918 flag_rerun_cse_after_loop
= 1;
2921 /* Warn about options that are not supported on this machine. */
2922 #ifndef INSN_SCHEDULING
2923 if (flag_schedule_insns
|| flag_schedule_insns_after_reload
)
2924 warning ("instruction scheduling not supported on this target machine");
2927 if (flag_delayed_branch
)
2928 warning ("this target machine does not have delayed branches");
2931 /* If we are in verbose mode, write out the version and maybe all the
2932 option flags in use. */
2935 fprintf (stderr
, "%s version %s", language_string
, version_string
);
2936 #ifdef TARGET_VERSION
2941 #define __VERSION__ "[unknown]"
2943 fprintf (stderr
, " compiled by GNU C version %s.\n", __VERSION__
);
2945 fprintf (stderr
, " compiled by CC.\n");
2948 print_switch_values ();
2951 /* Now that register usage is specified, convert it to HARD_REG_SETs. */
2954 compile_file (filename
);
2959 char *lim
= (char *) sbrk (0);
2961 fprintf (stderr
, "Data size %d.\n",
2962 (int) lim
- (int) &environ
);
2966 system ("ps -l 1>&2");
2969 #endif /* not USG */
2971 #endif /* not VMS */
2974 exit (FATAL_EXIT_CODE
);
2976 exit (FATAL_EXIT_CODE
);
2977 exit (SUCCESS_EXIT_CODE
);
2981 /* Decode -m switches. */
2983 /* Here is a table, controlled by the tm.h file, listing each -m switch
2984 and which bits in `target_switches' it should set or clear.
2985 If VALUE is positive, it is bits to set.
2986 If VALUE is negative, -VALUE is bits to clear.
2987 (The sign bit is not used so there is no confusion.) */
2989 struct {char *name
; int value
;} target_switches
[]
2992 /* This table is similar, but allows the switch to have a value. */
2994 #ifdef TARGET_OPTIONS
2995 struct {char *prefix
; char ** variable
;} target_options
[]
2999 /* Decode the switch -mNAME. */
3002 set_target_switch (name
)
3008 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
3009 if (!strcmp (target_switches
[j
].name
, name
))
3011 if (target_switches
[j
].value
< 0)
3012 target_flags
&= ~-target_switches
[j
].value
;
3014 target_flags
|= target_switches
[j
].value
;
3018 #ifdef TARGET_OPTIONS
3020 for (j
= 0; j
< sizeof target_options
/ sizeof target_options
[0]; j
++)
3022 int len
= strlen (target_options
[j
].prefix
);
3023 if (!strncmp (target_options
[j
].prefix
, name
, len
))
3025 *target_options
[j
].variable
= name
+ len
;
3032 error ("Invalid option `%s'", name
);
3035 /* Variable used for communication between the following two routines. */
3037 static int line_position
;
3039 /* Print an option value and adjust the position in the line. */
3042 print_single_switch (type
, name
)
3045 fprintf (stderr
, " %s%s", type
, name
);
3047 line_position
+= strlen (type
) + strlen (name
) + 1;
3049 if (line_position
> 65)
3051 fprintf (stderr
, "\n\t");
3056 /* Print default target switches for -version. */
3059 print_switch_values ()
3063 fprintf (stderr
, "enabled:");
3066 for (j
= 0; j
< sizeof f_options
/ sizeof f_options
[0]; j
++)
3067 if (*f_options
[j
].variable
== f_options
[j
].on_value
)
3068 print_single_switch ("-f", f_options
[j
].string
);
3070 for (j
= 0; j
< sizeof W_options
/ sizeof W_options
[0]; j
++)
3071 if (*W_options
[j
].variable
== W_options
[j
].on_value
)
3072 print_single_switch ("-W", W_options
[j
].string
);
3074 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
3075 if (target_switches
[j
].name
[0] != '\0'
3076 && target_switches
[j
].value
> 0
3077 && ((target_switches
[j
].value
& target_flags
)
3078 == target_switches
[j
].value
))
3079 print_single_switch ("-m", target_switches
[j
].name
);
3081 fprintf (stderr
, "\n");