Skip to content

Commit

Permalink
enable arm64 encode
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Nov 3, 2023
1 parent f38b467 commit 813b4c8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
## 致谢
本项目的大部分纯Go代码源自 [golang base64](https://github.com/golang/go/tree/master/src/encoding/base64),本包的使用和Go语言的base64完全相同。

AMD64架构的SIMD实现 (特别是SSE版本)算法源自 [aklomp/base64](https://github.com/aklomp/base64)
AMD64架构(特别是SSE版本)和ARM64架构的SIMD实现算法源自 [aklomp/base64](https://github.com/aklomp/base64)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Base64 with SIMD acceleration
## Acknowledgements
This is an extension of [golang base64](https://github.com/golang/go/tree/master/src/encoding/base64).

The amd64 SIMD implementation (especially SSE version) is inspired by code from [aklomp/base64](https://github.com/aklomp/base64).
The amd64 (especially SSE version) / arm64 SIMD implementation are inspired by code from [aklomp/base64](https://github.com/aklomp/base64).
13 changes: 13 additions & 0 deletions base64_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,16 @@ package base64

//go:noescape
func encodeAsm(dst, src []byte, lut *[64]byte) int

func encode(enc *Encoding, dst, src []byte) {
if len(src) >= 48 {
encoded := encodeAsm(dst, src, &enc.encode)
src = src[(encoded/4)*3:]
dst = dst[encoded:]
}
encodeGeneric(enc, dst, src)
}

func decode(enc *Encoding, dst, src []byte) (int, error) {
return decodeGeneric(enc, dst, src)
}
6 changes: 3 additions & 3 deletions base64_generic.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !amd64 || purego
// +build !amd64 purego
//go:build !amd64 && !arm64 || purego
// +build !amd64,!arm64 purego

package base64

Expand All @@ -9,4 +9,4 @@ func encode(enc *Encoding, dst, src []byte) {

func decode(enc *Encoding, dst, src []byte) (int, error) {
return decodeGeneric(enc, dst, src)
}
}

0 comments on commit 813b4c8

Please sign in to comment.