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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
// Copyright 2014 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.
// +build ppc64 ppc64le
// +build linux
/*
* Apple still insists on underscore prefixes for C function names.
*/
#if defined(__APPLE__)
#define EXT(s) _##s
#else
#define EXT(s) s
#endif
/*
* void crosscall_ppc64(void (*fn)(void), void *g)
*
* Calling into the gc tool chain, where all registers are caller save.
* Called from standard ppc64 C ABI, where r2, r14-r31, f14-f31 are
* callee-save, so they must be saved explicitly.
*/
.globl EXT(crosscall_ppc64)
EXT(crosscall_ppc64):
// Start with standard C stack frame layout and linkage
mflr %r0
std %r0, 16(%r1) // Save LR in caller's frame
std %r2, 24(%r1) // Save TOC in caller's frame
bl saveregs
stdu %r1, -296(%r1)
// Set up Go ABI constant registers
bl _cgo_reginit
nop
// Restore g pointer (r30 in Go ABI, which may have been clobbered by C)
mr %r30, %r4
// Call fn
mr %r12, %r3
mtctr %r3
bctrl
addi %r1, %r1, 296
bl restoreregs
ld %r2, 24(%r1)
ld %r0, 16(%r1)
mtlr %r0
blr
saveregs:
// Save callee-save registers
// O=-288; for R in %r{14..31}; do echo "\tstd\t$R, $O(%r1)"; ((O+=8)); done; for F in f{14..31}; do echo "\tstfd\t$F, $O(%r1)"; ((O+=8)); done
std %r14, -288(%r1)
std %r15, -280(%r1)
std %r16, -272(%r1)
std %r17, -264(%r1)
std %r18, -256(%r1)
std %r19, -248(%r1)
std %r20, -240(%r1)
std %r21, -232(%r1)
std %r22, -224(%r1)
std %r23, -216(%r1)
std %r24, -208(%r1)
std %r25, -200(%r1)
std %r26, -192(%r1)
std %r27, -184(%r1)
std %r28, -176(%r1)
std %r29, -168(%r1)
std %r30, -160(%r1)
std %r31, -152(%r1)
stfd %f14, -144(%r1)
stfd %f15, -136(%r1)
stfd %f16, -128(%r1)
stfd %f17, -120(%r1)
stfd %f18, -112(%r1)
stfd %f19, -104(%r1)
stfd %f20, -96(%r1)
stfd %f21, -88(%r1)
stfd %f22, -80(%r1)
stfd %f23, -72(%r1)
stfd %f24, -64(%r1)
stfd %f25, -56(%r1)
stfd %f26, -48(%r1)
stfd %f27, -40(%r1)
stfd %f28, -32(%r1)
stfd %f29, -24(%r1)
stfd %f30, -16(%r1)
stfd %f31, -8(%r1)
blr
restoreregs:
// O=-288; for R in %r{14..31}; do echo "\tld\t$R, $O(%r1)"; ((O+=8)); done; for F in %f{14..31}; do echo "\tlfd\t$F, $O(%r1)"; ((O+=8)); done
ld %r14, -288(%r1)
ld %r15, -280(%r1)
ld %r16, -272(%r1)
ld %r17, -264(%r1)
ld %r18, -256(%r1)
ld %r19, -248(%r1)
ld %r20, -240(%r1)
ld %r21, -232(%r1)
ld %r22, -224(%r1)
ld %r23, -216(%r1)
ld %r24, -208(%r1)
ld %r25, -200(%r1)
ld %r26, -192(%r1)
ld %r27, -184(%r1)
ld %r28, -176(%r1)
ld %r29, -168(%r1)
ld %r30, -160(%r1)
ld %r31, -152(%r1)
lfd %f14, -144(%r1)
lfd %f15, -136(%r1)
lfd %f16, -128(%r1)
lfd %f17, -120(%r1)
lfd %f18, -112(%r1)
lfd %f19, -104(%r1)
lfd %f20, -96(%r1)
lfd %f21, -88(%r1)
lfd %f22, -80(%r1)
lfd %f23, -72(%r1)
lfd %f24, -64(%r1)
lfd %f25, -56(%r1)
lfd %f26, -48(%r1)
lfd %f27, -40(%r1)
lfd %f28, -32(%r1)
lfd %f29, -24(%r1)
lfd %f30, -16(%r1)
lfd %f31, -8(%r1)
blr
#ifdef __ELF__
.section .note.GNU-stack,"",%progbits
#endif
|