aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-03-18 22:48:28 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-03-18 22:48:28 -0700
commitbd2154da3d90daa4520ee7ef69dac42f9049ed92 (patch)
tree2b541e218121779de830b7d372975c790b469014 /src/codegen.zig
parentb2682237dbe90306b569cb36914f8823cd7b0431 (diff)
downloadzig-bd2154da3d90daa4520ee7ef69dac42f9049ed92.tar.gz
zig-bd2154da3d90daa4520ee7ef69dac42f9049ed92.zip
stage2: the code is compiling again
(with a lot of things commented out)
Diffstat (limited to 'src/codegen.zig')
-rw-r--r--src/codegen.zig14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/codegen.zig b/src/codegen.zig
index 45d66b2767..6649226426 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -792,8 +792,8 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
}
}
- fn dbgAdvancePCAndLine(self: *Self, src: usize) InnerError!void {
- self.prev_di_src = src;
+ fn dbgAdvancePCAndLine(self: *Self, abs_byte_off: usize) InnerError!void {
+ self.prev_di_src = abs_byte_off;
self.prev_di_pc = self.code.items.len;
switch (self.debug_output) {
.dwarf => |dbg_out| {
@@ -801,7 +801,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
// lookup table, and changing ir.Inst from storing byte offset to token. Currently
// this involves scanning over the source code for newlines
// (but only from the previous byte offset to the new one).
- const delta_line = std.zig.lineDelta(self.source, self.prev_di_src, src);
+ const delta_line = std.zig.lineDelta(self.source, self.prev_di_src, abs_byte_off);
const delta_pc = self.code.items.len - self.prev_di_pc;
// TODO Look into using the DWARF special opcodes to compress this data. It lets you emit
// single-byte opcodes that add different numbers to both the PC and the line number
@@ -2315,8 +2315,12 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
}
}
- fn genDbgStmt(self: *Self, inst: *ir.Inst.NoOp) !MCValue {
- try self.dbgAdvancePCAndLine(inst.base.src);
+ fn genDbgStmt(self: *Self, inst: *ir.Inst.DbgStmt) !MCValue {
+ // TODO when reworking tzir 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.byte_offset);
assert(inst.base.isUnused());
return MCValue.dead;
}