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",
585 /* These are for C++. */
586 "-+e0", /* gcc.c tacks the `-' on the front. */
590 "-fno-save-memoized",
599 "-fthis-is-variable",
600 "-fno-this-is-variable",
601 "-fstrict-prototype",
602 "-fno-strict-prototype",
606 "-fno-memoize-lookups",
607 "-felide-constructors",
608 "-fno-elide-constructors",
611 "-fhandle-exceptions",
612 "-fno-handle-exceptions",
614 "-fno-ansi-exceptions",
615 "-fspring-exceptions",
616 "-fno-spring-exceptions",
618 "-fno-default-inline",
620 "-fno-enum-int-equiv",
626 "-fno-nonnull-objects",
627 "-fimplement-inlines",
628 "-fno-implement-inlines",
632 "-Woverloaded-virtual",
633 "-Wno-overloaded-virtual",
636 "-Wtemplate-debugging",
637 "-Wno-template-debugging",
639 /* these are for obj c */
647 /* Options controlling warnings */
649 /* Don't print warning messages. -w. */
651 int inhibit_warnings = 0;
653 /* Print various extra warnings. -W. */
655 int extra_warnings = 0;
657 /* Treat warnings as errors. -Werror. */
659 int warnings_are_errors = 0;
661 /* Nonzero to warn about unused local variables. */
665 /* Nonzero to warn about variables used before they are initialized. */
667 int warn_uninitialized;
669 /* Nonzero means warn about all declarations which shadow others. */
673 /* Warn if a switch on an enum fails to have a case for every enum value. */
677 /* Nonzero means warn about function definitions that default the return type
678 or that use a null return and have a return-type other than void. */
680 int warn_return_type;
682 /* Nonzero means warn about pointer casts that increase the required
683 alignment of the target type (and might therefore lead to a crash
684 due to a misaligned access). */
688 /* Nonzero means warn about any identifiers that match in the first N
689 characters. The value N is in `id_clash_len'. */
694 /* Nonzero means warn if inline function is too large. */
698 /* Warn if a function returns an aggregate,
699 since there are often incompatible calling conventions for doing this. */
701 int warn_aggregate_return;
703 /* Likewise for -W. */
705 struct { char *string; int *variable; int on_value;} W_options[] =
707 {"unused", &warn_unused, 1},
708 {"error", &warnings_are_errors, 1},
709 {"shadow", &warn_shadow, 1},
710 {"switch", &warn_switch, 1},
711 {"aggregate-return", &warn_aggregate_return, 1},
712 {"cast-align", &warn_cast_align, 1},
713 {"uninitialized", &warn_uninitialized, 1},
714 {"inline", &warn_inline, 1}
717 /* Output files for assembler code (real compiler output)
718 and debugging dumps. */
723 FILE *jump_opt_dump_file;
725 FILE *loop_dump_file;
726 FILE *cse2_dump_file;
727 FILE *flow_dump_file;
728 FILE *combine_dump_file;
729 FILE *sched_dump_file;
730 FILE *local_reg_dump_file;
731 FILE *global_reg_dump_file;
732 FILE *sched2_dump_file;
733 FILE *jump2_opt_dump_file;
734 FILE *dbr_sched_dump_file;
735 FILE *stack_reg_dump_file;
737 /* Time accumulators, to count the total time spent in various passes. */
741 int integration_time;
749 int local_alloc_time;
750 int global_alloc_time;
753 int shorten_branch_time;
759 /* Return time used so far, in microseconds. */
768 struct rusage rusage;
773 int proc_system_time;
775 int child_system_time;
785 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
788 getrusage (0, &rusage);
789 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
790 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
793 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
798 #define TIMEVAR(VAR, BODY) \
799 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
802 print_time (str, total)
807 "time in %s: %d.%06d\n",
808 str, total / 1000000, total % 1000000);
811 /* Count an error or warning. Return 1 if the message should be printed. */
814 count_error (warningp)
817 if (warningp && inhibit_warnings)
820 if (warningp && !warnings_are_errors)
824 static int warning_message = 0;
826 if (warningp && !warning_message)
828 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
837 /* Print a fatal error message. NAME is the text.
838 Also include a system error message based on `errno'. */
841 pfatal_with_name (name)
844 fprintf (stderr, "%s: ", progname);
850 fatal_io_error (name)
853 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
866 /* Called to give a better error message when we don't have an insn to match
867 what we are looking for or if the insn's constraints aren't satisfied,
868 rather than just calling abort(). */
871 fatal_insn_not_found (insn)
874 if (INSN_CODE (insn) < 0)
875 error ("internal error--unrecognizable insn:", 0);
877 error ("internal error--insn does not satisfy its constraints:", 0);
880 fflush (asm_out_file);
882 fflush (aux_info_file);
884 fflush (rtl_dump_file);
885 if (jump_opt_dump_file)
886 fflush (jump_opt_dump_file);
888 fflush (cse_dump_file);
890 fflush (loop_dump_file);
892 fflush (cse2_dump_file);
894 fflush (flow_dump_file);
895 if (combine_dump_file)
896 fflush (combine_dump_file);
898 fflush (sched_dump_file);
899 if (local_reg_dump_file)
900 fflush (local_reg_dump_file);
901 if (global_reg_dump_file)
902 fflush (global_reg_dump_file);
903 if (sched2_dump_file)
904 fflush (sched2_dump_file);
905 if (jump2_opt_dump_file)
906 fflush (jump2_opt_dump_file);
907 if (dbr_sched_dump_file)
908 fflush (dbr_sched_dump_file);
909 if (stack_reg_dump_file)
910 fflush (stack_reg_dump_file);
914 /* This is the default decl_printable_name function. */
917 decl_name (decl, kind)
921 return IDENTIFIER_POINTER (DECL_NAME (decl));
924 static int need_error_newline;
926 /* Function of last error message;
927 more generally, function such that if next error message is in it
928 then we don't have to mention the function name. */
929 static tree last_error_function = NULL;
931 /* Used to detect when input_file_stack has changed since last described. */
932 static int last_error_tick;
934 /* Called when the start of a function definition is parsed,
935 this function prints on stderr the name of the function. */
938 announce_function (decl)
944 if (rtl_dump_and_exit)
945 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
947 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
949 need_error_newline = 1;
950 last_error_function = current_function_decl;
954 /* Prints out, if necessary, the name of the current function
955 which caused an error. Called from all error and warning functions. */
958 report_error_function (file)
961 struct file_stack *p;
963 if (need_error_newline)
965 fprintf (stderr, "\n");
966 need_error_newline = 0;
969 if (last_error_function != current_function_decl)
971 char *kind = "function";
972 if (current_function_decl != 0
973 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
977 fprintf (stderr, "%s: ", file);
979 if (current_function_decl == NULL)
980 fprintf (stderr, "At top level:\n");
983 char *name = (*decl_printable_name) (current_function_decl, &kind);
984 fprintf (stderr, "In %s `%s':\n", kind, name);
987 last_error_function = current_function_decl;
989 if (input_file_stack && input_file_stack->next != 0
990 && input_file_stack_tick != last_error_tick)
992 fprintf (stderr, "In file included");
993 for (p = input_file_stack->next; p; p = p->next)
995 fprintf (stderr, " from %s:%d", p->name, p->line);
997 fprintf (stderr, ",");
999 fprintf (stderr, ":\n");
1000 last_error_tick = input_file_stack_tick;
1004 /* Report an error at the current line number.
1005 S is a string and V and V2 are args for `printf'. We use HOST_WIDE_INT
1006 as the type for these args assuming it is wide enough to hold a
1007 pointer. This isn't terribly portable, but is the best we can do
1008 without vprintf universally available. */
1013 HOST_WIDE_INT v; /* Also used as pointer */
1014 HOST_WIDE_INT v2; /* Also used as pointer */
1016 error_with_file_and_line (input_filename, lineno, s, v, v2);
1019 /* Report an error at line LINE of file FILE.
1020 S and V are a string and an arg for `printf'. */
1023 error_with_file_and_line (file, line, s, v, v2)
1032 report_error_function (file);
1035 fprintf (stderr, "%s:%d: ", file, line);
1037 fprintf (stderr, "%s: ", progname);
1038 fprintf (stderr, s, v, v2);
1039 fprintf (stderr, "\n");
1042 /* Report an error at the declaration DECL.
1043 S and V are a string and an arg which uses %s to substitute
1044 the declaration name. */
1047 error_with_decl (decl, s, v)
1055 report_error_function (DECL_SOURCE_FILE (decl));
1057 fprintf (stderr, "%s:%d: ",
1058 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1060 if (DECL_NAME (decl))
1061 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1063 fprintf (stderr, s, "((anonymous))", v);
1064 fprintf (stderr, "\n");
1067 /* Report an error at the line number of the insn INSN.
1068 S and V are a string and an arg for `printf'.
1069 This is used only when INSN is an `asm' with operands,
1070 and each ASM_OPERANDS records its own source file and line. */
1073 error_for_asm (insn, s, v, v2)
1076 HOST_WIDE_INT v; /* Also used as pointer */
1077 HOST_WIDE_INT v2; /* Also used as pointer */
1081 rtx body = PATTERN (insn);
1084 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1085 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1086 asmop = SET_SRC (body);
1087 else if (GET_CODE (body) == ASM_OPERANDS)
1089 else if (GET_CODE (body) == PARALLEL
1090 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1091 asmop = SET_SRC (XVECEXP (body, 0, 0));
1092 else if (GET_CODE (body) == PARALLEL
1093 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1094 asmop = XVECEXP (body, 0, 0);
1096 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1097 line = ASM_OPERANDS_SOURCE_LINE (asmop);
1099 error_with_file_and_line (filename, line, s, v, v2);
1102 /* Report a warning at line LINE.
1103 S and V are a string and an arg for `printf'. */
1106 warning_with_file_and_line (file, line, s, v, v2, v3)
1110 HOST_WIDE_INT v, v2, v3;
1112 if (count_error (1) == 0)
1115 report_error_function (file);
1118 fprintf (stderr, "%s:%d: ", file, line);
1120 fprintf (stderr, "%s: ", progname);
1122 fprintf (stderr, "warning: ");
1123 fprintf (stderr, s, v, v2, v3);
1124 fprintf (stderr, "\n");
1127 /* Report a warning at the current line number.
1128 S and V are a string and an arg for `printf'. */
1131 warning (s, v, v2, v3)
1133 HOST_WIDE_INT v, v2, v3; /* Also used as pointer */
1135 warning_with_file_and_line (input_filename, lineno, s, v, v2, v3);
1138 /* Report a warning at the declaration DECL.
1139 S is string which uses %s to substitute the declaration name.
1140 V is a second parameter that S can refer to. */
1143 warning_with_decl (decl, s, v)
1150 if (count_error (1) == 0)
1153 report_error_function (DECL_SOURCE_FILE (decl));
1155 fprintf (stderr, "%s:%d: ",
1156 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1158 fprintf (stderr, "warning: ");
1159 if (DECL_NAME (decl))
1160 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1162 fprintf (stderr, s, "((anonymous))", v);
1163 fprintf (stderr, "\n");
1166 /* Report a warning at the line number of the insn INSN.
1167 S and V are a string and an arg for `printf'.
1168 This is used only when INSN is an `asm' with operands,
1169 and each ASM_OPERANDS records its own source file and line. */
1172 warning_for_asm (insn, s, v, v2)
1175 HOST_WIDE_INT v; /* Also used as pointer */
1176 HOST_WIDE_INT v2; /* Also used as pointer */
1180 rtx body = PATTERN (insn);
1183 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1184 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1185 asmop = SET_SRC (body);
1186 else if (GET_CODE (body) == ASM_OPERANDS)
1188 else if (GET_CODE (body) == PARALLEL
1189 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1190 asmop = SET_SRC (XVECEXP (body, 0, 0));
1191 else if (GET_CODE (body) == PARALLEL
1192 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1193 asmop = XVECEXP (body, 0, 0);
1195 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1196 line = ASM_OPERANDS_SOURCE_LINE (asmop);
1198 warning_with_file_and_line (filename, line, s, v, v2);
1201 /* These functions issue either warnings or errors depending on
1202 -pedantic-errors. */
1207 HOST_WIDE_INT v; /* Also used as pointer */
1210 if (flag_pedantic_errors)
1217 pedwarn_with_decl (decl, s, v)
1222 if (flag_pedantic_errors)
1223 error_with_decl (decl, s, v);
1225 warning_with_decl (decl, s, v);
1229 pedwarn_with_file_and_line (file, line, s, v, v2)
1236 if (flag_pedantic_errors)
1237 error_with_file_and_line (file, line, s, v, v2);
1239 warning_with_file_and_line (file, line, s, v, v2);
1242 /* Apologize for not implementing some feature.
1243 S, V, and V2 are a string and args for `printf'. */
1248 HOST_WIDE_INT v, v2;
1252 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1254 fprintf (stderr, "%s: ", progname);
1256 fprintf (stderr, "sorry, not implemented: ");
1257 fprintf (stderr, s, v, v2);
1258 fprintf (stderr, "\n");
1261 /* Apologize for not implementing some feature, then quit.
1262 S, V, and V2 are a string and args for `printf'. */
1265 really_sorry (s, v, v2)
1267 HOST_WIDE_INT v, v2;
1270 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1272 fprintf (stderr, "%s: ", progname);
1274 fprintf (stderr, "sorry, not implemented: ");
1275 fprintf (stderr, s, v, v2);
1276 fatal (" (fatal)\n");
1279 /* More 'friendly' abort that prints the line and file.
1280 config.h can #define abort fancy_abort if you like that sort of thing.
1282 I don't think this is actually a good idea.
1283 Other sorts of crashes will look a certain way.
1284 It is a good thing if crashes from calling abort look the same way.
1290 fatal ("internal gcc abort");
1293 /* This calls abort and is used to avoid problems when abort if a macro.
1294 It is used when we need to pass the address of abort. */
1302 /* When `malloc.c' is compiled with `rcheck' defined,
1303 it calls this function to report clobberage. */
1311 /* Same as `malloc' but report error if no memory available. */
1317 register char *value = (char *) malloc (size);
1319 fatal ("virtual memory exhausted");
1323 /* Same as `realloc' but report error if no memory available. */
1326 xrealloc (ptr, size)
1330 char *result = (char *) realloc (ptr, size);
1332 fatal ("virtual memory exhausted");
1336 /* Return the logarithm of X, base 2, considering X unsigned,
1337 if X is a power of 2. Otherwise, returns -1.
1339 This should be used via the `exact_log2' macro. */
1343 register unsigned HOST_WIDE_INT x;
1345 register int log = 0;
1346 /* Test for 0 or a power of 2. */
1347 if (x == 0 || x != (x & -x))
1349 while ((x >>= 1) != 0)
1354 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1355 If X is 0, return -1.
1357 This should be used via the floor_log2 macro. */
1361 register unsigned HOST_WIDE_INT x;
1363 register int log = -1;
1371 jmp_buf float_handler;
1373 /* Specify where to longjmp to when a floating arithmetic error happens.
1374 If HANDLER is 0, it means don't handle the errors any more. */
1377 set_float_handler (handler)
1380 float_handled = (handler != 0);
1382 bcopy (handler, float_handler, sizeof (float_handler));
1385 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1386 error happens, pushing the previous specification into OLD_HANDLER.
1387 Return an indication of whether there was a previous handler in effect. */
1390 push_float_handler (handler, old_handler)
1391 jmp_buf handler, old_handler;
1393 int was_handled = float_handled;
1397 bcopy (float_handler, old_handler, sizeof (float_handler));
1398 bcopy (handler, float_handler, sizeof (float_handler));
1402 /* Restore the previous specification of whether and where to longjmp to
1403 when a floating arithmetic error happens. */
1406 pop_float_handler (handled, handler)
1410 float_handled = handled;
1412 bcopy (handler, float_handler, sizeof (float_handler));
1415 /* Signals actually come here. */
1418 float_signal (signo)
1419 /* If this is missing, some compilers complain. */
1422 if (float_handled == 0)
1424 #if defined (USG) || defined (hpux)
1425 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1428 signal (SIGFPE, float_signal);
1429 longjmp (float_handler, 1);
1432 /* Handler for SIGPIPE. */
1436 /* If this is missing, some compilers complain. */
1439 fatal ("output pipe has been closed");
1442 /* Strip off a legitimate source ending from the input string NAME of
1446 strip_off_ending (name, len)
1450 if (len > 2 && ! strcmp (".c", name + len - 2))
1452 else if (len > 2 && ! strcmp (".m", name + len - 2))
1454 else if (len > 2 && ! strcmp (".i", name + len - 2))
1456 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1458 else if (len > 3 && ! strcmp (".co", name + len - 3))
1460 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1462 else if (len > 2 && ! strcmp (".C", name + len - 2))
1464 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1466 else if (len > 2 && ! strcmp (".f", name + len - 2))
1468 else if (len > 4 && ! strcmp (".ada", name + len - 4))
1472 /* Output a file name in the form wanted by System V. */
1475 output_file_directive (asm_file, input_name)
1479 int len = strlen (input_name);
1480 char *na = input_name + len;
1482 /* NA gets INPUT_NAME sans directory names. */
1483 while (na > input_name)
1490 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1491 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1493 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1494 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1496 fprintf (asm_file, "\t.file\t\"%s\"\n", na);
1501 /* Routine to build language identifier for object file. */
1503 output_lang_identify (asm_out_file)
1506 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1507 char *s = (char *) alloca (len);
1508 sprintf (s, "__gnu_compiled_%s", lang_identify ());
1509 ASM_OUTPUT_LABEL (asm_out_file, s);
1512 /* Compile an entire file of output from cpp, named NAME.
1513 Write a file of assembly output and various debugging dumps. */
1521 int dump_base_name_length;
1523 int name_specified = name != 0;
1525 if (dump_base_name == 0)
1526 dump_base_name = name ? name : "gccdump";
1527 dump_base_name_length = strlen (dump_base_name);
1531 integration_time = 0;
1539 local_alloc_time = 0;
1540 global_alloc_time = 0;
1543 shorten_branch_time = 0;
1549 /* Open input file. */
1551 if (name == 0 || !strcmp (name, "-"))
1557 finput = fopen (name, "r");
1559 pfatal_with_name (name);
1561 #ifdef IO_BUFFER_SIZE
1562 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
1565 /* Initialize data in various passes. */
1571 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
1572 || debug_info_level == DINFO_LEVEL_VERBOSE);
1573 init_decl_processing ();
1581 if (flag_caller_saves)
1582 init_caller_save ();
1584 /* If auxiliary info generation is desired, open the output file.
1585 This goes in the same directory as the source file--unlike
1586 all the other output files. */
1587 if (flag_gen_aux_info)
1589 aux_info_file = fopen (aux_info_file_name, "w");
1590 if (aux_info_file == 0)
1591 pfatal_with_name (aux_info_file_name);
1594 /* If rtl dump desired, open the output file. */
1597 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1598 strcpy (dumpname, dump_base_name);
1599 strcat (dumpname, ".rtl");
1600 rtl_dump_file = fopen (dumpname, "w");
1601 if (rtl_dump_file == 0)
1602 pfatal_with_name (dumpname);
1605 /* If jump_opt dump desired, open the output file. */
1608 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1609 strcpy (dumpname, dump_base_name);
1610 strcat (dumpname, ".jump");
1611 jump_opt_dump_file = fopen (dumpname, "w");
1612 if (jump_opt_dump_file == 0)
1613 pfatal_with_name (dumpname);
1616 /* If cse dump desired, open the output file. */
1619 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1620 strcpy (dumpname, dump_base_name);
1621 strcat (dumpname, ".cse");
1622 cse_dump_file = fopen (dumpname, "w");
1623 if (cse_dump_file == 0)
1624 pfatal_with_name (dumpname);
1627 /* If loop dump desired, open the output file. */
1630 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1631 strcpy (dumpname, dump_base_name);
1632 strcat (dumpname, ".loop");
1633 loop_dump_file = fopen (dumpname, "w");
1634 if (loop_dump_file == 0)
1635 pfatal_with_name (dumpname);
1638 /* If cse2 dump desired, open the output file. */
1641 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1642 strcpy (dumpname, dump_base_name);
1643 strcat (dumpname, ".cse2");
1644 cse2_dump_file = fopen (dumpname, "w");
1645 if (cse2_dump_file == 0)
1646 pfatal_with_name (dumpname);
1649 /* If flow dump desired, open the output file. */
1652 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1653 strcpy (dumpname, dump_base_name);
1654 strcat (dumpname, ".flow");
1655 flow_dump_file = fopen (dumpname, "w");
1656 if (flow_dump_file == 0)
1657 pfatal_with_name (dumpname);
1660 /* If combine dump desired, open the output file. */
1663 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1664 strcpy (dumpname, dump_base_name);
1665 strcat (dumpname, ".combine");
1666 combine_dump_file = fopen (dumpname, "w");
1667 if (combine_dump_file == 0)
1668 pfatal_with_name (dumpname);
1671 /* If scheduling dump desired, open the output file. */
1674 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1675 strcpy (dumpname, dump_base_name);
1676 strcat (dumpname, ".sched");
1677 sched_dump_file = fopen (dumpname, "w");
1678 if (sched_dump_file == 0)
1679 pfatal_with_name (dumpname);
1682 /* If local_reg dump desired, open the output file. */
1685 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1686 strcpy (dumpname, dump_base_name);
1687 strcat (dumpname, ".lreg");
1688 local_reg_dump_file = fopen (dumpname, "w");
1689 if (local_reg_dump_file == 0)
1690 pfatal_with_name (dumpname);
1693 /* If global_reg dump desired, open the output file. */
1694 if (global_reg_dump)
1696 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1697 strcpy (dumpname, dump_base_name);
1698 strcat (dumpname, ".greg");
1699 global_reg_dump_file = fopen (dumpname, "w");
1700 if (global_reg_dump_file == 0)
1701 pfatal_with_name (dumpname);
1704 /* If 2nd scheduling dump desired, open the output file. */
1707 register char *dumpname = (char *) xmalloc (dump_base_name_length + 8);
1708 strcpy (dumpname, dump_base_name);
1709 strcat (dumpname, ".sched2");
1710 sched2_dump_file = fopen (dumpname, "w");
1711 if (sched2_dump_file == 0)
1712 pfatal_with_name (dumpname);
1715 /* If jump2_opt dump desired, open the output file. */
1718 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1719 strcpy (dumpname, dump_base_name);
1720 strcat (dumpname, ".jump2");
1721 jump2_opt_dump_file = fopen (dumpname, "w");
1722 if (jump2_opt_dump_file == 0)
1723 pfatal_with_name (dumpname);
1726 /* If dbr_sched dump desired, open the output file. */
1729 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1730 strcpy (dumpname, dump_base_name);
1731 strcat (dumpname, ".dbr");
1732 dbr_sched_dump_file = fopen (dumpname, "w");
1733 if (dbr_sched_dump_file == 0)
1734 pfatal_with_name (dumpname);
1739 /* If stack_reg dump desired, open the output file. */
1742 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1743 strcpy (dumpname, dump_base_name);
1744 strcat (dumpname, ".stack");
1745 stack_reg_dump_file = fopen (dumpname, "w");
1746 if (stack_reg_dump_file == 0)
1747 pfatal_with_name (dumpname);
1752 /* Open assembler code output file. */
1754 if (! name_specified && asm_file_name == 0)
1755 asm_out_file = stdout;
1758 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1759 int len = strlen (dump_base_name);
1760 strcpy (dumpname, dump_base_name);
1761 strip_off_ending (dumpname, len);
1762 strcat (dumpname, ".s");
1763 if (asm_file_name == 0)
1765 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
1766 strcpy (asm_file_name, dumpname);
1768 if (!strcmp (asm_file_name, "-"))
1769 asm_out_file = stdout;
1771 asm_out_file = fopen (asm_file_name, "w");
1772 if (asm_out_file == 0)
1773 pfatal_with_name (asm_file_name);
1776 #ifdef IO_BUFFER_SIZE
1777 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
1778 _IOFBF, IO_BUFFER_SIZE);
1781 input_filename = name;
1783 /* Perform language-specific initialization.
1784 This may set main_input_filename. */
1787 /* If the input doesn't start with a #line, use the input name
1788 as the official input file name. */
1789 if (main_input_filename == 0)
1790 main_input_filename = name;
1792 /* Put an entry on the input file stack for the main input file. */
1794 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
1795 input_file_stack->next = 0;
1796 input_file_stack->name = input_filename;
1798 ASM_FILE_START (asm_out_file);
1800 /* Output something to inform GDB that this compilation was by GCC. */
1801 #ifndef ASM_IDENTIFY_GCC
1802 fprintf (asm_out_file, "gcc2_compiled.:\n");
1804 ASM_IDENTIFY_GCC (asm_out_file);
1807 /* Output something to identify which front-end produced this file. */
1808 #ifdef ASM_IDENTIFY_LANGUAGE
1809 ASM_IDENTIFY_LANGUAGE (asm_out_file);
1812 /* Don't let the first function fall at the same address
1813 as gcc_compiled., if profiling. */
1814 if (profile_flag || profile_block_flag)
1815 assemble_zeros (UNITS_PER_WORD);
1817 /* If dbx symbol table desired, initialize writing it
1818 and output the predefined types. */
1819 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1820 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1821 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
1824 #ifdef SDB_DEBUGGING_INFO
1825 if (write_symbols == SDB_DEBUG)
1826 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
1829 #ifdef DWARF_DEBUGGING_INFO
1830 if (write_symbols == DWARF_DEBUG)
1831 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
1834 /* Initialize yet another pass. */
1836 init_final (main_input_filename);
1838 start_time = get_run_time ();
1840 /* Call the parser, which parses the entire file
1841 (calling rest_of_compilation for each function). */
1843 if (yyparse () != 0)
1844 if (errorcount == 0)
1845 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
1847 /* Compilation is now finished except for writing
1848 what's left of the symbol table output. */
1850 parse_time += get_run_time () - start_time;
1852 parse_time -= integration_time;
1853 parse_time -= varconst_time;
1855 globals = getdecls ();
1857 /* Really define vars that have had only a tentative definition.
1858 Really output inline functions that must actually be callable
1859 and have not been output so far. */
1862 int len = list_length (globals);
1863 tree *vec = (tree *) alloca (sizeof (tree) * len);
1867 /* Process the decls in reverse order--earliest first.
1868 Put them into VEC from back to front, then take out from front. */
1870 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
1871 vec[len - i - 1] = decl;
1873 for (i = 0; i < len; i++)
1876 if (DECL_SIZE (decl) == 0)
1877 (*incomplete_decl_finalize_hook) (decl);
1879 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1880 && ! TREE_ASM_WRITTEN (decl))
1882 /* Don't write out static consts, unless we used them.
1883 (This used to write them out only if the address was
1884 taken, but that was wrong; if the variable was simply
1885 referred to, it still needs to exist or else it will
1886 be undefined in the linker.) */
1887 if (! TREE_READONLY (decl)
1888 || TREE_PUBLIC (decl)
1890 || TREE_ADDRESSABLE (decl)
1891 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1892 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1894 /* Cancel the RTL for this decl so that, if debugging info
1895 output for global variables is still to come,
1896 this one will be omitted. */
1897 DECL_RTL (decl) = NULL;
1900 if (TREE_CODE (decl) == FUNCTION_DECL
1901 && ! TREE_ASM_WRITTEN (decl)
1902 && DECL_INITIAL (decl) != 0
1903 && (TREE_ADDRESSABLE (decl)
1904 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1905 && ! DECL_EXTERNAL (decl))
1906 output_inline_function (decl);
1908 /* Warn about any function
1909 declared static but not defined.
1910 We don't warn about variables,
1911 because many programs have static variables
1912 that exist only to get some text into the object file. */
1915 || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))))
1916 && TREE_CODE (decl) == FUNCTION_DECL
1917 && DECL_INITIAL (decl) == 0
1918 && DECL_EXTERNAL (decl)
1919 && ! TREE_PUBLIC (decl))
1921 pedwarn_with_decl (decl,
1922 "`%s' declared `static' but never defined");
1923 /* This symbol is effectively an "extern" declaration now. */
1924 TREE_PUBLIC (decl) = 1;
1925 assemble_external (decl);
1928 /* Warn about static fns or vars defined but not used,
1929 but not about inline functions
1930 since unused inline statics is normal practice. */
1932 && (TREE_CODE (decl) == FUNCTION_DECL
1933 || TREE_CODE (decl) == VAR_DECL)
1934 && ! DECL_IN_SYSTEM_HEADER (decl)
1935 && ! DECL_EXTERNAL (decl)
1936 && ! TREE_PUBLIC (decl)
1937 && ! TREE_USED (decl)
1938 && ! DECL_INLINE (decl)
1939 && ! DECL_REGISTER (decl)
1940 /* The TREE_USED bit for file-scope decls
1941 is kept in the identifier, to handle multiple
1942 external decls in different scopes. */
1943 && ! TREE_USED (DECL_NAME (decl)))
1944 warning_with_decl (decl, "`%s' defined but not used");
1946 #ifdef SDB_DEBUGGING_INFO
1947 /* The COFF linker can move initialized global vars to the end.
1948 And that can screw up the symbol ordering.
1949 By putting the symbols in that order to begin with,
1950 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1951 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
1952 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
1953 && DECL_RTL (decl) != 0)
1954 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1956 /* Output COFF information for non-global
1957 file-scope initialized variables. */
1958 if (write_symbols == SDB_DEBUG
1959 && TREE_CODE (decl) == VAR_DECL
1960 && DECL_INITIAL (decl)
1961 && DECL_RTL (decl) != 0
1962 && GET_CODE (DECL_RTL (decl)) == MEM)
1963 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
1964 #endif /* SDB_DEBUGGING_INFO */
1965 #ifdef DWARF_DEBUGGING_INFO
1966 /* Output DWARF information for file-scope tentative data object
1967 declarations, file-scope (extern) function declarations (which
1968 had no corresponding body) and file-scope tagged type declarations
1969 and definitions which have not yet been forced out. */
1971 if (write_symbols == DWARF_DEBUG
1972 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1973 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
1978 /* Do dbx symbols */
1979 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1980 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1981 TIMEVAR (symout_time,
1983 dbxout_finish (asm_out_file, main_input_filename);
1987 #ifdef DWARF_DEBUGGING_INFO
1988 if (write_symbols == DWARF_DEBUG)
1989 TIMEVAR (symout_time,
1995 /* Output some stuff at end of file if nec. */
1997 end_final (main_input_filename);
2000 ASM_FILE_END (asm_out_file);
2003 after_finish_compilation:
2005 /* Language-specific end of compilation actions. */
2009 /* Close the dump files. */
2011 if (flag_gen_aux_info)
2013 fclose (aux_info_file);
2015 unlink (aux_info_file_name);
2019 fclose (rtl_dump_file);
2022 fclose (jump_opt_dump_file);
2025 fclose (cse_dump_file);
2028 fclose (loop_dump_file);
2031 fclose (cse2_dump_file);
2034 fclose (flow_dump_file);
2038 dump_combine_total_stats (combine_dump_file);
2039 fclose (combine_dump_file);
2043 fclose (sched_dump_file);
2046 fclose (local_reg_dump_file);
2048 if (global_reg_dump)
2049 fclose (global_reg_dump_file);
2052 fclose (sched2_dump_file);
2055 fclose (jump2_opt_dump_file);
2058 fclose (dbr_sched_dump_file);
2062 fclose (stack_reg_dump_file);
2065 /* Close non-debugging input and output files. Take special care to note
2066 whether fclose returns an error, since the pages might still be on the
2067 buffer chain while the file is open. */
2070 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2071 fatal_io_error (asm_file_name);
2073 /* Print the times. */
2077 fprintf (stderr,"\n");
2078 print_time ("parse", parse_time);
2079 print_time ("integration", integration_time);
2080 print_time ("jump", jump_time);
2081 print_time ("cse", cse_time);
2082 print_time ("loop", loop_time);
2083 print_time ("cse2", cse2_time);
2084 print_time ("flow", flow_time);
2085 print_time ("combine", combine_time);
2086 print_time ("sched", sched_time);
2087 print_time ("local-alloc", local_alloc_time);
2088 print_time ("global-alloc", global_alloc_time);
2089 print_time ("sched2", sched2_time);
2090 print_time ("dbranch", dbr_sched_time);
2091 print_time ("shorten-branch", shorten_branch_time);
2092 print_time ("stack-reg", stack_reg_time);
2093 print_time ("final", final_time);
2094 print_time ("varconst", varconst_time);
2095 print_time ("symout", symout_time);
2096 print_time ("dump", dump_time);
2100 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2101 and TYPE_DECL nodes.
2103 This does nothing for local (non-static) variables.
2104 Otherwise, it sets up the RTL and outputs any assembler code
2105 (label definition, storage allocation and initialization).
2107 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2108 the assembler symbol name to be used. TOP_LEVEL is nonzero
2109 if this declaration is not within a function. */
2112 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2118 /* Declarations of variables, and of functions defined elsewhere. */
2120 /* Forward declarations for nested functions are not "external",
2121 but we need to treat them as if they were. */
2122 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2123 || TREE_CODE (decl) == FUNCTION_DECL)
2124 TIMEVAR (varconst_time,
2126 make_decl_rtl (decl, asmspec, top_level);
2127 /* For a user-invisible decl that should be replaced
2128 by its value when used, don't output anything. */
2129 if (! (TREE_CODE (decl) == VAR_DECL
2130 && DECL_IGNORED_P (decl) && TREE_READONLY (decl)
2131 && DECL_INITIAL (decl) != 0))
2132 /* Don't output anything
2133 when a tentative file-scope definition is seen.
2134 But at end of compilation, do output code for them. */
2135 if (! (! at_end && top_level
2136 && (DECL_INITIAL (decl) == 0
2137 || DECL_INITIAL (decl) == error_mark_node
2138 || DECL_IGNORED_P (decl))))
2139 assemble_variable (decl, top_level, at_end);
2141 else if (DECL_REGISTER (decl) && asmspec != 0)
2143 if (decode_reg_name (asmspec) >= 0)
2145 DECL_RTL (decl) = 0;
2146 make_decl_rtl (decl, asmspec, top_level);
2149 error ("invalid register name `%s' for register variable", asmspec);
2151 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2152 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2153 && TREE_CODE (decl) == TYPE_DECL)
2154 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2156 #ifdef SDB_DEBUGGING_INFO
2157 else if (write_symbols == SDB_DEBUG && top_level
2158 && TREE_CODE (decl) == TYPE_DECL)
2159 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2163 /* Called after finishing a record, union or enumeral type. */
2166 rest_of_type_compilation (type, toplev)
2170 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2171 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2172 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2174 #ifdef SDB_DEBUGGING_INFO
2175 if (write_symbols == SDB_DEBUG)
2176 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2180 /* This is called from finish_function (within yyparse)
2181 after each top-level definition is parsed.
2182 It is supposed to compile that function or variable
2183 and output the assembler code for it.
2184 After we return, the tree storage is freed. */
2187 rest_of_compilation (decl)
2191 int start_time = get_run_time ();
2193 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2194 to be restored after we finish compiling the function
2195 (for use when compiling inline calls to this function). */
2196 tree saved_block_tree = 0;
2197 /* Likewise, for DECL_ARGUMENTS. */
2198 tree saved_arguments = 0;
2201 /* If we are reconsidering an inline function
2202 at the end of compilation, skip the stuff for making it inline. */
2204 if (DECL_SAVED_INSNS (decl) == 0)
2206 int specd = DECL_INLINE (decl);
2209 /* If requested, consider whether to make this function inline. */
2210 if (specd || flag_inline_functions)
2211 TIMEVAR (integration_time,
2213 lose = function_cannot_inline_p (decl);
2216 if (warn_inline && specd)
2217 warning_with_decl (decl, lose);
2218 DECL_INLINE (decl) = 0;
2221 DECL_INLINE (decl) = 1;
2224 insns = get_insns ();
2226 /* Dump the rtl code if we are dumping rtl. */
2231 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2232 IDENTIFIER_POINTER (DECL_NAME (decl)));
2233 if (DECL_SAVED_INSNS (decl))
2234 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2235 print_rtl (rtl_dump_file, insns);
2236 fflush (rtl_dump_file);
2239 /* If function is inline, and we don't yet know whether to
2240 compile it by itself, defer decision till end of compilation.
2241 finish_compilation will call rest_of_compilation again
2242 for those functions that need to be output. */
2244 if (DECL_INLINE (decl)
2245 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2246 && ! flag_keep_inline_functions)
2247 || DECL_EXTERNAL (decl)))
2249 #ifdef DWARF_DEBUGGING_INFO
2250 /* Generate the DWARF info for the "abstract" instance
2251 of a function which we may later generate inlined and/or
2252 out-of-line instances of. */
2253 if (write_symbols == DWARF_DEBUG)
2255 set_decl_abstract_flags (decl, 1);
2256 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2257 set_decl_abstract_flags (decl, 0);
2260 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2261 goto exit_rest_of_compilation;
2264 /* If we have to compile the function now, save its rtl and subdecls
2265 so that its compilation will not affect what others get. */
2266 if (DECL_INLINE (decl))
2268 #ifdef DWARF_DEBUGGING_INFO
2269 /* Generate the DWARF info for the "abstract" instance of
2270 a function which we will generate an out-of-line instance
2271 of almost immediately (and which we may also later generate
2272 various inlined instances of). */
2273 if (write_symbols == DWARF_DEBUG)
2275 set_decl_abstract_flags (decl, 1);
2276 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2277 set_decl_abstract_flags (decl, 0);
2280 saved_block_tree = DECL_INITIAL (decl);
2281 saved_arguments = DECL_ARGUMENTS (decl);
2282 TIMEVAR (integration_time, save_for_inline_copying (decl));
2286 TREE_ASM_WRITTEN (decl) = 1;
2288 /* Now that integrate will no longer see our rtl, we need not distinguish
2289 between the return value of this function and the return value of called
2291 rtx_equal_function_value_matters = 0;
2293 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2294 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2296 goto exit_rest_of_compilation;
2299 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2300 Note that that may have been done above, in save_for_inline_copying.
2301 The call to resume_temporary_allocation near the end of this function
2302 goes back to the usual state of affairs. */
2304 rtl_in_current_obstack ();
2307 /* If we are doing position-independent code generation, now
2308 is the time to output special prologues and epilogues.
2309 We do not want to do this earlier, because it just clutters
2310 up inline functions with meaningless insns. */
2315 insns = get_insns ();
2317 /* Copy any shared structure that should not be shared. */
2319 unshare_all_rtl (insns);
2321 /* Instantiate all virtual registers. */
2323 instantiate_virtual_regs (current_function_decl, get_insns ());
2325 /* See if we have allocated stack slots that are not directly addressable.
2326 If so, scan all the insns and create explicit address computation
2327 for all references to such slots. */
2328 /* fixup_stack_slots (); */
2330 /* Do jump optimization the first time, if -opt.
2331 Also do it if -W, but in that case it doesn't change the rtl code,
2332 it only computes whether control can drop off the end of the function. */
2334 if (optimize > 0 || extra_warnings || warn_return_type
2335 /* If function is `volatile', we should warn if it tries to return. */
2336 || TREE_THIS_VOLATILE (decl))
2338 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2339 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2342 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2343 if (rtl_dump_and_exit || flag_syntax_only)
2344 goto exit_rest_of_compilation;
2346 /* Dump rtl code after jump, if we are doing that. */
2351 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2352 IDENTIFIER_POINTER (DECL_NAME (decl)));
2353 print_rtl (jump_opt_dump_file, insns);
2354 fflush (jump_opt_dump_file);
2357 /* Perform common subexpression elimination.
2358 Nonzero value from `cse_main' means that jumps were simplified
2359 and some code may now be unreachable, so do
2360 jump optimization again. */
2365 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2366 IDENTIFIER_POINTER (DECL_NAME (decl)));
2371 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2373 if (flag_thread_jumps)
2374 /* Hacks by tiemann & kenner. */
2375 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2377 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2379 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2382 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2385 /* Dump rtl code after cse, if we are doing that. */
2390 print_rtl (cse_dump_file, insns);
2391 fflush (cse_dump_file);
2397 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2398 IDENTIFIER_POINTER (DECL_NAME (decl)));
2401 /* Move constant computations out of loops. */
2407 loop_optimize (insns, loop_dump_file);
2411 /* Dump rtl code after loop opt, if we are doing that. */
2416 print_rtl (loop_dump_file, insns);
2417 fflush (loop_dump_file);
2423 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2424 IDENTIFIER_POINTER (DECL_NAME (decl)));
2427 if (optimize > 0 && flag_rerun_cse_after_loop)
2429 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2431 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2432 1, cse2_dump_file));
2434 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2437 if (optimize > 0 && flag_thread_jumps)
2438 /* This pass of jump threading straightens out code
2439 that was kinked by loop optimization. */
2440 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2442 /* Dump rtl code after cse, if we are doing that. */
2447 print_rtl (cse2_dump_file, insns);
2448 fflush (cse2_dump_file);
2451 /* We are no longer anticipating cse in this function, at least. */
2453 cse_not_expected = 1;
2455 /* Now we choose between stupid (pcc-like) register allocation
2456 (if we got the -noreg switch and not -opt)
2457 and smart register allocation. */
2459 if (optimize > 0) /* Stupid allocation probably won't work */
2460 obey_regdecls = 0; /* if optimizations being done. */
2464 /* Print function header into flow dump now
2465 because doing the flow analysis makes some of the dump. */
2470 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2471 IDENTIFIER_POINTER (DECL_NAME (decl)));
2478 regclass (insns, max_reg_num ());
2479 stupid_life_analysis (insns, max_reg_num (),
2485 /* Do control and data flow analysis,
2486 and write some of the results to dump file. */
2488 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2490 if (warn_uninitialized)
2492 uninitialized_vars_warning (DECL_INITIAL (decl));
2493 setjmp_args_warning ();
2497 /* Dump rtl after flow analysis. */
2502 print_rtl (flow_dump_file, insns);
2503 fflush (flow_dump_file);
2506 /* If -opt, try combining insns through substitution. */
2509 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2511 /* Dump rtl code after insn combination. */
2516 fprintf (combine_dump_file, "\n;; Function %s\n\n",
2517 IDENTIFIER_POINTER (DECL_NAME (decl)));
2518 dump_combine_stats (combine_dump_file);
2519 print_rtl (combine_dump_file, insns);
2520 fflush (combine_dump_file);
2523 /* Print function header into sched dump now
2524 because doing the sched analysis makes some of the dump. */
2529 fprintf (sched_dump_file, "\n;; Function %s\n\n",
2530 IDENTIFIER_POINTER (DECL_NAME (decl)));
2533 if (optimize > 0 && flag_schedule_insns)
2535 /* Do control and data sched analysis,
2536 and write some of the results to dump file. */
2538 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
2541 /* Dump rtl after instruction scheduling. */
2546 print_rtl (sched_dump_file, insns);
2547 fflush (sched_dump_file);
2550 /* Unless we did stupid register allocation,
2551 allocate pseudo-regs that are used only within 1 basic block. */
2554 TIMEVAR (local_alloc_time,
2556 regclass (insns, max_reg_num ());
2560 /* Dump rtl code after allocating regs within basic blocks. */
2565 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
2566 IDENTIFIER_POINTER (DECL_NAME (decl)));
2567 dump_flow_info (local_reg_dump_file);
2568 dump_local_alloc (local_reg_dump_file);
2569 print_rtl (local_reg_dump_file, insns);
2570 fflush (local_reg_dump_file);
2573 if (global_reg_dump)
2575 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
2576 IDENTIFIER_POINTER (DECL_NAME (decl))));
2578 /* Unless we did stupid register allocation,
2579 allocate remaining pseudo-regs, then do the reload pass
2580 fixing up any insns that are invalid. */
2582 TIMEVAR (global_alloc_time,
2585 failure = global_alloc (global_reg_dump_file);
2587 failure = reload (insns, 0, global_reg_dump_file);
2590 if (global_reg_dump)
2593 dump_global_regs (global_reg_dump_file);
2594 print_rtl (global_reg_dump_file, insns);
2595 fflush (global_reg_dump_file);
2599 goto exit_rest_of_compilation;
2601 reload_completed = 1;
2603 /* On some machines, the prologue and epilogue code, or parts thereof,
2604 can be represented as RTL. Doing so lets us schedule insns between
2605 it and the rest of the code and also allows delayed branch
2606 scheduling to operate in the epilogue. */
2608 thread_prologue_and_epilogue_insns (insns);
2610 if (optimize > 0 && flag_schedule_insns_after_reload)
2615 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
2616 IDENTIFIER_POINTER (DECL_NAME (decl)));
2619 /* Do control and data sched analysis again,
2620 and write some more of the results to dump file. */
2622 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
2624 /* Dump rtl after post-reorder instruction scheduling. */
2629 print_rtl (sched2_dump_file, insns);
2630 fflush (sched2_dump_file);
2634 #ifdef LEAF_REGISTERS
2636 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
2640 /* One more attempt to remove jumps to .+1
2641 left by dead-store-elimination.
2642 Also do cross-jumping this time
2643 and delete no-op move insns. */
2647 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
2650 /* Dump rtl code after jump, if we are doing that. */
2655 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
2656 IDENTIFIER_POINTER (DECL_NAME (decl)));
2657 print_rtl (jump2_opt_dump_file, insns);
2658 fflush (jump2_opt_dump_file);
2661 /* If a scheduling pass for delayed branches is to be done,
2662 call the scheduling code. */
2665 if (optimize > 0 && flag_delayed_branch)
2667 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
2672 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
2673 IDENTIFIER_POINTER (DECL_NAME (decl)));
2674 print_rtl (dbr_sched_dump_file, insns);
2675 fflush (dbr_sched_dump_file);
2682 /* Shorten branches. */
2683 TIMEVAR (shorten_branch_time,
2685 shorten_branches (get_insns ());
2689 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
2694 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
2695 IDENTIFIER_POINTER (DECL_NAME (decl)));
2696 print_rtl (stack_reg_dump_file, insns);
2697 fflush (stack_reg_dump_file);
2702 /* Now turn the rtl into assembler code. */
2704 TIMEVAR (final_time,
2709 /* Get the function's name, as described by its RTL.
2710 This may be different from the DECL_NAME name used
2711 in the source file. */
2713 x = DECL_RTL (decl);
2714 if (GET_CODE (x) != MEM)
2717 if (GET_CODE (x) != SYMBOL_REF)
2719 fnname = XSTR (x, 0);
2721 assemble_start_function (decl, fnname);
2722 final_start_function (insns, asm_out_file, optimize);
2723 final (insns, asm_out_file, optimize, 0);
2724 final_end_function (insns, asm_out_file, optimize);
2725 assemble_end_function (decl, fnname);
2726 fflush (asm_out_file);
2729 /* Write DBX symbols if requested */
2731 /* Note that for those inline functions where we don't initially
2732 know for certain that we will be generating an out-of-line copy,
2733 the first invocation of this routine (rest_of_compilation) will
2734 skip over this code by doing a `goto exit_rest_of_compilation;'.
2735 Later on, finish_compilation will call rest_of_compilation again
2736 for those inline functions that need to have out-of-line copies
2737 generated. During that call, we *will* be routed past here. */
2739 #ifdef DBX_DEBUGGING_INFO
2740 if (write_symbols == DBX_DEBUG)
2741 TIMEVAR (symout_time, dbxout_function (decl));
2744 #ifdef DWARF_DEBUGGING_INFO
2745 if (write_symbols == DWARF_DEBUG)
2746 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2749 exit_rest_of_compilation:
2751 /* In case the function was not output,
2752 don't leave any temporary anonymous types
2753 queued up for sdb output. */
2754 #ifdef SDB_DEBUGGING_INFO
2755 if (write_symbols == SDB_DEBUG)
2756 sdbout_types (NULL_TREE);
2759 /* Put back the tree of subblocks and list of arguments
2760 from before we copied them.
2761 Code generation and the output of debugging info may have modified
2762 the copy, but the original is unchanged. */
2764 if (saved_block_tree != 0)
2765 DECL_INITIAL (decl) = saved_block_tree;
2766 if (saved_arguments != 0)
2767 DECL_ARGUMENTS (decl) = saved_arguments;
2769 reload_completed = 0;
2771 /* Clear out the real_constant_chain before some of the rtx's
2772 it runs through become garbage. */
2774 clear_const_double_mem ();
2776 /* Cancel the effect of rtl_in_current_obstack. */
2778 resume_temporary_allocation ();
2780 /* The parsing time is all the time spent in yyparse
2781 *except* what is spent in this function. */
2783 parse_time -= get_run_time () - start_time;
2786 /* Entry point of cc1/c++. Decode command args, then call compile_file.
2787 Exit code is 35 if can't open files, 34 if fatal error,
2788 33 if had nonfatal errors, else success. */
2791 main (argc, argv, envp)
2798 int flag_print_mem = 0;
2799 int version_flag = 0;
2802 /* save in case md file wants to emit args as a comment. */
2806 p = argv[0] + strlen (argv[0]);
2807 while (p != argv[0] && p[-1] != '/') --p;
2811 /* Get rid of any avoidable limit on stack size. */
2815 /* Set the stack limit huge so that alloca does not fail. */
2816 getrlimit (RLIMIT_STACK, &rlim);
2817 rlim.rlim_cur = rlim.rlim_max;
2818 setrlimit (RLIMIT_STACK, &rlim);
2820 #endif /* RLIMIT_STACK */
2822 signal (SIGFPE, float_signal);
2824 signal (SIGPIPE, pipe_closed);
2826 decl_printable_name = decl_name;
2827 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
2829 /* Initialize whether `char' is signed. */
2830 flag_signed_char = DEFAULT_SIGNED_CHAR;
2831 #ifdef DEFAULT_SHORT_ENUMS
2832 /* Initialize how much space enums occupy, by default. */
2833 flag_short_enums = DEFAULT_SHORT_ENUMS;
2836 /* Scan to see what optimization level has been specified. That will
2837 determine the default value of many flags. */
2838 for (i = 1; i < argc; i++)
2840 if (!strcmp (argv[i], "-O"))
2844 else if (argv[i][0] == '-' && argv[i][1] == 'O')
2846 /* Handle -O2, -O3, -O69, ... */
2847 char *p = &argv[i][2];
2851 if (! (c >= '0' && c <= '9'))
2854 optimize = atoi (&argv[i][2]);
2858 obey_regdecls = (optimize == 0);
2867 flag_thread_jumps = 1;
2869 flag_delayed_branch = 1;
2875 flag_cse_follow_jumps = 1;
2876 flag_cse_skip_blocks = 1;
2877 flag_expensive_optimizations = 1;
2878 flag_strength_reduce = 1;
2879 flag_rerun_cse_after_loop = 1;
2880 flag_caller_saves = 1;
2881 #ifdef INSN_SCHEDULING
2882 flag_schedule_insns = 1;
2883 flag_schedule_insns_after_reload = 1;
2887 #ifdef OPTIMIZATION_OPTIONS
2888 /* Allow default optimizations to be specified on a per-machine basis. */
2889 OPTIMIZATION_OPTIONS (optimize);
2892 /* Initialize register usage now so switches may override. */
2896 set_target_switch ("");
2898 for (i = 1; i < argc; i++)
2901 /* If this is a language-specific option,
2902 decode it in a language-specific way. */
2903 for (j = 0; lang_options[j] != 0; j++)
2904 if (!strncmp (argv[i], lang_options[j],
2905 strlen (lang_options[j])))
2907 if (lang_options[j] != 0)
2908 /* If the option is valid for *some* language,
2909 treat it as valid even if this language doesn't understand it. */
2910 lang_decode_option (argv[i]);
2911 else if (argv[i][0] == '-' && argv[i][1] != 0)
2913 register char *str = argv[i] + 1;
2918 set_target_switch (&str[1]);
2919 else if (!strcmp (str, "dumpbase"))
2921 dump_base_name = argv[++i];
2923 else if (str[0] == 'd')
2925 register char *p = &str[1];
2933 global_reg_dump = 1;
2939 cse_dump = 1, cse2_dump = 1;
2957 global_reg_dump = 1;
2975 flag_print_asm_name = 1;
2997 rtl_dump_and_exit = 1;
3001 else if (str[0] == 'f')
3003 register char *p = &str[1];
3006 /* Some kind of -f option.
3007 P's value is the option sans `-f'.
3008 Search for it in the table of options. */
3011 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3014 if (!strcmp (p, f_options[j].string))
3016 *f_options[j].variable = f_options[j].on_value;
3017 /* A goto here would be cleaner,
3018 but breaks the vax pcc. */
3021 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3022 && ! strcmp (p+3, f_options[j].string))
3024 *f_options[j].variable = ! f_options[j].on_value;
3031 else if (!strncmp (p, "fixed-", 6))
3032 fix_register (&p[6], 1, 1);
3033 else if (!strncmp (p, "call-used-", 10))
3034 fix_register (&p[10], 0, 1);
3035 else if (!strncmp (p, "call-saved-", 11))
3036 fix_register (&p[11], 0, 0);
3038 error ("Invalid option `%s'", argv[i]);
3040 else if (str[0] == 'O')
3042 register char *p = str+1;
3043 while (*p && *p >= '0' && *p <= '9')
3048 error ("Invalid option `%s'", argv[i]);
3050 else if (!strcmp (str, "pedantic"))
3052 else if (!strcmp (str, "pedantic-errors"))
3053 flag_pedantic_errors = pedantic = 1;
3054 else if (!strcmp (str, "quiet"))
3056 else if (!strcmp (str, "version"))
3058 else if (!strcmp (str, "w"))
3059 inhibit_warnings = 1;
3060 else if (!strcmp (str, "W"))
3063 warn_uninitialized = 1;
3065 else if (str[0] == 'W')
3067 register char *p = &str[1];
3070 /* Some kind of -W option.
3071 P's value is the option sans `-W'.
3072 Search for it in the table of options. */
3075 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3078 if (!strcmp (p, W_options[j].string))
3080 *W_options[j].variable = W_options[j].on_value;
3081 /* A goto here would be cleaner,
3082 but breaks the vax pcc. */
3085 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3086 && ! strcmp (p+3, W_options[j].string))
3088 *W_options[j].variable = ! W_options[j].on_value;
3095 else if (!strncmp (p, "id-clash-", 9))
3101 if (*endp >= '0' && *endp <= '9')
3105 error ("Invalid option `%s'", argv[i]);
3110 id_clash_len = atoi (str + 10);
3114 error ("Invalid option `%s'", argv[i]);
3116 else if (!strcmp (str, "p"))
3118 else if (!strcmp (str, "a"))
3120 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3121 warning ("`-a' option (basic block profile) not supported");
3123 profile_block_flag = 1;
3126 else if (str[0] == 'g')
3133 while (*p && (*p < '0' || *p > '9'))
3137 while (*q && (*q >= '0' && *q <= '9'))
3142 level = 2; /* default debugging info level */
3143 if (*q || level > 3)
3145 warning ("invalid debug level specification in option: `-%s'",
3147 warning ("no debugging information will be generated");
3151 /* If more than one debugging type is supported,
3152 you must define PREFERRED_DEBUGGING_TYPE
3153 to choose a format in a system-dependent way. */
3154 /* This is one long line cause VAXC can't handle a \-newline. */
3155 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3156 #ifdef PREFERRED_DEBUGGING_TYPE
3157 if (!strncmp (str, "ggdb", len))
3158 write_symbols = PREFERRED_DEBUGGING_TYPE;
3159 #else /* no PREFERRED_DEBUGGING_TYPE */
3160 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3161 #endif /* no PREFERRED_DEBUGGING_TYPE */
3162 #endif /* More than one debugger format enabled. */
3163 #ifdef DBX_DEBUGGING_INFO
3164 if (write_symbols != NO_DEBUG)
3166 else if (!strncmp (str, "ggdb", len))
3167 write_symbols = DBX_DEBUG;
3168 else if (!strncmp (str, "gstabs", len))
3169 write_symbols = DBX_DEBUG;
3170 else if (!strncmp (str, "gstabs+", len))
3171 write_symbols = DBX_DEBUG;
3173 /* Always enable extensions for -ggdb or -gstabs+,
3174 always disable for -gstabs.
3175 For plain -g, use system-specific default. */
3176 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3178 use_gnu_debug_info_extensions = 1;
3179 else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
3181 use_gnu_debug_info_extensions = 1;
3182 else if (write_symbols == DBX_DEBUG
3183 && !strncmp (str, "gstabs", len) && len >= 2)
3184 use_gnu_debug_info_extensions = 0;
3186 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3187 #endif /* DBX_DEBUGGING_INFO */
3188 #ifdef DWARF_DEBUGGING_INFO
3189 if (write_symbols != NO_DEBUG)
3191 else if (!strncmp (str, "g", len))
3192 write_symbols = DWARF_DEBUG;
3193 else if (!strncmp (str, "ggdb", len))
3194 write_symbols = DWARF_DEBUG;
3195 else if (!strncmp (str, "gdwarf", len))
3196 write_symbols = DWARF_DEBUG;
3198 /* Always enable extensions for -ggdb or -gdwarf+,
3199 always disable for -gdwarf.
3200 For plain -g, use system-specific default. */
3201 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3203 use_gnu_debug_info_extensions = 1;
3204 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3205 use_gnu_debug_info_extensions = 1;
3206 else if (write_symbols == DWARF_DEBUG
3207 && !strncmp (str, "gdwarf", len) && len >= 2)
3208 use_gnu_debug_info_extensions = 0;
3210 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3212 #ifdef SDB_DEBUGGING_INFO
3213 if (write_symbols != NO_DEBUG)
3215 else if (!strncmp (str, "g", len))
3216 write_symbols = SDB_DEBUG;
3217 else if (!strncmp (str, "gdb", len))
3218 write_symbols = SDB_DEBUG;
3219 else if (!strncmp (str, "gcoff", len))
3220 write_symbols = SDB_DEBUG;
3221 #endif /* SDB_DEBUGGING_INFO */
3222 #ifdef XCOFF_DEBUGGING_INFO
3223 if (write_symbols != NO_DEBUG)
3225 else if (!strncmp (str, "g", len))
3226 write_symbols = XCOFF_DEBUG;
3227 else if (!strncmp (str, "ggdb", len))
3228 write_symbols = XCOFF_DEBUG;
3229 else if (!strncmp (str, "gxcoff", len))
3230 write_symbols = XCOFF_DEBUG;
3232 /* Always enable extensions for -ggdb or -gxcoff+,
3233 always disable for -gxcoff.
3234 For plain -g, use system-specific default. */
3235 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3237 use_gnu_debug_info_extensions = 1;
3238 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3239 use_gnu_debug_info_extensions = 1;
3240 else if (write_symbols == XCOFF_DEBUG
3241 && !strncmp (str, "gxcoff", len) && len >= 2)
3242 use_gnu_debug_info_extensions = 0;
3244 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3246 if (write_symbols == NO_DEBUG)
3247 warning ("`-%s' option not supported on this version of GCC", str);
3248 else if (level == 0)
3249 write_symbols = NO_DEBUG;
3251 debug_info_level = (enum debug_info_level) level;
3253 else if (!strcmp (str, "o"))
3255 asm_file_name = argv[++i];
3257 else if (str[0] == 'G')
3259 g_switch_set = TRUE;
3260 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3262 else if (!strncmp (str, "aux-info", 8))
3264 flag_gen_aux_info = 1;
3265 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3268 error ("Invalid option `%s'", argv[i]);
3270 else if (argv[i][0] == '+')
3271 error ("Invalid option `%s'", argv[i]);
3278 /* Inlining does not work if not optimizing,
3279 so force it not to be done. */
3283 /* The c_decode_option and lang_decode_option functions set
3284 this to `2' if -Wall is used, so we can avoid giving out
3285 lots of errors for people who don't realize what -Wall does. */
3286 if (warn_uninitialized == 1)
3287 warning ("-Wuninitialized is not supported without -O");
3290 #ifdef OVERRIDE_OPTIONS
3291 /* Some machines may reject certain combinations of options. */
3295 /* Unrolling all loops implies that standard loop unrolling must also
3297 if (flag_unroll_all_loops)
3298 flag_unroll_loops = 1;
3299 /* Loop unrolling requires that strength_reduction be on also. Silently
3300 turn on strength reduction here if it isn't already on. Also, the loop
3301 unrolling code assumes that cse will be run after loop, so that must
3302 be turned on also. */
3303 if (flag_unroll_loops)
3305 flag_strength_reduce = 1;
3306 flag_rerun_cse_after_loop = 1;
3309 /* Warn about options that are not supported on this machine. */
3310 #ifndef INSN_SCHEDULING
3311 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3312 warning ("instruction scheduling not supported on this target machine");
3315 if (flag_delayed_branch)
3316 warning ("this target machine does not have delayed branches");
3319 /* If we are in verbose mode, write out the version and maybe all the
3320 option flags in use. */
3323 fprintf (stderr, "%s version %s", language_string, version_string);
3324 #ifdef TARGET_VERSION
3329 #define __VERSION__ "[unknown]"
3331 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3333 fprintf (stderr, " compiled by CC.\n");
3336 print_switch_values ();
3339 /* Now that register usage is specified, convert it to HARD_REG_SETs. */
3342 compile_file (filename);
3348 char *lim = (char *) sbrk (0);
3350 fprintf (stderr, "Data size %d.\n",
3351 lim - (char *) &environ);
3355 system ("ps -l 1>&2");
3358 #endif /* not USG */
3360 #endif /* not VMS */
3361 #endif /* not OS2 */
3364 exit (FATAL_EXIT_CODE);
3366 exit (FATAL_EXIT_CODE);
3367 exit (SUCCESS_EXIT_CODE);
3371 /* Decode -m switches. */
3373 /* Here is a table, controlled by the tm.h file, listing each -m switch
3374 and which bits in `target_switches' it should set or clear.
3375 If VALUE is positive, it is bits to set.
3376 If VALUE is negative, -VALUE is bits to clear.
3377 (The sign bit is not used so there is no confusion.) */
3379 struct {char *name; int value;} target_switches []
3382 /* This table is similar, but allows the switch to have a value. */
3384 #ifdef TARGET_OPTIONS
3385 struct {char *prefix; char ** variable;} target_options []
3389 /* Decode the switch -mNAME. */
3392 set_target_switch (name)
3398 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3399 if (!strcmp (target_switches[j].name, name))
3401 if (target_switches[j].value < 0)
3402 target_flags &= ~-target_switches[j].value;
3404 target_flags |= target_switches[j].value;
3408 #ifdef TARGET_OPTIONS
3410 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3412 int len = strlen (target_options[j].prefix);
3413 if (!strncmp (target_options[j].prefix, name, len))
3415 *target_options[j].variable = name + len;
3422 error ("Invalid option `%s'", name);
3425 /* Variable used for communication between the following two routines. */
3427 static int line_position;
3429 /* Print an option value and adjust the position in the line. */
3432 print_single_switch (type, name)
3435 fprintf (stderr, " %s%s", type, name);
3437 line_position += strlen (type) + strlen (name) + 1;
3439 if (line_position > 65)
3441 fprintf (stderr, "\n\t");
3446 /* Print default target switches for -version. */
3449 print_switch_values ()
3453 fprintf (stderr, "enabled:");
3456 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3457 if (*f_options[j].variable == f_options[j].on_value)
3458 print_single_switch ("-f", f_options[j].string);
3460 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
3461 if (*W_options[j].variable == W_options[j].on_value)
3462 print_single_switch ("-W", W_options[j].string);
3464 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3465 if (target_switches[j].name[0] != '\0'
3466 && target_switches[j].value > 0
3467 && ((target_switches[j].value & target_flags)
3468 == target_switches[j].value))
3469 print_single_switch ("-m", target_switches[j].name);
3471 fprintf (stderr, "\n");