Text file src/runtime/cgo/gcc_s390x.S

     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  .file "gcc_s390x.S"
     6  
     7  /*
     8   * void crosscall1(void (*fn)(void), void (*setg_gcc)(void*), void *g)
     9   *
    10   * Calling into the go tool chain, where all registers are caller save.
    11   * Called from standard s390x C ABI, where r6-r13, r15, and f8-f15 are
    12   * callee-save, so they must be saved explicitly.
    13   * ABI: r2=fn, r3=setg_gcc, r4=g.
    14   */
    15  .globl crosscall1
    16  crosscall1:
    17  	/* save r6-r15 in the register save area of the calling function */
    18  	stmg    %r6, %r15, 48(%r15)
    19  
    20  	/* allocate 64 bytes of stack space to save f8-f15 */
    21  	lay     %r15, -64(%r15)
    22  
    23  	/* save callee-saved floating point registers */
    24  	std     %f8, 0(%r15)
    25  	std     %f9, 8(%r15)
    26  	std     %f10, 16(%r15)
    27  	std     %f11, 24(%r15)
    28  	std     %f12, 32(%r15)
    29  	std     %f13, 40(%r15)
    30  	std     %f14, 48(%r15)
    31  	std     %f15, 56(%r15)
    32  
    33  	/* save fn pointer in r6 (already saved to stack) */
    34  	lgr     %r6, %r2
    35  	/* restore g pointer */
    36  	lgr     %r13, %r4
    37  
    38  	/* prepare arg for setg_gcc: first argument in r2 */
    39  	lgr     %r2, %r4      /* r2 = g */
    40  	/* call setg_gcc(g) using function pointer in r3 */
    41  	basr    %r14, %r3
    42  
    43  	/* call fn */
    44  	lgr     %r2, %r6
    45  	basr    %r14, %r2
    46  
    47  	/* restore floating point registers */
    48  	ld      %f8, 0(%r15)
    49  	ld      %f9, 8(%r15)
    50  	ld      %f10, 16(%r15)
    51  	ld      %f11, 24(%r15)
    52  	ld      %f12, 32(%r15)
    53  	ld      %f13, 40(%r15)
    54  	ld      %f14, 48(%r15)
    55  	ld      %f15, 56(%r15)
    56  
    57  	/* de-allocate stack frame */
    58  	la      %r15, 64(%r15)
    59  
    60  	/* restore general purpose registers */
    61  	lmg     %r6, %r15, 48(%r15)
    62  
    63  	br      %r14 /* restored by lmg */
    64  
    65  #ifdef __ELF__
    66  .section .note.GNU-stack,"",%progbits
    67  #endif
    68  

View as plain text