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 #ifdef XCOFF_DEBUGGING_INFO
62 /* The extra parameters substantially improve the I/O performance. */
64 VMS_fopen (fname
, type
)
68 if (strcmp (type
, "w") == 0)
69 return fopen (fname
, type
, "mbc=16", "deq=64", "fop=tef", "shr=nil");
70 return fopen (fname
, type
, "mbc=16");
72 #define fopen VMS_fopen
75 #ifndef DEFAULT_GDB_EXTENSIONS
76 #define DEFAULT_GDB_EXTENSIONS 1
79 extern int rtx_equal_function_value_matters
;
81 #if ! (defined (VMS) || defined (OS2))
82 extern char **environ
;
84 extern char *version_string
, *language_string
;
86 extern void init_lex ();
87 extern void init_decl_processing ();
88 extern void init_obstacks ();
89 extern void init_tree_codes ();
90 extern void init_rtl ();
91 extern void init_optabs ();
92 extern void init_stmt ();
93 extern void init_reg_sets ();
94 extern void dump_flow_info ();
95 extern void dump_sched_info ();
96 extern void dump_local_alloc ();
98 void rest_of_decl_compilation ();
100 void error_with_file_and_line ();
105 void set_target_switch ();
106 static void print_switch_values ();
107 static char *decl_name ();
109 /* Name of program invoked, sans directories. */
113 /* Copy of arguments to main. */
117 /* Name of current original source file (what was input to cpp).
118 This comes from each #-command in the actual input. */
120 char *input_filename
;
122 /* Name of top-level original source file (what was input to cpp).
123 This comes from the #-command at the beginning of the actual input.
124 If there isn't any there, then this is the cc1 input file name. */
126 char *main_input_filename
;
128 /* Stream for reading from the input file. */
132 /* Current line number in real source file. */
136 /* Stack of currently pending input files. */
138 struct file_stack
*input_file_stack
;
140 /* Incremented on each change to input_file_stack. */
141 int input_file_stack_tick
;
143 /* FUNCTION_DECL for function now being parsed or compiled. */
145 extern tree current_function_decl
;
147 /* Name to use as base of names for dump output files. */
149 char *dump_base_name
;
151 /* Bit flags that specify the machine subtype we are compiling for.
152 Bits are tested using macros TARGET_... defined in the tm.h file
153 and set by `-m...' switches. Must be defined in rtlanal.c. */
155 extern int target_flags
;
157 /* Flags saying which kinds of debugging dump have been requested. */
160 int rtl_dump_and_exit
= 0;
161 int jump_opt_dump
= 0;
166 int combine_dump
= 0;
168 int local_reg_dump
= 0;
169 int global_reg_dump
= 0;
171 int jump2_opt_dump
= 0;
172 int dbr_sched_dump
= 0;
173 int flag_print_asm_name
= 0;
174 int stack_reg_dump
= 0;
176 /* Name for output file of assembly code, specified with -o. */
180 /* Value of the -G xx switch, and whether it was passed or not. */
184 /* Type(s) of debugging information we are producing (if any).
185 See flags.h for the definitions of the different possible
186 types of debugging information. */
187 enum debug_info_type write_symbols
= NO_DEBUG
;
189 /* Level of debugging information we are producing. See flags.h
190 for the definitions of the different possible levels. */
191 enum debug_info_level debug_info_level
= DINFO_LEVEL_NONE
;
193 /* Nonzero means use GNU-only extensions in the generated symbolic
194 debugging information. */
195 /* Currently, this only has an effect when write_symbols is set to
196 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
197 int use_gnu_debug_info_extensions
= 0;
199 /* Nonzero means do optimizations. -O.
200 Particular numeric values stand for particular amounts of optimization;
201 thus, -O2 stores 2 here. However, the optimizations beyond the basic
202 ones are not controlled directly by this variable. Instead, they are
203 controlled by individual `flag_...' variables that are defaulted
204 based on this variable. */
208 /* Number of error messages and warning messages so far. */
211 int warningcount
= 0;
214 /* Pointer to function to compute the name to use to print a declaration. */
216 char *(*decl_printable_name
) ();
218 /* Pointer to function to compute rtl for a language-specific tree code. */
220 struct rtx_def
*(*lang_expand_expr
) ();
222 /* Pointer to function to finish handling an incomplete decl at the
223 end of compilation. */
225 void (*incomplete_decl_finalize_hook
) () = 0;
227 /* Nonzero if generating code to do profiling. */
229 int profile_flag
= 0;
231 /* Nonzero if generating code to do profiling on a line-by-line basis. */
233 int profile_block_flag
;
235 /* Nonzero for -pedantic switch: warn about anything
236 that standard spec forbids. */
240 /* Temporarily suppress certain warnings.
241 This is set while reading code from a system header file. */
243 int in_system_header
= 0;
245 /* Nonzero means do stupid register allocation.
246 Currently, this is 1 if `optimize' is 0. */
248 int obey_regdecls
= 0;
250 /* Don't print functions as they are compiled and don't print
251 times taken by the various passes. -quiet. */
257 /* Nonzero means `char' should be signed. */
259 int flag_signed_char
;
261 /* Nonzero means give an enum type only as many bytes as it needs. */
263 int flag_short_enums
;
265 /* Nonzero for -fcaller-saves: allocate values in regs that need to
266 be saved across function calls, if that produces overall better code.
267 Optional now, so people can test it. */
269 #ifdef DEFAULT_CALLER_SAVES
270 int flag_caller_saves
= 1;
272 int flag_caller_saves
= 0;
275 /* Nonzero if structures and unions should be returned in memory.
277 This should only be defined if compatibility with another compiler or
278 with an ABI is needed, because it results in slower code. */
280 #ifndef DEFAULT_PCC_STRUCT_RETURN
281 #define DEFAULT_PCC_STRUCT_RETURN 1
284 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
286 int flag_pcc_struct_return
= DEFAULT_PCC_STRUCT_RETURN
;
288 /* Nonzero for -fforce-mem: load memory value into a register
289 before arithmetic on it. This makes better cse but slower compilation. */
291 int flag_force_mem
= 0;
293 /* Nonzero for -fforce-addr: load memory address into a register before
294 reference to memory. This makes better cse but slower compilation. */
296 int flag_force_addr
= 0;
298 /* Nonzero for -fdefer-pop: don't pop args after each function call;
299 instead save them up to pop many calls' args with one insns. */
301 int flag_defer_pop
= 1;
303 /* Nonzero for -ffloat-store: don't allocate floats and doubles
304 in extended-precision registers. */
306 int flag_float_store
= 0;
308 /* Nonzero for -fcse-follow-jumps:
309 have cse follow jumps to do a more extensive job. */
311 int flag_cse_follow_jumps
;
313 /* Nonzero for -fcse-skip-blocks:
314 have cse follow a branch around a block. */
315 int flag_cse_skip_blocks
;
317 /* Nonzero for -fexpensive-optimizations:
318 perform miscellaneous relatively-expensive optimizations. */
319 int flag_expensive_optimizations
;
321 /* Nonzero for -fthread-jumps:
322 have jump optimize output of loop. */
324 int flag_thread_jumps
;
326 /* Nonzero enables strength-reduction in loop.c. */
328 int flag_strength_reduce
= 0;
330 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
331 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
332 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
335 int flag_unroll_loops
;
337 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
338 This is generally not a win. */
340 int flag_unroll_all_loops
;
342 /* Nonzero for -fwritable-strings:
343 store string constants in data segment and don't uniquize them. */
345 int flag_writable_strings
= 0;
347 /* Nonzero means don't put addresses of constant functions in registers.
348 Used for compiling the Unix kernel, where strange substitutions are
349 done on the assembly output. */
351 int flag_no_function_cse
= 0;
353 /* Nonzero for -fomit-frame-pointer:
354 don't make a frame pointer in simple functions that don't require one. */
356 int flag_omit_frame_pointer
= 0;
358 /* Nonzero to inhibit use of define_optimization peephole opts. */
360 int flag_no_peephole
= 0;
362 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
363 operations in the interest of optimization. For example it allows
364 GCC to assume arguments to sqrt are nonnegative numbers, allowing
365 faster code for sqrt to be generated. */
367 int flag_fast_math
= 0;
369 /* Nonzero means all references through pointers are volatile. */
373 /* Nonzero means treat all global and extern variables as global. */
375 int flag_volatile_global
;
377 /* Nonzero means just do syntax checking; don't output anything. */
379 int flag_syntax_only
= 0;
381 /* Nonzero means to rerun cse after loop optimization. This increases
382 compilation time about 20% and picks up a few more common expressions. */
384 static int flag_rerun_cse_after_loop
;
386 /* Nonzero for -finline-functions: ok to inline functions that look like
387 good inline candidates. */
389 int flag_inline_functions
;
391 /* Nonzero for -fkeep-inline-functions: even if we make a function
392 go inline everywhere, keep its definition around for debugging
395 int flag_keep_inline_functions
;
397 /* Nonzero means that functions declared `inline' will be treated
398 as `static'. Prevents generation of zillions of copies of unused
399 static inline functions; instead, `inlines' are written out
400 only when actually used. Used in conjunction with -g. Also
401 does the right thing with #pragma interface. */
405 /* Nonzero means we should be saving declaration info into a .X file. */
407 int flag_gen_aux_info
= 0;
409 /* Specified name of aux-info file. */
411 static char *aux_info_file_name
;
413 /* Nonzero means make the text shared if supported. */
415 int flag_shared_data
;
417 /* Nonzero means schedule into delayed branch slots if supported. */
419 int flag_delayed_branch
;
421 /* Nonzero if we are compiling pure (sharable) code.
422 Value is 1 if we are doing reasonable (i.e. simple
423 offset into offset table) pic. Value is 2 if we can
424 only perform register offsets. */
428 /* Nonzero means place uninitialized global data in the bss section. */
432 /* Nonzero means pretend it is OK to examine bits of target floats,
433 even if that isn't true. The resulting code will have incorrect constants,
434 but the same series of instructions that the native compiler would make. */
436 int flag_pretend_float
;
438 /* Nonzero means change certain warnings into errors.
439 Usually these are warnings about failure to conform to some standard. */
441 int flag_pedantic_errors
= 0;
443 /* flag_schedule_insns means schedule insns within basic blocks (before
445 flag_schedule_insns_after_reload means schedule insns after
448 int flag_schedule_insns
= 0;
449 int flag_schedule_insns_after_reload
= 0;
451 /* -finhibit-size-directive inhibits output of .size for ELF.
452 This is used only for compiling crtstuff.c,
453 and it may be extended to other effects
454 needed for crtstuff.c on other systems. */
455 int flag_inhibit_size_directive
= 0;
457 /* -fverbose-asm causes extra commentary information to be produced in
458 the generated assembly code (to make it more readable). This option
459 is generally only of use to those who actually need to read the
460 generated assembly code (perhaps while debugging the compiler itself). */
462 int flag_verbose_asm
= 0;
464 /* -fgnu-linker specifies use of the GNU linker for initializations.
465 (Or, more generally, a linker that handles initializations.)
466 -fno-gnu-linker says that collect2 will be used. */
468 int flag_gnu_linker
= 0;
470 int flag_gnu_linker
= 1;
473 /* Table of language-independent -f options.
474 STRING is the option name. VARIABLE is the address of the variable.
475 ON_VALUE is the value to store in VARIABLE
476 if `-fSTRING' is seen as an option.
477 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
479 struct { char *string
; int *variable
; int on_value
;} f_options
[] =
481 {"float-store", &flag_float_store
, 1},
482 {"volatile", &flag_volatile
, 1},
483 {"volatile-global", &flag_volatile_global
, 1},
484 {"defer-pop", &flag_defer_pop
, 1},
485 {"omit-frame-pointer", &flag_omit_frame_pointer
, 1},
486 {"cse-follow-jumps", &flag_cse_follow_jumps
, 1},
487 {"cse-skip-blocks", &flag_cse_skip_blocks
, 1},
488 {"expensive-optimizations", &flag_expensive_optimizations
, 1},
489 {"thread-jumps", &flag_thread_jumps
, 1},
490 {"strength-reduce", &flag_strength_reduce
, 1},
491 {"unroll-loops", &flag_unroll_loops
, 1},
492 {"unroll-all-loops", &flag_unroll_all_loops
, 1},
493 {"writable-strings", &flag_writable_strings
, 1},
494 {"peephole", &flag_no_peephole
, 0},
495 {"force-mem", &flag_force_mem
, 1},
496 {"force-addr", &flag_force_addr
, 1},
497 {"function-cse", &flag_no_function_cse
, 0},
498 {"inline-functions", &flag_inline_functions
, 1},
499 {"keep-inline-functions", &flag_keep_inline_functions
, 1},
500 {"inline", &flag_no_inline
, 0},
501 {"syntax-only", &flag_syntax_only
, 1},
502 {"shared-data", &flag_shared_data
, 1},
503 {"caller-saves", &flag_caller_saves
, 1},
504 {"pcc-struct-return", &flag_pcc_struct_return
, 1},
505 {"reg-struct-return", &flag_pcc_struct_return
, 0},
506 {"delayed-branch", &flag_delayed_branch
, 1},
507 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop
, 1},
508 {"pretend-float", &flag_pretend_float
, 1},
509 {"schedule-insns", &flag_schedule_insns
, 1},
510 {"schedule-insns2", &flag_schedule_insns_after_reload
, 1},
511 {"pic", &flag_pic
, 1},
512 {"PIC", &flag_pic
, 2},
513 {"fast-math", &flag_fast_math
, 1},
514 {"common", &flag_no_common
, 0},
515 {"inhibit-size-directive", &flag_inhibit_size_directive
, 1},
516 {"verbose-asm", &flag_verbose_asm
, 1},
517 {"gnu-linker", &flag_gnu_linker
, 1}
520 /* Table of language-specific options. */
522 char *lang_options
[] =
531 "-fno-unsigned-char",
532 "-fsigned-bitfields",
533 "-funsigned-bitfields",
534 "-fno-signed-bitfields",
535 "-fno-unsigned-bitfields",
539 "-fno-cond-mismatch",
552 "-Wno-write-strings",
556 "-Wno-pointer-arith",
557 "-Wstrict-prototypes",
558 "-Wno-strict-prototypes",
559 "-Wmissing-prototypes",
560 "-Wno-missing-prototypes",
562 "-Wno-redundant-decls",
564 "-Wno-nested-externs",
570 "-Wno-char-subscripts",
584 "-Wno-missing-braces",
587 /* These are for C++. */
588 "-+e0", /* gcc.c tacks the `-' on the front. */
592 "-fno-save-memoized",
601 "-fthis-is-variable",
602 "-fno-this-is-variable",
603 "-fstrict-prototype",
604 "-fno-strict-prototype",
608 "-fno-memoize-lookups",
609 "-felide-constructors",
610 "-fno-elide-constructors",
613 "-fhandle-exceptions",
614 "-fno-handle-exceptions",
616 "-fno-ansi-exceptions",
617 "-fspring-exceptions",
618 "-fno-spring-exceptions",
620 "-fno-default-inline",
622 "-fno-enum-int-equiv",
628 "-fno-nonnull-objects",
629 "-fimplement-inlines",
630 "-fno-implement-inlines",
634 "-Woverloaded-virtual",
635 "-Wno-overloaded-virtual",
638 "-Wtemplate-debugging",
639 "-Wno-template-debugging",
641 /* these are for obj c */
655 /* Options controlling warnings */
657 /* Don't print warning messages. -w. */
659 int inhibit_warnings
= 0;
661 /* Print various extra warnings. -W. */
663 int extra_warnings
= 0;
665 /* Treat warnings as errors. -Werror. */
667 int warnings_are_errors
= 0;
669 /* Nonzero to warn about unused local variables. */
673 /* Nonzero to warn about variables used before they are initialized. */
675 int warn_uninitialized
;
677 /* Nonzero means warn about all declarations which shadow others. */
681 /* Warn if a switch on an enum fails to have a case for every enum value. */
685 /* Nonzero means warn about function definitions that default the return type
686 or that use a null return and have a return-type other than void. */
688 int warn_return_type
;
690 /* Nonzero means warn about pointer casts that increase the required
691 alignment of the target type (and might therefore lead to a crash
692 due to a misaligned access). */
696 /* Nonzero means warn about any identifiers that match in the first N
697 characters. The value N is in `id_clash_len'. */
702 /* Nonzero means warn if inline function is too large. */
706 /* Warn if a function returns an aggregate,
707 since there are often incompatible calling conventions for doing this. */
709 int warn_aggregate_return
;
711 /* Likewise for -W. */
713 struct { char *string
; int *variable
; int on_value
;} W_options
[] =
715 {"unused", &warn_unused
, 1},
716 {"error", &warnings_are_errors
, 1},
717 {"shadow", &warn_shadow
, 1},
718 {"switch", &warn_switch
, 1},
719 {"aggregate-return", &warn_aggregate_return
, 1},
720 {"cast-align", &warn_cast_align
, 1},
721 {"uninitialized", &warn_uninitialized
, 1},
722 {"inline", &warn_inline
, 1}
725 /* Output files for assembler code (real compiler output)
726 and debugging dumps. */
731 FILE *jump_opt_dump_file
;
733 FILE *loop_dump_file
;
734 FILE *cse2_dump_file
;
735 FILE *flow_dump_file
;
736 FILE *combine_dump_file
;
737 FILE *sched_dump_file
;
738 FILE *local_reg_dump_file
;
739 FILE *global_reg_dump_file
;
740 FILE *sched2_dump_file
;
741 FILE *jump2_opt_dump_file
;
742 FILE *dbr_sched_dump_file
;
743 FILE *stack_reg_dump_file
;
745 /* Time accumulators, to count the total time spent in various passes. */
749 int integration_time
;
757 int local_alloc_time
;
758 int global_alloc_time
;
761 int shorten_branch_time
;
767 /* Return time used so far, in microseconds. */
776 struct rusage rusage
;
781 int proc_system_time
;
783 int child_system_time
;
793 return (tms
.tms_utime
+ tms
.tms_stime
) * (1000000 / HZ
);
796 getrusage (0, &rusage
);
797 return (rusage
.ru_utime
.tv_sec
* 1000000 + rusage
.ru_utime
.tv_usec
798 + rusage
.ru_stime
.tv_sec
* 1000000 + rusage
.ru_stime
.tv_usec
);
801 return (vms_times
.proc_user_time
+ vms_times
.proc_system_time
) * 10000;
806 #define TIMEVAR(VAR, BODY) \
807 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
810 print_time (str
, total
)
815 "time in %s: %d.%06d\n",
816 str
, total
/ 1000000, total
% 1000000);
819 /* Count an error or warning. Return 1 if the message should be printed. */
822 count_error (warningp
)
825 if (warningp
&& inhibit_warnings
)
828 if (warningp
&& !warnings_are_errors
)
832 static int warning_message
= 0;
834 if (warningp
&& !warning_message
)
836 fprintf (stderr
, "%s: warnings being treated as errors\n", progname
);
845 /* Print a fatal error message. NAME is the text.
846 Also include a system error message based on `errno'. */
849 pfatal_with_name (name
)
852 fprintf (stderr
, "%s: ", progname
);
858 fatal_io_error (name
)
861 fprintf (stderr
, "%s: %s: I/O error\n", progname
, name
);
874 /* Called to give a better error message when we don't have an insn to match
875 what we are looking for or if the insn's constraints aren't satisfied,
876 rather than just calling abort(). */
879 fatal_insn_not_found (insn
)
882 if (INSN_CODE (insn
) < 0)
883 error ("internal error--unrecognizable insn:", 0);
885 error ("internal error--insn does not satisfy its constraints:", 0);
888 fflush (asm_out_file
);
890 fflush (aux_info_file
);
892 fflush (rtl_dump_file
);
893 if (jump_opt_dump_file
)
894 fflush (jump_opt_dump_file
);
896 fflush (cse_dump_file
);
898 fflush (loop_dump_file
);
900 fflush (cse2_dump_file
);
902 fflush (flow_dump_file
);
903 if (combine_dump_file
)
904 fflush (combine_dump_file
);
906 fflush (sched_dump_file
);
907 if (local_reg_dump_file
)
908 fflush (local_reg_dump_file
);
909 if (global_reg_dump_file
)
910 fflush (global_reg_dump_file
);
911 if (sched2_dump_file
)
912 fflush (sched2_dump_file
);
913 if (jump2_opt_dump_file
)
914 fflush (jump2_opt_dump_file
);
915 if (dbr_sched_dump_file
)
916 fflush (dbr_sched_dump_file
);
917 if (stack_reg_dump_file
)
918 fflush (stack_reg_dump_file
);
922 /* This is the default decl_printable_name function. */
925 decl_name (decl
, kind
)
929 return IDENTIFIER_POINTER (DECL_NAME (decl
));
932 static int need_error_newline
;
934 /* Function of last error message;
935 more generally, function such that if next error message is in it
936 then we don't have to mention the function name. */
937 static tree last_error_function
= NULL
;
939 /* Used to detect when input_file_stack has changed since last described. */
940 static int last_error_tick
;
942 /* Called when the start of a function definition is parsed,
943 this function prints on stderr the name of the function. */
946 announce_function (decl
)
952 if (rtl_dump_and_exit
)
953 fprintf (stderr
, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl
)));
955 fprintf (stderr
, " %s", (*decl_printable_name
) (decl
, &junk
));
957 need_error_newline
= 1;
958 last_error_function
= current_function_decl
;
962 /* Prints out, if necessary, the name of the current function
963 which caused an error. Called from all error and warning functions. */
966 report_error_function (file
)
969 struct file_stack
*p
;
971 if (need_error_newline
)
973 fprintf (stderr
, "\n");
974 need_error_newline
= 0;
977 if (last_error_function
!= current_function_decl
)
979 char *kind
= "function";
980 if (current_function_decl
!= 0
981 && TREE_CODE (TREE_TYPE (current_function_decl
)) == METHOD_TYPE
)
985 fprintf (stderr
, "%s: ", file
);
987 if (current_function_decl
== NULL
)
988 fprintf (stderr
, "At top level:\n");
991 char *name
= (*decl_printable_name
) (current_function_decl
, &kind
);
992 fprintf (stderr
, "In %s `%s':\n", kind
, name
);
995 last_error_function
= current_function_decl
;
997 if (input_file_stack
&& input_file_stack
->next
!= 0
998 && input_file_stack_tick
!= last_error_tick
)
1000 fprintf (stderr
, "In file included");
1001 for (p
= input_file_stack
->next
; p
; p
= p
->next
)
1003 fprintf (stderr
, " from %s:%d", p
->name
, p
->line
);
1005 fprintf (stderr
, ",");
1007 fprintf (stderr
, ":\n");
1008 last_error_tick
= input_file_stack_tick
;
1012 /* Report an error at the current line number.
1013 S is a string and V and V2 are args for `printf'. We use HOST_WIDE_INT
1014 as the type for these args assuming it is wide enough to hold a
1015 pointer. This isn't terribly portable, but is the best we can do
1016 without vprintf universally available. */
1021 HOST_WIDE_INT v
; /* Also used as pointer */
1022 HOST_WIDE_INT v2
; /* Also used as pointer */
1024 error_with_file_and_line (input_filename
, lineno
, s
, v
, v2
);
1027 /* Report an error at line LINE of file FILE.
1028 S and V are a string and an arg for `printf'. */
1031 error_with_file_and_line (file
, line
, s
, v
, v2
)
1040 report_error_function (file
);
1043 fprintf (stderr
, "%s:%d: ", file
, line
);
1045 fprintf (stderr
, "%s: ", progname
);
1046 fprintf (stderr
, s
, v
, v2
);
1047 fprintf (stderr
, "\n");
1050 /* Report an error at the declaration DECL.
1051 S and V are a string and an arg which uses %s to substitute
1052 the declaration name. */
1055 error_with_decl (decl
, s
, v
)
1063 report_error_function (DECL_SOURCE_FILE (decl
));
1065 fprintf (stderr
, "%s:%d: ",
1066 DECL_SOURCE_FILE (decl
), DECL_SOURCE_LINE (decl
));
1068 if (DECL_NAME (decl
))
1069 fprintf (stderr
, s
, (*decl_printable_name
) (decl
, &junk
), v
);
1071 fprintf (stderr
, s
, "((anonymous))", v
);
1072 fprintf (stderr
, "\n");
1075 /* Report an error at the line number of the insn INSN.
1076 S and V are a string and an arg for `printf'.
1077 This is used only when INSN is an `asm' with operands,
1078 and each ASM_OPERANDS records its own source file and line. */
1081 error_for_asm (insn
, s
, v
, v2
)
1084 HOST_WIDE_INT v
; /* Also used as pointer */
1085 HOST_WIDE_INT v2
; /* Also used as pointer */
1089 rtx body
= PATTERN (insn
);
1092 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1093 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
1094 asmop
= SET_SRC (body
);
1095 else if (GET_CODE (body
) == ASM_OPERANDS
)
1097 else if (GET_CODE (body
) == PARALLEL
1098 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
)
1099 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
1100 else if (GET_CODE (body
) == PARALLEL
1101 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
1102 asmop
= XVECEXP (body
, 0, 0);
1104 filename
= ASM_OPERANDS_SOURCE_FILE (asmop
);
1105 line
= ASM_OPERANDS_SOURCE_LINE (asmop
);
1107 error_with_file_and_line (filename
, line
, s
, v
, v2
);
1110 /* Report a warning at line LINE.
1111 S and V are a string and an arg for `printf'. */
1114 warning_with_file_and_line (file
, line
, s
, v
, v2
, v3
)
1118 HOST_WIDE_INT v
, v2
, v3
;
1120 if (count_error (1) == 0)
1123 report_error_function (file
);
1126 fprintf (stderr
, "%s:%d: ", file
, line
);
1128 fprintf (stderr
, "%s: ", progname
);
1130 fprintf (stderr
, "warning: ");
1131 fprintf (stderr
, s
, v
, v2
, v3
);
1132 fprintf (stderr
, "\n");
1135 /* Report a warning at the current line number.
1136 S and V are a string and an arg for `printf'. */
1139 warning (s
, v
, v2
, v3
)
1141 HOST_WIDE_INT v
, v2
, v3
; /* Also used as pointer */
1143 warning_with_file_and_line (input_filename
, lineno
, s
, v
, v2
, v3
);
1146 /* Report a warning at the declaration DECL.
1147 S is string which uses %s to substitute the declaration name.
1148 V is a second parameter that S can refer to. */
1151 warning_with_decl (decl
, s
, v
)
1158 if (count_error (1) == 0)
1161 report_error_function (DECL_SOURCE_FILE (decl
));
1163 fprintf (stderr
, "%s:%d: ",
1164 DECL_SOURCE_FILE (decl
), DECL_SOURCE_LINE (decl
));
1166 fprintf (stderr
, "warning: ");
1167 if (DECL_NAME (decl
))
1168 fprintf (stderr
, s
, (*decl_printable_name
) (decl
, &junk
), v
);
1170 fprintf (stderr
, s
, "((anonymous))", v
);
1171 fprintf (stderr
, "\n");
1174 /* Report a warning at the line number of the insn INSN.
1175 S and V are a string and an arg for `printf'.
1176 This is used only when INSN is an `asm' with operands,
1177 and each ASM_OPERANDS records its own source file and line. */
1180 warning_for_asm (insn
, s
, v
, v2
)
1183 HOST_WIDE_INT v
; /* Also used as pointer */
1184 HOST_WIDE_INT v2
; /* Also used as pointer */
1188 rtx body
= PATTERN (insn
);
1191 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1192 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
1193 asmop
= SET_SRC (body
);
1194 else if (GET_CODE (body
) == ASM_OPERANDS
)
1196 else if (GET_CODE (body
) == PARALLEL
1197 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
)
1198 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
1199 else if (GET_CODE (body
) == PARALLEL
1200 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
1201 asmop
= XVECEXP (body
, 0, 0);
1203 filename
= ASM_OPERANDS_SOURCE_FILE (asmop
);
1204 line
= ASM_OPERANDS_SOURCE_LINE (asmop
);
1206 warning_with_file_and_line (filename
, line
, s
, v
, v2
);
1209 /* These functions issue either warnings or errors depending on
1210 -pedantic-errors. */
1215 HOST_WIDE_INT v
; /* Also used as pointer */
1218 if (flag_pedantic_errors
)
1225 pedwarn_with_decl (decl
, s
, v
)
1230 if (flag_pedantic_errors
)
1231 error_with_decl (decl
, s
, v
);
1233 warning_with_decl (decl
, s
, v
);
1237 pedwarn_with_file_and_line (file
, line
, s
, v
, v2
)
1244 if (flag_pedantic_errors
)
1245 error_with_file_and_line (file
, line
, s
, v
, v2
);
1247 warning_with_file_and_line (file
, line
, s
, v
, v2
);
1250 /* Apologize for not implementing some feature.
1251 S, V, and V2 are a string and args for `printf'. */
1256 HOST_WIDE_INT v
, v2
;
1260 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
1262 fprintf (stderr
, "%s: ", progname
);
1264 fprintf (stderr
, "sorry, not implemented: ");
1265 fprintf (stderr
, s
, v
, v2
);
1266 fprintf (stderr
, "\n");
1269 /* Apologize for not implementing some feature, then quit.
1270 S, V, and V2 are a string and args for `printf'. */
1273 really_sorry (s
, v
, v2
)
1275 HOST_WIDE_INT v
, v2
;
1278 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
1280 fprintf (stderr
, "%s: ", progname
);
1282 fprintf (stderr
, "sorry, not implemented: ");
1283 fprintf (stderr
, s
, v
, v2
);
1284 fatal (" (fatal)\n");
1287 /* More 'friendly' abort that prints the line and file.
1288 config.h can #define abort fancy_abort if you like that sort of thing.
1290 I don't think this is actually a good idea.
1291 Other sorts of crashes will look a certain way.
1292 It is a good thing if crashes from calling abort look the same way.
1298 fatal ("internal gcc abort");
1301 /* This calls abort and is used to avoid problems when abort if a macro.
1302 It is used when we need to pass the address of abort. */
1310 /* When `malloc.c' is compiled with `rcheck' defined,
1311 it calls this function to report clobberage. */
1319 /* Same as `malloc' but report error if no memory available. */
1325 register char *value
= (char *) malloc (size
);
1327 fatal ("virtual memory exhausted");
1331 /* Same as `realloc' but report error if no memory available. */
1334 xrealloc (ptr
, size
)
1338 char *result
= (char *) realloc (ptr
, size
);
1340 fatal ("virtual memory exhausted");
1344 /* Return the logarithm of X, base 2, considering X unsigned,
1345 if X is a power of 2. Otherwise, returns -1.
1347 This should be used via the `exact_log2' macro. */
1351 register unsigned HOST_WIDE_INT x
;
1353 register int log
= 0;
1354 /* Test for 0 or a power of 2. */
1355 if (x
== 0 || x
!= (x
& -x
))
1357 while ((x
>>= 1) != 0)
1362 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1363 If X is 0, return -1.
1365 This should be used via the floor_log2 macro. */
1369 register unsigned HOST_WIDE_INT x
;
1371 register int log
= -1;
1379 jmp_buf float_handler
;
1381 /* Specify where to longjmp to when a floating arithmetic error happens.
1382 If HANDLER is 0, it means don't handle the errors any more. */
1385 set_float_handler (handler
)
1388 float_handled
= (handler
!= 0);
1390 bcopy (handler
, float_handler
, sizeof (float_handler
));
1393 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1394 error happens, pushing the previous specification into OLD_HANDLER.
1395 Return an indication of whether there was a previous handler in effect. */
1398 push_float_handler (handler
, old_handler
)
1399 jmp_buf handler
, old_handler
;
1401 int was_handled
= float_handled
;
1405 bcopy (float_handler
, old_handler
, sizeof (float_handler
));
1406 bcopy (handler
, float_handler
, sizeof (float_handler
));
1410 /* Restore the previous specification of whether and where to longjmp to
1411 when a floating arithmetic error happens. */
1414 pop_float_handler (handled
, handler
)
1418 float_handled
= handled
;
1420 bcopy (handler
, float_handler
, sizeof (float_handler
));
1423 /* Signals actually come here. */
1426 float_signal (signo
)
1427 /* If this is missing, some compilers complain. */
1430 if (float_handled
== 0)
1432 #if defined (USG) || defined (hpux)
1433 signal (SIGFPE
, float_signal
); /* re-enable the signal catcher */
1436 signal (SIGFPE
, float_signal
);
1437 longjmp (float_handler
, 1);
1440 /* Handler for SIGPIPE. */
1444 /* If this is missing, some compilers complain. */
1447 fatal ("output pipe has been closed");
1450 /* Strip off a legitimate source ending from the input string NAME of
1454 strip_off_ending (name
, len
)
1458 if (len
> 2 && ! strcmp (".c", name
+ len
- 2))
1460 else if (len
> 2 && ! strcmp (".m", name
+ len
- 2))
1462 else if (len
> 2 && ! strcmp (".i", name
+ len
- 2))
1464 else if (len
> 3 && ! strcmp (".ii", name
+ len
- 3))
1466 else if (len
> 3 && ! strcmp (".co", name
+ len
- 3))
1468 else if (len
> 3 && ! strcmp (".cc", name
+ len
- 3))
1470 else if (len
> 2 && ! strcmp (".C", name
+ len
- 2))
1472 else if (len
> 4 && ! strcmp (".cxx", name
+ len
- 4))
1474 else if (len
> 2 && ! strcmp (".f", name
+ len
- 2))
1476 else if (len
> 4 && ! strcmp (".ada", name
+ len
- 4))
1478 else if (len
> 4 && ! strcmp (".atr", name
+ len
- 4))
1482 /* Output a file name in the form wanted by System V. */
1485 output_file_directive (asm_file
, input_name
)
1489 int len
= strlen (input_name
);
1490 char *na
= input_name
+ len
;
1492 /* NA gets INPUT_NAME sans directory names. */
1493 while (na
> input_name
)
1500 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1501 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file
, na
);
1503 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1504 ASM_OUTPUT_SOURCE_FILENAME (asm_file
, na
);
1506 fprintf (asm_file
, "\t.file\t\"%s\"\n", na
);
1511 /* Routine to build language identifier for object file. */
1513 output_lang_identify (asm_out_file
)
1516 int len
= strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1517 char *s
= (char *) alloca (len
);
1518 sprintf (s
, "__gnu_compiled_%s", lang_identify ());
1519 ASM_OUTPUT_LABEL (asm_out_file
, s
);
1522 /* Compile an entire file of output from cpp, named NAME.
1523 Write a file of assembly output and various debugging dumps. */
1531 int dump_base_name_length
;
1533 int name_specified
= name
!= 0;
1535 if (dump_base_name
== 0)
1536 dump_base_name
= name
? name
: "gccdump";
1537 dump_base_name_length
= strlen (dump_base_name
);
1541 integration_time
= 0;
1549 local_alloc_time
= 0;
1550 global_alloc_time
= 0;
1553 shorten_branch_time
= 0;
1559 /* Open input file. */
1561 if (name
== 0 || !strcmp (name
, "-"))
1567 finput
= fopen (name
, "r");
1569 pfatal_with_name (name
);
1571 #ifdef IO_BUFFER_SIZE
1572 setvbuf (finput
, (char *) xmalloc (IO_BUFFER_SIZE
), _IOFBF
, IO_BUFFER_SIZE
);
1575 /* Initialize data in various passes. */
1581 init_emit_once (debug_info_level
== DINFO_LEVEL_NORMAL
1582 || debug_info_level
== DINFO_LEVEL_VERBOSE
);
1583 init_decl_processing ();
1591 if (flag_caller_saves
)
1592 init_caller_save ();
1594 /* If auxiliary info generation is desired, open the output file.
1595 This goes in the same directory as the source file--unlike
1596 all the other output files. */
1597 if (flag_gen_aux_info
)
1599 aux_info_file
= fopen (aux_info_file_name
, "w");
1600 if (aux_info_file
== 0)
1601 pfatal_with_name (aux_info_file_name
);
1604 /* If rtl dump desired, open the output file. */
1607 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1608 strcpy (dumpname
, dump_base_name
);
1609 strcat (dumpname
, ".rtl");
1610 rtl_dump_file
= fopen (dumpname
, "w");
1611 if (rtl_dump_file
== 0)
1612 pfatal_with_name (dumpname
);
1615 /* If jump_opt dump desired, open the output file. */
1618 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1619 strcpy (dumpname
, dump_base_name
);
1620 strcat (dumpname
, ".jump");
1621 jump_opt_dump_file
= fopen (dumpname
, "w");
1622 if (jump_opt_dump_file
== 0)
1623 pfatal_with_name (dumpname
);
1626 /* If cse dump desired, open the output file. */
1629 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1630 strcpy (dumpname
, dump_base_name
);
1631 strcat (dumpname
, ".cse");
1632 cse_dump_file
= fopen (dumpname
, "w");
1633 if (cse_dump_file
== 0)
1634 pfatal_with_name (dumpname
);
1637 /* If loop dump desired, open the output file. */
1640 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1641 strcpy (dumpname
, dump_base_name
);
1642 strcat (dumpname
, ".loop");
1643 loop_dump_file
= fopen (dumpname
, "w");
1644 if (loop_dump_file
== 0)
1645 pfatal_with_name (dumpname
);
1648 /* If cse2 dump desired, open the output file. */
1651 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1652 strcpy (dumpname
, dump_base_name
);
1653 strcat (dumpname
, ".cse2");
1654 cse2_dump_file
= fopen (dumpname
, "w");
1655 if (cse2_dump_file
== 0)
1656 pfatal_with_name (dumpname
);
1659 /* If flow dump desired, open the output file. */
1662 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1663 strcpy (dumpname
, dump_base_name
);
1664 strcat (dumpname
, ".flow");
1665 flow_dump_file
= fopen (dumpname
, "w");
1666 if (flow_dump_file
== 0)
1667 pfatal_with_name (dumpname
);
1670 /* If combine dump desired, open the output file. */
1673 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 10);
1674 strcpy (dumpname
, dump_base_name
);
1675 strcat (dumpname
, ".combine");
1676 combine_dump_file
= fopen (dumpname
, "w");
1677 if (combine_dump_file
== 0)
1678 pfatal_with_name (dumpname
);
1681 /* If scheduling dump desired, open the output file. */
1684 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 7);
1685 strcpy (dumpname
, dump_base_name
);
1686 strcat (dumpname
, ".sched");
1687 sched_dump_file
= fopen (dumpname
, "w");
1688 if (sched_dump_file
== 0)
1689 pfatal_with_name (dumpname
);
1692 /* If local_reg dump desired, open the output file. */
1695 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1696 strcpy (dumpname
, dump_base_name
);
1697 strcat (dumpname
, ".lreg");
1698 local_reg_dump_file
= fopen (dumpname
, "w");
1699 if (local_reg_dump_file
== 0)
1700 pfatal_with_name (dumpname
);
1703 /* If global_reg dump desired, open the output file. */
1704 if (global_reg_dump
)
1706 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1707 strcpy (dumpname
, dump_base_name
);
1708 strcat (dumpname
, ".greg");
1709 global_reg_dump_file
= fopen (dumpname
, "w");
1710 if (global_reg_dump_file
== 0)
1711 pfatal_with_name (dumpname
);
1714 /* If 2nd scheduling dump desired, open the output file. */
1717 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 8);
1718 strcpy (dumpname
, dump_base_name
);
1719 strcat (dumpname
, ".sched2");
1720 sched2_dump_file
= fopen (dumpname
, "w");
1721 if (sched2_dump_file
== 0)
1722 pfatal_with_name (dumpname
);
1725 /* If jump2_opt dump desired, open the output file. */
1728 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 7);
1729 strcpy (dumpname
, dump_base_name
);
1730 strcat (dumpname
, ".jump2");
1731 jump2_opt_dump_file
= fopen (dumpname
, "w");
1732 if (jump2_opt_dump_file
== 0)
1733 pfatal_with_name (dumpname
);
1736 /* If dbr_sched dump desired, open the output file. */
1739 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 7);
1740 strcpy (dumpname
, dump_base_name
);
1741 strcat (dumpname
, ".dbr");
1742 dbr_sched_dump_file
= fopen (dumpname
, "w");
1743 if (dbr_sched_dump_file
== 0)
1744 pfatal_with_name (dumpname
);
1749 /* If stack_reg dump desired, open the output file. */
1752 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 10);
1753 strcpy (dumpname
, dump_base_name
);
1754 strcat (dumpname
, ".stack");
1755 stack_reg_dump_file
= fopen (dumpname
, "w");
1756 if (stack_reg_dump_file
== 0)
1757 pfatal_with_name (dumpname
);
1762 /* Open assembler code output file. */
1764 if (! name_specified
&& asm_file_name
== 0)
1765 asm_out_file
= stdout
;
1768 register char *dumpname
= (char *) xmalloc (dump_base_name_length
+ 6);
1769 int len
= strlen (dump_base_name
);
1770 strcpy (dumpname
, dump_base_name
);
1771 strip_off_ending (dumpname
, len
);
1772 strcat (dumpname
, ".s");
1773 if (asm_file_name
== 0)
1775 asm_file_name
= (char *) xmalloc (strlen (dumpname
) + 1);
1776 strcpy (asm_file_name
, dumpname
);
1778 if (!strcmp (asm_file_name
, "-"))
1779 asm_out_file
= stdout
;
1781 asm_out_file
= fopen (asm_file_name
, "w");
1782 if (asm_out_file
== 0)
1783 pfatal_with_name (asm_file_name
);
1786 #ifdef IO_BUFFER_SIZE
1787 setvbuf (asm_out_file
, (char *) xmalloc (IO_BUFFER_SIZE
),
1788 _IOFBF
, IO_BUFFER_SIZE
);
1791 input_filename
= name
;
1793 /* Perform language-specific initialization.
1794 This may set main_input_filename. */
1797 /* If the input doesn't start with a #line, use the input name
1798 as the official input file name. */
1799 if (main_input_filename
== 0)
1800 main_input_filename
= name
;
1802 /* Put an entry on the input file stack for the main input file. */
1804 = (struct file_stack
*) xmalloc (sizeof (struct file_stack
));
1805 input_file_stack
->next
= 0;
1806 input_file_stack
->name
= input_filename
;
1808 ASM_FILE_START (asm_out_file
);
1810 /* Output something to inform GDB that this compilation was by GCC. */
1811 #ifndef ASM_IDENTIFY_GCC
1812 fprintf (asm_out_file
, "gcc2_compiled.:\n");
1814 ASM_IDENTIFY_GCC (asm_out_file
);
1817 /* Output something to identify which front-end produced this file. */
1818 #ifdef ASM_IDENTIFY_LANGUAGE
1819 ASM_IDENTIFY_LANGUAGE (asm_out_file
);
1822 /* Don't let the first function fall at the same address
1823 as gcc_compiled., if profiling. */
1824 if (profile_flag
|| profile_block_flag
)
1825 assemble_zeros (UNITS_PER_WORD
);
1827 /* If dbx symbol table desired, initialize writing it
1828 and output the predefined types. */
1829 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1830 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
1831 TIMEVAR (symout_time
, dbxout_init (asm_out_file
, main_input_filename
,
1834 #ifdef SDB_DEBUGGING_INFO
1835 if (write_symbols
== SDB_DEBUG
)
1836 TIMEVAR (symout_time
, sdbout_init (asm_out_file
, main_input_filename
,
1839 #ifdef DWARF_DEBUGGING_INFO
1840 if (write_symbols
== DWARF_DEBUG
)
1841 TIMEVAR (symout_time
, dwarfout_init (asm_out_file
, main_input_filename
));
1844 /* Initialize yet another pass. */
1846 init_final (main_input_filename
);
1848 start_time
= get_run_time ();
1850 /* Call the parser, which parses the entire file
1851 (calling rest_of_compilation for each function). */
1853 if (yyparse () != 0)
1854 if (errorcount
== 0)
1855 fprintf (stderr
, "Errors detected in input file (your bison.simple is out of date)");
1857 /* Compilation is now finished except for writing
1858 what's left of the symbol table output. */
1860 parse_time
+= get_run_time () - start_time
;
1862 parse_time
-= integration_time
;
1863 parse_time
-= varconst_time
;
1865 globals
= getdecls ();
1867 /* Really define vars that have had only a tentative definition.
1868 Really output inline functions that must actually be callable
1869 and have not been output so far. */
1872 int len
= list_length (globals
);
1873 tree
*vec
= (tree
*) alloca (sizeof (tree
) * len
);
1877 /* Process the decls in reverse order--earliest first.
1878 Put them into VEC from back to front, then take out from front. */
1880 for (i
= 0, decl
= globals
; i
< len
; i
++, decl
= TREE_CHAIN (decl
))
1881 vec
[len
- i
- 1] = decl
;
1883 for (i
= 0; i
< len
; i
++)
1886 if (TREE_CODE (decl
) == VAR_DECL
&& DECL_SIZE (decl
) == 0
1887 && incomplete_decl_finalize_hook
!= 0)
1888 (*incomplete_decl_finalize_hook
) (decl
);
1890 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
1891 && ! TREE_ASM_WRITTEN (decl
))
1893 /* Don't write out static consts, unless we used them.
1894 (This used to write them out only if the address was
1895 taken, but that was wrong; if the variable was simply
1896 referred to, it still needs to exist or else it will
1897 be undefined in the linker.) */
1898 if (! TREE_READONLY (decl
)
1899 || TREE_PUBLIC (decl
)
1901 || TREE_ADDRESSABLE (decl
)
1902 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl
)))
1903 rest_of_decl_compilation (decl
, NULL_PTR
, 1, 1);
1905 /* Cancel the RTL for this decl so that, if debugging info
1906 output for global variables is still to come,
1907 this one will be omitted. */
1908 DECL_RTL (decl
) = NULL
;
1911 if (TREE_CODE (decl
) == FUNCTION_DECL
1912 && ! TREE_ASM_WRITTEN (decl
)
1913 && DECL_INITIAL (decl
) != 0
1914 && (TREE_ADDRESSABLE (decl
)
1915 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl
)))
1916 && ! DECL_EXTERNAL (decl
))
1917 output_inline_function (decl
);
1919 /* Warn about any function
1920 declared static but not defined.
1921 We don't warn about variables,
1922 because many programs have static variables
1923 that exist only to get some text into the object file. */
1926 || (DECL_NAME (decl
) && TREE_USED (DECL_NAME (decl
))))
1927 && TREE_CODE (decl
) == FUNCTION_DECL
1928 && DECL_INITIAL (decl
) == 0
1929 && DECL_EXTERNAL (decl
)
1930 && ! TREE_PUBLIC (decl
))
1932 pedwarn_with_decl (decl
,
1933 "`%s' declared `static' but never defined");
1934 /* This symbol is effectively an "extern" declaration now. */
1935 TREE_PUBLIC (decl
) = 1;
1936 assemble_external (decl
);
1939 /* Warn about static fns or vars defined but not used,
1940 but not about inline functions
1941 since unused inline statics is normal practice. */
1943 && (TREE_CODE (decl
) == FUNCTION_DECL
1944 || TREE_CODE (decl
) == VAR_DECL
)
1945 && ! DECL_IN_SYSTEM_HEADER (decl
)
1946 && ! DECL_EXTERNAL (decl
)
1947 && ! TREE_PUBLIC (decl
)
1948 && ! TREE_USED (decl
)
1949 && ! DECL_INLINE (decl
)
1950 && ! DECL_REGISTER (decl
)
1951 /* The TREE_USED bit for file-scope decls
1952 is kept in the identifier, to handle multiple
1953 external decls in different scopes. */
1954 && ! TREE_USED (DECL_NAME (decl
)))
1955 warning_with_decl (decl
, "`%s' defined but not used");
1957 #ifdef SDB_DEBUGGING_INFO
1958 /* The COFF linker can move initialized global vars to the end.
1959 And that can screw up the symbol ordering.
1960 By putting the symbols in that order to begin with,
1961 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1962 if (write_symbols
== SDB_DEBUG
&& TREE_CODE (decl
) == VAR_DECL
1963 && TREE_PUBLIC (decl
) && DECL_INITIAL (decl
)
1964 && DECL_RTL (decl
) != 0)
1965 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
1967 /* Output COFF information for non-global
1968 file-scope initialized variables. */
1969 if (write_symbols
== SDB_DEBUG
1970 && TREE_CODE (decl
) == VAR_DECL
1971 && DECL_INITIAL (decl
)
1972 && DECL_RTL (decl
) != 0
1973 && GET_CODE (DECL_RTL (decl
)) == MEM
)
1974 TIMEVAR (symout_time
, sdbout_toplevel_data (decl
));
1975 #endif /* SDB_DEBUGGING_INFO */
1976 #ifdef DWARF_DEBUGGING_INFO
1977 /* Output DWARF information for file-scope tentative data object
1978 declarations, file-scope (extern) function declarations (which
1979 had no corresponding body) and file-scope tagged type declarations
1980 and definitions which have not yet been forced out. */
1982 if (write_symbols
== DWARF_DEBUG
1983 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
1984 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 1));
1989 /* Do dbx symbols */
1990 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1991 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
1992 TIMEVAR (symout_time
,
1994 dbxout_finish (asm_out_file
, main_input_filename
);
1998 #ifdef DWARF_DEBUGGING_INFO
1999 if (write_symbols
== DWARF_DEBUG
)
2000 TIMEVAR (symout_time
,
2006 /* Output some stuff at end of file if nec. */
2008 end_final (main_input_filename
);
2011 ASM_FILE_END (asm_out_file
);
2014 after_finish_compilation
:
2016 /* Language-specific end of compilation actions. */
2020 /* Close the dump files. */
2022 if (flag_gen_aux_info
)
2024 fclose (aux_info_file
);
2026 unlink (aux_info_file_name
);
2030 fclose (rtl_dump_file
);
2033 fclose (jump_opt_dump_file
);
2036 fclose (cse_dump_file
);
2039 fclose (loop_dump_file
);
2042 fclose (cse2_dump_file
);
2045 fclose (flow_dump_file
);
2049 dump_combine_total_stats (combine_dump_file
);
2050 fclose (combine_dump_file
);
2054 fclose (sched_dump_file
);
2057 fclose (local_reg_dump_file
);
2059 if (global_reg_dump
)
2060 fclose (global_reg_dump_file
);
2063 fclose (sched2_dump_file
);
2066 fclose (jump2_opt_dump_file
);
2069 fclose (dbr_sched_dump_file
);
2073 fclose (stack_reg_dump_file
);
2076 /* Close non-debugging input and output files. Take special care to note
2077 whether fclose returns an error, since the pages might still be on the
2078 buffer chain while the file is open. */
2081 if (ferror (asm_out_file
) != 0 || fclose (asm_out_file
) != 0)
2082 fatal_io_error (asm_file_name
);
2084 /* Print the times. */
2088 fprintf (stderr
,"\n");
2089 print_time ("parse", parse_time
);
2090 print_time ("integration", integration_time
);
2091 print_time ("jump", jump_time
);
2092 print_time ("cse", cse_time
);
2093 print_time ("loop", loop_time
);
2094 print_time ("cse2", cse2_time
);
2095 print_time ("flow", flow_time
);
2096 print_time ("combine", combine_time
);
2097 print_time ("sched", sched_time
);
2098 print_time ("local-alloc", local_alloc_time
);
2099 print_time ("global-alloc", global_alloc_time
);
2100 print_time ("sched2", sched2_time
);
2101 print_time ("dbranch", dbr_sched_time
);
2102 print_time ("shorten-branch", shorten_branch_time
);
2103 print_time ("stack-reg", stack_reg_time
);
2104 print_time ("final", final_time
);
2105 print_time ("varconst", varconst_time
);
2106 print_time ("symout", symout_time
);
2107 print_time ("dump", dump_time
);
2111 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2112 and TYPE_DECL nodes.
2114 This does nothing for local (non-static) variables.
2115 Otherwise, it sets up the RTL and outputs any assembler code
2116 (label definition, storage allocation and initialization).
2118 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2119 the assembler symbol name to be used. TOP_LEVEL is nonzero
2120 if this declaration is not within a function. */
2123 rest_of_decl_compilation (decl
, asmspec
, top_level
, at_end
)
2129 /* Declarations of variables, and of functions defined elsewhere. */
2131 /* Forward declarations for nested functions are not "external",
2132 but we need to treat them as if they were. */
2133 if (TREE_STATIC (decl
) || DECL_EXTERNAL (decl
)
2134 || TREE_CODE (decl
) == FUNCTION_DECL
)
2135 TIMEVAR (varconst_time
,
2137 make_decl_rtl (decl
, asmspec
, top_level
);
2138 /* For a user-invisible decl that should be replaced
2139 by its value when used, don't output anything. */
2140 if (! (TREE_CODE (decl
) == VAR_DECL
2141 && DECL_IGNORED_P (decl
) && TREE_READONLY (decl
)
2142 && DECL_INITIAL (decl
) != 0))
2143 /* Don't output anything
2144 when a tentative file-scope definition is seen.
2145 But at end of compilation, do output code for them. */
2146 if (! (! at_end
&& top_level
2147 && (DECL_INITIAL (decl
) == 0
2148 || DECL_INITIAL (decl
) == error_mark_node
2149 || DECL_IGNORED_P (decl
))))
2150 assemble_variable (decl
, top_level
, at_end
);
2152 else if (DECL_REGISTER (decl
) && asmspec
!= 0)
2154 if (decode_reg_name (asmspec
) >= 0)
2156 DECL_RTL (decl
) = 0;
2157 make_decl_rtl (decl
, asmspec
, top_level
);
2160 error ("invalid register name `%s' for register variable", asmspec
);
2162 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2163 else if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2164 && TREE_CODE (decl
) == TYPE_DECL
)
2165 TIMEVAR (symout_time
, dbxout_symbol (decl
, 0));
2167 #ifdef SDB_DEBUGGING_INFO
2168 else if (write_symbols
== SDB_DEBUG
&& top_level
2169 && TREE_CODE (decl
) == TYPE_DECL
)
2170 TIMEVAR (symout_time
, sdbout_symbol (decl
, 0));
2174 /* Called after finishing a record, union or enumeral type. */
2177 rest_of_type_compilation (type
, toplev
)
2181 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2182 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2183 TIMEVAR (symout_time
, dbxout_symbol (TYPE_STUB_DECL (type
), !toplev
));
2185 #ifdef SDB_DEBUGGING_INFO
2186 if (write_symbols
== SDB_DEBUG
)
2187 TIMEVAR (symout_time
, sdbout_symbol (TYPE_STUB_DECL (type
), !toplev
));
2191 /* This is called from finish_function (within yyparse)
2192 after each top-level definition is parsed.
2193 It is supposed to compile that function or variable
2194 and output the assembler code for it.
2195 After we return, the tree storage is freed. */
2198 rest_of_compilation (decl
)
2202 int start_time
= get_run_time ();
2204 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2205 to be restored after we finish compiling the function
2206 (for use when compiling inline calls to this function). */
2207 tree saved_block_tree
= 0;
2208 /* Likewise, for DECL_ARGUMENTS. */
2209 tree saved_arguments
= 0;
2212 /* If we are reconsidering an inline function
2213 at the end of compilation, skip the stuff for making it inline. */
2215 if (DECL_SAVED_INSNS (decl
) == 0)
2217 int specd
= DECL_INLINE (decl
);
2220 /* If requested, consider whether to make this function inline. */
2221 if (specd
|| flag_inline_functions
)
2222 TIMEVAR (integration_time
,
2224 lose
= function_cannot_inline_p (decl
);
2227 if (warn_inline
&& specd
)
2228 warning_with_decl (decl
, lose
);
2229 DECL_INLINE (decl
) = 0;
2232 DECL_INLINE (decl
) = 1;
2235 insns
= get_insns ();
2237 /* Dump the rtl code if we are dumping rtl. */
2242 fprintf (rtl_dump_file
, "\n;; Function %s\n\n",
2243 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2244 if (DECL_SAVED_INSNS (decl
))
2245 fprintf (rtl_dump_file
, ";; (integrable)\n\n");
2246 print_rtl (rtl_dump_file
, insns
);
2247 fflush (rtl_dump_file
);
2250 /* If function is inline, and we don't yet know whether to
2251 compile it by itself, defer decision till end of compilation.
2252 finish_compilation will call rest_of_compilation again
2253 for those functions that need to be output. */
2255 if (DECL_INLINE (decl
)
2256 && ((! TREE_PUBLIC (decl
) && ! TREE_ADDRESSABLE (decl
)
2257 && ! flag_keep_inline_functions
)
2258 || DECL_EXTERNAL (decl
)))
2260 #ifdef DWARF_DEBUGGING_INFO
2261 /* Generate the DWARF info for the "abstract" instance
2262 of a function which we may later generate inlined and/or
2263 out-of-line instances of. */
2264 if (write_symbols
== DWARF_DEBUG
)
2266 set_decl_abstract_flags (decl
, 1);
2267 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
2268 set_decl_abstract_flags (decl
, 0);
2271 TIMEVAR (integration_time
, save_for_inline_nocopy (decl
));
2272 goto exit_rest_of_compilation
;
2275 /* If we have to compile the function now, save its rtl and subdecls
2276 so that its compilation will not affect what others get. */
2277 if (DECL_INLINE (decl
))
2279 #ifdef DWARF_DEBUGGING_INFO
2280 /* Generate the DWARF info for the "abstract" instance of
2281 a function which we will generate an out-of-line instance
2282 of almost immediately (and which we may also later generate
2283 various inlined instances of). */
2284 if (write_symbols
== DWARF_DEBUG
)
2286 set_decl_abstract_flags (decl
, 1);
2287 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
2288 set_decl_abstract_flags (decl
, 0);
2291 saved_block_tree
= DECL_INITIAL (decl
);
2292 saved_arguments
= DECL_ARGUMENTS (decl
);
2293 TIMEVAR (integration_time
, save_for_inline_copying (decl
));
2297 TREE_ASM_WRITTEN (decl
) = 1;
2299 /* Now that integrate will no longer see our rtl, we need not distinguish
2300 between the return value of this function and the return value of called
2302 rtx_equal_function_value_matters
= 0;
2304 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2305 if ((rtl_dump_and_exit
|| flag_syntax_only
) && !warn_return_type
)
2307 goto exit_rest_of_compilation
;
2310 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2311 Note that that may have been done above, in save_for_inline_copying.
2312 The call to resume_temporary_allocation near the end of this function
2313 goes back to the usual state of affairs. */
2315 rtl_in_current_obstack ();
2318 /* If we are doing position-independent code generation, now
2319 is the time to output special prologues and epilogues.
2320 We do not want to do this earlier, because it just clutters
2321 up inline functions with meaningless insns. */
2326 insns
= get_insns ();
2328 /* Copy any shared structure that should not be shared. */
2330 unshare_all_rtl (insns
);
2332 /* Instantiate all virtual registers. */
2334 instantiate_virtual_regs (current_function_decl
, get_insns ());
2336 /* See if we have allocated stack slots that are not directly addressable.
2337 If so, scan all the insns and create explicit address computation
2338 for all references to such slots. */
2339 /* fixup_stack_slots (); */
2341 /* Do jump optimization the first time, if -opt.
2342 Also do it if -W, but in that case it doesn't change the rtl code,
2343 it only computes whether control can drop off the end of the function. */
2345 if (optimize
> 0 || extra_warnings
|| warn_return_type
2346 /* If function is `volatile', we should warn if it tries to return. */
2347 || TREE_THIS_VOLATILE (decl
))
2349 TIMEVAR (jump_time
, reg_scan (insns
, max_reg_num (), 0));
2350 TIMEVAR (jump_time
, jump_optimize (insns
, 0, 0, 1));
2353 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2354 if (rtl_dump_and_exit
|| flag_syntax_only
)
2355 goto exit_rest_of_compilation
;
2357 /* Dump rtl code after jump, if we are doing that. */
2362 fprintf (jump_opt_dump_file
, "\n;; Function %s\n\n",
2363 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2364 print_rtl (jump_opt_dump_file
, insns
);
2365 fflush (jump_opt_dump_file
);
2368 /* Perform common subexpression elimination.
2369 Nonzero value from `cse_main' means that jumps were simplified
2370 and some code may now be unreachable, so do
2371 jump optimization again. */
2376 fprintf (cse_dump_file
, "\n;; Function %s\n\n",
2377 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2382 TIMEVAR (cse_time
, reg_scan (insns
, max_reg_num (), 1));
2384 if (flag_thread_jumps
)
2385 /* Hacks by tiemann & kenner. */
2386 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 0));
2388 TIMEVAR (cse_time
, tem
= cse_main (insns
, max_reg_num (),
2390 TIMEVAR (cse_time
, delete_dead_from_cse (insns
, max_reg_num ()));
2393 TIMEVAR (jump_time
, jump_optimize (insns
, 0, 0, 0));
2396 /* Dump rtl code after cse, if we are doing that. */
2401 print_rtl (cse_dump_file
, insns
);
2402 fflush (cse_dump_file
);
2408 fprintf (loop_dump_file
, "\n;; Function %s\n\n",
2409 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2412 /* Move constant computations out of loops. */
2418 loop_optimize (insns
, loop_dump_file
);
2422 /* Dump rtl code after loop opt, if we are doing that. */
2427 print_rtl (loop_dump_file
, insns
);
2428 fflush (loop_dump_file
);
2434 fprintf (cse2_dump_file
, "\n;; Function %s\n\n",
2435 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2438 if (optimize
> 0 && flag_rerun_cse_after_loop
)
2440 TIMEVAR (cse2_time
, reg_scan (insns
, max_reg_num (), 0));
2442 TIMEVAR (cse2_time
, tem
= cse_main (insns
, max_reg_num (),
2443 1, cse2_dump_file
));
2445 TIMEVAR (jump_time
, jump_optimize (insns
, 0, 0, 0));
2448 if (optimize
> 0 && flag_thread_jumps
)
2449 /* This pass of jump threading straightens out code
2450 that was kinked by loop optimization. */
2451 TIMEVAR (jump_time
, thread_jumps (insns
, max_reg_num (), 0));
2453 /* Dump rtl code after cse, if we are doing that. */
2458 print_rtl (cse2_dump_file
, insns
);
2459 fflush (cse2_dump_file
);
2462 /* We are no longer anticipating cse in this function, at least. */
2464 cse_not_expected
= 1;
2466 /* Now we choose between stupid (pcc-like) register allocation
2467 (if we got the -noreg switch and not -opt)
2468 and smart register allocation. */
2470 if (optimize
> 0) /* Stupid allocation probably won't work */
2471 obey_regdecls
= 0; /* if optimizations being done. */
2475 /* Print function header into flow dump now
2476 because doing the flow analysis makes some of the dump. */
2481 fprintf (flow_dump_file
, "\n;; Function %s\n\n",
2482 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2489 regclass (insns
, max_reg_num ());
2490 stupid_life_analysis (insns
, max_reg_num (),
2496 /* Do control and data flow analysis,
2497 and write some of the results to dump file. */
2499 TIMEVAR (flow_time
, flow_analysis (insns
, max_reg_num (),
2501 if (warn_uninitialized
)
2503 uninitialized_vars_warning (DECL_INITIAL (decl
));
2504 setjmp_args_warning ();
2508 /* Dump rtl after flow analysis. */
2513 print_rtl (flow_dump_file
, insns
);
2514 fflush (flow_dump_file
);
2517 /* If -opt, try combining insns through substitution. */
2520 TIMEVAR (combine_time
, combine_instructions (insns
, max_reg_num ()));
2522 /* Dump rtl code after insn combination. */
2527 fprintf (combine_dump_file
, "\n;; Function %s\n\n",
2528 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2529 dump_combine_stats (combine_dump_file
);
2530 print_rtl (combine_dump_file
, insns
);
2531 fflush (combine_dump_file
);
2534 /* Print function header into sched dump now
2535 because doing the sched analysis makes some of the dump. */
2540 fprintf (sched_dump_file
, "\n;; Function %s\n\n",
2541 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2544 if (optimize
> 0 && flag_schedule_insns
)
2546 /* Do control and data sched analysis,
2547 and write some of the results to dump file. */
2549 TIMEVAR (sched_time
, schedule_insns (sched_dump_file
));
2552 /* Dump rtl after instruction scheduling. */
2557 print_rtl (sched_dump_file
, insns
);
2558 fflush (sched_dump_file
);
2561 /* Unless we did stupid register allocation,
2562 allocate pseudo-regs that are used only within 1 basic block. */
2565 TIMEVAR (local_alloc_time
,
2567 regclass (insns
, max_reg_num ());
2571 /* Dump rtl code after allocating regs within basic blocks. */
2576 fprintf (local_reg_dump_file
, "\n;; Function %s\n\n",
2577 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2578 dump_flow_info (local_reg_dump_file
);
2579 dump_local_alloc (local_reg_dump_file
);
2580 print_rtl (local_reg_dump_file
, insns
);
2581 fflush (local_reg_dump_file
);
2584 if (global_reg_dump
)
2586 fprintf (global_reg_dump_file
, "\n;; Function %s\n\n",
2587 IDENTIFIER_POINTER (DECL_NAME (decl
))));
2589 /* Unless we did stupid register allocation,
2590 allocate remaining pseudo-regs, then do the reload pass
2591 fixing up any insns that are invalid. */
2593 TIMEVAR (global_alloc_time
,
2596 failure
= global_alloc (global_reg_dump_file
);
2598 failure
= reload (insns
, 0, global_reg_dump_file
);
2601 if (global_reg_dump
)
2604 dump_global_regs (global_reg_dump_file
);
2605 print_rtl (global_reg_dump_file
, insns
);
2606 fflush (global_reg_dump_file
);
2610 goto exit_rest_of_compilation
;
2612 reload_completed
= 1;
2614 /* On some machines, the prologue and epilogue code, or parts thereof,
2615 can be represented as RTL. Doing so lets us schedule insns between
2616 it and the rest of the code and also allows delayed branch
2617 scheduling to operate in the epilogue. */
2619 thread_prologue_and_epilogue_insns (insns
);
2621 if (optimize
> 0 && flag_schedule_insns_after_reload
)
2626 fprintf (sched2_dump_file
, "\n;; Function %s\n\n",
2627 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2630 /* Do control and data sched analysis again,
2631 and write some more of the results to dump file. */
2633 TIMEVAR (sched2_time
, schedule_insns (sched2_dump_file
));
2635 /* Dump rtl after post-reorder instruction scheduling. */
2640 print_rtl (sched2_dump_file
, insns
);
2641 fflush (sched2_dump_file
);
2645 #ifdef LEAF_REGISTERS
2647 if (optimize
> 0 && only_leaf_regs_used () && leaf_function_p ())
2651 /* One more attempt to remove jumps to .+1
2652 left by dead-store-elimination.
2653 Also do cross-jumping this time
2654 and delete no-op move insns. */
2658 TIMEVAR (jump_time
, jump_optimize (insns
, 1, 1, 0));
2661 /* Dump rtl code after jump, if we are doing that. */
2666 fprintf (jump2_opt_dump_file
, "\n;; Function %s\n\n",
2667 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2668 print_rtl (jump2_opt_dump_file
, insns
);
2669 fflush (jump2_opt_dump_file
);
2672 /* If a scheduling pass for delayed branches is to be done,
2673 call the scheduling code. */
2676 if (optimize
> 0 && flag_delayed_branch
)
2678 TIMEVAR (dbr_sched_time
, dbr_schedule (insns
, dbr_sched_dump_file
));
2683 fprintf (dbr_sched_dump_file
, "\n;; Function %s\n\n",
2684 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2685 print_rtl (dbr_sched_dump_file
, insns
);
2686 fflush (dbr_sched_dump_file
);
2693 /* Shorten branches. */
2694 TIMEVAR (shorten_branch_time
,
2696 shorten_branches (get_insns ());
2700 TIMEVAR (stack_reg_time
, reg_to_stack (insns
, stack_reg_dump_file
));
2705 fprintf (stack_reg_dump_file
, "\n;; Function %s\n\n",
2706 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2707 print_rtl (stack_reg_dump_file
, insns
);
2708 fflush (stack_reg_dump_file
);
2713 /* Now turn the rtl into assembler code. */
2715 TIMEVAR (final_time
,
2720 /* Get the function's name, as described by its RTL.
2721 This may be different from the DECL_NAME name used
2722 in the source file. */
2724 x
= DECL_RTL (decl
);
2725 if (GET_CODE (x
) != MEM
)
2728 if (GET_CODE (x
) != SYMBOL_REF
)
2730 fnname
= XSTR (x
, 0);
2732 assemble_start_function (decl
, fnname
);
2733 final_start_function (insns
, asm_out_file
, optimize
);
2734 final (insns
, asm_out_file
, optimize
, 0);
2735 final_end_function (insns
, asm_out_file
, optimize
);
2736 assemble_end_function (decl
, fnname
);
2737 fflush (asm_out_file
);
2740 /* Write DBX symbols if requested */
2742 /* Note that for those inline functions where we don't initially
2743 know for certain that we will be generating an out-of-line copy,
2744 the first invocation of this routine (rest_of_compilation) will
2745 skip over this code by doing a `goto exit_rest_of_compilation;'.
2746 Later on, finish_compilation will call rest_of_compilation again
2747 for those inline functions that need to have out-of-line copies
2748 generated. During that call, we *will* be routed past here. */
2750 #ifdef DBX_DEBUGGING_INFO
2751 if (write_symbols
== DBX_DEBUG
)
2752 TIMEVAR (symout_time
, dbxout_function (decl
));
2755 #ifdef DWARF_DEBUGGING_INFO
2756 if (write_symbols
== DWARF_DEBUG
)
2757 TIMEVAR (symout_time
, dwarfout_file_scope_decl (decl
, 0));
2760 exit_rest_of_compilation
:
2762 /* In case the function was not output,
2763 don't leave any temporary anonymous types
2764 queued up for sdb output. */
2765 #ifdef SDB_DEBUGGING_INFO
2766 if (write_symbols
== SDB_DEBUG
)
2767 sdbout_types (NULL_TREE
);
2770 /* Put back the tree of subblocks and list of arguments
2771 from before we copied them.
2772 Code generation and the output of debugging info may have modified
2773 the copy, but the original is unchanged. */
2775 if (saved_block_tree
!= 0)
2776 DECL_INITIAL (decl
) = saved_block_tree
;
2777 if (saved_arguments
!= 0)
2778 DECL_ARGUMENTS (decl
) = saved_arguments
;
2780 reload_completed
= 0;
2782 /* Clear out the real_constant_chain before some of the rtx's
2783 it runs through become garbage. */
2785 clear_const_double_mem ();
2787 /* Cancel the effect of rtl_in_current_obstack. */
2789 resume_temporary_allocation ();
2791 /* The parsing time is all the time spent in yyparse
2792 *except* what is spent in this function. */
2794 parse_time
-= get_run_time () - start_time
;
2797 /* Entry point of cc1/c++. Decode command args, then call compile_file.
2798 Exit code is 35 if can't open files, 34 if fatal error,
2799 33 if had nonfatal errors, else success. */
2802 main (argc
, argv
, envp
)
2809 int flag_print_mem
= 0;
2810 int version_flag
= 0;
2813 /* save in case md file wants to emit args as a comment. */
2817 p
= argv
[0] + strlen (argv
[0]);
2818 while (p
!= argv
[0] && p
[-1] != '/') --p
;
2822 /* Get rid of any avoidable limit on stack size. */
2826 /* Set the stack limit huge so that alloca does not fail. */
2827 getrlimit (RLIMIT_STACK
, &rlim
);
2828 rlim
.rlim_cur
= rlim
.rlim_max
;
2829 setrlimit (RLIMIT_STACK
, &rlim
);
2831 #endif /* RLIMIT_STACK */
2833 signal (SIGFPE
, float_signal
);
2836 signal (SIGPIPE
, pipe_closed
);
2839 decl_printable_name
= decl_name
;
2840 lang_expand_expr
= (struct rtx_def
*(*)()) do_abort
;
2842 /* Initialize whether `char' is signed. */
2843 flag_signed_char
= DEFAULT_SIGNED_CHAR
;
2844 #ifdef DEFAULT_SHORT_ENUMS
2845 /* Initialize how much space enums occupy, by default. */
2846 flag_short_enums
= DEFAULT_SHORT_ENUMS
;
2849 /* Scan to see what optimization level has been specified. That will
2850 determine the default value of many flags. */
2851 for (i
= 1; i
< argc
; i
++)
2853 if (!strcmp (argv
[i
], "-O"))
2857 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'O')
2859 /* Handle -O2, -O3, -O69, ... */
2860 char *p
= &argv
[i
][2];
2864 if (! (c
>= '0' && c
<= '9'))
2867 optimize
= atoi (&argv
[i
][2]);
2871 obey_regdecls
= (optimize
== 0);
2880 flag_thread_jumps
= 1;
2882 flag_delayed_branch
= 1;
2888 flag_cse_follow_jumps
= 1;
2889 flag_cse_skip_blocks
= 1;
2890 flag_expensive_optimizations
= 1;
2891 flag_strength_reduce
= 1;
2892 flag_rerun_cse_after_loop
= 1;
2893 flag_caller_saves
= 1;
2894 #ifdef INSN_SCHEDULING
2895 flag_schedule_insns
= 1;
2896 flag_schedule_insns_after_reload
= 1;
2900 #ifdef OPTIMIZATION_OPTIONS
2901 /* Allow default optimizations to be specified on a per-machine basis. */
2902 OPTIMIZATION_OPTIONS (optimize
);
2905 /* Initialize register usage now so switches may override. */
2909 set_target_switch ("");
2911 for (i
= 1; i
< argc
; i
++)
2914 /* If this is a language-specific option,
2915 decode it in a language-specific way. */
2916 for (j
= 0; lang_options
[j
] != 0; j
++)
2917 if (!strncmp (argv
[i
], lang_options
[j
],
2918 strlen (lang_options
[j
])))
2920 if (lang_options
[j
] != 0)
2921 /* If the option is valid for *some* language,
2922 treat it as valid even if this language doesn't understand it. */
2923 lang_decode_option (argv
[i
]);
2924 else if (argv
[i
][0] == '-' && argv
[i
][1] != 0)
2926 register char *str
= argv
[i
] + 1;
2931 set_target_switch (&str
[1]);
2932 else if (!strcmp (str
, "dumpbase"))
2934 dump_base_name
= argv
[++i
];
2936 else if (str
[0] == 'd')
2938 register char *p
= &str
[1];
2946 global_reg_dump
= 1;
2952 cse_dump
= 1, cse2_dump
= 1;
2970 global_reg_dump
= 1;
2988 flag_print_asm_name
= 1;
3010 rtl_dump_and_exit
= 1;
3014 else if (str
[0] == 'f')
3016 register char *p
= &str
[1];
3019 /* Some kind of -f option.
3020 P's value is the option sans `-f'.
3021 Search for it in the table of options. */
3024 !found
&& j
< sizeof (f_options
) / sizeof (f_options
[0]);
3027 if (!strcmp (p
, f_options
[j
].string
))
3029 *f_options
[j
].variable
= f_options
[j
].on_value
;
3030 /* A goto here would be cleaner,
3031 but breaks the vax pcc. */
3034 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
3035 && ! strcmp (p
+3, f_options
[j
].string
))
3037 *f_options
[j
].variable
= ! f_options
[j
].on_value
;
3044 else if (!strncmp (p
, "fixed-", 6))
3045 fix_register (&p
[6], 1, 1);
3046 else if (!strncmp (p
, "call-used-", 10))
3047 fix_register (&p
[10], 0, 1);
3048 else if (!strncmp (p
, "call-saved-", 11))
3049 fix_register (&p
[11], 0, 0);
3051 error ("Invalid option `%s'", argv
[i
]);
3053 else if (str
[0] == 'O')
3055 register char *p
= str
+1;
3056 while (*p
&& *p
>= '0' && *p
<= '9')
3061 error ("Invalid option `%s'", argv
[i
]);
3063 else if (!strcmp (str
, "pedantic"))
3065 else if (!strcmp (str
, "pedantic-errors"))
3066 flag_pedantic_errors
= pedantic
= 1;
3067 else if (!strcmp (str
, "quiet"))
3069 else if (!strcmp (str
, "version"))
3071 else if (!strcmp (str
, "w"))
3072 inhibit_warnings
= 1;
3073 else if (!strcmp (str
, "W"))
3076 warn_uninitialized
= 1;
3078 else if (str
[0] == 'W')
3080 register char *p
= &str
[1];
3083 /* Some kind of -W option.
3084 P's value is the option sans `-W'.
3085 Search for it in the table of options. */
3088 !found
&& j
< sizeof (W_options
) / sizeof (W_options
[0]);
3091 if (!strcmp (p
, W_options
[j
].string
))
3093 *W_options
[j
].variable
= W_options
[j
].on_value
;
3094 /* A goto here would be cleaner,
3095 but breaks the vax pcc. */
3098 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
3099 && ! strcmp (p
+3, W_options
[j
].string
))
3101 *W_options
[j
].variable
= ! W_options
[j
].on_value
;
3108 else if (!strncmp (p
, "id-clash-", 9))
3114 if (*endp
>= '0' && *endp
<= '9')
3118 error ("Invalid option `%s'", argv
[i
]);
3123 id_clash_len
= atoi (str
+ 10);
3127 error ("Invalid option `%s'", argv
[i
]);
3129 else if (!strcmp (str
, "p"))
3131 else if (!strcmp (str
, "a"))
3133 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3134 warning ("`-a' option (basic block profile) not supported");
3136 profile_block_flag
= 1;
3139 else if (str
[0] == 'g')
3146 while (*p
&& (*p
< '0' || *p
> '9'))
3150 while (*q
&& (*q
>= '0' && *q
<= '9'))
3155 level
= 2; /* default debugging info level */
3156 if (*q
|| level
> 3)
3158 warning ("invalid debug level specification in option: `-%s'",
3160 warning ("no debugging information will be generated");
3164 /* If more than one debugging type is supported,
3165 you must define PREFERRED_DEBUGGING_TYPE
3166 to choose a format in a system-dependent way. */
3167 /* This is one long line cause VAXC can't handle a \-newline. */
3168 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3169 #ifdef PREFERRED_DEBUGGING_TYPE
3170 if (!strncmp (str
, "ggdb", len
))
3171 write_symbols
= PREFERRED_DEBUGGING_TYPE
;
3172 #else /* no PREFERRED_DEBUGGING_TYPE */
3173 You Lose
! You must define PREFERRED_DEBUGGING_TYPE
!
3174 #endif /* no PREFERRED_DEBUGGING_TYPE */
3175 #endif /* More than one debugger format enabled. */
3176 #ifdef DBX_DEBUGGING_INFO
3177 if (write_symbols
!= NO_DEBUG
)
3179 else if (!strncmp (str
, "ggdb", len
))
3180 write_symbols
= DBX_DEBUG
;
3181 else if (!strncmp (str
, "gstabs", len
))
3182 write_symbols
= DBX_DEBUG
;
3183 else if (!strncmp (str
, "gstabs+", len
))
3184 write_symbols
= DBX_DEBUG
;
3186 /* Always enable extensions for -ggdb or -gstabs+,
3187 always disable for -gstabs.
3188 For plain -g, use system-specific default. */
3189 if (write_symbols
== DBX_DEBUG
&& !strncmp (str
, "ggdb", len
)
3191 use_gnu_debug_info_extensions
= 1;
3192 else if (write_symbols
== DBX_DEBUG
&& !strncmp (str
, "gstabs+", len
)
3194 use_gnu_debug_info_extensions
= 1;
3195 else if (write_symbols
== DBX_DEBUG
3196 && !strncmp (str
, "gstabs", len
) && len
>= 2)
3197 use_gnu_debug_info_extensions
= 0;
3199 use_gnu_debug_info_extensions
= DEFAULT_GDB_EXTENSIONS
;
3200 #endif /* DBX_DEBUGGING_INFO */
3201 #ifdef DWARF_DEBUGGING_INFO
3202 if (write_symbols
!= NO_DEBUG
)
3204 else if (!strncmp (str
, "g", len
))
3205 write_symbols
= DWARF_DEBUG
;
3206 else if (!strncmp (str
, "ggdb", len
))
3207 write_symbols
= DWARF_DEBUG
;
3208 else if (!strncmp (str
, "gdwarf", len
))
3209 write_symbols
= DWARF_DEBUG
;
3211 /* Always enable extensions for -ggdb or -gdwarf+,
3212 always disable for -gdwarf.
3213 For plain -g, use system-specific default. */
3214 if (write_symbols
== DWARF_DEBUG
&& !strncmp (str
, "ggdb", len
)
3216 use_gnu_debug_info_extensions
= 1;
3217 else if (write_symbols
== DWARF_DEBUG
&& !strcmp (str
, "gdwarf+"))
3218 use_gnu_debug_info_extensions
= 1;
3219 else if (write_symbols
== DWARF_DEBUG
3220 && !strncmp (str
, "gdwarf", len
) && len
>= 2)
3221 use_gnu_debug_info_extensions
= 0;
3223 use_gnu_debug_info_extensions
= DEFAULT_GDB_EXTENSIONS
;
3225 #ifdef SDB_DEBUGGING_INFO
3226 if (write_symbols
!= NO_DEBUG
)
3228 else if (!strncmp (str
, "g", len
))
3229 write_symbols
= SDB_DEBUG
;
3230 else if (!strncmp (str
, "gdb", len
))
3231 write_symbols
= SDB_DEBUG
;
3232 else if (!strncmp (str
, "gcoff", len
))
3233 write_symbols
= SDB_DEBUG
;
3234 #endif /* SDB_DEBUGGING_INFO */
3235 #ifdef XCOFF_DEBUGGING_INFO
3236 if (write_symbols
!= NO_DEBUG
)
3238 else if (!strncmp (str
, "g", len
))
3239 write_symbols
= XCOFF_DEBUG
;
3240 else if (!strncmp (str
, "ggdb", len
))
3241 write_symbols
= XCOFF_DEBUG
;
3242 else if (!strncmp (str
, "gxcoff", len
))
3243 write_symbols
= XCOFF_DEBUG
;
3245 /* Always enable extensions for -ggdb or -gxcoff+,
3246 always disable for -gxcoff.
3247 For plain -g, use system-specific default. */
3248 if (write_symbols
== XCOFF_DEBUG
&& !strncmp (str
, "ggdb", len
)
3250 use_gnu_debug_info_extensions
= 1;
3251 else if (write_symbols
== XCOFF_DEBUG
&& !strcmp (str
, "gxcoff+"))
3252 use_gnu_debug_info_extensions
= 1;
3253 else if (write_symbols
== XCOFF_DEBUG
3254 && !strncmp (str
, "gxcoff", len
) && len
>= 2)
3255 use_gnu_debug_info_extensions
= 0;
3257 use_gnu_debug_info_extensions
= DEFAULT_GDB_EXTENSIONS
;
3259 if (write_symbols
== NO_DEBUG
)
3260 warning ("`-%s' option not supported on this version of GCC", str
);
3261 else if (level
== 0)
3262 write_symbols
= NO_DEBUG
;
3264 debug_info_level
= (enum debug_info_level
) level
;
3266 else if (!strcmp (str
, "o"))
3268 asm_file_name
= argv
[++i
];
3270 else if (str
[0] == 'G')
3272 g_switch_set
= TRUE
;
3273 g_switch_value
= atoi ((str
[1] != '\0') ? str
+1 : argv
[++i
]);
3275 else if (!strncmp (str
, "aux-info", 8))
3277 flag_gen_aux_info
= 1;
3278 aux_info_file_name
= (str
[8] != '\0' ? str
+8 : argv
[++i
]);
3281 error ("Invalid option `%s'", argv
[i
]);
3283 else if (argv
[i
][0] == '+')
3284 error ("Invalid option `%s'", argv
[i
]);
3291 /* Inlining does not work if not optimizing,
3292 so force it not to be done. */
3296 /* The c_decode_option and lang_decode_option functions set
3297 this to `2' if -Wall is used, so we can avoid giving out
3298 lots of errors for people who don't realize what -Wall does. */
3299 if (warn_uninitialized
== 1)
3300 warning ("-Wuninitialized is not supported without -O");
3303 #ifdef OVERRIDE_OPTIONS
3304 /* Some machines may reject certain combinations of options. */
3308 /* Unrolling all loops implies that standard loop unrolling must also
3310 if (flag_unroll_all_loops
)
3311 flag_unroll_loops
= 1;
3312 /* Loop unrolling requires that strength_reduction be on also. Silently
3313 turn on strength reduction here if it isn't already on. Also, the loop
3314 unrolling code assumes that cse will be run after loop, so that must
3315 be turned on also. */
3316 if (flag_unroll_loops
)
3318 flag_strength_reduce
= 1;
3319 flag_rerun_cse_after_loop
= 1;
3322 /* Warn about options that are not supported on this machine. */
3323 #ifndef INSN_SCHEDULING
3324 if (flag_schedule_insns
|| flag_schedule_insns_after_reload
)
3325 warning ("instruction scheduling not supported on this target machine");
3328 if (flag_delayed_branch
)
3329 warning ("this target machine does not have delayed branches");
3332 /* If we are in verbose mode, write out the version and maybe all the
3333 option flags in use. */
3336 fprintf (stderr
, "%s version %s", language_string
, version_string
);
3337 #ifdef TARGET_VERSION
3342 #define __VERSION__ "[unknown]"
3344 fprintf (stderr
, " compiled by GNU C version %s.\n", __VERSION__
);
3346 fprintf (stderr
, " compiled by CC.\n");
3349 print_switch_values ();
3352 /* Now that register usage is specified, convert it to HARD_REG_SETs. */
3355 compile_file (filename
);
3361 char *lim
= (char *) sbrk (0);
3363 fprintf (stderr
, "Data size %d.\n",
3364 lim
- (char *) &environ
);
3368 system ("ps -l 1>&2");
3371 #endif /* not USG */
3373 #endif /* not VMS */
3374 #endif /* not OS2 */
3377 exit (FATAL_EXIT_CODE
);
3379 exit (FATAL_EXIT_CODE
);
3380 exit (SUCCESS_EXIT_CODE
);
3384 /* Decode -m switches. */
3386 /* Here is a table, controlled by the tm.h file, listing each -m switch
3387 and which bits in `target_switches' it should set or clear.
3388 If VALUE is positive, it is bits to set.
3389 If VALUE is negative, -VALUE is bits to clear.
3390 (The sign bit is not used so there is no confusion.) */
3392 struct {char *name
; int value
;} target_switches
[]
3395 /* This table is similar, but allows the switch to have a value. */
3397 #ifdef TARGET_OPTIONS
3398 struct {char *prefix
; char ** variable
;} target_options
[]
3402 /* Decode the switch -mNAME. */
3405 set_target_switch (name
)
3411 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
3412 if (!strcmp (target_switches
[j
].name
, name
))
3414 if (target_switches
[j
].value
< 0)
3415 target_flags
&= ~-target_switches
[j
].value
;
3417 target_flags
|= target_switches
[j
].value
;
3421 #ifdef TARGET_OPTIONS
3423 for (j
= 0; j
< sizeof target_options
/ sizeof target_options
[0]; j
++)
3425 int len
= strlen (target_options
[j
].prefix
);
3426 if (!strncmp (target_options
[j
].prefix
, name
, len
))
3428 *target_options
[j
].variable
= name
+ len
;
3435 error ("Invalid option `%s'", name
);
3438 /* Variable used for communication between the following two routines. */
3440 static int line_position
;
3442 /* Print an option value and adjust the position in the line. */
3445 print_single_switch (type
, name
)
3448 fprintf (stderr
, " %s%s", type
, name
);
3450 line_position
+= strlen (type
) + strlen (name
) + 1;
3452 if (line_position
> 65)
3454 fprintf (stderr
, "\n\t");
3459 /* Print default target switches for -version. */
3462 print_switch_values ()
3466 fprintf (stderr
, "enabled:");
3469 for (j
= 0; j
< sizeof f_options
/ sizeof f_options
[0]; j
++)
3470 if (*f_options
[j
].variable
== f_options
[j
].on_value
)
3471 print_single_switch ("-f", f_options
[j
].string
);
3473 for (j
= 0; j
< sizeof W_options
/ sizeof W_options
[0]; j
++)
3474 if (*W_options
[j
].variable
== W_options
[j
].on_value
)
3475 print_single_switch ("-W", W_options
[j
].string
);
3477 for (j
= 0; j
< sizeof target_switches
/ sizeof target_switches
[0]; j
++)
3478 if (target_switches
[j
].name
[0] != '\0'
3479 && target_switches
[j
].value
> 0
3480 && ((target_switches
[j
].value
& target_flags
)
3481 == target_switches
[j
].value
))
3482 print_single_switch ("-m", target_switches
[j
].name
);
3484 fprintf (stderr
, "\n");