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"
56 #ifdef XCOFF_DEBUGGING_INFO
61 /* The extra parameters substantially improve the I/O performance. */
63 VMS_fopen (fname, type)
67 if (strcmp (type, "w") == 0)
68 return fopen (fname, type, "mbc=16", "deq=64", "fop=tef", "shr=nil");
69 return fopen (fname, type, "mbc=16");
71 #define fopen VMS_fopen
74 #ifndef DEFAULT_GDB_EXTENSIONS
75 #define DEFAULT_GDB_EXTENSIONS 1
78 extern int rtx_equal_function_value_matters;
80 #if ! (defined (VMS) && defined (OS2))
81 extern char **environ;
83 extern char *version_string, *language_string;
85 extern void init_lex ();
86 extern void init_decl_processing ();
87 extern void init_obstacks ();
88 extern void init_tree_codes ();
89 extern void init_rtl ();
90 extern void init_optabs ();
91 extern void init_stmt ();
92 extern void init_reg_sets ();
93 extern void dump_flow_info ();
94 extern void dump_sched_info ();
95 extern void dump_local_alloc ();
97 void rest_of_decl_compilation ();
99 void error_with_file_and_line ();
104 void set_target_switch ();
105 static void print_switch_values ();
106 static char *decl_name ();
108 /* Name of program invoked, sans directories. */
112 /* Copy of arguments to main. */
116 /* Name of current original source file (what was input to cpp).
117 This comes from each #-command in the actual input. */
119 char *input_filename;
121 /* Name of top-level original source file (what was input to cpp).
122 This comes from the #-command at the beginning of the actual input.
123 If there isn't any there, then this is the cc1 input file name. */
125 char *main_input_filename;
127 /* Stream for reading from the input file. */
131 /* Current line number in real source file. */
135 /* Stack of currently pending input files. */
137 struct file_stack *input_file_stack;
139 /* Incremented on each change to input_file_stack. */
140 int input_file_stack_tick;
142 /* FUNCTION_DECL for function now being parsed or compiled. */
144 extern tree current_function_decl;
146 /* Name to use as base of names for dump output files. */
148 char *dump_base_name;
150 /* Bit flags that specify the machine subtype we are compiling for.
151 Bits are tested using macros TARGET_... defined in the tm.h file
152 and set by `-m...' switches. Must be defined in rtlanal.c. */
154 extern int target_flags;
156 /* Flags saying which kinds of debugging dump have been requested. */
159 int rtl_dump_and_exit = 0;
160 int jump_opt_dump = 0;
165 int combine_dump = 0;
167 int local_reg_dump = 0;
168 int global_reg_dump = 0;
170 int jump2_opt_dump = 0;
171 int dbr_sched_dump = 0;
172 int flag_print_asm_name = 0;
173 int stack_reg_dump = 0;
175 /* Name for output file of assembly code, specified with -o. */
179 /* Value of the -G xx switch, and whether it was passed or not. */
183 /* Type(s) of debugging information we are producing (if any).
184 See flags.h for the definitions of the different possible
185 types of debugging information. */
186 enum debug_info_type write_symbols = NO_DEBUG;
188 /* Level of debugging information we are producing. See flags.h
189 for the definitions of the different possible levels. */
190 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
192 /* Nonzero means use GNU-only extensions in the generated symbolic
193 debugging information. */
194 /* Currently, this only has an effect when write_symbols is set to
195 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
196 int use_gnu_debug_info_extensions = 0;
198 /* Nonzero means do optimizations. -O.
199 Particular numeric values stand for particular amounts of optimization;
200 thus, -O2 stores 2 here. However, the optimizations beyond the basic
201 ones are not controlled directly by this variable. Instead, they are
202 controlled by individual `flag_...' variables that are defaulted
203 based on this variable. */
207 /* Number of error messages and warning messages so far. */
210 int warningcount = 0;
213 /* Pointer to function to compute the name to use to print a declaration. */
215 char *(*decl_printable_name) ();
217 /* Pointer to function to compute rtl for a language-specific tree code. */
219 struct rtx_def *(*lang_expand_expr) ();
221 /* Nonzero if generating code to do profiling. */
223 int profile_flag = 0;
225 /* Nonzero if generating code to do profiling on a line-by-line basis. */
227 int profile_block_flag;
229 /* Nonzero for -pedantic switch: warn about anything
230 that standard spec forbids. */
234 /* Temporarily suppress certain warnings.
235 This is set while reading code from a system header file. */
237 int in_system_header = 0;
239 /* Nonzero means do stupid register allocation.
240 Currently, this is 1 if `optimize' is 0. */
242 int obey_regdecls = 0;
244 /* Don't print functions as they are compiled and don't print
245 times taken by the various passes. -quiet. */
251 /* Nonzero means `char' should be signed. */
253 int flag_signed_char;
255 /* Nonzero means give an enum type only as many bytes as it needs. */
257 int flag_short_enums;
259 /* Nonzero for -fcaller-saves: allocate values in regs that need to
260 be saved across function calls, if that produces overall better code.
261 Optional now, so people can test it. */
263 #ifdef DEFAULT_CALLER_SAVES
264 int flag_caller_saves = 1;
266 int flag_caller_saves = 0;
269 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
271 int flag_pcc_struct_return = 0;
273 /* Nonzero for -fforce-mem: load memory value into a register
274 before arithmetic on it. This makes better cse but slower compilation. */
276 int flag_force_mem = 0;
278 /* Nonzero for -fforce-addr: load memory address into a register before
279 reference to memory. This makes better cse but slower compilation. */
281 int flag_force_addr = 0;
283 /* Nonzero for -fdefer-pop: don't pop args after each function call;
284 instead save them up to pop many calls' args with one insns. */
286 int flag_defer_pop = 1;
288 /* Nonzero for -ffloat-store: don't allocate floats and doubles
289 in extended-precision registers. */
291 int flag_float_store = 0;
293 /* Nonzero for -fcse-follow-jumps:
294 have cse follow jumps to do a more extensive job. */
296 int flag_cse_follow_jumps;
298 /* Nonzero for -fcse-skip-blocks:
299 have cse follow a branch around a block. */
300 int flag_cse_skip_blocks;
302 /* Nonzero for -fexpensive-optimizations:
303 perform miscellaneous relatively-expensive optimizations. */
304 int flag_expensive_optimizations;
306 /* Nonzero for -fthread-jumps:
307 have jump optimize output of loop. */
309 int flag_thread_jumps;
311 /* Nonzero enables strength-reduction in loop.c. */
313 int flag_strength_reduce = 0;
315 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
316 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
317 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
320 int flag_unroll_loops;
322 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
323 This is generally not a win. */
325 int flag_unroll_all_loops;
327 /* Nonzero for -fwritable-strings:
328 store string constants in data segment and don't uniquize them. */
330 int flag_writable_strings = 0;
332 /* Nonzero means don't put addresses of constant functions in registers.
333 Used for compiling the Unix kernel, where strange substitutions are
334 done on the assembly output. */
336 int flag_no_function_cse = 0;
338 /* Nonzero for -fomit-frame-pointer:
339 don't make a frame pointer in simple functions that don't require one. */
341 int flag_omit_frame_pointer = 0;
343 /* Nonzero to inhibit use of define_optimization peephole opts. */
345 int flag_no_peephole = 0;
347 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
348 operations in the interest of optimization. For example it allows
349 GCC to assume arguments to sqrt are nonnegative numbers, allowing
350 faster code for sqrt to be generated. */
352 int flag_fast_math = 0;
354 /* Nonzero means all references through pointers are volatile. */
358 /* Nonzero means just do syntax checking; don't output anything. */
360 int flag_syntax_only = 0;
362 /* Nonzero means to rerun cse after loop optimization. This increases
363 compilation time about 20% and picks up a few more common expressions. */
365 static int flag_rerun_cse_after_loop;
367 /* Nonzero for -finline-functions: ok to inline functions that look like
368 good inline candidates. */
370 int flag_inline_functions;
372 /* Nonzero for -fkeep-inline-functions: even if we make a function
373 go inline everywhere, keep its defintion around for debugging
376 int flag_keep_inline_functions;
378 /* Nonzero means that functions declared `inline' will be treated
379 as `static'. Prevents generation of zillions of copies of unused
380 static inline functions; instead, `inlines' are written out
381 only when actually used. Used in conjunction with -g. Also
382 does the right thing with #pragma interface. */
386 /* Nonzero means we should be saving declaration info into a .X file. */
388 int flag_gen_aux_info = 0;
390 /* Specified name of aux-info file. */
392 static char *aux_info_file_name;
394 /* Nonzero means make the text shared if supported. */
396 int flag_shared_data;
398 /* Nonzero means schedule into delayed branch slots if supported. */
400 int flag_delayed_branch;
402 /* Nonzero if we are compiling pure (sharable) code.
403 Value is 1 if we are doing reasonable (i.e. simple
404 offset into offset table) pic. Value is 2 if we can
405 only perform register offsets. */
409 /* Nonzero means place uninitialized global data in the bss section. */
413 /* Nonzero means pretend it is OK to examine bits of target floats,
414 even if that isn't true. The resulting code will have incorrect constants,
415 but the same series of instructions that the native compiler would make. */
417 int flag_pretend_float;
419 /* Nonzero means change certain warnings into errors.
420 Usually these are warnings about failure to conform to some standard. */
422 int flag_pedantic_errors = 0;
424 /* flag_schedule_insns means schedule insns within basic blocks (before
426 flag_schedule_insns_after_reload means schedule insns after
429 int flag_schedule_insns = 0;
430 int flag_schedule_insns_after_reload = 0;
432 /* -finhibit-size-directive inhibits output of .size for ELF.
433 This is used only for compiling crtstuff.c,
434 and it may be extended to other effects
435 needed for crtstuff.c on other systems. */
436 int flag_inhibit_size_directive = 0;
438 /* -fverbose-asm causes extra commentary information to be produced in
439 the generated assembly code (to make it more readable). This option
440 is generally only of use to those who actually need to read the
441 generated assembly code (perhaps while debugging the compiler itself). */
443 int flag_verbose_asm = 0;
445 /* -fgnu-linker specifies use of the GNU linker for initializations.
446 (Or, more generally, a linker that handles initializations.)
447 -fno-gnu-linker says that collect2 will be used. */
449 int flag_gnu_linker = 0;
451 int flag_gnu_linker = 1;
454 /* Table of language-independent -f options.
455 STRING is the option name. VARIABLE is the address of the variable.
456 ON_VALUE is the value to store in VARIABLE
457 if `-fSTRING' is seen as an option.
458 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
460 struct { char *string; int *variable; int on_value;} f_options[] =
462 {"float-store", &flag_float_store, 1},
463 {"volatile", &flag_volatile, 1},
464 {"defer-pop", &flag_defer_pop, 1},
465 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
466 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
467 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
468 {"expensive-optimizations", &flag_expensive_optimizations, 1},
469 {"thread-jumps", &flag_thread_jumps, 1},
470 {"strength-reduce", &flag_strength_reduce, 1},
471 {"unroll-loops", &flag_unroll_loops, 1},
472 {"unroll-all-loops", &flag_unroll_all_loops, 1},
473 {"writable-strings", &flag_writable_strings, 1},
474 {"peephole", &flag_no_peephole, 0},
475 {"force-mem", &flag_force_mem, 1},
476 {"force-addr", &flag_force_addr, 1},
477 {"function-cse", &flag_no_function_cse, 0},
478 {"inline-functions", &flag_inline_functions, 1},
479 {"keep-inline-functions", &flag_keep_inline_functions, 1},
480 {"inline", &flag_no_inline, 0},
481 {"syntax-only", &flag_syntax_only, 1},
482 {"shared-data", &flag_shared_data, 1},
483 {"caller-saves", &flag_caller_saves, 1},
484 {"pcc-struct-return", &flag_pcc_struct_return, 1},
485 {"delayed-branch", &flag_delayed_branch, 1},
486 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
487 {"pretend-float", &flag_pretend_float, 1},
488 {"schedule-insns", &flag_schedule_insns, 1},
489 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
490 {"pic", &flag_pic, 1},
491 {"PIC", &flag_pic, 2},
492 {"fast-math", &flag_fast_math, 1},
493 {"common", &flag_no_common, 0},
494 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
495 {"verbose-asm", &flag_verbose_asm, 1},
496 {"gnu-linker", &flag_gnu_linker, 1}
499 /* Options controlling warnings */
501 /* Don't print warning messages. -w. */
503 int inhibit_warnings = 0;
505 /* Print various extra warnings. -W. */
507 int extra_warnings = 0;
509 /* Treat warnings as errors. -Werror. */
511 int warnings_are_errors = 0;
513 /* Nonzero to warn about unused local variables. */
517 /* Nonzero to warn about variables used before they are initialized. */
519 int warn_uninitialized;
521 /* Nonzero means warn about all declarations which shadow others. */
525 /* Warn if a switch on an enum fails to have a case for every enum value. */
529 /* Nonzero means warn about function definitions that default the return type
530 or that use a null return and have a return-type other than void. */
532 int warn_return_type;
534 /* Nonzero means warn about pointer casts that increase the required
535 alignment of the target type (and might therefore lead to a crash
536 due to a misaligned access). */
540 /* Nonzero means warn about any identifiers that match in the first N
541 characters. The value N is in `id_clash_len'. */
546 /* Nonzero means warn if inline function is too large. */
550 /* Warn if a function returns an aggregate,
551 since there are often incompatible calling conventions for doing this. */
553 int warn_aggregate_return;
555 /* Likewise for -W. */
557 struct { char *string; int *variable; int on_value;} W_options[] =
559 {"unused", &warn_unused, 1},
560 {"error", &warnings_are_errors, 1},
561 {"shadow", &warn_shadow, 1},
562 {"switch", &warn_switch, 1},
563 {"return-type", &warn_return_type, 1},
564 {"aggregate-return", &warn_aggregate_return, 1},
565 {"cast-align", &warn_cast_align, 1},
566 {"uninitialized", &warn_uninitialized, 1},
567 {"inline", &warn_inline, 1}
570 /* Output files for assembler code (real compiler output)
571 and debugging dumps. */
576 FILE *jump_opt_dump_file;
578 FILE *loop_dump_file;
579 FILE *cse2_dump_file;
580 FILE *flow_dump_file;
581 FILE *combine_dump_file;
582 FILE *sched_dump_file;
583 FILE *local_reg_dump_file;
584 FILE *global_reg_dump_file;
585 FILE *sched2_dump_file;
586 FILE *jump2_opt_dump_file;
587 FILE *dbr_sched_dump_file;
588 FILE *stack_reg_dump_file;
590 /* Time accumulators, to count the total time spent in various passes. */
594 int integration_time;
602 int local_alloc_time;
603 int global_alloc_time;
606 int shorten_branch_time;
612 /* Return time used so far, in microseconds. */
621 struct rusage rusage;
626 int proc_system_time;
628 int child_system_time;
638 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
641 getrusage (0, &rusage);
642 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
643 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
646 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
651 #define TIMEVAR(VAR, BODY) \
652 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
655 print_time (str, total)
660 "time in %s: %d.%06d\n",
661 str, total / 1000000, total % 1000000);
664 /* Count an error or warning. Return 1 if the message should be printed. */
667 count_error (warningp)
670 if (warningp && inhibit_warnings)
673 if (warningp && !warnings_are_errors)
677 static int warning_message = 0;
679 if (warningp && !warning_message)
681 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
690 /* Print a fatal error message. NAME is the text.
691 Also include a system error message based on `errno'. */
694 pfatal_with_name (name)
697 fprintf (stderr, "%s: ", progname);
703 fatal_io_error (name)
706 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
719 /* Called to give a better error message when we don't have an insn to match
720 what we are looking for or if the insn's constraints aren't satisfied,
721 rather than just calling abort(). */
724 fatal_insn_not_found (insn)
727 if (INSN_CODE (insn) < 0)
728 error ("internal error--unrecognizable insn:", 0);
730 error ("internal error--insn does not satisfy its constraints:", 0);
733 fflush (asm_out_file);
735 fflush (aux_info_file);
737 fflush (rtl_dump_file);
738 if (jump_opt_dump_file)
739 fflush (jump_opt_dump_file);
741 fflush (cse_dump_file);
743 fflush (loop_dump_file);
745 fflush (cse2_dump_file);
747 fflush (flow_dump_file);
748 if (combine_dump_file)
749 fflush (combine_dump_file);
751 fflush (sched_dump_file);
752 if (local_reg_dump_file)
753 fflush (local_reg_dump_file);
754 if (global_reg_dump_file)
755 fflush (global_reg_dump_file);
756 if (sched2_dump_file)
757 fflush (sched2_dump_file);
758 if (jump2_opt_dump_file)
759 fflush (jump2_opt_dump_file);
760 if (dbr_sched_dump_file)
761 fflush (dbr_sched_dump_file);
762 if (stack_reg_dump_file)
763 fflush (stack_reg_dump_file);
767 /* This is the default decl_printable_name function. */
770 decl_name (decl, kind)
774 return IDENTIFIER_POINTER (DECL_NAME (decl));
777 static int need_error_newline;
779 /* Function of last error message;
780 more generally, function such that if next error message is in it
781 then we don't have to mention the function name. */
782 static tree last_error_function = NULL;
784 /* Used to detect when input_file_stack has changed since last described. */
785 static int last_error_tick;
787 /* Called when the start of a function definition is parsed,
788 this function prints on stderr the name of the function. */
791 announce_function (decl)
797 if (rtl_dump_and_exit)
798 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
800 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
802 need_error_newline = 1;
803 last_error_function = current_function_decl;
807 /* Prints out, if necessary, the name of the current function
808 which caused an error. Called from all error and warning functions. */
811 report_error_function (file)
814 struct file_stack *p;
816 if (need_error_newline)
818 fprintf (stderr, "\n");
819 need_error_newline = 0;
822 if (last_error_function != current_function_decl)
824 char *kind = "function";
825 if (current_function_decl != 0
826 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
830 fprintf (stderr, "%s: ", file);
832 if (current_function_decl == NULL)
833 fprintf (stderr, "At top level:\n");
836 char *name = (*decl_printable_name) (current_function_decl, &kind);
837 fprintf (stderr, "In %s `%s':\n", kind, name);
840 last_error_function = current_function_decl;
842 if (input_file_stack && input_file_stack->next != 0
843 && input_file_stack_tick != last_error_tick)
845 fprintf (stderr, "In file included");
846 for (p = input_file_stack->next; p; p = p->next)
848 fprintf (stderr, " from %s:%d", p->name, p->line);
850 fprintf (stderr, ",");
852 fprintf (stderr, ":\n");
853 last_error_tick = input_file_stack_tick;
857 /* Report an error at the current line number.
858 S is a string and V and V2 are args for `printf'. We use HOST_WIDE_INT
859 as the type for these args assuming it is wide enough to hold a
860 pointer. This isn't terribly portable, but is the best we can do
861 without vprintf universally available. */
866 HOST_WIDE_INT v; /* Also used as pointer */
867 HOST_WIDE_INT v2; /* Also used as pointer */
869 error_with_file_and_line (input_filename, lineno, s, v, v2);
872 /* Report an error at line LINE of file FILE.
873 S and V are a string and an arg for `printf'. */
876 error_with_file_and_line (file, line, s, v, v2)
885 report_error_function (file);
888 fprintf (stderr, "%s:%d: ", file, line);
890 fprintf (stderr, "%s: ", progname);
891 fprintf (stderr, s, v, v2);
892 fprintf (stderr, "\n");
895 /* Report an error at the declaration DECL.
896 S and V are a string and an arg which uses %s to substitute
897 the declaration name. */
900 error_with_decl (decl, s, v)
908 report_error_function (DECL_SOURCE_FILE (decl));
910 fprintf (stderr, "%s:%d: ",
911 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
913 if (DECL_NAME (decl))
914 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
916 fprintf (stderr, s, "((anonymous))", v);
917 fprintf (stderr, "\n");
920 /* Report an error at the line number of the insn INSN.
921 S and V are a string and an arg for `printf'.
922 This is used only when INSN is an `asm' with operands,
923 and each ASM_OPERANDS records its own source file and line. */
926 error_for_asm (insn, s, v, v2)
929 HOST_WIDE_INT v; /* Also used as pointer */
930 HOST_WIDE_INT v2; /* Also used as pointer */
934 rtx body = PATTERN (insn);
937 /* Find the (or one of the) ASM_OPERANDS in the insn. */
938 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
939 asmop = SET_SRC (body);
940 else if (GET_CODE (body) == ASM_OPERANDS)
942 else if (GET_CODE (body) == PARALLEL
943 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
944 asmop = SET_SRC (XVECEXP (body, 0, 0));
945 else if (GET_CODE (body) == PARALLEL
946 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
947 asmop = XVECEXP (body, 0, 0);
949 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
950 line = ASM_OPERANDS_SOURCE_LINE (asmop);
952 error_with_file_and_line (filename, line, s, v, v2);
955 /* Report a warning at line LINE.
956 S and V are a string and an arg for `printf'. */
959 warning_with_file_and_line (file, line, s, v, v2, v3)
963 HOST_WIDE_INT v, v2, v3;
965 if (count_error (1) == 0)
968 report_error_function (file);
971 fprintf (stderr, "%s:%d: ", file, line);
973 fprintf (stderr, "%s: ", progname);
975 fprintf (stderr, "warning: ");
976 fprintf (stderr, s, v, v2, v3);
977 fprintf (stderr, "\n");
980 /* Report a warning at the current line number.
981 S and V are a string and an arg for `printf'. */
984 warning (s, v, v2, v3)
986 HOST_WIDE_INT v, v2, v3; /* Also used as pointer */
988 warning_with_file_and_line (input_filename, lineno, s, v, v2, v3);
991 /* Report a warning at the declaration DECL.
992 S is string which uses %s to substitute the declaration name.
993 V is a second parameter that S can refer to. */
996 warning_with_decl (decl, s, v)
1003 if (count_error (1) == 0)
1006 report_error_function (DECL_SOURCE_FILE (decl));
1008 fprintf (stderr, "%s:%d: ",
1009 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1011 fprintf (stderr, "warning: ");
1012 if (DECL_NAME (decl))
1013 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1015 fprintf (stderr, s, "((anonymous))", v);
1016 fprintf (stderr, "\n");
1019 /* Report a warning at the line number of the insn INSN.
1020 S and V are a string and an arg for `printf'.
1021 This is used only when INSN is an `asm' with operands,
1022 and each ASM_OPERANDS records its own source file and line. */
1025 warning_for_asm (insn, s, v, v2)
1028 HOST_WIDE_INT v; /* Also used as pointer */
1029 HOST_WIDE_INT v2; /* Also used as pointer */
1033 rtx body = PATTERN (insn);
1036 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1037 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1038 asmop = SET_SRC (body);
1039 else if (GET_CODE (body) == ASM_OPERANDS)
1041 else if (GET_CODE (body) == PARALLEL
1042 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1043 asmop = SET_SRC (XVECEXP (body, 0, 0));
1044 else if (GET_CODE (body) == PARALLEL
1045 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1046 asmop = XVECEXP (body, 0, 0);
1048 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1049 line = ASM_OPERANDS_SOURCE_LINE (asmop);
1051 warning_with_file_and_line (filename, line, s, v, v2);
1054 /* These functions issue either warnings or errors depending on
1055 -pedantic-errors. */
1060 HOST_WIDE_INT v; /* Also used as pointer */
1063 if (flag_pedantic_errors)
1070 pedwarn_with_decl (decl, s, v)
1075 if (flag_pedantic_errors)
1076 error_with_decl (decl, s, v);
1078 warning_with_decl (decl, s, v);
1082 pedwarn_with_file_and_line (file, line, s, v, v2)
1089 if (flag_pedantic_errors)
1090 error_with_file_and_line (file, line, s, v, v2);
1092 warning_with_file_and_line (file, line, s, v, v2);
1095 /* Apologize for not implementing some feature.
1096 S, V, and V2 are a string and args for `printf'. */
1101 HOST_WIDE_INT v, v2;
1105 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1107 fprintf (stderr, "%s: ", progname);
1109 fprintf (stderr, "sorry, not implemented: ");
1110 fprintf (stderr, s, v, v2);
1111 fprintf (stderr, "\n");
1114 /* Apologize for not implementing some feature, then quit.
1115 S, V, and V2 are a string and args for `printf'. */
1118 really_sorry (s, v, v2)
1120 HOST_WIDE_INT v, v2;
1123 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1125 fprintf (stderr, "c++: ");
1127 fprintf (stderr, "sorry, not implemented: ");
1128 fprintf (stderr, s, v, v2);
1129 fatal (" (fatal)\n");
1132 /* More 'friendly' abort that prints the line and file.
1133 config.h can #define abort fancy_abort if you like that sort of thing.
1135 I don't think this is actually a good idea.
1136 Other sorts of crashes will look a certain way.
1137 It is a good thing if crashes from calling abort look the same way.
1143 fatal ("internal gcc abort");
1146 /* This calls abort and is used to avoid problems when abort if a macro.
1147 It is used when we need to pass the address of abort. */
1155 /* When `malloc.c' is compiled with `rcheck' defined,
1156 it calls this function to report clobberage. */
1164 /* Same as `malloc' but report error if no memory available. */
1170 register char *value = (char *) malloc (size);
1172 fatal ("virtual memory exhausted");
1176 /* Same as `realloc' but report error if no memory available. */
1179 xrealloc (ptr, size)
1183 char *result = (char *) realloc (ptr, size);
1185 fatal ("virtual memory exhausted");
1189 /* Return the logarithm of X, base 2, considering X unsigned,
1190 if X is a power of 2. Otherwise, returns -1.
1192 This should be used via the `exact_log2' macro. */
1196 register unsigned HOST_WIDE_INT x;
1198 register int log = 0;
1199 /* Test for 0 or a power of 2. */
1200 if (x == 0 || x != (x & -x))
1202 while ((x >>= 1) != 0)
1207 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1208 If X is 0, return -1.
1210 This should be used via the floor_log2 macro. */
1214 register unsigned HOST_WIDE_INT x;
1216 register int log = -1;
1224 jmp_buf float_handler;
1226 /* Specify where to longjmp to when a floating arithmetic error happens.
1227 If HANDLER is 0, it means don't handle the errors any more. */
1230 set_float_handler (handler)
1233 float_handled = (handler != 0);
1235 bcopy (handler, float_handler, sizeof (float_handler));
1238 /* Signals actually come here. */
1241 float_signal (signo)
1242 /* If this is missing, some compilers complain. */
1245 if (float_handled == 0)
1247 #if defined (USG) || defined (hpux)
1248 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1251 signal (SIGFPE, float_signal);
1252 longjmp (float_handler, 1);
1255 /* Handler for SIGPIPE. */
1259 /* If this is missing, some compilers complain. */
1262 fatal ("output pipe has been closed");
1265 /* Strip off a legitimate source ending from the input string NAME of
1269 strip_off_ending (name, len)
1273 if (len > 2 && ! strcmp (".c", name + len - 2))
1275 else if (len > 2 && ! strcmp (".m", name + len - 2))
1277 else if (len > 2 && ! strcmp (".i", name + len - 2))
1279 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1281 else if (len > 3 && ! strcmp (".co", name + len - 3))
1283 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1285 else if (len > 2 && ! strcmp (".C", name + len - 2))
1287 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1289 else if (len > 2 && ! strcmp (".f", name + len - 2))
1291 else if (len > 4 && ! strcmp (".ada", name + len - 4))
1295 /* Output a file name in the form wanted by System V. */
1298 output_file_directive (asm_file, input_name)
1302 int len = strlen (input_name);
1303 char *na = input_name + len;
1305 /* NA gets INPUT_NAME sans directory names. */
1306 while (na > input_name)
1313 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1314 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1316 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1317 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1319 fprintf (asm_file, "\t.file\t\"%s\"\n", na);
1324 /* Compile an entire file of output from cpp, named NAME.
1325 Write a file of assembly output and various debugging dumps. */
1333 int dump_base_name_length;
1335 int name_specified = name != 0;
1337 if (dump_base_name == 0)
1338 dump_base_name = name ? name : "gccdump";
1339 dump_base_name_length = strlen (dump_base_name);
1343 integration_time = 0;
1351 local_alloc_time = 0;
1352 global_alloc_time = 0;
1355 shorten_branch_time = 0;
1361 /* Open input file. */
1363 if (name == 0 || !strcmp (name, "-"))
1369 finput = fopen (name, "r");
1371 pfatal_with_name (name);
1373 #ifdef IO_BUFFER_SIZE
1374 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
1377 /* Initialize data in various passes. */
1383 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
1384 || debug_info_level == DINFO_LEVEL_VERBOSE);
1385 init_decl_processing ();
1393 if (flag_caller_saves)
1394 init_caller_save ();
1396 /* If auxiliary info generation is desired, open the output file.
1397 This goes in the same directory as the source file--unlike
1398 all the other output files. */
1399 if (flag_gen_aux_info)
1401 aux_info_file = fopen (aux_info_file_name, "w");
1402 if (aux_info_file == 0)
1403 pfatal_with_name (aux_info_file_name);
1406 /* If rtl dump desired, open the output file. */
1409 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1410 strcpy (dumpname, dump_base_name);
1411 strcat (dumpname, ".rtl");
1412 rtl_dump_file = fopen (dumpname, "w");
1413 if (rtl_dump_file == 0)
1414 pfatal_with_name (dumpname);
1417 /* If jump_opt dump desired, open the output file. */
1420 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1421 strcpy (dumpname, dump_base_name);
1422 strcat (dumpname, ".jump");
1423 jump_opt_dump_file = fopen (dumpname, "w");
1424 if (jump_opt_dump_file == 0)
1425 pfatal_with_name (dumpname);
1428 /* If cse dump desired, open the output file. */
1431 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1432 strcpy (dumpname, dump_base_name);
1433 strcat (dumpname, ".cse");
1434 cse_dump_file = fopen (dumpname, "w");
1435 if (cse_dump_file == 0)
1436 pfatal_with_name (dumpname);
1439 /* If loop dump desired, open the output file. */
1442 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1443 strcpy (dumpname, dump_base_name);
1444 strcat (dumpname, ".loop");
1445 loop_dump_file = fopen (dumpname, "w");
1446 if (loop_dump_file == 0)
1447 pfatal_with_name (dumpname);
1450 /* If cse2 dump desired, open the output file. */
1453 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1454 strcpy (dumpname, dump_base_name);
1455 strcat (dumpname, ".cse2");
1456 cse2_dump_file = fopen (dumpname, "w");
1457 if (cse2_dump_file == 0)
1458 pfatal_with_name (dumpname);
1461 /* If flow dump desired, open the output file. */
1464 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1465 strcpy (dumpname, dump_base_name);
1466 strcat (dumpname, ".flow");
1467 flow_dump_file = fopen (dumpname, "w");
1468 if (flow_dump_file == 0)
1469 pfatal_with_name (dumpname);
1472 /* If combine dump desired, open the output file. */
1475 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1476 strcpy (dumpname, dump_base_name);
1477 strcat (dumpname, ".combine");
1478 combine_dump_file = fopen (dumpname, "w");
1479 if (combine_dump_file == 0)
1480 pfatal_with_name (dumpname);
1483 /* If scheduling dump desired, open the output file. */
1486 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1487 strcpy (dumpname, dump_base_name);
1488 strcat (dumpname, ".sched");
1489 sched_dump_file = fopen (dumpname, "w");
1490 if (sched_dump_file == 0)
1491 pfatal_with_name (dumpname);
1494 /* If local_reg dump desired, open the output file. */
1497 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1498 strcpy (dumpname, dump_base_name);
1499 strcat (dumpname, ".lreg");
1500 local_reg_dump_file = fopen (dumpname, "w");
1501 if (local_reg_dump_file == 0)
1502 pfatal_with_name (dumpname);
1505 /* If global_reg dump desired, open the output file. */
1506 if (global_reg_dump)
1508 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1509 strcpy (dumpname, dump_base_name);
1510 strcat (dumpname, ".greg");
1511 global_reg_dump_file = fopen (dumpname, "w");
1512 if (global_reg_dump_file == 0)
1513 pfatal_with_name (dumpname);
1516 /* If 2nd scheduling dump desired, open the output file. */
1519 register char *dumpname = (char *) xmalloc (dump_base_name_length + 8);
1520 strcpy (dumpname, dump_base_name);
1521 strcat (dumpname, ".sched2");
1522 sched2_dump_file = fopen (dumpname, "w");
1523 if (sched2_dump_file == 0)
1524 pfatal_with_name (dumpname);
1527 /* If jump2_opt dump desired, open the output file. */
1530 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1531 strcpy (dumpname, dump_base_name);
1532 strcat (dumpname, ".jump2");
1533 jump2_opt_dump_file = fopen (dumpname, "w");
1534 if (jump2_opt_dump_file == 0)
1535 pfatal_with_name (dumpname);
1538 /* If dbr_sched dump desired, open the output file. */
1541 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1542 strcpy (dumpname, dump_base_name);
1543 strcat (dumpname, ".dbr");
1544 dbr_sched_dump_file = fopen (dumpname, "w");
1545 if (dbr_sched_dump_file == 0)
1546 pfatal_with_name (dumpname);
1551 /* If stack_reg dump desired, open the output file. */
1554 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1555 strcpy (dumpname, dump_base_name);
1556 strcat (dumpname, ".stack");
1557 stack_reg_dump_file = fopen (dumpname, "w");
1558 if (stack_reg_dump_file == 0)
1559 pfatal_with_name (dumpname);
1564 /* Open assembler code output file. */
1566 if (! name_specified && asm_file_name == 0)
1567 asm_out_file = stdout;
1570 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1571 int len = strlen (dump_base_name);
1572 strcpy (dumpname, dump_base_name);
1573 strip_off_ending (dumpname, len);
1574 strcat (dumpname, ".s");
1575 if (asm_file_name == 0)
1577 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
1578 strcpy (asm_file_name, dumpname);
1580 if (!strcmp (asm_file_name, "-"))
1581 asm_out_file = stdout;
1583 asm_out_file = fopen (asm_file_name, "w");
1584 if (asm_out_file == 0)
1585 pfatal_with_name (asm_file_name);
1588 #ifdef IO_BUFFER_SIZE
1589 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
1590 _IOFBF, IO_BUFFER_SIZE);
1593 input_filename = name;
1595 /* Perform language-specific initialization.
1596 This may set main_input_filename. */
1599 /* If the input doesn't start with a #line, use the input name
1600 as the official input file name. */
1601 if (main_input_filename == 0)
1602 main_input_filename = name;
1604 /* Put an entry on the input file stack for the main input file. */
1606 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
1607 input_file_stack->next = 0;
1608 input_file_stack->name = input_filename;
1610 ASM_FILE_START (asm_out_file);
1612 /* Output something to inform GDB that this compilation was by GCC. */
1613 #ifndef ASM_IDENTIFY_GCC
1614 fprintf (asm_out_file, "gcc2_compiled.:\n");
1616 ASM_IDENTIFY_GCC (asm_out_file);
1618 /* Don't let the first function fall at the same address
1619 as gcc_compiled., if profiling. */
1620 if (profile_flag || profile_block_flag)
1621 assemble_zeros (UNITS_PER_WORD);
1623 /* If dbx symbol table desired, initialize writing it
1624 and output the predefined types. */
1625 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1626 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1627 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
1630 #ifdef SDB_DEBUGGING_INFO
1631 if (write_symbols == SDB_DEBUG)
1632 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
1635 #ifdef DWARF_DEBUGGING_INFO
1636 if (write_symbols == DWARF_DEBUG)
1637 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
1640 /* Initialize yet another pass. */
1642 init_final (main_input_filename);
1644 start_time = get_run_time ();
1646 /* Call the parser, which parses the entire file
1647 (calling rest_of_compilation for each function). */
1649 if (yyparse () != 0)
1650 if (errorcount == 0)
1651 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
1653 /* Compilation is now finished except for writing
1654 what's left of the symbol table output. */
1656 parse_time += get_run_time () - start_time;
1658 parse_time -= integration_time;
1659 parse_time -= varconst_time;
1661 globals = getdecls ();
1663 /* Really define vars that have had only a tentative definition.
1664 Really output inline functions that must actually be callable
1665 and have not been output so far. */
1668 int len = list_length (globals);
1669 tree *vec = (tree *) alloca (sizeof (tree) * len);
1673 /* Process the decls in reverse order--earliest first.
1674 Put them into VEC from back to front, then take out from front. */
1676 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
1677 vec[len - i - 1] = decl;
1679 for (i = 0; i < len; i++)
1682 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1683 && ! TREE_ASM_WRITTEN (decl))
1685 /* Don't write out static consts, unless we used them.
1686 (This used to write them out only if the address was
1687 taken, but that was wrong; if the variable was simply
1688 referred to, it still needs to exist or else it will
1689 be undefined in the linker.) */
1690 if (! TREE_READONLY (decl)
1691 || TREE_PUBLIC (decl)
1693 || TREE_ADDRESSABLE (decl)
1694 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1695 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1697 /* Cancel the RTL for this decl so that, if debugging info
1698 output for global variables is still to come,
1699 this one will be omitted. */
1700 DECL_RTL (decl) = NULL;
1703 if (TREE_CODE (decl) == FUNCTION_DECL
1704 && ! TREE_ASM_WRITTEN (decl)
1705 && DECL_INITIAL (decl) != 0
1706 && (TREE_ADDRESSABLE (decl)
1707 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1708 && ! DECL_EXTERNAL (decl))
1709 output_inline_function (decl);
1711 /* Warn about any function
1712 declared static but not defined.
1713 We don't warn about variables,
1714 because many programs have static variables
1715 that exist only to get some text into the object file. */
1718 || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))))
1719 && TREE_CODE (decl) == FUNCTION_DECL
1720 && DECL_INITIAL (decl) == 0
1721 && DECL_EXTERNAL (decl)
1722 && ! TREE_PUBLIC (decl))
1723 warning_with_decl (decl, "`%s' declared `static' but never defined");
1724 /* Warn about static fns or vars defined but not used,
1725 but not about inline functions
1726 since unused inline statics is normal practice. */
1728 && (TREE_CODE (decl) == FUNCTION_DECL
1729 || TREE_CODE (decl) == VAR_DECL)
1730 && ! DECL_IN_SYSTEM_HEADER (decl)
1731 && ! DECL_EXTERNAL (decl)
1732 && ! TREE_PUBLIC (decl)
1733 && ! TREE_USED (decl)
1734 && ! DECL_INLINE (decl)
1735 /* The TREE_USED bit for file-scope decls
1736 is kept in the identifier, to handle multiple
1737 external decls in different scopes. */
1738 && ! TREE_USED (DECL_NAME (decl)))
1739 warning_with_decl (decl, "`%s' defined but not used");
1741 #ifdef SDB_DEBUGGING_INFO
1742 /* The COFF linker can move initialized global vars to the end.
1743 And that can screw up the symbol ordering.
1744 By putting the symbols in that order to begin with,
1745 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1746 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
1747 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
1748 && DECL_RTL (decl) != 0)
1749 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1751 /* Output COFF information for non-global
1752 file-scope initialized variables. */
1753 if (write_symbols == SDB_DEBUG
1754 && TREE_CODE (decl) == VAR_DECL
1755 && DECL_INITIAL (decl)
1756 && DECL_RTL (decl) != 0
1757 && GET_CODE (DECL_RTL (decl)) == MEM)
1758 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
1759 #endif /* SDB_DEBUGGING_INFO */
1760 #ifdef DWARF_DEBUGGING_INFO
1761 /* Output DWARF information for file-scope tentative data object
1762 declarations, file-scope (extern) function declarations (which
1763 had no corresponding body) and file-scope tagged type declarations
1764 and definitions which have not yet been forced out. */
1766 if (write_symbols == DWARF_DEBUG
1767 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1768 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
1773 /* Do dbx symbols */
1774 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1775 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1776 TIMEVAR (symout_time,
1778 dbxout_finish (asm_out_file, main_input_filename);
1782 #ifdef DWARF_DEBUGGING_INFO
1783 if (write_symbols == DWARF_DEBUG)
1784 TIMEVAR (symout_time,
1790 /* Output some stuff at end of file if nec. */
1792 end_final (main_input_filename);
1795 ASM_FILE_END (asm_out_file);
1798 after_finish_compilation:
1800 /* Language-specific end of compilation actions. */
1804 /* Close the dump files. */
1806 if (flag_gen_aux_info)
1808 fclose (aux_info_file);
1810 unlink (aux_info_file_name);
1814 fclose (rtl_dump_file);
1817 fclose (jump_opt_dump_file);
1820 fclose (cse_dump_file);
1823 fclose (loop_dump_file);
1826 fclose (cse2_dump_file);
1829 fclose (flow_dump_file);
1833 dump_combine_total_stats (combine_dump_file);
1834 fclose (combine_dump_file);
1838 fclose (sched_dump_file);
1841 fclose (local_reg_dump_file);
1843 if (global_reg_dump)
1844 fclose (global_reg_dump_file);
1847 fclose (sched2_dump_file);
1850 fclose (jump2_opt_dump_file);
1853 fclose (dbr_sched_dump_file);
1857 fclose (stack_reg_dump_file);
1860 /* Close non-debugging input and output files. Take special care to note
1861 whether fclose returns an error, since the pages might still be on the
1862 buffer chain while the file is open. */
1865 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
1866 fatal_io_error (asm_file_name);
1868 /* Print the times. */
1872 fprintf (stderr,"\n");
1873 print_time ("parse", parse_time);
1874 print_time ("integration", integration_time);
1875 print_time ("jump", jump_time);
1876 print_time ("cse", cse_time);
1877 print_time ("loop", loop_time);
1878 print_time ("cse2", cse2_time);
1879 print_time ("flow", flow_time);
1880 print_time ("combine", combine_time);
1881 print_time ("sched", sched_time);
1882 print_time ("local-alloc", local_alloc_time);
1883 print_time ("global-alloc", global_alloc_time);
1884 print_time ("sched2", sched2_time);
1885 print_time ("dbranch", dbr_sched_time);
1886 print_time ("shorten-branch", shorten_branch_time);
1887 print_time ("stack-reg", stack_reg_time);
1888 print_time ("final", final_time);
1889 print_time ("varconst", varconst_time);
1890 print_time ("symout", symout_time);
1891 print_time ("dump", dump_time);
1895 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
1896 and TYPE_DECL nodes.
1898 This does nothing for local (non-static) variables.
1899 Otherwise, it sets up the RTL and outputs any assembler code
1900 (label definition, storage allocation and initialization).
1902 DECL is the declaration. If ASMSPEC is nonzero, it specifies
1903 the assembler symbol name to be used. TOP_LEVEL is nonzero
1904 if this declaration is not within a function. */
1907 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
1913 /* Declarations of variables, and of functions defined elsewhere. */
1915 /* Forward declarations for nested functions are not "external",
1916 but we need to treat them as if they were. */
1917 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
1918 || TREE_CODE (decl) == FUNCTION_DECL)
1919 TIMEVAR (varconst_time,
1921 make_decl_rtl (decl, asmspec, top_level);
1922 /* For a user-invisible decl that should be replaced
1923 by its value when used, don't output anything. */
1924 if (! (TREE_CODE (decl) == VAR_DECL
1925 && DECL_IGNORED_P (decl) && TREE_READONLY (decl)
1926 && DECL_INITIAL (decl) != 0))
1927 /* Don't output anything
1928 when a tentative file-scope definition is seen.
1929 But at end of compilation, do output code for them. */
1930 if (! (! at_end && top_level
1931 && (DECL_INITIAL (decl) == 0
1932 || DECL_INITIAL (decl) == error_mark_node
1933 || DECL_IGNORED_P (decl))))
1934 assemble_variable (decl, top_level, at_end);
1936 else if (DECL_REGISTER (decl) && asmspec != 0)
1938 if (decode_reg_name (asmspec) >= 0)
1940 DECL_RTL (decl) = 0;
1941 make_decl_rtl (decl, asmspec, top_level);
1944 error ("invalid register name `%s' for register variable", asmspec);
1946 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1947 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1948 && TREE_CODE (decl) == TYPE_DECL)
1949 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
1951 #ifdef SDB_DEBUGGING_INFO
1952 else if (write_symbols == SDB_DEBUG && top_level
1953 && TREE_CODE (decl) == TYPE_DECL)
1954 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1958 /* Called after finishing a record, union or enumeral type. */
1961 rest_of_type_compilation (type, toplev)
1965 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1966 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1967 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
1969 #ifdef SDB_DEBUGGING_INFO
1970 if (write_symbols == SDB_DEBUG)
1971 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
1975 /* This is called from finish_function (within yyparse)
1976 after each top-level definition is parsed.
1977 It is supposed to compile that function or variable
1978 and output the assembler code for it.
1979 After we return, the tree storage is freed. */
1982 rest_of_compilation (decl)
1986 int start_time = get_run_time ();
1988 /* Nonzero if we have saved the original DECL_INITIAL of the function,
1989 to be restored after we finish compiling the function
1990 (for use when compiling inline calls to this function). */
1991 tree saved_block_tree = 0;
1992 /* Likewise, for DECL_ARGUMENTS. */
1993 tree saved_arguments = 0;
1996 /* If we are reconsidering an inline function
1997 at the end of compilation, skip the stuff for making it inline. */
1999 if (DECL_SAVED_INSNS (decl) == 0)
2001 int specd = DECL_INLINE (decl);
2004 /* If requested, consider whether to make this function inline. */
2005 if (specd || flag_inline_functions)
2006 TIMEVAR (integration_time,
2008 lose = function_cannot_inline_p (decl);
2011 if (warn_inline && specd)
2012 warning_with_decl (decl, lose);
2013 DECL_INLINE (decl) = 0;
2016 DECL_INLINE (decl) = 1;
2019 insns = get_insns ();
2021 /* Dump the rtl code if we are dumping rtl. */
2026 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2027 IDENTIFIER_POINTER (DECL_NAME (decl)));
2028 if (DECL_SAVED_INSNS (decl))
2029 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2030 print_rtl (rtl_dump_file, insns);
2031 fflush (rtl_dump_file);
2034 /* If function is inline, and we don't yet know whether to
2035 compile it by itself, defer decision till end of compilation.
2036 finish_compilation will call rest_of_compilation again
2037 for those functions that need to be output. */
2039 if (DECL_INLINE (decl)
2040 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2041 && ! flag_keep_inline_functions)
2042 || DECL_EXTERNAL (decl)))
2044 #ifdef DWARF_DEBUGGING_INFO
2045 /* Generate the DWARF info for the "abstract" instance
2046 of a function which we may later generate inlined and/or
2047 out-of-line instances of. */
2048 if (write_symbols == DWARF_DEBUG)
2050 set_decl_abstract_flags (decl, 1);
2051 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2052 set_decl_abstract_flags (decl, 0);
2055 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2056 goto exit_rest_of_compilation;
2059 /* If we have to compile the function now, save its rtl and subdecls
2060 so that its compilation will not affect what others get. */
2061 if (DECL_INLINE (decl))
2063 #ifdef DWARF_DEBUGGING_INFO
2064 /* Generate the DWARF info for the "abstract" instance of
2065 a function which we will generate an out-of-line instance
2066 of almost immediately (and which we may also later generate
2067 various inlined instances of). */
2068 if (write_symbols == DWARF_DEBUG)
2070 set_decl_abstract_flags (decl, 1);
2071 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2072 set_decl_abstract_flags (decl, 0);
2075 saved_block_tree = DECL_INITIAL (decl);
2076 saved_arguments = DECL_ARGUMENTS (decl);
2077 TIMEVAR (integration_time, save_for_inline_copying (decl));
2081 TREE_ASM_WRITTEN (decl) = 1;
2083 /* Now that integrate will no longer see our rtl, we need not distinguish
2084 between the return value of this function and the return value of called
2086 rtx_equal_function_value_matters = 0;
2088 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2089 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2091 goto exit_rest_of_compilation;
2094 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2095 Note that that may have been done above, in save_for_inline_copying.
2096 The call to resume_temporary_allocation near the end of this function
2097 goes back to the usual state of affairs. */
2099 rtl_in_current_obstack ();
2102 /* If we are doing position-independent code generation, now
2103 is the time to output special prologues and epilogues.
2104 We do not want to do this earlier, because it just clutters
2105 up inline functions with meaningless insns. */
2110 insns = get_insns ();
2112 /* Copy any shared structure that should not be shared. */
2114 unshare_all_rtl (insns);
2116 /* Instantiate all virtual registers. */
2118 instantiate_virtual_regs (current_function_decl, get_insns ());
2120 /* See if we have allocated stack slots that are not directly addressable.
2121 If so, scan all the insns and create explicit address computation
2122 for all references to such slots. */
2123 /* fixup_stack_slots (); */
2125 /* Do jump optimization the first time, if -opt.
2126 Also do it if -W, but in that case it doesn't change the rtl code,
2127 it only computes whether control can drop off the end of the function. */
2129 if (optimize > 0 || extra_warnings || warn_return_type
2130 /* If function is `volatile', we should warn if it tries to return. */
2131 || TREE_THIS_VOLATILE (decl))
2133 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2134 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2137 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2138 if (rtl_dump_and_exit || flag_syntax_only)
2139 goto exit_rest_of_compilation;
2141 /* Dump rtl code after jump, if we are doing that. */
2146 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2147 IDENTIFIER_POINTER (DECL_NAME (decl)));
2148 print_rtl (jump_opt_dump_file, insns);
2149 fflush (jump_opt_dump_file);
2152 /* Perform common subexpression elimination.
2153 Nonzero value from `cse_main' means that jumps were simplified
2154 and some code may now be unreachable, so do
2155 jump optimization again. */
2160 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2161 IDENTIFIER_POINTER (DECL_NAME (decl)));
2166 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2168 if (flag_thread_jumps)
2169 /* Hacks by tiemann & kenner. */
2170 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2172 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2174 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2177 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2180 /* Dump rtl code after cse, if we are doing that. */
2185 print_rtl (cse_dump_file, insns);
2186 fflush (cse_dump_file);
2192 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2193 IDENTIFIER_POINTER (DECL_NAME (decl)));
2196 /* Move constant computations out of loops. */
2202 loop_optimize (insns, loop_dump_file);
2206 /* Dump rtl code after loop opt, if we are doing that. */
2211 print_rtl (loop_dump_file, insns);
2212 fflush (loop_dump_file);
2218 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2219 IDENTIFIER_POINTER (DECL_NAME (decl)));
2222 if (optimize > 0 && flag_rerun_cse_after_loop)
2224 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2226 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2227 1, cse2_dump_file));
2229 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2232 if (optimize > 0 && flag_thread_jumps)
2233 /* This pass of jump threading straightens out code
2234 that was kinked by loop optimization. */
2235 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2237 /* Dump rtl code after cse, if we are doing that. */
2242 print_rtl (cse2_dump_file, insns);
2243 fflush (cse2_dump_file);
2246 /* We are no longer anticipating cse in this function, at least. */
2248 cse_not_expected = 1;
2250 /* Now we choose between stupid (pcc-like) register allocation
2251 (if we got the -noreg switch and not -opt)
2252 and smart register allocation. */
2254 if (optimize > 0) /* Stupid allocation probably won't work */
2255 obey_regdecls = 0; /* if optimizations being done. */
2259 /* Print function header into flow dump now
2260 because doing the flow analysis makes some of the dump. */
2265 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2266 IDENTIFIER_POINTER (DECL_NAME (decl)));
2273 regclass (insns, max_reg_num ());
2274 stupid_life_analysis (insns, max_reg_num (),
2280 /* Do control and data flow analysis,
2281 and write some of the results to dump file. */
2283 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2285 if (warn_uninitialized)
2287 uninitialized_vars_warning (DECL_INITIAL (decl));
2288 setjmp_args_warning ();
2292 /* Dump rtl after flow analysis. */
2297 print_rtl (flow_dump_file, insns);
2298 fflush (flow_dump_file);
2301 /* If -opt, try combining insns through substitution. */
2304 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2306 /* Dump rtl code after insn combination. */
2311 fprintf (combine_dump_file, "\n;; Function %s\n\n",
2312 IDENTIFIER_POINTER (DECL_NAME (decl)));
2313 dump_combine_stats (combine_dump_file);
2314 print_rtl (combine_dump_file, insns);
2315 fflush (combine_dump_file);
2318 /* Print function header into sched dump now
2319 because doing the sched analysis makes some of the dump. */
2324 fprintf (sched_dump_file, "\n;; Function %s\n\n",
2325 IDENTIFIER_POINTER (DECL_NAME (decl)));
2328 if (optimize > 0 && flag_schedule_insns)
2330 /* Do control and data sched analysis,
2331 and write some of the results to dump file. */
2333 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
2336 /* Dump rtl after instruction scheduling. */
2341 print_rtl (sched_dump_file, insns);
2342 fflush (sched_dump_file);
2345 /* Unless we did stupid register allocation,
2346 allocate pseudo-regs that are used only within 1 basic block. */
2349 TIMEVAR (local_alloc_time,
2351 regclass (insns, max_reg_num ());
2355 /* Dump rtl code after allocating regs within basic blocks. */
2360 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
2361 IDENTIFIER_POINTER (DECL_NAME (decl)));
2362 dump_flow_info (local_reg_dump_file);
2363 dump_local_alloc (local_reg_dump_file);
2364 print_rtl (local_reg_dump_file, insns);
2365 fflush (local_reg_dump_file);
2368 if (global_reg_dump)
2370 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
2371 IDENTIFIER_POINTER (DECL_NAME (decl))));
2373 /* Unless we did stupid register allocation,
2374 allocate remaining pseudo-regs, then do the reload pass
2375 fixing up any insns that are invalid. */
2377 TIMEVAR (global_alloc_time,
2380 failure = global_alloc (global_reg_dump_file);
2382 failure = reload (insns, 0, global_reg_dump_file);
2385 if (global_reg_dump)
2388 dump_global_regs (global_reg_dump_file);
2389 print_rtl (global_reg_dump_file, insns);
2390 fflush (global_reg_dump_file);
2394 goto exit_rest_of_compilation;
2396 reload_completed = 1;
2398 /* On some machines, the prologue and epilogue code, or parts thereof,
2399 can be represented as RTL. Doing so lets us schedule insns between
2400 it and the rest of the code and also allows delayed branch
2401 scheduling to operate in the epilogue. */
2403 thread_prologue_and_epilogue_insns (insns);
2405 if (optimize > 0 && flag_schedule_insns_after_reload)
2410 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
2411 IDENTIFIER_POINTER (DECL_NAME (decl)));
2414 /* Do control and data sched analysis again,
2415 and write some more of the results to dump file. */
2417 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
2419 /* Dump rtl after post-reorder instruction scheduling. */
2424 print_rtl (sched2_dump_file, insns);
2425 fflush (sched2_dump_file);
2429 #ifdef LEAF_REGISTERS
2431 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
2435 /* One more attempt to remove jumps to .+1
2436 left by dead-store-elimination.
2437 Also do cross-jumping this time
2438 and delete no-op move insns. */
2442 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
2445 /* Dump rtl code after jump, if we are doing that. */
2450 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
2451 IDENTIFIER_POINTER (DECL_NAME (decl)));
2452 print_rtl (jump2_opt_dump_file, insns);
2453 fflush (jump2_opt_dump_file);
2456 /* If a scheduling pass for delayed branches is to be done,
2457 call the scheduling code. */
2460 if (optimize > 0 && flag_delayed_branch)
2462 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
2467 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
2468 IDENTIFIER_POINTER (DECL_NAME (decl)));
2469 print_rtl (dbr_sched_dump_file, insns);
2470 fflush (dbr_sched_dump_file);
2477 /* Shorten branches. */
2478 TIMEVAR (shorten_branch_time,
2480 shorten_branches (get_insns ());
2484 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
2489 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
2490 IDENTIFIER_POINTER (DECL_NAME (decl)));
2491 print_rtl (stack_reg_dump_file, insns);
2492 fflush (stack_reg_dump_file);
2497 /* Now turn the rtl into assembler code. */
2499 TIMEVAR (final_time,
2504 /* Get the function's name, as described by its RTL.
2505 This may be different from the DECL_NAME name used
2506 in the source file. */
2508 x = DECL_RTL (decl);
2509 if (GET_CODE (x) != MEM)
2512 if (GET_CODE (x) != SYMBOL_REF)
2514 fnname = XSTR (x, 0);
2516 assemble_start_function (decl, fnname);
2517 final_start_function (insns, asm_out_file, optimize);
2518 final (insns, asm_out_file, optimize, 0);
2519 final_end_function (insns, asm_out_file, optimize);
2520 assemble_end_function (decl, fnname);
2521 fflush (asm_out_file);
2524 /* Write DBX symbols if requested */
2526 /* Note that for those inline functions where we don't initially
2527 know for certain that we will be generating an out-of-line copy,
2528 the first invocation of this routine (rest_of_compilation) will
2529 skip over this code by doing a `goto exit_rest_of_compilation;'.
2530 Later on, finish_compilation will call rest_of_compilation again
2531 for those inline functions that need to have out-of-line copies
2532 generated. During that call, we *will* be routed past here. */
2534 #ifdef DBX_DEBUGGING_INFO
2535 if (write_symbols == DBX_DEBUG)
2536 TIMEVAR (symout_time, dbxout_function (decl));
2539 #ifdef DWARF_DEBUGGING_INFO
2540 if (write_symbols == DWARF_DEBUG)
2541 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2544 exit_rest_of_compilation:
2546 /* In case the function was not output,
2547 don't leave any temporary anonymous types
2548 queued up for sdb output. */
2549 #ifdef SDB_DEBUGGING_INFO
2550 if (write_symbols == SDB_DEBUG)
2551 sdbout_types (NULL_TREE);
2554 /* Put back the tree of subblocks and list of arguments
2555 from before we copied them.
2556 Code generation and the output of debugging info may have modified
2557 the copy, but the original is unchanged. */
2559 if (saved_block_tree != 0)
2560 DECL_INITIAL (decl) = saved_block_tree;
2561 if (saved_arguments != 0)
2562 DECL_ARGUMENTS (decl) = saved_arguments;
2564 reload_completed = 0;
2566 /* Clear out the real_constant_chain before some of the rtx's
2567 it runs through become garbage. */
2569 clear_const_double_mem ();
2571 /* Cancel the effect of rtl_in_current_obstack. */
2573 resume_temporary_allocation ();
2575 /* The parsing time is all the time spent in yyparse
2576 *except* what is spent in this function. */
2578 parse_time -= get_run_time () - start_time;
2581 /* Entry point of cc1/c++. Decode command args, then call compile_file.
2582 Exit code is 35 if can't open files, 34 if fatal error,
2583 33 if had nonfatal errors, else success. */
2586 main (argc, argv, envp)
2593 int flag_print_mem = 0;
2594 int version_flag = 0;
2597 /* save in case md file wants to emit args as a comment. */
2601 p = argv[0] + strlen (argv[0]);
2602 while (p != argv[0] && p[-1] != '/') --p;
2606 /* Get rid of any avoidable limit on stack size. */
2610 /* Set the stack limit huge so that alloca does not fail. */
2611 getrlimit (RLIMIT_STACK, &rlim);
2612 rlim.rlim_cur = rlim.rlim_max;
2613 setrlimit (RLIMIT_STACK, &rlim);
2615 #endif /* RLIMIT_STACK */
2617 signal (SIGFPE, float_signal);
2619 signal (SIGPIPE, pipe_closed);
2621 decl_printable_name = decl_name;
2622 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
2624 /* Initialize whether `char' is signed. */
2625 flag_signed_char = DEFAULT_SIGNED_CHAR;
2626 #ifdef DEFAULT_SHORT_ENUMS
2627 /* Initialize how much space enums occupy, by default. */
2628 flag_short_enums = DEFAULT_SHORT_ENUMS;
2631 /* Scan to see what optimization level has been specified. That will
2632 determine the default value of many flags. */
2633 for (i = 1; i < argc; i++)
2635 if (!strcmp (argv[i], "-O"))
2639 else if (argv[i][0] == '-' && argv[i][1] == 'O')
2641 /* Handle -O2, -O3, -O69, ... */
2642 char *p = &argv[i][2];
2646 if (! (c >= '0' && c <= '9'))
2649 optimize = atoi (&argv[i][2]);
2653 obey_regdecls = (optimize == 0);
2662 flag_thread_jumps = 1;
2664 flag_delayed_branch = 1;
2670 flag_cse_follow_jumps = 1;
2671 flag_cse_skip_blocks = 1;
2672 flag_expensive_optimizations = 1;
2673 flag_strength_reduce = 1;
2674 flag_rerun_cse_after_loop = 1;
2675 flag_caller_saves = 1;
2676 #ifdef INSN_SCHEDULING
2677 flag_schedule_insns = 1;
2678 flag_schedule_insns_after_reload = 1;
2682 #ifdef OPTIMIZATION_OPTIONS
2683 /* Allow default optimizations to be specified on a per-machine basis. */
2684 OPTIMIZATION_OPTIONS (optimize);
2687 /* Initialize register usage now so switches may override. */
2691 set_target_switch ("");
2693 for (i = 1; i < argc; i++)
2695 if (argv[i][0] == '-' && argv[i][1] != 0)
2697 register char *str = argv[i] + 1;
2702 set_target_switch (&str[1]);
2703 else if (!strcmp (str, "dumpbase"))
2705 dump_base_name = argv[++i];
2707 else if (str[0] == 'd')
2709 register char *p = &str[1];
2717 global_reg_dump = 1;
2723 cse_dump = 1, cse2_dump = 1;
2741 global_reg_dump = 1;
2759 flag_print_asm_name = 1;
2781 rtl_dump_and_exit = 1;
2785 else if (str[0] == 'f')
2788 register char *p = &str[1];
2791 /* Some kind of -f option.
2792 P's value is the option sans `-f'.
2793 Search for it in the table of options. */
2796 !found && j < sizeof (f_options) / sizeof (f_options[0]);
2799 if (!strcmp (p, f_options[j].string))
2801 *f_options[j].variable = f_options[j].on_value;
2802 /* A goto here would be cleaner,
2803 but breaks the vax pcc. */
2806 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
2807 && ! strcmp (p+3, f_options[j].string))
2809 *f_options[j].variable = ! f_options[j].on_value;
2816 else if (!strncmp (p, "fixed-", 6))
2817 fix_register (&p[6], 1, 1);
2818 else if (!strncmp (p, "call-used-", 10))
2819 fix_register (&p[10], 0, 1);
2820 else if (!strncmp (p, "call-saved-", 11))
2821 fix_register (&p[11], 0, 0);
2822 else if (! lang_decode_option (argv[i]))
2823 error ("Invalid option `%s'", argv[i]);
2825 else if (str[0] == 'O')
2827 register char *p = str+1;
2828 while (*p && *p >= '0' && *p <= '9')
2833 error ("Invalid option `%s'", argv[i]);
2835 else if (!strcmp (str, "pedantic"))
2837 else if (!strcmp (str, "pedantic-errors"))
2838 flag_pedantic_errors = pedantic = 1;
2839 else if (lang_decode_option (argv[i]))
2841 else if (!strcmp (str, "quiet"))
2843 else if (!strcmp (str, "version"))
2845 else if (!strcmp (str, "w"))
2846 inhibit_warnings = 1;
2847 else if (!strcmp (str, "W"))
2850 warn_uninitialized = 1;
2852 else if (str[0] == 'W')
2855 register char *p = &str[1];
2858 /* Some kind of -W option.
2859 P's value is the option sans `-W'.
2860 Search for it in the table of options. */
2863 !found && j < sizeof (W_options) / sizeof (W_options[0]);
2866 if (!strcmp (p, W_options[j].string))
2868 *W_options[j].variable = W_options[j].on_value;
2869 /* A goto here would be cleaner,
2870 but breaks the vax pcc. */
2873 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
2874 && ! strcmp (p+3, W_options[j].string))
2876 *W_options[j].variable = ! W_options[j].on_value;
2883 else if (!strncmp (p, "id-clash-", 9))
2889 if (*endp >= '0' && *endp <= '9')
2892 error ("Invalid option `%s'", argv[i]);
2895 id_clash_len = atoi (str + 10);
2898 error ("Invalid option `%s'", argv[i]);
2900 else if (!strcmp (str, "p"))
2902 else if (!strcmp (str, "a"))
2904 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
2905 warning ("`-a' option (basic block profile) not supported");
2907 profile_block_flag = 1;
2910 else if (str[0] == 'g')
2917 while (*p && (*p < '0' || *p > '9'))
2921 while (*q && (*q >= '0' && *q <= '9'))
2926 level = 2; /* default debugging info level */
2927 if (*q || level > 3)
2929 warning ("invalid debug level specification in option: `-%s'",
2931 warning ("no debugging information will be generated");
2935 /* If more than one debugging type is supported,
2936 you must define PREFERRED_DEBUGGING_TYPE
2937 to choose a format in a system-dependent way. */
2938 /* This is one long line cause VAXC can't handle a \-newline. */
2939 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
2940 #ifdef PREFERRED_DEBUGGING_TYPE
2941 if (!strncmp (str, "ggdb", len))
2942 write_symbols = PREFERRED_DEBUGGING_TYPE;
2943 #else /* no PREFERRED_DEBUGGING_TYPE */
2944 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
2945 #endif /* no PREFERRED_DEBUGGING_TYPE */
2946 #endif /* More than one debugger format enabled. */
2947 #ifdef DBX_DEBUGGING_INFO
2948 if (write_symbols != NO_DEBUG)
2950 else if (!strncmp (str, "ggdb", len))
2951 write_symbols = DBX_DEBUG;
2952 else if (!strncmp (str, "gstabs", len))
2953 write_symbols = DBX_DEBUG;
2955 /* Always enable extensions for -ggdb or -gstabs+,
2956 always disable for -gstabs.
2957 For plain -g, use system-specific default. */
2958 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
2960 use_gnu_debug_info_extensions = 1;
2961 else if (write_symbols == DBX_DEBUG && !strcmp (str, "gstabs+"))
2962 use_gnu_debug_info_extensions = 1;
2963 else if (write_symbols == DBX_DEBUG
2964 && !strncmp (str, "gstabs", len) && len >= 2)
2965 use_gnu_debug_info_extensions = 0;
2967 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
2968 #endif /* DBX_DEBUGGING_INFO */
2969 #ifdef DWARF_DEBUGGING_INFO
2970 if (write_symbols != NO_DEBUG)
2972 else if (!strncmp (str, "g", len))
2973 write_symbols = DWARF_DEBUG;
2974 else if (!strncmp (str, "ggdb", len))
2975 write_symbols = DWARF_DEBUG;
2976 else if (!strncmp (str, "gdwarf", len))
2977 write_symbols = DWARF_DEBUG;
2979 /* Always enable extensions for -ggdb or -gdwarf+,
2980 always disable for -gdwarf.
2981 For plain -g, use system-specific default. */
2982 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
2984 use_gnu_debug_info_extensions = 1;
2985 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
2986 use_gnu_debug_info_extensions = 1;
2987 else if (write_symbols == DWARF_DEBUG
2988 && !strncmp (str, "gdwarf", len) && len >= 2)
2989 use_gnu_debug_info_extensions = 0;
2991 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
2993 #ifdef SDB_DEBUGGING_INFO
2994 if (write_symbols != NO_DEBUG)
2996 else if (!strncmp (str, "g", len))
2997 write_symbols = SDB_DEBUG;
2998 else if (!strncmp (str, "gdb", len))
2999 write_symbols = SDB_DEBUG;
3000 else if (!strncmp (str, "gcoff", len))
3001 write_symbols = SDB_DEBUG;
3002 #endif /* SDB_DEBUGGING_INFO */
3003 #ifdef XCOFF_DEBUGGING_INFO
3004 if (write_symbols != NO_DEBUG)
3006 else if (!strncmp (str, "g", len))
3007 write_symbols = XCOFF_DEBUG;
3008 else if (!strncmp (str, "ggdb", len))
3009 write_symbols = XCOFF_DEBUG;
3010 else if (!strncmp (str, "gxcoff", len))
3011 write_symbols = XCOFF_DEBUG;
3013 /* Always enable extensions for -ggdb or -gxcoff+,
3014 always disable for -gxcoff.
3015 For plain -g, use system-specific default. */
3016 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3018 use_gnu_debug_info_extensions = 1;
3019 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3020 use_gnu_debug_info_extensions = 1;
3021 else if (write_symbols == XCOFF_DEBUG
3022 && !strncmp (str, "gxcoff", len) && len >= 2)
3023 use_gnu_debug_info_extensions = 0;
3025 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3027 if (write_symbols == NO_DEBUG)
3028 warning ("`-%s' option not supported on this version of GCC", str);
3029 else if (level == 0)
3030 write_symbols = NO_DEBUG;
3032 debug_info_level = (enum debug_info_level) level;
3034 else if (!strcmp (str, "o"))
3036 asm_file_name = argv[++i];
3038 else if (str[0] == 'G')
3040 g_switch_set = TRUE;
3041 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3043 else if (!strncmp (str, "aux-info", 8))
3045 flag_gen_aux_info = 1;
3046 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3049 error ("Invalid option `%s'", argv[i]);
3051 else if (argv[i][0] == '+')
3053 if (lang_decode_option (argv[i]))
3056 error ("Invalid option `%s'", argv[i]);
3062 /* Inlining does not work if not optimizing,
3063 so force it not to be done. */
3070 #ifdef OVERRIDE_OPTIONS
3071 /* Some machines may reject certain combinations of options. */
3075 /* Unrolling all loops implies that standard loop unrolling must also
3077 if (flag_unroll_all_loops)
3078 flag_unroll_loops = 1;
3079 /* Loop unrolling requires that strength_reduction be on also. Silently
3080 turn on strength reduction here if it isn't already on. Also, the loop
3081 unrolling code assumes that cse will be run after loop, so that must
3082 be turned on also. */
3083 if (flag_unroll_loops)
3085 flag_strength_reduce = 1;
3086 flag_rerun_cse_after_loop = 1;
3089 /* Warn about options that are not supported on this machine. */
3090 #ifndef INSN_SCHEDULING
3091 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3092 warning ("instruction scheduling not supported on this target machine");
3095 if (flag_delayed_branch)
3096 warning ("this target machine does not have delayed branches");
3099 /* If we are in verbose mode, write out the version and maybe all the
3100 option flags in use. */
3103 fprintf (stderr, "%s version %s", language_string, version_string);
3104 #ifdef TARGET_VERSION
3109 #define __VERSION__ "[unknown]"
3111 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3113 fprintf (stderr, " compiled by CC.\n");
3116 print_switch_values ();
3119 /* Now that register usage is specified, convert it to HARD_REG_SETs. */
3122 compile_file (filename);
3128 char *lim = (char *) sbrk (0);
3130 fprintf (stderr, "Data size %d.\n",
3131 lim - (char *) &environ);
3135 system ("ps -l 1>&2");
3138 #endif /* not USG */
3140 #endif /* not VMS */
3141 #endif /* not OS2 */
3144 exit (FATAL_EXIT_CODE);
3146 exit (FATAL_EXIT_CODE);
3147 exit (SUCCESS_EXIT_CODE);
3151 /* Decode -m switches. */
3153 /* Here is a table, controlled by the tm.h file, listing each -m switch
3154 and which bits in `target_switches' it should set or clear.
3155 If VALUE is positive, it is bits to set.
3156 If VALUE is negative, -VALUE is bits to clear.
3157 (The sign bit is not used so there is no confusion.) */
3159 struct {char *name; int value;} target_switches []
3162 /* This table is similar, but allows the switch to have a value. */
3164 #ifdef TARGET_OPTIONS
3165 struct {char *prefix; char ** variable;} target_options []
3169 /* Decode the switch -mNAME. */
3172 set_target_switch (name)
3178 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3179 if (!strcmp (target_switches[j].name, name))
3181 if (target_switches[j].value < 0)
3182 target_flags &= ~-target_switches[j].value;
3184 target_flags |= target_switches[j].value;
3188 #ifdef TARGET_OPTIONS
3190 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3192 int len = strlen (target_options[j].prefix);
3193 if (!strncmp (target_options[j].prefix, name, len))
3195 *target_options[j].variable = name + len;
3202 error ("Invalid option `%s'", name);
3205 /* Variable used for communication between the following two routines. */
3207 static int line_position;
3209 /* Print an option value and adjust the position in the line. */
3212 print_single_switch (type, name)
3215 fprintf (stderr, " %s%s", type, name);
3217 line_position += strlen (type) + strlen (name) + 1;
3219 if (line_position > 65)
3221 fprintf (stderr, "\n\t");
3226 /* Print default target switches for -version. */
3229 print_switch_values ()
3233 fprintf (stderr, "enabled:");
3236 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3237 if (*f_options[j].variable == f_options[j].on_value)
3238 print_single_switch ("-f", f_options[j].string);
3240 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
3241 if (*W_options[j].variable == W_options[j].on_value)
3242 print_single_switch ("-W", W_options[j].string);
3244 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3245 if (target_switches[j].name[0] != '\0'
3246 && target_switches[j].value > 0
3247 && ((target_switches[j].value & target_flags)
3248 == target_switches[j].value))
3249 print_single_switch ("-m", target_switches[j].name);
3251 fprintf (stderr, "\n");