Black Lives Matter. Support the Equal Justice Initiative.

Text file src/runtime/cgo/asm_mipsx.s

Documentation: runtime/cgo

     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  //go:build mips || mipsle
     6  // +build mips mipsle
     7  
     8  #include "textflag.h"
     9  
    10  // Called by C code generated by cmd/cgo.
    11  // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
    12  // Saves C callee-saved registers and calls cgocallback with three arguments.
    13  // fn is the PC of a func(a unsafe.Pointer) function.
    14  TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
    15  	/*
    16  	 * We still need to save all callee save register as before, and then
    17  	 *  push 3 args for fn (R4, R5, R7), skipping R6.
    18  	 * Also note that at procedure entry in gc world, 4(R29) will be the
    19  	 *  first arg.
    20  	 */
    21  
    22  	// Space for 9 caller-saved GPR + LR + 6 caller-saved FPR.
    23  	// O32 ABI allows us to smash 16 bytes argument area of caller frame.
    24  #ifndef GOMIPS_softfloat
    25  	SUBU	$(4*14+8*6-16), R29
    26  #else
    27  	SUBU	$(4*14-16), R29	// For soft-float, no FPR.
    28  #endif
    29  	MOVW	R4, (4*1)(R29)	// fn unsafe.Pointer
    30  	MOVW	R5, (4*2)(R29)	// a unsafe.Pointer
    31  	MOVW	R7, (4*3)(R29)	// ctxt uintptr
    32  	MOVW	R16, (4*4)(R29)
    33  	MOVW	R17, (4*5)(R29)
    34  	MOVW	R18, (4*6)(R29)
    35  	MOVW	R19, (4*7)(R29)
    36  	MOVW	R20, (4*8)(R29)
    37  	MOVW	R21, (4*9)(R29)
    38  	MOVW	R22, (4*10)(R29)
    39  	MOVW	R23, (4*11)(R29)
    40  	MOVW	g, (4*12)(R29)
    41  	MOVW	R31, (4*13)(R29)
    42  #ifndef GOMIPS_softfloat
    43  	MOVD	F20, (4*14)(R29)
    44  	MOVD	F22, (4*14+8*1)(R29)
    45  	MOVD	F24, (4*14+8*2)(R29)
    46  	MOVD	F26, (4*14+8*3)(R29)
    47  	MOVD	F28, (4*14+8*4)(R29)
    48  	MOVD	F30, (4*14+8*5)(R29)
    49  #endif
    50  	JAL	runtimeĀ·load_g(SB)
    51  
    52  	JAL	runtimeĀ·cgocallback(SB)
    53  
    54  	MOVW	(4*4)(R29), R16
    55  	MOVW	(4*5)(R29), R17
    56  	MOVW	(4*6)(R29), R18
    57  	MOVW	(4*7)(R29), R19
    58  	MOVW	(4*8)(R29), R20
    59  	MOVW	(4*9)(R29), R21
    60  	MOVW	(4*10)(R29), R22
    61  	MOVW	(4*11)(R29), R23
    62  	MOVW	(4*12)(R29), g
    63  	MOVW	(4*13)(R29), R31
    64  #ifndef GOMIPS_softfloat
    65  	MOVD	(4*14)(R29), F20
    66  	MOVD	(4*14+8*1)(R29), F22
    67  	MOVD	(4*14+8*2)(R29), F24
    68  	MOVD	(4*14+8*3)(R29), F26
    69  	MOVD	(4*14+8*4)(R29), F28
    70  	MOVD	(4*14+8*5)(R29), F30
    71  
    72  	ADDU	$(4*14+8*6-16), R29
    73  #else
    74  	ADDU	$(4*14-16), R29
    75  #endif
    76  	RET
    77  

View as plain text