Add reference types R32 and R64

-Add resumable_trap, safepoint, isnull, and null instructions
-Add Stackmap struct and StackmapSink trait

Co-authored-by: Mir Ahmed <mirahmed753@gmail.com>
Co-authored-by: Dan Gohman <sunfish@mozilla.com>
This commit is contained in:
Carmen Kwan
2019-07-23 16:28:54 -07:00
committed by Dan Gohman
parent b659262d2a
commit 19257f80c1
47 changed files with 1027 additions and 62 deletions

View File

@@ -12,7 +12,7 @@ use crate::cdsl::formats::{
};
use crate::cdsl::operands::Operand;
use crate::cdsl::type_inference::Constraint;
use crate::cdsl::types::{LaneType, ValueType, VectorType};
use crate::cdsl::types::{LaneType, ReferenceType, ValueType, VectorType};
use crate::cdsl::typevar::TypeVar;
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
@@ -177,6 +177,10 @@ impl Instruction {
bind(self.clone(), Some(lane_type.into()), Vec::new())
}
pub fn bind_ref(&self, reference_type: impl Into<ReferenceType>) -> BoundInstruction {
bind_ref(self.clone(), Some(reference_type.into()), Vec::new())
}
pub fn bind_vector(&self, lane_type: impl Into<LaneType>, num_lanes: u64) -> BoundInstruction {
bind_vector(self.clone(), lane_type.into(), num_lanes, Vec::new())
}
@@ -406,6 +410,10 @@ impl BoundInstruction {
bind(self.inst, Some(lane_type.into()), self.value_types)
}
pub fn bind_ref(self, reference_type: impl Into<ReferenceType>) -> BoundInstruction {
bind_ref(self.inst, Some(reference_type.into()), self.value_types)
}
pub fn bind_vector(self, lane_type: impl Into<LaneType>, num_lanes: u64) -> BoundInstruction {
bind_vector(self.inst, lane_type.into(), num_lanes, self.value_types)
}
@@ -1043,6 +1051,13 @@ impl InstSpec {
InstSpec::Bound(inst) => inst.clone().bind(lane_type),
}
}
pub fn bind_ref(&self, reference_type: impl Into<ReferenceType>) -> BoundInstruction {
match self {
InstSpec::Inst(inst) => inst.bind_ref(reference_type),
InstSpec::Bound(inst) => inst.clone().bind_ref(reference_type),
}
}
}
impl Into<InstSpec> for &Instruction {
@@ -1077,6 +1092,26 @@ fn bind(
BoundInstruction { inst, value_types }
}
/// Helper bind for reference types reused by {Bound,}Instruction::bind_ref.
fn bind_ref(
inst: Instruction,
reference_type: Option<ReferenceType>,
mut value_types: Vec<ValueTypeOrAny>,
) -> BoundInstruction {
match reference_type {
Some(reference_type) => {
value_types.push(ValueTypeOrAny::ValueType(reference_type.into()));
}
None => {
value_types.push(ValueTypeOrAny::Any);
}
}
verify_polymorphic_binding(&inst, &value_types);
BoundInstruction { inst, value_types }
}
/// Helper bind for vector types reused by {Bound,}Instruction::bind.
fn bind_vector(
inst: Instruction,