Commit 6e6a07d2 by Mike Stump

except.c (start_dynamic_handler): Fix so that we can use __builtin_setjmp...

	* except.c (start_dynamic_handler): Fix so that we can use
 	__builtin_setjmp, and default to using __builtin_setjmp instead of
 	setjmp.
	* expr.c (expand_builtin_setjmp): New routine, split out from
	existing inline code from expand_builtin.
	(expand_builtin): Split out code into expand_builtin_setjmp.
	* expr.h (expand_builtin_setjmp): Add declaration.
	* libgcc2.c (__sjthrow): Default to using __builtin_setjmp instead
 	of setjmp.
	(__sjpopnthrow): Likewise.
	* optabs.c (init_optabs): Likewise.

From-SVN: r14045
parent 24f2dbd6
...@@ -693,9 +693,9 @@ add_partial_entry (handler) ...@@ -693,9 +693,9 @@ add_partial_entry (handler)
when there are no more elements in the dynamic handler chain, when when there are no more elements in the dynamic handler chain, when
the value is &top_elt from libgcc2.c. Immediately after the the value is &top_elt from libgcc2.c. Immediately after the
pointer, is an area suitable for setjmp/longjmp when pointer, is an area suitable for setjmp/longjmp when
USE_BUILTIN_SETJMP isn't defined, and an area suitable for DONT_USE_BUILTIN_SETJMP is defined, and an area suitable for
__builtin_setjmp/__builtin_longjmp when USE_BUILTIN_SETJMP is __builtin_setjmp/__builtin_longjmp when DONT_USE_BUILTIN_SETJMP
defined. isn't defined.
This routine is here to facilitate the porting of this code to This routine is here to facilitate the porting of this code to
systems with threads. One can either replace the routine we emit a systems with threads. One can either replace the routine we emit a
...@@ -843,10 +843,10 @@ static void ...@@ -843,10 +843,10 @@ static void
start_dynamic_handler () start_dynamic_handler ()
{ {
rtx dhc, dcc; rtx dhc, dcc;
rtx x, arg; rtx x, arg, buf;
int size; int size;
#ifdef USE_BUILTIN_SETJMP #ifndef DONT_USE_BUILTIN_SETJMP
/* The number of Pmode words for the setjmp buffer, when using the /* The number of Pmode words for the setjmp buffer, when using the
builtin setjmp/longjmp, see expand_builtin, case builtin setjmp/longjmp, see expand_builtin, case
BUILT_IN_LONGJMP. */ BUILT_IN_LONGJMP. */
...@@ -882,10 +882,14 @@ start_dynamic_handler () ...@@ -882,10 +882,14 @@ start_dynamic_handler ()
emit_move_insn (dcc, const0_rtx); emit_move_insn (dcc, const0_rtx);
/* The jmpbuf starts two words into the area allocated. */ /* The jmpbuf starts two words into the area allocated. */
buf = plus_constant (XEXP (arg, 0), GET_MODE_SIZE (Pmode)*2);
#ifdef DONT_USE_BUILTIN_SETJMP
x = emit_library_call_value (setjmp_libfunc, NULL_RTX, 1, SImode, 1, x = emit_library_call_value (setjmp_libfunc, NULL_RTX, 1, SImode, 1,
plus_constant (XEXP (arg, 0), GET_MODE_SIZE (Pmode)*2), buf, Pmode);
Pmode); #else
x = expand_builtin_setjmp (buf, NULL_RTX);
#endif
/* If we come back here for a catch, transfer control to the /* If we come back here for a catch, transfer control to the
handler. */ handler. */
......
...@@ -685,6 +685,8 @@ extern rtx store_expr PROTO((tree, rtx, int)); ...@@ -685,6 +685,8 @@ extern rtx store_expr PROTO((tree, rtx, int));
Useful after calling expand_expr with 1 as sum_ok. */ Useful after calling expand_expr with 1 as sum_ok. */
extern rtx force_operand PROTO((rtx, rtx)); extern rtx force_operand PROTO((rtx, rtx));
extern rtx expand_builtin_setjmp PROTO((rtx, rtx));
#ifdef TREE_CODE #ifdef TREE_CODE
/* Generate code for computing expression EXP. /* Generate code for computing expression EXP.
An rtx for the computed value is returned. The value is never null. An rtx for the computed value is returned. The value is never null.
......
...@@ -3120,7 +3120,7 @@ __terminate () ...@@ -3120,7 +3120,7 @@ __terminate ()
is raised when using the setjmp/longjmp exception handling codegen is raised when using the setjmp/longjmp exception handling codegen
method. */ method. */
extern longjmp (void *, int); extern void longjmp (void *, int);
extern void *__eh_type; extern void *__eh_type;
...@@ -3169,7 +3169,11 @@ __sjthrow () ...@@ -3169,7 +3169,11 @@ __sjthrow ()
buf[0] = (*dhc); buf[0] = (*dhc);
/* try { */ /* try { */
#ifdef DONT_USE_BUILTIN_SETJMP
if (! setjmp (&buf[2])) if (! setjmp (&buf[2]))
#else
if (! __builtin_setjmp (&buf[2]))
#endif
{ {
*dhc = buf; *dhc = buf;
while (cleanup[0]) while (cleanup[0])
...@@ -3206,10 +3210,10 @@ __sjthrow () ...@@ -3206,10 +3210,10 @@ __sjthrow ()
/* And then we jump to the handler. */ /* And then we jump to the handler. */
#ifdef USE_BUILTIN_SETJMP #ifdef DONT_USE_BUILTIN_SETJMP
__builtin_longjmp (jmpbuf, 1);
#else
longjmp (jmpbuf, 1); longjmp (jmpbuf, 1);
#else
__builtin_longjmp (jmpbuf, 1);
#endif #endif
} }
...@@ -3240,7 +3244,11 @@ __sjpopnthrow () ...@@ -3240,7 +3244,11 @@ __sjpopnthrow ()
buf[0] = (*dhc); buf[0] = (*dhc);
/* try { */ /* try { */
#ifdef DONT_USE_BUILTIN_SETJMP
if (! setjmp (&buf[2])) if (! setjmp (&buf[2]))
#else
if (! __builtin_setjmp (&buf[2]))
#endif
{ {
*dhc = buf; *dhc = buf;
while (cleanup[0]) while (cleanup[0])
......
...@@ -4277,7 +4277,7 @@ init_optabs () ...@@ -4277,7 +4277,7 @@ init_optabs ()
sjthrow_libfunc = gen_rtx (SYMBOL_REF, Pmode, "__sjthrow"); sjthrow_libfunc = gen_rtx (SYMBOL_REF, Pmode, "__sjthrow");
sjpopnthrow_libfunc = gen_rtx (SYMBOL_REF, Pmode, "__sjpopnthrow"); sjpopnthrow_libfunc = gen_rtx (SYMBOL_REF, Pmode, "__sjpopnthrow");
terminate_libfunc = gen_rtx (SYMBOL_REF, Pmode, "__terminate"); terminate_libfunc = gen_rtx (SYMBOL_REF, Pmode, "__terminate");
#ifdef USE_BUILTIN_SETJMP #ifndef DONT_USE_BUILTIN_SETJMP
setjmp_libfunc = gen_rtx (SYMBOL_REF, Pmode, "__builtin_setjmp"); setjmp_libfunc = gen_rtx (SYMBOL_REF, Pmode, "__builtin_setjmp");
longjmp_libfunc = gen_rtx (SYMBOL_REF, Pmode, "__builtin_longjmp"); longjmp_libfunc = gen_rtx (SYMBOL_REF, Pmode, "__builtin_longjmp");
#else #else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment