mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Add slice uintptr_low_12_bits method
This commit is contained in:
1 parent
0834b40d22
commit
81ba41e251
6 files changed
+42
-20
No files matched your search
@@ -37,6 +37,7 @@
|
||||
- Added iterate advance parameter.
|
||||
- Added preprocessor.
|
||||
- Added single-quoted strings.
|
||||
- Added slice `uintptr_low_12_bits` method.
|
||||
- Added tokens.
|
||||
- Changed `gif.decoder_workbuf_len_max_incl_worst_case` from 1 to 0.
|
||||
- Changed default C compilers from `clang-5.0,gcc` to `clang-9,gcc`.
|
||||
|
||||
@@ -687,6 +687,14 @@ func (g *gen) writeBuiltinSlice(b *buffer, recv *a.Expr, method t.ID, args []*a.
|
||||
b.writes(".len))")
|
||||
return nil
|
||||
|
||||
case t.IDUintptrLow12Bits:
|
||||
b.writes("((uint32_t)(0xFFF & (uintptr_t)(")
|
||||
if err := g.writeExpr(b, recv, false, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(".ptr)))")
|
||||
return nil
|
||||
|
||||
case t.IDSuffix:
|
||||
// TODO: don't assume that the slice is a slice of base.u8.
|
||||
b.writes("wuffs_base__slice_u8__suffix(")
|
||||
|
||||
@@ -680,6 +680,7 @@ var SliceFuncs = []string{
|
||||
"GENERIC T1.copy_from_slice!(s: T1) u64",
|
||||
"GENERIC T1.length() u64",
|
||||
"GENERIC T1.prefix(up_to: u64) T1",
|
||||
"GENERIC T1.uintptr_low_12_bits() u32[..= 4095]",
|
||||
"GENERIC T1.suffix(up_to: u64) T1",
|
||||
}
|
||||
|
||||
|
||||
+22
-20
@@ -645,16 +645,17 @@ const (
|
||||
IDIsOK = ID(0x231)
|
||||
IDIsSuspension = ID(0x232)
|
||||
|
||||
IDData = ID(0x240)
|
||||
IDHeight = ID(0x241)
|
||||
IDIO = ID(0x242)
|
||||
IDLimit = ID(0x243)
|
||||
IDPrefix = ID(0x244)
|
||||
IDRow = ID(0x245)
|
||||
IDStride = ID(0x246)
|
||||
IDSuffix = ID(0x247)
|
||||
IDValidUTF8Length = ID(0x248)
|
||||
IDWidth = ID(0x249)
|
||||
IDData = ID(0x240)
|
||||
IDHeight = ID(0x241)
|
||||
IDIO = ID(0x242)
|
||||
IDLimit = ID(0x243)
|
||||
IDPrefix = ID(0x244)
|
||||
IDRow = ID(0x245)
|
||||
IDStride = ID(0x246)
|
||||
IDSuffix = ID(0x247)
|
||||
IDUintptrLow12Bits = ID(0x248)
|
||||
IDValidUTF8Length = ID(0x249)
|
||||
IDWidth = ID(0x24A)
|
||||
|
||||
IDLimitedSwizzleU32InterleavedFromReader = ID(0x280)
|
||||
IDSwizzleInterleavedFromReader = ID(0x281)
|
||||
@@ -1066,16 +1067,17 @@ var builtInsByID = [nBuiltInIDs]string{
|
||||
IDIsOK: "is_ok",
|
||||
IDIsSuspension: "is_suspension",
|
||||
|
||||
IDData: "data",
|
||||
IDHeight: "height",
|
||||
IDIO: "io",
|
||||
IDLimit: "limit",
|
||||
IDPrefix: "prefix",
|
||||
IDRow: "row",
|
||||
IDStride: "stride",
|
||||
IDSuffix: "suffix",
|
||||
IDValidUTF8Length: "valid_utf_8_length",
|
||||
IDWidth: "width",
|
||||
IDData: "data",
|
||||
IDHeight: "height",
|
||||
IDIO: "io",
|
||||
IDLimit: "limit",
|
||||
IDPrefix: "prefix",
|
||||
IDRow: "row",
|
||||
IDStride: "stride",
|
||||
IDSuffix: "suffix",
|
||||
IDUintptrLow12Bits: "uintptr_low_12_bits",
|
||||
IDValidUTF8Length: "valid_utf_8_length",
|
||||
IDWidth: "width",
|
||||
|
||||
IDLimitedSwizzleU32InterleavedFromReader: "limited_swizzle_u32_interleaved_from_reader",
|
||||
IDSwizzleInterleavedFromReader: "swizzle_interleaved_from_reader",
|
||||
|
||||
@@ -21944,6 +21944,10 @@ wuffs_crc32__ieee_hasher__up_arm_crc32(
|
||||
wuffs_base__slice_u8 v_p = {0};
|
||||
|
||||
v_s = (4294967295 ^ self->private_impl.f_state);
|
||||
while ((((uint64_t)(a_x.len)) > 0) && ((15 & ((uint32_t)(0xFFF & (uintptr_t)(a_x.ptr)))) != 0)) {
|
||||
v_s = (WUFFS_CRC32__IEEE_TABLE[0][(((uint8_t)((v_s & 255))) ^ a_x.ptr[0])] ^ (v_s >> 8));
|
||||
a_x = wuffs_base__slice_u8__subslice_i(a_x, 1);
|
||||
}
|
||||
{
|
||||
wuffs_base__slice_u8 i_slice_p = a_x;
|
||||
v_p.ptr = i_slice_p.ptr;
|
||||
|
||||
@@ -77,6 +77,12 @@ pri func ieee_hasher.up_arm_crc32!(x: 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
|
||||
|
||||
// See "Multi-Byte Lookup Tables" in std/crc32/README.md for more detail on
|
||||
// the slicing-by-M algorithm. We use an M of 16.
|
||||
iterate (p = args.x)(length: 16, advance: 16, unroll: 2) {
|
||||
|
||||
Reference in new issue
Block a user