1// Copyright 2016 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5.file "gcc_s390x.S"
6
7/*
8 * void crosscall_s390x(void (*fn)(void), void *g)
9 *
10 * Calling into the go tool chain, where all registers are caller save.
11 * Called from standard s390x C ABI, where r6-r13, r15, and f8-f15 are
12 * callee-save, so they must be saved explicitly.
13 */
14.globl crosscall_s390x
15crosscall_s390x:
16	/* save r6-r15 in the register save area of the calling function */
17	stmg    %r6, %r15, 48(%r15)
18
19	/* allocate 64 bytes of stack space to save f8-f15 */
20	lay     %r15, -64(%r15)
21
22	/* save callee-saved floating point registers */
23	std     %f8, 0(%r15)
24	std     %f9, 8(%r15)
25	std     %f10, 16(%r15)
26	std     %f11, 24(%r15)
27	std     %f12, 32(%r15)
28	std     %f13, 40(%r15)
29	std     %f14, 48(%r15)
30	std     %f15, 56(%r15)
31
32	/* restore g pointer */
33	lgr     %r13, %r3
34
35	/* call fn */
36	basr    %r14, %r2
37
38	/* restore floating point registers */
39	ld      %f8, 0(%r15)
40	ld      %f9, 8(%r15)
41	ld      %f10, 16(%r15)
42	ld      %f11, 24(%r15)
43	ld      %f12, 32(%r15)
44	ld      %f13, 40(%r15)
45	ld      %f14, 48(%r15)
46	ld      %f15, 56(%r15)
47
48	/* de-allocate stack frame */
49	la      %r15, 64(%r15)
50
51	/* restore general purpose registers */
52	lmg     %r6, %r15, 48(%r15)
53
54	br      %r14 /* restored by lmg */
55
56#ifdef __ELF__
57.section .note.GNU-stack,"",%progbits
58#endif
59