Debian Codegraph @

xor_amd64.go

raw symbols SCIP
1 // Copyright (c) 2019. Temple3x ([email protected])
2 //
3 // Use of this source code is governed by the MIT License
4 // that can be found in the LICENSE file.
5
6 package xorsimd
7
8 import "github.com/templexxx/cpu"
9
10 func encode(dst []byte, src [][]byte) {
11
12 switch cpuFeature {
13 case avx512:
14 encodeAVX512(dst, src)
15 case avx2:
16 encodeAVX2(dst, src)
17 default:
18 encodeSSE2(dst, src)
19 }
20 return
21 }
22
23 func getCPUFeature() int {
24 if hasAVX512() && EnableAVX512 {
25 return avx512
26 } else if cpu.X86.HasAVX2 {
27 return avx2
28 } else {
29 return sse2 // amd64 must have sse2
30 }
31 }
32
33 // Bytes8 XORs exactly 8 bytes from a and b into dst.
34 // Each slice must have length >= 8, otherwise it panics.
35 func Bytes8(dst, a, b []byte) {
36
37 bytes8(&dst[0], &a[0], &b[0])
38 }
39
40 // Bytes16 XORs exactly 16 bytes from a and b into dst.
41 // Each slice must have length >= 16, otherwise it panics.
42 func Bytes16(dst, a, b []byte) {
43
44 bytes16(&dst[0], &a[0], &b[0])
45 }
46
47 // Bytes8Align XORs exactly 8 bytes from a and b into dst.
48 // Each slice must have length >= 8, otherwise it panics.
49 // On amd64, explicit alignment is not required; this function exists for API
50 // compatibility with non-amd64 implementations.
51 func Bytes8Align(dst, a, b []byte) {
52
53 bytes8(&dst[0], &a[0], &b[0])
54 }
55
56 // Bytes16Align XORs exactly 16 bytes from a and b into dst.
57 // Each slice must have length >= 16, otherwise it panics.
58 // On amd64, explicit alignment is not required; this function exists for API
59 // compatibility with non-amd64 implementations.
60 func Bytes16Align(dst, a, b []byte) {
61
62 bytes16(&dst[0], &a[0], &b[0])
63 }
64
65 // BytesA XORs len(a) bytes from a and b into dst.
66 // Callers must ensure len(dst) >= len(a) and len(b) >= len(a).
67 //
68 // This helper is intended for small slices where setup overhead dominates.
69 // For larger slices, Bytes is usually faster.
70 func BytesA(dst, a, b []byte) {
71
72 bytesN(&dst[0], &a[0], &b[0], len(a))
73 }
74
75 // BytesB XORs len(b) bytes from a and b into dst.
76 // Callers must ensure len(dst) >= len(b) and len(a) >= len(b).
77 //
78 // This helper is intended for small slices where setup overhead dominates.
79 // For larger slices, Bytes is usually faster.
80 func BytesB(dst, a, b []byte) {
81
82 bytesN(&dst[0], &a[0], &b[0], len(b))
83 }
84
85 //go:noescape
86 func encodeAVX512(dst []byte, src [][]byte)
87
88 //go:noescape
89 func encodeAVX2(dst []byte, src [][]byte)
90
91 //go:noescape
92 func encodeSSE2(dst []byte, src [][]byte)
93
94 //go:noescape
95 func bytesN(dst, a, b *byte, n int)
96
97 //go:noescape
98 func bytes8(dst, a, b *byte)
99
100 //go:noescape
101 func bytes16(dst, a, b *byte)