Add a verifier

The current implementation only performs a few basic checks.
This commit is contained in:
Morgan Phillips
2016-09-06 14:05:44 -07:00
parent 78a9e67a09
commit d8712b2ce6
10 changed files with 287 additions and 3 deletions

View File

@@ -55,7 +55,7 @@ impl Layout {
/// can only be removed from the layout when it is empty.
///
/// Since every EBB must end with a terminator instruction which cannot fall through, the layout of
/// EBBs does not affect the semantics of the program.
/// EBBs do not affect the semantics of the program.
///
impl Layout {
/// Is `ebb` currently part of the layout?
@@ -188,6 +188,11 @@ impl Layout {
ebb_node.last_inst = inst;
}
/// Fetch an ebb's last instruction.
pub fn last_inst(&self, ebb: Ebb) -> Inst {
self.ebbs[ebb].last_inst
}
/// Insert `inst` before the instruction `before` in the same EBB.
pub fn insert_inst(&mut self, inst: Inst, before: Inst) {
assert_eq!(self.inst_ebb(inst), None);