#include "tm_p.h"
#include "flags.h"
#include "insn-attr.h"
-#include "insn-codes.h"
#include "insn-config.h"
#include "hard-reg-set.h"
#include "recog.h"
#include "diagnostic.h"
#include "ssa.h"
#include "params.h"
-
-#ifndef ACCUMULATE_OUTGOING_ARGS
-#define ACCUMULATE_OUTGOING_ARGS 0
-#endif
+#include "reload.h"
+#include "dwarf2asm.h"
#ifdef DWARF_DEBUGGING_INFO
#include "dwarfout.h"
static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
-#ifdef ASM_IDENTIFY_LANGUAGE
-/* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
-static void output_lang_identify PARAMS ((FILE *)) ATTRIBUTE_UNUSED;
-#endif
static void compile_file PARAMS ((const char *));
static void display_help PARAMS ((void));
static void display_target_options PARAMS ((void));
{
DFI_rtl,
DFI_sibling,
+ DFI_eh,
DFI_jump,
DFI_cse,
DFI_addressof,
Remaining -d letters:
- " h o q u "
+ " o q u "
" H K OPQ TUVW YZ"
*/
{
{ "rtl", 'r', 0, 0, 0 },
{ "sibling", 'i', 0, 0, 0 },
+ { "eh", 'h', 0, 0, 0 },
{ "jump", 'j', 0, 0, 0 },
{ "cse", 's', 0, 0, 0 },
{ "addressof", 'F', 0, 0, 0 },
int rtl_dump_and_exit;
int flag_print_asm_name;
-static int flag_print_mem;
static int version_flag;
static char *filename;
enum graph_dump_types graph_dump_format;
static int flag_delete_null_pointer_checks;
+/* Nonzero means to do the enhanced load motion during gcse, which trys
+ to hoist loads by not killing them when a store to the same location
+ is seen. */
+
+int flag_gcse_lm = 1;
+
+/* Nonzero means to perform store motion after gcse, which will try to
+ move stores closer to the exit block. Its not very effective without
+ flag_gcse_lm. */
+
+int flag_gcse_sm = 1;
+
/* Nonzero means to rerun cse after loop optimization. This increases
compilation time about 20% and picks up a few more common expressions. */
int flag_exceptions;
-/* Nonzero means use the new model for exception handling. Replaces
- -DNEW_EH_MODEL as a compile option. */
-
-int flag_new_exceptions = 1;
-
/* Nonzero means generate frame unwind info table when supported. */
int flag_unwind_tables = 0;
static const param_info lang_independent_params[] = {
#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
- { OPTION, DEFAULT },
+ { OPTION, DEFAULT, HELP },
#include "params.def"
#undef DEFPARAM
- { NULL, 0 }
+ { NULL, 0, NULL }
};
/* A default for same. */
"Attempt to fill delay slots of branch instructions" },
{"gcse", &flag_gcse, 1,
"Perform the global common subexpression elimination" },
+ {"gcse-lm", &flag_gcse_lm, 1,
+ "Perform enhanced load motion during global subexpression elimination" },
+ {"gcse-sm", &flag_gcse_sm, 1,
+ "Perform store motion after global subexpression elimination" },
{"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
"Run CSE pass after loop optimisations"},
{"rerun-loop-opt", &flag_rerun_loop_opt, 1,
{"PIC", &flag_pic, 2, ""},
{"exceptions", &flag_exceptions, 1,
"Enable exception handling" },
- {"new-exceptions", &flag_new_exceptions, 1,
- "Use the new model for exception handling" },
{"unwind-tables", &flag_unwind_tables, 1,
"Just generate unwind tables for exception handling" },
- {"sjlj-exceptions", &exceptions_via_longjmp, 1,
- "Use setjmp/longjmp to handle exceptions" },
- {"asynchronous-exceptions", &asynchronous_exceptions, 1,
- "Support asynchronous exceptions" },
+ {"non-call-exceptions", &flag_non_call_exceptions, 1,
+ "Support synchronous non-call exceptions" },
{"profile-arcs", &profile_arc_flag, 1,
"Insert arc based program profiling code" },
{"test-coverage", &flag_test_coverage, 1,
characters. The value N is in `id_clash_len'. */
int warn_id_clash;
-int id_clash_len;
+unsigned int id_clash_len;
/* Nonzero means warn about any objects definitions whose size is larger
than N bytes. Also want about function definitions whose returned
return log;
}
-/* Return the approximate positive square root of a number N. This is for
- statistical reports, not code generation. */
-double
-approx_sqrt (x)
- double x;
-{
- double s, d;
-
- if (x < 0)
- abort ();
- if (x == 0)
- return 0;
-
- s = x;
- do
- {
- d = (s * s - x) / (2 * s);
- s -= d;
- }
- while (d > .0001);
- return s;
-}
-
static int float_handler_set;
int float_handled;
jmp_buf float_handler;
{
if (float_handled == 0)
crash_signal (signo);
-#if defined (USG) || defined (hpux)
- /* Re-enable the signal catcher. */
- signal (SIGFPE, float_signal);
-#endif
float_handled = 0;
+
+ /* On System-V derived systems, we must reinstall the signal handler.
+ This is harmless on BSD-derived systems. */
signal (SIGFPE, float_signal);
longjmp (float_handler, 1);
}
{
float_handled = (handler != 0);
if (handler)
- bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
+ memcpy (float_handler, handler, sizeof (float_handler));
if (float_handled && ! float_handler_set)
{
}
}
-/* Given a file name X, return the nondirectory portion. */
-
-char *
-file_name_nondirectory (x)
- const char *x;
-{
- char *tmp = (char *) strrchr (x, '/');
- if (DIR_SEPARATOR != '/' && ! tmp)
- tmp = (char *) strrchr (x, DIR_SEPARATOR);
- if (tmp)
- return (char *) (tmp + 1);
- else
- return (char *) x;
-}
-
/* Output a quoted string. */
void
#endif
}
\f
-#ifdef ASM_IDENTIFY_LANGUAGE
-/* Routine to build language identifier for object file. */
-
-static void
-output_lang_identify (asm_out_file)
- FILE *asm_out_file;
-{
- int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
- char *s = (char *) alloca (len);
-
- sprintf (s, "__gnu_compiled_%s", lang_identify ());
- ASM_OUTPUT_LABEL (asm_out_file, s);
-}
-#endif
-
/* Routine to open a dump file. Return true if the dump file is enabled. */
static int
|| TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
{
reconsider = 1;
- rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
+ rest_of_decl_compilation (decl, NULL, 1, 1);
}
if (TREE_CODE (decl) == FUNCTION_DECL
/* Cancel the RTL for this decl so that, if debugging info
output for global variables is still to come,
this one will be omitted. */
- DECL_RTL (decl) = NULL;
+ SET_DECL_RTL (decl, NULL_RTX);
/* Warn about any function
declared static but not defined.
init_timevar ();
timevar_start (TV_TOTAL);
+ /* Open assembler code output file. Do this even if -fsyntax-only is on,
+ because then the driver will have provided the name of a temporary
+ file or bit bucket for us. */
+
+ if (! name_specified && asm_file_name == 0)
+ asm_out_file = stdout;
+ else
+ {
+ if (asm_file_name == 0)
+ {
+ int len = strlen (dump_base_name);
+ char *dumpname = (char *) xmalloc (len + 6);
+ memcpy (dumpname, dump_base_name, len + 1);
+ strip_off_ending (dumpname, len);
+ strcat (dumpname, ".s");
+ asm_file_name = dumpname;
+ }
+ if (!strcmp (asm_file_name, "-"))
+ asm_out_file = stdout;
+ else
+ asm_out_file = fopen (asm_file_name, "w");
+ if (asm_out_file == 0)
+ fatal_io_error ("can't open %s for writing", asm_file_name);
+ }
+
/* Initialize data in various passes. */
init_obstacks ();
init_regs ();
init_alias_once ();
init_decl_processing ();
+ init_eh ();
init_optabs ();
init_stmt ();
- init_eh ();
init_loop ();
init_reload ();
init_function_once ();
fatal_io_error ("can't open %s", aux_info_file_name);
}
- /* Open assembler code output file. Do this even if -fsyntax-only is on,
- because then the driver will have provided the name of a temporary
- file or bit bucket for us. */
-
- if (! name_specified && asm_file_name == 0)
- asm_out_file = stdout;
- else
- {
- if (asm_file_name == 0)
- {
- int len = strlen (dump_base_name);
- char *dumpname = (char *) xmalloc (len + 6);
- memcpy (dumpname, dump_base_name, len + 1);
- strip_off_ending (dumpname, len);
- strcat (dumpname, ".s");
- asm_file_name = dumpname;
- }
- if (!strcmp (asm_file_name, "-"))
- asm_out_file = stdout;
- else
- asm_out_file = fopen (asm_file_name, "w");
- if (asm_out_file == 0)
- fatal_io_error ("can't open %s for writing", asm_file_name);
- }
-
#ifdef IO_BUFFER_SIZE
setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
_IOFBF, IO_BUFFER_SIZE);
fprintf (asm_out_file, "\n");
}
#endif
-
- /* Output something to inform GDB that this compilation was by GCC. */
-#ifndef ASM_IDENTIFY_GCC
- fprintf (asm_out_file, "gcc2_compiled.:\n");
-#else
- ASM_IDENTIFY_GCC (asm_out_file);
-#endif
-
- /* Output something to identify which front-end produced this file. */
-#ifdef ASM_IDENTIFY_LANGUAGE
- ASM_IDENTIFY_LANGUAGE (asm_out_file);
-#endif
} /* ! flag_syntax_only */
#ifndef ASM_OUTPUT_SECTION_NAME
warning ("-ffunction-sections may affect debugging on some targets.");
#endif
- /* ??? Note: There used to be a conditional here
- to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
- This was to guarantee separation between gcc_compiled. and
- the first function, for the sake of dbx on Suns.
- However, having the extra zero here confused the Emacs
- code for unexec, and might confuse other programs too.
- Therefore, I took out that change.
- In future versions we should find another way to solve
- that dbx problem. -- rms, 23 May 93. */
-
- /* Don't let the first function fall at the same address
- as gcc_compiled., if profiling. */
- if (profile_flag || profile_block_flag)
- {
- /* It's best if we can write a nop here since some
- assemblers don't tolerate zeros in the text section. */
- output_asm_insn (get_insn_template (CODE_FOR_nop, NULL), NULL_PTR);
- }
-
/* If dbx symbol table desired, initialize writing it
and output the predefined types. */
timevar_push (TV_SYMOUT);
loop above. */
output_func_start_profiler ();
- /* Now that all possible functions have been output, we can dump
- the exception table. */
-
-#ifndef IA64_UNWIND_INFO
- output_exception_table ();
-#endif
- free_exception_table ();
-
check_global_declarations (vec, len);
/* Clean up. */
/* Output some stuff at end of file if nec. */
+ dw2_output_indirect_constants ();
+
end_final (dump_base_name);
if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
ASM_FILE_END (asm_out_file);
#endif
+ /* Attach a special .ident directive to the end of the file to identify
+ the version of GCC which compiled this code. The format of the .ident
+ string is patterned after the ones produced by native SVR4 compilers. */
+#ifdef IDENT_ASM_OP
+ if (!flag_no_ident)
+ fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
+ IDENT_ASM_OP, version_string);
+#endif
+
/* Language-specific end of compilation actions. */
finish_syntax:
if (lang_hooks.finish)
|| TREE_CODE (decl) == FUNCTION_DECL)
{
timevar_push (TV_VARCONST);
- make_decl_rtl (decl, asmspec);
+ if (asmspec)
+ make_decl_rtl (decl, asmspec);
/* Don't output anything
when a tentative file-scope definition is seen.
But at end of compilation, do output code for them. */
{
if (decode_reg_name (asmspec) >= 0)
{
- DECL_RTL (decl) = 0;
+ SET_DECL_RTL (decl, NULL_RTX);
make_decl_rtl (decl, asmspec);
}
else
{
error ("invalid register name `%s' for register variable", asmspec);
DECL_REGISTER (decl) = 0;
- make_decl_rtl (decl, NULL);
+ if (!top_level)
+ expand_decl (decl);
}
}
#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
}
/* If requested, consider whether to make this function inline. */
- if (DECL_INLINE (decl) || flag_inline_functions)
+ if ((DECL_INLINE (decl) && !flag_no_inline)
+ || flag_inline_functions)
{
timevar_push (TV_INTEGRATION);
lose = function_cannot_inline_p (decl);
close_dump_file (DFI_rtl, print_rtl, insns);
}
+ /* Convert from NOTE_INSN_EH_REGION style notes, and do other
+ sorts of eh initialization. Delay this until after the
+ initial rtl dump so that we can see the original nesting. */
+ convert_from_eh_region_ranges ();
+
/* If function is inline, and we don't yet know whether to
compile it by itself, defer decision till end of compilation.
finish_compilation will call rest_of_compilation again
if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
goto exit_rest_of_compilation;
- /* Emit code to get eh context, if needed. */
- emit_eh_context ();
-
/* We may have potential sibling or tail recursion sites. Select one
(of possibly multiple) methods of performing the call. */
if (flag_optimize_sibling_calls)
timevar_pop (TV_JUMP);
}
+ /* Complete generation of exception handling code. */
+ find_exception_handler_labels ();
+ if (doing_eh (0))
+ {
+ timevar_push (TV_JUMP);
+ open_dump_file (DFI_eh, decl);
+
+ finish_eh_generation ();
+
+ close_dump_file (DFI_eh, print_rtl, get_insns ());
+ timevar_pop (TV_JUMP);
+ }
+
#ifdef FINALIZE_PIC
/* If we are doing position-independent code generation, now
is the time to output special prologues and epilogues.
/* Instantiate all virtual registers. */
instantiate_virtual_regs (current_function_decl, insns);
- /* Find all the EH handlers. */
- find_exception_handler_labels ();
-
open_dump_file (DFI_jump, decl);
/* Always do one jump optimization pass to ensure that JUMP_LABEL fields
if (optimize > 0)
{
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (insns);
+ cleanup_cfg ();
/* ??? Run if-conversion before delete_null_pointer_checks,
since the later does not preserve the CFG. This should
timevar_push (TV_JUMP);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (insns);
+ cleanup_cfg ();
delete_null_pointer_checks (insns);
timevar_pop (TV_JUMP);
open_dump_file (DFI_ssa, decl);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (insns);
+ cleanup_cfg ();
convert_to_ssa ();
close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
open_dump_file (DFI_gcse, decl);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (insns);
+ cleanup_cfg ();
tem = gcse_main (insns, rtl_dump_file);
save_csb = flag_cse_skip_blocks;
timevar_pop (TV_CSE);
cse_not_expected = !flag_rerun_cse_after_loop;
}
-
+
/* If gcse or cse altered any jumps, rerun jump optimizations to clean
things up. Then possibly re-run CSE again. */
while (tem || tem2)
??? Rework to not call reg_scan so often. */
timevar_push (TV_JUMP);
+ /* The previous call to loop_optimize makes some instructions
+ trivially dead. We delete those instructions now in the
+ hope that doing so will make the heuristics in jump work
+ better and possibly speed up compilation. */
+ delete_trivially_dead_insns (insns, max_reg_num ());
+
reg_scan (insns, max_reg_num (), 0);
jump_optimize (insns, !JUMP_CROSS_JUMP,
!JUMP_NOOP_MOVES, JUMP_AFTER_REGSCAN);
timevar_push (TV_IFCVT);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (insns);
+ cleanup_cfg ();
if_convert (0);
timevar_pop(TV_IFCVT);
open_dump_file (DFI_cfg, decl);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (insns);
+ cleanup_cfg ();
check_function_return_warnings ();
close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
timevar_push (TV_FLOW);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (insns);
+ cleanup_cfg ();
/* Blimey. We've got to have the CFG up to date for the call to
if_convert below. However, the random deletion of blocks
#ifdef OPTIMIZE_MODE_SWITCHING
timevar_push (TV_GCSE);
- if (optimize_mode_switching (NULL_PTR))
+ if (optimize_mode_switching (NULL))
{
/* We did work, and so had to regenerate global life information.
Take advantage of this and don't re-recompute register life
if (optimize)
{
- cleanup_cfg (insns);
+ cleanup_cfg ();
life_analysis (insns, rtl_dump_file, PROP_FINAL);
/* This is kind of a heuristic. We need to run combine_stack_adjustments
}
#endif
+#ifndef STACK_REGS
+ /* ??? Do this before shorten branches so that we aren't creating
+ insns too late and fail sanity checks in final. */
+ convert_to_eh_region_ranges ();
+#endif
+
/* Shorten branches.
Note this must run before reg-stack because of death note (ab)use
timevar_pop (TV_REG_STACK);
ggc_collect ();
+
+ convert_to_eh_region_ranges ();
#endif
current_function_nothrow = nothrow_function_p ();
final_start_function (insns, asm_out_file, optimize);
final (insns, asm_out_file, optimize, 0);
final_end_function (insns, asm_out_file, optimize);
+
+#ifdef IA64_UNWIND_INFO
+ /* ??? The IA-64 ".handlerdata" directive must be issued before
+ the ".endp" directive that closes the procedure descriptor. */
+ output_function_exception_table ();
+#endif
+
assemble_end_function (decl, fnname);
+
+#ifndef IA64_UNWIND_INFO
+ /* Otherwise, it feels unclean to switch sections in the middle. */
+ output_function_exception_table ();
+#endif
+
if (! quiet_flag)
fflush (asm_out_file);
printf (_(" -O[number] Set optimisation level to [number]\n"));
printf (_(" -Os Optimise for space rather than speed\n"));
- printf (_(" --param <name>=<value> Set constant controlling optimization\n"));
+ for (i = sizeof (compiler_params); i--;)
+ {
+ const char *description = compiler_params[i].help;
+ const int length = 21-strlen(compiler_params[i].option);
+
+ if (description != NULL && * description != 0)
+ printf (" --param %s=<value>%.*s%s\n",
+ compiler_params[i].option,
+ length > 0 ? length : 1, " ",
+ description);
+ }
printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
printf (_(" -w Suppress warnings\n"));
case 'A':
flag_debug_asm = 1;
break;
- case 'm':
- flag_print_mem = 1;
- break;
case 'p':
flag_print_asm_name = 1;
break;
else if ((option_value = skip_leading_substring (arg, "inline-limit-"))
|| (option_value = skip_leading_substring (arg, "inline-limit=")))
{
- int val =
+ int val =
read_integral_parameter (option_value, arg - 2,
MAX_INLINE_INSNS);
set_param_value ("max-inline-insns", val);
arg = argv[1];
/* Look for the `='. */
equal = strchr (arg, '=');
- if (!equal)
+ if (!equal)
error ("invalid --param option: %s", arg);
- else
+ else
{
int val;
return 2;
}
-
+
if (*arg == 'Y')
arg++;
Decode command args, then call compile_file.
Exit code is FATAL_EXIT_CODE if can't open files or if there were
any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
-
+
It is not safe to call this function more than once. */
int
/* Perform normal command line switch decoding. */
for (i = 1; i < argc;)
{
- unsigned int lang_processed;
- unsigned int indep_processed;
+ int lang_processed;
+ int indep_processed;
/* Give the language a chance to decode the option for itself. */
lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
- /* Now see if the option also has a language independent meaning.
- Some options are both language specific and language independent,
- eg --help. */
- indep_processed = independent_decode_option (argc - i, argv + i);
+ if (lang_processed >= 0)
+ /* Now see if the option also has a language independent meaning.
+ Some options are both language specific and language independent,
+ eg --help. */
+ indep_processed = independent_decode_option (argc - i, argv + i);
+ else
+ {
+ lang_processed = -lang_processed;
+ indep_processed = 0;
+ }
if (lang_processed || indep_processed)
i += MAX (lang_processed, indep_processed);
OVERRIDE_OPTIONS;
#endif
- if (exceptions_via_longjmp == 2)
- {
-#ifdef DWARF2_UNWIND_INFO
- exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
-#else
-#ifdef IA64_UNWIND_INFO
- exceptions_via_longjmp = ! IA64_UNWIND_INFO;
-#else
- exceptions_via_longjmp = 1;
-#endif
-#endif
- }
-
- /* Since each function gets its own handler data, we can't support the
- new model currently, since it depend on a specific rethrow label
- which is declared at the front of the table, and we can only
- have one such symbol in a file. */
-#ifdef IA64_UNWIND_INFO
- flag_new_exceptions = 0;
-#endif
-
/* Set up the align_*_log variables, defaulting them to 1 if they
were still unset. */
if (align_loops <= 0) align_loops = 1;
warning ("this target machine does not have delayed branches");
#endif
+ /* Some operating systems do not allow profiling without a frame
+ pointer. */
+ if (!TARGET_ALLOWS_PROFILING_WITHOUT_FRAME_POINTER
+ && profile_flag
+ && flag_omit_frame_pointer)
+ {
+ error ("profiling does not work without a frame pointer");
+ flag_omit_frame_pointer = 0;
+ }
+
user_label_prefix = USER_LABEL_PREFIX;
if (flag_leading_underscore != -1)
{
compile_file (filename);
-#if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
- if (flag_print_mem)
- {
- char *lim = (char *) sbrk (0);
-
- fnotice (stderr, "Data size %ld.\n", (long) (lim - (char *) &environ));
- fflush (stderr);
-
-#ifndef __MSDOS__
-#ifdef USG
- system ("ps -l 1>&2");
-#else /* not USG */
- system ("ps v");
-#endif /* not USG */
-#endif
- }
-#endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
-
if (errorcount)
return (FATAL_EXIT_CODE);
if (sorrycount)