Skip to content

Commit

Permalink
Support more arch with gohack library
Browse files Browse the repository at this point in the history
  • Loading branch information
timandy committed Nov 18, 2022
1 parent e5b4772 commit b7e8a67
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 0 deletions.
28 changes: 28 additions & 0 deletions g/asm_loong64.s
@@ -0,0 +1,28 @@
// Copyright 2022 TimAndy. All rights reserved.
// Licensed under the Apache-2.0 license that can be found in the LICENSE file.

//go:build loong64
// +build loong64

#include "funcdata.h"
#include "go_asm.h"
#include "textflag.h"

TEXT ·getgp(SB), NOSPLIT, $0-8
MOVV g, R8
MOVV R8, ret+0(FP)
RET

TEXT ·getg0(SB), NOSPLIT, $0-16
NO_LOCAL_POINTERS
MOVV $0, ret_type+0(FP)
MOVV $0, ret_data+8(FP)
GO_RESULTS_INITIALIZED
//get runtime.g type
MOVV $type·runtime·g(SB), R8
//get runtime·g0 variable
MOVV $runtime·g0(SB), R9
//return interface{}
MOVV R8, ret_type+0(FP)
MOVV R9, ret_data+8(FP)
RET
28 changes: 28 additions & 0 deletions g/asm_mips64x.s
@@ -0,0 +1,28 @@
// Copyright 2022 TimAndy. All rights reserved.
// Licensed under the Apache-2.0 license that can be found in the LICENSE file.

//go:build mips64 || mips64le
// +build mips64 mips64le

#include "funcdata.h"
#include "go_asm.h"
#include "textflag.h"

TEXT ·getgp(SB), NOSPLIT, $0-8
MOVV g, R8
MOVV R8, ret+0(FP)
RET

TEXT ·getg0(SB), NOSPLIT, $0-16
NO_LOCAL_POINTERS
MOVV $0, ret_type+0(FP)
MOVV $0, ret_data+8(FP)
GO_RESULTS_INITIALIZED
//get runtime.g type
MOVV $type·runtime·g(SB), R8
//get runtime·g0 variable
MOVV $runtime·g0(SB), R9
//return interface{}
MOVV R8, ret_type+0(FP)
MOVV R9, ret_data+8(FP)
RET
28 changes: 28 additions & 0 deletions g/asm_mipsx.s
@@ -0,0 +1,28 @@
// Copyright 2022 TimAndy. All rights reserved.
// Licensed under the Apache-2.0 license that can be found in the LICENSE file.

//go:build mips || mipsle
// +build mips mipsle

#include "funcdata.h"
#include "go_asm.h"
#include "textflag.h"

TEXT ·getgp(SB), NOSPLIT, $0-4
MOVW g, R8
MOVW R8, ret+0(FP)
RET

TEXT ·getg0(SB), NOSPLIT, $0-8
NO_LOCAL_POINTERS
MOVW $0, ret_type+0(FP)
MOVW $0, ret_data+4(FP)
GO_RESULTS_INITIALIZED
//get runtime.g type
MOVW $type·runtime·g(SB), R8
//get runtime·g0 variable
MOVW $runtime·g0(SB), R9
//return interface{}
MOVW R8, ret_type+0(FP)
MOVW R9, ret_data+4(FP)
RET
3 changes: 3 additions & 0 deletions g/asm_ppc64x.s
@@ -1,6 +1,9 @@
// Copyright 2022 TimAndy. All rights reserved.
// Licensed under the Apache-2.0 license that can be found in the LICENSE file.

//go:build ppc64 || ppc64le
// +build ppc64 ppc64le

#include "funcdata.h"
#include "go_asm.h"
#include "textflag.h"
Expand Down
25 changes: 25 additions & 0 deletions g/asm_riscv64.s
@@ -0,0 +1,25 @@
// Copyright 2022 TimAndy. All rights reserved.
// Licensed under the Apache-2.0 license that can be found in the LICENSE file.

#include "funcdata.h"
#include "go_asm.h"
#include "textflag.h"

TEXT ·getgp(SB), NOSPLIT, $0-8
MOV g, X10
MOV X10, ret+0(FP)
RET

TEXT ·getg0(SB), NOSPLIT, $0-16
NO_LOCAL_POINTERS
MOV X10, ret_type+0(FP)
MOV X11, ret_data+8(FP)
GO_RESULTS_INITIALIZED
//get runtime.g type
MOV $type·runtime·g(SB), X10
//get runtime·g0 variable
MOV $runtime·g0(SB), X11
//return interface{}
MOV X10, ret_type+0(FP)
MOV X11, ret_data+8(FP)
RET
25 changes: 25 additions & 0 deletions g/asm_wasm.s
@@ -0,0 +1,25 @@
// Copyright 2022 TimAndy. All rights reserved.
// Licensed under the Apache-2.0 license that can be found in the LICENSE file.

#include "funcdata.h"
#include "go_asm.h"
#include "textflag.h"

TEXT ·getgp(SB), NOSPLIT, $0-8
MOVD g, R8
MOVD R8, ret+0(FP)
RET

TEXT ·getg0(SB), NOSPLIT, $0-16
NO_LOCAL_POINTERS
MOVD $0, ret_type+0(FP)
MOVD $0, ret_data+8(FP)
GO_RESULTS_INITIALIZED
//get runtime.g type
MOVD $type·runtime·g(SB), R8
//get runtime·g0 variable
MOVD $runtime·g0(SB), R9
//return interface{}
MOVD R8, ret_type+0(FP)
MOVD R9, ret_data+8(FP)
RET

0 comments on commit b7e8a67

Please sign in to comment.