gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 5 Jul 2015 07:58:30 +0000 (07:58 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 5 Jul 2015 07:58:30 +0000 (07:58 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225429 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/explow.c
gcc/function.c
gcc/target-insns.def

index 6f077c7..eca124b 100644 (file)
@@ -1,5 +1,16 @@
 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
        targetm instruction patterns.
        * cfgexpand.c (stack_protect_prologue): Use them instead of
index c64a3ee..cfd8dc5 100644 (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.  */
index 2c9deac..8ee79d3 100644 (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;
index 6aae708..28d3151 100644 (file)
    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))