Source file src/crypto/internal/fips/sha512/sha512block_amd64.go

     1  // Copyright 2013 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 !purego
     6  
     7  package sha512
     8  
     9  import (
    10  	"crypto/internal/impl"
    11  	"internal/cpu"
    12  )
    13  
    14  var useAVX2 = cpu.X86.HasAVX2 && cpu.X86.HasBMI1 && cpu.X86.HasBMI2
    15  
    16  func init() {
    17  	impl.Register("crypto/sha512", "AVX2", &useAVX2)
    18  }
    19  
    20  //go:noescape
    21  func blockAVX2(dig *Digest, p []byte)
    22  
    23  //go:noescape
    24  func blockAMD64(dig *Digest, p []byte)
    25  
    26  func block(dig *Digest, p []byte) {
    27  	if useAVX2 {
    28  		blockAVX2(dig, p)
    29  	} else {
    30  		blockAMD64(dig, p)
    31  	}
    32  }
    33  

View as plain text