blake2bAVX2_amd64.go 947 B

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