1// Copyright 2017 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// +build ignore
6
7// ARM64-specific hardware-assisted CRC32 algorithms. See crc32.go for a
8// description of the interface that each architecture-specific file
9// implements.
10
11package crc32
12
13import "internal/cpu"
14
15func castagnoliUpdate(crc uint32, p []byte) uint32
16func ieeeUpdate(crc uint32, p []byte) uint32
17
18func archAvailableCastagnoli() bool {
19	return cpu.ARM64.HasCRC32
20}
21
22func archInitCastagnoli() {
23	if !cpu.ARM64.HasCRC32 {
24		panic("arch-specific crc32 instruction for Catagnoli not available")
25	}
26}
27
28func archUpdateCastagnoli(crc uint32, p []byte) uint32 {
29	if !cpu.ARM64.HasCRC32 {
30		panic("arch-specific crc32 instruction for Castagnoli not available")
31	}
32
33	return ^castagnoliUpdate(^crc, p)
34}
35
36func archAvailableIEEE() bool {
37	return cpu.ARM64.HasCRC32
38}
39
40func archInitIEEE() {
41	if !cpu.ARM64.HasCRC32 {
42		panic("arch-specific crc32 instruction for IEEE not available")
43	}
44}
45
46func archUpdateIEEE(crc uint32, p []byte) uint32 {
47	if !cpu.ARM64.HasCRC32 {
48		panic("arch-specific crc32 instruction for IEEE not available")
49	}
50
51	return ^ieeeUpdate(^crc, p)
52}
53