Debian Codegraph @

rpython/translator/c/src/stacklet/switch_s390x_gcc.h

raw symbols SCIP
1 /* This depends on these attributes so that gcc generates a function
2 with no code before the asm, and only "blr" after. */
3 static __attribute__((noinline, optimize("O2")))
4 void *slp_switch(void *(*save_state)(void*, void*),
5 void *(*restore_state)(void*, void*),
6 void *extra)
7 {
8 void *result;
9 __asm__ volatile (
10 /* The Stackless version by Kristjan Valur Jonsson,
11 ported to s390x by Richard Plangger */
12
13 "stmg 6,15,48(15)\n"
14
15 // store f8 - f15 into the stack frame that is not used!
16 "std 8,128(15)\n"
17 "std 9,136(15)\n"
18 "std 10,144(15)\n"
19 "std 11,152(15)\n"
20
21 "std 12,16(15)\n"
22 "std 13,24(15)\n"
23 "std 14,32(15)\n"
24 "std 15,40(15)\n"
25
26 "lgr 10, %[restore_state]\n" /* save 'restore_state' for later */
27 "lgr 11, %[extra]\n" /* save 'extra' for later */
28 "lgr 14, %[save_state]\n" /* move 'save_state' into r14 for branching */
29 "lgr 2, 15\n" /* arg 1: current (old) stack pointer */
30 "lgr 3, 11\n" /* arg 2: extra */
31
32 "lay 15,-160(15)\n" /* create stack frame */
33 "basr 14, 14\n" /* call save_state() */
34 "lay 15,160(15)\n"
35
36 "cgij 2, 0, 8, zero\n" /* skip the rest if the return value is null */
37
38 "lgr 15, 2\n" /* change the stack pointer */
39
40 /* From now on, the stack pointer is modified, but the content of the
41 stack is not restored yet. It contains only garbage here. */
42 /* arg 1: current (new) stack pointer
43 is already in r2 */
44 "lgr 3, 11\n" /* arg 2: extra */
45
46 "lay 15,-160(15)\n" /* create stack frame */
47 "basr 14, 10\n" /* call restore_state() */
48 "lay 15,160(15)\n"
49
50 /* The stack's content is now restored. */
51
52 "zero:\n"
53
54 /* Epilogue */
55 "ld 8,128(15)\n"
56 "ld 9,136(15)\n"
57 "ld 10,144(15)\n"
58 "ld 11,152(15)\n"
59
60 "ld 12,16(15)\n"
61 "ld 13,24(15)\n"
62 "ld 14,32(15)\n"
63 "ld 15,40(15)\n"
64
65 "lmg 6,15,48(15)\n"
66
67 : "=r"(result) /* output variable: expected to be r2 */
68 : [restore_state]"r"(restore_state), /* input variables */
69 [save_state]"r"(save_state),
70 [extra]"r"(extra)
71 );
72 return result;
73 }