| ... | ... | @@ -6595,35 +6595,26 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { |
| 6595 | 6595 | if (Air.refToIndex(pl_op.operand)) |op_inst| self.processDeath(op_inst); |
| 6596 | 6596 | } |
| 6597 | 6597 | |
| 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(); |
| 6602 | 6600 | |
| 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 | }); |
| 6611 | 6609 | |
| 6612 | | try self.performReloc(reloc); |
| 6610 | try self.performReloc(reloc); |
| 6613 | 6611 | |
| 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, &.{}, .{ |
| 6624 | 6615 | .emit_instructions = false, |
| 6625 | | .update_tracking = false, |
| 6626 | | .resurrect = false, |
| 6616 | .update_tracking = true, |
| 6617 | .resurrect = true, |
| 6627 | 6618 | .close_scope = true, |
| 6628 | 6619 | }); |
| 6629 | 6620 | |
| ... | ... | @@ -6996,64 +6987,55 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) !void { |
| 6996 | 6987 | if (Air.refToIndex(pl_op.operand)) |op_inst| self.processDeath(op_inst); |
| 6997 | 6988 | } |
| 6998 | 6989 | |
| 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(); |
| 7012 | 6992 | |
| 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; |
| 7015 | 7001 | |
| 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); |
| 7022 | 7004 | |
| 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 | } |
| 7024 | 7011 | |
| 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); |
| 7032 | 7013 | |
| 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 | }); |
| 7035 | 7021 | |
| 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 | } |
| 7038 | 7024 | |
| 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]; |
| 7041 | 7027 | |
| 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 | }); |
| 7050 | 7038 | } |
| 7051 | | try self.restoreState(outer_state, &.{}, .{ |
| 7052 | | .emit_instructions = false, |
| 7053 | | .update_tracking = false, |
| 7054 | | .resurrect = false, |
| 7055 | | .close_scope = true, |
| 7056 | | }); |
| 7057 | 7039 | |
| 7058 | 7040 | // We already took care of pl_op.operand earlier, so we're going to pass .none here |
| 7059 | 7041 | return self.finishAir(inst, .unreach, .{ .none, .none, .none }); |