blake2bAVX2_amd64.go 996 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. func init() {
  7. useAVX2 = supportsAVX2()
  8. useAVX = supportsAVX()
  9. useSSE4 = supportsSSE4()
  10. }
  11. //go:noescape
  12. func supportsSSE4() bool
  13. //go:noescape
  14. func supportsAVX() bool
  15. //go:noescape
  16. func supportsAVX2() bool
  17. //go:noescape
  18. func hashBlocksAVX2(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
  19. //go:noescape
  20. func hashBlocksAVX(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
  21. //go:noescape
  22. func hashBlocksSSE4(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)
  23. func hashBlocks(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) {
  24. if useAVX2 {
  25. hashBlocksAVX2(h, c, flag, blocks)
  26. } else if useAVX {
  27. hashBlocksAVX(h, c, flag, blocks)
  28. } else if useSSE4 {
  29. hashBlocksSSE4(h, c, flag, blocks)
  30. } else {
  31. hashBlocksGeneric(h, c, flag, blocks)
  32. }
  33. }