github.com/euank/go@v0.0.0-20160829210321-495514729181/src/runtime/cgo/asm_s390x.s (about)

     1  // Copyright 2016 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  TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
    11  	// Start with standard C stack frame layout and linkage
    12  
    13  	// Save R6-R15, F0, F2, F4 and F6 in the
    14  	// register save area of the calling function
    15  	STMG	R6, R15, 48(R15)
    16  	FMOVD	F0, 128(R15)
    17  	FMOVD	F2, 136(R15)
    18  	FMOVD	F4, 144(R15)
    19  	FMOVD	F6, 152(R15)
    20  
    21  	// Initialize Go ABI environment
    22  	XOR	R0, R0
    23  	BL	runtimeĀ·load_g(SB)
    24  
    25  	// Allocate 32 bytes on the stack
    26  	SUB	$32, R15
    27  
    28  	MOVD	R3, 8(R15)  // arg1
    29  	MOVW	R4, 16(R15) // arg2
    30  	MOVD	R5, 24(R15) // arg3
    31  	BL	(R2)        // fn(arg1, arg2, arg3)
    32  
    33  	ADD	$32, R15
    34  
    35  	// Restore R6-R15, F0, F2, F4 and F6
    36  	LMG	48(R15), R6, R15
    37  	FMOVD	F0, 128(R15)
    38  	FMOVD	F2, 136(R15)
    39  	FMOVD	F4, 144(R15)
    40  	FMOVD	F6, 152(R15)
    41  
    42  	RET
    43