authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-04 15:31:54-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-04 15:31:54-07:00
log02d09d13281a10dbab0d80d07935712b1fc50756
tree07b44df54da2f66b38b4c1c363c2471017b3e3c0
parentea3cc777ccccf3113d7724898c35473343f71080

codegen: introduce toCanonicalReg to clean up x86-specific logic


1 files changed, 12 insertions(+), 3 deletions(-)

src-self-hosted/codegen.zig+12-3
...@@ -588,9 +588,9 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -588,9 +588,9 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
588 entry.value = .dead;588 entry.value = .dead;
589 switch (prev_value) {589 switch (prev_value) {
590 .register => |reg| {590 .register => |reg| {
591 const reg64 = if (arch == .x86_64) reg.to64() else reg;591 const canon_reg = toCanonicalReg(reg);
592 _ = branch.registers.remove(reg64);592 _ = branch.registers.remove(canon_reg);
593 branch.markRegFree(reg64);593 branch.markRegFree(canon_reg);
594 },594 },
595 else => {}, // TODO process stack allocation death595 else => {}, // TODO process stack allocation death
596 }596 }
...@@ -2097,5 +2097,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -2097,5 +2097,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
2097 else => return reg,2097 else => return reg,
2098 }2098 }
2099 }2099 }
2100
2101 /// For most architectures this does nothing. For x86_64 it resolves any aliased registers
2102 /// to the 64-bit wide ones.
2103 fn toCanonicalReg(reg: Register) Register {
2104 return switch (arch) {
2105 .x86_64 => reg.to64(),
2106 else => reg,
2107 };
2108 }
2100 };2109 };
2101}2110}