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 go1.7 && amd64 && gc && !purego
6// +build go1.7,amd64,gc,!purego
7
8package blake2b
9
10import "golang.org/x/sys/cpu"
11
12func init() {
13	useAVX2 = cpu.X86.HasAVX2
14	useAVX = cpu.X86.HasAVX
15	useSSE4 = cpu.X86.HasSSE41
16}
17
18//go:noescape
19func hashBlocksAVX2(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
20
21//go:noescape
22func hashBlocksAVX(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
23
24//go:noescape
25func hashBlocksSSE4(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
26
27func hashBlocks(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) {
28	switch {
29	case useAVX2:
30		hashBlocksAVX2(h, c, flag, blocks)
31	case useAVX:
32		hashBlocksAVX(h, c, flag, blocks)
33	case useSSE4:
34		hashBlocksSSE4(h, c, flag, blocks)
35	default:
36		hashBlocksGeneric(h, c, flag, blocks)
37	}
38}
39