crc32: add notw macro
instead of materializing a constant 0xffffffff, do a NOT and then zero-extend the result. my qemu doesn't support the zext.w instruction, so we have to do two shifts instead. these can potentially be fused into a single instruction by the processor.
This commit is contained in:
parent
6d1413c754
commit
cc18d535a5
15
crc32.s
15
crc32.s
@ -127,6 +127,14 @@ iloop2:
|
|||||||
|
|
||||||
#............................................
|
#............................................
|
||||||
|
|
||||||
|
.macro notw rd, rs
|
||||||
|
not \rd, \rs
|
||||||
|
#zext.w \rd, \rd
|
||||||
|
#add.uw \rd, \rs, 0
|
||||||
|
slli \rd, \rd, 32
|
||||||
|
srli \rd, \rd, 32
|
||||||
|
.endm
|
||||||
|
|
||||||
# inputs:
|
# inputs:
|
||||||
# a0: crc
|
# a0: crc
|
||||||
# a1: buf
|
# a1: buf
|
||||||
@ -142,9 +150,7 @@ crc_update:
|
|||||||
mv t2, s1
|
mv t2, s1
|
||||||
mv t3, s2
|
mv t3, s2
|
||||||
# invert crc
|
# invert crc
|
||||||
li t0, -1
|
notw a0, a0
|
||||||
srli t0, t0, 32
|
|
||||||
xor a0, a0, t0
|
|
||||||
|
|
||||||
mv s0, a0 # crc
|
mv s0, a0 # crc
|
||||||
mv s1, a1 # buffer
|
mv s1, a1 # buffer
|
||||||
@ -174,6 +180,5 @@ udone:
|
|||||||
# invert crc
|
# invert crc
|
||||||
#li t0, -1
|
#li t0, -1
|
||||||
#srli t0, t0, 32
|
#srli t0, t0, 32
|
||||||
li t0, 0xFFFFFFFF
|
notw a0, a0
|
||||||
xor a0, a0, t0
|
|
||||||
ret
|
ret
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user