Add std/crc32 ieee_hasher.up_x86_sse42 placeholder

This commit is contained in:
Nigel Tao committed 2021-03-06 11:20:50 +11:00
1 parent aae62e407b
commit 44acd0e20a
4 files changed
+109 -3

No files matched your search

+3 -1
View File
@@ -25,7 +25,9 @@ pub func ieee_hasher.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
// C code, be "struct{ uint32_t checksum; wuffs_crc32__status status }"?
pub func ieee_hasher.update_u32!(x: slice base.u8) base.u32 {
if this.state == 0 {
choose up = [up_arm_crc32]
choose up = [
up_arm_crc32,
up_x86_sse42]
}
this.up!(x: args.x)
return this.state
+2 -1
View File
@@ -15,9 +15,10 @@
pri func ieee_hasher.up_arm_crc32!(x: slice base.u8),
choose cpu_arch >= arm_crc32,
{
var p : slice base.u8
var util : base.arm_crc32_utility
var s : base.arm_crc32_u32
var p : slice base.u8
s = util.make_u32(a: 0xFFFF_FFFF ^ this.state)
+44
View File
@@ -0,0 +1,44 @@
// Copyright 2021 The Wuffs Authors.
//
// 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
//
// https://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.
pri func ieee_hasher.up_x86_sse42!(x: slice base.u8),
choose cpu_arch >= x86_sse42,
{
var s : base.u32
var p : slice base.u8
s = 0xFFFF_FFFF ^ this.state
// Align to a 16-byte boundary.
while (args.x.length() > 0) and ((15 & args.x.uintptr_low_12_bits()) <> 0) {
s = IEEE_TABLE[0][((s & 0xFF) as base.u8) ^ args.x[0]] ^ (s >> 8)
args.x = args.x[1 ..]
} endwhile
// For short inputs, just do a simple loop.
if args.x.length() < 64 {
iterate (p = args.x)(length: 1, advance: 1, unroll: 1) {
s = IEEE_TABLE[0][((s & 0xFF) as base.u8) ^ p[0]] ^ (s >> 8)
}
this.state = 0xFFFF_FFFF ^ s
return nothing
}
// Placeholder.
iterate (p = args.x)(length: 1, advance: 1, unroll: 1) {
s = IEEE_TABLE[0][((s & 0xFF) as base.u8) ^ p[0]] ^ (s >> 8)
}
this.state = 0xFFFF_FFFF ^ s
}