authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-04-28 01:56:18-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-05-01 19:22:52-04:00
log1fd48815c6e22b266b318f58c6b3c828b20ace80
tree6bb2dc66b8fca96f01314802ae144e6894dc8921
parent6de457211fe4f261fab6c30f652f833ed2a144b5

x86_64: cleanup unneeded code


1 files changed, 56 insertions(+), 74 deletions(-)

src/arch/x86_64/CodeGen.zig+56-74
......@@ -6595,35 +6595,26 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
65956595 if (Air.refToIndex(pl_op.operand)) |op_inst| self.processDeath(op_inst);
65966596 }
65976597
6598 const outer_state = try self.saveState();
6599 {
6600 self.scope_generation += 1;
6601 const inner_state = try self.saveState();
6598 self.scope_generation += 1;
6599 const state = try self.saveState();
66026600
6603 for (liveness_cond_br.then_deaths) |operand| self.processDeath(operand);
6604 try self.genBody(then_body);
6605 try self.restoreState(inner_state, &.{}, .{
6606 .emit_instructions = false,
6607 .update_tracking = true,
6608 .resurrect = true,
6609 .close_scope = true,
6610 });
6601 for (liveness_cond_br.then_deaths) |operand| self.processDeath(operand);
6602 try self.genBody(then_body);
6603 try self.restoreState(state, &.{}, .{
6604 .emit_instructions = false,
6605 .update_tracking = true,
6606 .resurrect = true,
6607 .close_scope = true,
6608 });
66116609
6612 try self.performReloc(reloc);
6610 try self.performReloc(reloc);
66136611
6614 for (liveness_cond_br.else_deaths) |operand| self.processDeath(operand);
6615 try self.genBody(else_body);
6616 try self.restoreState(inner_state, &.{}, .{
6617 .emit_instructions = false,
6618 .update_tracking = true,
6619 .resurrect = true,
6620 .close_scope = true,
6621 });
6622 }
6623 try self.restoreState(outer_state, &.{}, .{
6612 for (liveness_cond_br.else_deaths) |operand| self.processDeath(operand);
6613 try self.genBody(else_body);
6614 try self.restoreState(state, &.{}, .{
66246615 .emit_instructions = false,
6625 .update_tracking = false,
6626 .resurrect = false,
6616 .update_tracking = true,
6617 .resurrect = true,
66276618 .close_scope = true,
66286619 });
66296620
......@@ -6996,64 +6987,55 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) !void {
69966987 if (Air.refToIndex(pl_op.operand)) |op_inst| self.processDeath(op_inst);
69976988 }
69986989
6999 const outer_state = try self.saveState();
7000 {
7001 self.scope_generation += 1;
7002 const inner_state = try self.saveState();
7003
7004 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
7005 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
7006 const items = @ptrCast(
7007 []const Air.Inst.Ref,
7008 self.air.extra[case.end..][0..case.data.items_len],
7009 );
7010 const case_body = self.air.extra[case.end + items.len ..][0..case.data.body_len];
7011 extra_index = case.end + items.len + case_body.len;
6990 self.scope_generation += 1;
6991 const state = try self.saveState();
70126992
7013 var relocs = try self.gpa.alloc(u32, items.len);
7014 defer self.gpa.free(relocs);
6993 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
6994 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
6995 const items = @ptrCast(
6996 []const Air.Inst.Ref,
6997 self.air.extra[case.end..][0..case.data.items_len],
6998 );
6999 const case_body = self.air.extra[case.end + items.len ..][0..case.data.body_len];
7000 extra_index = case.end + items.len + case_body.len;
70157001
7016 for (items, relocs) |item, *reloc| {
7017 try self.spillEflagsIfOccupied();
7018 const item_mcv = try self.resolveInst(item);
7019 try self.genBinOpMir(.cmp, condition_ty, condition, item_mcv);
7020 reloc.* = try self.asmJccReloc(undefined, .ne);
7021 }
7002 var relocs = try self.gpa.alloc(u32, items.len);
7003 defer self.gpa.free(relocs);
70227004
7023 for (liveness.deaths[case_i]) |operand| self.processDeath(operand);
7005 for (items, relocs) |item, *reloc| {
7006 try self.spillEflagsIfOccupied();
7007 const item_mcv = try self.resolveInst(item);
7008 try self.genBinOpMir(.cmp, condition_ty, condition, item_mcv);
7009 reloc.* = try self.asmJccReloc(undefined, .ne);
7010 }
70247011
7025 try self.genBody(case_body);
7026 try self.restoreState(inner_state, &.{}, .{
7027 .emit_instructions = false,
7028 .update_tracking = true,
7029 .resurrect = true,
7030 .close_scope = true,
7031 });
7012 for (liveness.deaths[case_i]) |operand| self.processDeath(operand);
70327013
7033 for (relocs) |reloc| try self.performReloc(reloc);
7034 }
7014 try self.genBody(case_body);
7015 try self.restoreState(state, &.{}, .{
7016 .emit_instructions = false,
7017 .update_tracking = true,
7018 .resurrect = true,
7019 .close_scope = true,
7020 });
70357021
7036 if (switch_br.data.else_body_len > 0) {
7037 const else_body = self.air.extra[extra_index..][0..switch_br.data.else_body_len];
7022 for (relocs) |reloc| try self.performReloc(reloc);
7023 }
70387024
7039 const else_deaths = liveness.deaths.len - 1;
7040 for (liveness.deaths[else_deaths]) |operand| self.processDeath(operand);
7025 if (switch_br.data.else_body_len > 0) {
7026 const else_body = self.air.extra[extra_index..][0..switch_br.data.else_body_len];
70417027
7042 try self.genBody(else_body);
7043 try self.restoreState(inner_state, &.{}, .{
7044 .emit_instructions = false,
7045 .update_tracking = true,
7046 .resurrect = true,
7047 .close_scope = true,
7048 });
7049 }
7028 const else_deaths = liveness.deaths.len - 1;
7029 for (liveness.deaths[else_deaths]) |operand| self.processDeath(operand);
7030
7031 try self.genBody(else_body);
7032 try self.restoreState(state, &.{}, .{
7033 .emit_instructions = false,
7034 .update_tracking = true,
7035 .resurrect = true,
7036 .close_scope = true,
7037 });
70507038 }
7051 try self.restoreState(outer_state, &.{}, .{
7052 .emit_instructions = false,
7053 .update_tracking = false,
7054 .resurrect = false,
7055 .close_scope = true,
7056 });
70577039
70587040 // We already took care of pl_op.operand earlier, so we're going to pass .none here
70597041 return self.finishAir(inst, .unreach, .{ .none, .none, .none });