Source file src/hash/crc32/crc32_loong64.go

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

View as plain text