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 extern char **environ;
81 extern char *version_string, *language_string;
83 extern void init_lex ();
84 extern void init_decl_processing ();
85 extern void init_obstacks ();
86 extern void init_tree_codes ();
87 extern void init_rtl ();
88 extern void init_optabs ();
89 extern void init_stmt ();
90 extern void init_reg_sets ();
91 extern void dump_flow_info ();
92 extern void dump_sched_info ();
93 extern void dump_local_alloc ();
95 void rest_of_decl_compilation ();
97 void error_with_file_and_line ();
102 void set_target_switch ();
103 static void print_switch_values ();
104 static char *decl_name ();
106 /* Name of program invoked, sans directories. */
110 /* Copy of arguments to main. */
114 /* Name of current original source file (what was input to cpp).
115 This comes from each #-command in the actual input. */
117 char *input_filename;
119 /* Name of top-level original source file (what was input to cpp).
120 This comes from the #-command at the beginning of the actual input.
121 If there isn't any there, then this is the cc1 input file name. */
123 char *main_input_filename;
125 /* Stream for reading from the input file. */
129 /* Current line number in real source file. */
133 /* Stack of currently pending input files. */
135 struct file_stack *input_file_stack;
137 /* Incremented on each change to input_file_stack. */
138 int input_file_stack_tick;
140 /* FUNCTION_DECL for function now being parsed or compiled. */
142 extern tree current_function_decl;
144 /* Name to use as base of names for dump output files. */
146 char *dump_base_name;
148 /* Bit flags that specify the machine subtype we are compiling for.
149 Bits are tested using macros TARGET_... defined in the tm.h file
150 and set by `-m...' switches. Must be defined in rtlanal.c. */
152 extern int target_flags;
154 /* Flags saying which kinds of debugging dump have been requested. */
157 int rtl_dump_and_exit = 0;
158 int jump_opt_dump = 0;
163 int combine_dump = 0;
165 int local_reg_dump = 0;
166 int global_reg_dump = 0;
168 int jump2_opt_dump = 0;
169 int dbr_sched_dump = 0;
170 int flag_print_asm_name = 0;
171 int stack_reg_dump = 0;
173 /* Name for output file of assembly code, specified with -o. */
177 /* Value of the -G xx switch, and whether it was passed or not. */
181 /* Type(s) of debugging information we are producing (if any).
182 See flags.h for the definitions of the different possible
183 types of debugging information. */
184 enum debug_info_type write_symbols = NO_DEBUG;
186 /* Level of debugging information we are producing. See flags.h
187 for the definitions of the different possible levels. */
188 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
190 /* Nonzero means use GNU-only extensions in the generated symbolic
191 debugging information. */
192 /* Currently, this only has an effect when write_symbols is set to
193 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
194 int use_gnu_debug_info_extensions = 0;
196 /* Nonzero means do optimizations. -O.
197 Particular numeric values stand for particular amounts of optimization;
198 thus, -O2 stores 2 here. However, the optimizations beyond the basic
199 ones are not controlled directly by this variable. Instead, they are
200 controlled by individual `flag_...' variables that are defaulted
201 based on this variable. */
205 /* Number of error messages and warning messages so far. */
208 int warningcount = 0;
211 /* Pointer to function to compute the name to use to print a declaration. */
213 char *(*decl_printable_name) ();
215 /* Pointer to function to compute rtl for a language-specific tree code. */
217 struct rtx_def *(*lang_expand_expr) ();
219 /* Nonzero if generating code to do profiling. */
221 int profile_flag = 0;
223 /* Nonzero if generating code to do profiling on a line-by-line basis. */
225 int profile_block_flag;
227 /* Nonzero for -pedantic switch: warn about anything
228 that standard spec forbids. */
232 /* Temporarily suppress certain warnings.
233 This is set while reading code from a system header file. */
235 int in_system_header = 0;
237 /* Nonzero means do stupid register allocation.
238 Currently, this is 1 if `optimize' is 0. */
240 int obey_regdecls = 0;
242 /* Don't print functions as they are compiled and don't print
243 times taken by the various passes. -quiet. */
249 /* Nonzero means `char' should be signed. */
251 int flag_signed_char;
253 /* Nonzero means give an enum type only as many bytes as it needs. */
255 int flag_short_enums;
257 /* Nonzero for -fcaller-saves: allocate values in regs that need to
258 be saved across function calls, if that produces overall better code.
259 Optional now, so people can test it. */
261 #ifdef DEFAULT_CALLER_SAVES
262 int flag_caller_saves = 1;
264 int flag_caller_saves = 0;
267 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
269 int flag_pcc_struct_return = 0;
271 /* Nonzero for -fforce-mem: load memory value into a register
272 before arithmetic on it. This makes better cse but slower compilation. */
274 int flag_force_mem = 0;
276 /* Nonzero for -fforce-addr: load memory address into a register before
277 reference to memory. This makes better cse but slower compilation. */
279 int flag_force_addr = 0;
281 /* Nonzero for -fdefer-pop: don't pop args after each function call;
282 instead save them up to pop many calls' args with one insns. */
284 int flag_defer_pop = 1;
286 /* Nonzero for -ffloat-store: don't allocate floats and doubles
287 in extended-precision registers. */
289 int flag_float_store = 0;
291 /* Nonzero for -fcse-follow-jumps:
292 have cse follow jumps to do a more extensive job. */
294 int flag_cse_follow_jumps;
296 /* Nonzero for -fcse-skip-blocks:
297 have cse follow a branch around a block. */
298 int flag_cse_skip_blocks;
300 /* Nonzero for -fexpensive-optimizations:
301 perform miscellaneous relatively-expensive optimizations. */
302 int flag_expensive_optimizations;
304 /* Nonzero for -fthread-jumps:
305 have jump optimize output of loop. */
307 int flag_thread_jumps;
309 /* Nonzero enables strength-reduction in loop.c. */
311 int flag_strength_reduce = 0;
313 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
314 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
315 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
318 int flag_unroll_loops;
320 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
321 This is generally not a win. */
323 int flag_unroll_all_loops;
325 /* Nonzero for -fwritable-strings:
326 store string constants in data segment and don't uniquize them. */
328 int flag_writable_strings = 0;
330 /* Nonzero means don't put addresses of constant functions in registers.
331 Used for compiling the Unix kernel, where strange substitutions are
332 done on the assembly output. */
334 int flag_no_function_cse = 0;
336 /* Nonzero for -fomit-frame-pointer:
337 don't make a frame pointer in simple functions that don't require one. */
339 int flag_omit_frame_pointer = 0;
341 /* Nonzero to inhibit use of define_optimization peephole opts. */
343 int flag_no_peephole = 0;
345 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
346 operations in the interest of optimization. For example it allows
347 GCC to assume arguments to sqrt are nonnegative numbers, allowing
348 faster code for sqrt to be generated. */
350 int flag_fast_math = 0;
352 /* Nonzero means all references through pointers are volatile. */
356 /* Nonzero means just do syntax checking; don't output anything. */
358 int flag_syntax_only = 0;
360 /* Nonzero means to rerun cse after loop optimization. This increases
361 compilation time about 20% and picks up a few more common expressions. */
363 static int flag_rerun_cse_after_loop;
365 /* Nonzero for -finline-functions: ok to inline functions that look like
366 good inline candidates. */
368 int flag_inline_functions;
370 /* Nonzero for -fkeep-inline-functions: even if we make a function
371 go inline everywhere, keep its defintion around for debugging
374 int flag_keep_inline_functions;
376 /* Nonzero means that functions declared `inline' will be treated
377 as `static'. Prevents generation of zillions of copies of unused
378 static inline functions; instead, `inlines' are written out
379 only when actually used. Used in conjunction with -g. Also
380 does the right thing with #pragma interface. */
384 /* Nonzero means we should be saving declaration info into a .X file. */
386 int flag_gen_aux_info = 0;
388 /* Specified name of aux-info file. */
390 static char *aux_info_file_name;
392 /* Nonzero means make the text shared if supported. */
394 int flag_shared_data;
396 /* Nonzero means schedule into delayed branch slots if supported. */
398 int flag_delayed_branch;
400 /* Nonzero if we are compiling pure (sharable) code.
401 Value is 1 if we are doing reasonable (i.e. simple
402 offset into offset table) pic. Value is 2 if we can
403 only perform register offsets. */
407 /* Nonzero means place uninitialized global data in the bss section. */
411 /* Nonzero means pretend it is OK to examine bits of target floats,
412 even if that isn't true. The resulting code will have incorrect constants,
413 but the same series of instructions that the native compiler would make. */
415 int flag_pretend_float;
417 /* Nonzero means change certain warnings into errors.
418 Usually these are warnings about failure to conform to some standard. */
420 int flag_pedantic_errors = 0;
422 /* flag_schedule_insns means schedule insns within basic blocks (before
424 flag_schedule_insns_after_reload means schedule insns after
427 int flag_schedule_insns = 0;
428 int flag_schedule_insns_after_reload = 0;
430 /* -finhibit-size-directive inhibits output of .size for ELF.
431 This is used only for compiling crtstuff.c,
432 and it may be extended to other effects
433 needed for crtstuff.c on other systems. */
434 int flag_inhibit_size_directive = 0;
436 /* -fverbose-asm causes extra commentary information to be produced in
437 the generated assembly code (to make it more readable). This option
438 is generally only of use to those who actually need to read the
439 generated assembly code (perhaps while debugging the compiler itself). */
441 int flag_verbose_asm = 0;
443 /* -fgnu-linker specifies use of the GNU linker for initializations.
444 (Or, more generally, a linker that handles initializations.)
445 -fno-gnu-linker says that collect2 will be used. */
447 int flag_gnu_linker = 0;
449 int flag_gnu_linker = 1;
452 /* Table of language-independent -f options.
453 STRING is the option name. VARIABLE is the address of the variable.
454 ON_VALUE is the value to store in VARIABLE
455 if `-fSTRING' is seen as an option.
456 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
458 struct { char *string; int *variable; int on_value;} f_options[] =
460 {"float-store", &flag_float_store, 1},
461 {"volatile", &flag_volatile, 1},
462 {"defer-pop", &flag_defer_pop, 1},
463 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
464 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
465 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
466 {"expensive-optimizations", &flag_expensive_optimizations, 1},
467 {"thread-jumps", &flag_thread_jumps, 1},
468 {"strength-reduce", &flag_strength_reduce, 1},
469 {"unroll-loops", &flag_unroll_loops, 1},
470 {"unroll-all-loops", &flag_unroll_all_loops, 1},
471 {"writable-strings", &flag_writable_strings, 1},
472 {"peephole", &flag_no_peephole, 0},
473 {"force-mem", &flag_force_mem, 1},
474 {"force-addr", &flag_force_addr, 1},
475 {"function-cse", &flag_no_function_cse, 0},
476 {"inline-functions", &flag_inline_functions, 1},
477 {"keep-inline-functions", &flag_keep_inline_functions, 1},
478 {"inline", &flag_no_inline, 0},
479 {"syntax-only", &flag_syntax_only, 1},
480 {"shared-data", &flag_shared_data, 1},
481 {"caller-saves", &flag_caller_saves, 1},
482 {"pcc-struct-return", &flag_pcc_struct_return, 1},
483 {"delayed-branch", &flag_delayed_branch, 1},
484 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
485 {"pretend-float", &flag_pretend_float, 1},
486 {"schedule-insns", &flag_schedule_insns, 1},
487 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
488 {"pic", &flag_pic, 1},
489 {"PIC", &flag_pic, 2},
490 {"fast-math", &flag_fast_math, 1},
491 {"common", &flag_no_common, 0},
492 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
493 {"verbose-asm", &flag_verbose_asm, 1},
494 {"gnu-linker", &flag_gnu_linker, 1}
497 /* Options controlling warnings */
499 /* Don't print warning messages. -w. */
501 int inhibit_warnings = 0;
503 /* Print various extra warnings. -W. */
505 int extra_warnings = 0;
507 /* Treat warnings as errors. -Werror. */
509 int warnings_are_errors = 0;
511 /* Nonzero to warn about unused local variables. */
515 /* Nonzero to warn about variables used before they are initialized. */
517 int warn_uninitialized;
519 /* Nonzero means warn about all declarations which shadow others. */
523 /* Warn if a switch on an enum fails to have a case for every enum value. */
527 /* Nonzero means warn about function definitions that default the return type
528 or that use a null return and have a return-type other than void. */
530 int warn_return_type;
532 /* Nonzero means warn about pointer casts that increase the required
533 alignment of the target type (and might therefore lead to a crash
534 due to a misaligned access). */
538 /* Nonzero means warn about any identifiers that match in the first N
539 characters. The value N is in `id_clash_len'. */
544 /* Nonzero means warn if inline function is too large. */
548 /* Warn if a function returns an aggregate,
549 since there are often incompatible calling conventions for doing this. */
551 int warn_aggregate_return;
553 /* Likewise for -W. */
555 struct { char *string; int *variable; int on_value;} W_options[] =
557 {"unused", &warn_unused, 1},
558 {"error", &warnings_are_errors, 1},
559 {"shadow", &warn_shadow, 1},
560 {"switch", &warn_switch, 1},
561 {"return-type", &warn_return_type, 1},
562 {"aggregate-return", &warn_aggregate_return, 1},
563 {"cast-align", &warn_cast_align, 1},
564 {"uninitialized", &warn_uninitialized, 1},
565 {"inline", &warn_inline, 1}
568 /* Output files for assembler code (real compiler output)
569 and debugging dumps. */
574 FILE *jump_opt_dump_file;
576 FILE *loop_dump_file;
577 FILE *cse2_dump_file;
578 FILE *flow_dump_file;
579 FILE *combine_dump_file;
580 FILE *sched_dump_file;
581 FILE *local_reg_dump_file;
582 FILE *global_reg_dump_file;
583 FILE *sched2_dump_file;
584 FILE *jump2_opt_dump_file;
585 FILE *dbr_sched_dump_file;
586 FILE *stack_reg_dump_file;
588 /* Time accumulators, to count the total time spent in various passes. */
592 int integration_time;
600 int local_alloc_time;
601 int global_alloc_time;
604 int shorten_branch_time;
610 /* Return time used so far, in microseconds. */
619 struct rusage rusage;
624 int proc_system_time;
626 int child_system_time;
636 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
639 getrusage (0, &rusage);
640 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
641 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
644 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
649 #define TIMEVAR(VAR, BODY) \
650 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
653 print_time (str, total)
658 "time in %s: %d.%06d\n",
659 str, total / 1000000, total % 1000000);
662 /* Count an error or warning. Return 1 if the message should be printed. */
665 count_error (warningp)
668 if (warningp && inhibit_warnings)
671 if (warningp && !warnings_are_errors)
675 static int warning_message = 0;
677 if (warningp && !warning_message)
679 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
688 /* Print a fatal error message. NAME is the text.
689 Also include a system error message based on `errno'. */
692 pfatal_with_name (name)
695 fprintf (stderr, "%s: ", progname);
701 fatal_io_error (name)
704 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
717 /* Called to give a better error message when we don't have an insn to match
718 what we are looking for or if the insn's constraints aren't satisfied,
719 rather than just calling abort(). */
722 fatal_insn_not_found (insn)
725 if (INSN_CODE (insn) < 0)
726 error ("internal error--unrecognizable insn:", 0);
728 error ("internal error--insn does not satisfy its constraints:", 0);
731 fflush (asm_out_file);
733 fflush (aux_info_file);
735 fflush (rtl_dump_file);
736 if (jump_opt_dump_file)
737 fflush (jump_opt_dump_file);
739 fflush (cse_dump_file);
741 fflush (loop_dump_file);
743 fflush (cse2_dump_file);
745 fflush (flow_dump_file);
746 if (combine_dump_file)
747 fflush (combine_dump_file);
749 fflush (sched_dump_file);
750 if (local_reg_dump_file)
751 fflush (local_reg_dump_file);
752 if (global_reg_dump_file)
753 fflush (global_reg_dump_file);
754 if (sched2_dump_file)
755 fflush (sched2_dump_file);
756 if (jump2_opt_dump_file)
757 fflush (jump2_opt_dump_file);
758 if (dbr_sched_dump_file)
759 fflush (dbr_sched_dump_file);
760 if (stack_reg_dump_file)
761 fflush (stack_reg_dump_file);
765 /* This is the default decl_printable_name function. */
768 decl_name (decl, kind)
772 return IDENTIFIER_POINTER (DECL_NAME (decl));
775 static int need_error_newline;
777 /* Function of last error message;
778 more generally, function such that if next error message is in it
779 then we don't have to mention the function name. */
780 static tree last_error_function = NULL;
782 /* Used to detect when input_file_stack has changed since last described. */
783 static int last_error_tick;
785 /* Called when the start of a function definition is parsed,
786 this function prints on stderr the name of the function. */
789 announce_function (decl)
795 if (rtl_dump_and_exit)
796 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
798 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
800 need_error_newline = 1;
801 last_error_function = current_function_decl;
805 /* Prints out, if necessary, the name of the current function
806 which caused an error. Called from all error and warning functions. */
809 report_error_function (file)
812 struct file_stack *p;
814 if (need_error_newline)
816 fprintf (stderr, "\n");
817 need_error_newline = 0;
820 if (last_error_function != current_function_decl)
822 char *kind = "function";
823 if (current_function_decl != 0
824 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
828 fprintf (stderr, "%s: ", file);
830 if (current_function_decl == NULL)
831 fprintf (stderr, "At top level:\n");
834 char *name = (*decl_printable_name) (current_function_decl, &kind);
835 fprintf (stderr, "In %s `%s':\n", kind, name);
838 last_error_function = current_function_decl;
840 if (input_file_stack && input_file_stack->next != 0
841 && input_file_stack_tick != last_error_tick)
843 fprintf (stderr, "In file included");
844 for (p = input_file_stack->next; p; p = p->next)
846 fprintf (stderr, " from %s:%d", p->name, p->line);
848 fprintf (stderr, ",");
850 fprintf (stderr, ":\n");
851 last_error_tick = input_file_stack_tick;
855 /* Report an error at the current line number.
856 S is a string and V and V2 are args for `printf'. We use HOST_WIDE_INT
857 as the type for these args assuming it is wide enough to hold a
858 pointer. This isn't terribly portable, but is the best we can do
859 without vprintf universally available. */
864 HOST_WIDE_INT v; /* Also used as pointer */
865 HOST_WIDE_INT v2; /* Also used as pointer */
867 error_with_file_and_line (input_filename, lineno, s, v, v2);
870 /* Report an error at line LINE of file FILE.
871 S and V are a string and an arg for `printf'. */
874 error_with_file_and_line (file, line, s, v, v2)
883 report_error_function (file);
886 fprintf (stderr, "%s:%d: ", file, line);
888 fprintf (stderr, "%s: ", progname);
889 fprintf (stderr, s, v, v2);
890 fprintf (stderr, "\n");
893 /* Report an error at the declaration DECL.
894 S and V are a string and an arg which uses %s to substitute
895 the declaration name. */
898 error_with_decl (decl, s, v)
906 report_error_function (DECL_SOURCE_FILE (decl));
908 fprintf (stderr, "%s:%d: ",
909 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
911 if (DECL_NAME (decl))
912 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
914 fprintf (stderr, s, "((anonymous))", v);
915 fprintf (stderr, "\n");
918 /* Report an error at the line number of the insn INSN.
919 S and V are a string and an arg for `printf'.
920 This is used only when INSN is an `asm' with operands,
921 and each ASM_OPERANDS records its own source file and line. */
924 error_for_asm (insn, s, v, v2)
927 HOST_WIDE_INT v; /* Also used as pointer */
928 HOST_WIDE_INT v2; /* Also used as pointer */
932 rtx body = PATTERN (insn);
935 /* Find the (or one of the) ASM_OPERANDS in the insn. */
936 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
937 asmop = SET_SRC (body);
938 else if (GET_CODE (body) == ASM_OPERANDS)
940 else if (GET_CODE (body) == PARALLEL
941 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
942 asmop = SET_SRC (XVECEXP (body, 0, 0));
943 else if (GET_CODE (body) == PARALLEL
944 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
945 asmop = XVECEXP (body, 0, 0);
947 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
948 line = ASM_OPERANDS_SOURCE_LINE (asmop);
950 error_with_file_and_line (filename, line, s, v, v2);
953 /* Report a warning at line LINE.
954 S and V are a string and an arg for `printf'. */
957 warning_with_file_and_line (file, line, s, v, v2, v3)
961 HOST_WIDE_INT v, v2, v3;
963 if (count_error (1) == 0)
966 report_error_function (file);
969 fprintf (stderr, "%s:%d: ", file, line);
971 fprintf (stderr, "%s: ", progname);
973 fprintf (stderr, "warning: ");
974 fprintf (stderr, s, v, v2, v3);
975 fprintf (stderr, "\n");
978 /* Report a warning at the current line number.
979 S and V are a string and an arg for `printf'. */
982 warning (s, v, v2, v3)
984 HOST_WIDE_INT v, v2, v3; /* Also used as pointer */
986 warning_with_file_and_line (input_filename, lineno, s, v, v2, v3);
989 /* Report a warning at the declaration DECL.
990 S is string which uses %s to substitute the declaration name.
991 V is a second parameter that S can refer to. */
994 warning_with_decl (decl, s, v)
1001 if (count_error (1) == 0)
1004 report_error_function (DECL_SOURCE_FILE (decl));
1006 fprintf (stderr, "%s:%d: ",
1007 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1009 fprintf (stderr, "warning: ");
1010 if (DECL_NAME (decl))
1011 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1013 fprintf (stderr, s, "((anonymous))", v);
1014 fprintf (stderr, "\n");
1017 /* Report a warning at the line number of the insn INSN.
1018 S and V are a string and an arg for `printf'.
1019 This is used only when INSN is an `asm' with operands,
1020 and each ASM_OPERANDS records its own source file and line. */
1023 warning_for_asm (insn, s, v, v2)
1026 HOST_WIDE_INT v; /* Also used as pointer */
1027 HOST_WIDE_INT v2; /* Also used as pointer */
1031 rtx body = PATTERN (insn);
1034 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1035 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1036 asmop = SET_SRC (body);
1037 else if (GET_CODE (body) == ASM_OPERANDS)
1039 else if (GET_CODE (body) == PARALLEL
1040 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1041 asmop = SET_SRC (XVECEXP (body, 0, 0));
1042 else if (GET_CODE (body) == PARALLEL
1043 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1044 asmop = XVECEXP (body, 0, 0);
1046 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1047 line = ASM_OPERANDS_SOURCE_LINE (asmop);
1049 warning_with_file_and_line (filename, line, s, v, v2);
1052 /* These functions issue either warnings or errors depending on
1053 -pedantic-errors. */
1058 HOST_WIDE_INT v; /* Also used as pointer */
1061 if (flag_pedantic_errors)
1068 pedwarn_with_decl (decl, s, v)
1073 if (flag_pedantic_errors)
1074 error_with_decl (decl, s, v);
1076 warning_with_decl (decl, s, v);
1080 pedwarn_with_file_and_line (file, line, s, v, v2)
1087 if (flag_pedantic_errors)
1088 error_with_file_and_line (file, line, s, v, v2);
1090 warning_with_file_and_line (file, line, s, v, v2);
1093 /* Apologize for not implementing some feature.
1094 S, V, and V2 are a string and args for `printf'. */
1099 HOST_WIDE_INT v, v2;
1103 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1105 fprintf (stderr, "%s: ", progname);
1107 fprintf (stderr, "sorry, not implemented: ");
1108 fprintf (stderr, s, v, v2);
1109 fprintf (stderr, "\n");
1112 /* Apologize for not implementing some feature, then quit.
1113 S, V, and V2 are a string and args for `printf'. */
1116 really_sorry (s, v, v2)
1118 HOST_WIDE_INT v, v2;
1121 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1123 fprintf (stderr, "c++: ");
1125 fprintf (stderr, "sorry, not implemented: ");
1126 fprintf (stderr, s, v, v2);
1127 fatal (" (fatal)\n");
1130 /* More 'friendly' abort that prints the line and file.
1131 config.h can #define abort fancy_abort if you like that sort of thing.
1133 I don't think this is actually a good idea.
1134 Other sorts of crashes will look a certain way.
1135 It is a good thing if crashes from calling abort look the same way.
1141 fatal ("internal gcc abort");
1144 /* This calls abort and is used to avoid problems when abort if a macro.
1145 It is used when we need to pass the address of abort. */
1153 /* When `malloc.c' is compiled with `rcheck' defined,
1154 it calls this function to report clobberage. */
1162 /* Same as `malloc' but report error if no memory available. */
1168 register char *value = (char *) malloc (size);
1170 fatal ("virtual memory exhausted");
1174 /* Same as `realloc' but report error if no memory available. */
1177 xrealloc (ptr, size)
1181 char *result = (char *) realloc (ptr, size);
1183 fatal ("virtual memory exhausted");
1187 /* Return the logarithm of X, base 2, considering X unsigned,
1188 if X is a power of 2. Otherwise, returns -1.
1190 This should be used via the `exact_log2' macro. */
1194 register unsigned HOST_WIDE_INT x;
1196 register int log = 0;
1197 /* Test for 0 or a power of 2. */
1198 if (x == 0 || x != (x & -x))
1200 while ((x >>= 1) != 0)
1205 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1206 If X is 0, return -1.
1208 This should be used via the floor_log2 macro. */
1212 register unsigned HOST_WIDE_INT x;
1214 register int log = -1;
1222 jmp_buf float_handler;
1224 /* Specify where to longjmp to when a floating arithmetic error happens.
1225 If HANDLER is 0, it means don't handle the errors any more. */
1228 set_float_handler (handler)
1231 float_handled = (handler != 0);
1233 bcopy (handler, float_handler, sizeof (float_handler));
1236 /* Signals actually come here. */
1239 float_signal (signo)
1240 /* If this is missing, some compilers complain. */
1243 if (float_handled == 0)
1245 #if defined (USG) || defined (hpux)
1246 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1249 signal (SIGFPE, float_signal);
1250 longjmp (float_handler, 1);
1253 /* Handler for SIGPIPE. */
1257 /* If this is missing, some compilers complain. */
1260 fatal ("output pipe has been closed");
1263 /* Strip off a legitimate source ending from the input string NAME of
1267 strip_off_ending (name, len)
1271 if (len > 2 && ! strcmp (".c", name + len - 2))
1273 else if (len > 2 && ! strcmp (".m", name + len - 2))
1275 else if (len > 2 && ! strcmp (".i", name + len - 2))
1277 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1279 else if (len > 3 && ! strcmp (".co", name + len - 3))
1281 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1283 else if (len > 2 && ! strcmp (".C", name + len - 2))
1285 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1287 else if (len > 2 && ! strcmp (".f", name + len - 2))
1289 else if (len > 4 && ! strcmp (".ada", name + len - 4))
1293 /* Output a file name in the form wanted by System V. */
1296 output_file_directive (asm_file, input_name)
1300 int len = strlen (input_name);
1301 char *na = input_name + len;
1303 /* NA gets INPUT_NAME sans directory names. */
1304 while (na > input_name)
1311 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1312 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1314 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1315 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1317 fprintf (asm_file, "\t.file\t\"%s\"\n", na);
1322 /* Compile an entire file of output from cpp, named NAME.
1323 Write a file of assembly output and various debugging dumps. */
1331 int dump_base_name_length;
1333 int name_specified = name != 0;
1335 if (dump_base_name == 0)
1336 dump_base_name = name ? name : "gccdump";
1337 dump_base_name_length = strlen (dump_base_name);
1341 integration_time = 0;
1349 local_alloc_time = 0;
1350 global_alloc_time = 0;
1353 shorten_branch_time = 0;
1359 /* Open input file. */
1361 if (name == 0 || !strcmp (name, "-"))
1367 finput = fopen (name, "r");
1369 pfatal_with_name (name);
1371 #ifdef IO_BUFFER_SIZE
1372 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
1375 /* Initialize data in various passes. */
1381 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
1382 || debug_info_level == DINFO_LEVEL_VERBOSE);
1383 init_decl_processing ();
1391 if (flag_caller_saves)
1392 init_caller_save ();
1394 /* If auxiliary info generation is desired, open the output file.
1395 This goes in the same directory as the source file--unlike
1396 all the other output files. */
1397 if (flag_gen_aux_info)
1399 aux_info_file = fopen (aux_info_file_name, "w");
1400 if (aux_info_file == 0)
1401 pfatal_with_name (aux_info_file_name);
1404 /* If rtl dump desired, open the output file. */
1407 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1408 strcpy (dumpname, dump_base_name);
1409 strcat (dumpname, ".rtl");
1410 rtl_dump_file = fopen (dumpname, "w");
1411 if (rtl_dump_file == 0)
1412 pfatal_with_name (dumpname);
1415 /* If jump_opt dump desired, open the output file. */
1418 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1419 strcpy (dumpname, dump_base_name);
1420 strcat (dumpname, ".jump");
1421 jump_opt_dump_file = fopen (dumpname, "w");
1422 if (jump_opt_dump_file == 0)
1423 pfatal_with_name (dumpname);
1426 /* If cse dump desired, open the output file. */
1429 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1430 strcpy (dumpname, dump_base_name);
1431 strcat (dumpname, ".cse");
1432 cse_dump_file = fopen (dumpname, "w");
1433 if (cse_dump_file == 0)
1434 pfatal_with_name (dumpname);
1437 /* If loop dump desired, open the output file. */
1440 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1441 strcpy (dumpname, dump_base_name);
1442 strcat (dumpname, ".loop");
1443 loop_dump_file = fopen (dumpname, "w");
1444 if (loop_dump_file == 0)
1445 pfatal_with_name (dumpname);
1448 /* If cse2 dump desired, open the output file. */
1451 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1452 strcpy (dumpname, dump_base_name);
1453 strcat (dumpname, ".cse2");
1454 cse2_dump_file = fopen (dumpname, "w");
1455 if (cse2_dump_file == 0)
1456 pfatal_with_name (dumpname);
1459 /* If flow dump desired, open the output file. */
1462 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1463 strcpy (dumpname, dump_base_name);
1464 strcat (dumpname, ".flow");
1465 flow_dump_file = fopen (dumpname, "w");
1466 if (flow_dump_file == 0)
1467 pfatal_with_name (dumpname);
1470 /* If combine dump desired, open the output file. */
1473 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1474 strcpy (dumpname, dump_base_name);
1475 strcat (dumpname, ".combine");
1476 combine_dump_file = fopen (dumpname, "w");
1477 if (combine_dump_file == 0)
1478 pfatal_with_name (dumpname);
1481 /* If scheduling dump desired, open the output file. */
1484 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1485 strcpy (dumpname, dump_base_name);
1486 strcat (dumpname, ".sched");
1487 sched_dump_file = fopen (dumpname, "w");
1488 if (sched_dump_file == 0)
1489 pfatal_with_name (dumpname);
1492 /* If local_reg dump desired, open the output file. */
1495 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1496 strcpy (dumpname, dump_base_name);
1497 strcat (dumpname, ".lreg");
1498 local_reg_dump_file = fopen (dumpname, "w");
1499 if (local_reg_dump_file == 0)
1500 pfatal_with_name (dumpname);
1503 /* If global_reg dump desired, open the output file. */
1504 if (global_reg_dump)
1506 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1507 strcpy (dumpname, dump_base_name);
1508 strcat (dumpname, ".greg");
1509 global_reg_dump_file = fopen (dumpname, "w");
1510 if (global_reg_dump_file == 0)
1511 pfatal_with_name (dumpname);
1514 /* If 2nd scheduling dump desired, open the output file. */
1517 register char *dumpname = (char *) xmalloc (dump_base_name_length + 8);
1518 strcpy (dumpname, dump_base_name);
1519 strcat (dumpname, ".sched2");
1520 sched2_dump_file = fopen (dumpname, "w");
1521 if (sched2_dump_file == 0)
1522 pfatal_with_name (dumpname);
1525 /* If jump2_opt dump desired, open the output file. */
1528 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1529 strcpy (dumpname, dump_base_name);
1530 strcat (dumpname, ".jump2");
1531 jump2_opt_dump_file = fopen (dumpname, "w");
1532 if (jump2_opt_dump_file == 0)
1533 pfatal_with_name (dumpname);
1536 /* If dbr_sched dump desired, open the output file. */
1539 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1540 strcpy (dumpname, dump_base_name);
1541 strcat (dumpname, ".dbr");
1542 dbr_sched_dump_file = fopen (dumpname, "w");
1543 if (dbr_sched_dump_file == 0)
1544 pfatal_with_name (dumpname);
1549 /* If stack_reg dump desired, open the output file. */
1552 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1553 strcpy (dumpname, dump_base_name);
1554 strcat (dumpname, ".stack");
1555 stack_reg_dump_file = fopen (dumpname, "w");
1556 if (stack_reg_dump_file == 0)
1557 pfatal_with_name (dumpname);
1562 /* Open assembler code output file. */
1564 if (! name_specified && asm_file_name == 0)
1565 asm_out_file = stdout;
1568 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1569 int len = strlen (dump_base_name);
1570 strcpy (dumpname, dump_base_name);
1571 strip_off_ending (dumpname, len);
1572 strcat (dumpname, ".s");
1573 if (asm_file_name == 0)
1575 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
1576 strcpy (asm_file_name, dumpname);
1578 if (!strcmp (asm_file_name, "-"))
1579 asm_out_file = stdout;
1581 asm_out_file = fopen (asm_file_name, "w");
1582 if (asm_out_file == 0)
1583 pfatal_with_name (asm_file_name);
1586 #ifdef IO_BUFFER_SIZE
1587 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
1588 _IOFBF, IO_BUFFER_SIZE);
1591 input_filename = name;
1593 /* Perform language-specific initialization.
1594 This may set main_input_filename. */
1597 /* If the input doesn't start with a #line, use the input name
1598 as the official input file name. */
1599 if (main_input_filename == 0)
1600 main_input_filename = name;
1602 /* Put an entry on the input file stack for the main input file. */
1604 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
1605 input_file_stack->next = 0;
1606 input_file_stack->name = input_filename;
1608 ASM_FILE_START (asm_out_file);
1610 /* Output something to inform GDB that this compilation was by GCC. */
1611 #ifndef ASM_IDENTIFY_GCC
1612 fprintf (asm_out_file, "gcc2_compiled.:\n");
1614 ASM_IDENTIFY_GCC (asm_out_file);
1616 /* Don't let the first function fall at the same address
1617 as gcc_compiled., if profiling. */
1618 if (profile_flag || profile_block_flag)
1619 assemble_zeros (UNITS_PER_WORD);
1621 /* If dbx symbol table desired, initialize writing it
1622 and output the predefined types. */
1623 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1624 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1625 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
1628 #ifdef SDB_DEBUGGING_INFO
1629 if (write_symbols == SDB_DEBUG)
1630 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
1633 #ifdef DWARF_DEBUGGING_INFO
1634 if (write_symbols == DWARF_DEBUG)
1635 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
1638 /* Initialize yet another pass. */
1640 init_final (main_input_filename);
1642 start_time = get_run_time ();
1644 /* Call the parser, which parses the entire file
1645 (calling rest_of_compilation for each function). */
1647 if (yyparse () != 0)
1648 if (errorcount == 0)
1649 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
1651 /* Compilation is now finished except for writing
1652 what's left of the symbol table output. */
1654 parse_time += get_run_time () - start_time;
1656 parse_time -= integration_time;
1657 parse_time -= varconst_time;
1659 globals = getdecls ();
1661 /* Really define vars that have had only a tentative definition.
1662 Really output inline functions that must actually be callable
1663 and have not been output so far. */
1666 int len = list_length (globals);
1667 tree *vec = (tree *) alloca (sizeof (tree) * len);
1671 /* Process the decls in reverse order--earliest first.
1672 Put them into VEC from back to front, then take out from front. */
1674 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
1675 vec[len - i - 1] = decl;
1677 for (i = 0; i < len; i++)
1680 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1681 && ! TREE_ASM_WRITTEN (decl))
1683 /* Don't write out static consts, unless we used them.
1684 (This used to write them out only if the address was
1685 taken, but that was wrong; if the variable was simply
1686 referred to, it still needs to exist or else it will
1687 be undefined in the linker.) */
1688 if (! TREE_READONLY (decl)
1689 || TREE_PUBLIC (decl)
1691 || TREE_ADDRESSABLE (decl)
1692 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1693 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1695 /* Cancel the RTL for this decl so that, if debugging info
1696 output for global variables is still to come,
1697 this one will be omitted. */
1698 DECL_RTL (decl) = NULL;
1701 if (TREE_CODE (decl) == FUNCTION_DECL
1702 && ! TREE_ASM_WRITTEN (decl)
1703 && DECL_INITIAL (decl) != 0
1704 && (TREE_ADDRESSABLE (decl)
1705 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1706 && ! TREE_EXTERNAL (decl))
1707 output_inline_function (decl);
1709 /* Warn about any function
1710 declared static but not defined.
1711 We don't warn about variables,
1712 because many programs have static variables
1713 that exist only to get some text into the object file. */
1716 || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))))
1717 && TREE_CODE (decl) == FUNCTION_DECL
1718 && DECL_INITIAL (decl) == 0
1719 && TREE_EXTERNAL (decl)
1720 && ! TREE_PUBLIC (decl))
1721 warning_with_decl (decl, "`%s' declared `static' but never defined");
1722 /* Warn about static fns or vars defined but not used,
1723 but not about inline functions
1724 since unused inline statics is normal practice. */
1726 && (TREE_CODE (decl) == FUNCTION_DECL
1727 || TREE_CODE (decl) == VAR_DECL)
1728 && ! DECL_IN_SYSTEM_HEADER (decl)
1729 && ! TREE_EXTERNAL (decl)
1730 && ! TREE_PUBLIC (decl)
1731 && ! TREE_USED (decl)
1732 && ! TREE_INLINE (decl)
1733 /* The TREE_USED bit for file-scope decls
1734 is kept in the identifier, to handle multiple
1735 external decls in different scopes. */
1736 && ! TREE_USED (DECL_NAME (decl)))
1737 warning_with_decl (decl, "`%s' defined but not used");
1739 #ifdef SDB_DEBUGGING_INFO
1740 /* The COFF linker can move initialized global vars to the end.
1741 And that can screw up the symbol ordering.
1742 By putting the symbols in that order to begin with,
1743 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1744 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
1745 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
1746 && DECL_RTL (decl) != 0)
1747 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1749 /* Output COFF information for non-global
1750 file-scope initialized variables. */
1751 if (write_symbols == SDB_DEBUG
1752 && TREE_CODE (decl) == VAR_DECL
1753 && DECL_INITIAL (decl)
1754 && DECL_RTL (decl) != 0
1755 && GET_CODE (DECL_RTL (decl)) == MEM)
1756 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
1757 #endif /* SDB_DEBUGGING_INFO */
1758 #ifdef DWARF_DEBUGGING_INFO
1759 /* Output DWARF information for file-scope tentative data object
1760 declarations, file-scope (extern) function declarations (which
1761 had no corresponding body) and file-scope tagged type declarations
1762 and definitions which have not yet been forced out. */
1764 if (write_symbols == DWARF_DEBUG
1765 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1766 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
1771 /* Do dbx symbols */
1772 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1773 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1774 TIMEVAR (symout_time,
1776 dbxout_finish (asm_out_file, main_input_filename);
1780 #ifdef DWARF_DEBUGGING_INFO
1781 if (write_symbols == DWARF_DEBUG)
1782 TIMEVAR (symout_time,
1788 /* Output some stuff at end of file if nec. */
1790 end_final (main_input_filename);
1793 ASM_FILE_END (asm_out_file);
1796 after_finish_compilation:
1798 /* Language-specific end of compilation actions. */
1802 /* Close the dump files. */
1804 if (flag_gen_aux_info)
1806 fclose (aux_info_file);
1808 unlink (aux_info_file_name);
1812 fclose (rtl_dump_file);
1815 fclose (jump_opt_dump_file);
1818 fclose (cse_dump_file);
1821 fclose (loop_dump_file);
1824 fclose (cse2_dump_file);
1827 fclose (flow_dump_file);
1831 dump_combine_total_stats (combine_dump_file);
1832 fclose (combine_dump_file);
1836 fclose (sched_dump_file);
1839 fclose (local_reg_dump_file);
1841 if (global_reg_dump)
1842 fclose (global_reg_dump_file);
1845 fclose (sched2_dump_file);
1848 fclose (jump2_opt_dump_file);
1851 fclose (dbr_sched_dump_file);
1855 fclose (stack_reg_dump_file);
1858 /* Close non-debugging input and output files. Take special care to note
1859 whether fclose returns an error, since the pages might still be on the
1860 buffer chain while the file is open. */
1863 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
1864 fatal_io_error (asm_file_name);
1866 /* Print the times. */
1870 fprintf (stderr,"\n");
1871 print_time ("parse", parse_time);
1872 print_time ("integration", integration_time);
1873 print_time ("jump", jump_time);
1874 print_time ("cse", cse_time);
1875 print_time ("loop", loop_time);
1876 print_time ("cse2", cse2_time);
1877 print_time ("flow", flow_time);
1878 print_time ("combine", combine_time);
1879 print_time ("sched", sched_time);
1880 print_time ("local-alloc", local_alloc_time);
1881 print_time ("global-alloc", global_alloc_time);
1882 print_time ("sched2", sched2_time);
1883 print_time ("dbranch", dbr_sched_time);
1884 print_time ("shorten-branch", shorten_branch_time);
1885 print_time ("stack-reg", stack_reg_time);
1886 print_time ("final", final_time);
1887 print_time ("varconst", varconst_time);
1888 print_time ("symout", symout_time);
1889 print_time ("dump", dump_time);
1893 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
1894 and TYPE_DECL nodes.
1896 This does nothing for local (non-static) variables.
1897 Otherwise, it sets up the RTL and outputs any assembler code
1898 (label definition, storage allocation and initialization).
1900 DECL is the declaration. If ASMSPEC is nonzero, it specifies
1901 the assembler symbol name to be used. TOP_LEVEL is nonzero
1902 if this declaration is not within a function. */
1905 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
1911 /* Declarations of variables, and of functions defined elsewhere. */
1913 /* Forward declarations for nested functions are not "external",
1914 but we need to treat them as if they were. */
1915 if (TREE_STATIC (decl) || TREE_EXTERNAL (decl)
1916 || TREE_CODE (decl) == FUNCTION_DECL)
1917 TIMEVAR (varconst_time,
1919 make_decl_rtl (decl, asmspec, top_level);
1920 /* For a user-invisible decl that should be replaced
1921 by its value when used, don't output anything. */
1922 if (! (TREE_CODE (decl) == VAR_DECL
1923 && DECL_IGNORED_P (decl) && TREE_READONLY (decl)
1924 && DECL_INITIAL (decl) != 0))
1925 /* Don't output anything
1926 when a tentative file-scope definition is seen.
1927 But at end of compilation, do output code for them. */
1928 if (! (! at_end && top_level
1929 && (DECL_INITIAL (decl) == 0
1930 || DECL_INITIAL (decl) == error_mark_node
1931 || DECL_IGNORED_P (decl))))
1932 assemble_variable (decl, top_level, at_end);
1934 else if (TREE_REGDECL (decl) && asmspec != 0)
1936 if (decode_reg_name (asmspec) >= 0)
1938 DECL_RTL (decl) = 0;
1939 make_decl_rtl (decl, asmspec, top_level);
1942 error ("invalid register name `%s' for register variable", asmspec);
1944 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1945 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1946 && TREE_CODE (decl) == TYPE_DECL)
1947 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
1949 #ifdef SDB_DEBUGGING_INFO
1950 else if (write_symbols == SDB_DEBUG && top_level
1951 && TREE_CODE (decl) == TYPE_DECL)
1952 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1956 /* Called after finishing a record, union or enumeral type. */
1959 rest_of_type_compilation (type, toplev)
1963 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1964 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1965 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
1967 #ifdef SDB_DEBUGGING_INFO
1968 if (write_symbols == SDB_DEBUG)
1969 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
1973 /* This is called from finish_function (within yyparse)
1974 after each top-level definition is parsed.
1975 It is supposed to compile that function or variable
1976 and output the assembler code for it.
1977 After we return, the tree storage is freed. */
1980 rest_of_compilation (decl)
1984 int start_time = get_run_time ();
1986 /* Nonzero if we have saved the original DECL_INITIAL of the function,
1987 to be restored after we finish compiling the function
1988 (for use when compiling inline calls to this function). */
1989 tree saved_block_tree = 0;
1990 /* Likewise, for DECL_ARGUMENTS. */
1991 tree saved_arguments = 0;
1994 /* If we are reconsidering an inline function
1995 at the end of compilation, skip the stuff for making it inline. */
1997 if (DECL_SAVED_INSNS (decl) == 0)
1999 int specd = TREE_INLINE (decl);
2002 /* If requested, consider whether to make this function inline. */
2003 if (specd || flag_inline_functions)
2004 TIMEVAR (integration_time,
2006 lose = function_cannot_inline_p (decl);
2009 if (warn_inline && specd)
2010 warning_with_decl (decl, lose);
2011 TREE_INLINE (decl) = 0;
2014 TREE_INLINE (decl) = 1;
2017 insns = get_insns ();
2019 /* Dump the rtl code if we are dumping rtl. */
2024 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2025 IDENTIFIER_POINTER (DECL_NAME (decl)));
2026 if (DECL_SAVED_INSNS (decl))
2027 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2028 print_rtl (rtl_dump_file, insns);
2029 fflush (rtl_dump_file);
2032 /* If function is inline, and we don't yet know whether to
2033 compile it by itself, defer decision till end of compilation.
2034 finish_compilation will call rest_of_compilation again
2035 for those functions that need to be output. */
2037 if (TREE_INLINE (decl)
2038 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2039 && ! flag_keep_inline_functions)
2040 || TREE_EXTERNAL (decl)))
2042 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2043 goto exit_rest_of_compilation;
2046 /* If we have to compile the function now, save its rtl and subdecls
2047 so that its compilation will not affect what others get. */
2048 if (TREE_INLINE (decl))
2050 saved_block_tree = DECL_INITIAL (decl);
2051 saved_arguments = DECL_ARGUMENTS (decl);
2052 TIMEVAR (integration_time, save_for_inline_copying (decl));
2056 TREE_ASM_WRITTEN (decl) = 1;
2058 /* Now that integrate will no longer see our rtl, we need not distinguish
2059 between the return value of this function and the return value of called
2061 rtx_equal_function_value_matters = 0;
2063 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2064 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2066 goto exit_rest_of_compilation;
2069 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2070 Note that that may have been done above, in save_for_inline_copying.
2071 The call to resume_temporary_allocation near the end of this function
2072 goes back to the usual state of affairs. */
2074 rtl_in_current_obstack ();
2077 /* If we are doing position-independent code generation, now
2078 is the time to output special prologues and epilogues.
2079 We do not want to do this earlier, because it just clutters
2080 up inline functions with meaningless insns. */
2085 insns = get_insns ();
2087 /* Copy any shared structure that should not be shared. */
2089 unshare_all_rtl (insns);
2091 /* Instantiate all virtual registers. */
2093 instantiate_virtual_regs (current_function_decl, get_insns ());
2095 /* See if we have allocated stack slots that are not directly addressable.
2096 If so, scan all the insns and create explicit address computation
2097 for all references to such slots. */
2098 /* fixup_stack_slots (); */
2100 /* Do jump optimization the first time, if -opt.
2101 Also do it if -W, but in that case it doesn't change the rtl code,
2102 it only computes whether control can drop off the end of the function. */
2104 if (optimize > 0 || extra_warnings || warn_return_type
2105 /* If function is `volatile', we should warn if it tries to return. */
2106 || TREE_THIS_VOLATILE (decl))
2108 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2109 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2112 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2113 if (rtl_dump_and_exit || flag_syntax_only)
2114 goto exit_rest_of_compilation;
2116 /* Dump rtl code after jump, if we are doing that. */
2121 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2122 IDENTIFIER_POINTER (DECL_NAME (decl)));
2123 print_rtl (jump_opt_dump_file, insns);
2124 fflush (jump_opt_dump_file);
2127 /* Perform common subexpression elimination.
2128 Nonzero value from `cse_main' means that jumps were simplified
2129 and some code may now be unreachable, so do
2130 jump optimization again. */
2135 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2136 IDENTIFIER_POINTER (DECL_NAME (decl)));
2141 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2143 if (flag_thread_jumps)
2144 /* Hacks by tiemann & kenner. */
2145 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2147 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2149 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2152 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2155 /* Dump rtl code after cse, if we are doing that. */
2160 print_rtl (cse_dump_file, insns);
2161 fflush (cse_dump_file);
2167 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2168 IDENTIFIER_POINTER (DECL_NAME (decl)));
2171 /* Move constant computations out of loops. */
2177 loop_optimize (insns, loop_dump_file);
2181 /* Dump rtl code after loop opt, if we are doing that. */
2186 print_rtl (loop_dump_file, insns);
2187 fflush (loop_dump_file);
2193 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2194 IDENTIFIER_POINTER (DECL_NAME (decl)));
2197 if (optimize > 0 && flag_rerun_cse_after_loop)
2199 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2201 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2202 1, cse2_dump_file));
2204 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2207 if (optimize > 0 && flag_thread_jumps)
2208 /* This pass of jump threading straightens out code
2209 that was kinked by loop optimization. */
2210 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2212 /* Dump rtl code after cse, if we are doing that. */
2217 print_rtl (cse2_dump_file, insns);
2218 fflush (cse2_dump_file);
2221 /* We are no longer anticipating cse in this function, at least. */
2223 cse_not_expected = 1;
2225 /* Now we choose between stupid (pcc-like) register allocation
2226 (if we got the -noreg switch and not -opt)
2227 and smart register allocation. */
2229 if (optimize > 0) /* Stupid allocation probably won't work */
2230 obey_regdecls = 0; /* if optimizations being done. */
2234 /* Print function header into flow dump now
2235 because doing the flow analysis makes some of the dump. */
2240 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2241 IDENTIFIER_POINTER (DECL_NAME (decl)));
2248 regclass (insns, max_reg_num ());
2249 stupid_life_analysis (insns, max_reg_num (),
2255 /* Do control and data flow analysis,
2256 and write some of the results to dump file. */
2258 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2260 if (warn_uninitialized)
2262 uninitialized_vars_warning (DECL_INITIAL (decl));
2263 setjmp_args_warning ();
2267 /* Dump rtl after flow analysis. */
2272 print_rtl (flow_dump_file, insns);
2273 fflush (flow_dump_file);
2276 /* If -opt, try combining insns through substitution. */
2279 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2281 /* Dump rtl code after insn combination. */
2286 fprintf (combine_dump_file, "\n;; Function %s\n\n",
2287 IDENTIFIER_POINTER (DECL_NAME (decl)));
2288 dump_combine_stats (combine_dump_file);
2289 print_rtl (combine_dump_file, insns);
2290 fflush (combine_dump_file);
2293 /* Print function header into sched dump now
2294 because doing the sched analysis makes some of the dump. */
2299 fprintf (sched_dump_file, "\n;; Function %s\n\n",
2300 IDENTIFIER_POINTER (DECL_NAME (decl)));
2303 if (optimize > 0 && flag_schedule_insns)
2305 /* Do control and data sched analysis,
2306 and write some of the results to dump file. */
2308 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
2311 /* Dump rtl after instruction scheduling. */
2316 print_rtl (sched_dump_file, insns);
2317 fflush (sched_dump_file);
2320 /* Unless we did stupid register allocation,
2321 allocate pseudo-regs that are used only within 1 basic block. */
2324 TIMEVAR (local_alloc_time,
2326 regclass (insns, max_reg_num ());
2330 /* Dump rtl code after allocating regs within basic blocks. */
2335 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
2336 IDENTIFIER_POINTER (DECL_NAME (decl)));
2337 dump_flow_info (local_reg_dump_file);
2338 dump_local_alloc (local_reg_dump_file);
2339 print_rtl (local_reg_dump_file, insns);
2340 fflush (local_reg_dump_file);
2343 if (global_reg_dump)
2345 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
2346 IDENTIFIER_POINTER (DECL_NAME (decl))));
2348 /* Unless we did stupid register allocation,
2349 allocate remaining pseudo-regs, then do the reload pass
2350 fixing up any insns that are invalid. */
2352 TIMEVAR (global_alloc_time,
2355 failure = global_alloc (global_reg_dump_file);
2357 failure = reload (insns, 0, global_reg_dump_file);
2360 if (global_reg_dump)
2363 dump_global_regs (global_reg_dump_file);
2364 print_rtl (global_reg_dump_file, insns);
2365 fflush (global_reg_dump_file);
2369 goto exit_rest_of_compilation;
2371 reload_completed = 1;
2373 /* On some machines, the prologue and epilogue code, or parts thereof,
2374 can be represented as RTL. Doing so lets us schedule insns between
2375 it and the rest of the code and also allows delayed branch
2376 scheduling to operate in the epilogue. */
2378 thread_prologue_and_epilogue_insns (insns);
2380 if (optimize > 0 && flag_schedule_insns_after_reload)
2385 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
2386 IDENTIFIER_POINTER (DECL_NAME (decl)));
2389 /* Do control and data sched analysis again,
2390 and write some more of the results to dump file. */
2392 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
2394 /* Dump rtl after post-reorder instruction scheduling. */
2399 print_rtl (sched2_dump_file, insns);
2400 fflush (sched2_dump_file);
2404 #ifdef LEAF_REGISTERS
2406 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
2410 /* One more attempt to remove jumps to .+1
2411 left by dead-store-elimination.
2412 Also do cross-jumping this time
2413 and delete no-op move insns. */
2417 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
2420 /* Dump rtl code after jump, if we are doing that. */
2425 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
2426 IDENTIFIER_POINTER (DECL_NAME (decl)));
2427 print_rtl (jump2_opt_dump_file, insns);
2428 fflush (jump2_opt_dump_file);
2431 /* If a scheduling pass for delayed branches is to be done,
2432 call the scheduling code. */
2435 if (optimize > 0 && flag_delayed_branch)
2437 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
2442 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
2443 IDENTIFIER_POINTER (DECL_NAME (decl)));
2444 print_rtl (dbr_sched_dump_file, insns);
2445 fflush (dbr_sched_dump_file);
2452 /* Shorten branches. */
2453 TIMEVAR (shorten_branch_time,
2455 shorten_branches (get_insns ());
2459 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
2464 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
2465 IDENTIFIER_POINTER (DECL_NAME (decl)));
2466 print_rtl (stack_reg_dump_file, insns);
2467 fflush (stack_reg_dump_file);
2472 /* Now turn the rtl into assembler code. */
2474 TIMEVAR (final_time,
2479 /* Get the function's name, as described by its RTL.
2480 This may be different from the DECL_NAME name used
2481 in the source file. */
2483 x = DECL_RTL (decl);
2484 if (GET_CODE (x) != MEM)
2487 if (GET_CODE (x) != SYMBOL_REF)
2489 fnname = XSTR (x, 0);
2491 assemble_start_function (decl, fnname);
2492 final_start_function (insns, asm_out_file, optimize);
2493 final (insns, asm_out_file, optimize, 0);
2494 final_end_function (insns, asm_out_file, optimize);
2495 assemble_end_function (decl, fnname);
2496 fflush (asm_out_file);
2499 /* Write DBX symbols if requested */
2501 /* Note that for those inline functions where we don't initially
2502 know for certain that we will be generating an out-of-line copy,
2503 the first invocation of this routine (rest_of_compilation) will
2504 skip over this code by doing a `goto exit_rest_of_compilation;'.
2505 Later on, finish_compilation will call rest_of_compilation again
2506 for those inline functions that need to have out-of-line copies
2507 generated. During that call, we *will* be routed past here. */
2509 #ifdef DBX_DEBUGGING_INFO
2510 if (write_symbols == DBX_DEBUG)
2511 TIMEVAR (symout_time, dbxout_function (decl));
2514 #ifdef DWARF_DEBUGGING_INFO
2515 if (write_symbols == DWARF_DEBUG)
2516 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2519 exit_rest_of_compilation:
2521 /* In case the function was not output,
2522 don't leave any temporary anonymous types
2523 queued up for sdb output. */
2524 #ifdef SDB_DEBUGGING_INFO
2525 if (write_symbols == SDB_DEBUG)
2526 sdbout_types (NULL_TREE);
2529 /* Put back the tree of subblocks and list of arguments
2530 from before we copied them.
2531 Code generation and the output of debugging info may have modified
2532 the copy, but the original is unchanged. */
2534 if (saved_block_tree != 0)
2535 DECL_INITIAL (decl) = saved_block_tree;
2536 if (saved_arguments != 0)
2537 DECL_ARGUMENTS (decl) = saved_arguments;
2539 reload_completed = 0;
2541 /* Clear out the real_constant_chain before some of the rtx's
2542 it runs through become garbage. */
2544 clear_const_double_mem ();
2546 /* Cancel the effect of rtl_in_current_obstack. */
2548 resume_temporary_allocation ();
2550 /* The parsing time is all the time spent in yyparse
2551 *except* what is spent in this function. */
2553 parse_time -= get_run_time () - start_time;
2556 /* Entry point of cc1/c++. Decode command args, then call compile_file.
2557 Exit code is 35 if can't open files, 34 if fatal error,
2558 33 if had nonfatal errors, else success. */
2561 main (argc, argv, envp)
2568 int flag_print_mem = 0;
2569 int version_flag = 0;
2572 /* save in case md file wants to emit args as a comment. */
2576 p = argv[0] + strlen (argv[0]);
2577 while (p != argv[0] && p[-1] != '/') --p;
2581 /* Get rid of any avoidable limit on stack size. */
2585 /* Set the stack limit huge so that alloca does not fail. */
2586 getrlimit (RLIMIT_STACK, &rlim);
2587 rlim.rlim_cur = rlim.rlim_max;
2588 setrlimit (RLIMIT_STACK, &rlim);
2590 #endif /* RLIMIT_STACK */
2592 signal (SIGFPE, float_signal);
2594 signal (SIGPIPE, pipe_closed);
2596 decl_printable_name = decl_name;
2597 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
2599 /* Initialize whether `char' is signed. */
2600 flag_signed_char = DEFAULT_SIGNED_CHAR;
2601 #ifdef DEFAULT_SHORT_ENUMS
2602 /* Initialize how much space enums occupy, by default. */
2603 flag_short_enums = DEFAULT_SHORT_ENUMS;
2606 /* Scan to see what optimization level has been specified. That will
2607 determine the default value of many flags. */
2608 for (i = 1; i < argc; i++)
2610 if (!strcmp (argv[i], "-O"))
2614 else if (argv[i][0] == '-' && argv[i][1] == 'O')
2616 /* Handle -O2, -O3, -O69, ... */
2617 char *p = &argv[i][2];
2621 if (! (c >= '0' && c <= '9'))
2624 optimize = atoi (&argv[i][2]);
2628 obey_regdecls = (optimize == 0);
2637 flag_thread_jumps = 1;
2639 flag_delayed_branch = 1;
2645 flag_cse_follow_jumps = 1;
2646 flag_cse_skip_blocks = 1;
2647 flag_expensive_optimizations = 1;
2648 flag_strength_reduce = 1;
2649 flag_rerun_cse_after_loop = 1;
2650 flag_caller_saves = 1;
2651 #ifdef INSN_SCHEDULING
2652 flag_schedule_insns = 1;
2653 flag_schedule_insns_after_reload = 1;
2657 #ifdef OPTIMIZATION_OPTIONS
2658 /* Allow default optimizations to be specified on a per-machine basis. */
2659 OPTIMIZATION_OPTIONS (optimize);
2662 /* Initialize register usage now so switches may override. */
2666 set_target_switch ("");
2668 for (i = 1; i < argc; i++)
2670 if (argv[i][0] == '-' && argv[i][1] != 0)
2672 register char *str = argv[i] + 1;
2677 set_target_switch (&str[1]);
2678 else if (!strcmp (str, "dumpbase"))
2680 dump_base_name = argv[++i];
2682 else if (str[0] == 'd')
2684 register char *p = &str[1];
2692 global_reg_dump = 1;
2698 cse_dump = 1, cse2_dump = 1;
2716 global_reg_dump = 1;
2734 flag_print_asm_name = 1;
2756 rtl_dump_and_exit = 1;
2760 else if (str[0] == 'f')
2763 register char *p = &str[1];
2766 /* Some kind of -f option.
2767 P's value is the option sans `-f'.
2768 Search for it in the table of options. */
2771 !found && j < sizeof (f_options) / sizeof (f_options[0]);
2774 if (!strcmp (p, f_options[j].string))
2776 *f_options[j].variable = f_options[j].on_value;
2777 /* A goto here would be cleaner,
2778 but breaks the vax pcc. */
2781 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
2782 && ! strcmp (p+3, f_options[j].string))
2784 *f_options[j].variable = ! f_options[j].on_value;
2791 else if (!strncmp (p, "fixed-", 6))
2792 fix_register (&p[6], 1, 1);
2793 else if (!strncmp (p, "call-used-", 10))
2794 fix_register (&p[10], 0, 1);
2795 else if (!strncmp (p, "call-saved-", 11))
2796 fix_register (&p[11], 0, 0);
2797 else if (! lang_decode_option (argv[i]))
2798 error ("Invalid option `%s'", argv[i]);
2800 else if (str[0] == 'O')
2802 register char *p = str+1;
2803 while (*p && *p >= '0' && *p <= '9')
2808 error ("Invalid option `%s'", argv[i]);
2810 else if (!strcmp (str, "pedantic"))
2812 else if (!strcmp (str, "pedantic-errors"))
2813 flag_pedantic_errors = pedantic = 1;
2814 else if (lang_decode_option (argv[i]))
2816 else if (!strcmp (str, "quiet"))
2818 else if (!strcmp (str, "version"))
2820 else if (!strcmp (str, "w"))
2821 inhibit_warnings = 1;
2822 else if (!strcmp (str, "W"))
2825 warn_uninitialized = 1;
2827 else if (str[0] == 'W')
2830 register char *p = &str[1];
2833 /* Some kind of -W option.
2834 P's value is the option sans `-W'.
2835 Search for it in the table of options. */
2838 !found && j < sizeof (W_options) / sizeof (W_options[0]);
2841 if (!strcmp (p, W_options[j].string))
2843 *W_options[j].variable = W_options[j].on_value;
2844 /* A goto here would be cleaner,
2845 but breaks the vax pcc. */
2848 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
2849 && ! strcmp (p+3, W_options[j].string))
2851 *W_options[j].variable = ! W_options[j].on_value;
2858 else if (!strncmp (p, "id-clash-", 9))
2864 if (*endp >= '0' && *endp <= '9')
2867 error ("Invalid option `%s'", argv[i]);
2870 id_clash_len = atoi (str + 10);
2873 error ("Invalid option `%s'", argv[i]);
2875 else if (!strcmp (str, "p"))
2877 else if (!strcmp (str, "a"))
2879 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
2880 warning ("`-a' option (basic block profile) not supported");
2882 profile_block_flag = 1;
2885 else if (str[0] == 'g')
2892 while (*p && (*p < '0' || *p > '9'))
2896 while (*q && (*q >= '0' && *q <= '9'))
2901 level = 2; /* default debugging info level */
2902 if (*q || level > 3)
2904 warning ("invalid debug level specification in option: `-%s'",
2906 warning ("no debugging information will be generated");
2910 /* If more than one debugging type is supported,
2911 you must define PREFERRED_DEBUGGING_TYPE
2912 to choose a format in a system-dependent way. */
2913 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) \
2914 + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
2915 #ifdef PREFERRED_DEBUGGING_TYPE
2916 if (!strncmp (str, "ggdb", len))
2917 write_symbols = PREFERRED_DEBUGGING_TYPE;
2918 #else /* no PREFERRED_DEBUGGING_TYPE */
2919 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
2920 #endif /* no PREFERRED_DEBUGGING_TYPE */
2921 #endif /* More than one debugger format enabled. */
2922 #ifdef DBX_DEBUGGING_INFO
2923 if (write_symbols != NO_DEBUG)
2925 else if (!strncmp (str, "ggdb", len))
2926 write_symbols = DBX_DEBUG;
2927 else if (!strncmp (str, "gstabs", len))
2928 write_symbols = DBX_DEBUG;
2930 /* Always enable extensions for -ggdb or -gstabs+,
2931 always disable for -gstabs.
2932 For plain -g, use system-specific default. */
2933 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
2935 use_gnu_debug_info_extensions = 1;
2936 else if (write_symbols == DBX_DEBUG && !strcmp (str, "gstabs+"))
2937 use_gnu_debug_info_extensions = 1;
2938 else if (write_symbols == DBX_DEBUG
2939 && !strncmp (str, "gstabs", len) && len >= 2)
2940 use_gnu_debug_info_extensions = 0;
2942 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
2943 #endif /* DBX_DEBUGGING_INFO */
2944 #ifdef DWARF_DEBUGGING_INFO
2945 if (write_symbols != NO_DEBUG)
2947 else if (!strncmp (str, "g", len))
2948 write_symbols = DWARF_DEBUG;
2949 else if (!strncmp (str, "ggdb", len))
2950 write_symbols = DWARF_DEBUG;
2951 else if (!strncmp (str, "gdwarf", len))
2952 write_symbols = DWARF_DEBUG;
2954 /* Always enable extensions for -ggdb or -gdwarf+,
2955 always disable for -gdwarf.
2956 For plain -g, use system-specific default. */
2957 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
2959 use_gnu_debug_info_extensions = 1;
2960 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
2961 use_gnu_debug_info_extensions = 1;
2962 else if (write_symbols == DWARF_DEBUG
2963 && !strncmp (str, "gdwarf", len) && len >= 2)
2964 use_gnu_debug_info_extensions = 0;
2966 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
2968 #ifdef SDB_DEBUGGING_INFO
2969 if (write_symbols != NO_DEBUG)
2971 else if (!strncmp (str, "g", len))
2972 write_symbols = SDB_DEBUG;
2973 else if (!strncmp (str, "gdb", len))
2974 write_symbols = SDB_DEBUG;
2975 else if (!strncmp (str, "gcoff", len))
2976 write_symbols = SDB_DEBUG;
2977 #endif /* SDB_DEBUGGING_INFO */
2978 #ifdef XCOFF_DEBUGGING_INFO
2979 if (write_symbols != NO_DEBUG)
2981 else if (!strncmp (str, "g", len))
2982 write_symbols = XCOFF_DEBUG;
2983 else if (!strncmp (str, "ggdb", len))
2984 write_symbols = XCOFF_DEBUG;
2985 else if (!strncmp (str, "gxcoff", len))
2986 write_symbols = XCOFF_DEBUG;
2988 /* Always enable extensions for -ggdb or -gxcoff+,
2989 always disable for -gxcoff.
2990 For plain -g, use system-specific default. */
2991 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
2993 use_gnu_debug_info_extensions = 1;
2994 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
2995 use_gnu_debug_info_extensions = 1;
2996 else if (write_symbols == XCOFF_DEBUG
2997 && !strncmp (str, "gxcoff", len) && len >= 2)
2998 use_gnu_debug_info_extensions = 0;
3000 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3002 if (write_symbols == NO_DEBUG)
3003 warning ("`-%s' option not supported on this version of GCC", str);
3004 else if (level == 0)
3005 write_symbols = NO_DEBUG;
3007 debug_info_level = (enum debug_info_level) level;
3009 else if (!strcmp (str, "o"))
3011 asm_file_name = argv[++i];
3013 else if (str[0] == 'G')
3015 g_switch_set = TRUE;
3016 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3018 else if (!strncmp (str, "aux-info", 8))
3020 flag_gen_aux_info = 1;
3021 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3024 error ("Invalid option `%s'", argv[i]);
3026 else if (argv[i][0] == '+')
3028 if (lang_decode_option (argv[i]))
3031 error ("Invalid option `%s'", argv[i]);
3037 /* Inlining does not work if not optimizing,
3038 so force it not to be done. */
3045 #ifdef OVERRIDE_OPTIONS
3046 /* Some machines may reject certain combinations of options. */
3050 /* Unrolling all loops implies that standard loop unrolling must also
3052 if (flag_unroll_all_loops)
3053 flag_unroll_loops = 1;
3054 /* Loop unrolling requires that strength_reduction be on also. Silently
3055 turn on strength reduction here if it isn't already on. Also, the loop
3056 unrolling code assumes that cse will be run after loop, so that must
3057 be turned on also. */
3058 if (flag_unroll_loops)
3060 flag_strength_reduce = 1;
3061 flag_rerun_cse_after_loop = 1;
3064 /* Warn about options that are not supported on this machine. */
3065 #ifndef INSN_SCHEDULING
3066 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3067 warning ("instruction scheduling not supported on this target machine");
3070 if (flag_delayed_branch)
3071 warning ("this target machine does not have delayed branches");
3074 /* If we are in verbose mode, write out the version and maybe all the
3075 option flags in use. */
3078 fprintf (stderr, "%s version %s", language_string, version_string);
3079 #ifdef TARGET_VERSION
3084 #define __VERSION__ "[unknown]"
3086 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3088 fprintf (stderr, " compiled by CC.\n");
3091 print_switch_values ();
3094 /* Now that register usage is specified, convert it to HARD_REG_SETs. */
3097 compile_file (filename);
3103 char *lim = (char *) sbrk (0);
3105 fprintf (stderr, "Data size %d.\n",
3106 (int) lim - (int) &environ);
3110 system ("ps -l 1>&2");
3113 #endif /* not USG */
3115 #endif /* not VMS */
3116 #endif /* not OS2 */
3119 exit (FATAL_EXIT_CODE);
3121 exit (FATAL_EXIT_CODE);
3122 exit (SUCCESS_EXIT_CODE);
3126 /* Decode -m switches. */
3128 /* Here is a table, controlled by the tm.h file, listing each -m switch
3129 and which bits in `target_switches' it should set or clear.
3130 If VALUE is positive, it is bits to set.
3131 If VALUE is negative, -VALUE is bits to clear.
3132 (The sign bit is not used so there is no confusion.) */
3134 struct {char *name; int value;} target_switches []
3137 /* This table is similar, but allows the switch to have a value. */
3139 #ifdef TARGET_OPTIONS
3140 struct {char *prefix; char ** variable;} target_options []
3144 /* Decode the switch -mNAME. */
3147 set_target_switch (name)
3153 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3154 if (!strcmp (target_switches[j].name, name))
3156 if (target_switches[j].value < 0)
3157 target_flags &= ~-target_switches[j].value;
3159 target_flags |= target_switches[j].value;
3163 #ifdef TARGET_OPTIONS
3165 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3167 int len = strlen (target_options[j].prefix);
3168 if (!strncmp (target_options[j].prefix, name, len))
3170 *target_options[j].variable = name + len;
3177 error ("Invalid option `%s'", name);
3180 /* Variable used for communication between the following two routines. */
3182 static int line_position;
3184 /* Print an option value and adjust the position in the line. */
3187 print_single_switch (type, name)
3190 fprintf (stderr, " %s%s", type, name);
3192 line_position += strlen (type) + strlen (name) + 1;
3194 if (line_position > 65)
3196 fprintf (stderr, "\n\t");
3201 /* Print default target switches for -version. */
3204 print_switch_values ()
3208 fprintf (stderr, "enabled:");
3211 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3212 if (*f_options[j].variable == f_options[j].on_value)
3213 print_single_switch ("-f", f_options[j].string);
3215 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
3216 if (*W_options[j].variable == W_options[j].on_value)
3217 print_single_switch ("-W", W_options[j].string);
3219 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3220 if (target_switches[j].name[0] != '\0'
3221 && target_switches[j].value > 0
3222 && ((target_switches[j].value & target_flags)
3223 == target_switches[j].value))
3224 print_single_switch ("-m", target_switches[j].name);
3226 fprintf (stderr, "\n");