diff options
Diffstat (limited to 'gcc/explow.c')
-rw-r--r-- | gcc/explow.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/gcc/explow.c b/gcc/explow.c index 28afe3c..857bcc6 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -1379,6 +1379,19 @@ allocate_dynamic_stack_space (size, target, known_align) return target; } +/* A front end may want to override GCC's stack checking by providing a + run-time routine to call to check the stack, so provide a mechanism for + calling that routine. */ + +static rtx stack_check_libfunc; + +void +set_stack_check_libfunc (libfunc) + rtx libfunc; +{ + stack_check_libfunc = libfunc; +} + /* Emit one stack probe at ADDRESS, an address within the stack. */ static void @@ -1412,9 +1425,19 @@ probe_stack_range (first, size) HOST_WIDE_INT first; rtx size; { - /* First see if we have an insn to check the stack. Use it if so. */ + /* First see if the front end has set up a function for us to call to + check the stack. */ + if (stack_check_libfunc != 0) + emit_library_call (stack_check_libfunc, 0, VOIDmode, 1, + memory_address (QImode, + gen_rtx (STACK_GROW_OP, Pmode, + stack_pointer_rtx, + plus_constant (size, first))), + ptr_mode); + + /* Next see if we have an insn to check the stack. Use it if so. */ #ifdef HAVE_check_stack - if (HAVE_check_stack) + else if (HAVE_check_stack) { insn_operand_predicate_fn pred; rtx last_addr @@ -1428,14 +1451,13 @@ probe_stack_range (first, size) last_addr = copy_to_mode_reg (Pmode, last_addr); emit_insn (gen_check_stack (last_addr)); - return; } #endif /* If we have to generate explicit probes, see if we have a constant small number of them to generate. If so, that's the easy case. */ - if (GET_CODE (size) == CONST_INT - && INTVAL (size) < 10 * STACK_CHECK_PROBE_INTERVAL) + else if (GET_CODE (size) == CONST_INT + && INTVAL (size) < 10 * STACK_CHECK_PROBE_INTERVAL) { HOST_WIDE_INT offset; |