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

This commit is contained in:
Jakub Konka 2023-03-11 09:29:53 +01:00
parent 621fc36b55
commit c9a153c797
3 changed files with 14 additions and 8 deletions

View File

@ -630,8 +630,8 @@ fn gen(self: *Self) InnerError!void {
// TODO During semantic analysis, check if there are no function calls. If there
// are none, here we can omit the part where we subtract and then add rsp.
const backpatch_stack_sub = try self.addInst(.{
.tag = .nop,
.ops = .none,
.tag = .dead,
.ops = undefined,
.data = undefined,
});
@ -657,8 +657,8 @@ fn gen(self: *Self) InnerError!void {
// Push callee-preserved regs that were used actually in use.
const backpatch_push_callee_preserved_regs = try self.addInst(.{
.tag = .nop,
.ops = .none,
.tag = .dead,
.ops = undefined,
.data = undefined,
});
@ -688,8 +688,8 @@ fn gen(self: *Self) InnerError!void {
// Pop saved callee-preserved regs.
const backpatch_pop_callee_preserved_regs = try self.addInst(.{
.tag = .nop,
.ops = .none,
.tag = .dead,
.ops = undefined,
.data = undefined,
});
@ -701,8 +701,8 @@ fn gen(self: *Self) InnerError!void {
// Maybe add rsp, x if required. This is backpatched later.
const backpatch_stack_add = try self.addInst(.{
.tag = .nop,
.ops = .none,
.tag = .dead,
.ops = undefined,
.data = undefined,
});

View File

@ -137,6 +137,8 @@ pub fn lowerMir(emit: *Emit) InnerError!void {
.push_regs => try emit.mirPushPopRegisterList(.push, inst),
.pop_regs => try emit.mirPushPopRegisterList(.pop, inst),
.dead => {},
}
}

View File

@ -163,6 +163,10 @@ pub const Inst = struct {
/// Pop registers
/// Uses `payload` payload with data of type `SaveRegisterList`.
pop_regs,
/// Tombstone
/// Emitter should skip this instruction.
dead,
};
pub const Ops = enum(u8) {