Debian Codegraph @

internal/fakecgo/asm_riscv64.s

raw
1 // Copyright 2020 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 #include "textflag.h"
6 #include "abi_riscv64.h"
7
8 // Called by C code generated by cmd/cgo.
9 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
10 // Saves C callee-saved registers and calls cgocallback with three arguments.
11 // fn is the PC of a func(a unsafe.Pointer) function.
12 TEXT crosscall2(SB), NOSPLIT|NOFRAME, $0
13 /*
14 * Push arguments for fn (X10, X11, X13), along with all callee-save
15 * registers. Note that at procedure entry the first argument is at
16 * 8(X2).
17 */
18 ADD $(-8*29), X2
19 MOV X10, (8*1)(X2) // fn unsafe.Pointer
20 MOV X11, (8*2)(X2) // a unsafe.Pointer
21 MOV X13, (8*3)(X2) // ctxt uintptr
22
23 SAVE_GPR((8*4))
24 MOV X1, (8*16)(X2)
25 SAVE_FPR((8*17))
26
27 // Initialize Go ABI environment
28 CALL runtime·cgocallback(SB)
29
30 RESTORE_GPR((8*4))
31 MOV (8*16)(X2), X1
32 RESTORE_FPR((8*17))
33
34 ADD $(8*29), X2
35
36 RET