Add heap_load, heap_store, and heap_addr instructions.

These are used when lowering WebAssembly sandbox code.
This commit is contained in:
Jakob Stoklund Olesen
2017-04-10 15:03:10 -07:00
parent ca12a683ac
commit b5237b6a4a
9 changed files with 110 additions and 46 deletions

View File

@@ -6,7 +6,7 @@
use ir::types;
use ir::{InstructionData, DataFlowGraph, Cursor};
use ir::{Opcode, Type, Inst, Value, Ebb, JumpTable, SigRef, FuncRef, StackSlot, ValueList};
use ir::immediates::{Imm64, Uimm8, Ieee32, Ieee64, Offset32};
use ir::immediates::{Imm64, Uimm8, Ieee32, Ieee64, Offset32, Uoffset32};
use ir::condcodes::{IntCC, FloatCC};
/// Base trait for instruction builders.

View File

@@ -11,7 +11,7 @@ use std::str::FromStr;
use std::ops::{Deref, DerefMut};
use ir::{Value, Type, Ebb, JumpTable, SigRef, FuncRef, StackSlot};
use ir::immediates::{Imm64, Uimm8, Ieee32, Ieee64, Offset32};
use ir::immediates::{Imm64, Uimm8, Ieee32, Ieee64, Offset32, Uoffset32};
use ir::condcodes::*;
use ir::types;
use ir::DataFlowGraph;
@@ -240,6 +240,18 @@ pub enum InstructionData {
stack_slot: StackSlot,
offset: Offset32,
},
HeapLoad {
opcode: Opcode,
ty: Type,
arg: Value,
offset: Uoffset32,
},
HeapStore {
opcode: Opcode,
ty: Type,
args: [Value; 2],
offset: Uoffset32,
},
}
/// A variable list of `Value` operands used for function call arguments and passing arguments to

View File

@@ -269,7 +269,9 @@ impl<'a> Verifier<'a> {
&ExtractLane { .. } |
&IntCompare { .. } |
&IntCompareImm { .. } |
&FloatCompare { .. } => {}
&FloatCompare { .. } |
&HeapLoad { .. } |
&HeapStore { .. } => {}
}
Ok(())

View File

@@ -320,6 +320,8 @@ pub fn write_operands(w: &mut Write, dfg: &DataFlowGraph, inst: Inst) -> Result
offset,
..
} => write!(w, " {}, {}{}", arg, stack_slot, offset),
HeapLoad { arg, offset, .. } => write!(w, " {}{}", arg, offset),
HeapStore { args, offset, .. } => write!(w, " {}, {}{}", args[0], args[1], offset),
}
}