lang: have hasher_u32.update_u32 take a roslice

This commit is contained in:
Nigel Tao committed 2023-04-10 21:16:53 +10:00
1 parent ea3fbc37f5
commit 29c4122360
11 files changed
+68 -42

No files matched your search

+4 -4
View File
@@ -21,7 +21,7 @@ pub struct hasher? implements base.hasher_u32(
pub func hasher.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
}
pub func hasher.update_u32!(x: slice base.u8) base.u32 {
pub func hasher.update_u32!(x: roslice base.u8) base.u32 {
if not this.started {
this.started = true
this.state = 1
@@ -37,7 +37,7 @@ pub func hasher.update_u32!(x: slice base.u8) base.u32 {
return this.state
}
pri func hasher.up!(x: slice base.u8),
pri func hasher.up!(x: roslice base.u8),
choosy,
{
// The Adler-32 checksum's magic 65521 and 5552 numbers are discussed in
@@ -45,8 +45,8 @@ pri func hasher.up!(x: slice base.u8),
var s1 : base.u32
var s2 : base.u32
var remaining : slice base.u8
var p : slice base.u8
var remaining : roslice base.u8
var p : roslice base.u8
s1 = this.state.low_bits(n: 16)
s2 = this.state.high_bits(n: 16)
+3 -3
View File
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
pri func hasher.up_arm_neon!(x: slice base.u8),
pri func hasher.up_arm_neon!(x: roslice base.u8),
choose cpu_arch >= arm_neon,
{
// These variables are the same as the non-SIMD version.
var s1 : base.u32
var s2 : base.u32
var remaining : slice base.u8
var p : slice base.u8
var remaining : roslice base.u8
var p : roslice base.u8
// The remaining variables are specific to the SIMD version.
+3 -3
View File
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
pri func hasher.up_x86_sse42!(x: slice base.u8),
pri func hasher.up_x86_sse42!(x: roslice base.u8),
choose cpu_arch >= x86_sse42,
{
// These variables are the same as the non-SIMD version.
var s1 : base.u32
var s2 : base.u32
var remaining : slice base.u8
var p : slice base.u8
var remaining : roslice base.u8
var p : roslice base.u8
// The remaining variables are specific to the SIMD version.
+3 -3
View File
@@ -23,7 +23,7 @@ pub func ieee_hasher.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
// TODO: should it be ? instead of ! because it's public, and might need a way
// to signal "initializer not called"? Should the return type, in the generated
// C code, be "struct{ uint32_t checksum; wuffs_crc32__status status }"?
pub func ieee_hasher.update_u32!(x: slice base.u8) base.u32 {
pub func ieee_hasher.update_u32!(x: roslice base.u8) base.u32 {
if this.state == 0 {
choose up = [
up_arm_crc32,
@@ -34,11 +34,11 @@ pub func ieee_hasher.update_u32!(x: slice base.u8) base.u32 {
return this.state
}
pri func ieee_hasher.up!(x: slice base.u8),
pri func ieee_hasher.up!(x: roslice base.u8),
choosy,
{
var s : base.u32
var p : slice base.u8
var p : roslice base.u8
s = 0xFFFF_FFFF ^ this.state
+2 -2
View File
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
pri func ieee_hasher.up_arm_crc32!(x: slice base.u8),
pri func ieee_hasher.up_arm_crc32!(x: roslice base.u8),
choose cpu_arch >= arm_crc32,
{
var p : slice base.u8
var p : roslice base.u8
var util : base.arm_crc32_utility
var s : base.arm_crc32_u32
+2 -2
View File
@@ -20,11 +20,11 @@
// up_x86_avx2 is exactly the same as up_x86_sse42 except for the "choose
// cpu_arch >= x86_avx2". With AVX, PCLMULQDQ has a three-operand form, not
// just a two-operand form: https://www.felixcloutier.com/x86/pclmulqdq
pri func ieee_hasher.up_x86_avx2!(x: slice base.u8),
pri func ieee_hasher.up_x86_avx2!(x: roslice base.u8),
choose cpu_arch >= x86_avx2,
{
var s : base.u32
var p : slice base.u8
var p : roslice base.u8
var util : base.x86_sse42_utility
var k : base.x86_m128i
+2 -2
View File
@@ -17,11 +17,11 @@
// See "SIMD Implementations" in README.md for a link to Gopal et al. "Fast CRC
// Computation for Generic Polynomials Using PCLMULQDQ Instruction".
pri func ieee_hasher.up_x86_sse42!(x: slice base.u8),
pri func ieee_hasher.up_x86_sse42!(x: roslice base.u8),
choose cpu_arch >= x86_sse42,
{
var s : base.u32
var p : slice base.u8
var p : roslice base.u8
var util : base.x86_sse42_utility
var k : base.x86_m128i