Add fixed stack slots to the fuzzer

This commit is contained in:
Amanieu d'Antras
2021-11-28 17:52:50 +00:00
parent 8f435243e0
commit 870e4729e1
2 changed files with 22 additions and 9 deletions

View File

@@ -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 });
}
}