| author | |
| committer | |
| log | 5ab307cf47b1f0418d9ed4ab56df6fb798305c20 |
| tree | e6efda29764d1fdaa92c40cce951f13c394facba |
| parent | 9eb400ef19391261a3b61129d8665602c89959c5 |
| signature |
As of this commit, every backend other than self-hosted Wasm and
self-hosted SPIR-V compiles and (at least somewhat) functions again.
Those two backends are currently disabled with panics.
Note that `Zcu.Feature.separate_thread` is *not* enabled for the fixed
backends. Avoiding linker references from codegen is a non-trivial task,
and can be done after this branch.25 files changed, 402 insertions(+), 251 deletions(-)
src/Compilation.zig+5-3| ... | ... | @@ -4550,8 +4550,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void { |
| 4550 | 4550 | air.deinit(gpa); |
| 4551 | 4551 | return; |
| 4552 | 4552 | } |
| 4553 | const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid)); | |
| 4554 | defer pt.deactivate(); | |
| 4555 | 4553 | const shared_mir = try gpa.create(link.ZcuTask.LinkFunc.SharedMir); |
| 4556 | 4554 | shared_mir.* = .{ |
| 4557 | 4555 | .status = .init(.pending), |
| ... | ... | @@ -4567,7 +4565,11 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void { |
| 4567 | 4565 | } }); |
| 4568 | 4566 | } else { |
| 4569 | 4567 | const emit_needs_air = !zcu.backendSupportsFeature(.separate_thread); |
| 4570 | pt.runCodegen(func.func, &air, shared_mir); | |
| 4568 | { | |
| 4569 | const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid)); | |
| 4570 | defer pt.deactivate(); | |
| 4571 | pt.runCodegen(func.func, &air, shared_mir); | |
| 4572 | } | |
| 4571 | 4573 | assert(shared_mir.status.load(.monotonic) != .pending); |
| 4572 | 4574 | comp.dispatchZcuLinkTask(tid, .{ .link_func = .{ |
| 4573 | 4575 | .func = func.func, |
src/Zcu/PerThread.zig+22-6| ... | ... | @@ -4376,26 +4376,40 @@ pub fn addDependency(pt: Zcu.PerThread, unit: AnalUnit, dependee: InternPool.Dep |
| 4376 | 4376 | /// other code. This function is currently run either on the main thread, or on a separate |
| 4377 | 4377 | /// codegen thread, depending on whether the backend supports `Zcu.Feature.separate_thread`. |
| 4378 | 4378 | pub fn runCodegen(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air, out: *@import("../link.zig").ZcuTask.LinkFunc.SharedMir) void { |
| 4379 | const zcu = pt.zcu; | |
| 4379 | 4380 | if (runCodegenInner(pt, func_index, air)) |mir| { |
| 4380 | 4381 | out.value = mir; |
| 4381 | 4382 | out.status.store(.ready, .release); |
| 4382 | 4383 | } else |err| switch (err) { |
| 4383 | 4384 | error.OutOfMemory => { |
| 4384 | pt.zcu.comp.setAllocFailure(); | |
| 4385 | zcu.comp.setAllocFailure(); | |
| 4385 | 4386 | out.status.store(.failed, .monotonic); |
| 4386 | 4387 | }, |
| 4387 | 4388 | error.CodegenFail => { |
| 4388 | pt.zcu.assertCodegenFailed(pt.zcu.funcInfo(func_index).owner_nav); | |
| 4389 | zcu.assertCodegenFailed(zcu.funcInfo(func_index).owner_nav); | |
| 4389 | 4390 | out.status.store(.failed, .monotonic); |
| 4390 | 4391 | }, |
| 4391 | 4392 | error.NoLinkFile => { |
| 4392 | assert(pt.zcu.comp.bin_file == null); | |
| 4393 | assert(zcu.comp.bin_file == null); | |
| 4394 | out.status.store(.failed, .monotonic); | |
| 4395 | }, | |
| 4396 | error.BackendDoesNotProduceMir => { | |
| 4397 | const backend = target_util.zigBackend(zcu.root_mod.resolved_target.result, zcu.comp.config.use_llvm); | |
| 4398 | switch (backend) { | |
| 4399 | else => unreachable, // assertion failure | |
| 4400 | .stage2_llvm => {}, | |
| 4401 | } | |
| 4393 | 4402 | out.status.store(.failed, .monotonic); |
| 4394 | 4403 | }, |
| 4395 | 4404 | } |
| 4396 | pt.zcu.comp.link_task_queue.mirReady(pt.zcu.comp, out); | |
| 4405 | zcu.comp.link_task_queue.mirReady(zcu.comp, out); | |
| 4397 | 4406 | } |
| 4398 | fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) error{ OutOfMemory, CodegenFail, NoLinkFile }!codegen.AnyMir { | |
| 4407 | fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) error{ | |
| 4408 | OutOfMemory, | |
| 4409 | CodegenFail, | |
| 4410 | NoLinkFile, | |
| 4411 | BackendDoesNotProduceMir, | |
| 4412 | }!codegen.AnyMir { | |
| 4399 | 4413 | const zcu = pt.zcu; |
| 4400 | 4414 | const gpa = zcu.gpa; |
| 4401 | 4415 | const ip = &zcu.intern_pool; |
| ... | ... | @@ -4441,7 +4455,9 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e |
| 4441 | 4455 | // "emit" step because LLVM does not support incremental linking. Our linker (LLD or self-hosted) |
| 4442 | 4456 | // will just see the ZCU object file which LLVM ultimately emits. |
| 4443 | 4457 | if (zcu.llvm_object) |llvm_object| { |
| 4444 | return llvm_object.updateFunc(pt, func_index, air, &liveness); | |
| 4458 | assert(pt.tid == .main); // LLVM has a lot of shared state | |
| 4459 | try llvm_object.updateFunc(pt, func_index, air, &liveness); | |
| 4460 | return error.BackendDoesNotProduceMir; | |
| 4445 | 4461 | } |
| 4446 | 4462 | |
| 4447 | 4463 | const lf = comp.bin_file orelse return error.NoLinkFile; |
src/arch/aarch64/CodeGen.zig+16-30| ... | ... | @@ -49,7 +49,6 @@ pt: Zcu.PerThread, |
| 49 | 49 | air: Air, |
| 50 | 50 | liveness: Air.Liveness, |
| 51 | 51 | bin_file: *link.File, |
| 52 | debug_output: link.File.DebugInfoOutput, | |
| 53 | 52 | target: *const std.Target, |
| 54 | 53 | func_index: InternPool.Index, |
| 55 | 54 | owner_nav: InternPool.Nav.Index, |
| ... | ... | @@ -185,6 +184,9 @@ const DbgInfoReloc = struct { |
| 185 | 184 | } |
| 186 | 185 | |
| 187 | 186 | fn genArgDbgInfo(reloc: DbgInfoReloc, function: Self) !void { |
| 187 | // TODO: Add a pseudo-instruction or something to defer this work until Emit. | |
| 188 | // We aren't allowed to interact with linker state here. | |
| 189 | if (true) return; | |
| 188 | 190 | switch (function.debug_output) { |
| 189 | 191 | .dwarf => |dw| { |
| 190 | 192 | const loc: link.File.Dwarf.Loc = switch (reloc.mcv) { |
| ... | ... | @@ -213,6 +215,9 @@ const DbgInfoReloc = struct { |
| 213 | 215 | } |
| 214 | 216 | |
| 215 | 217 | fn genVarDbgInfo(reloc: DbgInfoReloc, function: Self) !void { |
| 218 | // TODO: Add a pseudo-instruction or something to defer this work until Emit. | |
| 219 | // We aren't allowed to interact with linker state here. | |
| 220 | if (true) return; | |
| 216 | 221 | switch (function.debug_output) { |
| 217 | 222 | .dwarf => |dwarf| { |
| 218 | 223 | const loc: link.File.Dwarf.Loc = switch (reloc.mcv) { |
| ... | ... | @@ -326,11 +331,9 @@ pub fn generate( |
| 326 | 331 | pt: Zcu.PerThread, |
| 327 | 332 | src_loc: Zcu.LazySrcLoc, |
| 328 | 333 | func_index: InternPool.Index, |
| 329 | air: Air, | |
| 330 | liveness: Air.Liveness, | |
| 331 | code: *std.ArrayListUnmanaged(u8), | |
| 332 | debug_output: link.File.DebugInfoOutput, | |
| 333 | ) CodeGenError!void { | |
| 334 | air: *const Air, | |
| 335 | liveness: *const Air.Liveness, | |
| 336 | ) CodeGenError!Mir { | |
| 334 | 337 | const zcu = pt.zcu; |
| 335 | 338 | const gpa = zcu.gpa; |
| 336 | 339 | const func = zcu.funcInfo(func_index); |
| ... | ... | @@ -349,9 +352,8 @@ pub fn generate( |
| 349 | 352 | var function: Self = .{ |
| 350 | 353 | .gpa = gpa, |
| 351 | 354 | .pt = pt, |
| 352 | .air = air, | |
| 353 | .liveness = liveness, | |
| 354 | .debug_output = debug_output, | |
| 355 | .air = air.*, | |
| 356 | .liveness = liveness.*, | |
| 355 | 357 | .target = target, |
| 356 | 358 | .bin_file = lf, |
| 357 | 359 | .func_index = func_index, |
| ... | ... | @@ -395,29 +397,13 @@ pub fn generate( |
| 395 | 397 | |
| 396 | 398 | var mir: Mir = .{ |
| 397 | 399 | .instructions = function.mir_instructions.toOwnedSlice(), |
| 398 | .extra = try function.mir_extra.toOwnedSlice(gpa), | |
| 399 | }; | |
| 400 | defer mir.deinit(gpa); | |
| 401 | ||
| 402 | var emit: Emit = .{ | |
| 403 | .mir = mir, | |
| 404 | .bin_file = lf, | |
| 405 | .debug_output = debug_output, | |
| 406 | .target = target, | |
| 407 | .src_loc = src_loc, | |
| 408 | .code = code, | |
| 409 | .prev_di_pc = 0, | |
| 410 | .prev_di_line = func.lbrace_line, | |
| 411 | .prev_di_column = func.lbrace_column, | |
| 412 | .stack_size = function.max_end_stack, | |
| 400 | .extra = &.{}, // fallible, so assign after errdefer | |
| 401 | .max_end_stack = function.max_end_stack, | |
| 413 | 402 | .saved_regs_stack_space = function.saved_regs_stack_space, |
| 414 | 403 | }; |
| 415 | defer emit.deinit(); | |
| 416 | ||
| 417 | emit.emitMir() catch |err| switch (err) { | |
| 418 | error.EmitFail => return function.failMsg(emit.err_msg.?), | |
| 419 | else => |e| return e, | |
| 420 | }; | |
| 404 | errdefer mir.deinit(gpa); | |
| 405 | mir.extra = try function.mir_extra.toOwnedSlice(gpa); | |
| 406 | return mir; | |
| 421 | 407 | } |
| 422 | 408 | |
| 423 | 409 | fn addInst(self: *Self, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index { |
src/arch/aarch64/Mir.zig+43| ... | ... | @@ -13,6 +13,14 @@ const assert = std.debug.assert; |
| 13 | 13 | |
| 14 | 14 | const bits = @import("bits.zig"); |
| 15 | 15 | const Register = bits.Register; |
| 16 | const InternPool = @import("../../InternPool.zig"); | |
| 17 | const Emit = @import("Emit.zig"); | |
| 18 | const codegen = @import("../../codegen.zig"); | |
| 19 | const link = @import("../../link.zig"); | |
| 20 | const Zcu = @import("../../Zcu.zig"); | |
| 21 | ||
| 22 | max_end_stack: u32, | |
| 23 | saved_regs_stack_space: u32, | |
| 16 | 24 | |
| 17 | 25 | instructions: std.MultiArrayList(Inst).Slice, |
| 18 | 26 | /// The meaning of this data is determined by `Inst.Tag` value. |
| ... | ... | @@ -498,6 +506,41 @@ pub fn deinit(mir: *Mir, gpa: std.mem.Allocator) void { |
| 498 | 506 | mir.* = undefined; |
| 499 | 507 | } |
| 500 | 508 | |
| 509 | pub fn emit( | |
| 510 | mir: Mir, | |
| 511 | lf: *link.File, | |
| 512 | pt: Zcu.PerThread, | |
| 513 | src_loc: Zcu.LazySrcLoc, | |
| 514 | func_index: InternPool.Index, | |
| 515 | code: *std.ArrayListUnmanaged(u8), | |
| 516 | debug_output: link.File.DebugInfoOutput, | |
| 517 | air: *const @import("../../Air.zig"), | |
| 518 | ) codegen.CodeGenError!void { | |
| 519 | _ = air; // using this would be a bug | |
| 520 | const zcu = pt.zcu; | |
| 521 | const func = zcu.funcInfo(func_index); | |
| 522 | const nav = func.owner_nav; | |
| 523 | const mod = zcu.navFileScope(nav).mod.?; | |
| 524 | var e: Emit = .{ | |
| 525 | .mir = mir, | |
| 526 | .bin_file = lf, | |
| 527 | .debug_output = debug_output, | |
| 528 | .target = &mod.resolved_target.result, | |
| 529 | .src_loc = src_loc, | |
| 530 | .code = code, | |
| 531 | .prev_di_pc = 0, | |
| 532 | .prev_di_line = func.lbrace_line, | |
| 533 | .prev_di_column = func.lbrace_column, | |
| 534 | .stack_size = mir.max_end_stack, | |
| 535 | .saved_regs_stack_space = mir.saved_regs_stack_space, | |
| 536 | }; | |
| 537 | defer e.deinit(); | |
| 538 | e.emitMir() catch |err| switch (err) { | |
| 539 | error.EmitFail => return zcu.codegenFailMsg(nav, e.err_msg.?), | |
| 540 | else => |e1| return e1, | |
| 541 | }; | |
| 542 | } | |
| 543 | ||
| 501 | 544 | /// Returns the requested data, as well as the new index which is at the start of the |
| 502 | 545 | /// trailers for the object. |
| 503 | 546 | pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end: usize } { |
src/arch/arm/CodeGen.zig+17-31| ... | ... | @@ -50,7 +50,6 @@ pt: Zcu.PerThread, |
| 50 | 50 | air: Air, |
| 51 | 51 | liveness: Air.Liveness, |
| 52 | 52 | bin_file: *link.File, |
| 53 | debug_output: link.File.DebugInfoOutput, | |
| 54 | 53 | target: *const std.Target, |
| 55 | 54 | func_index: InternPool.Index, |
| 56 | 55 | err_msg: ?*ErrorMsg, |
| ... | ... | @@ -264,6 +263,9 @@ const DbgInfoReloc = struct { |
| 264 | 263 | } |
| 265 | 264 | |
| 266 | 265 | fn genArgDbgInfo(reloc: DbgInfoReloc, function: Self) !void { |
| 266 | // TODO: Add a pseudo-instruction or something to defer this work until Emit. | |
| 267 | // We aren't allowed to interact with linker state here. | |
| 268 | if (true) return; | |
| 267 | 269 | switch (function.debug_output) { |
| 268 | 270 | .dwarf => |dw| { |
| 269 | 271 | const loc: link.File.Dwarf.Loc = switch (reloc.mcv) { |
| ... | ... | @@ -292,6 +294,9 @@ const DbgInfoReloc = struct { |
| 292 | 294 | } |
| 293 | 295 | |
| 294 | 296 | fn genVarDbgInfo(reloc: DbgInfoReloc, function: Self) !void { |
| 297 | // TODO: Add a pseudo-instruction or something to defer this work until Emit. | |
| 298 | // We aren't allowed to interact with linker state here. | |
| 299 | if (true) return; | |
| 295 | 300 | switch (function.debug_output) { |
| 296 | 301 | .dwarf => |dw| { |
| 297 | 302 | const loc: link.File.Dwarf.Loc = switch (reloc.mcv) { |
| ... | ... | @@ -335,11 +340,9 @@ pub fn generate( |
| 335 | 340 | pt: Zcu.PerThread, |
| 336 | 341 | src_loc: Zcu.LazySrcLoc, |
| 337 | 342 | func_index: InternPool.Index, |
| 338 | air: Air, | |
| 339 | liveness: Air.Liveness, | |
| 340 | code: *std.ArrayListUnmanaged(u8), | |
| 341 | debug_output: link.File.DebugInfoOutput, | |
| 342 | ) CodeGenError!void { | |
| 343 | air: *const Air, | |
| 344 | liveness: *const Air.Liveness, | |
| 345 | ) CodeGenError!Mir { | |
| 343 | 346 | const zcu = pt.zcu; |
| 344 | 347 | const gpa = zcu.gpa; |
| 345 | 348 | const func = zcu.funcInfo(func_index); |
| ... | ... | @@ -358,11 +361,10 @@ pub fn generate( |
| 358 | 361 | var function: Self = .{ |
| 359 | 362 | .gpa = gpa, |
| 360 | 363 | .pt = pt, |
| 361 | .air = air, | |
| 362 | .liveness = liveness, | |
| 364 | .air = air.*, | |
| 365 | .liveness = liveness.*, | |
| 363 | 366 | .target = target, |
| 364 | 367 | .bin_file = lf, |
| 365 | .debug_output = debug_output, | |
| 366 | 368 | .func_index = func_index, |
| 367 | 369 | .err_msg = null, |
| 368 | 370 | .args = undefined, // populated after `resolveCallingConventionValues` |
| ... | ... | @@ -402,31 +404,15 @@ pub fn generate( |
| 402 | 404 | return function.fail("failed to generate debug info: {s}", .{@errorName(err)}); |
| 403 | 405 | } |
| 404 | 406 | |
| 405 | var mir = Mir{ | |
| 407 | var mir: Mir = .{ | |
| 406 | 408 | .instructions = function.mir_instructions.toOwnedSlice(), |
| 407 | .extra = try function.mir_extra.toOwnedSlice(gpa), | |
| 408 | }; | |
| 409 | defer mir.deinit(gpa); | |
| 410 | ||
| 411 | var emit = Emit{ | |
| 412 | .mir = mir, | |
| 413 | .bin_file = lf, | |
| 414 | .debug_output = debug_output, | |
| 415 | .target = target, | |
| 416 | .src_loc = src_loc, | |
| 417 | .code = code, | |
| 418 | .prev_di_pc = 0, | |
| 419 | .prev_di_line = func.lbrace_line, | |
| 420 | .prev_di_column = func.lbrace_column, | |
| 421 | .stack_size = function.max_end_stack, | |
| 409 | .extra = &.{}, // fallible, so assign after errdefer | |
| 410 | .max_end_stack = function.max_end_stack, | |
| 422 | 411 | .saved_regs_stack_space = function.saved_regs_stack_space, |
| 423 | 412 | }; |
| 424 | defer emit.deinit(); | |
| 425 | ||
| 426 | emit.emitMir() catch |err| switch (err) { | |
| 427 | error.EmitFail => return function.failMsg(emit.err_msg.?), | |
| 428 | else => |e| return e, | |
| 429 | }; | |
| 413 | errdefer mir.deinit(gpa); | |
| 414 | mir.extra = try function.mir_extra.toOwnedSlice(gpa); | |
| 415 | return mir; | |
| 430 | 416 | } |
| 431 | 417 | |
| 432 | 418 | fn addInst(self: *Self, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index { |
src/arch/arm/Mir.zig+43| ... | ... | @@ -13,6 +13,14 @@ const assert = std.debug.assert; |
| 13 | 13 | |
| 14 | 14 | const bits = @import("bits.zig"); |
| 15 | 15 | const Register = bits.Register; |
| 16 | const InternPool = @import("../../InternPool.zig"); | |
| 17 | const Emit = @import("Emit.zig"); | |
| 18 | const codegen = @import("../../codegen.zig"); | |
| 19 | const link = @import("../../link.zig"); | |
| 20 | const Zcu = @import("../../Zcu.zig"); | |
| 21 | ||
| 22 | max_end_stack: u32, | |
| 23 | saved_regs_stack_space: u32, | |
| 16 | 24 | |
| 17 | 25 | instructions: std.MultiArrayList(Inst).Slice, |
| 18 | 26 | /// The meaning of this data is determined by `Inst.Tag` value. |
| ... | ... | @@ -278,6 +286,41 @@ pub fn deinit(mir: *Mir, gpa: std.mem.Allocator) void { |
| 278 | 286 | mir.* = undefined; |
| 279 | 287 | } |
| 280 | 288 | |
| 289 | pub fn emit( | |
| 290 | mir: Mir, | |
| 291 | lf: *link.File, | |
| 292 | pt: Zcu.PerThread, | |
| 293 | src_loc: Zcu.LazySrcLoc, | |
| 294 | func_index: InternPool.Index, | |
| 295 | code: *std.ArrayListUnmanaged(u8), | |
| 296 | debug_output: link.File.DebugInfoOutput, | |
| 297 | air: *const @import("../../Air.zig"), | |
| 298 | ) codegen.CodeGenError!void { | |
| 299 | _ = air; // using this would be a bug | |
| 300 | const zcu = pt.zcu; | |
| 301 | const func = zcu.funcInfo(func_index); | |
| 302 | const nav = func.owner_nav; | |
| 303 | const mod = zcu.navFileScope(nav).mod.?; | |
| 304 | var e: Emit = .{ | |
| 305 | .mir = mir, | |
| 306 | .bin_file = lf, | |
| 307 | .debug_output = debug_output, | |
| 308 | .target = &mod.resolved_target.result, | |
| 309 | .src_loc = src_loc, | |
| 310 | .code = code, | |
| 311 | .prev_di_pc = 0, | |
| 312 | .prev_di_line = func.lbrace_line, | |
| 313 | .prev_di_column = func.lbrace_column, | |
| 314 | .stack_size = mir.max_end_stack, | |
| 315 | .saved_regs_stack_space = mir.saved_regs_stack_space, | |
| 316 | }; | |
| 317 | defer e.deinit(); | |
| 318 | e.emitMir() catch |err| switch (err) { | |
| 319 | error.EmitFail => return zcu.codegenFailMsg(nav, e.err_msg.?), | |
| 320 | else => |e1| return e1, | |
| 321 | }; | |
| 322 | } | |
| 323 | ||
| 281 | 324 | /// Returns the requested data, as well as the new index which is at the start of the |
| 282 | 325 | /// trailers for the object. |
| 283 | 326 | pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end: usize } { |
src/arch/powerpc/CodeGen.zig+3-7| ... | ... | @@ -19,19 +19,15 @@ pub fn generate( |
| 19 | 19 | pt: Zcu.PerThread, |
| 20 | 20 | src_loc: Zcu.LazySrcLoc, |
| 21 | 21 | func_index: InternPool.Index, |
| 22 | air: Air, | |
| 23 | liveness: Air.Liveness, | |
| 24 | code: *std.ArrayListUnmanaged(u8), | |
| 25 | debug_output: link.File.DebugInfoOutput, | |
| 26 | ) codegen.CodeGenError!void { | |
| 22 | air: *const Air, | |
| 23 | liveness: *const Air.Liveness, | |
| 24 | ) codegen.CodeGenError!noreturn { | |
| 27 | 25 | _ = bin_file; |
| 28 | 26 | _ = pt; |
| 29 | 27 | _ = src_loc; |
| 30 | 28 | _ = func_index; |
| 31 | 29 | _ = air; |
| 32 | 30 | _ = liveness; |
| 33 | _ = code; | |
| 34 | _ = debug_output; | |
| 35 | 31 | |
| 36 | 32 | unreachable; |
| 37 | 33 | } |
src/arch/riscv64/CodeGen.zig+13-38| ... | ... | @@ -68,7 +68,6 @@ gpa: Allocator, |
| 68 | 68 | |
| 69 | 69 | mod: *Package.Module, |
| 70 | 70 | target: *const std.Target, |
| 71 | debug_output: link.File.DebugInfoOutput, | |
| 72 | 71 | args: []MCValue, |
| 73 | 72 | ret_mcv: InstTracking, |
| 74 | 73 | fn_type: Type, |
| ... | ... | @@ -746,13 +745,10 @@ pub fn generate( |
| 746 | 745 | pt: Zcu.PerThread, |
| 747 | 746 | src_loc: Zcu.LazySrcLoc, |
| 748 | 747 | func_index: InternPool.Index, |
| 749 | air: Air, | |
| 750 | liveness: Air.Liveness, | |
| 751 | code: *std.ArrayListUnmanaged(u8), | |
| 752 | debug_output: link.File.DebugInfoOutput, | |
| 753 | ) CodeGenError!void { | |
| 748 | air: *const Air, | |
| 749 | liveness: *const Air.Liveness, | |
| 750 | ) CodeGenError!Mir { | |
| 754 | 751 | const zcu = pt.zcu; |
| 755 | const comp = zcu.comp; | |
| 756 | 752 | const gpa = zcu.gpa; |
| 757 | 753 | const ip = &zcu.intern_pool; |
| 758 | 754 | const func = zcu.funcInfo(func_index); |
| ... | ... | @@ -769,13 +765,12 @@ pub fn generate( |
| 769 | 765 | |
| 770 | 766 | var function: Func = .{ |
| 771 | 767 | .gpa = gpa, |
| 772 | .air = air, | |
| 768 | .air = air.*, | |
| 773 | 769 | .pt = pt, |
| 774 | 770 | .mod = mod, |
| 775 | 771 | .bin_file = bin_file, |
| 776 | .liveness = liveness, | |
| 772 | .liveness = liveness.*, | |
| 777 | 773 | .target = &mod.resolved_target.result, |
| 778 | .debug_output = debug_output, | |
| 779 | 774 | .owner = .{ .nav_index = func.owner_nav }, |
| 780 | 775 | .args = undefined, // populated after `resolveCallingConventionValues` |
| 781 | 776 | .ret_mcv = undefined, // populated after `resolveCallingConventionValues` |
| ... | ... | @@ -855,33 +850,8 @@ pub fn generate( |
| 855 | 850 | .instructions = function.mir_instructions.toOwnedSlice(), |
| 856 | 851 | .frame_locs = function.frame_locs.toOwnedSlice(), |
| 857 | 852 | }; |
| 858 | defer mir.deinit(gpa); | |
| 859 | ||
| 860 | var emit: Emit = .{ | |
| 861 | .lower = .{ | |
| 862 | .pt = pt, | |
| 863 | .allocator = gpa, | |
| 864 | .mir = mir, | |
| 865 | .cc = fn_info.cc, | |
| 866 | .src_loc = src_loc, | |
| 867 | .output_mode = comp.config.output_mode, | |
| 868 | .link_mode = comp.config.link_mode, | |
| 869 | .pic = mod.pic, | |
| 870 | }, | |
| 871 | .bin_file = bin_file, | |
| 872 | .debug_output = debug_output, | |
| 873 | .code = code, | |
| 874 | .prev_di_pc = 0, | |
| 875 | .prev_di_line = func.lbrace_line, | |
| 876 | .prev_di_column = func.lbrace_column, | |
| 877 | }; | |
| 878 | defer emit.deinit(); | |
| 879 | ||
| 880 | emit.emitMir() catch |err| switch (err) { | |
| 881 | error.LowerFail, error.EmitFail => return function.failMsg(emit.lower.err_msg.?), | |
| 882 | error.InvalidInstruction => |e| return function.fail("emit MIR failed: {s} (Zig compiler bug)", .{@errorName(e)}), | |
| 883 | else => |e| return e, | |
| 884 | }; | |
| 853 | errdefer mir.deinit(gpa); | |
| 854 | return mir; | |
| 885 | 855 | } |
| 886 | 856 | |
| 887 | 857 | pub fn generateLazy( |
| ... | ... | @@ -904,7 +874,6 @@ pub fn generateLazy( |
| 904 | 874 | .bin_file = bin_file, |
| 905 | 875 | .liveness = undefined, |
| 906 | 876 | .target = &mod.resolved_target.result, |
| 907 | .debug_output = debug_output, | |
| 908 | 877 | .owner = .{ .lazy_sym = lazy_sym }, |
| 909 | 878 | .args = undefined, // populated after `resolveCallingConventionValues` |
| 910 | 879 | .ret_mcv = undefined, // populated after `resolveCallingConventionValues` |
| ... | ... | @@ -4760,6 +4729,9 @@ fn genArgDbgInfo(func: *const Func, inst: Air.Inst.Index, mcv: MCValue) InnerErr |
| 4760 | 4729 | const ty = arg.ty.toType(); |
| 4761 | 4730 | if (arg.name == .none) return; |
| 4762 | 4731 | |
| 4732 | // TODO: Add a pseudo-instruction or something to defer this work until Emit. | |
| 4733 | // We aren't allowed to interact with linker state here. | |
| 4734 | if (true) return; | |
| 4763 | 4735 | switch (func.debug_output) { |
| 4764 | 4736 | .dwarf => |dw| switch (mcv) { |
| 4765 | 4737 | .register => |reg| dw.genLocalDebugInfo( |
| ... | ... | @@ -5273,6 +5245,9 @@ fn genVarDbgInfo( |
| 5273 | 5245 | mcv: MCValue, |
| 5274 | 5246 | name: []const u8, |
| 5275 | 5247 | ) !void { |
| 5248 | // TODO: Add a pseudo-instruction or something to defer this work until Emit. | |
| 5249 | // We aren't allowed to interact with linker state here. | |
| 5250 | if (true) return; | |
| 5276 | 5251 | switch (func.debug_output) { |
| 5277 | 5252 | .dwarf => |dwarf| { |
| 5278 | 5253 | const loc: link.File.Dwarf.Loc = switch (mcv) { |
src/arch/riscv64/Mir.zig+50| ... | ... | @@ -109,6 +109,50 @@ pub fn deinit(mir: *Mir, gpa: std.mem.Allocator) void { |
| 109 | 109 | mir.* = undefined; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | pub fn emit( | |
| 113 | mir: Mir, | |
| 114 | lf: *link.File, | |
| 115 | pt: Zcu.PerThread, | |
| 116 | src_loc: Zcu.LazySrcLoc, | |
| 117 | func_index: InternPool.Index, | |
| 118 | code: *std.ArrayListUnmanaged(u8), | |
| 119 | debug_output: link.File.DebugInfoOutput, | |
| 120 | air: *const @import("../../Air.zig"), | |
| 121 | ) codegen.CodeGenError!void { | |
| 122 | _ = air; // using this would be a bug | |
| 123 | const zcu = pt.zcu; | |
| 124 | const comp = zcu.comp; | |
| 125 | const gpa = comp.gpa; | |
| 126 | const func = zcu.funcInfo(func_index); | |
| 127 | const fn_info = zcu.typeToFunc(.fromInterned(func.ty)).?; | |
| 128 | const nav = func.owner_nav; | |
| 129 | const mod = zcu.navFileScope(nav).mod.?; | |
| 130 | var e: Emit = .{ | |
| 131 | .lower = .{ | |
| 132 | .pt = pt, | |
| 133 | .allocator = gpa, | |
| 134 | .mir = mir, | |
| 135 | .cc = fn_info.cc, | |
| 136 | .src_loc = src_loc, | |
| 137 | .output_mode = comp.config.output_mode, | |
| 138 | .link_mode = comp.config.link_mode, | |
| 139 | .pic = mod.pic, | |
| 140 | }, | |
| 141 | .bin_file = lf, | |
| 142 | .debug_output = debug_output, | |
| 143 | .code = code, | |
| 144 | .prev_di_pc = 0, | |
| 145 | .prev_di_line = func.lbrace_line, | |
| 146 | .prev_di_column = func.lbrace_column, | |
| 147 | }; | |
| 148 | defer e.deinit(); | |
| 149 | e.emitMir() catch |err| switch (err) { | |
| 150 | error.LowerFail, error.EmitFail => return zcu.codegenFailMsg(nav, e.lower.err_msg.?), | |
| 151 | error.InvalidInstruction => return zcu.codegenFail(nav, "emit MIR failed: {s} (Zig compiler bug)", .{@errorName(err)}), | |
| 152 | else => |err1| return err1, | |
| 153 | }; | |
| 154 | } | |
| 155 | ||
| 112 | 156 | pub const FrameLoc = struct { |
| 113 | 157 | base: Register, |
| 114 | 158 | disp: i32, |
| ... | ... | @@ -202,3 +246,9 @@ const FrameIndex = bits.FrameIndex; |
| 202 | 246 | const FrameAddr = @import("CodeGen.zig").FrameAddr; |
| 203 | 247 | const IntegerBitSet = std.bit_set.IntegerBitSet; |
| 204 | 248 | const Mnemonic = @import("mnem.zig").Mnemonic; |
| 249 | ||
| 250 | const InternPool = @import("../../InternPool.zig"); | |
| 251 | const Emit = @import("Emit.zig"); | |
| 252 | const codegen = @import("../../codegen.zig"); | |
| 253 | const link = @import("../../link.zig"); | |
| 254 | const Zcu = @import("../../Zcu.zig"); |
src/arch/sparc64/CodeGen.zig+13-32| ... | ... | @@ -57,8 +57,6 @@ liveness: Air.Liveness, |
| 57 | 57 | bin_file: *link.File, |
| 58 | 58 | target: *const std.Target, |
| 59 | 59 | func_index: InternPool.Index, |
| 60 | code: *std.ArrayListUnmanaged(u8), | |
| 61 | debug_output: link.File.DebugInfoOutput, | |
| 62 | 60 | err_msg: ?*ErrorMsg, |
| 63 | 61 | args: []MCValue, |
| 64 | 62 | ret_mcv: MCValue, |
| ... | ... | @@ -268,11 +266,9 @@ pub fn generate( |
| 268 | 266 | pt: Zcu.PerThread, |
| 269 | 267 | src_loc: Zcu.LazySrcLoc, |
| 270 | 268 | func_index: InternPool.Index, |
| 271 | air: Air, | |
| 272 | liveness: Air.Liveness, | |
| 273 | code: *std.ArrayListUnmanaged(u8), | |
| 274 | debug_output: link.File.DebugInfoOutput, | |
| 275 | ) CodeGenError!void { | |
| 269 | air: *const Air, | |
| 270 | liveness: *const Air.Liveness, | |
| 271 | ) CodeGenError!Mir { | |
| 276 | 272 | const zcu = pt.zcu; |
| 277 | 273 | const gpa = zcu.gpa; |
| 278 | 274 | const func = zcu.funcInfo(func_index); |
| ... | ... | @@ -291,13 +287,11 @@ pub fn generate( |
| 291 | 287 | var function: Self = .{ |
| 292 | 288 | .gpa = gpa, |
| 293 | 289 | .pt = pt, |
| 294 | .air = air, | |
| 295 | .liveness = liveness, | |
| 290 | .air = air.*, | |
| 291 | .liveness = liveness.*, | |
| 296 | 292 | .target = target, |
| 297 | 293 | .bin_file = lf, |
| 298 | 294 | .func_index = func_index, |
| 299 | .code = code, | |
| 300 | .debug_output = debug_output, | |
| 301 | 295 | .err_msg = null, |
| 302 | 296 | .args = undefined, // populated after `resolveCallingConventionValues` |
| 303 | 297 | .ret_mcv = undefined, // populated after `resolveCallingConventionValues` |
| ... | ... | @@ -330,29 +324,13 @@ pub fn generate( |
| 330 | 324 | else => |e| return e, |
| 331 | 325 | }; |
| 332 | 326 | |
| 333 | var mir = Mir{ | |
| 327 | var mir: Mir = .{ | |
| 334 | 328 | .instructions = function.mir_instructions.toOwnedSlice(), |
| 335 | .extra = try function.mir_extra.toOwnedSlice(gpa), | |
| 336 | }; | |
| 337 | defer mir.deinit(gpa); | |
| 338 | ||
| 339 | var emit: Emit = .{ | |
| 340 | .mir = mir, | |
| 341 | .bin_file = lf, | |
| 342 | .debug_output = debug_output, | |
| 343 | .target = target, | |
| 344 | .src_loc = src_loc, | |
| 345 | .code = code, | |
| 346 | .prev_di_pc = 0, | |
| 347 | .prev_di_line = func.lbrace_line, | |
| 348 | .prev_di_column = func.lbrace_column, | |
| 349 | }; | |
| 350 | defer emit.deinit(); | |
| 351 | ||
| 352 | emit.emitMir() catch |err| switch (err) { | |
| 353 | error.EmitFail => return function.failMsg(emit.err_msg.?), | |
| 354 | else => |e| return e, | |
| 329 | .extra = &.{}, // fallible, so populated after errdefer | |
| 355 | 330 | }; |
| 331 | errdefer mir.deinit(gpa); | |
| 332 | mir.extra = try function.mir_extra.toOwnedSlice(gpa); | |
| 333 | return mir; | |
| 356 | 334 | } |
| 357 | 335 | |
| 358 | 336 | fn gen(self: *Self) !void { |
| ... | ... | @@ -3566,6 +3544,9 @@ fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue) !void { |
| 3566 | 3544 | const ty = arg.ty.toType(); |
| 3567 | 3545 | if (arg.name == .none) return; |
| 3568 | 3546 | |
| 3547 | // TODO: Add a pseudo-instruction or something to defer this work until Emit. | |
| 3548 | // We aren't allowed to interact with linker state here. | |
| 3549 | if (true) return; | |
| 3569 | 3550 | switch (self.debug_output) { |
| 3570 | 3551 | .dwarf => |dw| switch (mcv) { |
| 3571 | 3552 | .register => |reg| try dw.genLocalDebugInfo( |
src/arch/sparc64/Mir.zig+38-1| ... | ... | @@ -12,7 +12,11 @@ const assert = std.debug.assert; |
| 12 | 12 | |
| 13 | 13 | const Mir = @This(); |
| 14 | 14 | const bits = @import("bits.zig"); |
| 15 | const Air = @import("../../Air.zig"); | |
| 15 | const InternPool = @import("../../InternPool.zig"); | |
| 16 | const Emit = @import("Emit.zig"); | |
| 17 | const codegen = @import("../../codegen.zig"); | |
| 18 | const link = @import("../../link.zig"); | |
| 19 | const Zcu = @import("../../Zcu.zig"); | |
| 16 | 20 | |
| 17 | 21 | const Instruction = bits.Instruction; |
| 18 | 22 | const ASI = bits.Instruction.ASI; |
| ... | ... | @@ -370,6 +374,39 @@ pub fn deinit(mir: *Mir, gpa: std.mem.Allocator) void { |
| 370 | 374 | mir.* = undefined; |
| 371 | 375 | } |
| 372 | 376 | |
| 377 | pub fn emit( | |
| 378 | mir: Mir, | |
| 379 | lf: *link.File, | |
| 380 | pt: Zcu.PerThread, | |
| 381 | src_loc: Zcu.LazySrcLoc, | |
| 382 | func_index: InternPool.Index, | |
| 383 | code: *std.ArrayListUnmanaged(u8), | |
| 384 | debug_output: link.File.DebugInfoOutput, | |
| 385 | air: *const @import("../../Air.zig"), | |
| 386 | ) codegen.CodeGenError!void { | |
| 387 | _ = air; // using this would be a bug | |
| 388 | const zcu = pt.zcu; | |
| 389 | const func = zcu.funcInfo(func_index); | |
| 390 | const nav = func.owner_nav; | |
| 391 | const mod = zcu.navFileScope(nav).mod.?; | |
| 392 | var e: Emit = .{ | |
| 393 | .mir = mir, | |
| 394 | .bin_file = lf, | |
| 395 | .debug_output = debug_output, | |
| 396 | .target = &mod.resolved_target.result, | |
| 397 | .src_loc = src_loc, | |
| 398 | .code = code, | |
| 399 | .prev_di_pc = 0, | |
| 400 | .prev_di_line = func.lbrace_line, | |
| 401 | .prev_di_column = func.lbrace_column, | |
| 402 | }; | |
| 403 | defer e.deinit(); | |
| 404 | e.emitMir() catch |err| switch (err) { | |
| 405 | error.EmitFail => return zcu.codegenFailMsg(nav, e.err_msg.?), | |
| 406 | else => |err1| return err1, | |
| 407 | }; | |
| 408 | } | |
| 409 | ||
| 373 | 410 | /// Returns the requested data, as well as the new index which is at the start of the |
| 374 | 411 | /// trailers for the object. |
| 375 | 412 | pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end: usize } { |
src/arch/x86_64/CodeGen.zig+33-71| ... | ... | @@ -125,7 +125,6 @@ pt: Zcu.PerThread, |
| 125 | 125 | air: Air, |
| 126 | 126 | liveness: Air.Liveness, |
| 127 | 127 | bin_file: *link.File, |
| 128 | debug_output: link.File.DebugInfoOutput, | |
| 129 | 128 | target: *const std.Target, |
| 130 | 129 | owner: Owner, |
| 131 | 130 | inline_func: InternPool.Index, |
| ... | ... | @@ -972,13 +971,10 @@ pub fn generate( |
| 972 | 971 | pt: Zcu.PerThread, |
| 973 | 972 | src_loc: Zcu.LazySrcLoc, |
| 974 | 973 | func_index: InternPool.Index, |
| 975 | air: Air, | |
| 976 | liveness: Air.Liveness, | |
| 977 | code: *std.ArrayListUnmanaged(u8), | |
| 978 | debug_output: link.File.DebugInfoOutput, | |
| 979 | ) codegen.CodeGenError!void { | |
| 974 | air: *const Air, | |
| 975 | liveness: *const Air.Liveness, | |
| 976 | ) codegen.CodeGenError!Mir { | |
| 980 | 977 | const zcu = pt.zcu; |
| 981 | const comp = zcu.comp; | |
| 982 | 978 | const gpa = zcu.gpa; |
| 983 | 979 | const ip = &zcu.intern_pool; |
| 984 | 980 | const func = zcu.funcInfo(func_index); |
| ... | ... | @@ -988,12 +984,11 @@ pub fn generate( |
| 988 | 984 | var function: CodeGen = .{ |
| 989 | 985 | .gpa = gpa, |
| 990 | 986 | .pt = pt, |
| 991 | .air = air, | |
| 992 | .liveness = liveness, | |
| 987 | .air = air.*, | |
| 988 | .liveness = liveness.*, | |
| 993 | 989 | .target = &mod.resolved_target.result, |
| 994 | 990 | .mod = mod, |
| 995 | 991 | .bin_file = bin_file, |
| 996 | .debug_output = debug_output, | |
| 997 | 992 | .owner = .{ .nav_index = func.owner_nav }, |
| 998 | 993 | .inline_func = func_index, |
| 999 | 994 | .arg_index = undefined, |
| ... | ... | @@ -1090,7 +1085,7 @@ pub fn generate( |
| 1090 | 1085 | }; |
| 1091 | 1086 | |
| 1092 | 1087 | // Drop them off at the rbrace. |
| 1093 | if (debug_output != .none) _ = try function.addInst(.{ | |
| 1088 | if (!mod.strip) _ = try function.addInst(.{ | |
| 1094 | 1089 | .tag = .pseudo, |
| 1095 | 1090 | .ops = .pseudo_dbg_line_line_column, |
| 1096 | 1091 | .data = .{ .line_column = .{ |
| ... | ... | @@ -1100,49 +1095,17 @@ pub fn generate( |
| 1100 | 1095 | }); |
| 1101 | 1096 | |
| 1102 | 1097 | var mir: Mir = .{ |
| 1103 | .instructions = function.mir_instructions.toOwnedSlice(), | |
| 1104 | .extra = try function.mir_extra.toOwnedSlice(gpa), | |
| 1105 | .table = try function.mir_table.toOwnedSlice(gpa), | |
| 1106 | .frame_locs = function.frame_locs.toOwnedSlice(), | |
| 1107 | }; | |
| 1108 | defer mir.deinit(gpa); | |
| 1109 | ||
| 1110 | var emit: Emit = .{ | |
| 1111 | .air = function.air, | |
| 1112 | .lower = .{ | |
| 1113 | .bin_file = bin_file, | |
| 1114 | .target = function.target, | |
| 1115 | .allocator = gpa, | |
| 1116 | .mir = mir, | |
| 1117 | .cc = fn_info.cc, | |
| 1118 | .src_loc = src_loc, | |
| 1119 | .output_mode = comp.config.output_mode, | |
| 1120 | .link_mode = comp.config.link_mode, | |
| 1121 | .pic = mod.pic, | |
| 1122 | }, | |
| 1123 | .atom_index = function.owner.getSymbolIndex(&function) catch |err| switch (err) { | |
| 1124 | error.CodegenFail => return error.CodegenFail, | |
| 1125 | else => |e| return e, | |
| 1126 | }, | |
| 1127 | .debug_output = debug_output, | |
| 1128 | .code = code, | |
| 1129 | .prev_di_loc = .{ | |
| 1130 | .line = func.lbrace_line, | |
| 1131 | .column = func.lbrace_column, | |
| 1132 | .is_stmt = switch (debug_output) { | |
| 1133 | .dwarf => |dwarf| dwarf.dwarf.debug_line.header.default_is_stmt, | |
| 1134 | .plan9 => undefined, | |
| 1135 | .none => undefined, | |
| 1136 | }, | |
| 1137 | }, | |
| 1138 | .prev_di_pc = 0, | |
| 1139 | }; | |
| 1140 | emit.emitMir() catch |err| switch (err) { | |
| 1141 | error.LowerFail, error.EmitFail => return function.failMsg(emit.lower.err_msg.?), | |
| 1142 | ||
| 1143 | error.InvalidInstruction, error.CannotEncode => |e| return function.fail("emit MIR failed: {s} (Zig compiler bug)", .{@errorName(e)}), | |
| 1144 | else => |e| return function.fail("emit MIR failed: {s}", .{@errorName(e)}), | |
| 1098 | .instructions = .empty, | |
| 1099 | .extra = &.{}, | |
| 1100 | .table = &.{}, | |
| 1101 | .frame_locs = .empty, | |
| 1145 | 1102 | }; |
| 1103 | errdefer mir.deinit(gpa); | |
| 1104 | mir.instructions = function.mir_instructions.toOwnedSlice(); | |
| 1105 | mir.extra = try function.mir_extra.toOwnedSlice(gpa); | |
| 1106 | mir.table = try function.mir_table.toOwnedSlice(gpa); | |
| 1107 | mir.frame_locs = function.frame_locs.toOwnedSlice(); | |
| 1108 | return mir; | |
| 1146 | 1109 | } |
| 1147 | 1110 | |
| 1148 | 1111 | pub fn generateLazy( |
| ... | ... | @@ -1165,7 +1128,6 @@ pub fn generateLazy( |
| 1165 | 1128 | .target = &mod.resolved_target.result, |
| 1166 | 1129 | .mod = mod, |
| 1167 | 1130 | .bin_file = bin_file, |
| 1168 | .debug_output = debug_output, | |
| 1169 | 1131 | .owner = .{ .lazy_sym = lazy_sym }, |
| 1170 | 1132 | .inline_func = undefined, |
| 1171 | 1133 | .arg_index = undefined, |
| ... | ... | @@ -2339,7 +2301,7 @@ fn gen(self: *CodeGen) InnerError!void { |
| 2339 | 2301 | else => |cc| return self.fail("{s} does not support var args", .{@tagName(cc)}), |
| 2340 | 2302 | }; |
| 2341 | 2303 | |
| 2342 | if (self.debug_output != .none) try self.asmPseudo(.pseudo_dbg_prologue_end_none); | |
| 2304 | if (!self.mod.strip) try self.asmPseudo(.pseudo_dbg_prologue_end_none); | |
| 2343 | 2305 | |
| 2344 | 2306 | try self.genBody(self.air.getMainBody()); |
| 2345 | 2307 | |
| ... | ... | @@ -2356,7 +2318,7 @@ fn gen(self: *CodeGen) InnerError!void { |
| 2356 | 2318 | } |
| 2357 | 2319 | for (self.epilogue_relocs.items) |epilogue_reloc| self.performReloc(epilogue_reloc); |
| 2358 | 2320 | |
| 2359 | if (self.debug_output != .none) try self.asmPseudo(.pseudo_dbg_epilogue_begin_none); | |
| 2321 | if (!self.mod.strip) try self.asmPseudo(.pseudo_dbg_epilogue_begin_none); | |
| 2360 | 2322 | const backpatch_stack_dealloc = try self.asmPlaceholder(); |
| 2361 | 2323 | const backpatch_pop_callee_preserved_regs = try self.asmPlaceholder(); |
| 2362 | 2324 | try self.asmRegister(.{ ._, .pop }, .rbp); |
| ... | ... | @@ -2475,9 +2437,9 @@ fn gen(self: *CodeGen) InnerError!void { |
| 2475 | 2437 | }); |
| 2476 | 2438 | } |
| 2477 | 2439 | } else { |
| 2478 | if (self.debug_output != .none) try self.asmPseudo(.pseudo_dbg_prologue_end_none); | |
| 2440 | if (!self.mod.strip) try self.asmPseudo(.pseudo_dbg_prologue_end_none); | |
| 2479 | 2441 | try self.genBody(self.air.getMainBody()); |
| 2480 | if (self.debug_output != .none) try self.asmPseudo(.pseudo_dbg_epilogue_begin_none); | |
| 2442 | if (!self.mod.strip) try self.asmPseudo(.pseudo_dbg_epilogue_begin_none); | |
| 2481 | 2443 | } |
| 2482 | 2444 | } |
| 2483 | 2445 | |
| ... | ... | @@ -2498,9 +2460,9 @@ fn checkInvariantsAfterAirInst(self: *CodeGen) void { |
| 2498 | 2460 | } |
| 2499 | 2461 | |
| 2500 | 2462 | fn genBodyBlock(self: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 2501 | if (self.debug_output != .none) try self.asmPseudo(.pseudo_dbg_enter_block_none); | |
| 2463 | if (!self.mod.strip) try self.asmPseudo(.pseudo_dbg_enter_block_none); | |
| 2502 | 2464 | try self.genBody(body); |
| 2503 | if (self.debug_output != .none) try self.asmPseudo(.pseudo_dbg_leave_block_none); | |
| 2465 | if (!self.mod.strip) try self.asmPseudo(.pseudo_dbg_leave_block_none); | |
| 2504 | 2466 | } |
| 2505 | 2467 | |
| 2506 | 2468 | fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| ... | ... | @@ -2544,7 +2506,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 2544 | 2506 | .shuffle_one, .shuffle_two => @panic("x86_64 TODO: shuffle_one/shuffle_two"), |
| 2545 | 2507 | // zig fmt: on |
| 2546 | 2508 | |
| 2547 | .arg => if (cg.debug_output != .none) { | |
| 2509 | .arg => if (!cg.mod.strip) { | |
| 2548 | 2510 | // skip zero-bit arguments as they don't have a corresponding arg instruction |
| 2549 | 2511 | var arg_index = cg.arg_index; |
| 2550 | 2512 | while (cg.args[arg_index] == .none) arg_index += 1; |
| ... | ... | @@ -64179,9 +64141,9 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 64179 | 64141 | .block => { |
| 64180 | 64142 | const ty_pl = air_datas[@intFromEnum(inst)].ty_pl; |
| 64181 | 64143 | const block = cg.air.extraData(Air.Block, ty_pl.payload); |
| 64182 | if (cg.debug_output != .none) try cg.asmPseudo(.pseudo_dbg_enter_block_none); | |
| 64144 | if (!cg.mod.strip) try cg.asmPseudo(.pseudo_dbg_enter_block_none); | |
| 64183 | 64145 | try cg.lowerBlock(inst, @ptrCast(cg.air.extra.items[block.end..][0..block.data.body_len])); |
| 64184 | if (cg.debug_output != .none) try cg.asmPseudo(.pseudo_dbg_leave_block_none); | |
| 64146 | if (!cg.mod.strip) try cg.asmPseudo(.pseudo_dbg_leave_block_none); | |
| 64185 | 64147 | }, |
| 64186 | 64148 | .loop => if (use_old) try cg.airLoop(inst) else { |
| 64187 | 64149 | const ty_pl = air_datas[@intFromEnum(inst)].ty_pl; |
| ... | ... | @@ -85191,7 +85153,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 85191 | 85153 | .switch_dispatch => try cg.airSwitchDispatch(inst), |
| 85192 | 85154 | .@"try", .try_cold => try cg.airTry(inst), |
| 85193 | 85155 | .try_ptr, .try_ptr_cold => try cg.airTryPtr(inst), |
| 85194 | .dbg_stmt => if (cg.debug_output != .none) { | |
| 85156 | .dbg_stmt => if (!cg.mod.strip) { | |
| 85195 | 85157 | const dbg_stmt = air_datas[@intFromEnum(inst)].dbg_stmt; |
| 85196 | 85158 | _ = try cg.addInst(.{ |
| 85197 | 85159 | .tag = .pseudo, |
| ... | ... | @@ -85202,7 +85164,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 85202 | 85164 | } }, |
| 85203 | 85165 | }); |
| 85204 | 85166 | }, |
| 85205 | .dbg_empty_stmt => if (cg.debug_output != .none) { | |
| 85167 | .dbg_empty_stmt => if (!cg.mod.strip) { | |
| 85206 | 85168 | if (cg.mir_instructions.len > 0) { |
| 85207 | 85169 | const prev_mir_op = &cg.mir_instructions.items(.ops)[cg.mir_instructions.len - 1]; |
| 85208 | 85170 | if (prev_mir_op.* == .pseudo_dbg_line_line_column) |
| ... | ... | @@ -85216,13 +85178,13 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 85216 | 85178 | const old_inline_func = cg.inline_func; |
| 85217 | 85179 | defer cg.inline_func = old_inline_func; |
| 85218 | 85180 | cg.inline_func = dbg_inline_block.data.func; |
| 85219 | if (cg.debug_output != .none) _ = try cg.addInst(.{ | |
| 85181 | if (!cg.mod.strip) _ = try cg.addInst(.{ | |
| 85220 | 85182 | .tag = .pseudo, |
| 85221 | 85183 | .ops = .pseudo_dbg_enter_inline_func, |
| 85222 | 85184 | .data = .{ .func = dbg_inline_block.data.func }, |
| 85223 | 85185 | }); |
| 85224 | 85186 | try cg.lowerBlock(inst, @ptrCast(cg.air.extra.items[dbg_inline_block.end..][0..dbg_inline_block.data.body_len])); |
| 85225 | if (cg.debug_output != .none) _ = try cg.addInst(.{ | |
| 85187 | if (!cg.mod.strip) _ = try cg.addInst(.{ | |
| 85226 | 85188 | .tag = .pseudo, |
| 85227 | 85189 | .ops = .pseudo_dbg_leave_inline_func, |
| 85228 | 85190 | .data = .{ .func = old_inline_func }, |
| ... | ... | @@ -85231,7 +85193,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 85231 | 85193 | .dbg_var_ptr, |
| 85232 | 85194 | .dbg_var_val, |
| 85233 | 85195 | .dbg_arg_inline, |
| 85234 | => if (use_old) try cg.airDbgVar(inst) else if (cg.debug_output != .none) { | |
| 85196 | => if (use_old) try cg.airDbgVar(inst) else if (!cg.mod.strip) { | |
| 85235 | 85197 | const pl_op = air_datas[@intFromEnum(inst)].pl_op; |
| 85236 | 85198 | var ops = try cg.tempsFromOperands(inst, .{pl_op.operand}); |
| 85237 | 85199 | var mcv = ops[0].tracking(cg).short; |
| ... | ... | @@ -173366,7 +173328,7 @@ fn airArg(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 173366 | 173328 | while (self.args[arg_index] == .none) arg_index += 1; |
| 173367 | 173329 | self.arg_index = arg_index + 1; |
| 173368 | 173330 | |
| 173369 | const result: MCValue = if (self.debug_output == .none and self.liveness.isUnused(inst)) .unreach else result: { | |
| 173331 | const result: MCValue = if (self.mod.strip and self.liveness.isUnused(inst)) .unreach else result: { | |
| 173370 | 173332 | const arg_ty = self.typeOfIndex(inst); |
| 173371 | 173333 | const src_mcv = self.args[arg_index]; |
| 173372 | 173334 | switch (src_mcv) { |
| ... | ... | @@ -173468,7 +173430,7 @@ fn airArg(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 173468 | 173430 | } |
| 173469 | 173431 | |
| 173470 | 173432 | fn airDbgVarArgs(self: *CodeGen) !void { |
| 173471 | if (self.debug_output == .none) return; | |
| 173433 | if (self.mod.strip) return; | |
| 173472 | 173434 | if (!self.pt.zcu.typeToFunc(self.fn_type).?.is_var_args) return; |
| 173473 | 173435 | try self.asmPseudo(.pseudo_dbg_var_args_none); |
| 173474 | 173436 | } |
| ... | ... | @@ -173478,7 +173440,7 @@ fn genLocalDebugInfo( |
| 173478 | 173440 | inst: Air.Inst.Index, |
| 173479 | 173441 | mcv: MCValue, |
| 173480 | 173442 | ) !void { |
| 173481 | if (self.debug_output == .none) return; | |
| 173443 | if (self.mod.strip) return; | |
| 173482 | 173444 | switch (self.air.instructions.items(.tag)[@intFromEnum(inst)]) { |
| 173483 | 173445 | else => unreachable, |
| 173484 | 173446 | .arg, .dbg_arg_inline, .dbg_var_val => |tag| { |
src/arch/x86_64/Mir.zig+65| ... | ... | @@ -1929,6 +1929,67 @@ pub fn deinit(mir: *Mir, gpa: std.mem.Allocator) void { |
| 1929 | 1929 | mir.* = undefined; |
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | pub fn emit( | |
| 1933 | mir: Mir, | |
| 1934 | lf: *link.File, | |
| 1935 | pt: Zcu.PerThread, | |
| 1936 | src_loc: Zcu.LazySrcLoc, | |
| 1937 | func_index: InternPool.Index, | |
| 1938 | code: *std.ArrayListUnmanaged(u8), | |
| 1939 | debug_output: link.File.DebugInfoOutput, | |
| 1940 | /// TODO: remove dependency on this argument. This blocks enabling `Zcu.Feature.separate_thread`. | |
| 1941 | air: *const Air, | |
| 1942 | ) codegen.CodeGenError!void { | |
| 1943 | const zcu = pt.zcu; | |
| 1944 | const comp = zcu.comp; | |
| 1945 | const gpa = comp.gpa; | |
| 1946 | const func = zcu.funcInfo(func_index); | |
| 1947 | const fn_info = zcu.typeToFunc(.fromInterned(func.ty)).?; | |
| 1948 | const nav = func.owner_nav; | |
| 1949 | const mod = zcu.navFileScope(nav).mod.?; | |
| 1950 | var e: Emit = .{ | |
| 1951 | .air = air.*, | |
| 1952 | .lower = .{ | |
| 1953 | .bin_file = lf, | |
| 1954 | .target = &mod.resolved_target.result, | |
| 1955 | .allocator = gpa, | |
| 1956 | .mir = mir, | |
| 1957 | .cc = fn_info.cc, | |
| 1958 | .src_loc = src_loc, | |
| 1959 | .output_mode = comp.config.output_mode, | |
| 1960 | .link_mode = comp.config.link_mode, | |
| 1961 | .pic = mod.pic, | |
| 1962 | }, | |
| 1963 | .atom_index = sym: { | |
| 1964 | if (lf.cast(.elf)) |ef| break :sym try ef.zigObjectPtr().?.getOrCreateMetadataForNav(zcu, nav); | |
| 1965 | if (lf.cast(.macho)) |mf| break :sym try mf.getZigObject().?.getOrCreateMetadataForNav(mf, nav); | |
| 1966 | if (lf.cast(.coff)) |cf| { | |
| 1967 | const atom = try cf.getOrCreateAtomForNav(nav); | |
| 1968 | break :sym cf.getAtom(atom).getSymbolIndex().?; | |
| 1969 | } | |
| 1970 | if (lf.cast(.plan9)) |p9f| break :sym try p9f.seeNav(pt, nav); | |
| 1971 | unreachable; | |
| 1972 | }, | |
| 1973 | .debug_output = debug_output, | |
| 1974 | .code = code, | |
| 1975 | .prev_di_loc = .{ | |
| 1976 | .line = func.lbrace_line, | |
| 1977 | .column = func.lbrace_column, | |
| 1978 | .is_stmt = switch (debug_output) { | |
| 1979 | .dwarf => |dwarf| dwarf.dwarf.debug_line.header.default_is_stmt, | |
| 1980 | .plan9 => undefined, | |
| 1981 | .none => undefined, | |
| 1982 | }, | |
| 1983 | }, | |
| 1984 | .prev_di_pc = 0, | |
| 1985 | }; | |
| 1986 | e.emitMir() catch |err| switch (err) { | |
| 1987 | error.LowerFail, error.EmitFail => return zcu.codegenFailMsg(nav, e.lower.err_msg.?), | |
| 1988 | error.InvalidInstruction, error.CannotEncode => return zcu.codegenFail(nav, "emit MIR failed: {s} (Zig compiler bug)", .{@errorName(err)}), | |
| 1989 | else => return zcu.codegenFail(nav, "emit MIR failed: {s}", .{@errorName(err)}), | |
| 1990 | }; | |
| 1991 | } | |
| 1992 | ||
| 1932 | 1993 | pub fn extraData(mir: Mir, comptime T: type, index: u32) struct { data: T, end: u32 } { |
| 1933 | 1994 | const fields = std.meta.fields(T); |
| 1934 | 1995 | var i: u32 = index; |
| ... | ... | @@ -1987,3 +2048,7 @@ const IntegerBitSet = std.bit_set.IntegerBitSet; |
| 1987 | 2048 | const InternPool = @import("../../InternPool.zig"); |
| 1988 | 2049 | const Mir = @This(); |
| 1989 | 2050 | const Register = bits.Register; |
| 2051 | const Emit = @import("Emit.zig"); | |
| 2052 | const codegen = @import("../../codegen.zig"); | |
| 2053 | const link = @import("../../link.zig"); | |
| 2054 | const Zcu = @import("../../Zcu.zig"); |
src/codegen.zig+1-1| ... | ... | @@ -182,7 +182,7 @@ pub fn emitFunction( |
| 182 | 182 | /// in the pipeline. Any information needed to call emit must be stored in MIR. |
| 183 | 183 | /// This is `undefined` if the backend supports the `separate_thread` feature. |
| 184 | 184 | air: *const Air, |
| 185 | ) Allocator.Error!void { | |
| 185 | ) CodeGenError!void { | |
| 186 | 186 | const zcu = pt.zcu; |
| 187 | 187 | const func = zcu.funcInfo(func_index); |
| 188 | 188 | const target = zcu.navFileScope(func.owner_nav).mod.?.resolved_target.result; |
src/libs/freebsd.zig+1-1| ... | ... | @@ -985,7 +985,7 @@ fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void { |
| 985 | 985 | assert(comp.freebsd_so_files == null); |
| 986 | 986 | comp.freebsd_so_files = so_files; |
| 987 | 987 | |
| 988 | var task_buffer: [libs.len]link.Task = undefined; | |
| 988 | var task_buffer: [libs.len]link.PrelinkTask = undefined; | |
| 989 | 989 | var task_buffer_i: usize = 0; |
| 990 | 990 | |
| 991 | 991 | { |
src/libs/glibc.zig+1-1| ... | ... | @@ -1148,7 +1148,7 @@ fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void { |
| 1148 | 1148 | assert(comp.glibc_so_files == null); |
| 1149 | 1149 | comp.glibc_so_files = so_files; |
| 1150 | 1150 | |
| 1151 | var task_buffer: [libs.len]link.Task = undefined; | |
| 1151 | var task_buffer: [libs.len]link.PrelinkTask = undefined; | |
| 1152 | 1152 | var task_buffer_i: usize = 0; |
| 1153 | 1153 | |
| 1154 | 1154 | { |
src/libs/netbsd.zig+1-1| ... | ... | @@ -650,7 +650,7 @@ fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void { |
| 650 | 650 | assert(comp.netbsd_so_files == null); |
| 651 | 651 | comp.netbsd_so_files = so_files; |
| 652 | 652 | |
| 653 | var task_buffer: [libs.len]link.Task = undefined; | |
| 653 | var task_buffer: [libs.len]link.PrelinkTask = undefined; | |
| 654 | 654 | var task_buffer_i: usize = 0; |
| 655 | 655 | |
| 656 | 656 | { |
src/link.zig+2| ... | ... | @@ -759,6 +759,8 @@ pub const File = struct { |
| 759 | 759 | switch (base.tag) { |
| 760 | 760 | .lld => unreachable, |
| 761 | 761 | inline else => |tag| { |
| 762 | if (tag == .wasm) @panic("MLUGG TODO"); | |
| 763 | if (tag == .spirv) @panic("MLUGG TODO"); | |
| 762 | 764 | dev.check(tag.devFeature()); |
| 763 | 765 | return @as(*tag.Type(), @fieldParentPtr("base", base)).updateFunc(pt, func_index, mir, maybe_undef_air); |
| 764 | 766 | }, |
src/link/Coff.zig+7-5| ... | ... | @@ -1057,8 +1057,10 @@ pub fn updateFunc( |
| 1057 | 1057 | coff: *Coff, |
| 1058 | 1058 | pt: Zcu.PerThread, |
| 1059 | 1059 | func_index: InternPool.Index, |
| 1060 | air: Air, | |
| 1061 | liveness: Air.Liveness, | |
| 1060 | mir: *const codegen.AnyMir, | |
| 1061 | /// This may be `undefined`; only pass it to `emitFunction`. | |
| 1062 | /// This parameter will eventually be removed. | |
| 1063 | maybe_undef_air: *const Air, | |
| 1062 | 1064 | ) link.File.UpdateNavError!void { |
| 1063 | 1065 | if (build_options.skip_non_native and builtin.object_format != .coff) { |
| 1064 | 1066 | @panic("Attempted to compile for object format that was disabled by build configuration"); |
| ... | ... | @@ -1079,15 +1081,15 @@ pub fn updateFunc( |
| 1079 | 1081 | var code_buffer: std.ArrayListUnmanaged(u8) = .empty; |
| 1080 | 1082 | defer code_buffer.deinit(gpa); |
| 1081 | 1083 | |
| 1082 | try codegen.generateFunction( | |
| 1084 | try codegen.emitFunction( | |
| 1083 | 1085 | &coff.base, |
| 1084 | 1086 | pt, |
| 1085 | 1087 | zcu.navSrcLoc(nav_index), |
| 1086 | 1088 | func_index, |
| 1087 | air, | |
| 1088 | liveness, | |
| 1089 | mir, | |
| 1089 | 1090 | &code_buffer, |
| 1090 | 1091 | .none, |
| 1092 | maybe_undef_air, | |
| 1091 | 1093 | ); |
| 1092 | 1094 | |
| 1093 | 1095 | try coff.updateNavCode(pt, nav_index, code_buffer.items, .FUNCTION); |
src/link/Goff.zig+5-4| ... | ... | @@ -13,6 +13,7 @@ const Path = std.Build.Cache.Path; |
| 13 | 13 | const Zcu = @import("../Zcu.zig"); |
| 14 | 14 | const InternPool = @import("../InternPool.zig"); |
| 15 | 15 | const Compilation = @import("../Compilation.zig"); |
| 16 | const codegen = @import("../codegen.zig"); | |
| 16 | 17 | const link = @import("../link.zig"); |
| 17 | 18 | const trace = @import("../tracy.zig").trace; |
| 18 | 19 | const build_options = @import("build_options"); |
| ... | ... | @@ -72,14 +73,14 @@ pub fn updateFunc( |
| 72 | 73 | self: *Goff, |
| 73 | 74 | pt: Zcu.PerThread, |
| 74 | 75 | func_index: InternPool.Index, |
| 75 | air: Air, | |
| 76 | liveness: Air.Liveness, | |
| 76 | mir: *const codegen.AnyMir, | |
| 77 | maybe_undef_air: *const Air, | |
| 77 | 78 | ) link.File.UpdateNavError!void { |
| 78 | 79 | _ = self; |
| 79 | 80 | _ = pt; |
| 80 | 81 | _ = func_index; |
| 81 | _ = air; | |
| 82 | _ = liveness; | |
| 82 | _ = mir; | |
| 83 | _ = maybe_undef_air; | |
| 83 | 84 | unreachable; // we always use llvm |
| 84 | 85 | } |
| 85 | 86 |
src/link/MachO.zig+3-3| ... | ... | @@ -3051,13 +3051,13 @@ pub fn updateFunc( |
| 3051 | 3051 | self: *MachO, |
| 3052 | 3052 | pt: Zcu.PerThread, |
| 3053 | 3053 | func_index: InternPool.Index, |
| 3054 | air: Air, | |
| 3055 | liveness: Air.Liveness, | |
| 3054 | mir: *const codegen.AnyMir, | |
| 3055 | maybe_undef_air: *const Air, | |
| 3056 | 3056 | ) link.File.UpdateNavError!void { |
| 3057 | 3057 | if (build_options.skip_non_native and builtin.object_format != .macho) { |
| 3058 | 3058 | @panic("Attempted to compile for object format that was disabled by build configuration"); |
| 3059 | 3059 | } |
| 3060 | return self.getZigObject().?.updateFunc(self, pt, func_index, air, liveness); | |
| 3060 | return self.getZigObject().?.updateFunc(self, pt, func_index, mir, maybe_undef_air); | |
| 3061 | 3061 | } |
| 3062 | 3062 | |
| 3063 | 3063 | pub fn updateNav(self: *MachO, pt: Zcu.PerThread, nav: InternPool.Nav.Index) link.File.UpdateNavError!void { |
src/link/MachO/ZigObject.zig+7-5| ... | ... | @@ -777,8 +777,10 @@ pub fn updateFunc( |
| 777 | 777 | macho_file: *MachO, |
| 778 | 778 | pt: Zcu.PerThread, |
| 779 | 779 | func_index: InternPool.Index, |
| 780 | air: Air, | |
| 781 | liveness: Air.Liveness, | |
| 780 | mir: *const codegen.AnyMir, | |
| 781 | /// This may be `undefined`; only pass it to `emitFunction`. | |
| 782 | /// This parameter will eventually be removed. | |
| 783 | maybe_undef_air: *const Air, | |
| 782 | 784 | ) link.File.UpdateNavError!void { |
| 783 | 785 | const tracy = trace(@src()); |
| 784 | 786 | defer tracy.end(); |
| ... | ... | @@ -796,15 +798,15 @@ pub fn updateFunc( |
| 796 | 798 | var debug_wip_nav = if (self.dwarf) |*dwarf| try dwarf.initWipNav(pt, func.owner_nav, sym_index) else null; |
| 797 | 799 | defer if (debug_wip_nav) |*wip_nav| wip_nav.deinit(); |
| 798 | 800 | |
| 799 | try codegen.generateFunction( | |
| 801 | try codegen.emitFunction( | |
| 800 | 802 | &macho_file.base, |
| 801 | 803 | pt, |
| 802 | 804 | zcu.navSrcLoc(func.owner_nav), |
| 803 | 805 | func_index, |
| 804 | air, | |
| 805 | liveness, | |
| 806 | mir, | |
| 806 | 807 | &code_buffer, |
| 807 | 808 | if (debug_wip_nav) |*wip_nav| .{ .dwarf = wip_nav } else .none, |
| 809 | maybe_undef_air, | |
| 808 | 810 | ); |
| 809 | 811 | const code = code_buffer.items; |
| 810 | 812 |
src/link/Plan9.zig+7-5| ... | ... | @@ -386,8 +386,10 @@ pub fn updateFunc( |
| 386 | 386 | self: *Plan9, |
| 387 | 387 | pt: Zcu.PerThread, |
| 388 | 388 | func_index: InternPool.Index, |
| 389 | air: Air, | |
| 390 | liveness: Air.Liveness, | |
| 389 | mir: *const codegen.AnyMir, | |
| 390 | /// This may be `undefined`; only pass it to `emitFunction`. | |
| 391 | /// This parameter will eventually be removed. | |
| 392 | maybe_undef_air: *const Air, | |
| 391 | 393 | ) link.File.UpdateNavError!void { |
| 392 | 394 | if (build_options.skip_non_native and builtin.object_format != .plan9) { |
| 393 | 395 | @panic("Attempted to compile for object format that was disabled by build configuration"); |
| ... | ... | @@ -412,15 +414,15 @@ pub fn updateFunc( |
| 412 | 414 | }; |
| 413 | 415 | defer dbg_info_output.dbg_line.deinit(); |
| 414 | 416 | |
| 415 | try codegen.generateFunction( | |
| 417 | try codegen.emitFunction( | |
| 416 | 418 | &self.base, |
| 417 | 419 | pt, |
| 418 | 420 | zcu.navSrcLoc(func.owner_nav), |
| 419 | 421 | func_index, |
| 420 | air, | |
| 421 | liveness, | |
| 422 | mir, | |
| 422 | 423 | &code_buffer, |
| 423 | 424 | .{ .plan9 = &dbg_info_output }, |
| 425 | maybe_undef_air, | |
| 424 | 426 | ); |
| 425 | 427 | const code = try code_buffer.toOwnedSlice(gpa); |
| 426 | 428 | self.getAtomPtr(atom_idx).code = .{ |
src/link/Queue.zig+1-2| ... | ... | @@ -97,8 +97,7 @@ pub fn mirReady(q: *Queue, comp: *Compilation, mir: *ZcuTask.LinkFunc.SharedMir) |
| 97 | 97 | q.mutex.lock(); |
| 98 | 98 | defer q.mutex.unlock(); |
| 99 | 99 | switch (q.state) { |
| 100 | .finished => unreachable, // there's definitely a task queued | |
| 101 | .running => return, | |
| 100 | .finished, .running => return, | |
| 102 | 101 | .wait_for_mir => |wait_for| if (wait_for != mir) return, |
| 103 | 102 | } |
| 104 | 103 | // We were waiting for `mir`, so we will restart the linker thread. |
src/link/Xcoff.zig+5-4| ... | ... | @@ -13,6 +13,7 @@ const Path = std.Build.Cache.Path; |
| 13 | 13 | const Zcu = @import("../Zcu.zig"); |
| 14 | 14 | const InternPool = @import("../InternPool.zig"); |
| 15 | 15 | const Compilation = @import("../Compilation.zig"); |
| 16 | const codegen = @import("../codegen.zig"); | |
| 16 | 17 | const link = @import("../link.zig"); |
| 17 | 18 | const trace = @import("../tracy.zig").trace; |
| 18 | 19 | const build_options = @import("build_options"); |
| ... | ... | @@ -72,14 +73,14 @@ pub fn updateFunc( |
| 72 | 73 | self: *Xcoff, |
| 73 | 74 | pt: Zcu.PerThread, |
| 74 | 75 | func_index: InternPool.Index, |
| 75 | air: Air, | |
| 76 | liveness: Air.Liveness, | |
| 76 | mir: *const codegen.AnyMir, | |
| 77 | maybe_undef_air: *const Air, | |
| 77 | 78 | ) link.File.UpdateNavError!void { |
| 78 | 79 | _ = self; |
| 79 | 80 | _ = pt; |
| 80 | 81 | _ = func_index; |
| 81 | _ = air; | |
| 82 | _ = liveness; | |
| 82 | _ = mir; | |
| 83 | _ = maybe_undef_air; | |
| 83 | 84 | unreachable; // we always use llvm |
| 84 | 85 | } |
| 85 | 86 |