github.com/jwijenbergh/purego@v0.0.0-20240126093400-70ff3a61df13/internal/fakecgo/trampolines_arm64.s (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
     3  
     4  //go:build darwin || freebsd || linux
     5  
     6  #include "textflag.h"
     7  #include "go_asm.h"
     8  
     9  // these trampolines map the gcc ABI to Go ABI and then calls into the Go equivalent functions.
    10  
    11  TEXT x_cgo_init_trampoline(SB), NOSPLIT, $0-0
    12  	MOVD R0, 8(RSP)
    13  	MOVD R1, 16(RSP)
    14  	MOVD ·x_cgo_init_call(SB), R26
    15  	MOVD (R26), R2
    16  	CALL (R2)
    17  	RET
    18  
    19  TEXT x_cgo_thread_start_trampoline(SB), NOSPLIT, $0-0
    20  	MOVD R0, 8(RSP)
    21  	MOVD ·x_cgo_thread_start_call(SB), R26
    22  	MOVD (R26), R2
    23  	CALL (R2)
    24  	RET
    25  
    26  TEXT x_cgo_setenv_trampoline(SB), NOSPLIT, $0-0
    27  	MOVD R0, 8(RSP)
    28  	MOVD ·x_cgo_setenv_call(SB), R26
    29  	MOVD (R26), R2
    30  	CALL (R2)
    31  	RET
    32  
    33  TEXT x_cgo_unsetenv_trampoline(SB), NOSPLIT, $0-0
    34  	MOVD R0, 8(RSP)
    35  	MOVD ·x_cgo_unsetenv_call(SB), R26
    36  	MOVD (R26), R2
    37  	CALL (R2)
    38  	RET
    39  
    40  TEXT x_cgo_notify_runtime_init_done_trampoline(SB), NOSPLIT, $0-0
    41  	CALL ·x_cgo_notify_runtime_init_done(SB)
    42  	RET
    43  
    44  TEXT x_cgo_bindm_trampoline(SB), NOSPLIT, $0
    45  	CALL ·x_cgo_bindm(SB)
    46  	RET
    47  
    48  // func setg_trampoline(setg uintptr, g uintptr)
    49  TEXT ·setg_trampoline(SB), NOSPLIT, $0-16
    50  	MOVD G+8(FP), R0
    51  	MOVD setg+0(FP), R1
    52  	CALL R1
    53  	RET
    54  
    55  TEXT threadentry_trampoline(SB), NOSPLIT, $0-0
    56  	MOVD R0, 8(RSP)
    57  	MOVD ·threadentry_call(SB), R26
    58  	MOVD (R26), R2
    59  	CALL (R2)
    60  	MOVD $0, R0                     // TODO: get the return value from threadentry
    61  	RET
    62  
    63  TEXT ·call5(SB), NOSPLIT, $0-0
    64  	MOVD fn+0(FP), R6
    65  	MOVD a1+8(FP), R0
    66  	MOVD a2+16(FP), R1
    67  	MOVD a3+24(FP), R2
    68  	MOVD a4+32(FP), R3
    69  	MOVD a5+40(FP), R4
    70  	CALL R6
    71  	MOVD R0, ret+48(FP)
    72  	RET