Home | History | Annotate | Download | only in runtime
      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 runtimeload_g(SB),NOSPLIT,$0
     12 	MOVB	runtimeiscgo(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	runtimetls_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 runtimesave_g(SB),NOSPLIT,$0
     34 	MOVB	runtimeiscgo(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	runtimetls_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 runtimetls_g+0(SB), NOPTR, $8
     60 #endif
     61