shrinking teh type repr to 32 bits

Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
Jakub Doka 2025-03-17 18:42:39 +01:00
parent a23c48d29e
commit af34b89f58
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
2 changed files with 10 additions and 8 deletions

View file

@ -1350,8 +1350,10 @@ pub fn emit(self: *Codegen, ctx: Ctx, expr: Ast.Id) EmitError!Value {
const prefix = 3; const prefix = 3;
const args = self.bl.allocCallArgs(tmp.arena, prefix + e.captures.len() * 2, 1); const args = self.bl.allocCallArgs(tmp.arena, prefix + e.captures.len() * 2, 1);
@memset(args.params, .int); @memset(args.params, self.abiCata(.type).ByValue);
@memset(args.returns, .int); args.params[0] = .int;
args.params[2] = .int;
args.returns[0] = self.abiCata(.type).ByValue;
args.arg_slots[0] = self.bl.addIntImm(.int, @intFromEnum(@field(Comptime.InteruptCode, @tagName(t)))); args.arg_slots[0] = self.bl.addIntImm(.int, @intFromEnum(@field(Comptime.InteruptCode, @tagName(t))));
args.arg_slots[1] = self.emitTyConst(self.parent_scope.perm()).id.Value; args.arg_slots[1] = self.emitTyConst(self.parent_scope.perm()).id.Value;
@ -1634,7 +1636,7 @@ pub fn emitTyped(self: *Codegen, ctx: Ctx, ty: Types.Id, expr: Ast.Id) !Value {
} }
pub fn emitTyConst(self: *Codegen, ty: Types.Id) Value { pub fn emitTyConst(self: *Codegen, ty: Types.Id) Value {
return .mkv(.type, self.bl.addIntImm(.int, @intCast(@as(isize, @intFromEnum(ty))))); return .mkv(.type, self.bl.addIntImm(self.abiCata(.type).ByValue, @intCast(@as(isize, @intFromEnum(ty)))));
} }
pub fn unwrapTyConst(self: *Codegen, pos: anytype, cnst: *Value) !Types.Id { pub fn unwrapTyConst(self: *Codegen, pos: anytype, cnst: *Value) !Types.Id {
@ -1691,7 +1693,7 @@ pub fn resolveGlobal(self: *Codegen, name: []const u8, bsty: Types.Id, ast: *con
const global = self.types.store.get(global_id).*; const global = self.types.store.get(global_id).*;
if (path.len != 0) { if (path.len != 0) {
if (global.ty != .type) return self.report(vari.value, "expected a global holding a type, {} is not", .{global.ty}); if (global.ty != .type) return self.report(vari.value, "expected a global holding a type, {} is not", .{global.ty});
var cur: Types.Id = @enumFromInt(@as(u64, @bitCast(global.data[0..8].*))); var cur: Types.Id = @enumFromInt(@as(u32, @bitCast(global.data[0..4].*)));
for (path) |ps| { for (path) |ps| {
var vl = try self.lookupScopeItem(ps, cur, ast.tokenSrc(ps.index)); var vl = try self.lookupScopeItem(ps, cur, ast.tokenSrc(ps.index));
cur = try self.unwrapTyConst(ps, &vl); cur = try self.unwrapTyConst(ps, &vl);

View file

@ -265,8 +265,8 @@ pub const Id = enum(IdRepr) {
.void => 0, .void => 0,
.u8, .i8, .bool => 1, .u8, .i8, .bool => 1,
.u16, .i16 => 2, .u16, .i16 => 2,
.u32, .i32, .f32 => 4, .u32, .i32, .type, .f32 => 4,
.uint, .int, .f64, .type, .u64, .i64 => 8, .uint, .int, .f64, .u64, .i64 => 8,
}, },
.Pointer => 8, .Pointer => 8,
.Enum => |e| { .Enum => |e| {
@ -469,8 +469,8 @@ pub const Abi = enum {
.void => return .Imaginary, .void => return .Imaginary,
.u8, .i8, .bool => .i8, .u8, .i8, .bool => .i8,
.u16, .i16 => .i16, .u16, .i16 => .i16,
.u32, .i32 => .i32, .u32, .type, .i32 => .i32,
.uint, .int, .type, .i64, .u64 => .int, .uint, .int, .i64, .u64 => .int,
.f32 => .f32, .f32 => .f32,
.f64 => .f64, .f64 => .f64,
} }, } },