blake2s_amd64.go raw
1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build amd64 && gc && !purego
6
7 package blake2s
8
9 import "golang.org/x/sys/cpu"
10
11 var (
12 useSSE4 = cpu.X86.HasSSE41
13 useSSSE3 = cpu.X86.HasSSSE3
14 useSSE2 = cpu.X86.HasSSE2
15 )
16
17 //go:noescape
18 func hashBlocksSSE2(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte)
19
20 //go:noescape
21 func hashBlocksSSSE3(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte)
22
23 //go:noescape
24 func hashBlocksSSE4(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte)
25
26 func hashBlocks(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte) {
27 switch {
28 case useSSE4:
29 hashBlocksSSE4(h, c, flag, blocks)
30 case useSSSE3:
31 hashBlocksSSSE3(h, c, flag, blocks)
32 case useSSE2:
33 hashBlocksSSE2(h, c, flag, blocks)
34 default:
35 hashBlocksGeneric(h, c, flag, blocks)
36 }
37 }
38