Skip to content

Commit 1a8ee03

Browse files
mauri870randall77
authored andcommitted
runtime/internal/atomic: add s390x operators for And/Or
These primitives will be used by the new And/Or sync/atomic apis. For #61395 Change-Id: Ia9b4877048002d3d7d1dffa2311d0ec5f38e4ee5 GitHub-Last-Rev: 20dea11 GitHub-Pull-Request: #63318 Reviewed-on: https://go-review.googlesource.com/c/go/+/531678 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Keith Randall <[email protected]> Run-TryBot: Mauri de Souza Meneguzzo <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent 2908352 commit 1a8ee03

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

src/runtime/internal/atomic/atomic_andor_generic.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build arm || s390x || mips || mipsle || mips64 || mips64le || wasm
5+
//go:build arm || mips || mipsle || mips64 || mips64le || wasm
66

77
package atomic
88

src/runtime/internal/atomic/atomic_s390x.go

+18
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,24 @@ func And(ptr *uint32, val uint32)
9898
//go:noescape
9999
func Or(ptr *uint32, val uint32)
100100

101+
//go:noescape
102+
func And32(ptr *uint32, val uint32) uint32
103+
104+
//go:noescape
105+
func Or32(ptr *uint32, val uint32) uint32
106+
107+
//go:noescape
108+
func And64(ptr *uint64, val uint64) uint64
109+
110+
//go:noescape
111+
func Or64(ptr *uint64, val uint64) uint64
112+
113+
//go:noescape
114+
func Anduintptr(ptr *uintptr, val uintptr) uintptr
115+
116+
//go:noescape
117+
func Oruintptr(ptr *uintptr, val uintptr) uintptr
118+
101119
//go:noescape
102120
func Xadd(ptr *uint32, delta int32) uint32
103121

src/runtime/internal/atomic/atomic_s390x.s

+56
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,59 @@ TEXT ·And(SB), NOSPLIT, $0-12
246246
MOVW val+8(FP), R4
247247
LAN R4, R6, 0(R3) // R6 = *R3; *R3 &= R4; (atomic)
248248
RET
249+
250+
// func Or32(addr *uint32, v uint32) old uint32
251+
TEXT ·Or32(SB), NOSPLIT, $0-20
252+
MOVD ptr+0(FP), R4
253+
MOVW val+8(FP), R5
254+
MOVW (R4), R3
255+
repeat:
256+
OR R5, R3, R6
257+
CS R3, R6, (R4) // if R3==(R4) then (R4)=R6 else R3=(R4)
258+
BNE repeat
259+
MOVW R3, ret+16(FP)
260+
RET
261+
262+
// func And32(addr *uint32, v uint32) old uint32
263+
TEXT ·And32(SB), NOSPLIT, $0-20
264+
MOVD ptr+0(FP), R4
265+
MOVW val+8(FP), R5
266+
MOVW (R4), R3
267+
repeat:
268+
AND R5, R3, R6
269+
CS R3, R6, (R4) // if R3==(R4) then (R4)=R6 else R3=(R4)
270+
BNE repeat
271+
MOVW R3, ret+16(FP)
272+
RET
273+
274+
// func Or64(addr *uint64, v uint64) old uint64
275+
TEXT ·Or64(SB), NOSPLIT, $0-24
276+
MOVD ptr+0(FP), R4
277+
MOVD val+8(FP), R5
278+
MOVD (R4), R3
279+
repeat:
280+
OR R5, R3, R6
281+
CSG R3, R6, (R4) // if R3==(R4) then (R4)=R6 else R3=(R4)
282+
BNE repeat
283+
MOVD R3, ret+16(FP)
284+
RET
285+
286+
// func And64(addr *uint64, v uint64) old uint64
287+
TEXT ·And64(SB), NOSPLIT, $0-24
288+
MOVD ptr+0(FP), R4
289+
MOVD val+8(FP), R5
290+
MOVD (R4), R3
291+
repeat:
292+
AND R5, R3, R6
293+
CSG R3, R6, (R4) // if R3==(R4) then (R4)=R6 else R3=(R4)
294+
BNE repeat
295+
MOVD R3, ret+16(FP)
296+
RET
297+
298+
// func Anduintptr(addr *uintptr, v uintptr) old uintptr
299+
TEXT ·Anduintptr(SB), NOSPLIT, $0-24
300+
BR ·And64(SB)
301+
302+
// func Oruintptr(addr *uintptr, v uintptr) old uintptr
303+
TEXT ·Oruintptr(SB), NOSPLIT, $0-24
304+
BR ·Or64(SB)

0 commit comments

Comments
 (0)