blake2bAVX2_amd64.go 935 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 fAVX2(h *[8]uint64, m *[16]uint64, c0, c1 uint64, flag uint64, rounds uint64)
  14. //go:noescape
  15. func fAVX(h *[8]uint64, m *[16]uint64, c0, c1 uint64, flag uint64, rounds uint64)
  16. //go:noescape
  17. func fSSE4(h *[8]uint64, m *[16]uint64, c0, c1 uint64, flag uint64, rounds uint64)
  18. func f(h *[8]uint64, m *[16]uint64, c0, c1 uint64, flag uint64, rounds uint64) {
  19. switch {
  20. case useAVX2:
  21. fAVX2(h, m, c0, c1, flag, rounds)
  22. case useAVX:
  23. fAVX(h, m, c0, c1, flag, rounds)
  24. case useSSE4:
  25. fSSE4(h, m, c0, c1, flag, rounds)
  26. default:
  27. fGeneric(h, m, c0, c1, flag, rounds)
  28. }
  29. }