authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-11 09:29:53+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-11 20:05:50+01:00
logc9a153c7978b363a252f83878f75bd875fe6ae5e
treefe460ceca16048242c35f94bd9bf0479c85f15a4
parent621fc36b55a882c562d9378d4cf1fd8a5e1a907c

x86_64: add .dead pseudo-instruction to mark an unused MIR instruction


3 files changed, 14 insertions(+), 8 deletions(-)

src/arch/x86_64/CodeGen.zig+8-8
......@@ -630,8 +630,8 @@ fn gen(self: *Self) InnerError!void {
630630 // TODO During semantic analysis, check if there are no function calls. If there
631631 // are none, here we can omit the part where we subtract and then add rsp.
632632 const backpatch_stack_sub = try self.addInst(.{
633 .tag = .nop,
634 .ops = .none,
633 .tag = .dead,
634 .ops = undefined,
635635 .data = undefined,
636636 });
637637
......@@ -657,8 +657,8 @@ fn gen(self: *Self) InnerError!void {
657657
658658 // Push callee-preserved regs that were used actually in use.
659659 const backpatch_push_callee_preserved_regs = try self.addInst(.{
660 .tag = .nop,
661 .ops = .none,
660 .tag = .dead,
661 .ops = undefined,
662662 .data = undefined,
663663 });
664664
......@@ -688,8 +688,8 @@ fn gen(self: *Self) InnerError!void {
688688
689689 // Pop saved callee-preserved regs.
690690 const backpatch_pop_callee_preserved_regs = try self.addInst(.{
691 .tag = .nop,
692 .ops = .none,
691 .tag = .dead,
692 .ops = undefined,
693693 .data = undefined,
694694 });
695695
......@@ -701,8 +701,8 @@ fn gen(self: *Self) InnerError!void {
701701
702702 // Maybe add rsp, x if required. This is backpatched later.
703703 const backpatch_stack_add = try self.addInst(.{
704 .tag = .nop,
705 .ops = .none,
704 .tag = .dead,
705 .ops = undefined,
706706 .data = undefined,
707707 });
708708
src/arch/x86_64/Emit.zig+2
......@@ -137,6 +137,8 @@ pub fn lowerMir(emit: *Emit) InnerError!void {
137137
138138 .push_regs => try emit.mirPushPopRegisterList(.push, inst),
139139 .pop_regs => try emit.mirPushPopRegisterList(.pop, inst),
140
141 .dead => {},
140142 }
141143 }
142144
src/arch/x86_64/Mir.zig+4
......@@ -163,6 +163,10 @@ pub const Inst = struct {
163163 /// Pop registers
164164 /// Uses `payload` payload with data of type `SaveRegisterList`.
165165 pop_regs,
166
167 /// Tombstone
168 /// Emitter should skip this instruction.
169 dead,
166170 };
167171
168172 pub const Ops = enum(u8) {