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