diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-07-10 16:24:35 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-07-20 12:18:14 -0700 |
| commit | 3c3abaf3907e344305620fb4565e7c1acb0a9c88 (patch) | |
| tree | d418d08645bf500bb30e3b3b388dbfa4a21e4aec /src/codegen.zig | |
| parent | 5d6f7b44c19b064a543b0c1eecb6ef5c671b612e (diff) | |
| download | zig-3c3abaf3907e344305620fb4565e7c1acb0a9c88.tar.gz zig-3c3abaf3907e344305620fb4565e7c1acb0a9c88.zip | |
stage2: update liveness analysis to new AIR memory layout
It's pretty compact, with each AIR instruction only taking up 4 bits,
plus a sparse table for special instructions such as conditional branch,
switch branch, and function calls with more than 2 arguments.
Diffstat (limited to 'src/codegen.zig')
| -rw-r--r-- | src/codegen.zig | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/codegen.zig b/src/codegen.zig index 205bab755a..91b0401291 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -297,7 +297,8 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { /// across each runtime branch upon joining. branch_stack: *std.ArrayList(Branch), - blocks: std.AutoHashMapUnmanaged(*ir.Inst.Block, BlockData) = .{}, + // Key is the block instruction + blocks: std.AutoHashMapUnmanaged(Air.Inst.Index, BlockData) = .{}, register_manager: RegisterManager(Self, Register, &callee_preserved_regs) = .{}, /// Maps offset to what is stored there. @@ -383,7 +384,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { }; const Branch = struct { - inst_table: std.AutoArrayHashMapUnmanaged(*ir.Inst, MCValue) = .{}, + inst_table: std.AutoArrayHashMapUnmanaged(Air.Inst.Index, MCValue) = .{}, fn deinit(self: *Branch, gpa: *Allocator) void { self.inst_table.deinit(gpa); @@ -392,7 +393,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { }; const StackAllocation = struct { - inst: *ir.Inst, + inst: Air.Inst.Index, /// TODO do we need size? should be determined by inst.ty.abiSize() size: u32, }; @@ -720,7 +721,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { try self.dbgAdvancePCAndLine(self.end_di_line, self.end_di_column); } - fn genBody(self: *Self, body: ir.Body) InnerError!void { + fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { for (body.instructions) |inst| { try self.ensureProcessDeathCapacity(@popCount(@TypeOf(inst.deaths), inst.deaths)); @@ -2824,10 +2825,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } fn genDbgStmt(self: *Self, inst: *ir.Inst.DbgStmt) !MCValue { - // TODO when reworking AIR memory layout, rework source locations here as - // well to be more efficient, as well as support inlined function calls correctly. - // For now we convert LazySrcLoc to absolute byte offset, to match what the - // existing codegen code expects. try self.dbgAdvancePCAndLine(inst.line, inst.column); assert(inst.base.isUnused()); return MCValue.dead; |
