...
Run Format

Text file src/runtime/cgo/asm_amd64.s

Documentation: runtime/cgo

     1	// Copyright 2009 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 func(a unsafe.Pointer, n int32, ctxt uintptr), a unsafe.Pointer, n int32, ctxt uintptr)
     9	// Saves C callee-saved registers and calls fn with three arguments.
    10	#ifndef GOOS_windows
    11	TEXT crosscall2(SB),NOSPLIT,$0x50-0 /* keeps stack pointer 32-byte aligned */
    12	#else
    13	TEXT crosscall2(SB),NOSPLIT,$0x110-0 /* also need to save xmm6 - xmm15 */
    14	#endif
    15		MOVQ	BX, 0x18(SP)
    16		MOVQ	R12, 0x28(SP)
    17		MOVQ	R13, 0x30(SP)
    18		MOVQ	R14, 0x38(SP)
    19		MOVQ	R15, 0x40(SP)
    20	
    21	#ifdef GOOS_windows
    22		// Win64 save RBX, RBP, RDI, RSI, RSP, R12, R13, R14, R15 and XMM6 -- XMM15.
    23		MOVQ	DI, 0x48(SP)
    24		MOVQ	SI, 0x50(SP)
    25		MOVUPS	X6, 0x60(SP)
    26		MOVUPS	X7, 0x70(SP)
    27		MOVUPS	X8, 0x80(SP)
    28		MOVUPS	X9, 0x90(SP)
    29		MOVUPS	X10, 0xa0(SP)
    30		MOVUPS	X11, 0xb0(SP)
    31		MOVUPS	X12, 0xc0(SP)
    32		MOVUPS	X13, 0xd0(SP)
    33		MOVUPS	X14, 0xe0(SP)
    34		MOVUPS	X15, 0xf0(SP)
    35	
    36		MOVQ	DX, 0x0(SP)	/* arg */
    37		MOVQ	R8, 0x8(SP)	/* argsize (includes padding) */
    38		MOVQ	R9, 0x10(SP)	/* ctxt */
    39		
    40		CALL	CX	/* fn */
    41		
    42		MOVQ	0x48(SP), DI
    43		MOVQ	0x50(SP), SI
    44		MOVUPS	0x60(SP), X6
    45		MOVUPS	0x70(SP), X7
    46		MOVUPS	0x80(SP), X8
    47		MOVUPS	0x90(SP), X9
    48		MOVUPS	0xa0(SP), X10
    49		MOVUPS	0xb0(SP), X11
    50		MOVUPS	0xc0(SP), X12
    51		MOVUPS	0xd0(SP), X13
    52		MOVUPS	0xe0(SP), X14
    53		MOVUPS	0xf0(SP), X15
    54	#else
    55		MOVQ	SI, 0x0(SP)	/* arg */
    56		MOVQ	DX, 0x8(SP)	/* argsize (includes padding) */
    57		MOVQ	CX, 0x10(SP)	/* ctxt */
    58	
    59		CALL	DI	/* fn */
    60	#endif
    61	
    62		MOVQ	0x18(SP), BX
    63		MOVQ	0x28(SP), R12
    64		MOVQ	0x30(SP), R13
    65		MOVQ	0x38(SP), R14
    66		MOVQ	0x40(SP), R15
    67		
    68		RET

View as plain text