aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-03-10 19:38:15 +0100
committerJakub Konka <kubkon@jakubkonka.com>2023-03-11 20:05:50 +0100
commit6e1da365038856d9fbff690f187dc0a5c0933440 (patch)
treeacfb14aa4b785da058d9f747596211c7c6f7c4c4 /src
parente34e7d5ad1a61c66c145af612e11b7c6500caf79 (diff)
downloadzig-6e1da365038856d9fbff690f187dc0a5c0933440.tar.gz
zig-6e1da365038856d9fbff690f187dc0a5c0933440.zip
x86_64: PtrSize.fromSize() should take into account nonexact sizes too
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86_64/bits.zig20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/arch/x86_64/bits.zig b/src/arch/x86_64/bits.zig
index b6ac9ec5a8..1828cdc08f 100644
--- a/src/arch/x86_64/bits.zig
+++ b/src/arch/x86_64/bits.zig
@@ -418,14 +418,18 @@ pub const Memory = union(enum) {
tbyte,
pub fn fromSize(size: u32) PtrSize {
- return switch (size) {
- 1 => .byte,
- 2 => .word,
- 4 => .dword,
- 8 => .qword,
- 10 => .tbyte,
- else => unreachable,
- };
+ return if (size <= 1)
+ .byte
+ else if (size <= 2)
+ .word
+ else if (size <= 4)
+ .dword
+ else if (size <= 8)
+ .qword
+ else if (size == 10)
+ .tbyte
+ else
+ unreachable;
}
pub fn fromBitSize(bit_size: u64) PtrSize {