blocksisa_amd64.go raw

   1  // Copyright (c) 2024 The Decred developers
   2  // Use of this source code is governed by an ISC
   3  // license that can be found in the LICENSE file.
   4  //
   5  // Automatic selection originally written by Dave Collins July 2024.
   6  
   7  //go:build !purego
   8  
   9  package compress
  10  
  11  // Blocks performs BLAKE-224 and BLAKE-256 block compression using processor
  12  // specific vector extensions when available.  It will compress as many full
  13  // blocks as are available in the provided message.
  14  //
  15  // The parameters are:
  16  //
  17  //	state: the block compression state with the chain value and salt
  18  //	msg: the padded message to compress (must be at least 64 bytes)
  19  //	counter: the total number of message bits hashed so far
  20  //
  21  // It will panic if the provided message block does not have at least 64 bytes.
  22  //
  23  // The chain value in the passed state is updated in place.
  24  func Blocks(state *State, msg []byte, counter uint64) {
  25  	switch {
  26  	case hasAVX:
  27  		blocksAVX(state, msg, counter)
  28  	case hasSSE41:
  29  		blocksSSE41(state, msg, counter)
  30  	case hasSSE2:
  31  		blocksSSE2(state, msg, counter)
  32  	default:
  33  		blocksGeneric(state, msg, counter)
  34  	}
  35  }
  36