aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/go/_std_1.22/src/runtime/cgo/asm_s390x.s
blob: 8f74fd5fe7810e44f0b3afd9489836d4e73dab60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "textflag.h"

// Set the x_crosscall2_ptr C function pointer variable point to crosscall2.
// It's such a pointer chain: _crosscall2_ptr -> x_crosscall2_ptr -> crosscall2
// Use a local trampoline, to avoid taking the address of a dynamically exported
// function.
TEXT ·set_crosscall2(SB),NOSPLIT,$0-0
	MOVD	_crosscall2_ptr(SB), R1
	MOVD	$crosscall2_trampoline<>(SB), R2
	MOVD	R2, (R1)
	RET

TEXT crosscall2_trampoline<>(SB),NOSPLIT,$0-0
	JMP	crosscall2(SB)

// Called by C code generated by cmd/cgo.
// func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
// Saves C callee-saved registers and calls cgocallback with three arguments.
// fn is the PC of a func(a unsafe.Pointer) function.
TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
	// Start with standard C stack frame layout and linkage.

	// Save R6-R15 in the register save area of the calling function.
	STMG	R6, R15, 48(R15)

	// Allocate 96 bytes on the stack.
	MOVD	$-96(R15), R15

	// Save F8-F15 in our stack frame.
	FMOVD	F8, 32(R15)
	FMOVD	F9, 40(R15)
	FMOVD	F10, 48(R15)
	FMOVD	F11, 56(R15)
	FMOVD	F12, 64(R15)
	FMOVD	F13, 72(R15)
	FMOVD	F14, 80(R15)
	FMOVD	F15, 88(R15)

	// Initialize Go ABI environment.
	BL	runtime·load_g(SB)

	MOVD	R2, 8(R15)	// fn unsafe.Pointer
	MOVD	R3, 16(R15)	// a unsafe.Pointer
	// Skip R4 = n uint32
	MOVD	R5, 24(R15)	// ctxt uintptr
	BL	runtime·cgocallback(SB)

	FMOVD	32(R15), F8
	FMOVD	40(R15), F9
	FMOVD	48(R15), F10
	FMOVD	56(R15), F11
	FMOVD	64(R15), F12
	FMOVD	72(R15), F13
	FMOVD	80(R15), F14
	FMOVD	88(R15), F15

	// De-allocate stack frame.
	MOVD	$96(R15), R15

	// Restore R6-R15.
	LMG	48(R15), R6, R15

	RET