Source file
src/hash/crc32/crc32_s390x.go
1
2
3
4
5 package crc32
6
7 import "internal/cpu"
8
9 const (
10 vxMinLen = 64
11 vxAlignMask = 15
12 )
13
14
15
16 var hasVX = cpu.S390X.HasVX
17
18
19
20
21 func vectorizedCastagnoli(crc uint32, p []byte) uint32
22
23
24
25
26 func vectorizedIEEE(crc uint32, p []byte) uint32
27
28 func archAvailableCastagnoli() bool {
29 return hasVX
30 }
31
32 var archCastagnoliTable8 *slicing8Table
33
34 func archInitCastagnoli() {
35 if !hasVX {
36 panic("not available")
37 }
38
39 archCastagnoliTable8 = slicingMakeTable(Castagnoli)
40 }
41
42
43
44 func archUpdateCastagnoli(crc uint32, p []byte) uint32 {
45 if !hasVX {
46 panic("not available")
47 }
48
49 if len(p) >= vxMinLen {
50 aligned := len(p) & ^vxAlignMask
51 crc = vectorizedCastagnoli(crc, p[:aligned])
52 p = p[aligned:]
53 }
54 if len(p) == 0 {
55 return crc
56 }
57 return slicingUpdate(crc, archCastagnoliTable8, p)
58 }
59
60 func archAvailableIEEE() bool {
61 return hasVX
62 }
63
64 var archIeeeTable8 *slicing8Table
65
66 func archInitIEEE() {
67 if !hasVX {
68 panic("not available")
69 }
70
71 archIeeeTable8 = slicingMakeTable(IEEE)
72 }
73
74
75 func archUpdateIEEE(crc uint32, p []byte) uint32 {
76 if !hasVX {
77 panic("not available")
78 }
79
80 if len(p) >= vxMinLen {
81 aligned := len(p) & ^vxAlignMask
82 crc = vectorizedIEEE(crc, p[:aligned])
83 p = p[aligned:]
84 }
85 if len(p) == 0 {
86 return crc
87 }
88 return slicingUpdate(crc, archIeeeTable8, p)
89 }
90
View as plain text