github.com/shrimpyuk/bor@v0.2.15-0.20220224151350-fb4ec6020bae/crypto/blake2b/blake2bAVX2_amd64.go (about)

     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  
     5  //go:build go1.7 && amd64 && !gccgo && !appengine
     6  // +build go1.7,amd64,!gccgo,!appengine
     7  
     8  package blake2b
     9  
    10  import "golang.org/x/sys/cpu"
    11  
    12  func init() {
    13  	useAVX2 = cpu.X86.HasAVX2
    14  	useAVX = cpu.X86.HasAVX
    15  	useSSE4 = cpu.X86.HasSSE41
    16  }
    17  
    18  //go:noescape
    19  func fAVX2(h *[8]uint64, m *[16]uint64, c0, c1 uint64, flag uint64, rounds uint64)
    20  
    21  //go:noescape
    22  func fAVX(h *[8]uint64, m *[16]uint64, c0, c1 uint64, flag uint64, rounds uint64)
    23  
    24  //go:noescape
    25  func fSSE4(h *[8]uint64, m *[16]uint64, c0, c1 uint64, flag uint64, rounds uint64)
    26  
    27  func f(h *[8]uint64, m *[16]uint64, c0, c1 uint64, flag uint64, rounds uint64) {
    28  	switch {
    29  	case useAVX2:
    30  		fAVX2(h, m, c0, c1, flag, rounds)
    31  	case useAVX:
    32  		fAVX(h, m, c0, c1, flag, rounds)
    33  	case useSSE4:
    34  		fSSE4(h, m, c0, c1, flag, rounds)
    35  	default:
    36  		fGeneric(h, m, c0, c1, flag, rounds)
    37  	}
    38  }