File: compressAvx2_amd64.go

package info (click to toggle)
golang-github-minio-blake2b-simd 0.0~git20160723.3f5f724-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 336 kB
  • sloc: asm: 1,888; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,474 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//+build !noasm
//+build !appengine

/*
 * Minio Cloud Storage, (C) 2016 Minio, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package blake2b

//go:noescape
func compressAVX2Loop(p []uint8, in, iv, t, f, shffle, out []uint64)

func compressAVX2(d *digest, p []uint8) {
	var (
		in     [8]uint64
		out    [8]uint64
		shffle [8]uint64
	)

	// vector for PSHUFB instruction
	shffle[0] = 0x0201000706050403
	shffle[1] = 0x0a09080f0e0d0c0b
	shffle[2] = 0x0201000706050403
	shffle[3] = 0x0a09080f0e0d0c0b
	shffle[4] = 0x0100070605040302
	shffle[5] = 0x09080f0e0d0c0b0a
	shffle[6] = 0x0100070605040302
	shffle[7] = 0x09080f0e0d0c0b0a

	in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7] = d.h[0], d.h[1], d.h[2], d.h[3], d.h[4], d.h[5], d.h[6], d.h[7]

	compressAVX2Loop(p, in[:], iv[:], d.t[:], d.f[:], shffle[:], out[:])

	d.h[0], d.h[1], d.h[2], d.h[3], d.h[4], d.h[5], d.h[6], d.h[7] = out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7]
}