github.com/mtsmfm/go/src@v0.0.0-20221020090648-44bdcb9f8fde/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  
     7  // Called by C code generated by cmd/cgo.
     8  // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
     9  // Saves C callee-saved registers and calls cgocallback with three arguments.
    10  // fn is the PC of a func(a unsafe.Pointer) function.
    11  TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
    12  	/*
    13  	 * We still need to save all callee save register as before, and then
    14  	 * push 3 args for fn (R4, R5, R7), skipping R6.
    15  	 * Also note that at procedure entry in gc world, 8(R29) will be the
    16  	 *  first arg.
    17  	 */
    18  
    19  	ADDV	$(-8*22), R3
    20  	MOVV	R4, (8*1)(R3) // fn unsafe.Pointer
    21  	MOVV	R5, (8*2)(R3) // a unsafe.Pointer
    22  	MOVV	R7, (8*3)(R3) // ctxt uintptr
    23  	MOVV	R23, (8*4)(R3)
    24  	MOVV	R24, (8*5)(R3)
    25  	MOVV	R25, (8*6)(R3)
    26  	MOVV	R26, (8*7)(R3)
    27  	MOVV	R27, (8*8)(R3)
    28  	MOVV	R28, (8*9)(R3)
    29  	MOVV	R29, (8*10)(R3)
    30  	MOVV	R30, (8*11)(R3)
    31  	MOVV	g, (8*12)(R3)
    32  	MOVV	R1, (8*13)(R3)
    33  	MOVD	F24, (8*14)(R3)
    34  	MOVD	F25, (8*15)(R3)
    35  	MOVD	F26, (8*16)(R3)
    36  	MOVD	F27, (8*17)(R3)
    37  	MOVD	F28, (8*18)(R3)
    38  	MOVD	F29, (8*19)(R3)
    39  	MOVD	F30, (8*20)(R3)
    40  	MOVD	F31, (8*21)(R3)
    41  
    42  	// Initialize Go ABI environment
    43  	JAL	runtimeĀ·load_g(SB)
    44  
    45  	JAL	runtimeĀ·cgocallback(SB)
    46  
    47  	MOVV	(8*4)(R3), R23
    48  	MOVV	(8*5)(R3), R24
    49  	MOVV	(8*6)(R3), R25
    50  	MOVV	(8*7)(R3), R26
    51  	MOVV	(8*8)(R3), R27
    52  	MOVV	(8*9)(R3), R28
    53  	MOVV	(8*10)(R3), R29
    54  	MOVV	(8*11)(R3), R30
    55  	MOVV	(8*12)(R3), g
    56  	MOVV	(8*13)(R3), R1
    57  	MOVD	(8*14)(R3), F24
    58  	MOVD	(8*15)(R3), F25
    59  	MOVD	(8*16)(R3), F26
    60  	MOVD	(8*17)(R3), F27
    61  	MOVD	(8*18)(R3), F28
    62  	MOVD	(8*19)(R3), F29
    63  	MOVD	(8*20)(R3), F30
    64  	MOVD	(8*21)(R3), F31
    65  	ADDV	$(8*22), R3
    66  
    67  	RET