diff --git a/src/checker.rs b/src/checker.rs index 55f4860..d66610a 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -426,12 +426,22 @@ impl CheckerState { match op.constraint() { OperandConstraint::Any => {} OperandConstraint::Reg => { - if alloc.kind() != AllocationKind::Reg { - return Err(CheckerError::AllocationIsNotReg { inst, op, alloc }); + // Reject pregs that represent a fixed stack slot. + if let Some(preg) = alloc.as_reg() { + if preg.class() == RegClass::Int && (0..32).contains(&preg.hw_enc()) { + return Ok(()); + } } + return Err(CheckerError::AllocationIsNotReg { inst, op, alloc }); } OperandConstraint::Stack => { if alloc.kind() != AllocationKind::Stack { + // Accept pregs that represent a fixed stack slot. + if let Some(preg) = alloc.as_reg() { + if preg.class() == RegClass::Int && (32..63).contains(&preg.hw_enc()) { + return Ok(()); + } + } return Err(CheckerError::AllocationIsNotStack { inst, op, alloc }); } } diff --git a/src/fuzzing/func.rs b/src/fuzzing/func.rs index e5174cb..cbc9717 100644 --- a/src/fuzzing/func.rs +++ b/src/fuzzing/func.rs @@ -465,7 +465,7 @@ impl Func { let mut fixed = vec![]; for _ in 0..u.int_in_range(0..=operands.len() - 1)? { // Pick an operand and make it a fixed reg. - let fixed_reg = PReg::new(u.int_in_range(0..=30)?, RegClass::Int); + let fixed_reg = PReg::new(u.int_in_range(0..=62)?, RegClass::Int); if fixed.contains(&fixed_reg) { break; } @@ -602,15 +602,18 @@ impl std::fmt::Debug for Func { } pub fn machine_env() -> MachineEnv { - // Reg 31 is the scratch reg. - let regs: Vec = (0..31).map(|i| PReg::new(i, RegClass::Int)).collect(); - let preferred_regs_by_class: [Vec; 2] = [regs.iter().cloned().take(24).collect(), vec![]]; - let non_preferred_regs_by_class: [Vec; 2] = - [regs.iter().cloned().skip(24).collect(), vec![]]; - let scratch_by_class: [PReg; 2] = [PReg::new(31, RegClass::Int), PReg::new(0, RegClass::Float)]; + // Reg 63 is the scratch reg. + fn regs(r: std::ops::Range) -> Vec { + r.map(|i| PReg::new(i, RegClass::Int)).collect() + } + let preferred_regs_by_class: [Vec; 2] = [regs(0..24), vec![]]; + let non_preferred_regs_by_class: [Vec; 2] = [regs(24..32), vec![]]; + let scratch_by_class: [PReg; 2] = [PReg::new(63, RegClass::Int), PReg::new(0, RegClass::Float)]; + let fixed_stack_slots = regs(32..63); MachineEnv { preferred_regs_by_class, non_preferred_regs_by_class, scratch_by_class, + fixed_stack_slots, } }