public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Use target-insns.def for various stack patterns
@ 2015-07-05  7:58 Richard Sandiford
  0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2015-07-05  7:58 UTC (permalink / raw)
  To: gcc-patches

Bootstrapped & regression-tested on x86_64-linux-gnu and aarch64-linux-gnu.
Also tested via config-list.mk.  Committed as preapproved.

Thanks,
Richard


gcc/
	* 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.

Index: gcc/target-insns.def
===================================================================
--- gcc/target-insns.def	2015-07-05 08:56:54.099718182 +0100
+++ gcc/target-insns.def	2015-07-05 08:57:13.000000000 +0100
@@ -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, (r
 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))
Index: gcc/explow.c
===================================================================
--- gcc/explow.c	2015-07-05 08:56:54.099718182 +0100
+++ gcc/explow.c	2015-07-05 08:56:54.091718280 +0100
@@ -1308,16 +1308,15 @@ allocate_dynamic_stack_space (rtx size,
 
       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,
   /* 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,
 	 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 *lib
 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,
     }
 
   /* 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,
 								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.  */
Index: gcc/function.c
===================================================================
--- gcc/function.c	2015-07-05 08:56:54.099718182 +0100
+++ gcc/function.c	2015-07-05 08:56:54.091718280 +0100
@@ -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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-05  7:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-05  7:58 [committed] Use target-insns.def for various stack patterns Richard Sandiford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).