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. */
357 int flag_volatile_global;
359 /* Nonzero means just do syntax checking; don't output anything. */
361 int flag_syntax_only = 0;
363 /* Nonzero means to rerun cse after loop optimization. This increases
364 compilation time about 20% and picks up a few more common expressions. */
366 static int flag_rerun_cse_after_loop;
368 /* Nonzero for -finline-functions: ok to inline functions that look like
369 good inline candidates. */
371 int flag_inline_functions;
373 /* Nonzero for -fkeep-inline-functions: even if we make a function
374 go inline everywhere, keep its definition around for debugging
377 int flag_keep_inline_functions;
379 /* Nonzero means that functions declared `inline' will be treated
380 as `static'. Prevents generation of zillions of copies of unused
381 static inline functions; instead, `inlines' are written out
382 only when actually used. Used in conjunction with -g. Also
383 does the right thing with #pragma interface. */
387 /* Nonzero means we should be saving declaration info into a .X file. */
389 int flag_gen_aux_info = 0;
391 /* Specified name of aux-info file. */
393 static char *aux_info_file_name;
395 /* Nonzero means make the text shared if supported. */
397 int flag_shared_data;
399 /* Nonzero means schedule into delayed branch slots if supported. */
401 int flag_delayed_branch;
403 /* Nonzero if we are compiling pure (sharable) code.
404 Value is 1 if we are doing reasonable (i.e. simple
405 offset into offset table) pic. Value is 2 if we can
406 only perform register offsets. */
410 /* Nonzero means place uninitialized global data in the bss section. */
414 /* Nonzero means pretend it is OK to examine bits of target floats,
415 even if that isn't true. The resulting code will have incorrect constants,
416 but the same series of instructions that the native compiler would make. */
418 int flag_pretend_float;
420 /* Nonzero means change certain warnings into errors.
421 Usually these are warnings about failure to conform to some standard. */
423 int flag_pedantic_errors = 0;
425 /* flag_schedule_insns means schedule insns within basic blocks (before
427 flag_schedule_insns_after_reload means schedule insns after
430 int flag_schedule_insns = 0;
431 int flag_schedule_insns_after_reload = 0;
433 /* -finhibit-size-directive inhibits output of .size for ELF.
434 This is used only for compiling crtstuff.c,
435 and it may be extended to other effects
436 needed for crtstuff.c on other systems. */
437 int flag_inhibit_size_directive = 0;
439 /* -fverbose-asm causes extra commentary information to be produced in
440 the generated assembly code (to make it more readable). This option
441 is generally only of use to those who actually need to read the
442 generated assembly code (perhaps while debugging the compiler itself). */
444 int flag_verbose_asm = 0;
446 /* -fgnu-linker specifies use of the GNU linker for initializations.
447 (Or, more generally, a linker that handles initializations.)
448 -fno-gnu-linker says that collect2 will be used. */
450 int flag_gnu_linker = 0;
452 int flag_gnu_linker = 1;
455 /* Table of language-independent -f options.
456 STRING is the option name. VARIABLE is the address of the variable.
457 ON_VALUE is the value to store in VARIABLE
458 if `-fSTRING' is seen as an option.
459 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
461 struct { char *string; int *variable; int on_value;} f_options[] =
463 {"float-store", &flag_float_store, 1},
464 {"volatile", &flag_volatile, 1},
465 {"volatile-global", &flag_volatile_global, 1},
466 {"defer-pop", &flag_defer_pop, 1},
467 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
468 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
469 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
470 {"expensive-optimizations", &flag_expensive_optimizations, 1},
471 {"thread-jumps", &flag_thread_jumps, 1},
472 {"strength-reduce", &flag_strength_reduce, 1},
473 {"unroll-loops", &flag_unroll_loops, 1},
474 {"unroll-all-loops", &flag_unroll_all_loops, 1},
475 {"writable-strings", &flag_writable_strings, 1},
476 {"peephole", &flag_no_peephole, 0},
477 {"force-mem", &flag_force_mem, 1},
478 {"force-addr", &flag_force_addr, 1},
479 {"function-cse", &flag_no_function_cse, 0},
480 {"inline-functions", &flag_inline_functions, 1},
481 {"keep-inline-functions", &flag_keep_inline_functions, 1},
482 {"inline", &flag_no_inline, 0},
483 {"syntax-only", &flag_syntax_only, 1},
484 {"shared-data", &flag_shared_data, 1},
485 {"caller-saves", &flag_caller_saves, 1},
486 {"pcc-struct-return", &flag_pcc_struct_return, 1},
487 {"delayed-branch", &flag_delayed_branch, 1},
488 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
489 {"pretend-float", &flag_pretend_float, 1},
490 {"schedule-insns", &flag_schedule_insns, 1},
491 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
492 {"pic", &flag_pic, 1},
493 {"PIC", &flag_pic, 2},
494 {"fast-math", &flag_fast_math, 1},
495 {"common", &flag_no_common, 0},
496 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
497 {"verbose-asm", &flag_verbose_asm, 1},
498 {"gnu-linker", &flag_gnu_linker, 1}
501 /* Table of language-specific options. */
503 char *lang_options[] =
512 "-fno-unsigned-char",
513 "-fsigned-bitfields",
514 "-funsigned-bitfields",
515 "-fno-signed-bitfields",
516 "-fno-unsigned-bitfields",
520 "-fno-cond-mismatch",
533 "-Wno-write-strings",
537 "-Wno-pointer-arith",
538 "-Wstrict-prototypes",
539 "-Wno-strict-prototypes",
540 "-Wmissing-prototypes",
541 "-Wno-missing-prototypes",
543 "-Wno-redundant-decls",
545 "-Wno-nested-externs",
551 "-Wno-char-subscripts",
566 /* These are for C++. */
567 "-+e0", /* gcc.c tacks the `-' on the front. */
571 "-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",
615 "-Wtemplate-debugging",
616 "-Wno-template-debugging",
618 /* these are for obj c */
626 /* Options controlling warnings */
628 /* Don't print warning messages. -w. */
630 int inhibit_warnings = 0;
632 /* Print various extra warnings. -W. */
634 int extra_warnings = 0;
636 /* Treat warnings as errors. -Werror. */
638 int warnings_are_errors = 0;
640 /* Nonzero to warn about unused local variables. */
644 /* Nonzero to warn about variables used before they are initialized. */
646 int warn_uninitialized;
648 /* Nonzero means warn about all declarations which shadow others. */
652 /* Warn if a switch on an enum fails to have a case for every enum value. */
656 /* Nonzero means warn about function definitions that default the return type
657 or that use a null return and have a return-type other than void. */
659 int warn_return_type;
661 /* Nonzero means warn about pointer casts that increase the required
662 alignment of the target type (and might therefore lead to a crash
663 due to a misaligned access). */
667 /* Nonzero means warn about any identifiers that match in the first N
668 characters. The value N is in `id_clash_len'. */
673 /* Nonzero means warn if inline function is too large. */
677 /* Warn if a function returns an aggregate,
678 since there are often incompatible calling conventions for doing this. */
680 int warn_aggregate_return;
682 /* Likewise for -W. */
684 struct { char *string; int *variable; int on_value;} W_options[] =
686 {"unused", &warn_unused, 1},
687 {"error", &warnings_are_errors, 1},
688 {"shadow", &warn_shadow, 1},
689 {"switch", &warn_switch, 1},
690 {"aggregate-return", &warn_aggregate_return, 1},
691 {"cast-align", &warn_cast_align, 1},
692 {"uninitialized", &warn_uninitialized, 1},
693 {"inline", &warn_inline, 1}
696 /* Output files for assembler code (real compiler output)
697 and debugging dumps. */
702 FILE *jump_opt_dump_file;
704 FILE *loop_dump_file;
705 FILE *cse2_dump_file;
706 FILE *flow_dump_file;
707 FILE *combine_dump_file;
708 FILE *sched_dump_file;
709 FILE *local_reg_dump_file;
710 FILE *global_reg_dump_file;
711 FILE *sched2_dump_file;
712 FILE *jump2_opt_dump_file;
713 FILE *dbr_sched_dump_file;
714 FILE *stack_reg_dump_file;
716 /* Time accumulators, to count the total time spent in various passes. */
720 int integration_time;
728 int local_alloc_time;
729 int global_alloc_time;
732 int shorten_branch_time;
738 /* Return time used so far, in microseconds. */
747 struct rusage rusage;
752 int proc_system_time;
754 int child_system_time;
764 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
767 getrusage (0, &rusage);
768 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
769 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
772 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
777 #define TIMEVAR(VAR, BODY) \
778 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
781 print_time (str, total)
786 "time in %s: %d.%06d\n",
787 str, total / 1000000, total % 1000000);
790 /* Count an error or warning. Return 1 if the message should be printed. */
793 count_error (warningp)
796 if (warningp && inhibit_warnings)
799 if (warningp && !warnings_are_errors)
803 static int warning_message = 0;
805 if (warningp && !warning_message)
807 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
816 /* Print a fatal error message. NAME is the text.
817 Also include a system error message based on `errno'. */
820 pfatal_with_name (name)
823 fprintf (stderr, "%s: ", progname);
829 fatal_io_error (name)
832 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
845 /* Called to give a better error message when we don't have an insn to match
846 what we are looking for or if the insn's constraints aren't satisfied,
847 rather than just calling abort(). */
850 fatal_insn_not_found (insn)
853 if (INSN_CODE (insn) < 0)
854 error ("internal error--unrecognizable insn:", 0);
856 error ("internal error--insn does not satisfy its constraints:", 0);
859 fflush (asm_out_file);
861 fflush (aux_info_file);
863 fflush (rtl_dump_file);
864 if (jump_opt_dump_file)
865 fflush (jump_opt_dump_file);
867 fflush (cse_dump_file);
869 fflush (loop_dump_file);
871 fflush (cse2_dump_file);
873 fflush (flow_dump_file);
874 if (combine_dump_file)
875 fflush (combine_dump_file);
877 fflush (sched_dump_file);
878 if (local_reg_dump_file)
879 fflush (local_reg_dump_file);
880 if (global_reg_dump_file)
881 fflush (global_reg_dump_file);
882 if (sched2_dump_file)
883 fflush (sched2_dump_file);
884 if (jump2_opt_dump_file)
885 fflush (jump2_opt_dump_file);
886 if (dbr_sched_dump_file)
887 fflush (dbr_sched_dump_file);
888 if (stack_reg_dump_file)
889 fflush (stack_reg_dump_file);
893 /* This is the default decl_printable_name function. */
896 decl_name (decl, kind)
900 return IDENTIFIER_POINTER (DECL_NAME (decl));
903 static int need_error_newline;
905 /* Function of last error message;
906 more generally, function such that if next error message is in it
907 then we don't have to mention the function name. */
908 static tree last_error_function = NULL;
910 /* Used to detect when input_file_stack has changed since last described. */
911 static int last_error_tick;
913 /* Called when the start of a function definition is parsed,
914 this function prints on stderr the name of the function. */
917 announce_function (decl)
923 if (rtl_dump_and_exit)
924 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
926 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
928 need_error_newline = 1;
929 last_error_function = current_function_decl;
933 /* Prints out, if necessary, the name of the current function
934 which caused an error. Called from all error and warning functions. */
937 report_error_function (file)
940 struct file_stack *p;
942 if (need_error_newline)
944 fprintf (stderr, "\n");
945 need_error_newline = 0;
948 if (last_error_function != current_function_decl)
950 char *kind = "function";
951 if (current_function_decl != 0
952 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
956 fprintf (stderr, "%s: ", file);
958 if (current_function_decl == NULL)
959 fprintf (stderr, "At top level:\n");
962 char *name = (*decl_printable_name) (current_function_decl, &kind);
963 fprintf (stderr, "In %s `%s':\n", kind, name);
966 last_error_function = current_function_decl;
968 if (input_file_stack && input_file_stack->next != 0
969 && input_file_stack_tick != last_error_tick)
971 fprintf (stderr, "In file included");
972 for (p = input_file_stack->next; p; p = p->next)
974 fprintf (stderr, " from %s:%d", p->name, p->line);
976 fprintf (stderr, ",");
978 fprintf (stderr, ":\n");
979 last_error_tick = input_file_stack_tick;
983 /* Report an error at the current line number.
984 S is a string and V and V2 are args for `printf'. We use HOST_WIDE_INT
985 as the type for these args assuming it is wide enough to hold a
986 pointer. This isn't terribly portable, but is the best we can do
987 without vprintf universally available. */
992 HOST_WIDE_INT v; /* Also used as pointer */
993 HOST_WIDE_INT v2; /* Also used as pointer */
995 error_with_file_and_line (input_filename, lineno, s, v, v2);
998 /* Report an error at line LINE of file FILE.
999 S and V are a string and an arg for `printf'. */
1002 error_with_file_and_line (file, line, s, v, v2)
1011 report_error_function (file);
1014 fprintf (stderr, "%s:%d: ", file, line);
1016 fprintf (stderr, "%s: ", progname);
1017 fprintf (stderr, s, v, v2);
1018 fprintf (stderr, "\n");
1021 /* Report an error at the declaration DECL.
1022 S and V are a string and an arg which uses %s to substitute
1023 the declaration name. */
1026 error_with_decl (decl, s, v)
1034 report_error_function (DECL_SOURCE_FILE (decl));
1036 fprintf (stderr, "%s:%d: ",
1037 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1039 if (DECL_NAME (decl))
1040 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1042 fprintf (stderr, s, "((anonymous))", v);
1043 fprintf (stderr, "\n");
1046 /* Report an error at the line number of the insn INSN.
1047 S and V are a string and an arg for `printf'.
1048 This is used only when INSN is an `asm' with operands,
1049 and each ASM_OPERANDS records its own source file and line. */
1052 error_for_asm (insn, s, v, v2)
1055 HOST_WIDE_INT v; /* Also used as pointer */
1056 HOST_WIDE_INT v2; /* Also used as pointer */
1060 rtx body = PATTERN (insn);
1063 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1064 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1065 asmop = SET_SRC (body);
1066 else if (GET_CODE (body) == ASM_OPERANDS)
1068 else if (GET_CODE (body) == PARALLEL
1069 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1070 asmop = SET_SRC (XVECEXP (body, 0, 0));
1071 else if (GET_CODE (body) == PARALLEL
1072 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1073 asmop = XVECEXP (body, 0, 0);
1075 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1076 line = ASM_OPERANDS_SOURCE_LINE (asmop);
1078 error_with_file_and_line (filename, line, s, v, v2);
1081 /* Report a warning at line LINE.
1082 S and V are a string and an arg for `printf'. */
1085 warning_with_file_and_line (file, line, s, v, v2, v3)
1089 HOST_WIDE_INT v, v2, v3;
1091 if (count_error (1) == 0)
1094 report_error_function (file);
1097 fprintf (stderr, "%s:%d: ", file, line);
1099 fprintf (stderr, "%s: ", progname);
1101 fprintf (stderr, "warning: ");
1102 fprintf (stderr, s, v, v2, v3);
1103 fprintf (stderr, "\n");
1106 /* Report a warning at the current line number.
1107 S and V are a string and an arg for `printf'. */
1110 warning (s, v, v2, v3)
1112 HOST_WIDE_INT v, v2, v3; /* Also used as pointer */
1114 warning_with_file_and_line (input_filename, lineno, s, v, v2, v3);
1117 /* Report a warning at the declaration DECL.
1118 S is string which uses %s to substitute the declaration name.
1119 V is a second parameter that S can refer to. */
1122 warning_with_decl (decl, s, v)
1129 if (count_error (1) == 0)
1132 report_error_function (DECL_SOURCE_FILE (decl));
1134 fprintf (stderr, "%s:%d: ",
1135 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1137 fprintf (stderr, "warning: ");
1138 if (DECL_NAME (decl))
1139 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
1141 fprintf (stderr, s, "((anonymous))", v);
1142 fprintf (stderr, "\n");
1145 /* Report a warning at the line number of the insn INSN.
1146 S and V are a string and an arg for `printf'.
1147 This is used only when INSN is an `asm' with operands,
1148 and each ASM_OPERANDS records its own source file and line. */
1151 warning_for_asm (insn, s, v, v2)
1154 HOST_WIDE_INT v; /* Also used as pointer */
1155 HOST_WIDE_INT v2; /* Also used as pointer */
1159 rtx body = PATTERN (insn);
1162 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1163 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1164 asmop = SET_SRC (body);
1165 else if (GET_CODE (body) == ASM_OPERANDS)
1167 else if (GET_CODE (body) == PARALLEL
1168 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1169 asmop = SET_SRC (XVECEXP (body, 0, 0));
1170 else if (GET_CODE (body) == PARALLEL
1171 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1172 asmop = XVECEXP (body, 0, 0);
1174 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1175 line = ASM_OPERANDS_SOURCE_LINE (asmop);
1177 warning_with_file_and_line (filename, line, s, v, v2);
1180 /* These functions issue either warnings or errors depending on
1181 -pedantic-errors. */
1186 HOST_WIDE_INT v; /* Also used as pointer */
1189 if (flag_pedantic_errors)
1196 pedwarn_with_decl (decl, s, v)
1201 if (flag_pedantic_errors)
1202 error_with_decl (decl, s, v);
1204 warning_with_decl (decl, s, v);
1208 pedwarn_with_file_and_line (file, line, s, v, v2)
1215 if (flag_pedantic_errors)
1216 error_with_file_and_line (file, line, s, v, v2);
1218 warning_with_file_and_line (file, line, s, v, v2);
1221 /* Apologize for not implementing some feature.
1222 S, V, and V2 are a string and args for `printf'. */
1227 HOST_WIDE_INT v, v2;
1231 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1233 fprintf (stderr, "%s: ", progname);
1235 fprintf (stderr, "sorry, not implemented: ");
1236 fprintf (stderr, s, v, v2);
1237 fprintf (stderr, "\n");
1240 /* Apologize for not implementing some feature, then quit.
1241 S, V, and V2 are a string and args for `printf'. */
1244 really_sorry (s, v, v2)
1246 HOST_WIDE_INT v, v2;
1249 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1251 fprintf (stderr, "%s: ", progname);
1253 fprintf (stderr, "sorry, not implemented: ");
1254 fprintf (stderr, s, v, v2);
1255 fatal (" (fatal)\n");
1258 /* More 'friendly' abort that prints the line and file.
1259 config.h can #define abort fancy_abort if you like that sort of thing.
1261 I don't think this is actually a good idea.
1262 Other sorts of crashes will look a certain way.
1263 It is a good thing if crashes from calling abort look the same way.
1269 fatal ("internal gcc abort");
1272 /* This calls abort and is used to avoid problems when abort if a macro.
1273 It is used when we need to pass the address of abort. */
1281 /* When `malloc.c' is compiled with `rcheck' defined,
1282 it calls this function to report clobberage. */
1290 /* Same as `malloc' but report error if no memory available. */
1296 register char *value = (char *) malloc (size);
1298 fatal ("virtual memory exhausted");
1302 /* Same as `realloc' but report error if no memory available. */
1305 xrealloc (ptr, size)
1309 char *result = (char *) realloc (ptr, size);
1311 fatal ("virtual memory exhausted");
1315 /* Return the logarithm of X, base 2, considering X unsigned,
1316 if X is a power of 2. Otherwise, returns -1.
1318 This should be used via the `exact_log2' macro. */
1322 register unsigned HOST_WIDE_INT x;
1324 register int log = 0;
1325 /* Test for 0 or a power of 2. */
1326 if (x == 0 || x != (x & -x))
1328 while ((x >>= 1) != 0)
1333 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1334 If X is 0, return -1.
1336 This should be used via the floor_log2 macro. */
1340 register unsigned HOST_WIDE_INT x;
1342 register int log = -1;
1350 jmp_buf float_handler;
1352 /* Specify where to longjmp to when a floating arithmetic error happens.
1353 If HANDLER is 0, it means don't handle the errors any more. */
1356 set_float_handler (handler)
1359 float_handled = (handler != 0);
1361 bcopy (handler, float_handler, sizeof (float_handler));
1364 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1365 error happens, pushing the previous specification into OLD_HANDLER.
1366 Return an indication of whether there was a previous handler in effect. */
1369 push_float_handler (handler, old_handler)
1370 jmp_buf handler, old_handler;
1372 int was_handled = float_handled;
1376 bcopy (float_handler, old_handler, sizeof (float_handler));
1377 bcopy (handler, float_handler, sizeof (float_handler));
1381 /* Restore the previous specification of whether and where to longjmp to
1382 when a floating arithmetic error happens. */
1385 pop_float_handler (handled, handler)
1389 float_handled = handled;
1391 bcopy (handler, float_handler, sizeof (float_handler));
1394 /* Signals actually come here. */
1397 float_signal (signo)
1398 /* If this is missing, some compilers complain. */
1401 if (float_handled == 0)
1403 #if defined (USG) || defined (hpux)
1404 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1407 signal (SIGFPE, float_signal);
1408 longjmp (float_handler, 1);
1411 /* Handler for SIGPIPE. */
1415 /* If this is missing, some compilers complain. */
1418 fatal ("output pipe has been closed");
1421 /* Strip off a legitimate source ending from the input string NAME of
1425 strip_off_ending (name, len)
1429 if (len > 2 && ! strcmp (".c", name + len - 2))
1431 else if (len > 2 && ! strcmp (".m", name + len - 2))
1433 else if (len > 2 && ! strcmp (".i", name + len - 2))
1435 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1437 else if (len > 3 && ! strcmp (".co", name + len - 3))
1439 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1441 else if (len > 2 && ! strcmp (".C", name + len - 2))
1443 else if (len > 4 && ! strcmp (".cxx", name + len - 4))
1445 else if (len > 2 && ! strcmp (".f", name + len - 2))
1447 else if (len > 4 && ! strcmp (".ada", name + len - 4))
1451 /* Output a file name in the form wanted by System V. */
1454 output_file_directive (asm_file, input_name)
1458 int len = strlen (input_name);
1459 char *na = input_name + len;
1461 /* NA gets INPUT_NAME sans directory names. */
1462 while (na > input_name)
1469 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1470 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1472 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1473 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1475 fprintf (asm_file, "\t.file\t\"%s\"\n", na);
1480 /* Compile an entire file of output from cpp, named NAME.
1481 Write a file of assembly output and various debugging dumps. */
1489 int dump_base_name_length;
1491 int name_specified = name != 0;
1493 if (dump_base_name == 0)
1494 dump_base_name = name ? name : "gccdump";
1495 dump_base_name_length = strlen (dump_base_name);
1499 integration_time = 0;
1507 local_alloc_time = 0;
1508 global_alloc_time = 0;
1511 shorten_branch_time = 0;
1517 /* Open input file. */
1519 if (name == 0 || !strcmp (name, "-"))
1525 finput = fopen (name, "r");
1527 pfatal_with_name (name);
1529 #ifdef IO_BUFFER_SIZE
1530 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
1533 /* Initialize data in various passes. */
1539 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
1540 || debug_info_level == DINFO_LEVEL_VERBOSE);
1541 init_decl_processing ();
1549 if (flag_caller_saves)
1550 init_caller_save ();
1552 /* If auxiliary info generation is desired, open the output file.
1553 This goes in the same directory as the source file--unlike
1554 all the other output files. */
1555 if (flag_gen_aux_info)
1557 aux_info_file = fopen (aux_info_file_name, "w");
1558 if (aux_info_file == 0)
1559 pfatal_with_name (aux_info_file_name);
1562 /* If rtl dump desired, open the output file. */
1565 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1566 strcpy (dumpname, dump_base_name);
1567 strcat (dumpname, ".rtl");
1568 rtl_dump_file = fopen (dumpname, "w");
1569 if (rtl_dump_file == 0)
1570 pfatal_with_name (dumpname);
1573 /* If jump_opt dump desired, open the output file. */
1576 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1577 strcpy (dumpname, dump_base_name);
1578 strcat (dumpname, ".jump");
1579 jump_opt_dump_file = fopen (dumpname, "w");
1580 if (jump_opt_dump_file == 0)
1581 pfatal_with_name (dumpname);
1584 /* If cse dump desired, open the output file. */
1587 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1588 strcpy (dumpname, dump_base_name);
1589 strcat (dumpname, ".cse");
1590 cse_dump_file = fopen (dumpname, "w");
1591 if (cse_dump_file == 0)
1592 pfatal_with_name (dumpname);
1595 /* If loop dump desired, open the output file. */
1598 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1599 strcpy (dumpname, dump_base_name);
1600 strcat (dumpname, ".loop");
1601 loop_dump_file = fopen (dumpname, "w");
1602 if (loop_dump_file == 0)
1603 pfatal_with_name (dumpname);
1606 /* If cse2 dump desired, open the output file. */
1609 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1610 strcpy (dumpname, dump_base_name);
1611 strcat (dumpname, ".cse2");
1612 cse2_dump_file = fopen (dumpname, "w");
1613 if (cse2_dump_file == 0)
1614 pfatal_with_name (dumpname);
1617 /* If flow dump desired, open the output file. */
1620 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1621 strcpy (dumpname, dump_base_name);
1622 strcat (dumpname, ".flow");
1623 flow_dump_file = fopen (dumpname, "w");
1624 if (flow_dump_file == 0)
1625 pfatal_with_name (dumpname);
1628 /* If combine dump desired, open the output file. */
1631 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1632 strcpy (dumpname, dump_base_name);
1633 strcat (dumpname, ".combine");
1634 combine_dump_file = fopen (dumpname, "w");
1635 if (combine_dump_file == 0)
1636 pfatal_with_name (dumpname);
1639 /* If scheduling dump desired, open the output file. */
1642 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1643 strcpy (dumpname, dump_base_name);
1644 strcat (dumpname, ".sched");
1645 sched_dump_file = fopen (dumpname, "w");
1646 if (sched_dump_file == 0)
1647 pfatal_with_name (dumpname);
1650 /* If local_reg dump desired, open the output file. */
1653 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1654 strcpy (dumpname, dump_base_name);
1655 strcat (dumpname, ".lreg");
1656 local_reg_dump_file = fopen (dumpname, "w");
1657 if (local_reg_dump_file == 0)
1658 pfatal_with_name (dumpname);
1661 /* If global_reg dump desired, open the output file. */
1662 if (global_reg_dump)
1664 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1665 strcpy (dumpname, dump_base_name);
1666 strcat (dumpname, ".greg");
1667 global_reg_dump_file = fopen (dumpname, "w");
1668 if (global_reg_dump_file == 0)
1669 pfatal_with_name (dumpname);
1672 /* If 2nd scheduling dump desired, open the output file. */
1675 register char *dumpname = (char *) xmalloc (dump_base_name_length + 8);
1676 strcpy (dumpname, dump_base_name);
1677 strcat (dumpname, ".sched2");
1678 sched2_dump_file = fopen (dumpname, "w");
1679 if (sched2_dump_file == 0)
1680 pfatal_with_name (dumpname);
1683 /* If jump2_opt dump desired, open the output file. */
1686 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1687 strcpy (dumpname, dump_base_name);
1688 strcat (dumpname, ".jump2");
1689 jump2_opt_dump_file = fopen (dumpname, "w");
1690 if (jump2_opt_dump_file == 0)
1691 pfatal_with_name (dumpname);
1694 /* If dbr_sched dump desired, open the output file. */
1697 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1698 strcpy (dumpname, dump_base_name);
1699 strcat (dumpname, ".dbr");
1700 dbr_sched_dump_file = fopen (dumpname, "w");
1701 if (dbr_sched_dump_file == 0)
1702 pfatal_with_name (dumpname);
1707 /* If stack_reg dump desired, open the output file. */
1710 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1711 strcpy (dumpname, dump_base_name);
1712 strcat (dumpname, ".stack");
1713 stack_reg_dump_file = fopen (dumpname, "w");
1714 if (stack_reg_dump_file == 0)
1715 pfatal_with_name (dumpname);
1720 /* Open assembler code output file. */
1722 if (! name_specified && asm_file_name == 0)
1723 asm_out_file = stdout;
1726 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1727 int len = strlen (dump_base_name);
1728 strcpy (dumpname, dump_base_name);
1729 strip_off_ending (dumpname, len);
1730 strcat (dumpname, ".s");
1731 if (asm_file_name == 0)
1733 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
1734 strcpy (asm_file_name, dumpname);
1736 if (!strcmp (asm_file_name, "-"))
1737 asm_out_file = stdout;
1739 asm_out_file = fopen (asm_file_name, "w");
1740 if (asm_out_file == 0)
1741 pfatal_with_name (asm_file_name);
1744 #ifdef IO_BUFFER_SIZE
1745 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
1746 _IOFBF, IO_BUFFER_SIZE);
1749 input_filename = name;
1751 /* Perform language-specific initialization.
1752 This may set main_input_filename. */
1755 /* If the input doesn't start with a #line, use the input name
1756 as the official input file name. */
1757 if (main_input_filename == 0)
1758 main_input_filename = name;
1760 /* Put an entry on the input file stack for the main input file. */
1762 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
1763 input_file_stack->next = 0;
1764 input_file_stack->name = input_filename;
1766 ASM_FILE_START (asm_out_file);
1768 /* Output something to inform GDB that this compilation was by GCC. */
1769 #ifndef ASM_IDENTIFY_GCC
1770 fprintf (asm_out_file, "gcc2_compiled.:\n");
1772 ASM_IDENTIFY_GCC (asm_out_file);
1774 /* Don't let the first function fall at the same address
1775 as gcc_compiled., if profiling. */
1776 if (profile_flag || profile_block_flag)
1777 assemble_zeros (UNITS_PER_WORD);
1779 /* If dbx symbol table desired, initialize writing it
1780 and output the predefined types. */
1781 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1782 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1783 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
1786 #ifdef SDB_DEBUGGING_INFO
1787 if (write_symbols == SDB_DEBUG)
1788 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
1791 #ifdef DWARF_DEBUGGING_INFO
1792 if (write_symbols == DWARF_DEBUG)
1793 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
1796 /* Initialize yet another pass. */
1798 init_final (main_input_filename);
1800 start_time = get_run_time ();
1802 /* Call the parser, which parses the entire file
1803 (calling rest_of_compilation for each function). */
1805 if (yyparse () != 0)
1806 if (errorcount == 0)
1807 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
1809 /* Compilation is now finished except for writing
1810 what's left of the symbol table output. */
1812 parse_time += get_run_time () - start_time;
1814 parse_time -= integration_time;
1815 parse_time -= varconst_time;
1817 globals = getdecls ();
1819 /* Really define vars that have had only a tentative definition.
1820 Really output inline functions that must actually be callable
1821 and have not been output so far. */
1824 int len = list_length (globals);
1825 tree *vec = (tree *) alloca (sizeof (tree) * len);
1829 /* Process the decls in reverse order--earliest first.
1830 Put them into VEC from back to front, then take out from front. */
1832 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
1833 vec[len - i - 1] = decl;
1835 for (i = 0; i < len; i++)
1838 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1839 && ! TREE_ASM_WRITTEN (decl))
1841 /* Don't write out static consts, unless we used them.
1842 (This used to write them out only if the address was
1843 taken, but that was wrong; if the variable was simply
1844 referred to, it still needs to exist or else it will
1845 be undefined in the linker.) */
1846 if (! TREE_READONLY (decl)
1847 || TREE_PUBLIC (decl)
1849 || TREE_ADDRESSABLE (decl)
1850 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1851 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1853 /* Cancel the RTL for this decl so that, if debugging info
1854 output for global variables is still to come,
1855 this one will be omitted. */
1856 DECL_RTL (decl) = NULL;
1859 if (TREE_CODE (decl) == FUNCTION_DECL
1860 && ! TREE_ASM_WRITTEN (decl)
1861 && DECL_INITIAL (decl) != 0
1862 && (TREE_ADDRESSABLE (decl)
1863 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1864 && ! DECL_EXTERNAL (decl))
1865 output_inline_function (decl);
1867 /* Warn about any function
1868 declared static but not defined.
1869 We don't warn about variables,
1870 because many programs have static variables
1871 that exist only to get some text into the object file. */
1874 || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))))
1875 && TREE_CODE (decl) == FUNCTION_DECL
1876 && DECL_INITIAL (decl) == 0
1877 && DECL_EXTERNAL (decl)
1878 && ! TREE_PUBLIC (decl))
1879 pedwarn_with_decl (decl, "`%s' declared `static' but never defined");
1880 /* Warn about static fns or vars defined but not used,
1881 but not about inline functions
1882 since unused inline statics is normal practice. */
1884 && (TREE_CODE (decl) == FUNCTION_DECL
1885 || TREE_CODE (decl) == VAR_DECL)
1886 && ! DECL_IN_SYSTEM_HEADER (decl)
1887 && ! DECL_EXTERNAL (decl)
1888 && ! TREE_PUBLIC (decl)
1889 && ! TREE_USED (decl)
1890 && ! DECL_INLINE (decl)
1891 && ! DECL_REGISTER (decl)
1892 /* The TREE_USED bit for file-scope decls
1893 is kept in the identifier, to handle multiple
1894 external decls in different scopes. */
1895 && ! TREE_USED (DECL_NAME (decl)))
1896 warning_with_decl (decl, "`%s' defined but not used");
1898 #ifdef SDB_DEBUGGING_INFO
1899 /* The COFF linker can move initialized global vars to the end.
1900 And that can screw up the symbol ordering.
1901 By putting the symbols in that order to begin with,
1902 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1903 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
1904 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
1905 && DECL_RTL (decl) != 0)
1906 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1908 /* Output COFF information for non-global
1909 file-scope initialized variables. */
1910 if (write_symbols == SDB_DEBUG
1911 && TREE_CODE (decl) == VAR_DECL
1912 && DECL_INITIAL (decl)
1913 && DECL_RTL (decl) != 0
1914 && GET_CODE (DECL_RTL (decl)) == MEM)
1915 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
1916 #endif /* SDB_DEBUGGING_INFO */
1917 #ifdef DWARF_DEBUGGING_INFO
1918 /* Output DWARF information for file-scope tentative data object
1919 declarations, file-scope (extern) function declarations (which
1920 had no corresponding body) and file-scope tagged type declarations
1921 and definitions which have not yet been forced out. */
1923 if (write_symbols == DWARF_DEBUG
1924 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1925 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
1930 /* Do dbx symbols */
1931 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1932 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1933 TIMEVAR (symout_time,
1935 dbxout_finish (asm_out_file, main_input_filename);
1939 #ifdef DWARF_DEBUGGING_INFO
1940 if (write_symbols == DWARF_DEBUG)
1941 TIMEVAR (symout_time,
1947 /* Output some stuff at end of file if nec. */
1949 end_final (main_input_filename);
1952 ASM_FILE_END (asm_out_file);
1955 after_finish_compilation:
1957 /* Language-specific end of compilation actions. */
1961 /* Close the dump files. */
1963 if (flag_gen_aux_info)
1965 fclose (aux_info_file);
1967 unlink (aux_info_file_name);
1971 fclose (rtl_dump_file);
1974 fclose (jump_opt_dump_file);
1977 fclose (cse_dump_file);
1980 fclose (loop_dump_file);
1983 fclose (cse2_dump_file);
1986 fclose (flow_dump_file);
1990 dump_combine_total_stats (combine_dump_file);
1991 fclose (combine_dump_file);
1995 fclose (sched_dump_file);
1998 fclose (local_reg_dump_file);
2000 if (global_reg_dump)
2001 fclose (global_reg_dump_file);
2004 fclose (sched2_dump_file);
2007 fclose (jump2_opt_dump_file);
2010 fclose (dbr_sched_dump_file);
2014 fclose (stack_reg_dump_file);
2017 /* Close non-debugging input and output files. Take special care to note
2018 whether fclose returns an error, since the pages might still be on the
2019 buffer chain while the file is open. */
2022 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2023 fatal_io_error (asm_file_name);
2025 /* Print the times. */
2029 fprintf (stderr,"\n");
2030 print_time ("parse", parse_time);
2031 print_time ("integration", integration_time);
2032 print_time ("jump", jump_time);
2033 print_time ("cse", cse_time);
2034 print_time ("loop", loop_time);
2035 print_time ("cse2", cse2_time);
2036 print_time ("flow", flow_time);
2037 print_time ("combine", combine_time);
2038 print_time ("sched", sched_time);
2039 print_time ("local-alloc", local_alloc_time);
2040 print_time ("global-alloc", global_alloc_time);
2041 print_time ("sched2", sched2_time);
2042 print_time ("dbranch", dbr_sched_time);
2043 print_time ("shorten-branch", shorten_branch_time);
2044 print_time ("stack-reg", stack_reg_time);
2045 print_time ("final", final_time);
2046 print_time ("varconst", varconst_time);
2047 print_time ("symout", symout_time);
2048 print_time ("dump", dump_time);
2052 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2053 and TYPE_DECL nodes.
2055 This does nothing for local (non-static) variables.
2056 Otherwise, it sets up the RTL and outputs any assembler code
2057 (label definition, storage allocation and initialization).
2059 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2060 the assembler symbol name to be used. TOP_LEVEL is nonzero
2061 if this declaration is not within a function. */
2064 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2070 /* Declarations of variables, and of functions defined elsewhere. */
2072 /* Forward declarations for nested functions are not "external",
2073 but we need to treat them as if they were. */
2074 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2075 || TREE_CODE (decl) == FUNCTION_DECL)
2076 TIMEVAR (varconst_time,
2078 make_decl_rtl (decl, asmspec, top_level);
2079 /* For a user-invisible decl that should be replaced
2080 by its value when used, don't output anything. */
2081 if (! (TREE_CODE (decl) == VAR_DECL
2082 && DECL_IGNORED_P (decl) && TREE_READONLY (decl)
2083 && DECL_INITIAL (decl) != 0))
2084 /* Don't output anything
2085 when a tentative file-scope definition is seen.
2086 But at end of compilation, do output code for them. */
2087 if (! (! at_end && top_level
2088 && (DECL_INITIAL (decl) == 0
2089 || DECL_INITIAL (decl) == error_mark_node
2090 || DECL_IGNORED_P (decl))))
2091 assemble_variable (decl, top_level, at_end);
2093 else if (DECL_REGISTER (decl) && asmspec != 0)
2095 if (decode_reg_name (asmspec) >= 0)
2097 DECL_RTL (decl) = 0;
2098 make_decl_rtl (decl, asmspec, top_level);
2101 error ("invalid register name `%s' for register variable", asmspec);
2103 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2104 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2105 && TREE_CODE (decl) == TYPE_DECL)
2106 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2108 #ifdef SDB_DEBUGGING_INFO
2109 else if (write_symbols == SDB_DEBUG && top_level
2110 && TREE_CODE (decl) == TYPE_DECL)
2111 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2115 /* Called after finishing a record, union or enumeral type. */
2118 rest_of_type_compilation (type, toplev)
2122 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2123 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2124 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2126 #ifdef SDB_DEBUGGING_INFO
2127 if (write_symbols == SDB_DEBUG)
2128 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2132 /* This is called from finish_function (within yyparse)
2133 after each top-level definition is parsed.
2134 It is supposed to compile that function or variable
2135 and output the assembler code for it.
2136 After we return, the tree storage is freed. */
2139 rest_of_compilation (decl)
2143 int start_time = get_run_time ();
2145 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2146 to be restored after we finish compiling the function
2147 (for use when compiling inline calls to this function). */
2148 tree saved_block_tree = 0;
2149 /* Likewise, for DECL_ARGUMENTS. */
2150 tree saved_arguments = 0;
2153 /* If we are reconsidering an inline function
2154 at the end of compilation, skip the stuff for making it inline. */
2156 if (DECL_SAVED_INSNS (decl) == 0)
2158 int specd = DECL_INLINE (decl);
2161 /* If requested, consider whether to make this function inline. */
2162 if (specd || flag_inline_functions)
2163 TIMEVAR (integration_time,
2165 lose = function_cannot_inline_p (decl);
2168 if (warn_inline && specd)
2169 warning_with_decl (decl, lose);
2170 DECL_INLINE (decl) = 0;
2173 DECL_INLINE (decl) = 1;
2176 insns = get_insns ();
2178 /* Dump the rtl code if we are dumping rtl. */
2183 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
2184 IDENTIFIER_POINTER (DECL_NAME (decl)));
2185 if (DECL_SAVED_INSNS (decl))
2186 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2187 print_rtl (rtl_dump_file, insns);
2188 fflush (rtl_dump_file);
2191 /* If function is inline, and we don't yet know whether to
2192 compile it by itself, defer decision till end of compilation.
2193 finish_compilation will call rest_of_compilation again
2194 for those functions that need to be output. */
2196 if (DECL_INLINE (decl)
2197 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2198 && ! flag_keep_inline_functions)
2199 || DECL_EXTERNAL (decl)))
2201 #ifdef DWARF_DEBUGGING_INFO
2202 /* Generate the DWARF info for the "abstract" instance
2203 of a function which we may later generate inlined and/or
2204 out-of-line instances of. */
2205 if (write_symbols == DWARF_DEBUG)
2207 set_decl_abstract_flags (decl, 1);
2208 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2209 set_decl_abstract_flags (decl, 0);
2212 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2213 goto exit_rest_of_compilation;
2216 /* If we have to compile the function now, save its rtl and subdecls
2217 so that its compilation will not affect what others get. */
2218 if (DECL_INLINE (decl))
2220 #ifdef DWARF_DEBUGGING_INFO
2221 /* Generate the DWARF info for the "abstract" instance of
2222 a function which we will generate an out-of-line instance
2223 of almost immediately (and which we may also later generate
2224 various inlined instances of). */
2225 if (write_symbols == DWARF_DEBUG)
2227 set_decl_abstract_flags (decl, 1);
2228 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2229 set_decl_abstract_flags (decl, 0);
2232 saved_block_tree = DECL_INITIAL (decl);
2233 saved_arguments = DECL_ARGUMENTS (decl);
2234 TIMEVAR (integration_time, save_for_inline_copying (decl));
2238 TREE_ASM_WRITTEN (decl) = 1;
2240 /* Now that integrate will no longer see our rtl, we need not distinguish
2241 between the return value of this function and the return value of called
2243 rtx_equal_function_value_matters = 0;
2245 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2246 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2248 goto exit_rest_of_compilation;
2251 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2252 Note that that may have been done above, in save_for_inline_copying.
2253 The call to resume_temporary_allocation near the end of this function
2254 goes back to the usual state of affairs. */
2256 rtl_in_current_obstack ();
2259 /* If we are doing position-independent code generation, now
2260 is the time to output special prologues and epilogues.
2261 We do not want to do this earlier, because it just clutters
2262 up inline functions with meaningless insns. */
2267 insns = get_insns ();
2269 /* Copy any shared structure that should not be shared. */
2271 unshare_all_rtl (insns);
2273 /* Instantiate all virtual registers. */
2275 instantiate_virtual_regs (current_function_decl, get_insns ());
2277 /* See if we have allocated stack slots that are not directly addressable.
2278 If so, scan all the insns and create explicit address computation
2279 for all references to such slots. */
2280 /* fixup_stack_slots (); */
2282 /* Do jump optimization the first time, if -opt.
2283 Also do it if -W, but in that case it doesn't change the rtl code,
2284 it only computes whether control can drop off the end of the function. */
2286 if (optimize > 0 || extra_warnings || warn_return_type
2287 /* If function is `volatile', we should warn if it tries to return. */
2288 || TREE_THIS_VOLATILE (decl))
2290 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2291 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2294 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2295 if (rtl_dump_and_exit || flag_syntax_only)
2296 goto exit_rest_of_compilation;
2298 /* Dump rtl code after jump, if we are doing that. */
2303 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2304 IDENTIFIER_POINTER (DECL_NAME (decl)));
2305 print_rtl (jump_opt_dump_file, insns);
2306 fflush (jump_opt_dump_file);
2309 /* Perform common subexpression elimination.
2310 Nonzero value from `cse_main' means that jumps were simplified
2311 and some code may now be unreachable, so do
2312 jump optimization again. */
2317 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2318 IDENTIFIER_POINTER (DECL_NAME (decl)));
2323 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2325 if (flag_thread_jumps)
2326 /* Hacks by tiemann & kenner. */
2327 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2329 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2331 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2334 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2337 /* Dump rtl code after cse, if we are doing that. */
2342 print_rtl (cse_dump_file, insns);
2343 fflush (cse_dump_file);
2349 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2350 IDENTIFIER_POINTER (DECL_NAME (decl)));
2353 /* Move constant computations out of loops. */
2359 loop_optimize (insns, loop_dump_file);
2363 /* Dump rtl code after loop opt, if we are doing that. */
2368 print_rtl (loop_dump_file, insns);
2369 fflush (loop_dump_file);
2375 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2376 IDENTIFIER_POINTER (DECL_NAME (decl)));
2379 if (optimize > 0 && flag_rerun_cse_after_loop)
2381 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2383 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2384 1, cse2_dump_file));
2386 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2389 if (optimize > 0 && flag_thread_jumps)
2390 /* This pass of jump threading straightens out code
2391 that was kinked by loop optimization. */
2392 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2394 /* Dump rtl code after cse, if we are doing that. */
2399 print_rtl (cse2_dump_file, insns);
2400 fflush (cse2_dump_file);
2403 /* We are no longer anticipating cse in this function, at least. */
2405 cse_not_expected = 1;
2407 /* Now we choose between stupid (pcc-like) register allocation
2408 (if we got the -noreg switch and not -opt)
2409 and smart register allocation. */
2411 if (optimize > 0) /* Stupid allocation probably won't work */
2412 obey_regdecls = 0; /* if optimizations being done. */
2416 /* Print function header into flow dump now
2417 because doing the flow analysis makes some of the dump. */
2422 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2423 IDENTIFIER_POINTER (DECL_NAME (decl)));
2430 regclass (insns, max_reg_num ());
2431 stupid_life_analysis (insns, max_reg_num (),
2437 /* Do control and data flow analysis,
2438 and write some of the results to dump file. */
2440 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2442 if (warn_uninitialized)
2444 uninitialized_vars_warning (DECL_INITIAL (decl));
2445 setjmp_args_warning ();
2449 /* Dump rtl after flow analysis. */
2454 print_rtl (flow_dump_file, insns);
2455 fflush (flow_dump_file);
2458 /* If -opt, try combining insns through substitution. */
2461 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2463 /* Dump rtl code after insn combination. */
2468 fprintf (combine_dump_file, "\n;; Function %s\n\n",
2469 IDENTIFIER_POINTER (DECL_NAME (decl)));
2470 dump_combine_stats (combine_dump_file);
2471 print_rtl (combine_dump_file, insns);
2472 fflush (combine_dump_file);
2475 /* Print function header into sched dump now
2476 because doing the sched analysis makes some of the dump. */
2481 fprintf (sched_dump_file, "\n;; Function %s\n\n",
2482 IDENTIFIER_POINTER (DECL_NAME (decl)));
2485 if (optimize > 0 && flag_schedule_insns)
2487 /* Do control and data sched analysis,
2488 and write some of the results to dump file. */
2490 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
2493 /* Dump rtl after instruction scheduling. */
2498 print_rtl (sched_dump_file, insns);
2499 fflush (sched_dump_file);
2502 /* Unless we did stupid register allocation,
2503 allocate pseudo-regs that are used only within 1 basic block. */
2506 TIMEVAR (local_alloc_time,
2508 regclass (insns, max_reg_num ());
2512 /* Dump rtl code after allocating regs within basic blocks. */
2517 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
2518 IDENTIFIER_POINTER (DECL_NAME (decl)));
2519 dump_flow_info (local_reg_dump_file);
2520 dump_local_alloc (local_reg_dump_file);
2521 print_rtl (local_reg_dump_file, insns);
2522 fflush (local_reg_dump_file);
2525 if (global_reg_dump)
2527 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
2528 IDENTIFIER_POINTER (DECL_NAME (decl))));
2530 /* Unless we did stupid register allocation,
2531 allocate remaining pseudo-regs, then do the reload pass
2532 fixing up any insns that are invalid. */
2534 TIMEVAR (global_alloc_time,
2537 failure = global_alloc (global_reg_dump_file);
2539 failure = reload (insns, 0, global_reg_dump_file);
2542 if (global_reg_dump)
2545 dump_global_regs (global_reg_dump_file);
2546 print_rtl (global_reg_dump_file, insns);
2547 fflush (global_reg_dump_file);
2551 goto exit_rest_of_compilation;
2553 reload_completed = 1;
2555 /* On some machines, the prologue and epilogue code, or parts thereof,
2556 can be represented as RTL. Doing so lets us schedule insns between
2557 it and the rest of the code and also allows delayed branch
2558 scheduling to operate in the epilogue. */
2560 thread_prologue_and_epilogue_insns (insns);
2562 if (optimize > 0 && flag_schedule_insns_after_reload)
2567 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
2568 IDENTIFIER_POINTER (DECL_NAME (decl)));
2571 /* Do control and data sched analysis again,
2572 and write some more of the results to dump file. */
2574 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
2576 /* Dump rtl after post-reorder instruction scheduling. */
2581 print_rtl (sched2_dump_file, insns);
2582 fflush (sched2_dump_file);
2586 #ifdef LEAF_REGISTERS
2588 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
2592 /* One more attempt to remove jumps to .+1
2593 left by dead-store-elimination.
2594 Also do cross-jumping this time
2595 and delete no-op move insns. */
2599 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
2602 /* Dump rtl code after jump, if we are doing that. */
2607 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
2608 IDENTIFIER_POINTER (DECL_NAME (decl)));
2609 print_rtl (jump2_opt_dump_file, insns);
2610 fflush (jump2_opt_dump_file);
2613 /* If a scheduling pass for delayed branches is to be done,
2614 call the scheduling code. */
2617 if (optimize > 0 && flag_delayed_branch)
2619 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
2624 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
2625 IDENTIFIER_POINTER (DECL_NAME (decl)));
2626 print_rtl (dbr_sched_dump_file, insns);
2627 fflush (dbr_sched_dump_file);
2634 /* Shorten branches. */
2635 TIMEVAR (shorten_branch_time,
2637 shorten_branches (get_insns ());
2641 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
2646 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
2647 IDENTIFIER_POINTER (DECL_NAME (decl)));
2648 print_rtl (stack_reg_dump_file, insns);
2649 fflush (stack_reg_dump_file);
2654 /* Now turn the rtl into assembler code. */
2656 TIMEVAR (final_time,
2661 /* Get the function's name, as described by its RTL.
2662 This may be different from the DECL_NAME name used
2663 in the source file. */
2665 x = DECL_RTL (decl);
2666 if (GET_CODE (x) != MEM)
2669 if (GET_CODE (x) != SYMBOL_REF)
2671 fnname = XSTR (x, 0);
2673 assemble_start_function (decl, fnname);
2674 final_start_function (insns, asm_out_file, optimize);
2675 final (insns, asm_out_file, optimize, 0);
2676 final_end_function (insns, asm_out_file, optimize);
2677 assemble_end_function (decl, fnname);
2678 fflush (asm_out_file);
2681 /* Write DBX symbols if requested */
2683 /* Note that for those inline functions where we don't initially
2684 know for certain that we will be generating an out-of-line copy,
2685 the first invocation of this routine (rest_of_compilation) will
2686 skip over this code by doing a `goto exit_rest_of_compilation;'.
2687 Later on, finish_compilation will call rest_of_compilation again
2688 for those inline functions that need to have out-of-line copies
2689 generated. During that call, we *will* be routed past here. */
2691 #ifdef DBX_DEBUGGING_INFO
2692 if (write_symbols == DBX_DEBUG)
2693 TIMEVAR (symout_time, dbxout_function (decl));
2696 #ifdef DWARF_DEBUGGING_INFO
2697 if (write_symbols == DWARF_DEBUG)
2698 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2701 exit_rest_of_compilation:
2703 /* In case the function was not output,
2704 don't leave any temporary anonymous types
2705 queued up for sdb output. */
2706 #ifdef SDB_DEBUGGING_INFO
2707 if (write_symbols == SDB_DEBUG)
2708 sdbout_types (NULL_TREE);
2711 /* Put back the tree of subblocks and list of arguments
2712 from before we copied them.
2713 Code generation and the output of debugging info may have modified
2714 the copy, but the original is unchanged. */
2716 if (saved_block_tree != 0)
2717 DECL_INITIAL (decl) = saved_block_tree;
2718 if (saved_arguments != 0)
2719 DECL_ARGUMENTS (decl) = saved_arguments;
2721 reload_completed = 0;
2723 /* Clear out the real_constant_chain before some of the rtx's
2724 it runs through become garbage. */
2726 clear_const_double_mem ();
2728 /* Cancel the effect of rtl_in_current_obstack. */
2730 resume_temporary_allocation ();
2732 /* The parsing time is all the time spent in yyparse
2733 *except* what is spent in this function. */
2735 parse_time -= get_run_time () - start_time;
2738 /* Entry point of cc1/c++. Decode command args, then call compile_file.
2739 Exit code is 35 if can't open files, 34 if fatal error,
2740 33 if had nonfatal errors, else success. */
2743 main (argc, argv, envp)
2750 int flag_print_mem = 0;
2751 int version_flag = 0;
2754 /* save in case md file wants to emit args as a comment. */
2758 p = argv[0] + strlen (argv[0]);
2759 while (p != argv[0] && p[-1] != '/') --p;
2763 /* Get rid of any avoidable limit on stack size. */
2767 /* Set the stack limit huge so that alloca does not fail. */
2768 getrlimit (RLIMIT_STACK, &rlim);
2769 rlim.rlim_cur = rlim.rlim_max;
2770 setrlimit (RLIMIT_STACK, &rlim);
2772 #endif /* RLIMIT_STACK */
2774 signal (SIGFPE, float_signal);
2776 signal (SIGPIPE, pipe_closed);
2778 decl_printable_name = decl_name;
2779 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
2781 /* Initialize whether `char' is signed. */
2782 flag_signed_char = DEFAULT_SIGNED_CHAR;
2783 #ifdef DEFAULT_SHORT_ENUMS
2784 /* Initialize how much space enums occupy, by default. */
2785 flag_short_enums = DEFAULT_SHORT_ENUMS;
2788 /* Scan to see what optimization level has been specified. That will
2789 determine the default value of many flags. */
2790 for (i = 1; i < argc; i++)
2792 if (!strcmp (argv[i], "-O"))
2796 else if (argv[i][0] == '-' && argv[i][1] == 'O')
2798 /* Handle -O2, -O3, -O69, ... */
2799 char *p = &argv[i][2];
2803 if (! (c >= '0' && c <= '9'))
2806 optimize = atoi (&argv[i][2]);
2810 obey_regdecls = (optimize == 0);
2819 flag_thread_jumps = 1;
2821 flag_delayed_branch = 1;
2827 flag_cse_follow_jumps = 1;
2828 flag_cse_skip_blocks = 1;
2829 flag_expensive_optimizations = 1;
2830 flag_strength_reduce = 1;
2831 flag_rerun_cse_after_loop = 1;
2832 flag_caller_saves = 1;
2833 #ifdef INSN_SCHEDULING
2834 flag_schedule_insns = 1;
2835 flag_schedule_insns_after_reload = 1;
2839 #ifdef OPTIMIZATION_OPTIONS
2840 /* Allow default optimizations to be specified on a per-machine basis. */
2841 OPTIMIZATION_OPTIONS (optimize);
2844 /* Initialize register usage now so switches may override. */
2848 set_target_switch ("");
2850 for (i = 1; i < argc; i++)
2853 /* If this is a language-specific option,
2854 decode it in a language-specific way. */
2855 for (j = 0; lang_options[j] != 0; j++)
2856 if (!strncmp (argv[i], lang_options[j],
2857 strlen (lang_options[j])))
2859 if (lang_options[j] != 0)
2860 /* If the option is valid for *some* language,
2861 treat it as valid even if this language doesn't understand it. */
2862 lang_decode_option (argv[i]);
2863 else if (argv[i][0] == '-' && argv[i][1] != 0)
2865 register char *str = argv[i] + 1;
2870 set_target_switch (&str[1]);
2871 else if (!strcmp (str, "dumpbase"))
2873 dump_base_name = argv[++i];
2875 else if (str[0] == 'd')
2877 register char *p = &str[1];
2885 global_reg_dump = 1;
2891 cse_dump = 1, cse2_dump = 1;
2909 global_reg_dump = 1;
2927 flag_print_asm_name = 1;
2949 rtl_dump_and_exit = 1;
2953 else if (str[0] == 'f')
2955 register char *p = &str[1];
2958 /* Some kind of -f option.
2959 P's value is the option sans `-f'.
2960 Search for it in the table of options. */
2963 !found && j < sizeof (f_options) / sizeof (f_options[0]);
2966 if (!strcmp (p, f_options[j].string))
2968 *f_options[j].variable = f_options[j].on_value;
2969 /* A goto here would be cleaner,
2970 but breaks the vax pcc. */
2973 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
2974 && ! strcmp (p+3, f_options[j].string))
2976 *f_options[j].variable = ! f_options[j].on_value;
2983 else if (!strncmp (p, "fixed-", 6))
2984 fix_register (&p[6], 1, 1);
2985 else if (!strncmp (p, "call-used-", 10))
2986 fix_register (&p[10], 0, 1);
2987 else if (!strncmp (p, "call-saved-", 11))
2988 fix_register (&p[11], 0, 0);
2990 error ("Invalid option `%s'", argv[i]);
2992 else if (str[0] == 'O')
2994 register char *p = str+1;
2995 while (*p && *p >= '0' && *p <= '9')
3000 error ("Invalid option `%s'", argv[i]);
3002 else if (!strcmp (str, "pedantic"))
3004 else if (!strcmp (str, "pedantic-errors"))
3005 flag_pedantic_errors = pedantic = 1;
3006 else if (!strcmp (str, "quiet"))
3008 else if (!strcmp (str, "version"))
3010 else if (!strcmp (str, "w"))
3011 inhibit_warnings = 1;
3012 else if (!strcmp (str, "W"))
3015 warn_uninitialized = 1;
3017 else if (str[0] == 'W')
3019 register char *p = &str[1];
3022 /* Some kind of -W option.
3023 P's value is the option sans `-W'.
3024 Search for it in the table of options. */
3027 !found && j < sizeof (W_options) / sizeof (W_options[0]);
3030 if (!strcmp (p, W_options[j].string))
3032 *W_options[j].variable = W_options[j].on_value;
3033 /* A goto here would be cleaner,
3034 but breaks the vax pcc. */
3037 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3038 && ! strcmp (p+3, W_options[j].string))
3040 *W_options[j].variable = ! W_options[j].on_value;
3047 else if (!strncmp (p, "id-clash-", 9))
3053 if (*endp >= '0' && *endp <= '9')
3057 error ("Invalid option `%s'", argv[i]);
3062 id_clash_len = atoi (str + 10);
3066 error ("Invalid option `%s'", argv[i]);
3068 else if (!strcmp (str, "p"))
3070 else if (!strcmp (str, "a"))
3072 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
3073 warning ("`-a' option (basic block profile) not supported");
3075 profile_block_flag = 1;
3078 else if (str[0] == 'g')
3085 while (*p && (*p < '0' || *p > '9'))
3089 while (*q && (*q >= '0' && *q <= '9'))
3094 level = 2; /* default debugging info level */
3095 if (*q || level > 3)
3097 warning ("invalid debug level specification in option: `-%s'",
3099 warning ("no debugging information will be generated");
3103 /* If more than one debugging type is supported,
3104 you must define PREFERRED_DEBUGGING_TYPE
3105 to choose a format in a system-dependent way. */
3106 /* This is one long line cause VAXC can't handle a \-newline. */
3107 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
3108 #ifdef PREFERRED_DEBUGGING_TYPE
3109 if (!strncmp (str, "ggdb", len))
3110 write_symbols = PREFERRED_DEBUGGING_TYPE;
3111 #else /* no PREFERRED_DEBUGGING_TYPE */
3112 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
3113 #endif /* no PREFERRED_DEBUGGING_TYPE */
3114 #endif /* More than one debugger format enabled. */
3115 #ifdef DBX_DEBUGGING_INFO
3116 if (write_symbols != NO_DEBUG)
3118 else if (!strncmp (str, "ggdb", len))
3119 write_symbols = DBX_DEBUG;
3120 else if (!strncmp (str, "gstabs", len))
3121 write_symbols = DBX_DEBUG;
3122 else if (!strncmp (str, "gstabs+", len))
3123 write_symbols = DBX_DEBUG;
3125 /* Always enable extensions for -ggdb or -gstabs+,
3126 always disable for -gstabs.
3127 For plain -g, use system-specific default. */
3128 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
3130 use_gnu_debug_info_extensions = 1;
3131 else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
3133 use_gnu_debug_info_extensions = 1;
3134 else if (write_symbols == DBX_DEBUG
3135 && !strncmp (str, "gstabs", len) && len >= 2)
3136 use_gnu_debug_info_extensions = 0;
3138 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3139 #endif /* DBX_DEBUGGING_INFO */
3140 #ifdef DWARF_DEBUGGING_INFO
3141 if (write_symbols != NO_DEBUG)
3143 else if (!strncmp (str, "g", len))
3144 write_symbols = DWARF_DEBUG;
3145 else if (!strncmp (str, "ggdb", len))
3146 write_symbols = DWARF_DEBUG;
3147 else if (!strncmp (str, "gdwarf", len))
3148 write_symbols = DWARF_DEBUG;
3150 /* Always enable extensions for -ggdb or -gdwarf+,
3151 always disable for -gdwarf.
3152 For plain -g, use system-specific default. */
3153 if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
3155 use_gnu_debug_info_extensions = 1;
3156 else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
3157 use_gnu_debug_info_extensions = 1;
3158 else if (write_symbols == DWARF_DEBUG
3159 && !strncmp (str, "gdwarf", len) && len >= 2)
3160 use_gnu_debug_info_extensions = 0;
3162 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3164 #ifdef SDB_DEBUGGING_INFO
3165 if (write_symbols != NO_DEBUG)
3167 else if (!strncmp (str, "g", len))
3168 write_symbols = SDB_DEBUG;
3169 else if (!strncmp (str, "gdb", len))
3170 write_symbols = SDB_DEBUG;
3171 else if (!strncmp (str, "gcoff", len))
3172 write_symbols = SDB_DEBUG;
3173 #endif /* SDB_DEBUGGING_INFO */
3174 #ifdef XCOFF_DEBUGGING_INFO
3175 if (write_symbols != NO_DEBUG)
3177 else if (!strncmp (str, "g", len))
3178 write_symbols = XCOFF_DEBUG;
3179 else if (!strncmp (str, "ggdb", len))
3180 write_symbols = XCOFF_DEBUG;
3181 else if (!strncmp (str, "gxcoff", len))
3182 write_symbols = XCOFF_DEBUG;
3184 /* Always enable extensions for -ggdb or -gxcoff+,
3185 always disable for -gxcoff.
3186 For plain -g, use system-specific default. */
3187 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
3189 use_gnu_debug_info_extensions = 1;
3190 else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
3191 use_gnu_debug_info_extensions = 1;
3192 else if (write_symbols == XCOFF_DEBUG
3193 && !strncmp (str, "gxcoff", len) && len >= 2)
3194 use_gnu_debug_info_extensions = 0;
3196 use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
3198 if (write_symbols == NO_DEBUG)
3199 warning ("`-%s' option not supported on this version of GCC", str);
3200 else if (level == 0)
3201 write_symbols = NO_DEBUG;
3203 debug_info_level = (enum debug_info_level) level;
3205 else if (!strcmp (str, "o"))
3207 asm_file_name = argv[++i];
3209 else if (str[0] == 'G')
3211 g_switch_set = TRUE;
3212 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
3214 else if (!strncmp (str, "aux-info", 8))
3216 flag_gen_aux_info = 1;
3217 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
3220 error ("Invalid option `%s'", argv[i]);
3222 else if (argv[i][0] == '+')
3223 error ("Invalid option `%s'", argv[i]);
3230 /* Inlining does not work if not optimizing,
3231 so force it not to be done. */
3235 /* The c_decode_option and lang_decode_option functions set
3236 this to `2' if -Wall is used, so we can avoid giving out
3237 lots of errors for people who don't realize what -Wall does. */
3238 if (warn_uninitialized == 1)
3239 warning ("-Wuninitialized is not supported without -O");
3242 #ifdef OVERRIDE_OPTIONS
3243 /* Some machines may reject certain combinations of options. */
3247 /* Unrolling all loops implies that standard loop unrolling must also
3249 if (flag_unroll_all_loops)
3250 flag_unroll_loops = 1;
3251 /* Loop unrolling requires that strength_reduction be on also. Silently
3252 turn on strength reduction here if it isn't already on. Also, the loop
3253 unrolling code assumes that cse will be run after loop, so that must
3254 be turned on also. */
3255 if (flag_unroll_loops)
3257 flag_strength_reduce = 1;
3258 flag_rerun_cse_after_loop = 1;
3261 /* Warn about options that are not supported on this machine. */
3262 #ifndef INSN_SCHEDULING
3263 if (flag_schedule_insns || flag_schedule_insns_after_reload)
3264 warning ("instruction scheduling not supported on this target machine");
3267 if (flag_delayed_branch)
3268 warning ("this target machine does not have delayed branches");
3271 /* If we are in verbose mode, write out the version and maybe all the
3272 option flags in use. */
3275 fprintf (stderr, "%s version %s", language_string, version_string);
3276 #ifdef TARGET_VERSION
3281 #define __VERSION__ "[unknown]"
3283 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3285 fprintf (stderr, " compiled by CC.\n");
3288 print_switch_values ();
3291 /* Now that register usage is specified, convert it to HARD_REG_SETs. */
3294 compile_file (filename);
3300 char *lim = (char *) sbrk (0);
3302 fprintf (stderr, "Data size %d.\n",
3303 lim - (char *) &environ);
3307 system ("ps -l 1>&2");
3310 #endif /* not USG */
3312 #endif /* not VMS */
3313 #endif /* not OS2 */
3316 exit (FATAL_EXIT_CODE);
3318 exit (FATAL_EXIT_CODE);
3319 exit (SUCCESS_EXIT_CODE);
3323 /* Decode -m switches. */
3325 /* Here is a table, controlled by the tm.h file, listing each -m switch
3326 and which bits in `target_switches' it should set or clear.
3327 If VALUE is positive, it is bits to set.
3328 If VALUE is negative, -VALUE is bits to clear.
3329 (The sign bit is not used so there is no confusion.) */
3331 struct {char *name; int value;} target_switches []
3334 /* This table is similar, but allows the switch to have a value. */
3336 #ifdef TARGET_OPTIONS
3337 struct {char *prefix; char ** variable;} target_options []
3341 /* Decode the switch -mNAME. */
3344 set_target_switch (name)
3350 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3351 if (!strcmp (target_switches[j].name, name))
3353 if (target_switches[j].value < 0)
3354 target_flags &= ~-target_switches[j].value;
3356 target_flags |= target_switches[j].value;
3360 #ifdef TARGET_OPTIONS
3362 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3364 int len = strlen (target_options[j].prefix);
3365 if (!strncmp (target_options[j].prefix, name, len))
3367 *target_options[j].variable = name + len;
3374 error ("Invalid option `%s'", name);
3377 /* Variable used for communication between the following two routines. */
3379 static int line_position;
3381 /* Print an option value and adjust the position in the line. */
3384 print_single_switch (type, name)
3387 fprintf (stderr, " %s%s", type, name);
3389 line_position += strlen (type) + strlen (name) + 1;
3391 if (line_position > 65)
3393 fprintf (stderr, "\n\t");
3398 /* Print default target switches for -version. */
3401 print_switch_values ()
3405 fprintf (stderr, "enabled:");
3408 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3409 if (*f_options[j].variable == f_options[j].on_value)
3410 print_single_switch ("-f", f_options[j].string);
3412 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
3413 if (*W_options[j].variable == W_options[j].on_value)
3414 print_single_switch ("-W", W_options[j].string);
3416 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3417 if (target_switches[j].name[0] != '\0'
3418 && target_switches[j].value > 0
3419 && ((target_switches[j].value & target_flags)
3420 == target_switches[j].value))
3421 print_single_switch ("-m", target_switches[j].name);
3423 fprintf (stderr, "\n");