+2004-04-26 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
+
+ * builtins.c (expand_builtin_update_setjmp_buf): New function.
+ (expand_builtin, case BUILT_IN_UPDATE_SETJMP_BUF): New case.
+ * builtins.def (BUILT_IN_UPDATE_SETJMP_BUF): New code.
+
2004-04-26 Paul Brook <paul@codesourcery.com>
* config/arm/arm.c (arm_legitimate_index_p): Correct iwmmxt offsets.
static rtx result_vector (int, rtx);
#endif
static rtx expand_builtin_setjmp (tree, rtx);
+static void expand_builtin_update_setjmp_buf (rtx);
static void expand_builtin_prefetch (tree);
static rtx expand_builtin_apply_args (void);
static rtx expand_builtin_apply_args_1 (void);
}
}
+/* __builtin_update_setjmp_buf is passed a pointer to an array of five words
+ (not all will be used on all machines) that was passed to __builtin_setjmp.
+ It updates the stack pointer in that block to correspond to the current
+ stack pointer. */
+
+static void
+expand_builtin_update_setjmp_buf (rtx buf_addr)
+{
+ enum machine_mode sa_mode = Pmode;
+ rtx stack_save;
+
+
+#ifdef HAVE_save_stack_nonlocal
+ if (HAVE_save_stack_nonlocal)
+ sa_mode = insn_data[(int) CODE_FOR_save_stack_nonlocal].operand[0].mode;
+#endif
+#ifdef STACK_SAVEAREA_MODE
+ sa_mode = STACK_SAVEAREA_MODE (SAVE_NONLOCAL);
+#endif
+
+ stack_save
+ = gen_rtx_MEM (sa_mode,
+ memory_address
+ (sa_mode,
+ plus_constant (buf_addr, 2 * GET_MODE_SIZE (Pmode))));
+
+#ifdef HAVE_setjmp
+ if (HAVE_setjmp)
+ emit_insn (gen_setjmp ());
+#endif
+
+ emit_stack_save (SAVE_NONLOCAL, &stack_save, NULL_RTX);
+}
+
/* Expand a call to __builtin_prefetch. For a target that does not support
data prefetch, evaluate the memory address argument in case it has side
effects. */
return const0_rtx;
}
+ /* This updates the setjmp buffer that is its argument with the value
+ of the current stack pointer. */
+ case BUILT_IN_UPDATE_SETJMP_BUF:
+ if (validate_arglist (arglist, POINTER_TYPE, VOID_TYPE))
+ {
+ rtx buf_addr
+ = expand_expr (TREE_VALUE (arglist), NULL_RTX, VOIDmode, 0);
+
+ expand_builtin_update_setjmp_buf (buf_addr);
+ return const0_rtx;
+ }
+ break;
+
case BUILT_IN_TRAP:
expand_builtin_trap ();
return const0_rtx;
DEF_LIB_BUILTIN (BUILT_IN_STRFTIME, "strftime", BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_PTR, ATTR_FORMAT_STRFTIME_3_0)
DEF_GCC_BUILTIN (BUILT_IN_TRAP, "trap", BT_FN_VOID, ATTR_NORETURN_NOTHROW_LIST)
DEF_GCC_BUILTIN (BUILT_IN_UNWIND_INIT, "unwind_init", BT_FN_VOID, ATTR_NULL)
+DEF_GCC_BUILTIN (BUILT_IN_UPDATE_SETJMP_BUF, "update_setjmp_buf", BT_FN_VOID_PTR_INT, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_VA_COPY, "va_copy", BT_FN_VOID_VALIST_REF_VALIST_ARG, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_VA_END, "va_end", BT_FN_VOID_VALIST_REF, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_VA_START, "va_start", BT_FN_VOID_VALIST_REF_VAR, ATTR_NULL)