(&mut self, value: Value)
| 713 | } |
| 714 | |
| 715 | fn check_value(&mut self, value: Value) -> Result<()> { |
| 716 | let value_bank = self.func.value_bank(value); |
| 717 | ensure!( |
| 718 | !self |
| 719 | .reginfo |
| 720 | .class_members(self.reginfo.top_level_class(value_bank)) |
| 721 | .is_empty(), |
| 722 | "{value} cannot be in empty register bank {value_bank}" |
| 723 | ); |
| 724 | if let Some((_cost, class)) = self.func.can_rematerialize(value) { |
| 725 | ensure!( |
| 726 | self.reginfo.class_group_size(class) == 1, |
| 727 | "{value} direct remat target: Value used with group register class" |
| 728 | ); |
| 729 | let bank = self.reginfo.bank_for_class(class); |
| 730 | ensure!( |
| 731 | bank == value_bank, |
| 732 | "{value} direct remat target: {value} used with different register banks: {bank} \ |
| 733 | vs {value_bank}" |
| 734 | ); |
| 735 | ensure!( |
| 736 | !self.reginfo.allocation_order(class).is_empty(), |
| 737 | "{value} direct remat target uses register class {class} with an empty allocation \ |
| 738 | order" |
| 739 | ); |
| 740 | for reg in self.reginfo.class_members(class) { |
| 741 | ensure!( |
| 742 | self.reginfo.class_includes_spillslots(class) || !self.reginfo.is_memory(reg), |
| 743 | "{value} direct remat target uses register class {class} which has in-memory \ |
| 744 | members but doesn't include spill slots" |
| 745 | ); |
| 746 | } |
| 747 | } |
| 748 | if let Some(remat) = self.func.can_indirectly_rematerialize(value) { |
| 749 | ensure!( |
| 750 | !remat.inputs.is_empty(), |
| 751 | "{value} cannot have indirect rematerialization with no inputs" |
| 752 | ); |
| 753 | ensure!( |
| 754 | remat.inputs.len() <= MAX_INST_OPERANDS, |
| 755 | "{value} indirect remat has too many inputs: {} (max: {MAX_INST_OPERANDS})", |
| 756 | remat.inputs.len(), |
| 757 | ); |
| 758 | ensure!( |
| 759 | !remat |
| 760 | .inputs |
| 761 | .iter() |
| 762 | .all(|op| matches!(op.kind(), OperandKind::NonAllocatable)), |
| 763 | "{value} cannot have indirect rematerialization with only NonAllocatable inputs" |
| 764 | ); |
| 765 | |
| 766 | self.early_fixed.clear(); |
| 767 | self.late_fixed.clear(); |
| 768 | self.reuse_targets.clear(); |
| 769 | let source = ConstraintSource::Remat(value); |
| 770 | let dest = match remat.constraint { |
| 771 | OperandConstraint::Reuse(_) => { |
| 772 | Operand::new(OperandKind::EarlyDef(value), remat.constraint) |
no test coverage detected