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:
@@ -444,6 +444,8 @@ pub struct ValueTypeSet {
|
||||
pub floats: BitSet8,
|
||||
/// Allowed bool widths
|
||||
pub bools: BitSet8,
|
||||
/// Allowed ref widths
|
||||
pub refs: BitSet8,
|
||||
}
|
||||
|
||||
impl ValueTypeSet {
|
||||
@@ -458,6 +460,8 @@ impl ValueTypeSet {
|
||||
self.floats.contains(l2b)
|
||||
} else if scalar.is_bool() {
|
||||
self.bools.contains(l2b)
|
||||
} else if scalar.is_ref() {
|
||||
self.refs.contains(l2b)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
@@ -652,6 +656,7 @@ mod tests {
|
||||
ints: BitSet8::from_range(4, 7),
|
||||
floats: BitSet8::from_range(0, 0),
|
||||
bools: BitSet8::from_range(3, 7),
|
||||
refs: BitSet8::from_range(5, 7),
|
||||
};
|
||||
assert!(!vts.contains(I8));
|
||||
assert!(vts.contains(I32));
|
||||
@@ -661,6 +666,8 @@ mod tests {
|
||||
assert!(!vts.contains(B1));
|
||||
assert!(vts.contains(B8));
|
||||
assert!(vts.contains(B64));
|
||||
assert!(vts.contains(R32));
|
||||
assert!(vts.contains(R64));
|
||||
assert_eq!(vts.example().to_string(), "i32");
|
||||
|
||||
let vts = ValueTypeSet {
|
||||
@@ -668,6 +675,7 @@ mod tests {
|
||||
ints: BitSet8::from_range(0, 0),
|
||||
floats: BitSet8::from_range(5, 7),
|
||||
bools: BitSet8::from_range(3, 7),
|
||||
refs: BitSet8::from_range(0, 0),
|
||||
};
|
||||
assert_eq!(vts.example().to_string(), "f32");
|
||||
|
||||
@@ -676,6 +684,7 @@ mod tests {
|
||||
ints: BitSet8::from_range(0, 0),
|
||||
floats: BitSet8::from_range(5, 7),
|
||||
bools: BitSet8::from_range(3, 7),
|
||||
refs: BitSet8::from_range(0, 0),
|
||||
};
|
||||
assert_eq!(vts.example().to_string(), "f32x2");
|
||||
|
||||
@@ -684,6 +693,7 @@ mod tests {
|
||||
ints: BitSet8::from_range(0, 0),
|
||||
floats: BitSet8::from_range(0, 0),
|
||||
bools: BitSet8::from_range(3, 7),
|
||||
refs: BitSet8::from_range(0, 0),
|
||||
};
|
||||
assert!(!vts.contains(B32X2));
|
||||
assert!(vts.contains(B32X4));
|
||||
@@ -695,8 +705,11 @@ mod tests {
|
||||
ints: BitSet8::from_range(3, 7),
|
||||
floats: BitSet8::from_range(0, 0),
|
||||
bools: BitSet8::from_range(0, 0),
|
||||
refs: BitSet8::from_range(0, 0),
|
||||
};
|
||||
assert!(vts.contains(I32));
|
||||
assert!(vts.contains(I32X4));
|
||||
assert!(!vts.contains(R32));
|
||||
assert!(!vts.contains(R64));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ impl Type {
|
||||
B1 => 0,
|
||||
B8 | I8 => 3,
|
||||
B16 | I16 => 4,
|
||||
B32 | I32 | F32 => 5,
|
||||
B64 | I64 | F64 => 6,
|
||||
B32 | I32 | F32 | R32 => 5,
|
||||
B64 | I64 | F64 | R64 => 6,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
@@ -73,8 +73,8 @@ impl Type {
|
||||
B1 => 1,
|
||||
B8 | I8 => 8,
|
||||
B16 | I16 => 16,
|
||||
B32 | I32 | F32 => 32,
|
||||
B64 | I64 | F64 => 64,
|
||||
B32 | I32 | F32 | R32 => 32,
|
||||
B64 | I64 | F64 | R64 => 64,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ impl Type {
|
||||
/// Get a type with the same number of lanes as this type, but with the lanes replaced by
|
||||
/// booleans of the same size.
|
||||
///
|
||||
/// Scalar types are treated as vectors with one lane, so they are converted to the multi-bit
|
||||
/// Lane types are treated as vectors with one lane, so they are converted to the multi-bit
|
||||
/// boolean types.
|
||||
pub fn as_bool_pedantic(self) -> Self {
|
||||
// Replace the low 4 bits with the boolean version, preserve the high 4 bits.
|
||||
@@ -108,6 +108,7 @@ impl Type {
|
||||
B16 | I16 => B16,
|
||||
B32 | I32 | F32 => B32,
|
||||
B64 | I64 | F64 => B64,
|
||||
R32 | R64 => panic!("Reference types should not convert to bool"),
|
||||
_ => B1,
|
||||
})
|
||||
}
|
||||
@@ -210,6 +211,14 @@ impl Type {
|
||||
}
|
||||
}
|
||||
|
||||
/// Is this a ref type?
|
||||
pub fn is_ref(self) -> bool {
|
||||
match self {
|
||||
R32 | R64 => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get log_2 of the number of lanes in this SIMD vector type.
|
||||
///
|
||||
/// All SIMD types have a lane count that is a power of two and no larger than 256, so this
|
||||
@@ -301,6 +310,8 @@ impl Display for Type {
|
||||
write!(f, "f{}", self.lane_bits())
|
||||
} else if self.is_vector() {
|
||||
write!(f, "{}x{}", self.lane_type(), self.lane_count())
|
||||
} else if self.is_ref() {
|
||||
write!(f, "r{}", self.lane_bits())
|
||||
} else {
|
||||
f.write_str(match *self {
|
||||
IFLAGS => "iflags",
|
||||
@@ -322,6 +333,8 @@ impl Debug for Type {
|
||||
write!(f, "types::F{}", self.lane_bits())
|
||||
} else if self.is_vector() {
|
||||
write!(f, "{:?}X{}", self.lane_type(), self.lane_count())
|
||||
} else if self.is_ref() {
|
||||
write!(f, "types::R{}", self.lane_bits())
|
||||
} else {
|
||||
match *self {
|
||||
INVALID => write!(f, "types::INVALID"),
|
||||
@@ -366,6 +379,8 @@ mod tests {
|
||||
assert_eq!(B1, B1.by(8).unwrap().lane_type());
|
||||
assert_eq!(I32, I32X4.lane_type());
|
||||
assert_eq!(F64, F64X2.lane_type());
|
||||
assert_eq!(R32, R32.lane_type());
|
||||
assert_eq!(R64, R64.lane_type());
|
||||
|
||||
assert_eq!(INVALID.lane_bits(), 0);
|
||||
assert_eq!(IFLAGS.lane_bits(), 0);
|
||||
@@ -381,6 +396,8 @@ mod tests {
|
||||
assert_eq!(I64.lane_bits(), 64);
|
||||
assert_eq!(F32.lane_bits(), 32);
|
||||
assert_eq!(F64.lane_bits(), 64);
|
||||
assert_eq!(R32.lane_bits(), 32);
|
||||
assert_eq!(R64.lane_bits(), 64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -450,6 +467,8 @@ mod tests {
|
||||
assert_eq!(I64.to_string(), "i64");
|
||||
assert_eq!(F32.to_string(), "f32");
|
||||
assert_eq!(F64.to_string(), "f64");
|
||||
assert_eq!(R32.to_string(), "r32");
|
||||
assert_eq!(R64.to_string(), "r64");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user