Improve codegen for bit_field [N]T compound literals

This commit is contained in:
gingerBill
2024-04-24 17:01:09 +01:00
parent c330e5b5c1
commit 214537b420
3 changed files with 91 additions and 18 deletions

View File

@@ -1042,19 +1042,17 @@ fixdfti :: proc(a: u64) -> i128 {
__write_bits :: proc "contextless" (dst, src: [^]byte, offset: uintptr, size: uintptr) {
for i in 0..<size {
j := offset+i
the_bit := byte((src[i/8]) & (1<<(i&7)) != 0)
the_bit := byte((src[i>>3]) & (1<<(i&7)) != 0)
b := the_bit<<(j&7)
dst[j/8] &~= b
dst[j/8] |= b
dst[j>>3] = (dst[j>>3] &~ b) | b
}
}
__read_bits :: proc "contextless" (dst, src: [^]byte, offset: uintptr, size: uintptr) {
for j in 0..<size {
i := offset+j
the_bit := byte((src[i/8]) & (1<<(i&7)) != 0)
the_bit := byte((src[i>>3]) & (1<<(i&7)) != 0)
b := the_bit<<(j&7)
dst[j/8] &~= b
dst[j/8] |= b
dst[j>>3] = (dst[j>>3] &~ b) | b
}
}