| author | |
| committer | |
| log | 66c43968546e38879a2d4c3f2264e10676deef73 |
| tree | 9220a6d6f006e08bd7aa7ccd6997276dae6383bf |
| parent | 9afa97418350a51d8e27f1df903d8034507254ce |
13 files changed, 44 insertions(+), 62 deletions(-)
src/Air.zig+9-7| ... | @@ -17,7 +17,6 @@ instructions: std.MultiArrayList(Inst).Slice, | ... | @@ -17,7 +17,6 @@ instructions: std.MultiArrayList(Inst).Slice, |
| 17 | /// The meaning of this data is determined by `Inst.Tag` value. | 17 | /// The meaning of this data is determined by `Inst.Tag` value. |
| 18 | /// The first few indexes are reserved. See `ExtraIndex` for the values. | 18 | /// The first few indexes are reserved. See `ExtraIndex` for the values. |
| 19 | extra: []const u32, | 19 | extra: []const u32, |
| 20 | values: []const Value, | ||
| 21 | 20 | ||
| 22 | pub const ExtraIndex = enum(u32) { | 21 | pub const ExtraIndex = enum(u32) { |
| 23 | /// Payload index of the main `Block` in the `extra` array. | 22 | /// Payload index of the main `Block` in the `extra` array. |
| ... | @@ -421,10 +420,10 @@ pub const Inst = struct { | ... | @@ -421,10 +420,10 @@ pub const Inst = struct { |
| 421 | /// Marks the end of a semantic scope for debug info variables. | 420 | /// Marks the end of a semantic scope for debug info variables. |
| 422 | dbg_block_end, | 421 | dbg_block_end, |
| 423 | /// Marks the start of an inline call. | 422 | /// Marks the start of an inline call. |
| 424 | /// Uses `ty_pl` with the payload being the index of a Value.Function in air.values. | 423 | /// Uses the `ty_fn` field. |
| 425 | dbg_inline_begin, | 424 | dbg_inline_begin, |
| 426 | /// Marks the end of an inline call. | 425 | /// Marks the end of an inline call. |
| 427 | /// Uses `ty_pl` with the payload being the index of a Value.Function in air.values. | 426 | /// Uses the `ty_fn` field. |
| 428 | dbg_inline_end, | 427 | dbg_inline_end, |
| 429 | /// Marks the beginning of a local variable. The operand is a pointer pointing | 428 | /// Marks the beginning of a local variable. The operand is a pointer pointing |
| 430 | /// to the storage for the variable. The local may be a const or a var. | 429 | /// to the storage for the variable. The local may be a const or a var. |
| ... | @@ -967,6 +966,10 @@ pub const Inst = struct { | ... | @@ -967,6 +966,10 @@ pub const Inst = struct { |
| 967 | // Index into a different array. | 966 | // Index into a different array. |
| 968 | payload: u32, | 967 | payload: u32, |
| 969 | }, | 968 | }, |
| 969 | ty_fn: struct { | ||
| 970 | ty: Ref, | ||
| 971 | func: Module.Fn.Index, | ||
| 972 | }, | ||
| 970 | br: struct { | 973 | br: struct { |
| 971 | block_inst: Index, | 974 | block_inst: Index, |
| 972 | operand: Ref, | 975 | operand: Ref, |
| ... | @@ -1090,8 +1093,7 @@ pub const FieldParentPtr = struct { | ... | @@ -1090,8 +1093,7 @@ pub const FieldParentPtr = struct { |
| 1090 | pub const Shuffle = struct { | 1093 | pub const Shuffle = struct { |
| 1091 | a: Inst.Ref, | 1094 | a: Inst.Ref, |
| 1092 | b: Inst.Ref, | 1095 | b: Inst.Ref, |
| 1093 | // index to air_values | 1096 | mask: InternPool.Index, |
| 1094 | mask: u32, | ||
| 1095 | mask_len: u32, | 1097 | mask_len: u32, |
| 1096 | }; | 1098 | }; |
| 1097 | 1099 | ||
| ... | @@ -1469,7 +1471,8 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end | ... | @@ -1469,7 +1471,8 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end |
| 1469 | u32 => air.extra[i], | 1471 | u32 => air.extra[i], |
| 1470 | Inst.Ref => @intToEnum(Inst.Ref, air.extra[i]), | 1472 | Inst.Ref => @intToEnum(Inst.Ref, air.extra[i]), |
| 1471 | i32 => @bitCast(i32, air.extra[i]), | 1473 | i32 => @bitCast(i32, air.extra[i]), |
| 1472 | else => @compileError("bad field type"), | 1474 | InternPool.Index => @intToEnum(InternPool.Index, air.extra[i]), |
| 1475 | else => @compileError("bad field type: " ++ @typeName(field.type)), | ||
| 1473 | }; | 1476 | }; |
| 1474 | i += 1; | 1477 | i += 1; |
| 1475 | } | 1478 | } |
| ... | @@ -1482,7 +1485,6 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end | ... | @@ -1482,7 +1485,6 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end |
| 1482 | pub fn deinit(air: *Air, gpa: std.mem.Allocator) void { | 1485 | pub fn deinit(air: *Air, gpa: std.mem.Allocator) void { |
| 1483 | air.instructions.deinit(gpa); | 1486 | air.instructions.deinit(gpa); |
| 1484 | gpa.free(air.extra); | 1487 | gpa.free(air.extra); |
| 1485 | gpa.free(air.values); | ||
| 1486 | air.* = undefined; | 1488 | air.* = undefined; |
| 1487 | } | 1489 | } |
| 1488 | 1490 |
src/Module.zig-1| ... | @@ -5720,7 +5720,6 @@ pub fn analyzeFnBody(mod: *Module, func_index: Fn.Index, arena: Allocator) SemaE | ... | @@ -5720,7 +5720,6 @@ pub fn analyzeFnBody(mod: *Module, func_index: Fn.Index, arena: Allocator) SemaE |
| 5720 | return Air{ | 5720 | return Air{ |
| 5721 | .instructions = sema.air_instructions.toOwnedSlice(), | 5721 | .instructions = sema.air_instructions.toOwnedSlice(), |
| 5722 | .extra = try sema.air_extra.toOwnedSlice(gpa), | 5722 | .extra = try sema.air_extra.toOwnedSlice(gpa), |
| 5723 | .values = try sema.air_values.toOwnedSlice(gpa), | ||
| 5724 | }; | 5723 | }; |
| 5725 | } | 5724 | } |
| 5726 | 5725 |
src/Sema.zig+9-18| ... | @@ -17,7 +17,6 @@ perm_arena: Allocator, | ... | @@ -17,7 +17,6 @@ perm_arena: Allocator, |
| 17 | code: Zir, | 17 | code: Zir, |
| 18 | air_instructions: std.MultiArrayList(Air.Inst) = .{}, | 18 | air_instructions: std.MultiArrayList(Air.Inst) = .{}, |
| 19 | air_extra: std.ArrayListUnmanaged(u32) = .{}, | 19 | air_extra: std.ArrayListUnmanaged(u32) = .{}, |
| 20 | air_values: std.ArrayListUnmanaged(Value) = .{}, | ||
| 21 | /// Maps ZIR to AIR. | 20 | /// Maps ZIR to AIR. |
| 22 | inst_map: InstMap = .{}, | 21 | inst_map: InstMap = .{}, |
| 23 | /// When analyzing an inline function call, owner_decl is the Decl of the caller | 22 | /// When analyzing an inline function call, owner_decl is the Decl of the caller |
| ... | @@ -772,7 +771,6 @@ pub fn deinit(sema: *Sema) void { | ... | @@ -772,7 +771,6 @@ pub fn deinit(sema: *Sema) void { |
| 772 | const gpa = sema.gpa; | 771 | const gpa = sema.gpa; |
| 773 | sema.air_instructions.deinit(gpa); | 772 | sema.air_instructions.deinit(gpa); |
| 774 | sema.air_extra.deinit(gpa); | 773 | sema.air_extra.deinit(gpa); |
| 775 | sema.air_values.deinit(gpa); | ||
| 776 | sema.inst_map.deinit(gpa); | 774 | sema.inst_map.deinit(gpa); |
| 777 | sema.decl_val_table.deinit(gpa); | 775 | sema.decl_val_table.deinit(gpa); |
| 778 | sema.types_to_resolve.deinit(gpa); | 776 | sema.types_to_resolve.deinit(gpa); |
| ... | @@ -2018,10 +2016,8 @@ fn resolveMaybeUndefValAllowVariablesMaybeRuntime( | ... | @@ -2018,10 +2016,8 @@ fn resolveMaybeUndefValAllowVariablesMaybeRuntime( |
| 2018 | } | 2016 | } |
| 2019 | const air_datas = sema.air_instructions.items(.data); | 2017 | const air_datas = sema.air_instructions.items(.data); |
| 2020 | const val = switch (air_tags[i]) { | 2018 | const val = switch (air_tags[i]) { |
| 2021 | .inferred_alloc, .inferred_alloc_comptime => val: { | 2019 | .inferred_alloc => unreachable, |
| 2022 | const ty_pl = sema.air_instructions.items(.data)[i].ty_pl; | 2020 | .inferred_alloc_comptime => unreachable, |
| 2023 | break :val sema.air_values.items[ty_pl.payload]; | ||
| 2024 | }, | ||
| 2025 | .interned => air_datas[i].interned.toValue(), | 2021 | .interned => air_datas[i].interned.toValue(), |
| 2026 | else => return null, | 2022 | else => return null, |
| 2027 | }; | 2023 | }; |
| ... | @@ -7930,20 +7926,17 @@ fn emitDbgInline( | ... | @@ -7930,20 +7926,17 @@ fn emitDbgInline( |
| 7930 | new_func_ty: Type, | 7926 | new_func_ty: Type, |
| 7931 | tag: Air.Inst.Tag, | 7927 | tag: Air.Inst.Tag, |
| 7932 | ) CompileError!void { | 7928 | ) CompileError!void { |
| 7933 | if (sema.mod.comp.bin_file.options.strip) return; | 7929 | const mod = sema.mod; |
| 7930 | if (mod.comp.bin_file.options.strip) return; | ||
| 7934 | 7931 | ||
| 7935 | // Recursive inline call; no dbg_inline needed. | 7932 | // Recursive inline call; no dbg_inline needed. |
| 7936 | if (old_func == new_func) return; | 7933 | if (old_func == new_func) return; |
| 7937 | 7934 | ||
| 7938 | try sema.air_values.append(sema.gpa, (try sema.mod.intern(.{ .func = .{ | ||
| 7939 | .ty = new_func_ty.toIntern(), | ||
| 7940 | .index = new_func, | ||
| 7941 | } })).toValue()); | ||
| 7942 | _ = try block.addInst(.{ | 7935 | _ = try block.addInst(.{ |
| 7943 | .tag = tag, | 7936 | .tag = tag, |
| 7944 | .data = .{ .ty_pl = .{ | 7937 | .data = .{ .ty_fn = .{ |
| 7945 | .ty = try sema.addType(new_func_ty), | 7938 | .ty = try sema.addType(new_func_ty), |
| 7946 | .payload = @intCast(u32, sema.air_values.items.len - 1), | 7939 | .func = new_func, |
| 7947 | } }, | 7940 | } }, |
| 7948 | }); | 7941 | }); |
| 7949 | } | 7942 | } |
| ... | @@ -21724,8 +21717,6 @@ fn analyzeShuffle( | ... | @@ -21724,8 +21717,6 @@ fn analyzeShuffle( |
| 21724 | } | 21717 | } |
| 21725 | } | 21718 | } |
| 21726 | 21719 | ||
| 21727 | const mask_index = @intCast(u32, sema.air_values.items.len); | ||
| 21728 | try sema.air_values.append(sema.gpa, mask); | ||
| 21729 | return block.addInst(.{ | 21720 | return block.addInst(.{ |
| 21730 | .tag = .shuffle, | 21721 | .tag = .shuffle, |
| 21731 | .data = .{ .ty_pl = .{ | 21722 | .data = .{ .ty_pl = .{ |
| ... | @@ -21733,7 +21724,7 @@ fn analyzeShuffle( | ... | @@ -21733,7 +21724,7 @@ fn analyzeShuffle( |
| 21733 | .payload = try block.sema.addExtra(Air.Shuffle{ | 21724 | .payload = try block.sema.addExtra(Air.Shuffle{ |
| 21734 | .a = a, | 21725 | .a = a, |
| 21735 | .b = b, | 21726 | .b = b, |
| 21736 | .mask = mask_index, | 21727 | .mask = mask.toIntern(), |
| 21737 | .mask_len = mask_len, | 21728 | .mask_len = mask_len, |
| 21738 | }), | 21729 | }), |
| 21739 | } }, | 21730 | } }, |
| ... | @@ -33311,7 +33302,6 @@ pub fn getTmpAir(sema: Sema) Air { | ... | @@ -33311,7 +33302,6 @@ pub fn getTmpAir(sema: Sema) Air { |
| 33311 | return .{ | 33302 | return .{ |
| 33312 | .instructions = sema.air_instructions.slice(), | 33303 | .instructions = sema.air_instructions.slice(), |
| 33313 | .extra = sema.air_extra.items, | 33304 | .extra = sema.air_extra.items, |
| 33314 | .values = sema.air_values.items, | ||
| 33315 | }; | 33305 | }; |
| 33316 | } | 33306 | } |
| 33317 | 33307 | ||
| ... | @@ -33371,7 +33361,8 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 { | ... | @@ -33371,7 +33361,8 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 { |
| 33371 | u32 => @field(extra, field.name), | 33361 | u32 => @field(extra, field.name), |
| 33372 | Air.Inst.Ref => @enumToInt(@field(extra, field.name)), | 33362 | Air.Inst.Ref => @enumToInt(@field(extra, field.name)), |
| 33373 | i32 => @bitCast(u32, @field(extra, field.name)), | 33363 | i32 => @bitCast(u32, @field(extra, field.name)), |
| 33374 | else => @compileError("bad field type"), | 33364 | InternPool.Index => @enumToInt(@field(extra, field.name)), |
| 33365 | else => @compileError("bad field type: " ++ @typeName(field.type)), | ||
| 33375 | }); | 33366 | }); |
| 33376 | } | 33367 | } |
| 33377 | return result; | 33368 | return result; |
src/arch/aarch64/CodeGen.zig+2-2| ... | @@ -4621,9 +4621,9 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -4621,9 +4621,9 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void { |
| 4621 | } | 4621 | } |
| 4622 | 4622 | ||
| 4623 | fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void { | 4623 | fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void { |
| 4624 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 4624 | const ty_fn = self.air.instructions.items(.data)[inst].ty_fn; |
| 4625 | const mod = self.bin_file.options.module.?; | 4625 | const mod = self.bin_file.options.module.?; |
| 4626 | const function = self.air.values[ty_pl.payload].getFunction(mod).?; | 4626 | const function = mod.funcPtr(ty_fn.func); |
| 4627 | // TODO emit debug info for function change | 4627 | // TODO emit debug info for function change |
| 4628 | _ = function; | 4628 | _ = function; |
| 4629 | return self.finishAir(inst, .dead, .{ .none, .none, .none }); | 4629 | return self.finishAir(inst, .dead, .{ .none, .none, .none }); |
src/arch/arm/CodeGen.zig+2-2| ... | @@ -4568,9 +4568,9 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -4568,9 +4568,9 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void { |
| 4568 | } | 4568 | } |
| 4569 | 4569 | ||
| 4570 | fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void { | 4570 | fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void { |
| 4571 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 4571 | const ty_fn = self.air.instructions.items(.data)[inst].ty_fn; |
| 4572 | const mod = self.bin_file.options.module.?; | 4572 | const mod = self.bin_file.options.module.?; |
| 4573 | const function = self.air.values[ty_pl.payload].getFunction(mod).?; | 4573 | const function = mod.funcPtr(ty_fn.func); |
| 4574 | // TODO emit debug info for function change | 4574 | // TODO emit debug info for function change |
| 4575 | _ = function; | 4575 | _ = function; |
| 4576 | return self.finishAir(inst, .dead, .{ .none, .none, .none }); | 4576 | return self.finishAir(inst, .dead, .{ .none, .none, .none }); |
src/arch/riscv64/CodeGen.zig+2-2| ... | @@ -1875,9 +1875,9 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -1875,9 +1875,9 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void { |
| 1875 | } | 1875 | } |
| 1876 | 1876 | ||
| 1877 | fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void { | 1877 | fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void { |
| 1878 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 1878 | const ty_fn = self.air.instructions.items(.data)[inst].ty_fn; |
| 1879 | const mod = self.bin_file.options.module.?; | 1879 | const mod = self.bin_file.options.module.?; |
| 1880 | const function = self.air.values[ty_pl.payload].getFunction(mod).?; | 1880 | const function = mod.funcPtr(ty_fn.func); |
| 1881 | // TODO emit debug info for function change | 1881 | // TODO emit debug info for function change |
| 1882 | _ = function; | 1882 | _ = function; |
| 1883 | return self.finishAir(inst, .dead, .{ .none, .none, .none }); | 1883 | return self.finishAir(inst, .dead, .{ .none, .none, .none }); |
src/arch/sparc64/CodeGen.zig+2-2| ... | @@ -1660,9 +1660,9 @@ fn airDbgBlock(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -1660,9 +1660,9 @@ fn airDbgBlock(self: *Self, inst: Air.Inst.Index) !void { |
| 1660 | } | 1660 | } |
| 1661 | 1661 | ||
| 1662 | fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void { | 1662 | fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void { |
| 1663 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 1663 | const ty_fn = self.air.instructions.items(.data)[inst].ty_fn; |
| 1664 | const mod = self.bin_file.options.module.?; | 1664 | const mod = self.bin_file.options.module.?; |
| 1665 | const function = self.air.values[ty_pl.payload].getFunction(mod).?; | 1665 | const function = mod.funcPtr(ty_fn.func); |
| 1666 | // TODO emit debug info for function change | 1666 | // TODO emit debug info for function change |
| 1667 | _ = function; | 1667 | _ = function; |
| 1668 | return self.finishAir(inst, .dead, .{ .none, .none, .none }); | 1668 | return self.finishAir(inst, .dead, .{ .none, .none, .none }); |
src/arch/wasm/CodeGen.zig+1-1| ... | @@ -4947,7 +4947,7 @@ fn airShuffle(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -4947,7 +4947,7 @@ fn airShuffle(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4947 | 4947 | ||
| 4948 | const a = try func.resolveInst(extra.a); | 4948 | const a = try func.resolveInst(extra.a); |
| 4949 | const b = try func.resolveInst(extra.b); | 4949 | const b = try func.resolveInst(extra.b); |
| 4950 | const mask = func.air.values[extra.mask]; | 4950 | const mask = extra.mask.toValue(); |
| 4951 | const mask_len = extra.mask_len; | 4951 | const mask_len = extra.mask_len; |
| 4952 | 4952 | ||
| 4953 | const child_ty = inst_ty.childType(mod); | 4953 | const child_ty = inst_ty.childType(mod); |
src/arch/x86_64/CodeGen.zig+2-2| ... | @@ -8541,9 +8541,9 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -8541,9 +8541,9 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void { |
| 8541 | } | 8541 | } |
| 8542 | 8542 | ||
| 8543 | fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void { | 8543 | fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void { |
| 8544 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 8544 | const ty_fn = self.air.instructions.items(.data)[inst].ty_fn; |
| 8545 | const mod = self.bin_file.options.module.?; | 8545 | const mod = self.bin_file.options.module.?; |
| 8546 | const function = self.air.values[ty_pl.payload].getFunction(mod).?; | 8546 | const function = mod.funcPtr(ty_fn.func); |
| 8547 | // TODO emit debug info for function change | 8547 | // TODO emit debug info for function change |
| 8548 | _ = function; | 8548 | _ = function; |
| 8549 | return self.finishAir(inst, .unreach, .{ .none, .none, .none }); | 8549 | return self.finishAir(inst, .unreach, .{ .none, .none, .none }); |
src/codegen/c.zig+3-3| ... | @@ -4302,10 +4302,10 @@ fn airDbgStmt(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4302,10 +4302,10 @@ fn airDbgStmt(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4302 | } | 4302 | } |
| 4303 | 4303 | ||
| 4304 | fn airDbgInline(f: *Function, inst: Air.Inst.Index) !CValue { | 4304 | fn airDbgInline(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4305 | const ty_pl = f.air.instructions.items(.data)[inst].ty_pl; | 4305 | const ty_fn = f.air.instructions.items(.data)[inst].ty_fn; |
| 4306 | const mod = f.object.dg.module; | 4306 | const mod = f.object.dg.module; |
| 4307 | const writer = f.object.writer(); | 4307 | const writer = f.object.writer(); |
| 4308 | const function = f.air.values[ty_pl.payload].getFunction(mod).?; | 4308 | const function = mod.funcPtr(ty_fn.func); |
| 4309 | try writer.print("/* dbg func:{s} */\n", .{mod.declPtr(function.owner_decl).name}); | 4309 | try writer.print("/* dbg func:{s} */\n", .{mod.declPtr(function.owner_decl).name}); |
| 4310 | return .none; | 4310 | return .none; |
| 4311 | } | 4311 | } |
| ... | @@ -6612,7 +6612,7 @@ fn airShuffle(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6612,7 +6612,7 @@ fn airShuffle(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6612 | const ty_pl = f.air.instructions.items(.data)[inst].ty_pl; | 6612 | const ty_pl = f.air.instructions.items(.data)[inst].ty_pl; |
| 6613 | const extra = f.air.extraData(Air.Shuffle, ty_pl.payload).data; | 6613 | const extra = f.air.extraData(Air.Shuffle, ty_pl.payload).data; |
| 6614 | 6614 | ||
| 6615 | const mask = f.air.values[extra.mask]; | 6615 | const mask = extra.mask.toValue(); |
| 6616 | const lhs = try f.resolveInst(extra.a); | 6616 | const lhs = try f.resolveInst(extra.a); |
| 6617 | const rhs = try f.resolveInst(extra.b); | 6617 | const rhs = try f.resolveInst(extra.b); |
| 6618 | 6618 |
src/codegen/llvm.zig+5-5| ... | @@ -5927,10 +5927,10 @@ pub const FuncGen = struct { | ... | @@ -5927,10 +5927,10 @@ pub const FuncGen = struct { |
| 5927 | 5927 | ||
| 5928 | fn airDbgInlineBegin(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value { | 5928 | fn airDbgInlineBegin(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value { |
| 5929 | const dib = self.dg.object.di_builder orelse return null; | 5929 | const dib = self.dg.object.di_builder orelse return null; |
| 5930 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 5930 | const ty_fn = self.air.instructions.items(.data)[inst].ty_fn; |
| 5931 | 5931 | ||
| 5932 | const mod = self.dg.module; | 5932 | const mod = self.dg.module; |
| 5933 | const func = self.air.values[ty_pl.payload].getFunction(mod).?; | 5933 | const func = mod.funcPtr(ty_fn.func); |
| 5934 | const decl_index = func.owner_decl; | 5934 | const decl_index = func.owner_decl; |
| 5935 | const decl = mod.declPtr(decl_index); | 5935 | const decl = mod.declPtr(decl_index); |
| 5936 | const di_file = try self.dg.object.getDIFile(self.gpa, mod.namespacePtr(decl.src_namespace).file_scope); | 5936 | const di_file = try self.dg.object.getDIFile(self.gpa, mod.namespacePtr(decl.src_namespace).file_scope); |
| ... | @@ -5986,10 +5986,10 @@ pub const FuncGen = struct { | ... | @@ -5986,10 +5986,10 @@ pub const FuncGen = struct { |
| 5986 | 5986 | ||
| 5987 | fn airDbgInlineEnd(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value { | 5987 | fn airDbgInlineEnd(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value { |
| 5988 | if (self.dg.object.di_builder == null) return null; | 5988 | if (self.dg.object.di_builder == null) return null; |
| 5989 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 5989 | const ty_fn = self.air.instructions.items(.data)[inst].ty_fn; |
| 5990 | 5990 | ||
| 5991 | const mod = self.dg.module; | 5991 | const mod = self.dg.module; |
| 5992 | const func = self.air.values[ty_pl.payload].getFunction(mod).?; | 5992 | const func = mod.funcPtr(ty_fn.func); |
| 5993 | const decl = mod.declPtr(func.owner_decl); | 5993 | const decl = mod.declPtr(func.owner_decl); |
| 5994 | const di_file = try self.dg.object.getDIFile(self.gpa, mod.namespacePtr(decl.src_namespace).file_scope); | 5994 | const di_file = try self.dg.object.getDIFile(self.gpa, mod.namespacePtr(decl.src_namespace).file_scope); |
| 5995 | self.di_file = di_file; | 5995 | self.di_file = di_file; |
| ... | @@ -8875,7 +8875,7 @@ pub const FuncGen = struct { | ... | @@ -8875,7 +8875,7 @@ pub const FuncGen = struct { |
| 8875 | const extra = self.air.extraData(Air.Shuffle, ty_pl.payload).data; | 8875 | const extra = self.air.extraData(Air.Shuffle, ty_pl.payload).data; |
| 8876 | const a = try self.resolveInst(extra.a); | 8876 | const a = try self.resolveInst(extra.a); |
| 8877 | const b = try self.resolveInst(extra.b); | 8877 | const b = try self.resolveInst(extra.b); |
| 8878 | const mask = self.air.values[extra.mask]; | 8878 | const mask = extra.mask.toValue(); |
| 8879 | const mask_len = extra.mask_len; | 8879 | const mask_len = extra.mask_len; |
| 8880 | const a_len = self.typeOf(extra.a).vectorLen(mod); | 8880 | const a_len = self.typeOf(extra.a).vectorLen(mod); |
| 8881 | 8881 |
src/codegen/spirv.zig+1-1| ... | @@ -2074,7 +2074,7 @@ pub const DeclGen = struct { | ... | @@ -2074,7 +2074,7 @@ pub const DeclGen = struct { |
| 2074 | const extra = self.air.extraData(Air.Shuffle, ty_pl.payload).data; | 2074 | const extra = self.air.extraData(Air.Shuffle, ty_pl.payload).data; |
| 2075 | const a = try self.resolve(extra.a); | 2075 | const a = try self.resolve(extra.a); |
| 2076 | const b = try self.resolve(extra.b); | 2076 | const b = try self.resolve(extra.b); |
| 2077 | const mask = self.air.values[extra.mask]; | 2077 | const mask = extra.mask.toValue(); |
| 2078 | const mask_len = extra.mask_len; | 2078 | const mask_len = extra.mask_len; |
| 2079 | const a_len = self.typeOf(extra.a).vectorLen(mod); | 2079 | const a_len = self.typeOf(extra.a).vectorLen(mod); |
| 2080 | 2080 |
src/print_air.zig+6-16| ... | @@ -15,12 +15,11 @@ pub fn write(stream: anytype, module: *Module, air: Air, liveness: ?Liveness) vo | ... | @@ -15,12 +15,11 @@ pub fn write(stream: anytype, module: *Module, air: Air, liveness: ?Liveness) vo |
| 15 | // the debug safety tag but we want to measure release size. | 15 | // the debug safety tag but we want to measure release size. |
| 16 | (@sizeOf(Air.Inst.Tag) + 8); | 16 | (@sizeOf(Air.Inst.Tag) + 8); |
| 17 | const extra_bytes = air.extra.len * @sizeOf(u32); | 17 | const extra_bytes = air.extra.len * @sizeOf(u32); |
| 18 | const values_bytes = air.values.len * @sizeOf(Value); | ||
| 19 | const tomb_bytes = if (liveness) |l| l.tomb_bits.len * @sizeOf(usize) else 0; | 18 | const tomb_bytes = if (liveness) |l| l.tomb_bits.len * @sizeOf(usize) else 0; |
| 20 | const liveness_extra_bytes = if (liveness) |l| l.extra.len * @sizeOf(u32) else 0; | 19 | const liveness_extra_bytes = if (liveness) |l| l.extra.len * @sizeOf(u32) else 0; |
| 21 | const liveness_special_bytes = if (liveness) |l| l.special.count() * 8 else 0; | 20 | const liveness_special_bytes = if (liveness) |l| l.special.count() * 8 else 0; |
| 22 | const total_bytes = @sizeOf(Air) + instruction_bytes + extra_bytes + | 21 | const total_bytes = @sizeOf(Air) + instruction_bytes + extra_bytes + |
| 23 | values_bytes + @sizeOf(Liveness) + liveness_extra_bytes + | 22 | @sizeOf(Liveness) + liveness_extra_bytes + |
| 24 | liveness_special_bytes + tomb_bytes; | 23 | liveness_special_bytes + tomb_bytes; |
| 25 | 24 | ||
| 26 | // zig fmt: off | 25 | // zig fmt: off |
| ... | @@ -28,7 +27,6 @@ pub fn write(stream: anytype, module: *Module, air: Air, liveness: ?Liveness) vo | ... | @@ -28,7 +27,6 @@ pub fn write(stream: anytype, module: *Module, air: Air, liveness: ?Liveness) vo |
| 28 | \\# Total AIR+Liveness bytes: {} | 27 | \\# Total AIR+Liveness bytes: {} |
| 29 | \\# AIR Instructions: {d} ({}) | 28 | \\# AIR Instructions: {d} ({}) |
| 30 | \\# AIR Extra Data: {d} ({}) | 29 | \\# AIR Extra Data: {d} ({}) |
| 31 | \\# AIR Values Bytes: {d} ({}) | ||
| 32 | \\# Liveness tomb_bits: {} | 30 | \\# Liveness tomb_bits: {} |
| 33 | \\# Liveness Extra Data: {d} ({}) | 31 | \\# Liveness Extra Data: {d} ({}) |
| 34 | \\# Liveness special table: {d} ({}) | 32 | \\# Liveness special table: {d} ({}) |
| ... | @@ -37,7 +35,6 @@ pub fn write(stream: anytype, module: *Module, air: Air, liveness: ?Liveness) vo | ... | @@ -37,7 +35,6 @@ pub fn write(stream: anytype, module: *Module, air: Air, liveness: ?Liveness) vo |
| 37 | fmtIntSizeBin(total_bytes), | 35 | fmtIntSizeBin(total_bytes), |
| 38 | air.instructions.len, fmtIntSizeBin(instruction_bytes), | 36 | air.instructions.len, fmtIntSizeBin(instruction_bytes), |
| 39 | air.extra.len, fmtIntSizeBin(extra_bytes), | 37 | air.extra.len, fmtIntSizeBin(extra_bytes), |
| 40 | air.values.len, fmtIntSizeBin(values_bytes), | ||
| 41 | fmtIntSizeBin(tomb_bytes), | 38 | fmtIntSizeBin(tomb_bytes), |
| 42 | if (liveness) |l| l.extra.len else 0, fmtIntSizeBin(liveness_extra_bytes), | 39 | if (liveness) |l| l.extra.len else 0, fmtIntSizeBin(liveness_extra_bytes), |
| 43 | if (liveness) |l| l.special.count() else 0, fmtIntSizeBin(liveness_special_bytes), | 40 | if (liveness) |l| l.special.count() else 0, fmtIntSizeBin(liveness_special_bytes), |
| ... | @@ -300,7 +297,8 @@ const Writer = struct { | ... | @@ -300,7 +297,8 @@ const Writer = struct { |
| 300 | 297 | ||
| 301 | .struct_field_ptr => try w.writeStructField(s, inst), | 298 | .struct_field_ptr => try w.writeStructField(s, inst), |
| 302 | .struct_field_val => try w.writeStructField(s, inst), | 299 | .struct_field_val => try w.writeStructField(s, inst), |
| 303 | .inferred_alloc, .inferred_alloc_comptime => try w.writeConstant(s, inst), | 300 | .inferred_alloc => @panic("TODO"), |
| 301 | .inferred_alloc_comptime => @panic("TODO"), | ||
| 304 | .interned => try w.writeInterned(s, inst), | 302 | .interned => try w.writeInterned(s, inst), |
| 305 | .assembly => try w.writeAssembly(s, inst), | 303 | .assembly => try w.writeAssembly(s, inst), |
| 306 | .dbg_stmt => try w.writeDbgStmt(s, inst), | 304 | .dbg_stmt => try w.writeDbgStmt(s, inst), |
| ... | @@ -598,14 +596,6 @@ const Writer = struct { | ... | @@ -598,14 +596,6 @@ const Writer = struct { |
| 598 | try s.print(", {d}", .{extra.field_index}); | 596 | try s.print(", {d}", .{extra.field_index}); |
| 599 | } | 597 | } |
| 600 | 598 | ||
| 601 | fn writeConstant(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | ||
| 602 | const ty_pl = w.air.instructions.items(.data)[inst].ty_pl; | ||
| 603 | const val = w.air.values[ty_pl.payload]; | ||
| 604 | const ty = w.air.getRefType(ty_pl.ty); | ||
| 605 | try w.writeType(s, ty); | ||
| 606 | try s.print(", {}", .{val.fmtValue(ty, w.module)}); | ||
| 607 | } | ||
| 608 | |||
| 609 | fn writeInterned(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 599 | fn writeInterned(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |
| 610 | const mod = w.module; | 600 | const mod = w.module; |
| 611 | const ip_index = w.air.instructions.items(.data)[inst].interned; | 601 | const ip_index = w.air.instructions.items(.data)[inst].interned; |
| ... | @@ -693,9 +683,9 @@ const Writer = struct { | ... | @@ -693,9 +683,9 @@ const Writer = struct { |
| 693 | } | 683 | } |
| 694 | 684 | ||
| 695 | fn writeDbgInline(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 685 | fn writeDbgInline(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |
| 696 | const ty_pl = w.air.instructions.items(.data)[inst].ty_pl; | 686 | const ty_fn = w.air.instructions.items(.data)[inst].ty_fn; |
| 697 | const func_index = w.module.intern_pool.indexToFunc(w.air.values[ty_pl.payload].ip_index); | 687 | const func_index = ty_fn.func; |
| 698 | const owner_decl = w.module.declPtr(w.module.funcPtrUnwrap(func_index).?.owner_decl); | 688 | const owner_decl = w.module.declPtr(w.module.funcPtr(func_index).owner_decl); |
| 699 | try s.print("{s}", .{owner_decl.name}); | 689 | try s.print("{s}", .{owner_decl.name}); |
| 700 | } | 690 | } |
| 701 | 691 |