Define stack_load, stack_store, and stack_addr instructions.

This commit is contained in:
Jakob Stoklund Olesen
2017-04-10 13:20:41 -07:00
parent af2516e996
commit c52e3e0b3f
10 changed files with 163 additions and 56 deletions

View File

@@ -57,7 +57,8 @@ use dominator_tree::DominatorTree;
use flowgraph::ControlFlowGraph;
use ir::entities::AnyEntity;
use ir::instructions::{InstructionFormat, BranchInfo, ResolvedConstraint, CallInfo};
use ir::{types, Function, ValueDef, Ebb, Inst, SigRef, FuncRef, ValueList, JumpTable, Value, Type};
use ir::{types, Function, ValueDef, Ebb, Inst, SigRef, FuncRef, ValueList, JumpTable, StackSlot,
Value, Type};
use Context;
use std::fmt::{self, Display, Formatter};
use std::result;
@@ -248,6 +249,11 @@ impl<'a> Verifier<'a> {
self.verify_sig_ref(inst, sig_ref)?;
self.verify_value_list(inst, args)?;
}
&StackLoad { stack_slot, .. } |
&StackStore { stack_slot, .. } => {
self.verify_stack_slot(inst, stack_slot)?;
}
// Exhaustive list so we can't forget to add new formats
&Nullary { .. } |
&Unary { .. } |
@@ -293,6 +299,14 @@ impl<'a> Verifier<'a> {
}
}
fn verify_stack_slot(&self, inst: Inst, ss: StackSlot) -> Result<()> {
if !self.func.stack_slots.is_valid(ss) {
err!(inst, "invalid stack slot {}", ss)
} else {
Ok(())
}
}
fn verify_value_list(&self, inst: Inst, l: &ValueList) -> Result<()> {
if !l.is_valid(&self.func.dfg.value_lists) {
err!(inst, "invalid value list reference {:?}", l)