blake2bAVX2_amd64.go 911 B

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