#include "function.h"
#include "expr.h"
#include "optabs.h"
+#include "libfuncs.h"
#include "hard-reg-set.h"
#include "insn-config.h"
#include "ggc.h"
static rtx break_out_memory_refs (rtx);
static void emit_stack_probe (rtx);
-static void anti_adjust_stack_and_probe (rtx);
/* Truncate and perhaps sign-extend C as appropriate for MODE. */
}
if (flag_stack_check && STACK_CHECK_MOVING_SP)
- anti_adjust_stack_and_probe (size);
+ anti_adjust_stack_and_probe (size, false);
else
anti_adjust_stack (size);
static GTY(()) rtx stack_check_libfunc;
void
-set_stack_check_libfunc (rtx libfunc)
+set_stack_check_libfunc (const char *libfunc_name)
{
- stack_check_libfunc = libfunc;
+ gcc_assert (stack_check_libfunc == NULL_RTX);
+ stack_check_libfunc = gen_rtx_SYMBOL_REF (Pmode, libfunc_name);
}
\f
/* Emit one stack probe at ADDRESS, an address within the stack. */
emit_insn (gen_probe_stack (memref));
else
#endif
- if (STACK_CHECK_PROBE_LOAD)
- emit_move_insn (gen_reg_rtx (word_mode), memref);
- else
emit_move_insn (memref, const0_rtx);
}
gen_rtx_fmt_ee (STACK_GROW_OP, Pmode,
stack_pointer_rtx,
plus_constant (size, first)));
- emit_library_call (stack_check_libfunc, LCT_NORMAL, VOIDmode, 1, addr);
+ emit_library_call (stack_check_libfunc, LCT_NORMAL, VOIDmode, 1, addr,
+ Pmode);
}
/* Next see if we have an insn to check the stack. */
}
}
-/* Adjust the stack by SIZE bytes while probing it. Note that we skip the
- probe for the first interval + a small dope of 4 words and instead probe
- that many bytes past the specified size to maintain a protection area. */
+/* Adjust the stack pointer by minus SIZE (an rtx for a number of bytes)
+ while probing it. This pushes when SIZE is positive. SIZE need not
+ be constant. If ADJUST_BACK is true, adjust back the stack pointer
+ by plus SIZE at the end. */
-static void
-anti_adjust_stack_and_probe (rtx size)
+void
+anti_adjust_stack_and_probe (rtx size, bool adjust_back)
{
+ /* We skip the probe for the first interval + a small dope of 4 words and
+ probe that many bytes past the specified size to maintain a protection
+ area at the botton of the stack. */
const int dope = 4 * UNITS_PER_WORD;
/* First ensure SIZE is Pmode. */
}
}
- /* Adjust back to account for the additional first interval. */
- adjust_stack (GEN_INT (PROBE_INTERVAL + dope));
+ /* Adjust back and account for the additional first interval. */
+ if (adjust_back)
+ adjust_stack (plus_constant (size, PROBE_INTERVAL + dope));
+ else
+ adjust_stack (GEN_INT (PROBE_INTERVAL + dope));
}
/* Return an rtx representing the register or memory location