Use block_insts_and_edits in the checker
This commit is contained in:
@@ -77,8 +77,8 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use crate::{
|
||||
Allocation, AllocationKind, Block, Edit, Function, Inst, InstPosition, Operand,
|
||||
OperandConstraint, OperandKind, OperandPos, Output, PReg, ProgPoint, RegClass, VReg,
|
||||
Allocation, AllocationKind, Block, Edit, Function, Inst, InstOrEdit, InstPosition, Operand,
|
||||
OperandConstraint, OperandKind, OperandPos, Output, PReg, RegClass, VReg,
|
||||
};
|
||||
|
||||
use std::collections::{HashMap, HashSet, VecDeque};
|
||||
@@ -544,18 +544,30 @@ impl<'a, F: Function> Checker<'a, F> {
|
||||
.push(slot);
|
||||
}
|
||||
|
||||
// For each original instruction, create an `Op`.
|
||||
let mut last_inst = None;
|
||||
let mut insert_idx = 0;
|
||||
for block in 0..self.f.num_blocks() {
|
||||
let block = Block::new(block);
|
||||
for inst in self.f.block_insns(block).iter() {
|
||||
for inst_or_edit in out.block_insts_and_edits(self.f, block) {
|
||||
match inst_or_edit {
|
||||
InstOrEdit::Inst(inst) => {
|
||||
assert!(last_inst.is_none() || inst > last_inst.unwrap());
|
||||
last_inst = Some(inst);
|
||||
self.handle_inst(block, inst, &mut safepoint_slots, out);
|
||||
}
|
||||
InstOrEdit::Edit(edit) => self.handle_edit(block, edit),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Any inserted edits before instruction.
|
||||
self.handle_edits(block, out, &mut insert_idx, ProgPoint::before(inst));
|
||||
|
||||
/// For each original instruction, create an `Op`.
|
||||
fn handle_inst(
|
||||
&mut self,
|
||||
block: Block,
|
||||
inst: Inst,
|
||||
safepoint_slots: &mut HashMap<Inst, Vec<Allocation>>,
|
||||
out: &Output,
|
||||
) {
|
||||
// If this is a safepoint, then check the spillslots at this point.
|
||||
if self.f.requires_refs_on_stack(inst) {
|
||||
let allocs = safepoint_slots.remove(&inst).unwrap_or_else(|| vec![]);
|
||||
@@ -582,21 +594,10 @@ impl<'a, F: Function> Checker<'a, F> {
|
||||
log::trace!("checker: adding inst {:?}", checkinst);
|
||||
self.bb_insts.get_mut(&block).unwrap().push(checkinst);
|
||||
}
|
||||
|
||||
// Any inserted edits after instruction.
|
||||
self.handle_edits(block, out, &mut insert_idx, ProgPoint::after(inst));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_edits(&mut self, block: Block, out: &Output, idx: &mut usize, pos: ProgPoint) {
|
||||
while *idx < out.edits.len() && out.edits[*idx].0 <= pos {
|
||||
let &(edit_pos, ref edit) = &out.edits[*idx];
|
||||
*idx += 1;
|
||||
if edit_pos < pos {
|
||||
continue;
|
||||
}
|
||||
log::trace!("checker: adding edit {:?} at pos {:?}", edit, pos);
|
||||
fn handle_edit(&mut self, block: Block, edit: &Edit) {
|
||||
log::trace!("checker: adding edit {:?}", edit);
|
||||
match edit {
|
||||
&Edit::Move { from, to, to_vreg } => {
|
||||
self.bb_insts
|
||||
@@ -618,7 +619,6 @@ impl<'a, F: Function> Checker<'a, F> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform the dataflow analysis to compute checker state at each BB entry.
|
||||
fn analyze(&mut self) {
|
||||
|
||||
Reference in New Issue
Block a user