github.com/c0deoo1/golang1.5@v0.0.0-20220525150107-c87c805d4593/src/runtime/tls_arm64.s (about)

     1  // Copyright 2015 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 "go_tls.h"
     7  #include "funcdata.h"
     8  #include "textflag.h"
     9  #include "tls_arm64.h"
    10  
    11  TEXT runtime·load_g(SB),NOSPLIT,$0
    12  	MOVB	runtime·iscgo(SB), R0
    13  	CMP	$0, R0
    14  	BEQ	nocgo
    15  
    16  	MRS_TPIDR_R0
    17  #ifdef GOOS_darwin
    18  	// Darwin sometimes returns unaligned pointers
    19  	AND	$0xfffffffffffffff8, R0
    20  #endif
    21  #ifdef TLSG_IS_VARIABLE
    22  	MOVD	runtime·tls_g(SB), R27
    23  	ADD	R27, R0
    24  #else
    25  	// TODO(minux): use real TLS relocation, instead of hard-code for Linux
    26  	ADD	$0x10, R0
    27  #endif
    28  	MOVD	0(R0), g
    29  
    30  nocgo:
    31  	RET
    32  
    33  TEXT runtime·save_g(SB),NOSPLIT,$0
    34  	MOVB	runtime·iscgo(SB), R0
    35  	CMP	$0, R0
    36  	BEQ	nocgo
    37  
    38  	MRS_TPIDR_R0
    39  #ifdef GOOS_darwin
    40  	// Darwin sometimes returns unaligned pointers
    41  	AND	$0xfffffffffffffff8, R0
    42  #endif
    43  #ifdef TLSG_IS_VARIABLE
    44  	MOVD	runtime·tls_g(SB), R27
    45  	ADD	R27, R0
    46  #else
    47  	// TODO(minux): use real TLS relocation, instead of hard-code for Linux
    48  	ADD	$0x10, R0
    49  #endif
    50  	MOVD	g, 0(R0)
    51  
    52  nocgo:
    53  	RET
    54  
    55  #ifdef TLSG_IS_VARIABLE
    56  // The runtime.tlsg name is being handled specially in the
    57  // linker. As we just need a regular variable here, don't
    58  // use that name.
    59  GLOBL runtime·tls_g+0(SB), NOPTR, $8
    60  #endif