mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-26 09:01:35 +01:00
Add slice uintptr_low_12_bits method
This commit is contained in:
1 parent
0834b40d22
commit
81ba41e251
6 files changed
+24
-2
No files matched your search
@@ -37,6 +37,7 @@
|
|||||||
- Added iterate advance parameter.
|
- Added iterate advance parameter.
|
||||||
- Added preprocessor.
|
- Added preprocessor.
|
||||||
- Added single-quoted strings.
|
- Added single-quoted strings.
|
||||||
|
- Added slice `uintptr_low_12_bits` method.
|
||||||
- Added tokens.
|
- Added tokens.
|
||||||
- Changed `gif.decoder_workbuf_len_max_incl_worst_case` from 1 to 0.
|
- 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`.
|
- 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))")
|
b.writes(".len))")
|
||||||
return nil
|
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:
|
case t.IDSuffix:
|
||||||
// TODO: don't assume that the slice is a slice of base.u8.
|
// TODO: don't assume that the slice is a slice of base.u8.
|
||||||
b.writes("wuffs_base__slice_u8__suffix(")
|
b.writes("wuffs_base__slice_u8__suffix(")
|
||||||
|
|||||||
@@ -680,6 +680,7 @@ var SliceFuncs = []string{
|
|||||||
"GENERIC T1.copy_from_slice!(s: T1) u64",
|
"GENERIC T1.copy_from_slice!(s: T1) u64",
|
||||||
"GENERIC T1.length() u64",
|
"GENERIC T1.length() u64",
|
||||||
"GENERIC T1.prefix(up_to: u64) T1",
|
"GENERIC T1.prefix(up_to: u64) T1",
|
||||||
|
"GENERIC T1.uintptr_low_12_bits() u32[..= 4095]",
|
||||||
"GENERIC T1.suffix(up_to: u64) T1",
|
"GENERIC T1.suffix(up_to: u64) T1",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -653,8 +653,9 @@ const (
|
|||||||
IDRow = ID(0x245)
|
IDRow = ID(0x245)
|
||||||
IDStride = ID(0x246)
|
IDStride = ID(0x246)
|
||||||
IDSuffix = ID(0x247)
|
IDSuffix = ID(0x247)
|
||||||
IDValidUTF8Length = ID(0x248)
|
IDUintptrLow12Bits = ID(0x248)
|
||||||
IDWidth = ID(0x249)
|
IDValidUTF8Length = ID(0x249)
|
||||||
|
IDWidth = ID(0x24A)
|
||||||
|
|
||||||
IDLimitedSwizzleU32InterleavedFromReader = ID(0x280)
|
IDLimitedSwizzleU32InterleavedFromReader = ID(0x280)
|
||||||
IDSwizzleInterleavedFromReader = ID(0x281)
|
IDSwizzleInterleavedFromReader = ID(0x281)
|
||||||
@@ -1074,6 +1075,7 @@ var builtInsByID = [nBuiltInIDs]string{
|
|||||||
IDRow: "row",
|
IDRow: "row",
|
||||||
IDStride: "stride",
|
IDStride: "stride",
|
||||||
IDSuffix: "suffix",
|
IDSuffix: "suffix",
|
||||||
|
IDUintptrLow12Bits: "uintptr_low_12_bits",
|
||||||
IDValidUTF8Length: "valid_utf_8_length",
|
IDValidUTF8Length: "valid_utf_8_length",
|
||||||
IDWidth: "width",
|
IDWidth: "width",
|
||||||
|
|
||||||
|
|||||||
@@ -21944,6 +21944,10 @@ wuffs_crc32__ieee_hasher__up_arm_crc32(
|
|||||||
wuffs_base__slice_u8 v_p = {0};
|
wuffs_base__slice_u8 v_p = {0};
|
||||||
|
|
||||||
v_s = (4294967295 ^ self->private_impl.f_state);
|
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;
|
wuffs_base__slice_u8 i_slice_p = a_x;
|
||||||
v_p.ptr = i_slice_p.ptr;
|
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
|
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
|
// 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.
|
// the slicing-by-M algorithm. We use an M of 16.
|
||||||
iterate (p = args.x)(length: 16, advance: 16, unroll: 2) {
|
iterate (p = args.x)(length: 16, advance: 16, unroll: 2) {
|
||||||
|
|||||||
Reference in new issue
Block a user