| 1 |
// Copyright 2022 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_loong64.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 |
* We still need to save all callee save register as before, and then |
| 15 |
* push 3 args for fn (R4, R5, R7), skipping R6. |
| 16 |
* Also note that at procedure entry in gc world, 8(R29) will be the |
| 17 |
* first arg. |
| 18 |
*/ |
| 19 |
|
| 20 |
ADDV $(-23*8), R3 |
| 21 |
MOVV R4, (1*8)(R3) // fn unsafe.Pointer |
| 22 |
MOVV R5, (2*8)(R3) // a unsafe.Pointer |
| 23 |
MOVV R7, (3*8)(R3) // ctxt uintptr |
| 24 |
|
| 25 |
SAVE_R22_TO_R31((4*8)) |
| 26 |
SAVE_F24_TO_F31((14*8)) |
| 27 |
MOVV R1, (22*8)(R3) |
| 28 |
|
| 29 |
// Initialize Go ABI environment |
| 30 |
JAL runtime·cgocallback(SB) |
| 31 |
|
| 32 |
RESTORE_R22_TO_R31((4*8)) |
| 33 |
RESTORE_F24_TO_F31((14*8)) |
| 34 |
MOVV (22*8)(R3), R1 |
| 35 |
|
| 36 |
ADDV $(23*8), R3 |
| 37 |
|
| 38 |
RET |