]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/internal/sys: remove Bswap{32|64} assembly for 386
authorWayne Zuo <wdvxdr@golangcn.org>
Mon, 6 Feb 2023 13:27:37 +0000 (21:27 +0800)
committerWayne Zuo <wdvxdr@golangcn.org>
Wed, 8 Feb 2023 03:43:35 +0000 (03:43 +0000)
CL 465515 instrinsify these functions, so that we can remove them.

Change-Id: I81c9eb62ecf56d5a292dc5aced542b36b53847dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/465516
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/internal/sys/intrinsics.go
src/runtime/internal/sys/intrinsics_386.s
src/runtime/internal/sys/intrinsics_common.go
src/runtime/internal/sys/intrinsics_stubs.go

index 902d893178889c1918d4b3ab0195b6a3a2e762c1..b68b3cd93d22fdd7ffe9f29bafeac930e10e08f5 100644 (file)
@@ -76,35 +76,3 @@ func TrailingZeros64(x uint64) int {
 func TrailingZeros8(x uint8) int {
        return int(ntz8tab[x])
 }
-
-// Bswap64 returns its input with byte order reversed
-// 0x0102030405060708 -> 0x0807060504030201
-func Bswap64(x uint64) uint64 {
-       c8 := uint64(0x00ff00ff00ff00ff)
-       a := x >> 8 & c8
-       b := (x & c8) << 8
-       x = a | b
-       c16 := uint64(0x0000ffff0000ffff)
-       a = x >> 16 & c16
-       b = (x & c16) << 16
-       x = a | b
-       c32 := uint64(0x00000000ffffffff)
-       a = x >> 32 & c32
-       b = (x & c32) << 32
-       x = a | b
-       return x
-}
-
-// Bswap32 returns its input with byte order reversed
-// 0x01020304 -> 0x04030201
-func Bswap32(x uint32) uint32 {
-       c8 := uint32(0x00ff00ff)
-       a := x >> 8 & c8
-       b := (x & c8) << 8
-       x = a | b
-       c16 := uint32(0x0000ffff)
-       a = x >> 16 & c16
-       b = (x & c16) << 16
-       x = a | b
-       return x
-}
index f33ade0a3abf528e05a7ee63b19e1f78c367235c..fe4c561b99f3ae2515367445c7ef0c7a8ea2a0bd 100644 (file)
@@ -41,18 +41,3 @@ TEXT runtime∕internal∕sys·TrailingZeros8(SB), NOSPLIT, $0-8
        MOVL    $8, AX
        MOVL    AX, ret+4(FP)
        RET
-
-TEXT runtime∕internal∕sys·Bswap64(SB), NOSPLIT, $0-16
-       MOVL    x_lo+0(FP), AX
-       MOVL    x_hi+4(FP), BX
-       BSWAPL  AX
-       BSWAPL  BX
-       MOVL    BX, ret_lo+8(FP)
-       MOVL    AX, ret_hi+12(FP)
-       RET
-
-TEXT runtime∕internal∕sys·Bswap32(SB), NOSPLIT, $0-8
-       MOVL    x+0(FP), AX
-       BSWAPL  AX
-       MOVL    AX, ret+4(FP)
-       RET
index 1461551dda6e73c94ec1a29228a029e992571747..78ba44485b8b15b0ac782d0a0cc24446f14f4c10 100644 (file)
@@ -93,6 +93,38 @@ func Len8(x uint8) int {
        return int(len8tab[x])
 }
 
+// Bswap64 returns its input with byte order reversed
+// 0x0102030405060708 -> 0x0807060504030201
+func Bswap64(x uint64) uint64 {
+       c8 := uint64(0x00ff00ff00ff00ff)
+       a := x >> 8 & c8
+       b := (x & c8) << 8
+       x = a | b
+       c16 := uint64(0x0000ffff0000ffff)
+       a = x >> 16 & c16
+       b = (x & c16) << 16
+       x = a | b
+       c32 := uint64(0x00000000ffffffff)
+       a = x >> 32 & c32
+       b = (x & c32) << 32
+       x = a | b
+       return x
+}
+
+// Bswap32 returns its input with byte order reversed
+// 0x01020304 -> 0x04030201
+func Bswap32(x uint32) uint32 {
+       c8 := uint32(0x00ff00ff)
+       a := x >> 8 & c8
+       b := (x & c8) << 8
+       x = a | b
+       c16 := uint32(0x0000ffff)
+       a = x >> 16 & c16
+       b = (x & c16) << 16
+       x = a | b
+       return x
+}
+
 // Prefetch prefetches data from memory addr to cache
 //
 // AMD64: Produce PREFETCHT0 instruction
index 66cfcded409f2083ceb2280ce345eefad67a0e03..375aac190ac2dea321be970cf68fa9747ca0fd1a 100644 (file)
@@ -9,5 +9,3 @@ package sys
 func TrailingZeros64(x uint64) int
 func TrailingZeros32(x uint32) int
 func TrailingZeros8(x uint8) int
-func Bswap64(x uint64) uint64
-func Bswap32(x uint32) uint32