Add b128 type to fix tests

This commit is contained in:
bjorn3
2019-07-08 18:42:28 +02:00
committed by Dan Gohman
parent fa9602df80
commit 67593d997b
6 changed files with 41 additions and 25 deletions

View File

@@ -215,13 +215,14 @@ impl LaneType {
LaneType::BoolType(shared_types::Bool::B16) => 2,
LaneType::BoolType(shared_types::Bool::B32) => 3,
LaneType::BoolType(shared_types::Bool::B64) => 4,
LaneType::IntType(shared_types::Int::I8) => 5,
LaneType::IntType(shared_types::Int::I16) => 6,
LaneType::IntType(shared_types::Int::I32) => 7,
LaneType::IntType(shared_types::Int::I64) => 8,
LaneType::IntType(shared_types::Int::I128) => 9,
LaneType::FloatType(shared_types::Float::F32) => 10,
LaneType::FloatType(shared_types::Float::F64) => 11,
LaneType::BoolType(shared_types::Bool::B128) => 5,
LaneType::IntType(shared_types::Int::I8) => 6,
LaneType::IntType(shared_types::Int::I16) => 7,
LaneType::IntType(shared_types::Int::I32) => 8,
LaneType::IntType(shared_types::Int::I64) => 9,
LaneType::IntType(shared_types::Int::I128) => 10,
LaneType::FloatType(shared_types::Float::F32) => 11,
LaneType::FloatType(shared_types::Float::F64) => 12,
}
}
@@ -232,6 +233,7 @@ impl LaneType {
16 => shared_types::Bool::B16,
32 => shared_types::Bool::B32,
64 => shared_types::Bool::B64,
128 => shared_types::Bool::B128,
_ => unreachable!("unxpected num bits for bool"),
})
}

View File

@@ -10,6 +10,7 @@ use crate::cdsl::types::{BVType, LaneType, ReferenceType, SpecialType, ValueType
const MAX_LANES: u16 = 256;
const MAX_BITS: u16 = 128;
const MAX_FLOAT_BITS: u16 = 64;
const MAX_BITVEC: u16 = MAX_BITS * MAX_LANES;
/// Type variables can be used in place of concrete types when defining
@@ -177,7 +178,7 @@ impl TypeVar {
"can't double all integer types"
);
assert!(
ts.floats.len() == 0 || *ts.floats.iter().max().unwrap() < MAX_BITS,
ts.floats.len() == 0 || *ts.floats.iter().max().unwrap() < MAX_FLOAT_BITS,
"can't double all float types"
);
assert!(
@@ -503,7 +504,7 @@ impl TypeSet {
copy.floats = NumSet::from_iter(
self.floats
.iter()
.filter(|&&x| x < MAX_BITS)
.filter(|&&x| x < MAX_FLOAT_BITS)
.map(|&x| x * 2),
);
copy.bools = NumSet::from_iter(
@@ -621,7 +622,7 @@ impl TypeSet {
let mut copy = self.clone();
copy.bitvecs = NumSet::new();
if self.bools.contains(&1) {
copy.ints = NumSet::from_iter(vec![8, 16, 32, 64]);
copy.ints = NumSet::from_iter(vec![8, 16, 32, 64, 128]);
copy.floats = NumSet::from_iter(vec![32, 64]);
} else {
copy.ints = &self.bools - &NumSet::from_iter(vec![1]);
@@ -950,7 +951,7 @@ fn test_typevar_builder() {
let type_set = TypeSetBuilder::new().ints(Interval::All).build();
assert_eq!(type_set.lanes, num_set![1]);
assert!(type_set.floats.is_empty());
assert_eq!(type_set.ints, num_set![8, 16, 32, 64]);
assert_eq!(type_set.ints, num_set![8, 16, 32, 64, 128]);
assert!(type_set.bools.is_empty());
assert!(type_set.bitvecs.is_empty());
assert!(type_set.specials.is_empty());
@@ -959,7 +960,7 @@ fn test_typevar_builder() {
assert_eq!(type_set.lanes, num_set![1]);
assert!(type_set.floats.is_empty());
assert!(type_set.ints.is_empty());
assert_eq!(type_set.bools, num_set![1, 8, 16, 32, 64]);
assert_eq!(type_set.bools, num_set![1, 8, 16, 32, 64, 128]);
assert!(type_set.bitvecs.is_empty());
assert!(type_set.specials.is_empty());
@@ -1101,7 +1102,7 @@ fn test_forward_images() {
);
assert_eq!(
TypeSetBuilder::new().ints(32..64).build().double_width(),
TypeSetBuilder::new().ints(64..64).build()
TypeSetBuilder::new().ints(64..128).build()
);
assert_eq!(
TypeSetBuilder::new().floats(32..32).build().double_width(),
@@ -1117,7 +1118,7 @@ fn test_forward_images() {
);
assert_eq!(
TypeSetBuilder::new().bools(32..64).build().double_width(),
TypeSetBuilder::new().bools(64..64).build()
TypeSetBuilder::new().bools(64..128).build()
);
}
@@ -1145,7 +1146,7 @@ fn test_backward_images() {
assert_eq!(
TypeSetBuilder::new()
.simd_lanes(1..4)
.bools(1..64)
.bools(1..128)
.build()
.preimage(DerivedFunc::AsBool),
TypeSetBuilder::new()
@@ -1205,9 +1206,9 @@ fn test_backward_images() {
// Half width.
assert_eq!(
TypeSetBuilder::new()
.ints(64..64)
.ints(128..128)
.floats(64..64)
.bools(64..64)
.bools(128..128)
.build()
.preimage(DerivedFunc::HalfWidth)
.size(),
@@ -1221,7 +1222,7 @@ fn test_backward_images() {
.preimage(DerivedFunc::HalfWidth),
TypeSetBuilder::new()
.simd_lanes(64..256)
.bools(16..64)
.bools(16..128)
.build(),
);