github.com/4ad/go@v0.0.0-20161219182952-69a12818b605/src/runtime/tls_sparc64.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 "go_asm.h"
     6  #include "funcdata.h"
     7  #include "textflag.h"
     8  #include "asm_sparc64.h"
     9  
    10  // save_g saves the g register into pthread-provided
    11  // thread-local memory, so that we can call externally compiled
    12  // sparc64 code that will overwrite this register.
    13  //
    14  // If !iscgo, this is a no-op.
    15  //
    16  // NOTE: setg_gcc<> assume this clobbers only RT1.
    17  TEXT runtime·save_g(SB),NOSPLIT|NOFRAME,$0-0
    18  // On Solaris we always use TLS, even without cgo.
    19  #ifndef GOOS_solaris
    20  	MOVB	runtime·iscgo(SB), RT1
    21  	CMP	RT1, ZR
    22  	BEW	nocgo
    23  #endif
    24  
    25  	MOVD	$runtime·tls_g(SB), RT1
    26  	MOVD	g, (RT1)
    27  nocgo:
    28  	RET
    29  
    30  // load_g loads the g register from pthread-provided
    31  // thread-local memory, for use after calling externally compiled
    32  // sparc64 code that overwrote those registers.
    33  //
    34  // This is never called directly from C code (it doesn't have to
    35  // follow the C ABI), but it may be called from a C context, where the
    36  // usual Go registers aren't set up.
    37  //
    38  // NOTE: _cgo_topofstack assumes this only clobbers g, and RT1.
    39  TEXT runtime·load_g(SB),NOSPLIT|NOFRAME,$0-0
    40  // On Solaris we always use TLS, even without cgo.
    41  #ifndef GOOS_solaris
    42  	MOVB	runtime·iscgo(SB), RT1
    43  	CMP	RT1, ZR
    44  	BEW	nocgo
    45  #endif
    46  
    47  	MOVD	$runtime·tls_g(SB), RT1
    48  	MOVD	(RT1), g
    49  nocgo:
    50  	RET
    51  
    52  TEXT runtime·do_cgo_init(SB),NOSPLIT,$0-0
    53  	// if there is a _cgo_init, call it using the gcc ABI.
    54  	MOVD	_cgo_init(SB), O4
    55  	CMP	ZR, O4
    56  	BED	nocgo
    57  
    58  	MOVD	TLS, O3			// arg 3: TLS base pointer
    59  	MOVD	$runtime·tls_g(SB), O2 	// arg 2: &tls_g
    60  	MOVD	$setg_gcc<>(SB), O1	// arg 1: setg
    61  	MOVD	g, O0			// arg 0: G
    62  	CALL	(O4)
    63  	MOVD	$runtime·g0(SB), g
    64  nocgo:
    65  	RET
    66  
    67  // void setg_gcc(G*); set g called from gcc
    68  TEXT setg_gcc<>(SB),NOSPLIT,$16
    69  	MOVD	O0, g
    70  	MOVD	RT1, savedRT1-8(SP)
    71  	CALL	runtime·save_g(SB)
    72  	MOVD	savedRT1-8(SP), RT1
    73  	RET
    74  
    75  GLOBL runtime·tls_g+0(SB), TLSBSS, $8