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 /* Table of language-specific options. */
501 char *lang_options[] =
510 "-fno-unsigned-char",
511 "-fsigned-bitfields",
512 "-funsigned-bitfields",
513 "-fno-signed-bitfields",
514 "-fno-unsigned-bitfields",
518 "-fno-cond-mismatch",
531 "-Wno-write-strings",
535 "-Wno-pointer-arith",
536 "-Wstrict-prototypes",
537 "-Wno-strict-prototypes",
538 "-Wmissing-prototypes",
539 "-Wno-missing-prototypes",
541 "-Wno-redundant-decls",
543 "-Wno-nested-externs",
549 "-Wno-char-subscripts",
564 /* These are for C++. */
569 "-fno-save-memoized",
580 "-fthis-is-variable",
581 "-fno-this-is-variable",
582 "-fstrict-prototype",
583 "-fno-strict-prototype",
587 "-fno-memoize-lookups",
588 "-felide-constructors",
589 "-fno-elide-constructors",
592 "-fhandle-exceptions",
593 "-fno-handle-exceptions",
595 "-fno-ansi-exceptions",
596 "-fspring-exceptions",
597 "-fno-spring-exceptions",
599 "-fno-default-inline",
601 "-fno-enum-int-equiv",
607 "-fno-nonnull-objects",
611 "-Woverloaded-virtual",
612 "-Wno-overloaded-virtual",
616 /* these are for obj c */
624 /* Options controlling warnings */
626 /* Don't print warning messages. -w. */
628 int inhibit_warnings = 0;
630 /* Print various extra warnings. -W. */
632 int extra_warnings = 0;
634 /* Treat warnings as errors. -Werror. */
636 int warnings_are_errors = 0;
638 /* Nonzero to warn about unused local variables. */
642 /* Nonzero to warn about variables used before they are initialized. */
644 int warn_uninitialized;
646 /* Nonzero means warn about all declarations which shadow others. */
650 /* Warn if a switch on an enum fails to have a case for every enum value. */
654 /* Nonzero means warn about function definitions that default the return type
655 or that use a null return and have a return-type other than void. */
657 int warn_return_type;
659 /* Nonzero means warn about pointer casts that increase the required
660 alignment of the target type (and might therefore lead to a crash
661 due to a misaligned access). */
665 /* Nonzero means warn about any identifiers that match in the first N
666 characters. The value N is in `id_clash_len'. */
671 /* Nonzero means warn if inline function is too large. */
675 /* Warn if a function returns an aggregate,
676 since there are often incompatible calling conventions for doing this. */
678 int warn_aggregate_return;
680 /* Likewise for -W. */
682 struct { char *string; int *variable; int on_value;} W_options[] =
684 {"unused", &warn_unused, 1},
685 {"error", &warnings_are_errors, 1},
686 {"shadow", &warn_shadow, 1},
687 {"switch", &warn_switch, 1},
688 {"return-type", &warn_return_type, 1},
689 {"aggregate-return", &warn_aggregate_return, 1},
690 {"cast-align", &warn_cast_align, 1},
691 {"uninitialized", &warn_uninitialized, 1},
692 {"inline", &warn_inline, 1}
695 /* Output files for assembler code (real compiler output)
696 and debugging dumps. */
701 FILE *jump_opt_dump_file;
703 FILE *loop_dump_file;
704 FILE *cse2_dump_file;
705 FILE *flow_dump_file;
706 FILE *combine_dump_file;
707 FILE *sched_dump_file;
708 FILE *local_reg_dump_file;
709 FILE *global_reg_dump_file;
710 FILE *sched2_dump_file;
711 FILE *jump2_opt_dump_file;
712 FILE *dbr_sched_dump_file;
713 FILE *stack_reg_dump_file;
715 /* Time accumulators, to count the total time spent in various passes. */
719 int integration_time;
727 int local_alloc_time;
728 int global_alloc_time;
731 int shorten_branch_time;
737 /* Return time used so far, in microseconds. */
746 struct rusage rusage;
751 int proc_system_time;
753 int child_system_time;
763 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
766 getrusage (0, &rusage);
767 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
768 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
771 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
776 #define TIMEVAR(VAR, BODY) \
777 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
780 print_time (str, total)
785 "time in %s: %d.%06d\n",
786 str, total / 1000000, total % 1000000);
789 /* Count an error or warning. Return 1 if the message should be printed. */
792 count_error (warningp)
795 if (warningp && inhibit_warnings)
798 if (warningp && !warnings_are_errors)
802 static int warning_message = 0;
804 if (warningp && !warning_message)
806 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
815 /* Print a fatal error message. NAME is the text.
816 Also include a system error message based on `errno'. */
819 pfatal_with_name (name)
822 fprintf (stderr, "%s: ", progname);
828 fatal_io_error (name)
831 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
844 /* Called to give a better error message when we don't have an insn to match
845 what we are looking for or if the insn's constraints aren't satisfied,
846 rather than just calling abort(). */
849 fatal_insn_not_found (insn)
852 if (INSN_CODE (insn) < 0)
853 error ("internal error--unrecognizable insn:", 0);
855 error ("internal error--insn does not satisfy its constraints:", 0);
858 fflush (asm_out_file);
860 fflush (aux_info_file);
862 fflush (rtl_dump_file);
863 if (jump_opt_dump_file)
864 fflush (jump_opt_dump_file);
866 fflush (cse_dump_file);
868 fflush (loop_dump_file);
870 fflush (cse2_dump_file);
872 fflush (flow_dump_file);
873 if (combine_dump_file)
874 fflush (combine_dump_file);
876 fflush (sched_dump_file);
877 if (local_reg_dump_file)
878 fflush (local_reg_dump_file);
879 if (global_reg_dump_file)
880 fflush (global_reg_dump_file);
881 if (sched2_dump_file)
882 fflush (sched2_dump_file);
883 if (jump2_opt_dump_file)
884 fflush (jump2_opt_dump_file);
885 if (dbr_sched_dump_file)
886 fflush (dbr_sched_dump_file);
887 if (stack_reg_dump_file)
888 fflush (stack_reg_dump_file);
892 /* This is the default decl_printable_name function. */
895 decl_name (decl, kind)
899 return IDENTIFIER_POINTER (DECL_NAME (decl));
902 static int need_error_newline;
904 /* Function of last error message;
905 more generally, function such that if next error message is in it
906 then we don't have to mention the function name. */
907 static tree last_error_function = NULL;
909 /* Used to detect when input_file_stack has changed since last described. */
910 static int last_error_tick;
912 /* Called when the start of a function definition is parsed,
913 this function prints on stderr the name of the function. */
916 announce_function (decl)
922 if (rtl_dump_and_exit)
923 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
925 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
927 need_error_newline = 1;
928 last_error_function = current_function_decl;
932 /* Prints out, if necessary, the name of the current function
933 which caused an error. Called from all error and warning functions. */
936 report_error_function (file)
939 struct file_stack *p;
941 if (need_error_newline)
943 fprintf (stderr, "\n");
944 need_error_newline = 0;
947 if (last_error_function != current_function_decl)
949 char *kind = "function";
950 if (current_function_decl != 0
951 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
955 fprintf (stderr, "%s: ", file);
957 if (current_function_decl == NULL)
958 fprintf (stderr, "At top level:\n");
961 char *name = (*decl_printable_name) (current_function_decl, &kind);
962 fprintf (stderr, "In %s `%s':\n", kind, name);
965 last_error_function = current_function_decl;
967 if (input_file_stack && input_file_stack->next != 0
968 && input_file_stack_tick != last_error_tick)
970 fprintf (stderr, "In file included");
971 for (p = input_file_stack->next; p; p = p->next)
973 fprintf (stderr, " from %s:%d", p->name, p->line);
975 fprintf (stderr, ",");
977 fprintf (stderr, ":\n");
978 last_error_tick = input_file_stack_tick;
982 /* Report an error at the current line number.
983 S is a string and V and V2 are args for `printf'. We use HOST_WIDE_INT
984 as the type for these args assuming it is wide enough to hold a
985 pointer. This isn't terribly portable, but is the best we can do
986 without vprintf universally available. */
991 HOST_WIDE_INT v; /* Also used as pointer */
992 HOST_WIDE_INT v2; /* Also used as pointer */
994 error_with_file_and_line (input_filename, lineno, s, v, v2);
997 /* Report an error at line LINE of file FILE.
998 S and V are a string and an arg for `printf'. */
1001 error_with_file_and_line (file, line, s, v, v2)
1010 report_error_function (file);
1013 fprintf (stderr, "%s:%d: ", file, line);
1015 fprintf (stderr, "%s: ", progname);
1016 fprintf (stderr, s, v, v2);
1017 fprintf (stderr, "\n");
1020 /* Report an error at the declaration DECL.
1021 S and V are a string and an arg which uses %s to substitute
1022 the declaration name. */
1025 error_with_decl (decl, s, v)
1033 report_error_function (DECL_SOURCE_FILE (decl));
1035 fprintf (stderr, "%s:%d: ",
1036 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1038 if (DECL_NAME (decl))
1039 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1041 fprintf (stderr, s, "((anonymous))", v);
1042 fprintf (stderr, "\n");
1045 /* Report an error at the line number of the insn INSN.
1046 S and V are a string and an arg for `printf'.
1047 This is used only when INSN is an `asm' with operands,
1048 and each ASM_OPERANDS records its own source file and line. */
1051 error_for_asm (insn, s, v, v2)
1054 HOST_WIDE_INT v; /* Also used as pointer */
1055 HOST_WIDE_INT v2; /* Also used as pointer */
1059 rtx body = PATTERN (insn);
1062 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1063 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1064 asmop = SET_SRC (body);
1065 else if (GET_CODE (body) == ASM_OPERANDS)
1067 else if (GET_CODE (body) == PARALLEL
1068 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1069 asmop = SET_SRC (XVECEXP (body, 0, 0));
1070 else if (GET_CODE (body) == PARALLEL
1071 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1072 asmop = XVECEXP (body, 0, 0);
1074 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1075 line = ASM_OPERANDS_SOURCE_LINE (asmop);
1077 error_with_file_and_line (filename, line, s, v, v2);
1080 /* Report a warning at line LINE.
1081 S and V are a string and an arg for `printf'. */
1084 warning_with_file_and_line (file, line, s, v, v2, v3)
1088 HOST_WIDE_INT v, v2, v3;
1090 if (count_error (1) == 0)
1093 report_error_function (file);
1096 fprintf (stderr, "%s:%d: ", file, line);
1098 fprintf (stderr, "%s: ", progname);
1100 fprintf (stderr, "warning: ");
1101 fprintf (stderr, s, v, v2, v3);
1102 fprintf (stderr, "\n");
1105 /* Report a warning at the current line number.
1106 S and V are a string and an arg for `printf'. */
1109 warning (s, v, v2, v3)
1111 HOST_WIDE_INT v, v2, v3; /* Also used as pointer */
1113 warning_with_file_and_line (input_filename, lineno, s, v, v2, v3);
1116 /* Report a warning at the declaration DECL.
1117 S is string which uses %s to substitute the declaration name.
1118 V is a second parameter that S can refer to. */
1121 warning_with_decl (decl, s, v)
1128 if (count_error (1) == 0)
1131 report_error_function (DECL_SOURCE_FILE (decl));
1133 fprintf (stderr, "%s:%d: ",
1134 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1136 fprintf (stderr, "warning: ");
1137 if (DECL_NAME (decl))
1138 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1140 fprintf (stderr, s, "((anonymous))", v);
1141 fprintf (stderr, "\n");
1144 /* Report a warning at the line number of the insn INSN.
1145 S and V are a string and an arg for `printf'.
1146 This is used only when INSN is an `asm' with operands,
1147 and each ASM_OPERANDS records its own source file and line. */
1150 warning_for_asm (insn, s, v, v2)
1153 HOST_WIDE_INT v; /* Also used as pointer */
1154 HOST_WIDE_INT v2; /* Also used as pointer */
1158 rtx body = PATTERN (insn);
1161 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1162 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1163 asmop = SET_SRC (body);
1164 else if (GET_CODE (body) == ASM_OPERANDS)
1166 else if (GET_CODE (body) == PARALLEL
1167 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1168 asmop = SET_SRC (XVECEXP (body, 0, 0));
1169 else if (GET_CODE (body) == PARALLEL
1170 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1171 asmop = XVECEXP (body, 0, 0);
1173 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1174 line = ASM_OPERANDS_SOURCE_LINE (asmop);
1176 warning_with_file_and_line (filename, line, s, v, v2);
1179 /* These functions issue either warnings or errors depending on
1180 -pedantic-errors. */
1185 HOST_WIDE_INT v; /* Also used as pointer */
1188 if (flag_pedantic_errors)
1195 pedwarn_with_decl (decl, s, v)
1200 if (flag_pedantic_errors)
1201 error_with_decl (decl, s, v);
1203 warning_with_decl (decl, s, v);
1207 pedwarn_with_file_and_line (file, line, s, v, v2)
1214 if (flag_pedantic_errors)
1215 error_with_file_and_line (file, line, s, v, v2);
1217 warning_with_file_and_line (file, line, s, v, v2);
1220 /* Apologize for not implementing some feature.
1221 S, V, and V2 are a string and args for `printf'. */
1226 HOST_WIDE_INT v, v2;
1230 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1232 fprintf (stderr, "%s: ", progname);
1234 fprintf (stderr, "sorry, not implemented: ");
1235 fprintf (stderr, s, v, v2);
1236 fprintf (stderr, "\n");
1239 /* Apologize for not implementing some feature, then quit.
1240 S, V, and V2 are a string and args for `printf'. */
1243 really_sorry (s, v, v2)
1245 HOST_WIDE_INT v, v2;
1248 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1250 fprintf (stderr, "c++: ");
1252 fprintf (stderr, "sorry, not implemented: ");
1253 fprintf (stderr, s, v, v2);
1254 fatal (" (fatal)\n");
1257 /* More 'friendly' abort that prints the line and file.
1258 config.h can #define abort fancy_abort if you like that sort of thing.
1260 I don't think this is actually a good idea.
1261 Other sorts of crashes will look a certain way.
1262 It is a good thing if crashes from calling abort look the same way.
1268 fatal ("internal gcc abort");
1271 /* This calls abort and is used to avoid problems when abort if a macro.
1272 It is used when we need to pass the address of abort. */
1280 /* When `malloc.c' is compiled with `rcheck' defined,
1281 it calls this function to report clobberage. */
1289 /* Same as `malloc' but report error if no memory available. */
1295 register char *value = (char *) malloc (size);
1297 fatal ("virtual memory exhausted");
1301 /* Same as `realloc' but report error if no memory available. */
1304 xrealloc (ptr, size)
1308 char *result = (char *) realloc (ptr, size);
1310 fatal ("virtual memory exhausted");
1314 /* Return the logarithm of X, base 2, considering X unsigned,
1315 if X is a power of 2. Otherwise, returns -1.
1317 This should be used via the `exact_log2' macro. */
1321 register unsigned HOST_WIDE_INT x;
1323 register int log = 0;
1324 /* Test for 0 or a power of 2. */
1325 if (x == 0 || x != (x & -x))
1327 while ((x >>= 1) != 0)
1332 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1333 If X is 0, return -1.
1335 This should be used via the floor_log2 macro. */
1339 register unsigned HOST_WIDE_INT x;
1341 register int log = -1;
1349 jmp_buf float_handler;
1351 /* Specify where to longjmp to when a floating arithmetic error happens.
1352 If HANDLER is 0, it means don't handle the errors any more. */
1355 set_float_handler (handler)
1358 float_handled = (handler != 0);
1360 bcopy (handler, float_handler, sizeof (float_handler));
1363 /* Signals actually come here. */
1366 float_signal (signo)
1367 /* If this is missing, some compilers complain. */
1370 if (float_handled == 0)
1372 #if defined (USG) || defined (hpux)
1373 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1376 signal (SIGFPE, float_signal);
1377 longjmp (float_handler, 1);
1380 /* Handler for SIGPIPE. */
1384 /* If this is missing, some compilers complain. */
1387 fatal ("output pipe has been closed");
1390 /* Strip off a legitimate source ending from the input string NAME of
1394 strip_off_ending (name, len)
1398 if (len > 2 && ! strcmp (".c", name + len - 2))
1400 else if (len > 2 && ! strcmp (".m", name + len - 2))
1402 else if (len > 2 && ! strcmp (".i", name + len - 2))
1404 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1406 else if (len > 3 && ! strcmp (".co", name + len - 3))
1408 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1410 else if (len > 2 && ! strcmp (".C", name + len - 2))
1412 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1414 else if (len > 2 && ! strcmp (".f", name + len - 2))
1416 else if (len > 4 && ! strcmp (".ada", name + len - 4))
1420 /* Output a file name in the form wanted by System V. */
1423 output_file_directive (asm_file, input_name)
1427 int len = strlen (input_name);
1428 char *na = input_name + len;
1430 /* NA gets INPUT_NAME sans directory names. */
1431 while (na > input_name)
1438 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1439 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1441 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1442 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1444 fprintf (asm_file, "\t.file\t\"%s\"\n", na);
1449 /* Compile an entire file of output from cpp, named NAME.
1450 Write a file of assembly output and various debugging dumps. */
1458 int dump_base_name_length;
1460 int name_specified = name != 0;
1462 if (dump_base_name == 0)
1463 dump_base_name = name ? name : "gccdump";
1464 dump_base_name_length = strlen (dump_base_name);
1468 integration_time = 0;
1476 local_alloc_time = 0;
1477 global_alloc_time = 0;
1480 shorten_branch_time = 0;
1486 /* Open input file. */
1488 if (name == 0 || !strcmp (name, "-"))
1494 finput = fopen (name, "r");
1496 pfatal_with_name (name);
1498 #ifdef IO_BUFFER_SIZE
1499 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
1502 /* Initialize data in various passes. */
1508 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
1509 || debug_info_level == DINFO_LEVEL_VERBOSE);
1510 init_decl_processing ();
1518 if (flag_caller_saves)
1519 init_caller_save ();
1521 /* If auxiliary info generation is desired, open the output file.
1522 This goes in the same directory as the source file--unlike
1523 all the other output files. */
1524 if (flag_gen_aux_info)
1526 aux_info_file = fopen (aux_info_file_name, "w");
1527 if (aux_info_file == 0)
1528 pfatal_with_name (aux_info_file_name);
1531 /* If rtl dump desired, open the output file. */
1534 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1535 strcpy (dumpname, dump_base_name);
1536 strcat (dumpname, ".rtl");
1537 rtl_dump_file = fopen (dumpname, "w");
1538 if (rtl_dump_file == 0)
1539 pfatal_with_name (dumpname);
1542 /* If jump_opt dump desired, open the output file. */
1545 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1546 strcpy (dumpname, dump_base_name);
1547 strcat (dumpname, ".jump");
1548 jump_opt_dump_file = fopen (dumpname, "w");
1549 if (jump_opt_dump_file == 0)
1550 pfatal_with_name (dumpname);
1553 /* If cse dump desired, open the output file. */
1556 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1557 strcpy (dumpname, dump_base_name);
1558 strcat (dumpname, ".cse");
1559 cse_dump_file = fopen (dumpname, "w");
1560 if (cse_dump_file == 0)
1561 pfatal_with_name (dumpname);
1564 /* If loop dump desired, open the output file. */
1567 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1568 strcpy (dumpname, dump_base_name);
1569 strcat (dumpname, ".loop");
1570 loop_dump_file = fopen (dumpname, "w");
1571 if (loop_dump_file == 0)
1572 pfatal_with_name (dumpname);
1575 /* If cse2 dump desired, open the output file. */
1578 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1579 strcpy (dumpname, dump_base_name);
1580 strcat (dumpname, ".cse2");
1581 cse2_dump_file = fopen (dumpname, "w");
1582 if (cse2_dump_file == 0)
1583 pfatal_with_name (dumpname);
1586 /* If flow dump desired, open the output file. */
1589 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1590 strcpy (dumpname, dump_base_name);
1591 strcat (dumpname, ".flow");
1592 flow_dump_file = fopen (dumpname, "w");
1593 if (flow_dump_file == 0)
1594 pfatal_with_name (dumpname);
1597 /* If combine dump desired, open the output file. */
1600 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1601 strcpy (dumpname, dump_base_name);
1602 strcat (dumpname, ".combine");
1603 combine_dump_file = fopen (dumpname, "w");
1604 if (combine_dump_file == 0)
1605 pfatal_with_name (dumpname);
1608 /* If scheduling dump desired, open the output file. */
1611 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1612 strcpy (dumpname, dump_base_name);
1613 strcat (dumpname, ".sched");
1614 sched_dump_file = fopen (dumpname, "w");
1615 if (sched_dump_file == 0)
1616 pfatal_with_name (dumpname);
1619 /* If local_reg dump desired, open the output file. */
1622 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1623 strcpy (dumpname, dump_base_name);
1624 strcat (dumpname, ".lreg");
1625 local_reg_dump_file = fopen (dumpname, "w");
1626 if (local_reg_dump_file == 0)
1627 pfatal_with_name (dumpname);
1630 /* If global_reg dump desired, open the output file. */
1631 if (global_reg_dump)
1633 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1634 strcpy (dumpname, dump_base_name);
1635 strcat (dumpname, ".greg");
1636 global_reg_dump_file = fopen (dumpname, "w");
1637 if (global_reg_dump_file == 0)
1638 pfatal_with_name (dumpname);
1641 /* If 2nd scheduling dump desired, open the output file. */
1644 register char *dumpname = (char *) xmalloc (dump_base_name_length + 8);
1645 strcpy (dumpname, dump_base_name);
1646 strcat (dumpname, ".sched2");
1647 sched2_dump_file = fopen (dumpname, "w");
1648 if (sched2_dump_file == 0)
1649 pfatal_with_name (dumpname);
1652 /* If jump2_opt dump desired, open the output file. */
1655 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1656 strcpy (dumpname, dump_base_name);
1657 strcat (dumpname, ".jump2");
1658 jump2_opt_dump_file = fopen (dumpname, "w");
1659 if (jump2_opt_dump_file == 0)
1660 pfatal_with_name (dumpname);
1663 /* If dbr_sched dump desired, open the output file. */
1666 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1667 strcpy (dumpname, dump_base_name);
1668 strcat (dumpname, ".dbr");
1669 dbr_sched_dump_file = fopen (dumpname, "w");
1670 if (dbr_sched_dump_file == 0)
1671 pfatal_with_name (dumpname);
1676 /* If stack_reg dump desired, open the output file. */
1679 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1680 strcpy (dumpname, dump_base_name);
1681 strcat (dumpname, ".stack");
1682 stack_reg_dump_file = fopen (dumpname, "w");
1683 if (stack_reg_dump_file == 0)
1684 pfatal_with_name (dumpname);
1689 /* Open assembler code output file. */
1691 if (! name_specified && asm_file_name == 0)
1692 asm_out_file = stdout;
1695 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1696 int len = strlen (dump_base_name);
1697 strcpy (dumpname, dump_base_name);
1698 strip_off_ending (dumpname, len);
1699 strcat (dumpname, ".s");
1700 if (asm_file_name == 0)
1702 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
1703 strcpy (asm_file_name, dumpname);
1705 if (!strcmp (asm_file_name, "-"))
1706 asm_out_file = stdout;
1708 asm_out_file = fopen (asm_file_name, "w");
1709 if (asm_out_file == 0)
1710 pfatal_with_name (asm_file_name);
1713 #ifdef IO_BUFFER_SIZE
1714 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
1715 _IOFBF, IO_BUFFER_SIZE);
1718 input_filename = name;
1720 /* Perform language-specific initialization.
1721 This may set main_input_filename. */
1724 /* If the input doesn't start with a #line, use the input name
1725 as the official input file name. */
1726 if (main_input_filename == 0)
1727 main_input_filename = name;
1729 /* Put an entry on the input file stack for the main input file. */
1731 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
1732 input_file_stack->next = 0;
1733 input_file_stack->name = input_filename;
1735 ASM_FILE_START (asm_out_file);
1737 /* Output something to inform GDB that this compilation was by GCC. */
1738 #ifndef ASM_IDENTIFY_GCC
1739 fprintf (asm_out_file, "gcc2_compiled.:\n");
1741 ASM_IDENTIFY_GCC (asm_out_file);
1743 /* Don't let the first function fall at the same address
1744 as gcc_compiled., if profiling. */
1745 if (profile_flag || profile_block_flag)
1746 assemble_zeros (UNITS_PER_WORD);
1748 /* If dbx symbol table desired, initialize writing it
1749 and output the predefined types. */
1750 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1751 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1752 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
1755 #ifdef SDB_DEBUGGING_INFO
1756 if (write_symbols == SDB_DEBUG)
1757 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
1760 #ifdef DWARF_DEBUGGING_INFO
1761 if (write_symbols == DWARF_DEBUG)
1762 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
1765 /* Initialize yet another pass. */
1767 init_final (main_input_filename);
1769 start_time = get_run_time ();
1771 /* Call the parser, which parses the entire file
1772 (calling rest_of_compilation for each function). */
1774 if (yyparse () != 0)
1775 if (errorcount == 0)
1776 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
1778 /* Compilation is now finished except for writing
1779 what's left of the symbol table output. */
1781 parse_time += get_run_time () - start_time;
1783 parse_time -= integration_time;
1784 parse_time -= varconst_time;
1786 globals = getdecls ();
1788 /* Really define vars that have had only a tentative definition.
1789 Really output inline functions that must actually be callable
1790 and have not been output so far. */
1793 int len = list_length (globals);
1794 tree *vec = (tree *) alloca (sizeof (tree) * len);
1798 /* Process the decls in reverse order--earliest first.
1799 Put them into VEC from back to front, then take out from front. */
1801 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
1802 vec[len - i - 1] = decl;
1804 for (i = 0; i < len; i++)
1807 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1808 && ! TREE_ASM_WRITTEN (decl))
1810 /* Don't write out static consts, unless we used them.
1811 (This used to write them out only if the address was
1812 taken, but that was wrong; if the variable was simply
1813 referred to, it still needs to exist or else it will
1814 be undefined in the linker.) */
1815 if (! TREE_READONLY (decl)
1816 || TREE_PUBLIC (decl)
1818 || TREE_ADDRESSABLE (decl)
1819 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1820 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1822 /* Cancel the RTL for this decl so that, if debugging info
1823 output for global variables is still to come,
1824 this one will be omitted. */
1825 DECL_RTL (decl) = NULL;
1828 if (TREE_CODE (decl) == FUNCTION_DECL
1829 && ! TREE_ASM_WRITTEN (decl)
1830 && DECL_INITIAL (decl) != 0
1831 && (TREE_ADDRESSABLE (decl)
1832 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1833 && ! DECL_EXTERNAL (decl))
1834 output_inline_function (decl);
1836 /* Warn about any function
1837 declared static but not defined.
1838 We don't warn about variables,
1839 because many programs have static variables
1840 that exist only to get some text into the object file. */
1843 || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))))
1844 && TREE_CODE (decl) == FUNCTION_DECL
1845 && DECL_INITIAL (decl) == 0
1846 && DECL_EXTERNAL (decl)
1847 && ! TREE_PUBLIC (decl))
1848 warning_with_decl (decl, "`%s' declared `static' but never defined");
1849 /* Warn about static fns or vars defined but not used,
1850 but not about inline functions
1851 since unused inline statics is normal practice. */
1853 && (TREE_CODE (decl) == FUNCTION_DECL
1854 || TREE_CODE (decl) == VAR_DECL)
1855 && ! DECL_IN_SYSTEM_HEADER (decl)
1856 && ! DECL_EXTERNAL (decl)
1857 && ! TREE_PUBLIC (decl)
1858 && ! TREE_USED (decl)
1859 && ! DECL_INLINE (decl)
1860 /* The TREE_USED bit for file-scope decls
1861 is kept in the identifier, to handle multiple
1862 external decls in different scopes. */
1863 && ! TREE_USED (DECL_NAME (decl)))
1864 warning_with_decl (decl, "`%s' defined but not used");
1866 #ifdef SDB_DEBUGGING_INFO
1867 /* The COFF linker can move initialized global vars to the end.
1868 And that can screw up the symbol ordering.
1869 By putting the symbols in that order to begin with,
1870 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1871 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
1872 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
1873 && DECL_RTL (decl) != 0)
1874 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1876 /* Output COFF information for non-global
1877 file-scope initialized variables. */
1878 if (write_symbols == SDB_DEBUG
1879 && TREE_CODE (decl) == VAR_DECL
1880 && DECL_INITIAL (decl)
1881 && DECL_RTL (decl) != 0
1882 && GET_CODE (DECL_RTL (decl)) == MEM)
1883 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
1884 #endif /* SDB_DEBUGGING_INFO */
1885 #ifdef DWARF_DEBUGGING_INFO
1886 /* Output DWARF information for file-scope tentative data object
1887 declarations, file-scope (extern) function declarations (which
1888 had no corresponding body) and file-scope tagged type declarations
1889 and definitions which have not yet been forced out. */
1891 if (write_symbols == DWARF_DEBUG
1892 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1893 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
1898 /* Do dbx symbols */
1899 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1900 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1901 TIMEVAR (symout_time,
1903 dbxout_finish (asm_out_file, main_input_filename);
1907 #ifdef DWARF_DEBUGGING_INFO
1908 if (write_symbols == DWARF_DEBUG)
1909 TIMEVAR (symout_time,
1915 /* Output some stuff at end of file if nec. */
1917 end_final (main_input_filename);
1920 ASM_FILE_END (asm_out_file);
1923 after_finish_compilation:
1925 /* Language-specific end of compilation actions. */
1929 /* Close the dump files. */
1931 if (flag_gen_aux_info)
1933 fclose (aux_info_file);
1935 unlink (aux_info_file_name);
1939 fclose (rtl_dump_file);
1942 fclose (jump_opt_dump_file);
1945 fclose (cse_dump_file);
1948 fclose (loop_dump_file);
1951 fclose (cse2_dump_file);
1954 fclose (flow_dump_file);
1958 dump_combine_total_stats (combine_dump_file);
1959 fclose (combine_dump_file);
1963 fclose (sched_dump_file);
1966 fclose (local_reg_dump_file);
1968 if (global_reg_dump)
1969 fclose (global_reg_dump_file);
1972 fclose (sched2_dump_file);
1975 fclose (jump2_opt_dump_file);
1978 fclose (dbr_sched_dump_file);
1982 fclose (stack_reg_dump_file);
1985 /* Close non-debugging input and output files. Take special care to note
1986 whether fclose returns an error, since the pages might still be on the
1987 buffer chain while the file is open. */
1990 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
1991 fatal_io_error (asm_file_name);
1993 /* Print the times. */
1997 fprintf (stderr,"\n");
1998 print_time ("parse", parse_time);
1999 print_time ("integration", integration_time);
2000 print_time ("jump", jump_time);
2001 print_time ("cse", cse_time);
2002 print_time ("loop", loop_time);
2003 print_time ("cse2", cse2_time);
2004 print_time ("flow", flow_time);
2005 print_time ("combine", combine_time);
2006 print_time ("sched", sched_time);
2007 print_time ("local-alloc", local_alloc_time);
2008 print_time ("global-alloc", global_alloc_time);
2009 print_time ("sched2", sched2_time);
2010 print_time ("dbranch", dbr_sched_time);
2011 print_time ("shorten-branch", shorten_branch_time);
2012 print_time ("stack-reg", stack_reg_time);
2013 print_time ("final", final_time);
2014 print_time ("varconst", varconst_time);
2015 print_time ("symout", symout_time);
2016 print_time ("dump", dump_time);
2020 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2021 and TYPE_DECL nodes.
2023 This does nothing for local (non-static) variables.
2024 Otherwise, it sets up the RTL and outputs any assembler code
2025 (label definition, storage allocation and initialization).
2027 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2028 the assembler symbol name to be used. TOP_LEVEL is nonzero
2029 if this declaration is not within a function. */
2032 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2038 /* Declarations of variables, and of functions defined elsewhere. */
2040 /* Forward declarations for nested functions are not "external",
2041 but we need to treat them as if they were. */
2042 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2043 || TREE_CODE (decl) == FUNCTION_DECL)
2044 TIMEVAR (varconst_time,
2046 make_decl_rtl (decl, asmspec, top_level);
2047 /* For a user-invisible decl that should be replaced
2048 by its value when used, don't output anything. */
2049 if (! (TREE_CODE (decl) == VAR_DECL
2050 && DECL_IGNORED_P (decl) && TREE_READONLY (decl)
2051 && DECL_INITIAL (decl) != 0))
2052 /* Don't output anything
2053 when a tentative file-scope definition is seen.
2054 But at end of compilation, do output code for them. */
2055 if (! (! at_end && top_level
2056 && (DECL_INITIAL (decl) == 0
2057 || DECL_INITIAL (decl) == error_mark_node
2058 || DECL_IGNORED_P (decl))))
2059 assemble_variable (decl, top_level, at_end);
2061 else if (DECL_REGISTER (decl) && asmspec != 0)
2063 if (decode_reg_name (asmspec) >= 0)
2065 DECL_RTL (decl) = 0;
2066 make_decl_rtl (decl, asmspec, top_level);
2069 error ("invalid register name `%s' for register variable", asmspec);
2071 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2072 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2073 && TREE_CODE (decl) == TYPE_DECL)
2074 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2076 #ifdef SDB_DEBUGGING_INFO
2077 else if (write_symbols == SDB_DEBUG && top_level
2078 && TREE_CODE (decl) == TYPE_DECL)
2079 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2081 #ifdef DWARF_DEBUGGING_INFO
2082 if (write_symbols == DWARF_DEBUG
2084 && (TREE_CODE (decl) == TYPE_DECL
2085 || (TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl))))
2086 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2090 /* Called after finishing a record, union or enumeral type. */
2093 rest_of_type_compilation (type, toplev)
2097 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2098 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2099 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2101 #ifdef SDB_DEBUGGING_INFO
2102 if (write_symbols == SDB_DEBUG)
2103 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2107 /* This is called from finish_function (within yyparse)
2108 after each top-level definition is parsed.
2109 It is supposed to compile that function or variable
2110 and output the assembler code for it.
2111 After we return, the tree storage is freed. */
2114 rest_of_compilation (decl)
2118 int start_time = get_run_time ();
2120 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2121 to be restored after we finish compiling the function
2122 (for use when compiling inline calls to this function). */
2123 tree saved_block_tree = 0;
2124 /* Likewise, for DECL_ARGUMENTS. */
2125 tree saved_arguments = 0;
2128 /* If we are reconsidering an inline function
2129 at the end of compilation, skip the stuff for making it inline. */
2131 if (DECL_SAVED_INSNS (decl) == 0)
2133 int specd = DECL_INLINE (decl);
2136 /* If requested, consider whether to make this function inline. */
2137 if (specd || flag_inline_functions)
2138 TIMEVAR (integration_time,
2140 lose = function_cannot_inline_p (decl);
2143 if (warn_inline && specd)
2144 warning_with_decl (decl, lose);
2145 DECL_INLINE (decl) = 0;
2148 DECL_INLINE (decl) = 1;
2151 insns = get_insns ();
2153 /* Dump the rtl code if we are dumping rtl. */
2158 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2159 IDENTIFIER_POINTER (DECL_NAME (decl)));
2160 if (DECL_SAVED_INSNS (decl))
2161 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2162 print_rtl (rtl_dump_file, insns);
2163 fflush (rtl_dump_file);
2166 /* If function is inline, and we don't yet know whether to
2167 compile it by itself, defer decision till end of compilation.
2168 finish_compilation will call rest_of_compilation again
2169 for those functions that need to be output. */
2171 if (DECL_INLINE (decl)
2172 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2173 && ! flag_keep_inline_functions)
2174 || DECL_EXTERNAL (decl)))
2176 #ifdef DWARF_DEBUGGING_INFO
2177 /* Generate the DWARF info for the "abstract" instance
2178 of a function which we may later generate inlined and/or
2179 out-of-line instances of. */
2180 if (write_symbols == DWARF_DEBUG)
2182 set_decl_abstract_flags (decl, 1);
2183 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2184 set_decl_abstract_flags (decl, 0);
2187 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2188 goto exit_rest_of_compilation;
2191 /* If we have to compile the function now, save its rtl and subdecls
2192 so that its compilation will not affect what others get. */
2193 if (DECL_INLINE (decl))
2195 #ifdef DWARF_DEBUGGING_INFO
2196 /* Generate the DWARF info for the "abstract" instance of
2197 a function which we will generate an out-of-line instance
2198 of almost immediately (and which we may also later generate
2199 various inlined instances of). */
2200 if (write_symbols == DWARF_DEBUG)
2202 set_decl_abstract_flags (decl, 1);
2203 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2204 set_decl_abstract_flags (decl, 0);
2207 saved_block_tree = DECL_INITIAL (decl);
2208 saved_arguments = DECL_ARGUMENTS (decl);
2209 TIMEVAR (integration_time, save_for_inline_copying (decl));
2213 TREE_ASM_WRITTEN (decl) = 1;
2215 /* Now that integrate will no longer see our rtl, we need not distinguish
2216 between the return value of this function and the return value of called
2218 rtx_equal_function_value_matters = 0;
2220 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2221 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2223 goto exit_rest_of_compilation;
2226 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2227 Note that that may have been done above, in save_for_inline_copying.
2228 The call to resume_temporary_allocation near the end of this function
2229 goes back to the usual state of affairs. */
2231 rtl_in_current_obstack ();
2234 /* If we are doing position-independent code generation, now
2235 is the time to output special prologues and epilogues.
2236 We do not want to do this earlier, because it just clutters
2237 up inline functions with meaningless insns. */
2242 insns = get_insns ();
2244 /* Copy any shared structure that should not be shared. */
2246 unshare_all_rtl (insns);
2248 /* Instantiate all virtual registers. */
2250 instantiate_virtual_regs (current_function_decl, get_insns ());
2252 /* See if we have allocated stack slots that are not directly addressable.
2253 If so, scan all the insns and create explicit address computation
2254 for all references to such slots. */
2255 /* fixup_stack_slots (); */
2257 /* Do jump optimization the first time, if -opt.
2258 Also do it if -W, but in that case it doesn't change the rtl code,
2259 it only computes whether control can drop off the end of the function. */
2261 if (optimize > 0 || extra_warnings || warn_return_type
2262 /* If function is `volatile', we should warn if it tries to return. */
2263 || TREE_THIS_VOLATILE (decl))
2265 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2266 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2269 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2270 if (rtl_dump_and_exit || flag_syntax_only)
2271 goto exit_rest_of_compilation;
2273 /* Dump rtl code after jump, if we are doing that. */
2278 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2279 IDENTIFIER_POINTER (DECL_NAME (decl)));
2280 print_rtl (jump_opt_dump_file, insns);
2281 fflush (jump_opt_dump_file);
2284 /* Perform common subexpression elimination.
2285 Nonzero value from `cse_main' means that jumps were simplified
2286 and some code may now be unreachable, so do
2287 jump optimization again. */
2292 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2293 IDENTIFIER_POINTER (DECL_NAME (decl)));
2298 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2300 if (flag_thread_jumps)
2301 /* Hacks by tiemann & kenner. */
2302 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2304 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2306 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2309 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2312 /* Dump rtl code after cse, if we are doing that. */
2317 print_rtl (cse_dump_file, insns);
2318 fflush (cse_dump_file);
2324 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2325 IDENTIFIER_POINTER (DECL_NAME (decl)));
2328 /* Move constant computations out of loops. */
2334 loop_optimize (insns, loop_dump_file);
2338 /* Dump rtl code after loop opt, if we are doing that. */
2343 print_rtl (loop_dump_file, insns);
2344 fflush (loop_dump_file);
2350 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2351 IDENTIFIER_POINTER (DECL_NAME (decl)));
2354 if (optimize > 0 && flag_rerun_cse_after_loop)
2356 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2358 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2359 1, cse2_dump_file));
2361 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2364 if (optimize > 0 && flag_thread_jumps)
2365 /* This pass of jump threading straightens out code
2366 that was kinked by loop optimization. */
2367 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2369 /* Dump rtl code after cse, if we are doing that. */
2374 print_rtl (cse2_dump_file, insns);
2375 fflush (cse2_dump_file);
2378 /* We are no longer anticipating cse in this function, at least. */
2380 cse_not_expected = 1;
2382 /* Now we choose between stupid (pcc-like) register allocation
2383 (if we got the -noreg switch and not -opt)
2384 and smart register allocation. */
2386 if (optimize > 0) /* Stupid allocation probably won't work */
2387 obey_regdecls = 0; /* if optimizations being done. */
2391 /* Print function header into flow dump now
2392 because doing the flow analysis makes some of the dump. */
2397 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2398 IDENTIFIER_POINTER (DECL_NAME (decl)));
2405 regclass (insns, max_reg_num ());
2406 stupid_life_analysis (insns, max_reg_num (),
2412 /* Do control and data flow analysis,
2413 and write some of the results to dump file. */
2415 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2417 if (warn_uninitialized)
2419 uninitialized_vars_warning (DECL_INITIAL (decl));
2420 setjmp_args_warning ();
2424 /* Dump rtl after flow analysis. */
2429 print_rtl (flow_dump_file, insns);
2430 fflush (flow_dump_file);
2433 /* If -opt, try combining insns through substitution. */
2436 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2438 /* Dump rtl code after insn combination. */
2443 fprintf (combine_dump_file, "\n;; Function %s\n\n",
2444 IDENTIFIER_POINTER (DECL_NAME (decl)));
2445 dump_combine_stats (combine_dump_file);
2446 print_rtl (combine_dump_file, insns);
2447 fflush (combine_dump_file);
2450 /* Print function header into sched dump now
2451 because doing the sched analysis makes some of the dump. */
2456 fprintf (sched_dump_file, "\n;; Function %s\n\n",
2457 IDENTIFIER_POINTER (DECL_NAME (decl)));
2460 if (optimize > 0 && flag_schedule_insns)
2462 /* Do control and data sched analysis,
2463 and write some of the results to dump file. */
2465 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
2468 /* Dump rtl after instruction scheduling. */
2473 print_rtl (sched_dump_file, insns);
2474 fflush (sched_dump_file);
2477 /* Unless we did stupid register allocation,
2478 allocate pseudo-regs that are used only within 1 basic block. */
2481 TIMEVAR (local_alloc_time,
2483 regclass (insns, max_reg_num ());
2487 /* Dump rtl code after allocating regs within basic blocks. */
2492 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
2493 IDENTIFIER_POINTER (DECL_NAME (decl)));
2494 dump_flow_info (local_reg_dump_file);
2495 dump_local_alloc (local_reg_dump_file);
2496 print_rtl (local_reg_dump_file, insns);
2497 fflush (local_reg_dump_file);
2500 if (global_reg_dump)
2502 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
2503 IDENTIFIER_POINTER (DECL_NAME (decl))));
2505 /* Unless we did stupid register allocation,
2506 allocate remaining pseudo-regs, then do the reload pass
2507 fixing up any insns that are invalid. */
2509 TIMEVAR (global_alloc_time,
2512 failure = global_alloc (global_reg_dump_file);
2514 failure = reload (insns, 0, global_reg_dump_file);
2517 if (global_reg_dump)
2520 dump_global_regs (global_reg_dump_file);
2521 print_rtl (global_reg_dump_file, insns);
2522 fflush (global_reg_dump_file);
2526 goto exit_rest_of_compilation;
2528 reload_completed = 1;
2530 /* On some machines, the prologue and epilogue code, or parts thereof,
2531 can be represented as RTL. Doing so lets us schedule insns between
2532 it and the rest of the code and also allows delayed branch
2533 scheduling to operate in the epilogue. */
2535 thread_prologue_and_epilogue_insns (insns);
2537 if (optimize > 0 && flag_schedule_insns_after_reload)
2542 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
2543 IDENTIFIER_POINTER (DECL_NAME (decl)));
2546 /* Do control and data sched analysis again,
2547 and write some more of the results to dump file. */
2549 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
2551 /* Dump rtl after post-reorder instruction scheduling. */
2556 print_rtl (sched2_dump_file, insns);
2557 fflush (sched2_dump_file);
2561 #ifdef LEAF_REGISTERS
2563 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
2567 /* One more attempt to remove jumps to .+1
2568 left by dead-store-elimination.
2569 Also do cross-jumping this time
2570 and delete no-op move insns. */
2574 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
2577 /* Dump rtl code after jump, if we are doing that. */
2582 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
2583 IDENTIFIER_POINTER (DECL_NAME (decl)));
2584 print_rtl (jump2_opt_dump_file, insns);
2585 fflush (jump2_opt_dump_file);
2588 /* If a scheduling pass for delayed branches is to be done,
2589 call the scheduling code. */
2592 if (optimize > 0 && flag_delayed_branch)
2594 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
2599 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
2600 IDENTIFIER_POINTER (DECL_NAME (decl)));
2601 print_rtl (dbr_sched_dump_file, insns);
2602 fflush (dbr_sched_dump_file);
2609 /* Shorten branches. */
2610 TIMEVAR (shorten_branch_time,
2612 shorten_branches (get_insns ());
2616 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
2621 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
2622 IDENTIFIER_POINTER (DECL_NAME (decl)));
2623 print_rtl (stack_reg_dump_file, insns);
2624 fflush (stack_reg_dump_file);
2629 /* Now turn the rtl into assembler code. */
2631 TIMEVAR (final_time,
2636 /* Get the function's name, as described by its RTL.
2637 This may be different from the DECL_NAME name used
2638 in the source file. */
2640 x = DECL_RTL (decl);
2641 if (GET_CODE (x) != MEM)
2644 if (GET_CODE (x) != SYMBOL_REF)
2646 fnname = XSTR (x, 0);
2648 assemble_start_function (decl, fnname);
2649 final_start_function (insns, asm_out_file, optimize);
2650 final (insns, asm_out_file, optimize, 0);
2651 final_end_function (insns, asm_out_file, optimize);
2652 assemble_end_function (decl, fnname);
2653 fflush (asm_out_file);
2656 /* Write DBX symbols if requested */
2658 /* Note that for those inline functions where we don't initially
2659 know for certain that we will be generating an out-of-line copy,
2660 the first invocation of this routine (rest_of_compilation) will
2661 skip over this code by doing a `goto exit_rest_of_compilation;'.
2662 Later on, finish_compilation will call rest_of_compilation again
2663 for those inline functions that need to have out-of-line copies
2664 generated. During that call, we *will* be routed past here. */
2666 #ifdef DBX_DEBUGGING_INFO
2667 if (write_symbols == DBX_DEBUG)
2668 TIMEVAR (symout_time, dbxout_function (decl));
2671 #ifdef DWARF_DEBUGGING_INFO
2672 if (write_symbols == DWARF_DEBUG)
2673 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2676 exit_rest_of_compilation:
2678 /* In case the function was not output,
2679 don't leave any temporary anonymous types
2680 queued up for sdb output. */
2681 #ifdef SDB_DEBUGGING_INFO
2682 if (write_symbols == SDB_DEBUG)
2683 sdbout_types (NULL_TREE);
2686 /* Put back the tree of subblocks and list of arguments
2687 from before we copied them.
2688 Code generation and the output of debugging info may have modified
2689 the copy, but the original is unchanged. */
2691 if (saved_block_tree != 0)
2692 DECL_INITIAL (decl) = saved_block_tree;
2693 if (saved_arguments != 0)
2694 DECL_ARGUMENTS (decl) = saved_arguments;
2696 reload_completed = 0;
2698 /* Clear out the real_constant_chain before some of the rtx's
2699 it runs through become garbage. */
2701 clear_const_double_mem ();
2703 /* Cancel the effect of rtl_in_current_obstack. */
2705 resume_temporary_allocation ();
2707 /* The parsing time is all the time spent in yyparse
2708 *except* what is spent in this function. */
2710 parse_time -= get_run_time () - start_time;
2713 /* Entry point of cc1/c++. Decode command args, then call compile_file.
2714 Exit code is 35 if can't open files, 34 if fatal error,
2715 33 if had nonfatal errors, else success. */
2718 main (argc, argv, envp)
2725 int flag_print_mem = 0;
2726 int version_flag = 0;
2729 /* save in case md file wants to emit args as a comment. */
2733 p = argv[0] + strlen (argv[0]);
2734 while (p != argv[0] && p[-1] != '/') --p;
2738 /* Get rid of any avoidable limit on stack size. */
2742 /* Set the stack limit huge so that alloca does not fail. */
2743 getrlimit (RLIMIT_STACK, &rlim);
2744 rlim.rlim_cur = rlim.rlim_max;
2745 setrlimit (RLIMIT_STACK, &rlim);
2747 #endif /* RLIMIT_STACK */
2749 signal (SIGFPE, float_signal);
2751 signal (SIGPIPE, pipe_closed);
2753 decl_printable_name = decl_name;
2754 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
2756 /* Initialize whether `char' is signed. */
2757 flag_signed_char = DEFAULT_SIGNED_CHAR;
2758 #ifdef DEFAULT_SHORT_ENUMS
2759 /* Initialize how much space enums occupy, by default. */
2760 flag_short_enums = DEFAULT_SHORT_ENUMS;
2763 /* Scan to see what optimization level has been specified. That will
2764 determine the default value of many flags. */
2765 for (i = 1; i < argc; i++)
2767 if (!strcmp (argv[i], "-O"))
2771 else if (argv[i][0] == '-' && argv[i][1] == 'O')
2773 /* Handle -O2, -O3, -O69, ... */
2774 char *p = &argv[i][2];
2778 if (! (c >= '0' && c <= '9'))
2781 optimize = atoi (&argv[i][2]);
2785 obey_regdecls = (optimize == 0);
2794 flag_thread_jumps = 1;
2796 flag_delayed_branch = 1;
2802 flag_cse_follow_jumps = 1;
2803 flag_cse_skip_blocks = 1;
2804 flag_expensive_optimizations = 1;
2805 flag_strength_reduce = 1;
2806 flag_rerun_cse_after_loop = 1;
2807 flag_caller_saves = 1;
2808 #ifdef INSN_SCHEDULING
2809 flag_schedule_insns = 1;
2810 flag_schedule_insns_after_reload = 1;
2814 #ifdef OPTIMIZATION_OPTIONS
2815 /* Allow default optimizations to be specified on a per-machine basis. */
2816 OPTIMIZATION_OPTIONS (optimize);
2819 /* Initialize register usage now so switches may override. */
2823 set_target_switch ("");
2825 for (i = 1; i < argc; i++)
2828 /* If this is a language-specific option,
2829 decode it in a language-specific way. */
2830 for (j = 0; lang_options[j] != 0; j++)
2831 if (!strncmp (argv[i], lang_options[j],
2832 strlen (lang_options[j])))
2834 if (lang_options[j] != 0)
2835 /* If the option is valid for *some* language,
2836 treat it as valid even if this language doesn't understand it. */
2837 lang_decode_option (argv[i]);
2838 else if (argv[i][0] == '-' && argv[i][1] != 0)
2840 register char *str = argv[i] + 1;
2845 set_target_switch (&str[1]);
2846 else if (!strcmp (str, "dumpbase"))
2848 dump_base_name = argv[++i];
2850 else if (str[0] == 'd')
2852 register char *p = &str[1];
2860 global_reg_dump = 1;
2866 cse_dump = 1, cse2_dump = 1;
2884 global_reg_dump = 1;
2902 flag_print_asm_name = 1;
2924 rtl_dump_and_exit = 1;
2928 else if (str[0] == 'f')
2930 register char *p = &str[1];
2933 /* Some kind of -f option.
2934 P's value is the option sans `-f'.
2935 Search for it in the table of options. */
2938 !found && j < sizeof (f_options) / sizeof (f_options[0]);
2941 if (!strcmp (p, f_options[j].string))
2943 *f_options[j].variable = f_options[j].on_value;
2944 /* A goto here would be cleaner,
2945 but breaks the vax pcc. */
2948 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
2949 && ! strcmp (p+3, f_options[j].string))
2951 *f_options[j].variable = ! f_options[j].on_value;
2958 else if (!strncmp (p, "fixed-", 6))
2959 fix_register (&p[6], 1, 1);
2960 else if (!strncmp (p, "call-used-", 10))
2961 fix_register (&p[10], 0, 1);
2962 else if (!strncmp (p, "call-saved-", 11))
2963 fix_register (&p[11], 0, 0);
2965 error ("Invalid option `%s'", argv[i]);
2967 else if (str[0] == 'O')
2969 register char *p = str+1;
2970 while (*p && *p >= '0' && *p <= '9')
2975 error ("Invalid option `%s'", argv[i]);
2977 else if (!strcmp (str, "pedantic"))
2979 else if (!strcmp (str, "pedantic-errors"))
2980 flag_pedantic_errors = pedantic = 1;
2981 else if (!strcmp (str, "quiet"))
2983 else if (!strcmp (str, "version"))
2985 else if (!strcmp (str, "w"))
2986 inhibit_warnings = 1;
2987 else if (!strcmp (str, "W"))
2990 warn_uninitialized = 1;
2992 else if (str[0] == 'W')
2994 register char *p = &str[1];
2997 /* Some kind of -W option.
2998 P's value is the option sans `-W'.
2999 Search for it in the table of options. */
3002 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3005 if (!strcmp (p, W_options[j].string))
3007 *W_options[j].variable = W_options[j].on_value;
3008 /* A goto here would be cleaner,
3009 but breaks the vax pcc. */
3012 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3013 && ! strcmp (p+3, W_options[j].string))
3015 *W_options[j].variable = ! W_options[j].on_value;
3022 else if (!strncmp (p, "id-clash-", 9))
3028 if (*endp >= '0' && *endp <= '9')
3031 error ("Invalid option `%s'", argv[i]);
3034 id_clash_len = atoi (str + 10);
3037 error ("Invalid option `%s'", argv[i]);
3039 else if (!strcmp (str, "p"))
3041 else if (!strcmp (str, "a"))
3043 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3044 warning ("`-a' option (basic block profile) not supported");
3046 profile_block_flag = 1;
3049 else if (str[0] == 'g')
3056 while (*p && (*p < '0' || *p > '9'))
3060 while (*q && (*q >= '0' && *q <= '9'))
3065 level = 2; /* default debugging info level */
3066 if (*q || level > 3)
3068 warning ("invalid debug level specification in option: `-%s'",
3070 warning ("no debugging information will be generated");
3074 /* If more than one debugging type is supported,
3075 you must define PREFERRED_DEBUGGING_TYPE
3076 to choose a format in a system-dependent way. */
3077 /* This is one long line cause VAXC can't handle a \-newline. */
3078 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3079 #ifdef PREFERRED_DEBUGGING_TYPE
3080 if (!strncmp (str, "ggdb", len))
3081 write_symbols = PREFERRED_DEBUGGING_TYPE;
3082 #else /* no PREFERRED_DEBUGGING_TYPE */
3083 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3084 #endif /* no PREFERRED_DEBUGGING_TYPE */
3085 #endif /* More than one debugger format enabled. */
3086 #ifdef DBX_DEBUGGING_INFO
3087 if (write_symbols != NO_DEBUG)
3089 else if (!strncmp (str, "ggdb", len))
3090 write_symbols = DBX_DEBUG;
3091 else if (!strncmp (str, "gstabs", len))
3092 write_symbols = DBX_DEBUG;
3094 /* Always enable extensions for -ggdb or -gstabs+,
3095 always disable for -gstabs.
3096 For plain -g, use system-specific default. */
3097 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3099 use_gnu_debug_info_extensions = 1;
3100 else if (write_symbols == DBX_DEBUG && !strcmp (str, "gstabs+"))
3101 use_gnu_debug_info_extensions = 1;
3102 else if (write_symbols == DBX_DEBUG
3103 && !strncmp (str, "gstabs", len) && len >= 2)
3104 use_gnu_debug_info_extensions = 0;
3106 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3107 #endif /* DBX_DEBUGGING_INFO */
3108 #ifdef DWARF_DEBUGGING_INFO
3109 if (write_symbols != NO_DEBUG)
3111 else if (!strncmp (str, "g", len))
3112 write_symbols = DWARF_DEBUG;
3113 else if (!strncmp (str, "ggdb", len))
3114 write_symbols = DWARF_DEBUG;
3115 else if (!strncmp (str, "gdwarf", len))
3116 write_symbols = DWARF_DEBUG;
3118 /* Always enable extensions for -ggdb or -gdwarf+,
3119 always disable for -gdwarf.
3120 For plain -g, use system-specific default. */
3121 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3123 use_gnu_debug_info_extensions = 1;
3124 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3125 use_gnu_debug_info_extensions = 1;
3126 else if (write_symbols == DWARF_DEBUG
3127 && !strncmp (str, "gdwarf", len) && len >= 2)
3128 use_gnu_debug_info_extensions = 0;
3130 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3132 #ifdef SDB_DEBUGGING_INFO
3133 if (write_symbols != NO_DEBUG)
3135 else if (!strncmp (str, "g", len))
3136 write_symbols = SDB_DEBUG;
3137 else if (!strncmp (str, "gdb", len))
3138 write_symbols = SDB_DEBUG;
3139 else if (!strncmp (str, "gcoff", len))
3140 write_symbols = SDB_DEBUG;
3141 #endif /* SDB_DEBUGGING_INFO */
3142 #ifdef XCOFF_DEBUGGING_INFO
3143 if (write_symbols != NO_DEBUG)
3145 else if (!strncmp (str, "g", len))
3146 write_symbols = XCOFF_DEBUG;
3147 else if (!strncmp (str, "ggdb", len))
3148 write_symbols = XCOFF_DEBUG;
3149 else if (!strncmp (str, "gxcoff", len))
3150 write_symbols = XCOFF_DEBUG;
3152 /* Always enable extensions for -ggdb or -gxcoff+,
3153 always disable for -gxcoff.
3154 For plain -g, use system-specific default. */
3155 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3157 use_gnu_debug_info_extensions = 1;
3158 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3159 use_gnu_debug_info_extensions = 1;
3160 else if (write_symbols == XCOFF_DEBUG
3161 && !strncmp (str, "gxcoff", len) && len >= 2)
3162 use_gnu_debug_info_extensions = 0;
3164 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3166 if (write_symbols == NO_DEBUG)
3167 warning ("`-%s' option not supported on this version of GCC", str);
3168 else if (level == 0)
3169 write_symbols = NO_DEBUG;
3171 debug_info_level = (enum debug_info_level) level;
3173 else if (!strcmp (str, "o"))
3175 asm_file_name = argv[++i];
3177 else if (str[0] == 'G')
3179 g_switch_set = TRUE;
3180 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3182 else if (!strncmp (str, "aux-info", 8))
3184 flag_gen_aux_info = 1;
3185 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3188 error ("Invalid option `%s'", argv[i]);
3190 else if (argv[i][0] == '+')
3191 error ("Invalid option `%s'", argv[i]);
3196 /* Inlining does not work if not optimizing,
3197 so force it not to be done. */
3204 #ifdef OVERRIDE_OPTIONS
3205 /* Some machines may reject certain combinations of options. */
3209 /* Unrolling all loops implies that standard loop unrolling must also
3211 if (flag_unroll_all_loops)
3212 flag_unroll_loops = 1;
3213 /* Loop unrolling requires that strength_reduction be on also. Silently
3214 turn on strength reduction here if it isn't already on. Also, the loop
3215 unrolling code assumes that cse will be run after loop, so that must
3216 be turned on also. */
3217 if (flag_unroll_loops)
3219 flag_strength_reduce = 1;
3220 flag_rerun_cse_after_loop = 1;
3223 /* Warn about options that are not supported on this machine. */
3224 #ifndef INSN_SCHEDULING
3225 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3226 warning ("instruction scheduling not supported on this target machine");
3229 if (flag_delayed_branch)
3230 warning ("this target machine does not have delayed branches");
3233 /* If we are in verbose mode, write out the version and maybe all the
3234 option flags in use. */
3237 fprintf (stderr, "%s version %s", language_string, version_string);
3238 #ifdef TARGET_VERSION
3243 #define __VERSION__ "[unknown]"
3245 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3247 fprintf (stderr, " compiled by CC.\n");
3250 print_switch_values ();
3253 /* Now that register usage is specified, convert it to HARD_REG_SETs. */
3256 compile_file (filename);
3262 char *lim = (char *) sbrk (0);
3264 fprintf (stderr, "Data size %d.\n",
3265 lim - (char *) &environ);
3269 system ("ps -l 1>&2");
3272 #endif /* not USG */
3274 #endif /* not VMS */
3275 #endif /* not OS2 */
3278 exit (FATAL_EXIT_CODE);
3280 exit (FATAL_EXIT_CODE);
3281 exit (SUCCESS_EXIT_CODE);
3285 /* Decode -m switches. */
3287 /* Here is a table, controlled by the tm.h file, listing each -m switch
3288 and which bits in `target_switches' it should set or clear.
3289 If VALUE is positive, it is bits to set.
3290 If VALUE is negative, -VALUE is bits to clear.
3291 (The sign bit is not used so there is no confusion.) */
3293 struct {char *name; int value;} target_switches []
3296 /* This table is similar, but allows the switch to have a value. */
3298 #ifdef TARGET_OPTIONS
3299 struct {char *prefix; char ** variable;} target_options []
3303 /* Decode the switch -mNAME. */
3306 set_target_switch (name)
3312 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3313 if (!strcmp (target_switches[j].name, name))
3315 if (target_switches[j].value < 0)
3316 target_flags &= ~-target_switches[j].value;
3318 target_flags |= target_switches[j].value;
3322 #ifdef TARGET_OPTIONS
3324 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3326 int len = strlen (target_options[j].prefix);
3327 if (!strncmp (target_options[j].prefix, name, len))
3329 *target_options[j].variable = name + len;
3336 error ("Invalid option `%s'", name);
3339 /* Variable used for communication between the following two routines. */
3341 static int line_position;
3343 /* Print an option value and adjust the position in the line. */
3346 print_single_switch (type, name)
3349 fprintf (stderr, " %s%s", type, name);
3351 line_position += strlen (type) + strlen (name) + 1;
3353 if (line_position > 65)
3355 fprintf (stderr, "\n\t");
3360 /* Print default target switches for -version. */
3363 print_switch_values ()
3367 fprintf (stderr, "enabled:");
3370 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3371 if (*f_options[j].variable == f_options[j].on_value)
3372 print_single_switch ("-f", f_options[j].string);
3374 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
3375 if (*W_options[j].variable == W_options[j].on_value)
3376 print_single_switch ("-W", W_options[j].string);
3378 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3379 if (target_switches[j].name[0] != '\0'
3380 && target_switches[j].value > 0
3381 && ((target_switches[j].value & target_flags)
3382 == target_switches[j].value))
3383 print_single_switch ("-m", target_switches[j].name);
3385 fprintf (stderr, "\n");