Apply register diversions during binemit tests.
When "binemit" tests encode instructions, keep track of the current set of register diversions, and use the diverted locations to check operand constraints. This matches how constraints are applied during a real binemit phase.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
//! EBB.
|
||||
|
||||
use ir::{Value, ValueLoc, ValueLocations, StackSlot};
|
||||
use ir::{InstructionData, Opcode};
|
||||
use isa::{RegUnit, RegInfo};
|
||||
use std::fmt;
|
||||
|
||||
@@ -118,6 +119,34 @@ impl RegDiversions {
|
||||
self.divert(value, ValueLoc::Stack(from), ValueLoc::Reg(to));
|
||||
}
|
||||
|
||||
/// Apply the effect of `inst`.
|
||||
///
|
||||
/// If `inst` is a `regmove`, `regfill`, or `regspill` instruction, update the diversions to
|
||||
/// match.
|
||||
pub fn apply(&mut self, inst: &InstructionData) {
|
||||
match *inst {
|
||||
InstructionData::RegMove {
|
||||
opcode: Opcode::Regmove,
|
||||
arg,
|
||||
src,
|
||||
dst,
|
||||
} => self.regmove(arg, src, dst),
|
||||
InstructionData::RegSpill {
|
||||
opcode: Opcode::Regspill,
|
||||
arg,
|
||||
src,
|
||||
dst,
|
||||
} => self.regspill(arg, src, dst),
|
||||
InstructionData::RegFill {
|
||||
opcode: Opcode::Regfill,
|
||||
arg,
|
||||
src,
|
||||
dst,
|
||||
} => self.regfill(arg, src, dst),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Drop any recorded move for `value`.
|
||||
///
|
||||
/// Returns the `to` location of the removed diversion.
|
||||
|
||||
Reference in New Issue
Block a user