authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-10 19:38:15+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-11 20:05:50+01:00
log6e1da365038856d9fbff690f187dc0a5c0933440
treeacfb14aa4b785da058d9f747596211c7c6f7c4c4
parente34e7d5ad1a61c66c145af612e11b7c6500caf79

x86_64: PtrSize.fromSize() should take into account nonexact sizes too


1 files changed, 12 insertions(+), 8 deletions(-)

src/arch/x86_64/bits.zig+12-8
......@@ -418,14 +418,18 @@ pub const Memory = union(enum) {
418418 tbyte,
419419
420420 pub fn fromSize(size: u32) PtrSize {
421 return switch (size) {
422 1 => .byte,
423 2 => .word,
424 4 => .dword,
425 8 => .qword,
426 10 => .tbyte,
427 else => unreachable,
428 };
421 return if (size <= 1)
422 .byte
423 else if (size <= 2)
424 .word
425 else if (size <= 4)
426 .dword
427 else if (size <= 8)
428 .qword
429 else if (size == 10)
430 .tbyte
431 else
432 unreachable;
429433 }
430434
431435 pub fn fromBitSize(bit_size: u64) PtrSize {