* target-insns.def (allocate_stack, check_stack, probe_stack)
	(probe_stack_address, split_stack_prologue, split_stack_space_check):
	New targetm instruction patterns.
	* explow.c (allocate_dynamic_stack_space): Use them instead of
	HAVE_*/gen_* interface.
	(emit_stack_probe): Likewise.
	(probe_stack_range): Likewise.
	* function.c (thread_prologue_and_epilogue_insns): Likewise.

From-SVN: r225429
This commit is contained in:
Richard Sandiford 2015-07-05 07:58:30 +00:00 committed by Richard Sandiford
parent c65aa0429d
commit 10169a8b99
4 changed files with 29 additions and 27 deletions

View File

@ -1,3 +1,14 @@
2015-07-05 Richard Sandiford <richard.sandiford@arm.com>
* target-insns.def (allocate_stack, check_stack, probe_stack)
(probe_stack_address, split_stack_prologue, split_stack_space_check):
New targetm instruction patterns.
* explow.c (allocate_dynamic_stack_space): Use them instead of
HAVE_*/gen_* interface.
(emit_stack_probe): Likewise.
(probe_stack_range): Likewise.
* function.c (thread_prologue_and_epilogue_insns): Likewise.
2015-07-05 Richard Sandiford <richard.sandiford@arm.com>
* target-insns.def (stack_protect_set, stack_protect_test): New

View File

@ -1308,16 +1308,15 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align,
available_label = NULL;
#ifdef HAVE_split_stack_space_check
if (HAVE_split_stack_space_check)
if (targetm.have_split_stack_space_check ())
{
available_label = gen_label_rtx ();
/* This instruction will branch to AVAILABLE_LABEL if there
are SIZE bytes available on the stack. */
emit_insn (gen_split_stack_space_check (size, available_label));
emit_insn (targetm.gen_split_stack_space_check
(size, available_label));
}
#endif
/* The __morestack_allocate_stack_space function will allocate
memory using malloc. If the alignment of the memory returned
@ -1375,8 +1374,7 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align,
/* Perform the required allocation from the stack. Some systems do
this differently than simply incrementing/decrementing from the
stack pointer, such as acquiring the space by calling malloc(). */
#ifdef HAVE_allocate_stack
if (HAVE_allocate_stack)
if (targetm.have_allocate_stack ())
{
struct expand_operand ops[2];
/* We don't have to check against the predicate for operand 0 since
@ -1384,10 +1382,9 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align,
be valid for the operand. */
create_fixed_operand (&ops[0], target);
create_convert_operand_to (&ops[1], size, STACK_SIZE_MODE, true);
expand_insn (CODE_FOR_allocate_stack, 2, ops);
expand_insn (targetm.code_for_allocate_stack, 2, ops);
}
else
#endif
{
int saved_stack_pointer_delta;
@ -1491,22 +1488,18 @@ set_stack_check_libfunc (const char *libfunc_name)
void
emit_stack_probe (rtx address)
{
#ifdef HAVE_probe_stack_address
if (HAVE_probe_stack_address)
emit_insn (gen_probe_stack_address (address));
if (targetm.have_probe_stack_address ())
emit_insn (targetm.gen_probe_stack_address (address));
else
#endif
{
rtx memref = gen_rtx_MEM (word_mode, address);
MEM_VOLATILE_P (memref) = 1;
/* See if we have an insn to probe the stack. */
#ifdef HAVE_probe_stack
if (HAVE_probe_stack)
emit_insn (gen_probe_stack (memref));
if (targetm.have_probe_stack ())
emit_insn (targetm.gen_probe_stack (memref));
else
#endif
emit_move_insn (memref, const0_rtx);
}
}
@ -1548,8 +1541,7 @@ probe_stack_range (HOST_WIDE_INT first, rtx size)
}
/* Next see if we have an insn to check the stack. */
#ifdef HAVE_check_stack
else if (HAVE_check_stack)
else if (targetm.have_check_stack ())
{
struct expand_operand ops[1];
rtx addr = memory_address (Pmode,
@ -1559,10 +1551,9 @@ probe_stack_range (HOST_WIDE_INT first, rtx size)
size, first)));
bool success;
create_input_operand (&ops[0], addr, Pmode);
success = maybe_expand_insn (CODE_FOR_check_stack, 1, ops);
success = maybe_expand_insn (targetm.code_for_check_stack, 1, ops);
gcc_assert (success);
}
#endif
/* Otherwise we have to generate explicit probes. If we have a constant
small number of them to generate, that's the easy case. */

View File

@ -5842,19 +5842,13 @@ thread_prologue_and_epilogue_insns (void)
&& (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (cfun->decl))
== NULL))
{
#ifndef HAVE_split_stack_prologue
gcc_unreachable ();
#else
gcc_assert (HAVE_split_stack_prologue);
start_sequence ();
emit_insn (gen_split_stack_prologue ());
emit_insn (targetm.gen_split_stack_prologue ());
split_prologue_seq = get_insns ();
end_sequence ();
record_insns (split_prologue_seq, NULL, &prologue_insn_hash);
set_insn_locations (split_prologue_seq, prologue_location);
#endif
}
prologue_seq = NULL;

View File

@ -30,11 +30,13 @@
Patterns that take no operands should have a prototype "(void)".
Instructions should be documented in md.texi rather than here. */
DEF_TARGET_INSN (allocate_stack, (rtx x0, rtx x1))
DEF_TARGET_INSN (builtin_longjmp, (rtx x0))
DEF_TARGET_INSN (builtin_setjmp_receiver, (rtx x0))
DEF_TARGET_INSN (builtin_setjmp_setup, (rtx x0))
DEF_TARGET_INSN (canonicalize_funcptr_for_compare, (rtx x0, rtx x1))
DEF_TARGET_INSN (casesi, (rtx x0, rtx x1, rtx x2, rtx x3, rtx x4))
DEF_TARGET_INSN (check_stack, (rtx x0))
DEF_TARGET_INSN (epilogue, (void))
DEF_TARGET_INSN (exception_receiver, (void))
DEF_TARGET_INSN (jump, (rtx x0))
@ -45,6 +47,8 @@ DEF_TARGET_INSN (memory_barrier, (void))
DEF_TARGET_INSN (nonlocal_goto, (rtx x0, rtx x1, rtx x2, rtx x3))
DEF_TARGET_INSN (nonlocal_goto_receiver, (void))
DEF_TARGET_INSN (prefetch, (rtx x0, rtx x1, rtx x2))
DEF_TARGET_INSN (probe_stack, (rtx x0))
DEF_TARGET_INSN (probe_stack_address, (rtx x0))
DEF_TARGET_INSN (prologue, (void))
DEF_TARGET_INSN (restore_stack_block, (rtx x0, rtx x1))
DEF_TARGET_INSN (restore_stack_function, (rtx x0, rtx x1))
@ -55,6 +59,8 @@ DEF_TARGET_INSN (save_stack_function, (rtx x0, rtx x1))
DEF_TARGET_INSN (save_stack_nonlocal, (rtx x0, rtx x1))
DEF_TARGET_INSN (sibcall_epilogue, (void))
DEF_TARGET_INSN (simple_return, (void))
DEF_TARGET_INSN (split_stack_prologue, (void))
DEF_TARGET_INSN (split_stack_space_check, (rtx x0, rtx x1))
DEF_TARGET_INSN (stack_protect_set, (rtx x0, rtx x1))
DEF_TARGET_INSN (stack_protect_test, (rtx x0, rtx x1, rtx x2))
DEF_TARGET_INSN (store_multiple, (rtx x0, rtx x1, rtx x2))