github.com/twelsh-aw/go/src@v0.0.0-20230516233729-a56fe86a7c81/runtime/cgo/asm_loong64.s (about)

     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Ā·load_g(SB)
    31  
    32  	JAL	runtimeĀ·cgocallback(SB)
    33  
    34  	RESTORE_R22_TO_R31((4*8))
    35  	RESTORE_F24_TO_F31((14*8))
    36  	MOVV	(22*8)(R3), R1
    37  
    38  	ADDV	$(23*8), R3
    39  
    40  	RET