Author: Richard Plangger <[email protected]>
Branch: s390x-backend
Changeset: r81787:9eab6627968e
Date: 2016-01-15 11:45 +0100
http://bitbucket.org/pypy/pypy/changeset/9eab6627968e/
Log: implemented stacklet switch (slp_switch) for s390x
diff --git a/rpython/translator/c/src/stacklet/slp_platformselect.h
b/rpython/translator/c/src/stacklet/slp_platformselect.h
--- a/rpython/translator/c/src/stacklet/slp_platformselect.h
+++ b/rpython/translator/c/src/stacklet/slp_platformselect.h
@@ -14,7 +14,7 @@
#include "switch_ppc64_gcc.h" /* gcc on ppc64 */
#elif defined(__GNUC__) && defined(__mips__) && defined(_ABI64)
#include "switch_mips64_gcc.h" /* gcc on mips64 */
-#elif defined(__GNUC__) && defined(__s390x__) && defined(_ABI64)
+#elif defined(__GNUC__) && defined(__s390x__)
#include "switch_s390x_gcc.h"
#else
#error "Unsupported platform!"
diff --git a/rpython/translator/c/src/stacklet/switch_s390x_gcc.h
b/rpython/translator/c/src/stacklet/switch_s390x_gcc.h
--- a/rpython/translator/c/src/stacklet/switch_s390x_gcc.h
+++ b/rpython/translator/c/src/stacklet/switch_s390x_gcc.h
@@ -1,14 +1,3 @@
-#if !(defined(__LITTLE_ENDIAN__) ^ defined(__BIG_ENDIAN__))
-# error "cannot determine if it is ppc64 or ppc64le"
-#endif
-
-#ifdef __BIG_ENDIAN__
-# define TOC_AREA "40"
-#else
-# define TOC_AREA "24"
-#endif
-
-
/* This depends on these attributes so that gcc generates a function
with no code before the asm, and only "blr" after. */
static __attribute__((noinline, optimize("O2")))
@@ -36,67 +25,40 @@
"std 4,144(15)\n"
"std 6,152(15)\n"
- "lay 15,-160(15)\n" /* Create stack frame */
+ "lay 15,-160(15)\n" /* Create stack frame */
"lgr 10, %[restore_state]\n" /* save 'restore_state' for later */
"lgr 11, %[extra]\n" /* save 'extra' for later */
"lgr 14, %[save_state]\n" /* move 'save_state' into r14 for branching
*/
- "mr 2, 15\n" /* arg 1: current (old) stack pointer */
- "mr 3, 11\n" /* arg 2: extra */
+ "lgr 2, 15\n" /* arg 1: current (old) stack pointer */
+ "lgr 3, 11\n" /* arg 2: extra */
- "stdu 1, -48(1)\n" /* create temp stack space (see below) */
-#ifdef __BIG_ENDIAN__
- "ld 0, 0(12)\n"
- "ld 11, 16(12)\n"
- "mtctr 0\n"
- "ld 2, 8(12)\n"
-#else
- "mtctr 12\n" /* r12 is fixed by this ABI */
-#endif
- "bctrl\n" /* call save_state() */
- "addi 1, 1, 48\n" /* destroy temp stack space */
+ "lay 15, -160(15)\n" /* create temp stack space (see below) */
+ "basr 14, 14\n" /* call save_state() */
+ "lay 15, 160(15)\n" /* destroy temp stack space */
- "CGIJ 2, 0, 7, zero\n" /* skip the rest if the return value is null */
+ "cgij 2, 0, 8, zero\n" /* skip the rest if the return value is null
*/
- "lgr 15, 2\n" /* change the stack pointer */
- /* From now on, the stack pointer is modified, but the content of the
+ "lgr 15, 2\n" /* change the stack pointer */
+
+ /* From now on, the stack pointer is modified, but the content of the
stack is not restored yet. It contains only garbage here. */
+ /* arg 1: current (new) stack pointer
+ is already in r2 */
+ "lgr 3, 11\n" /* arg 2: extra */
- "mr 4, 15\n" /* arg 2: extra */
- /* arg 1: current (new) stack pointer
- is already in r3 */
- "stdu 1, -48(1)\n" /* create temp stack space for callee to use */
- /* ^^^ we have to be careful. The function call will store the link
- register in the current frame (as the ABI) dictates. But it will
- then trample it with the restore! We fix this by creating a fake
- stack frame */
-
-#ifdef __BIG_ENDIAN__
- "ld 0, 0(14)\n" /* 'restore_state' is in r14 */
- "ld 11, 16(14)\n"
- "mtctr 0\n"
- "ld 2, 8(14)\n"
-#endif
-#ifdef __LITTLE_ENDIAN__
- "mr 12, 14\n" /* copy 'restore_state' */
- "mtctr 12\n" /* r12 is fixed by this ABI */
-#endif
-
- "bctrl\n" /* call restore_state() */
- "addi 1, 1, 48\n" /* destroy temp stack space */
+ "lay 15, -160(15)\n" /* create temp stack space for callee to use */
+ "lgr 14, 10\n" /* load restore_state */
+ "basr 14, 14\n" /* call restore_state() */
+ "lay 15, 160(15)\n" /* destroy temp stack space */
/* The stack's content is now restored. */
"zero:\n"
/* Epilogue */
-
- // "mtcrf 0xff, 12\n"
-
- // "addi 1,1,528\n"
-
- "lay 15,160(15)\n" /* restore stack pointer */
+ /* no need */ /* restore stack pointer */
"ld 0,128(15)\n"
"ld 2,136(15)\n"
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit