Text file src/runtime/cgo/gcc_riscv64.S

     1  // Copyright 2020 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  /*
     6   * void crosscall1(void (*fn)(void), void (*setg_gcc)(void *g), void *g)
     7   *
     8   * Calling into the gc tool chain, where all registers are caller save.
     9   * Called from standard RISCV ELF psABI, where x8-x9, x18-x27, f8-f9 and
    10   * f18-f27 are callee-save, so they must be saved explicitly, along with
    11   * x1 (LR).
    12   */
    13  .globl crosscall1
    14  crosscall1:
    15  	sd	x1, -200(sp)
    16  	addi	sp, sp, -200
    17  	sd	x8, 8(sp)
    18  	sd	x9, 16(sp)
    19  	sd	x18, 24(sp)
    20  	sd	x19, 32(sp)
    21  	sd	x20, 40(sp)
    22  	sd	x21, 48(sp)
    23  	sd	x22, 56(sp)
    24  	sd	x23, 64(sp)
    25  	sd	x24, 72(sp)
    26  	sd	x25, 80(sp)
    27  	sd	x26, 88(sp)
    28  	sd	x27, 96(sp)
    29  	fsd	f8, 104(sp)
    30  	fsd	f9, 112(sp)
    31  	fsd	f18, 120(sp)
    32  	fsd	f19, 128(sp)
    33  	fsd	f20, 136(sp)
    34  	fsd	f21, 144(sp)
    35  	fsd	f22, 152(sp)
    36  	fsd	f23, 160(sp)
    37  	fsd	f24, 168(sp)
    38  	fsd	f25, 176(sp)
    39  	fsd	f26, 184(sp)
    40  	fsd	f27, 192(sp)
    41  
    42  	// a0 = *fn, a1 = *setg_gcc, a2 = *g
    43  	mv	s1, a0
    44  	mv	s0, a1
    45  	mv	a0, a2
    46  	jalr	ra, s0	// call setg_gcc (clobbers x30 aka g)
    47  	jalr	ra, s1	// call fn
    48  
    49  	ld	x1, 0(sp)
    50  	ld	x8, 8(sp)
    51  	ld	x9, 16(sp)
    52  	ld	x18, 24(sp)
    53  	ld	x19, 32(sp)
    54  	ld	x20, 40(sp)
    55  	ld	x21, 48(sp)
    56  	ld	x22, 56(sp)
    57  	ld	x23, 64(sp)
    58  	ld	x24, 72(sp)
    59  	ld	x25, 80(sp)
    60  	ld	x26, 88(sp)
    61  	ld	x27, 96(sp)
    62  	fld	f8, 104(sp)
    63  	fld	f9, 112(sp)
    64  	fld	f18, 120(sp)
    65  	fld	f19, 128(sp)
    66  	fld	f20, 136(sp)
    67  	fld	f21, 144(sp)
    68  	fld	f22, 152(sp)
    69  	fld	f23, 160(sp)
    70  	fld	f24, 168(sp)
    71  	fld	f25, 176(sp)
    72  	fld	f26, 184(sp)
    73  	fld	f27, 192(sp)
    74  	addi	sp, sp, 200
    75  
    76  	jr	ra
    77  
    78  #ifdef __ELF__
    79  .section .note.GNU-stack,"",%progbits
    80  #endif
    81  

View as plain text