From 1bbd7831840649eac7d4ea9253d16c6b22d483a9 Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Wed, 9 Apr 2025 20:59:52 -0600 Subject: [PATCH] u1 return --- src/bootstrap.zig | 9 +++++++-- src/main.zig | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bootstrap.zig b/src/bootstrap.zig index cce8f1e..77d22a2 100644 --- a/src/bootstrap.zig +++ b/src/bootstrap.zig @@ -380,7 +380,7 @@ pub const Type = struct { pub fn get_byte_size(ty: *const Type) u64 { const byte_size: u64 = switch (ty.bb) { - .integer => |integer| @max(8, lib.next_power_of_two(integer.bit_count)), + .integer => |integer| @divExact(@max(8, lib.next_power_of_two(integer.bit_count)), 8), else => @trap(), }; return byte_size; @@ -3512,6 +3512,7 @@ pub const Module = struct { .function => pointer.type, else => @trap(), }, + .function => call.callable.type.?, else => @trap(), }; @@ -4462,7 +4463,11 @@ pub const Abi = struct { return ty; } }, - else => return module.integer_type(@intCast(@min(ty.get_byte_size() - source_offset, 8) * 8), integer_type.signed), + else => { + const byte_count = @min(ty.get_byte_size() - source_offset, 8); + const bit_count = byte_count * 8; + return module.integer_type(@intCast(bit_count), integer_type.signed); + }, } }, .pointer => return if (offset == 0) ty else @trap(), diff --git a/src/main.zig b/src/main.zig index da6d0f2..27d1b12 100644 --- a/src/main.zig +++ b/src/main.zig @@ -194,4 +194,5 @@ const names = &[_][]const u8{ "basic_pointer", "basic_call", "pointer", + "u1_return", };