...

Text file src/runtime/cgo/asm_mips64x.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 mips64 || mips64le
     6
     7#include "textflag.h"
     8
     9// Set the x_crosscall2_ptr C function pointer variable point to crosscall2.
    10// It's such a pointer chain: _crosscall2_ptr -> x_crosscall2_ptr -> crosscall2
    11// Use a local trampoline, to avoid taking the address of a dynamically exported
    12// function.
    13TEXT ·set_crosscall2(SB),NOSPLIT,$0-0
    14	MOVV	_crosscall2_ptr(SB), R5
    15	MOVV	$crosscall2_trampoline<>(SB), R6
    16	MOVV	R6, (R5)
    17	RET
    18
    19TEXT crosscall2_trampoline<>(SB),NOSPLIT,$0-0
    20	JMP	crosscall2(SB)
    21
    22// Called by C code generated by cmd/cgo.
    23// func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
    24// Saves C callee-saved registers and calls cgocallback with three arguments.
    25// fn is the PC of a func(a unsafe.Pointer) function.
    26TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
    27	/*
    28	 * We still need to save all callee save register as before, and then
    29	 *  push 3 args for fn (R4, R5, R7), skipping R6.
    30	 * Also note that at procedure entry in gc world, 8(R29) will be the
    31	 *  first arg.
    32	 */
    33#ifndef GOMIPS64_softfloat
    34	ADDV	$(-8*23), R29
    35#else
    36	ADDV	$(-8*15), R29
    37#endif
    38	MOVV	R4, (8*1)(R29) // fn unsafe.Pointer
    39	MOVV	R5, (8*2)(R29) // a unsafe.Pointer
    40	MOVV	R7, (8*3)(R29) // ctxt uintptr
    41	MOVV	R16, (8*4)(R29)
    42	MOVV	R17, (8*5)(R29)
    43	MOVV	R18, (8*6)(R29)
    44	MOVV	R19, (8*7)(R29)
    45	MOVV	R20, (8*8)(R29)
    46	MOVV	R21, (8*9)(R29)
    47	MOVV	R22, (8*10)(R29)
    48	MOVV	R23, (8*11)(R29)
    49	MOVV	RSB, (8*12)(R29)
    50	MOVV	g, (8*13)(R29)
    51	MOVV	R31, (8*14)(R29)
    52#ifndef GOMIPS64_softfloat
    53	MOVD	F24, (8*15)(R29)
    54	MOVD	F25, (8*16)(R29)
    55	MOVD	F26, (8*17)(R29)
    56	MOVD	F27, (8*18)(R29)
    57	MOVD	F28, (8*19)(R29)
    58	MOVD	F29, (8*20)(R29)
    59	MOVD	F30, (8*21)(R29)
    60	MOVD	F31, (8*22)(R29)
    61#endif
    62	// Initialize Go ABI environment
    63	// prepare SB register = PC & 0xffffffff00000000
    64	BGEZAL	R0, 1(PC)
    65	SRLV	$32, R31, RSB
    66	SLLV	$32, RSB
    67	JAL	runtime·load_g(SB)
    68
    69	JAL	runtime·cgocallback(SB)
    70
    71	MOVV	(8*4)(R29), R16
    72	MOVV	(8*5)(R29), R17
    73	MOVV	(8*6)(R29), R18
    74	MOVV	(8*7)(R29), R19
    75	MOVV	(8*8)(R29), R20
    76	MOVV	(8*9)(R29), R21
    77	MOVV	(8*10)(R29), R22
    78	MOVV	(8*11)(R29), R23
    79	MOVV	(8*12)(R29), RSB
    80	MOVV	(8*13)(R29), g
    81	MOVV	(8*14)(R29), R31
    82#ifndef GOMIPS64_softfloat
    83	MOVD	(8*15)(R29), F24
    84	MOVD	(8*16)(R29), F25
    85	MOVD	(8*17)(R29), F26
    86	MOVD	(8*18)(R29), F27
    87	MOVD	(8*19)(R29), F28
    88	MOVD	(8*20)(R29), F29
    89	MOVD	(8*21)(R29), F30
    90	MOVD	(8*22)(R29), F31
    91	ADDV	$(8*23), R29
    92#else
    93	ADDV	$(8*15), R29
    94#endif
    95	RET

View as plain text