aboutsummaryrefslogtreecommitdiff
path: root/src/arch/aarch64/CodeGen.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/aarch64/CodeGen.zig')
-rw-r--r--src/arch/aarch64/CodeGen.zig71
1 files changed, 32 insertions, 39 deletions
diff --git a/src/arch/aarch64/CodeGen.zig b/src/arch/aarch64/CodeGen.zig
index 00cceb0c67..4aaf6bf85c 100644
--- a/src/arch/aarch64/CodeGen.zig
+++ b/src/arch/aarch64/CodeGen.zig
@@ -49,7 +49,6 @@ pt: Zcu.PerThread,
air: Air,
liveness: Air.Liveness,
bin_file: *link.File,
-debug_output: link.File.DebugInfoOutput,
target: *const std.Target,
func_index: InternPool.Index,
owner_nav: InternPool.Nav.Index,
@@ -185,6 +184,9 @@ const DbgInfoReloc = struct {
}
fn genArgDbgInfo(reloc: DbgInfoReloc, function: Self) !void {
+ // TODO: Add a pseudo-instruction or something to defer this work until Emit.
+ // We aren't allowed to interact with linker state here.
+ if (true) return;
switch (function.debug_output) {
.dwarf => |dw| {
const loc: link.File.Dwarf.Loc = switch (reloc.mcv) {
@@ -213,6 +215,9 @@ const DbgInfoReloc = struct {
}
fn genVarDbgInfo(reloc: DbgInfoReloc, function: Self) !void {
+ // TODO: Add a pseudo-instruction or something to defer this work until Emit.
+ // We aren't allowed to interact with linker state here.
+ if (true) return;
switch (function.debug_output) {
.dwarf => |dwarf| {
const loc: link.File.Dwarf.Loc = switch (reloc.mcv) {
@@ -326,11 +331,9 @@ pub fn generate(
pt: Zcu.PerThread,
src_loc: Zcu.LazySrcLoc,
func_index: InternPool.Index,
- air: Air,
- liveness: Air.Liveness,
- code: *std.ArrayListUnmanaged(u8),
- debug_output: link.File.DebugInfoOutput,
-) CodeGenError!void {
+ air: *const Air,
+ liveness: *const Air.Liveness,
+) CodeGenError!Mir {
const zcu = pt.zcu;
const gpa = zcu.gpa;
const func = zcu.funcInfo(func_index);
@@ -349,9 +352,8 @@ pub fn generate(
var function: Self = .{
.gpa = gpa,
.pt = pt,
- .air = air,
- .liveness = liveness,
- .debug_output = debug_output,
+ .air = air.*,
+ .liveness = liveness.*,
.target = target,
.bin_file = lf,
.func_index = func_index,
@@ -395,29 +397,13 @@ pub fn generate(
var mir: Mir = .{
.instructions = function.mir_instructions.toOwnedSlice(),
- .extra = try function.mir_extra.toOwnedSlice(gpa),
- };
- defer mir.deinit(gpa);
-
- var emit: Emit = .{
- .mir = mir,
- .bin_file = lf,
- .debug_output = debug_output,
- .target = target,
- .src_loc = src_loc,
- .code = code,
- .prev_di_pc = 0,
- .prev_di_line = func.lbrace_line,
- .prev_di_column = func.lbrace_column,
- .stack_size = function.max_end_stack,
+ .extra = &.{}, // fallible, so assign after errdefer
+ .max_end_stack = function.max_end_stack,
.saved_regs_stack_space = function.saved_regs_stack_space,
};
- defer emit.deinit();
-
- emit.emitMir() catch |err| switch (err) {
- error.EmitFail => return function.failMsg(emit.err_msg.?),
- else => |e| return e,
- };
+ errdefer mir.deinit(gpa);
+ mir.extra = try function.mir_extra.toOwnedSlice(gpa);
+ return mir;
}
fn addInst(self: *Self, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index {
@@ -4222,15 +4208,22 @@ fn airArg(self: *Self, inst: Air.Inst.Index) InnerError!void {
while (self.args[arg_index] == .none) arg_index += 1;
self.arg_index = arg_index + 1;
- const ty = self.typeOfIndex(inst);
- const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
- const name = self.air.instructions.items(.data)[@intFromEnum(inst)].arg.name;
- if (name != .none) try self.dbg_info_relocs.append(self.gpa, .{
- .tag = tag,
- .ty = ty,
- .name = name.toSlice(self.air),
- .mcv = self.args[arg_index],
- });
+ const zcu = self.pt.zcu;
+ const func_zir = zcu.funcInfo(self.func_index).zir_body_inst.resolveFull(&zcu.intern_pool).?;
+ const file = zcu.fileByIndex(func_zir.file);
+ if (!file.mod.?.strip) {
+ const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
+ const arg = self.air.instructions.items(.data)[@intFromEnum(inst)].arg;
+ const ty = self.typeOfIndex(inst);
+ const zir = &file.zir.?;
+ const name = zir.nullTerminatedString(zir.getParamName(zir.getParamBody(func_zir.inst)[arg.zir_param_index]).?);
+ try self.dbg_info_relocs.append(self.gpa, .{
+ .tag = tag,
+ .ty = ty,
+ .name = name,
+ .mcv = self.args[arg_index],
+ });
+ }
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else self.args[arg_index];
return self.finishAir(inst, result, .{ .none, .none, .none });