Text file src/runtime/cgo/asm_unix_arm64.s

     1  // Copyright 2026 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  //go:build goexperiment.cgobindings && (darwin || (linux && !android)) && arm64
     6  
     7  #include "textflag.h"
     8  #include "abi_arm64.h"
     9  
    10  // callC calls a C function with up to 6 integer/pointer arguments
    11  // in the AAPCS64 C ABI and returns its integer/pointer result.
    12  TEXT ·callC<ABIInternal>(SB),NOSPLIT,$0
    13  	// Convert from Go ABIInternal (R0=fn, R1..R6=a0..a5)
    14  	// to AAPCS64 (fn in R9; args in R0..R5).
    15  	MOVD	R0, R9
    16  	MOVD	R1, R0
    17  	MOVD	R2, R1
    18  	MOVD	R3, R2
    19  	MOVD	R4, R3
    20  	MOVD	R5, R4
    21  	MOVD	R6, R5
    22  	SUB	$16, RSP	// reserve 16 bytes for sp-8 where fp is saved
    23  	BL	(R9)
    24  	ADD	$16, RSP
    25  	RET
    26  

View as plain text