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 {...@@ -630,8 +630,8 @@ fn gen(self: *Self) InnerError!void {
630 // TODO During semantic analysis, check if there are no function calls. If there630 // TODO During semantic analysis, check if there are no function calls. If there
631 // are none, here we can omit the part where we subtract and then add rsp.631 // are none, here we can omit the part where we subtract and then add rsp.
632 const backpatch_stack_sub = try self.addInst(.{632 const backpatch_stack_sub = try self.addInst(.{
633 .tag = .nop,633 .tag = .dead,
634 .ops = .none,634 .ops = undefined,
635 .data = undefined,635 .data = undefined,
636 });636 });
637637
...@@ -657,8 +657,8 @@ fn gen(self: *Self) InnerError!void {...@@ -657,8 +657,8 @@ fn gen(self: *Self) InnerError!void {
657657
658 // Push callee-preserved regs that were used actually in use.658 // Push callee-preserved regs that were used actually in use.
659 const backpatch_push_callee_preserved_regs = try self.addInst(.{659 const backpatch_push_callee_preserved_regs = try self.addInst(.{
660 .tag = .nop,660 .tag = .dead,
661 .ops = .none,661 .ops = undefined,
662 .data = undefined,662 .data = undefined,
663 });663 });
664664
...@@ -688,8 +688,8 @@ fn gen(self: *Self) InnerError!void {...@@ -688,8 +688,8 @@ fn gen(self: *Self) InnerError!void {
688688
689 // Pop saved callee-preserved regs.689 // Pop saved callee-preserved regs.
690 const backpatch_pop_callee_preserved_regs = try self.addInst(.{690 const backpatch_pop_callee_preserved_regs = try self.addInst(.{
691 .tag = .nop,691 .tag = .dead,
692 .ops = .none,692 .ops = undefined,
693 .data = undefined,693 .data = undefined,
694 });694 });
695695
...@@ -701,8 +701,8 @@ fn gen(self: *Self) InnerError!void {...@@ -701,8 +701,8 @@ fn gen(self: *Self) InnerError!void {
701701
702 // Maybe add rsp, x if required. This is backpatched later.702 // Maybe add rsp, x if required. This is backpatched later.
703 const backpatch_stack_add = try self.addInst(.{703 const backpatch_stack_add = try self.addInst(.{
704 .tag = .nop,704 .tag = .dead,
705 .ops = .none,705 .ops = undefined,
706 .data = undefined,706 .data = undefined,
707 });707 });
708708
src/arch/x86_64/Emit.zig+2
...@@ -137,6 +137,8 @@ pub fn lowerMir(emit: *Emit) InnerError!void {...@@ -137,6 +137,8 @@ pub fn lowerMir(emit: *Emit) InnerError!void {
137137
138 .push_regs => try emit.mirPushPopRegisterList(.push, inst),138 .push_regs => try emit.mirPushPopRegisterList(.push, inst),
139 .pop_regs => try emit.mirPushPopRegisterList(.pop, inst),139 .pop_regs => try emit.mirPushPopRegisterList(.pop, inst),
140
141 .dead => {},
140 }142 }
141 }143 }
142144
src/arch/x86_64/Mir.zig+4
...@@ -163,6 +163,10 @@ pub const Inst = struct {...@@ -163,6 +163,10 @@ pub const Inst = struct {
163 /// Pop registers163 /// Pop registers
164 /// Uses `payload` payload with data of type `SaveRegisterList`.164 /// Uses `payload` payload with data of type `SaveRegisterList`.
165 pop_regs,165 pop_regs,
166
167 /// Tombstone
168 /// Emitter should skip this instruction.
169 dead,
166 };170 };
167171
168 pub const Ops = enum(u8) {172 pub const Ops = enum(u8) {