diff options
author | Richard Kenner <kenner@vlsi1.ultra.nyu.edu> | 2004-04-26 18:11:32 +0000 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 2004-04-26 14:11:32 -0400 |
commit | 2b92e7f5cd41d466afb316926e585b4ac4ca5193 (patch) | |
tree | 351f7dbe0bf373918422a5db8d9fd9a05de845db /gcc/builtins.c | |
parent | 479864fe8016dd4c1ec19e93fd50f61b31056e42 (diff) | |
download | gcc-2b92e7f5cd41d466afb316926e585b4ac4ca5193.zip gcc-2b92e7f5cd41d466afb316926e585b4ac4ca5193.tar.gz gcc-2b92e7f5cd41d466afb316926e585b4ac4ca5193.tar.bz2 |
builtins.c (expand_builtin_update_setjmp_buf): New function.
* 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.
From-SVN: r81198
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 7c6cae1..e2d3934 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -84,6 +84,7 @@ static int apply_result_size (void); 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); @@ -738,6 +739,40 @@ expand_builtin_longjmp (rtx buf_addr, rtx value) } } +/* __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. */ @@ -5621,6 +5656,19 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, 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; |