aboutsummaryrefslogtreecommitdiff
path: root/src/internal/runtime/atomic
diff options
context:
space:
mode:
authorPaul E. Murphy <murp@ibm.com>2024-10-02 13:31:37 -0500
committerPaul Murphy <murp@ibm.com>2024-10-07 19:20:23 +0000
commit15618840f6d416cc9da34505a5ea5190ff15c3aa (patch)
tree40f8c2e4a160efe1977d5a8aef6e4f2a7c71a1bf /src/internal/runtime/atomic
parent604eaa175bfaadfb868d6add76325020b6e13048 (diff)
downloadgo-15618840f6d416cc9da34505a5ea5190ff15c3aa.tar.xz
cmd/compile: add internal/runtime/atomic.Xchg8 intrinsic for PPC64
This is minor extension of the existing support for 32 and 64 bit types. For #69735 Change-Id: I6828ec223951d2b692e077dc507b000ac23c32a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/617496 Reviewed-by: Rhys Hiltner <rhys.hiltner@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/internal/runtime/atomic')
-rw-r--r--src/internal/runtime/atomic/atomic_ppc64x.go3
-rw-r--r--src/internal/runtime/atomic/atomic_ppc64x.s16
-rw-r--r--src/internal/runtime/atomic/xchg8_test.go2
3 files changed, 20 insertions, 1 deletions
diff --git a/src/internal/runtime/atomic/atomic_ppc64x.go b/src/internal/runtime/atomic/atomic_ppc64x.go
index 33a92b53f4..590ba03ecf 100644
--- a/src/internal/runtime/atomic/atomic_ppc64x.go
+++ b/src/internal/runtime/atomic/atomic_ppc64x.go
@@ -18,6 +18,9 @@ func Xadd64(ptr *uint64, delta int64) uint64
func Xadduintptr(ptr *uintptr, delta uintptr) uintptr
//go:noescape
+func Xchg8(ptr *uint8, new uint8) uint8
+
+//go:noescape
func Xchg(ptr *uint32, new uint32) uint32
//go:noescape
diff --git a/src/internal/runtime/atomic/atomic_ppc64x.s b/src/internal/runtime/atomic/atomic_ppc64x.s
index 75635b933d..184a30c970 100644
--- a/src/internal/runtime/atomic/atomic_ppc64x.s
+++ b/src/internal/runtime/atomic/atomic_ppc64x.s
@@ -236,6 +236,22 @@ TEXT ·Xadd64(SB), NOSPLIT, $0-24
MOVD R3, ret+16(FP)
RET
+// uint8 Xchg(ptr *uint8, new uint8)
+// Atomically:
+// old := *ptr;
+// *ptr = new;
+// return old;
+TEXT ·Xchg8(SB), NOSPLIT, $0-17
+ MOVD ptr+0(FP), R4
+ MOVB new+8(FP), R5
+ LWSYNC
+ LBAR (R4), R3
+ STBCCC R5, (R4)
+ BNE -2(PC)
+ ISYNC
+ MOVB R3, ret+16(FP)
+ RET
+
// uint32 Xchg(ptr *uint32, new uint32)
// Atomically:
// old := *ptr;
diff --git a/src/internal/runtime/atomic/xchg8_test.go b/src/internal/runtime/atomic/xchg8_test.go
index 139062422e..b0b39c2dd7 100644
--- a/src/internal/runtime/atomic/xchg8_test.go
+++ b/src/internal/runtime/atomic/xchg8_test.go
@@ -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 amd64
+//go:build amd64 || ppc64 || ppc64le
package atomic_test