Expanded instruction integrity checking in the verifier, now verifying result types and entity references.

This commit is contained in:
Angus Holder
2017-03-13 21:51:16 +00:00
committed by Jakob Stoklund Olesen
parent d3df198747
commit 477fb4d5da
3 changed files with 152 additions and 3 deletions

View File

@@ -82,6 +82,11 @@ impl DataFlowGraph {
pub fn num_ebbs(&self) -> usize {
self.ebbs.len()
}
/// Returns `true` if the given ebb reference is valid.
pub fn ebb_is_valid(&self, ebb: Ebb) -> bool {
self.ebbs.is_valid(ebb)
}
}
/// Handling values.
@@ -95,6 +100,14 @@ impl DataFlowGraph {
vref
}
/// Check if a value reference is valid.
pub fn value_is_valid(&self, v: Value) -> bool {
match v.expand() {
ExpandedValue::Direct(inst) => self.insts.is_valid(inst),
ExpandedValue::Table(index) => index < self.extended_values.len(),
}
}
/// Get the type of a value.
pub fn value_type(&self, v: Value) -> Type {
use ir::entities::ExpandedValue::*;