You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
909 B

  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 amd64,!gccgo,!appengine
  5. package blake2s
  6. import "golang.org/x/sys/cpu"
  7. var (
  8. useSSE4 = cpu.X86.HasSSE41
  9. useSSSE3 = cpu.X86.HasSSSE3
  10. useSSE2 = cpu.X86.HasSSE2
  11. )
  12. //go:noescape
  13. func hashBlocksSSE2(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte)
  14. //go:noescape
  15. func hashBlocksSSSE3(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte)
  16. //go:noescape
  17. func hashBlocksSSE4(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte)
  18. func hashBlocks(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte) {
  19. switch {
  20. case useSSE4:
  21. hashBlocksSSE4(h, c, flag, blocks)
  22. case useSSSE3:
  23. hashBlocksSSSE3(h, c, flag, blocks)
  24. case useSSE2:
  25. hashBlocksSSE2(h, c, flag, blocks)
  26. default:
  27. hashBlocksGeneric(h, c, flag, blocks)
  28. }
  29. }