MCPcopy Create free account
hub / github.com/Amanieu/regalloc3 / check_constraint

Method check_constraint

src/debug_utils/validate_func.rs:183–343  ·  view source on GitHub ↗

Check an operand with a constraint.

(
        &mut self,
        source: ConstraintSource,
        operands: &[Operand],
        operand: Operand,
        value_or_group: ValueOrGroup,
    )

Source from the content-addressed store, hash-verified

181
182 /// Check an operand with a constraint.
183 fn check_constraint(
184 &mut self,
185 source: ConstraintSource,
186 operands: &[Operand],
187 operand: Operand,
188 value_or_group: ValueOrGroup,
189 ) -> Result<()> {
190 match operand.constraint() {
191 OperandConstraint::Class(class) => {
192 let bank = self.reginfo.bank_for_class(class);
193 let group_size = self.reginfo.class_group_size(class);
194 match value_or_group {
195 ValueOrGroup::Value(value) => {
196 ensure!(
197 group_size == 1,
198 "{source} {operand}: Value used with group register class"
199 );
200 ensure!(
201 !self.reginfo.class_members(class).is_empty(),
202 "{source} {operand}: {value} constrained to empty register class"
203 );
204 let value_bank = self.func.value_bank(value);
205 ensure!(
206 bank == value_bank,
207 "{source} {operand}: {value} used with different register banks: \
208 {bank} vs {value_bank}"
209 );
210 }
211 ValueOrGroup::Group(group) => {
212 let members = self.func.value_group_members(group);
213 ensure!(
214 group_size == members.len(),
215 "{source} {operand}: group size mismatch {group_size} vs {}",
216 members.len()
217 );
218 ensure!(
219 !self.reginfo.class_group_members(class).is_empty(),
220 "{source} {operand}: {group} constrained to empty register class"
221 );
222 for &value in members {
223 let value_bank = self.func.value_bank(value);
224 ensure!(
225 bank == value_bank,
226 "{source} {operand}: {value} used with different register banks: \
227 {bank} vs {value_bank}"
228 );
229 }
230 }
231 }
232 }
233 OperandConstraint::Fixed(reg) => {
234 match value_or_group {
235 ValueOrGroup::Value(value) => {
236 let Some(bank) = self.reginfo.bank_for_reg(reg) else {
237 bail!("{source} {operand}: Use of non-allocatable register");
238 };
239 let value_bank = self.func.value_bank(value);
240 ensure!(

Callers 2

check_instMethod · 0.45
check_valueMethod · 0.45

Calls 13

constraintMethod · 0.80
bank_for_classMethod · 0.80
class_group_sizeMethod · 0.80
bank_for_regMethod · 0.80
check_fixedMethod · 0.80
pushMethod · 0.80
membersMethod · 0.80
value_bankMethod · 0.45
value_group_membersMethod · 0.45
kindMethod · 0.45
getMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected