Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime/internal/atomic: add loong64 operators for And/Or #63314

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/runtime/internal/atomic/atomic_andor_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build arm || s390x || loong64 || mips || mipsle || mips64 || mips64le || wasm
//go:build arm || s390x || mips || mipsle || mips64 || mips64le || wasm

package atomic

Expand Down
18 changes: 18 additions & 0 deletions src/runtime/internal/atomic/atomic_loong64.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ func Or8(ptr *uint8, val uint8)
//go:noescape
func Or(ptr *uint32, val uint32)

//go:noescape
func And32(ptr *uint32, val uint32) uint32

//go:noescape
func Or32(ptr *uint32, val uint32) uint32

//go:noescape
func And64(ptr *uint64, val uint64) uint64

//go:noescape
func Or64(ptr *uint64, val uint64) uint64

//go:noescape
func Anduintptr(ptr *uintptr, val uintptr) uintptr

//go:noescape
func Oruintptr(ptr *uintptr, val uintptr) uintptr

// NOTE: Do not add atomicxor8 (XOR is not idempotent).

//go:noescape
Expand Down
60 changes: 60 additions & 0 deletions src/runtime/internal/atomic/atomic_loong64.s
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,66 @@ TEXT ·And(SB), NOSPLIT, $0-12
DBAR
RET

// func Or32(addr *uint32, v uint32) old uint32
TEXT ·Or32(SB), NOSPLIT, $0-20
MOVV ptr+0(FP), R4
MOVW val+8(FP), R5
DBAR
LL (R4), R6
OR R5, R6, R7
SC R7, (R4)
BEQ R7, -4(PC)
DBAR
MOVW R6, ret+16(FP)
RET

// func And32(addr *uint32, v uint32) old uint32
TEXT ·And32(SB), NOSPLIT, $0-20
MOVV ptr+0(FP), R4
MOVW val+8(FP), R5
DBAR
LL (R4), R6
AND R5, R6, R7
SC R7, (R4)
BEQ R7, -4(PC)
DBAR
MOVW R6, ret+16(FP)
RET

// func Or64(addr *uint64, v uint64) old uint64
TEXT ·Or64(SB), NOSPLIT, $0-24
MOVV ptr+0(FP), R4
MOVV val+8(FP), R5
DBAR
LLV (R4), R6
OR R5, R6, R7
SCV R7, (R4)
BEQ R7, -4(PC)
DBAR
MOVV R6, ret+16(FP)
RET

// func And64(addr *uint64, v uint64) old uint64
TEXT ·And64(SB), NOSPLIT, $0-24
MOVV ptr+0(FP), R4
MOVV val+8(FP), R5
DBAR
LLV (R4), R6
AND R5, R6, R7
SCV R7, (R4)
BEQ R7, -4(PC)
DBAR
MOVV R6, ret+16(FP)
RET

// func Anduintptr(addr *uintptr, v uintptr) old uintptr
TEXT ·Anduintptr(SB), NOSPLIT, $0-24
JMP ·And64(SB)

// func Oruintptr(addr *uintptr, v uintptr) old uintptr
TEXT ·Oruintptr(SB), NOSPLIT, $0-24
JMP ·Or64(SB)

// uint32 runtime∕internal∕atomic·Load(uint32 volatile* ptr)
TEXT ·Load(SB),NOSPLIT|NOFRAME,$0-12
MOVV ptr+0(FP), R19
Expand Down